mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-31 12:23:23 +08:00
[sdlog] don't open log nor monitor battery if init fails
this protect when starting a log without SD card...
This commit is contained in:
@@ -159,23 +159,27 @@ static void thd_startlog(void *arg)
|
|||||||
// Check for init errors
|
// Check for init errors
|
||||||
sdOk = true;
|
sdOk = true;
|
||||||
|
|
||||||
if (sdLogInit (NULL) != SDLOG_OK)
|
if (sdLogInit (NULL) != SDLOG_OK) {
|
||||||
sdOk = false;
|
|
||||||
|
|
||||||
removeEmptyLogs (PPRZ_LOG_DIR, PPRZ_LOG_NAME, 50);
|
|
||||||
if (sdLogOpenLog (&pprzLogFile, PPRZ_LOG_DIR, PPRZ_LOG_NAME, true) != SDLOG_OK)
|
|
||||||
sdOk = false;
|
sdOk = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
removeEmptyLogs (PPRZ_LOG_DIR, PPRZ_LOG_NAME, 50);
|
||||||
|
if (sdLogOpenLog (&pprzLogFile, PPRZ_LOG_DIR, PPRZ_LOG_NAME, true) != SDLOG_OK)
|
||||||
|
sdOk = false;
|
||||||
|
|
||||||
#if FLIGHTRECORDER_SDLOG
|
#if FLIGHTRECORDER_SDLOG
|
||||||
removeEmptyLogs (FR_LOG_DIR, FLIGHTRECORDER_LOG_NAME, 50);
|
removeEmptyLogs (FR_LOG_DIR, FLIGHTRECORDER_LOG_NAME, 50);
|
||||||
if (sdLogOpenLog (&flightRecorderLogFile, FR_LOG_DIR, FLIGHTRECORDER_LOG_NAME, false) != SDLOG_OK)
|
if (sdLogOpenLog (&flightRecorderLogFile, FR_LOG_DIR, FLIGHTRECORDER_LOG_NAME, false) != SDLOG_OK)
|
||||||
sdOk = false;
|
sdOk = false;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Create Battery Survey Thread with event
|
if (sdOk) {
|
||||||
chEvtObjectInit (&powerOutageSource);
|
// Create Battery Survey Thread with event
|
||||||
chThdCreateStatic (wa_thd_bat_survey, sizeof(wa_thd_bat_survey),
|
chEvtObjectInit (&powerOutageSource);
|
||||||
NORMALPRIO+2, thd_bat_survey, NULL);
|
chThdCreateStatic (wa_thd_bat_survey, sizeof(wa_thd_bat_survey),
|
||||||
|
NORMALPRIO+2, thd_bat_survey, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
#ifdef LED_SDLOG
|
#ifdef LED_SDLOG
|
||||||
@@ -185,12 +189,6 @@ static void thd_startlog(void *arg)
|
|||||||
chThdSleepMilliseconds (sdOk == true ? 1000 : 200);
|
chThdSleepMilliseconds (sdOk == true ? 1000 : 200);
|
||||||
static uint32_t timestamp = 0;
|
static uint32_t timestamp = 0;
|
||||||
|
|
||||||
// FIXME what is this doing ? -> ask Alex
|
|
||||||
thread_t *tp = chRegFirstThread();
|
|
||||||
do {
|
|
||||||
tp = chRegNextThread(tp);
|
|
||||||
} while (tp != NULL);
|
|
||||||
|
|
||||||
#if HAL_USE_RTC
|
#if HAL_USE_RTC
|
||||||
// FIXME this could be done somewhere else, like in sys_time
|
// FIXME this could be done somewhere else, like in sys_time
|
||||||
// we sync gps time to rtc every 5 seconds
|
// we sync gps time to rtc every 5 seconds
|
||||||
|
|||||||
Reference in New Issue
Block a user