mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-23 21:36:28 +08:00
[sdlog] Add sdlog filename and fix Flight Recorder maximum message rate
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
<file name="flight_recorder.h"/>
|
||||
</header>
|
||||
<init fun="flight_recorder_init()"/>
|
||||
<periodic fun="flight_recorder_periodic()" freq="100" autorun="TRUE"/>
|
||||
<periodic fun="flight_recorder_periodic()" autorun="TRUE"/>
|
||||
<makefile target="ap">
|
||||
<file name="flight_recorder.c"/>
|
||||
<define name="FLIGHTRECORDER_SDLOG" cond="ifneq (FALSE,$(findstring $(FLIGHTRECORDER_SDLOG),FALSE))"/>
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <hal.h>
|
||||
#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
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
|
||||
|
||||
+1
-1
Submodule sw/ext/pprzlink updated: fadbcf78c9...7582389331
Reference in New Issue
Block a user