° add low level mechanism to permit flight parameter record in separate file

This commit is contained in:
Alexandre Bustico
2014-09-24 13:58:33 +02:00
committed by Gautier Hattenberger
parent 181b0da47b
commit fe2db94e9c
4 changed files with 11 additions and 50 deletions
@@ -58,9 +58,7 @@ static WORKING_AREA(wa_thd_heartbeat, 2048);
void chibios_launch_heartbeat (void);
bool_t sdOk = FALSE;
#if LOG_PROCESS_STATE
static int32_t get_stack_free (Thread *tp);
#endif
/*
* Init ChibiOS HAL and Sys
@@ -105,26 +103,6 @@ static __attribute__((noreturn)) msg_t thd_heartbeat(void *arg)
chThdSleepMilliseconds (sdOk == TRUE ? 1000 : 200);
static uint32_t timestamp = 0;
#if LOG_PROCESS_STATE
sdLogWriteLog (&processLogFile, " addr stack frestk prio refs state time name\r\n");
#endif
// chSysDisable ();
Thread *tp = chRegFirstThread();
do {
#if LOG_PROCESS_STATE
sdLogWriteLog (&processLogFile, "%.8lx %.8lx %6lu %4lu %4lu [S:%d] %5lu %s\r\n",
(uint32_t)tp, (uint32_t)tp->p_ctx.r13,
get_stack_free (tp),
(uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
tp->p_state, (uint32_t)tp->p_time,
chRegGetThreadName(tp));
#endif
tp = chRegNextThread(tp);
} while (tp != NULL);
// chSysEnable ();
// we sync gps time to rtc every 5 seconds
if (chTimeNow() - timestamp > 5000) {
@@ -138,20 +116,3 @@ static __attribute__((noreturn)) msg_t thd_heartbeat(void *arg)
}
#if LOG_PROCESS_STATE
static int32_t get_stack_free (Thread *tp)
{
int32_t index = 0;
const uint8_t *maxRamAddr = (uint8_t*) (0x20000000 + (128*1024));
const int32_t internalStructSize = 80;
unsigned long long *stkAdr = (unsigned long long *) ((uint8_t *) tp + internalStructSize);
//unsigned long long *stkAdr = (unsigned long long *) tp;
while ((stkAdr[index] == 0x5555555555555555) && ( ((uint8_t *) &(stkAdr[index])) < maxRamAddr))
index++;
const int32_t freeBytes = index * sizeof(long long);
return MAX(0, freeBytes - internalStructSize);
}
#endif
@@ -46,9 +46,9 @@ EventListener powerOutageListener;
FIL pprzLogFile = {0};
#if LOG_PROCESS_STATE
static const char PROCESS_LOG_NAME[] = "processLog_";
FIL processLogFile = {0};
#if LOG_FLIGHTRECORDER
static const char FLIGHTRECORDER_LOG_NAME[] = "fr_";
FIL flightRecorderLogFile = {0};
#endif
struct chibios_sdlog chibios_sdlog;
@@ -96,8 +96,8 @@ bool_t chibios_logInit(const bool_t binaryFile)
if (sdLogOpenLog (&pprzLogFile, PPRZ_LOG_DIR, PPRZ_LOG_NAME) != SDLOG_OK)
goto error;
#if LOG_PROCESS_STATE
if (sdLogOpenLog (&processLogFile, PROCESS_LOG_NAME) != SDLOG_OK)
#if LOG_FLIGHTRECORDER
if (sdLogOpenLog (&flightRecorderLogFile, FLIGHTRECORDER_LOG_NAME) != SDLOG_OK)
goto error;
#endif
@@ -120,8 +120,8 @@ void chibios_logFinish(void)
if (pprzLogFile.fs != NULL) {
sdLogStopThread ();
sdLogCloseLog (&pprzLogFile);
#if LOG_PROCESS_STATE
sdLogCloseLog (&processLogFile);
#if LOG_FLIGHTRECORDER
sdLogCloseLog (&flightRecorderLogFile);
#endif
sdLogFinish ();
pprzLogFile.fs = NULL;
@@ -40,9 +40,9 @@
extern FIL pprzLogFile;
#if LOG_PROCESS_STATE
#if LOG_FLIGHTRECORDER
// if activated, will log all process states
extern FIL processLogFile;
extern FIL flightRecorderLogFile;
#endif
extern bool_t chibios_logInit(const bool_t binaryFile);
@@ -185,7 +185,7 @@
/ function must be added to the project. */
#define _FS_SHARE 0 /* 0:Disable or >=1:Enable */
#define _FS_SHARE 2 /* 0:Disable or >=1:Enable */
/* To enable file shareing feature, set _FS_SHARE to 1 or greater. The value
defines how many files can be opened simultaneously. */