SD-card Model Backup bug when model name greater than 8 chars

This commit is contained in:
bsongis
2012-05-23 12:18:24 +00:00
parent f9673e3b8b
commit e32eeec487
9 changed files with 23 additions and 12 deletions
+1 -1
View File
@@ -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
/***************************************************/
+3 -2
View File
@@ -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])
+12 -2
View File
@@ -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);
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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;
+2 -2
View File
@@ -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;
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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;