diff --git a/src/board_gruvin9x.cpp b/src/board_gruvin9x.cpp index 4bcf3da17..0628eac27 100644 --- a/src/board_gruvin9x.cpp +++ b/src/board_gruvin9x.cpp @@ -83,7 +83,7 @@ inline void board_init() utm.tm_min = rtc.min; utm.tm_sec = rtc.sec; utm.tm_wday = rtc.wday - 1; - g_unixTime = mktime(&utm); + g_unixTime = gmktime(&utm); #endif /***************************************************/ diff --git a/src/eeprom_arm.cpp b/src/eeprom_arm.cpp index c54ff81b3..556e2537a 100644 --- a/src/eeprom_arm.cpp +++ b/src/eeprom_arm.cpp @@ -906,6 +906,7 @@ uint32_t unprotect_eeprom() #if defined(SDCARD) FATFS g_FATFS_Obj; // TODO not here +#define FILENAME_MAXLEN 8 const pm_char * eeBackupModel(uint8_t i_fileSrc) { char *buf = reusableBuffer.models.mainname; @@ -929,9 +930,9 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc) buf[sizeof(MODELS_PATH)-1] = '/'; memcpy(&buf[sizeof(MODELS_PATH)], ModelNames[i_fileSrc], sizeof(g_model.name)); - buf[sizeof(MODELS_PATH)+sizeof(g_model.name)] = '\0'; + buf[sizeof(MODELS_PATH)+FILENAME_MAXLEN] = '\0'; - uint8_t i = sizeof(MODELS_PATH)+sizeof(g_model.name)-1; + uint8_t i = sizeof(MODELS_PATH)+FILENAME_MAXLEN-1; uint8_t len = 0; while (i>sizeof(MODELS_PATH)-1) { if (!len && buf[i]) diff --git a/src/eeprom_avr.cpp b/src/eeprom_avr.cpp index 4660d4bad..34940d3ba 100644 --- a/src/eeprom_avr.cpp +++ b/src/eeprom_avr.cpp @@ -531,6 +531,7 @@ bool RlcFile::copy(uint8_t i_fileDst, uint8_t i_fileSrc) } #if defined(SDCARD) +#define FILENAME_MAXLEN 8 const pm_char * eeBackupModel(uint8_t i_fileSrc) { char *buf = reusableBuffer.models.mainname; @@ -538,25 +539,29 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc) DIR archiveFolder; UINT written; +#ifndef SIMU FRESULT result = f_mount(0, &g_FATFS_Obj); if (result != FR_OK) { return SDCARD_ERROR(result); } +#endif // check and create folder here strcpy_P(buf, STR_MODELS_PATH); +#ifndef SIMU result = f_opendir(&archiveFolder, buf); if (result != FR_OK) { result = f_mkdir(buf); if (result != FR_OK) return SDCARD_ERROR(result); } +#endif buf[sizeof(MODELS_PATH)-1] = '/'; eeLoadModelName(i_fileSrc, &buf[sizeof(MODELS_PATH)]); - buf[sizeof(MODELS_PATH)+sizeof(g_model.name)] = '\0'; + buf[sizeof(MODELS_PATH)+FILENAME_MAXLEN] = '\0'; - uint8_t i = sizeof(MODELS_PATH)+sizeof(g_model.name)-1; + uint8_t i = sizeof(MODELS_PATH)+FILENAME_MAXLEN-1; uint8_t len = 0; while (i>sizeof(MODELS_PATH)-1) { if (!len && buf[i]) @@ -576,6 +581,11 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc) strcpy_P(&buf[len], STR_MODELS_EXT); +#ifdef SIMU + printf("SD-card backup filename=%s\n", buf); fflush(stdout); + FRESULT +#endif + result = f_open(&archiveFile, buf, FA_OPEN_ALWAYS | FA_WRITE); if (result != FR_OK) { return SDCARD_ERROR(result); diff --git a/src/ersky9x/gtime.cpp b/src/ersky9x/gtime.cpp index ebe0069dd..3830a7cff 100644 --- a/src/ersky9x/gtime.cpp +++ b/src/ersky9x/gtime.cpp @@ -479,7 +479,7 @@ __mktime_internal (struct gtm *tp, /* Convert *TP to a gtime_t value. */ gtime_t -mktime (struct gtm *tp) +gmktime (struct gtm *tp) { // no time zone stuff. Just do the math ;) static gtime_t localtime_offset; diff --git a/src/ersky9x/gtime.h b/src/ersky9x/gtime.h index b275827cf..8126d8375 100644 --- a/src/ersky9x/gtime.h +++ b/src/ersky9x/gtime.h @@ -56,7 +56,7 @@ struct gtm extern const unsigned short int __mon_yday[2][13]; -extern gtime_t mktime(struct gtm *tp); +extern gtime_t gmktime(struct gtm *tp); extern gtime_t filltm(gtime_t *t, struct gtm *tp); #endif diff --git a/src/general_menus.cpp b/src/general_menus.cpp index 1b12476ab..b3303f67a 100644 --- a/src/general_menus.cpp +++ b/src/general_menus.cpp @@ -423,7 +423,7 @@ void menuProcTime(uint8_t event) if (sub >= 0 && s_editMode<=0) // set the date and time into RTC chip { g_ms100 = 0; // start of next second begins now - g_unixTime = mktime(&t); // update local timestamp and get wday calculated + g_unixTime = gmktime(&t); // update local timestamp and get wday calculated RTC rtc; rtc.year = t.tm_year + 1900; diff --git a/src/gruvin9x/gtime.cpp b/src/gruvin9x/gtime.cpp index ebe0069dd..60d8d6f63 100644 --- a/src/gruvin9x/gtime.cpp +++ b/src/gruvin9x/gtime.cpp @@ -31,7 +31,7 @@ * */ -#include "gtime.h" +#include "../open9x.h" #define LEAP_SECONDS_POSSIBLE 0 @@ -479,7 +479,7 @@ __mktime_internal (struct gtm *tp, /* Convert *TP to a gtime_t value. */ gtime_t -mktime (struct gtm *tp) +gmktime (struct gtm *tp) { // no time zone stuff. Just do the math ;) static gtime_t localtime_offset; diff --git a/src/gruvin9x/gtime.h b/src/gruvin9x/gtime.h index b275827cf..8126d8375 100644 --- a/src/gruvin9x/gtime.h +++ b/src/gruvin9x/gtime.h @@ -56,7 +56,7 @@ struct gtm extern const unsigned short int __mon_yday[2][13]; -extern gtime_t mktime(struct gtm *tp); +extern gtime_t gmktime(struct gtm *tp); extern gtime_t filltm(gtime_t *t, struct gtm *tp); #endif diff --git a/src/gruvin9x/sdcard.h b/src/gruvin9x/sdcard.h index 028edeeda..30c6e0062 100644 --- a/src/gruvin9x/sdcard.h +++ b/src/gruvin9x/sdcard.h @@ -53,7 +53,7 @@ extern FIL g_oLogFile; extern void initLogs(); extern void writeLogs(); -const pm_char *SDCARD_ERROR(FRESULT result) +inline const pm_char *SDCARD_ERROR(FRESULT result) { if (result == FR_NOT_READY) return STR_NO_SDCARD;