Skip to content

Commit

Permalink
fixing build
Browse files Browse the repository at this point in the history
  • Loading branch information
cagnulein committed Dec 25, 2024
1 parent 9c79549 commit b869a41
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/devices/kineticinroadbike/SmartControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "SmartControl.h"
#include <random>
#include <vector>

#define SensorHz 10000

Expand Down Expand Up @@ -83,12 +84,12 @@ double smart_control_ticks_to_seconds(uint32_t ticks)
smart_control_power_data smart_control_process_power_data(uint8_t *data, size_t size)
{
uint8_t hashSeed = 0x42;
uint8_t inData[size];
for (int i = 0; i < size; ++i) {
std::vector<uint8_t> inData(size); // Use vector instead of VLA
for (size_t i = 0; i < size; ++i) {
inData[i] = data[i];
}
uint8_t hash = hash8WithSeed(hashSeed, &inData[size - 1], 1);
for (unsigned index = 0; index < size - 1; index++) {
for (size_t index = 0; index < size - 1; index++) {
inData[index] ^= hash;
hash = hash8WithSeed(hash, &inData[index], 1);
}
Expand Down Expand Up @@ -122,20 +123,19 @@ smart_control_power_data smart_control_process_power_data(uint8_t *data, size_t
smart_control_config_data smart_control_process_config_data(uint8_t *data, size_t size)
{
uint8_t hashSeed = 0x42;
uint8_t inData[size];
for (int i = 0; i < size; ++i) {
std::vector<uint8_t> inData(size); // Use vector instead of VLA
for (size_t i = 0; i < size; ++i) {
inData[i] = data[i];
}
uint8_t hash = hash8WithSeed(hashSeed, &inData[size - 1], 1);
for (unsigned index = 0; index < size - 1; index++) {
for (size_t index = 0; index < size - 1; index++) {
inData[index] ^= hash;
hash = hash8WithSeed(hash, &inData[index], 1);
}

smart_control_config_data configData;

if (size >= 5) {

configData.updateRate = inData[0];
configData.tickRate = ((uint32_t)inData[1] << 16) | ((uint32_t)inData[2] << 8) | (uint32_t)inData[3];
configData.firmwareUpdateState = inData[4];
Expand Down

0 comments on commit b869a41

Please sign in to comment.