Fix SD card version check

This commit is contained in:
Andre Bernet
2016-08-27 15:11:54 +02:00
parent c5346f6846
commit 508e3e899c
3 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -1 +1 @@
2.2V0001
2.2V0001
+1 -1
View File
@@ -1 +1 @@
2.2V0001
2.2V0001
+6 -6
View File
@@ -1090,19 +1090,19 @@ void checkSDVersion()
if (sdMounted()) {
FIL versionFile = {0};
UINT read = 0;
char version[sizeof(REQUIRED_SDCARD_VERSION)];
char version[sizeof(REQUIRED_SDCARD_VERSION)-1];
FRESULT result = f_open(&versionFile, "/opentx.sdcard.version", FA_OPEN_EXISTING | FA_READ);
if ((result == FR_OK) && (f_size(&versionFile) == sizeof(REQUIRED_SDCARD_VERSION))) {
f_read(&versionFile, &version, sizeof(REQUIRED_SDCARD_VERSION), &read);
if (strncmp(version, REQUIRED_SDCARD_VERSION, sizeof(REQUIRED_SDCARD_VERSION)-1) != 0) {
if ((result == FR_OK) && (f_size(&versionFile) == sizeof(version))) {
f_read(&versionFile, &version, sizeof(version), &read);
if (strncmp(version, REQUIRED_SDCARD_VERSION, sizeof(version)) != 0) {
TRACE("sdCheckVersion FAILED: version are not the same");
ALERT(STR_SDCARD_ERROR, STR_WRONG_SDCARDVERSION, AU_ERROR);
ALERT(STR_SD_CARD, STR_WRONG_SDCARDVERSION, AU_ERROR);
}
}
else {
TRACE("sdCheckVersion FAILED: opentx.sdcard.version cannot be opened");
ALERT(STR_SDCARD_ERROR, STR_WRONG_SDCARDVERSION, AU_ERROR);
ALERT(STR_SD_CARD, STR_WRONG_SDCARDVERSION, AU_ERROR);
}
f_close(&versionFile);
}