mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-28 09:58:23 +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"/>
|
<file name="flight_recorder.h"/>
|
||||||
</header>
|
</header>
|
||||||
<init fun="flight_recorder_init()"/>
|
<init fun="flight_recorder_init()"/>
|
||||||
<periodic fun="flight_recorder_periodic()" freq="100" autorun="TRUE"/>
|
<periodic fun="flight_recorder_periodic()" autorun="TRUE"/>
|
||||||
<makefile target="ap">
|
<makefile target="ap">
|
||||||
<file name="flight_recorder.c"/>
|
<file name="flight_recorder.c"/>
|
||||||
<define name="FLIGHTRECORDER_SDLOG" cond="ifneq (FALSE,$(findstring $(FLIGHTRECORDER_SDLOG),FALSE))"/>
|
<define name="FLIGHTRECORDER_SDLOG" cond="ifneq (FALSE,$(findstring $(FLIGHTRECORDER_SDLOG),FALSE))"/>
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include <hal.h>
|
#include <hal.h>
|
||||||
#include "modules/loggers/sdlog_chibios/sdLog.h"
|
#include "modules/loggers/sdlog_chibios/sdLog.h"
|
||||||
#include "modules/loggers/sdlog_chibios/usbStorage.h"
|
#include "modules/loggers/sdlog_chibios/usbStorage.h"
|
||||||
|
#include "modules/loggers/sdlog_chibios/printf.h"
|
||||||
#include "modules/loggers/sdlog_chibios.h"
|
#include "modules/loggers/sdlog_chibios.h"
|
||||||
#include "modules/tlsf/tlsf_malloc.h"
|
#include "modules/tlsf/tlsf_malloc.h"
|
||||||
#include "mcu_periph/adc.h"
|
#include "mcu_periph/adc.h"
|
||||||
@@ -100,6 +101,10 @@ static enum {
|
|||||||
SDLOG_ERROR
|
SDLOG_ERROR
|
||||||
} chibios_sdlog_status;
|
} chibios_sdlog_status;
|
||||||
|
|
||||||
|
/** sdlog filenames
|
||||||
|
*/
|
||||||
|
static char chibios_sdlog_filenames[68];
|
||||||
|
|
||||||
#if PERIODIC_TELEMETRY
|
#if PERIODIC_TELEMETRY
|
||||||
#include "subsystems/datalink/telemetry.h"
|
#include "subsystems/datalink/telemetry.h"
|
||||||
static void send_sdlog_status(struct transport_tx *trans, struct link_device *dev)
|
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 status = (uint8_t) chibios_sdlog_status;
|
||||||
uint8_t errno = (uint8_t) sdLogGetStorageStatus();
|
uint8_t errno = (uint8_t) sdLogGetStorageStatus();
|
||||||
uint32_t used = (uint32_t) sdLogGetNbBytesWrittenToStorage();
|
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
|
#endif
|
||||||
|
|
||||||
@@ -212,6 +217,7 @@ static void thd_startlog(void *arg)
|
|||||||
{
|
{
|
||||||
(void) arg;
|
(void) arg;
|
||||||
chRegSetThreadName("start log");
|
chRegSetThreadName("start log");
|
||||||
|
char tmpFilename[32];
|
||||||
|
|
||||||
// Wait before starting the log if needed
|
// Wait before starting the log if needed
|
||||||
chThdSleepSeconds(SDLOG_START_DELAY);
|
chThdSleepSeconds(SDLOG_START_DELAY);
|
||||||
@@ -232,16 +238,18 @@ static void thd_startlog(void *arg)
|
|||||||
removeEmptyLogs(PPRZ_LOG_DIR, PPRZ_LOG_NAME, 50);
|
removeEmptyLogs(PPRZ_LOG_DIR, PPRZ_LOG_NAME, 50);
|
||||||
if (sdLogOpenLog(&pprzLogFile, PPRZ_LOG_DIR,
|
if (sdLogOpenLog(&pprzLogFile, PPRZ_LOG_DIR,
|
||||||
PPRZ_LOG_NAME, SDLOG_AUTO_FLUSH_PERIOD, LOG_APPEND_TAG_AT_CLOSE_DISABLED,
|
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;
|
sdOk = false;
|
||||||
}
|
}
|
||||||
|
chsnprintf(chibios_sdlog_filenames, sizeof(chibios_sdlog_filenames), "%s", tmpFilename);
|
||||||
#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,
|
if (sdLogOpenLog(&flightRecorderLogFile, FR_LOG_DIR, FLIGHTRECORDER_LOG_NAME,
|
||||||
SDLOG_AUTO_FLUSH_PERIOD, LOG_APPEND_TAG_AT_CLOSE_DISABLED,
|
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;
|
sdOk = false;
|
||||||
}
|
}
|
||||||
|
chsnprintf(chibios_sdlog_filenames, sizeof(chibios_sdlog_filenames), ", %s", tmpFilename);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -282,13 +282,12 @@ SdioError sdLogFinish(void)
|
|||||||
#ifdef SDLOG_NEED_QUEUE
|
#ifdef SDLOG_NEED_QUEUE
|
||||||
SdioError sdLogOpenLog(FileDes *fd, const char *directoryName, const char *prefix,
|
SdioError sdLogOpenLog(FileDes *fd, const char *directoryName, const char *prefix,
|
||||||
const uint32_t autoFlushPeriod, const bool appendTagAtClose,
|
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 */
|
FRESULT rc; /* fatfs result code */
|
||||||
SdioError sde = SDLOG_OK; /* sdio result code */
|
SdioError sde = SDLOG_OK; /* sdio result code */
|
||||||
//DIR dir; /* Directory object */
|
//DIR dir; /* Directory object */
|
||||||
//FILINFO fno; /* File information object */
|
//FILINFO fno; /* File information object */
|
||||||
char fileName[32];
|
|
||||||
|
|
||||||
/* local file descriptor
|
/* local file descriptor
|
||||||
using fd is a bad idea since fd is set before fatfs objets are coherents
|
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;
|
return storageStatus = sde;
|
||||||
}
|
}
|
||||||
|
|
||||||
sde = getFileName(prefix, directoryName, fileName, sizeof(fileName), +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
|
||||||
return storageStatus = SDLOG_FATFS_ERROR;
|
return storageStatus = SDLOG_FATFS_ERROR;
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ SdioError sdLogFinish(void);
|
|||||||
* @details always open new file with numeric index
|
* @details always open new file with numeric index
|
||||||
* @param[out] fileObject : file descriptor : small integer between 0 and _FS_REENTRANT-1
|
* @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] 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
|
* @param[in] autoFlushPeriod : if non 0, period in second at which flush to mass storage is done
|
||||||
* if 0, no autoflush 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
|
* @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
|
* but take room on storage ans is not easy to manipulate afterward because
|
||||||
* of big files
|
* of big files
|
||||||
* even if no log id recorded on file
|
* 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)
|
* @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 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