|
@ -69,12 +69,12 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui |
|
|
std::size_t bytes_written = 0; |
|
|
std::size_t bytes_written = 0; |
|
|
|
|
|
|
|
|
for (std::size_t i = 0; i < size; i++) { |
|
|
for (std::size_t i = 0; i < size; i++) { |
|
|
buffer[pos+i] = value[i]; |
|
|
buffer[pos + i] = value[i]; |
|
|
bytes_written ++; |
|
|
bytes_written++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
crc16(crc, value, size); |
|
|
crc16(crc, value, size); |
|
|
pos = pos + size; |
|
|
pos += size; |
|
|
return (bytes_written != size); // return true for any error
|
|
|
return (bytes_written != size); // return true for any error
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -82,21 +82,21 @@ bool PersistentStore::read_data(int &pos, uint8_t *value, const size_t size, uin |
|
|
std::size_t bytes_read = 0; |
|
|
std::size_t bytes_read = 0; |
|
|
if (writing) { |
|
|
if (writing) { |
|
|
for (std::size_t i = 0; i < size; i++) { |
|
|
for (std::size_t i = 0; i < size; i++) { |
|
|
value[i] = buffer[pos+i]; |
|
|
value[i] = buffer[pos + i]; |
|
|
bytes_read ++; |
|
|
bytes_read++; |
|
|
} |
|
|
} |
|
|
crc16(crc, value, size); |
|
|
crc16(crc, value, size); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
uint8_t temp[size]; |
|
|
uint8_t temp[size]; |
|
|
for (std::size_t i = 0; i < size; i++) { |
|
|
for (std::size_t i = 0; i < size; i++) { |
|
|
temp[i] = buffer[pos+i]; |
|
|
temp[i] = buffer[pos + i]; |
|
|
bytes_read ++; |
|
|
bytes_read++; |
|
|
} |
|
|
} |
|
|
crc16(crc, temp, size); |
|
|
crc16(crc, temp, size); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
pos = pos + size; |
|
|
pos += size; |
|
|
return bytes_read != size; // return true for any error
|
|
|
return bytes_read != size; // return true for any error
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|