mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-01 21:07:40 +08:00
[modules] Fix SD logger errors
This commit is contained in:
@@ -196,10 +196,6 @@ void sdlog_chibios_init(void)
|
|||||||
void sdlog_chibios_finish(const bool flush)
|
void sdlog_chibios_finish(const bool flush)
|
||||||
{
|
{
|
||||||
if (pprzLogFile != -1) {
|
if (pprzLogFile != -1) {
|
||||||
// disable all required periph to save energy and maximize chance to flush files
|
|
||||||
// to mass storage and avoid infamous dirty bit on filesystem
|
|
||||||
mcu_energy_save();
|
|
||||||
|
|
||||||
// if a FF_FS_REENTRANT is true, we can umount fs without closing
|
// if a FF_FS_REENTRANT is true, we can umount fs without closing
|
||||||
// file, fatfs lock will assure that umount is done after a write,
|
// file, fatfs lock will assure that umount is done after a write,
|
||||||
// and umount will close all open files cleanly. Thats the fatest
|
// and umount will close all open files cleanly. Thats the fatest
|
||||||
@@ -214,9 +210,9 @@ void sdlog_chibios_finish(const bool flush)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
sdLogFinish();
|
sdLogFinish();
|
||||||
pprzLogFile = 0;
|
pprzLogFile = -1;
|
||||||
#if FLIGHTRECORDER_SDLOG
|
#if FLIGHTRECORDER_SDLOG
|
||||||
flightRecorderLogFile = 0;
|
flightRecorderLogFile = -1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
chibios_sdlog_status = SDLOG_STOPPED;
|
chibios_sdlog_status = SDLOG_STOPPED;
|
||||||
@@ -321,15 +317,21 @@ static void thd_bat_survey(void *arg)
|
|||||||
register_adc_watchdog(&SDLOG_BAT_ADC, SDLOG_BAT_CHAN, V_ALERT, &powerOutageIsr);
|
register_adc_watchdog(&SDLOG_BAT_ADC, SDLOG_BAT_CHAN, V_ALERT, &powerOutageIsr);
|
||||||
|
|
||||||
chEvtWaitOne(EVENT_MASK(1));
|
chEvtWaitOne(EVENT_MASK(1));
|
||||||
|
// Only try to energy save is it is really a problem and not powered through USB
|
||||||
|
if (palReadPad(SDLOG_USB_VBUS_PORT, SDLOG_USB_VBUS_PIN) == PAL_LOW) {
|
||||||
|
// disable all required periph to save energy and maximize chance to flush files
|
||||||
|
// to mass storage and avoid infamous dirty bit on filesystem
|
||||||
|
mcu_energy_save();
|
||||||
|
}
|
||||||
|
|
||||||
// in case of powerloss, we should go fast and avoid to flush ram buffer
|
// in case of powerloss, we should go fast and avoid to flush ram buffer
|
||||||
sdlog_chibios_finish(false);
|
sdlog_chibios_finish(false);
|
||||||
chThdExit(0);
|
|
||||||
|
|
||||||
// Only put to deep sleep in case there is no power on the USB
|
// Only put to deep sleep in case there is no power on the USB
|
||||||
if (palReadPad(SDLOG_USB_VBUS_PORT, SDLOG_USB_VBUS_PIN) == PAL_LOW) {
|
if (palReadPad(SDLOG_USB_VBUS_PORT, SDLOG_USB_VBUS_PIN) == PAL_LOW) {
|
||||||
mcu_reboot(MCU_REBOOT_POWEROFF);
|
mcu_reboot(MCU_REBOOT_POWEROFF);
|
||||||
}
|
}
|
||||||
chThdSleep(TIME_INFINITE);
|
chThdExit(0);
|
||||||
while (true); // never goes here, only to avoid compiler warning: 'noreturn' function does return
|
while (true); // never goes here, only to avoid compiler warning: 'noreturn' function does return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -293,6 +293,7 @@ SdioError sdLogOpenLog(FileDes *fd, const char *directoryName, const char *prefi
|
|||||||
sde = getFileName(prefix, directoryName, fileName, nameLength, +1);
|
sde = getFileName(prefix, directoryName, fileName, nameLength, +1);
|
||||||
if (sde != SDLOG_OK) {
|
if (sde != SDLOG_OK) {
|
||||||
// sd card is not inserted, so logging task can be deleted
|
// sd card is not inserted, so logging task can be deleted
|
||||||
|
fileDes[ldf].inUse = false;
|
||||||
return storageStatus = SDLOG_FATFS_ERROR;
|
return storageStatus = SDLOG_FATFS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user