Add backup checksum

save_scan
erikkaashoek 3 years ago
parent aaf72f8adb
commit 6df64d7d38

@ -172,9 +172,17 @@ static THD_FUNCTION(Thread1, arg)
b.RBW = SI4432_rbw_selected+1; b.RBW = SI4432_rbw_selected+1;
#endif #endif
b.mode = setting.mode; b.mode = setting.mode;
b.checksum = 0;
uint8_t *c = (uint8_t *)&b;
int ci = USED_BACKUP_SIZE*4;
uint8_t checksum = 0x55;
while (ci--) {
checksum ^= *c++;
}
b.checksum = checksum;
uint32_t *f = (uint32_t *)&b; uint32_t *f = (uint32_t *)&b;
uint32_t *t = &backup; uint32_t *t = &backup;
int i = USED_BACKUP_SIZE; int i = USED_BACKUP_SIZE+1;
while (i--) while (i--)
*t++ = *f++; *t++ = *f++;
@ -2928,9 +2936,16 @@ int main(void)
backup_t b; backup_t b;
uint32_t *f = &backup; uint32_t *f = &backup;
uint32_t *t = (uint32_t *)&b; uint32_t *t = (uint32_t *)&b;
int i = USED_BACKUP_SIZE; int i = USED_BACKUP_SIZE+1;
while (i--) while (i--)
*t++ = *f++; *t++ = *f++;
uint8_t *c = (uint8_t *)&b;
int ci = USED_BACKUP_SIZE*3;
uint8_t checksum = 0x55;
while (ci--) {
checksum ^= *c++;
}
if (b.checksum == checksum) {
#ifdef TINYSA4 // Set mode not working reliably #ifdef TINYSA4 // Set mode not working reliably
set_mode(b.mode); set_mode(b.mode);
switch (b.mode) { switch (b.mode) {
@ -2974,6 +2989,7 @@ int main(void)
} }
} }
} }
}
set_refer_output(-1); set_refer_output(-1);
// ui_mode_menu(); // Show menu when autostarting mode // ui_mode_menu(); // Show menu when autostarting mode

@ -1709,6 +1709,7 @@ typedef struct {
uint8_t reflevel; uint8_t reflevel;
uint8_t RBW; uint8_t RBW;
uint8_t mode; uint8_t mode;
uint8_t checksum;
} backup_t; } backup_t;
#pragma pack(pop) #pragma pack(pop)

Loading…
Cancel
Save

Powered by TurnKey Linux.