Problem with invalid EEPROMS

This commit is contained in:
bsongis
2012-01-28 15:32:08 +00:00
parent 0af7630523
commit 4776415c14
+7 -12
View File
@@ -47,19 +47,15 @@ void generalDefault()
bool eeLoadGeneral() bool eeLoadGeneral()
{ {
theFile.openRlc(FILE_GENERAL); theFile.openRlc(FILE_GENERAL);
uint8_t sz = 0; if (theFile.readRlc((uint8_t*)&g_eeGeneral, 1) == 1 && g_eeGeneral.myVers == EEPROM_VER) {
if (theFile.readRlc((uint8_t*)&g_eeGeneral, 1) == 1) {
theFile.openRlc(FILE_GENERAL); // TODO include this openRlc inside readRlc theFile.openRlc(FILE_GENERAL); // TODO include this openRlc inside readRlc
if (g_eeGeneral.myVers == EEPROM_VER) { if (theFile.readRlc((uint8_t*)&g_eeGeneral, sizeof(g_eeGeneral)) <= sizeof(EEGeneral)) {
sz = theFile.readRlc((uint8_t*)&g_eeGeneral, sizeof(g_eeGeneral));
}
}
if (sz <= sizeof(EEGeneral)) {
uint16_t sum=0; uint16_t sum=0;
for (int i=0; i<12;i++) sum += g_eeGeneral.calibMid[i]; for (int i=0; i<12;i++) sum += g_eeGeneral.calibMid[i];
return g_eeGeneral.chkSum == sum; if (g_eeGeneral.chkSum == sum) {
return true;
}
}
} }
return false; return false;
} }
@@ -173,8 +169,7 @@ void eeReadAll()
{ {
if(!EeFsOpen() || if(!EeFsOpen() ||
EeFsck() < 0 || EeFsck() < 0 ||
!eeLoadGeneral() !eeLoadGeneral())
)
{ {
alert(STR_BADEEPROMDATA, true); alert(STR_BADEEPROMDATA, true);
message(STR_EEPROMFORMATTING); message(STR_EEPROMFORMATTING);