Add MarlinSettings::validate()

This commit is contained in:
Scott Lahteine
2018-01-04 19:51:18 -06:00
parent 878f54c27b
commit 51e0f2bee3
12 changed files with 192 additions and 138 deletions

View File

@ -128,7 +128,7 @@ bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
return (bytes_written != size); // return true for any error
}
bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const bool writing/*=true*/) {
UINT bytes_read = 0;
FRESULT s;
s = f_lseek(&eeprom_file, pos);
@ -140,7 +140,15 @@ bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
SERIAL_PROTOCOLLNPAIR(" f_lseek()=", (int)s);
return true;
}
s = f_read(&eeprom_file, (void *)value, size, &bytes_read);
if (writing) {
s = f_read(&eeprom_file, (void *)value, size, &bytes_read);
crc16(crc, value, size);
}
else {
uint8_t temp[size];
s = f_read(&eeprom_file, (void *)temp, size, &bytes_read);
crc16(crc, temp, size);
}
if (s) {
SERIAL_PROTOCOLPAIR(" read_data(", pos); // This extra chit-chat goes away soon. But it is helpful
SERIAL_PROTOCOLPAIR(",", (int)value); // right now to see errors that are happening in the
@ -151,7 +159,6 @@ bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
SERIAL_PROTOCOLLNPAIR("\n bytes_read=", bytes_read);
return true;
}
crc16(crc, value, size);
pos = pos + size;
return bytes_read != size; // return true for any error
}