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