SD-card Model Backup bug when model name greater than 8 chars
This commit is contained in:
@@ -83,7 +83,7 @@ inline void board_init()
|
|||||||
utm.tm_min = rtc.min;
|
utm.tm_min = rtc.min;
|
||||||
utm.tm_sec = rtc.sec;
|
utm.tm_sec = rtc.sec;
|
||||||
utm.tm_wday = rtc.wday - 1;
|
utm.tm_wday = rtc.wday - 1;
|
||||||
g_unixTime = mktime(&utm);
|
g_unixTime = gmktime(&utm);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/***************************************************/
|
/***************************************************/
|
||||||
|
|||||||
+3
-2
@@ -906,6 +906,7 @@ uint32_t unprotect_eeprom()
|
|||||||
|
|
||||||
#if defined(SDCARD)
|
#if defined(SDCARD)
|
||||||
FATFS g_FATFS_Obj; // TODO not here
|
FATFS g_FATFS_Obj; // TODO not here
|
||||||
|
#define FILENAME_MAXLEN 8
|
||||||
const pm_char * eeBackupModel(uint8_t i_fileSrc)
|
const pm_char * eeBackupModel(uint8_t i_fileSrc)
|
||||||
{
|
{
|
||||||
char *buf = reusableBuffer.models.mainname;
|
char *buf = reusableBuffer.models.mainname;
|
||||||
@@ -929,9 +930,9 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc)
|
|||||||
|
|
||||||
buf[sizeof(MODELS_PATH)-1] = '/';
|
buf[sizeof(MODELS_PATH)-1] = '/';
|
||||||
memcpy(&buf[sizeof(MODELS_PATH)], ModelNames[i_fileSrc], sizeof(g_model.name));
|
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;
|
uint8_t len = 0;
|
||||||
while (i>sizeof(MODELS_PATH)-1) {
|
while (i>sizeof(MODELS_PATH)-1) {
|
||||||
if (!len && buf[i])
|
if (!len && buf[i])
|
||||||
|
|||||||
+12
-2
@@ -531,6 +531,7 @@ bool RlcFile::copy(uint8_t i_fileDst, uint8_t i_fileSrc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(SDCARD)
|
#if defined(SDCARD)
|
||||||
|
#define FILENAME_MAXLEN 8
|
||||||
const pm_char * eeBackupModel(uint8_t i_fileSrc)
|
const pm_char * eeBackupModel(uint8_t i_fileSrc)
|
||||||
{
|
{
|
||||||
char *buf = reusableBuffer.models.mainname;
|
char *buf = reusableBuffer.models.mainname;
|
||||||
@@ -538,25 +539,29 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc)
|
|||||||
DIR archiveFolder;
|
DIR archiveFolder;
|
||||||
UINT written;
|
UINT written;
|
||||||
|
|
||||||
|
#ifndef SIMU
|
||||||
FRESULT result = f_mount(0, &g_FATFS_Obj);
|
FRESULT result = f_mount(0, &g_FATFS_Obj);
|
||||||
if (result != FR_OK) {
|
if (result != FR_OK) {
|
||||||
return SDCARD_ERROR(result);
|
return SDCARD_ERROR(result);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// check and create folder here
|
// check and create folder here
|
||||||
strcpy_P(buf, STR_MODELS_PATH);
|
strcpy_P(buf, STR_MODELS_PATH);
|
||||||
|
#ifndef SIMU
|
||||||
result = f_opendir(&archiveFolder, buf);
|
result = f_opendir(&archiveFolder, buf);
|
||||||
if (result != FR_OK) {
|
if (result != FR_OK) {
|
||||||
result = f_mkdir(buf);
|
result = f_mkdir(buf);
|
||||||
if (result != FR_OK)
|
if (result != FR_OK)
|
||||||
return SDCARD_ERROR(result);
|
return SDCARD_ERROR(result);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
buf[sizeof(MODELS_PATH)-1] = '/';
|
buf[sizeof(MODELS_PATH)-1] = '/';
|
||||||
eeLoadModelName(i_fileSrc, &buf[sizeof(MODELS_PATH)]);
|
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;
|
uint8_t len = 0;
|
||||||
while (i>sizeof(MODELS_PATH)-1) {
|
while (i>sizeof(MODELS_PATH)-1) {
|
||||||
if (!len && buf[i])
|
if (!len && buf[i])
|
||||||
@@ -576,6 +581,11 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc)
|
|||||||
|
|
||||||
strcpy_P(&buf[len], STR_MODELS_EXT);
|
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);
|
result = f_open(&archiveFile, buf, FA_OPEN_ALWAYS | FA_WRITE);
|
||||||
if (result != FR_OK) {
|
if (result != FR_OK) {
|
||||||
return SDCARD_ERROR(result);
|
return SDCARD_ERROR(result);
|
||||||
|
|||||||
@@ -479,7 +479,7 @@ __mktime_internal (struct gtm *tp,
|
|||||||
|
|
||||||
/* Convert *TP to a gtime_t value. */
|
/* Convert *TP to a gtime_t value. */
|
||||||
gtime_t
|
gtime_t
|
||||||
mktime (struct gtm *tp)
|
gmktime (struct gtm *tp)
|
||||||
{
|
{
|
||||||
// no time zone stuff. Just do the math ;)
|
// no time zone stuff. Just do the math ;)
|
||||||
static gtime_t localtime_offset;
|
static gtime_t localtime_offset;
|
||||||
|
|||||||
+1
-1
@@ -56,7 +56,7 @@ struct gtm
|
|||||||
|
|
||||||
extern const unsigned short int __mon_yday[2][13];
|
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);
|
extern gtime_t filltm(gtime_t *t, struct gtm *tp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -423,7 +423,7 @@ void menuProcTime(uint8_t event)
|
|||||||
if (sub >= 0 && s_editMode<=0) // set the date and time into RTC chip
|
if (sub >= 0 && s_editMode<=0) // set the date and time into RTC chip
|
||||||
{
|
{
|
||||||
g_ms100 = 0; // start of next second begins now
|
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 rtc;
|
||||||
rtc.year = t.tm_year + 1900;
|
rtc.year = t.tm_year + 1900;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gtime.h"
|
#include "../open9x.h"
|
||||||
|
|
||||||
#define LEAP_SECONDS_POSSIBLE 0
|
#define LEAP_SECONDS_POSSIBLE 0
|
||||||
|
|
||||||
@@ -479,7 +479,7 @@ __mktime_internal (struct gtm *tp,
|
|||||||
|
|
||||||
/* Convert *TP to a gtime_t value. */
|
/* Convert *TP to a gtime_t value. */
|
||||||
gtime_t
|
gtime_t
|
||||||
mktime (struct gtm *tp)
|
gmktime (struct gtm *tp)
|
||||||
{
|
{
|
||||||
// no time zone stuff. Just do the math ;)
|
// no time zone stuff. Just do the math ;)
|
||||||
static gtime_t localtime_offset;
|
static gtime_t localtime_offset;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ struct gtm
|
|||||||
|
|
||||||
extern const unsigned short int __mon_yday[2][13];
|
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);
|
extern gtime_t filltm(gtime_t *t, struct gtm *tp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ extern FIL g_oLogFile;
|
|||||||
extern void initLogs();
|
extern void initLogs();
|
||||||
extern void writeLogs();
|
extern void writeLogs();
|
||||||
|
|
||||||
const pm_char *SDCARD_ERROR(FRESULT result)
|
inline const pm_char *SDCARD_ERROR(FRESULT result)
|
||||||
{
|
{
|
||||||
if (result == FR_NOT_READY)
|
if (result == FR_NOT_READY)
|
||||||
return STR_NO_SDCARD;
|
return STR_NO_SDCARD;
|
||||||
|
|||||||
Reference in New Issue
Block a user