diff --git a/conf/modules/flight_recorder.xml b/conf/modules/flight_recorder.xml index 862b503f77..d76c7998f2 100644 --- a/conf/modules/flight_recorder.xml +++ b/conf/modules/flight_recorder.xml @@ -15,7 +15,7 @@ - + diff --git a/sw/airborne/modules/loggers/sdlog_chibios.c b/sw/airborne/modules/loggers/sdlog_chibios.c index 43ea3bf08f..39b4eec7b8 100644 --- a/sw/airborne/modules/loggers/sdlog_chibios.c +++ b/sw/airborne/modules/loggers/sdlog_chibios.c @@ -29,6 +29,7 @@ #include #include "modules/loggers/sdlog_chibios/sdLog.h" #include "modules/loggers/sdlog_chibios/usbStorage.h" +#include "modules/loggers/sdlog_chibios/printf.h" #include "modules/loggers/sdlog_chibios.h" #include "modules/tlsf/tlsf_malloc.h" #include "mcu_periph/adc.h" @@ -100,6 +101,10 @@ static enum { SDLOG_ERROR } chibios_sdlog_status; +/** sdlog filenames + */ +static char chibios_sdlog_filenames[68]; + #if PERIODIC_TELEMETRY #include "subsystems/datalink/telemetry.h" static void send_sdlog_status(struct transport_tx *trans, struct link_device *dev) @@ -107,7 +112,7 @@ static void send_sdlog_status(struct transport_tx *trans, struct link_device *de uint8_t status = (uint8_t) chibios_sdlog_status; uint8_t errno = (uint8_t) sdLogGetStorageStatus(); uint32_t used = (uint32_t) sdLogGetNbBytesWrittenToStorage(); - pprz_msg_send_LOGGER_STATUS(trans, dev, AC_ID, &status, &errno, &used); + pprz_msg_send_LOGGER_STATUS(trans, dev, AC_ID, &status, &errno, &used, strlen(chibios_sdlog_filenames), chibios_sdlog_filenames); } #endif @@ -212,6 +217,7 @@ static void thd_startlog(void *arg) { (void) arg; chRegSetThreadName("start log"); + char tmpFilename[32]; // Wait before starting the log if needed chThdSleepSeconds(SDLOG_START_DELAY); @@ -232,16 +238,18 @@ static void thd_startlog(void *arg) removeEmptyLogs(PPRZ_LOG_DIR, PPRZ_LOG_NAME, 50); if (sdLogOpenLog(&pprzLogFile, PPRZ_LOG_DIR, PPRZ_LOG_NAME, SDLOG_AUTO_FLUSH_PERIOD, LOG_APPEND_TAG_AT_CLOSE_DISABLED, - SDLOG_CONTIGUOUS_STORAGE_MEM, LOG_PREALLOCATION_DISABLED) != SDLOG_OK) { + SDLOG_CONTIGUOUS_STORAGE_MEM, LOG_PREALLOCATION_DISABLED, tmpFilename, sizeof(tmpFilename)) != SDLOG_OK) { sdOk = false; } + chsnprintf(chibios_sdlog_filenames, sizeof(chibios_sdlog_filenames), "%s", tmpFilename); #if FLIGHTRECORDER_SDLOG removeEmptyLogs(FR_LOG_DIR, FLIGHTRECORDER_LOG_NAME, 50); if (sdLogOpenLog(&flightRecorderLogFile, FR_LOG_DIR, FLIGHTRECORDER_LOG_NAME, SDLOG_AUTO_FLUSH_PERIOD, LOG_APPEND_TAG_AT_CLOSE_DISABLED, - SDLOG_CONTIGUOUS_STORAGE_MEM, LOG_PREALLOCATION_DISABLED) != SDLOG_OK) { + SDLOG_CONTIGUOUS_STORAGE_MEM, LOG_PREALLOCATION_DISABLED, tmpFilename, sizeof(tmpFilename)) != SDLOG_OK) { sdOk = false; } + chsnprintf(chibios_sdlog_filenames, sizeof(chibios_sdlog_filenames), ", %s", tmpFilename); #endif } diff --git a/sw/airborne/modules/loggers/sdlog_chibios/sdLog.c b/sw/airborne/modules/loggers/sdlog_chibios/sdLog.c index 712137a018..fd0b01e369 100644 --- a/sw/airborne/modules/loggers/sdlog_chibios/sdLog.c +++ b/sw/airborne/modules/loggers/sdlog_chibios/sdLog.c @@ -282,13 +282,12 @@ SdioError sdLogFinish(void) #ifdef SDLOG_NEED_QUEUE SdioError sdLogOpenLog(FileDes *fd, const char *directoryName, const char *prefix, const uint32_t autoFlushPeriod, const bool appendTagAtClose, - const size_t sizeInMo, const bool preallocate) + const size_t sizeInMo, const bool preallocate, char *fileName, const size_t nameLength) { FRESULT rc; /* fatfs result code */ SdioError sde = SDLOG_OK; /* sdio result code */ //DIR dir; /* Directory object */ //FILINFO fno; /* File information object */ - char fileName[32]; /* local file descriptor using fd is a bad idea since fd is set before fatfs objets are coherents @@ -302,7 +301,7 @@ SdioError sdLogOpenLog(FileDes *fd, const char *directoryName, const char *prefi return storageStatus = sde; } - sde = getFileName(prefix, directoryName, fileName, sizeof(fileName), +1); + sde = getFileName(prefix, directoryName, fileName, nameLength, +1); if (sde != SDLOG_OK) { // sd card is not inserted, so logging task can be deleted return storageStatus = SDLOG_FATFS_ERROR; diff --git a/sw/airborne/modules/loggers/sdlog_chibios/sdLog.h b/sw/airborne/modules/loggers/sdlog_chibios/sdLog.h index e5f874db8c..ad72a80f3d 100644 --- a/sw/airborne/modules/loggers/sdlog_chibios/sdLog.h +++ b/sw/airborne/modules/loggers/sdlog_chibios/sdLog.h @@ -189,7 +189,7 @@ SdioError sdLogFinish(void); * @details always open new file with numeric index * @param[out] fileObject : file descriptor : small integer between 0 and _FS_REENTRANT-1 * @param[in] directoryName : name of directory just under ROOT, created if nonexistant - * @param[in] fileName : the name will be appended with 3 digits number + * @param[in] prefix : the name will be appended with 3 digits number * @param[in] autoFlushPeriod : if non 0, period in second at which flush to mass storage is done * if 0, no autoflush is done. * @param[in] appendTagAtClose : at close, a marker will be added to prove that the file is complete @@ -200,11 +200,13 @@ SdioError sdLogFinish(void); * but take room on storage ans is not easy to manipulate afterward because * of big files * even if no log id recorded on file + * @param[out] fileName : buffer where the new filename will be created + * @param[in] nameLength : maximum length of the previous buffer * @return status (always check status) */ -SdioError sdLogOpenLog(FileDes *fileObject, const char *directoryName, const char *fileName, +SdioError sdLogOpenLog(FileDes *fileObject, const char *directoryName, const char *prefix, const uint32_t autoFlushPeriod, const bool appendTagAtClose, - const size_t sizeInMo, const bool preallocate); + const size_t sizeInMo, const bool preallocate, char *fileName, const size_t nameLength); diff --git a/sw/ext/pprzlink b/sw/ext/pprzlink index fadbcf78c9..7582389331 160000 --- a/sw/ext/pprzlink +++ b/sw/ext/pprzlink @@ -1 +1 @@ -Subproject commit fadbcf78c95a72e4fe4b8526fec26b17019bce47 +Subproject commit 758238933161923f7c99fca432b18020e02731ef