Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
sdlog_chibios.c File Reference
Include dependency graph for sdlog_chibios.c:

Go to the source code of this file.

Macros

#define SDLOG_START_DELAY   30
#define SDLOG_AUTO_FLUSH_PERIOD   10
#define SDLOG_CONTIGUOUS_STORAGE_MEM   50
#define SDLOG_ENABLE_LOWBAT_FLUSH   TRUE
#define SDLOG_CONF   TRUE
 Write the configuration of the firmware next to the logs (PPRZ/<md5>_<aircraft>.conf.gz), so sd2log can decode them without the var/conf of the computer that built the firmware.

Enumerations

enum  { SDLOG_STOPPED = 0 , SDLOG_RUNNING , SDLOG_ERROR }
 sdlog status More...

Functions

static IN_DMA_SECTION (THD_WORKING_AREA(wa_thd_startlog, 4096))
static void thd_startlog (void *arg)
static void sdlog_report_status (struct transport_tx *trans, struct link_device *dev)
 Tell the GCS in words why the logger does not run (no SD card, card full, ...): at the start and every time it goes into error later, and when the configuration could not be written.
static void send_sdlog_status (struct transport_tx *trans, struct link_device *dev)
static int sdlog_check_free_space (struct chibios_sdlog *p, long *fd, uint16_t len)
static void sdlog_transmit (struct chibios_sdlog *p, long fd, uint8_t byte)
static void sdlog_transmit_buffer (struct chibios_sdlog *p, long fd, uint8_t *data, uint16_t len)
static void sdlog_send (struct chibios_sdlog *p, long fd)
static int null_function (struct chibios_sdlog *p)
static uint8_t null_byte_function (struct chibios_sdlog *p)
void chibios_sdlog_init (struct chibios_sdlog *sdlog, FileDes *file)
 init chibios_sdlog structure
void sdlog_chibios_init (void)
void sdlog_chibios_finish (const bool flush)
static void sdlog_start_failed (const char *step, SdioError err)
 Keep why the start failed (the first failing step only).
void logger_log_msg_up (uint8_t *buf)

Variables

static const char PPRZ_LOG_NAME [] = "pprzlog_"
static const char PPRZ_LOG_DIR [] = "PPRZ"
static volatile SdioError sdlog_conf_error = SDLOG_OK
 Result of writing the configuration, reported to the GCS.
static volatile SdioError sdlog_start_error = SDLOG_OK
static const char * sdlog_start_step = ""
static volatile uint8_t sdlog_start_fatfs = 0
static volatile uint32_t sdlog_error_events = 0
static volatile SdioError sdlog_error_cause = SDLOG_OK
bool sdOk = false
FileDes pprzLogFile = -1
struct chibios_sdlog chibios_sdlog
static enum { ... }  chibios_sdlog_status
 sdlog status
static char chibios_sdlog_filenames [68]
 sdlog filenames
static char NO_FILE_NAME [] = "none"

Macro Definition Documentation

◆ SDLOG_AUTO_FLUSH_PERIOD

#define SDLOG_AUTO_FLUSH_PERIOD   10

Definition at line 54 of file sdlog_chibios.c.

Referenced by sdlog_write(), and thd_startlog().

◆ SDLOG_CONF

#define SDLOG_CONF   TRUE

Write the configuration of the firmware next to the logs (PPRZ/<md5>_<aircraft>.conf.gz), so sd2log can decode them without the var/conf of the computer that built the firmware.

Definition at line 78 of file sdlog_chibios.c.

◆ SDLOG_CONTIGUOUS_STORAGE_MEM

#define SDLOG_CONTIGUOUS_STORAGE_MEM   50

Definition at line 59 of file sdlog_chibios.c.

Referenced by thd_startlog().

◆ SDLOG_ENABLE_LOWBAT_FLUSH

#define SDLOG_ENABLE_LOWBAT_FLUSH   TRUE

Definition at line 64 of file sdlog_chibios.c.

◆ SDLOG_START_DELAY

#define SDLOG_START_DELAY   30

Definition at line 45 of file sdlog_chibios.c.

Referenced by thd_startlog().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

sdlog status

Enumerator
SDLOG_STOPPED 
SDLOG_RUNNING 
SDLOG_ERROR 

Definition at line 114 of file sdlog_chibios.c.

Function Documentation

◆ chibios_sdlog_init()

void chibios_sdlog_init ( struct chibios_sdlog * sdlog,
FileDes * file )

init chibios_sdlog structure

Definition at line 239 of file sdlog_chibios.c.

References chibios_sdlog::device, chibios_sdlog::file, null_byte_function(), null_function(), sdlog_check_free_space(), sdlog_send(), sdlog_transmit(), and sdlog_transmit_buffer().

Referenced by flight_recorder_init(), and thd_startlog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IN_DMA_SECTION()

IN_DMA_SECTION ( THD_WORKING_AREA(wa_thd_startlog, 4096) )
static

◆ logger_log_msg_up()

void logger_log_msg_up ( uint8_t * buf)

Definition at line 455 of file sdlog_chibios.c.

References DEST_INFO_MSG_ALL, DEST_INFO_MSG_PPRZLOG, fd, pprzLogFile, sdLogWriteByte(), and sdLogWriteRaw().

Here is the call graph for this function:

◆ null_byte_function()

uint8_t null_byte_function ( struct chibios_sdlog * p)
static

Definition at line 237 of file sdlog_chibios.c.

References p.

◆ null_function()

int null_function ( struct chibios_sdlog * p)
static

Definition at line 236 of file sdlog_chibios.c.

References p.

◆ sdlog_check_free_space()

int sdlog_check_free_space ( struct chibios_sdlog * p,
long * fd,
uint16_t len )
static

Definition at line 203 of file sdlog_chibios.c.

References fd, p, SDLOG_OK, and status.

Referenced by chibios_sdlog_init().

Here is the caller graph for this function:

◆ sdlog_chibios_finish()

void sdlog_chibios_finish ( const bool flush)

Definition at line 274 of file sdlog_chibios.c.

References chibios_sdlog_status, pprzLogFile, SDLOG_STOPPED, and sdLogFinish().

Referenced by thdUsbStorage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdlog_chibios_init()

void sdlog_chibios_init ( void )

◆ sdlog_report_status()

void sdlog_report_status ( struct transport_tx * trans,
struct link_device * dev )
static

Tell the GCS in words why the logger does not run (no SD card, card full, ...): at the start and every time it goes into error later, and when the configuration could not be written.

A normal start is not reported. Sent with the LOGGER_STATUS message, from the main thread.

Definition at line 152 of file sdlog_chibios.c.

References chibios_sdlog_status, chsnprintf(), dev, sdlog_conf_error, sdlog_error_cause, sdlog_error_events, sdlog_error_string(), SDLOG_OK, sdlog_start_error, sdlog_start_fatfs, sdlog_start_step, and SDLOG_STOPPED.

Referenced by send_sdlog_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdlog_send()

void sdlog_send ( struct chibios_sdlog * p,
long fd )
static

Definition at line 230 of file sdlog_chibios.c.

References fd, and p.

Referenced by chibios_sdlog_init().

Here is the caller graph for this function:

◆ sdlog_start_failed()

void sdlog_start_failed ( const char * step,
SdioError err )
static

Keep why the start failed (the first failing step only).

Definition at line 353 of file sdlog_chibios.c.

References sdlog_error_cause, sdlog_start_error, sdlog_start_fatfs, sdlog_start_step, sdLogGetFatfsResult(), sdOk, and step.

Referenced by thd_startlog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sdlog_transmit()

void sdlog_transmit ( struct chibios_sdlog * p,
long fd,
uint8_t byte )
static

Definition at line 215 of file sdlog_chibios.c.

References fd, and p.

Referenced by chibios_sdlog_init().

Here is the caller graph for this function:

◆ sdlog_transmit_buffer()

void sdlog_transmit_buffer ( struct chibios_sdlog * p,
long fd,
uint8_t * data,
uint16_t len )
static

Definition at line 223 of file sdlog_chibios.c.

References fd, and p.

Referenced by chibios_sdlog_init().

Here is the caller graph for this function:

◆ send_sdlog_status()

void send_sdlog_status ( struct transport_tx * trans,
struct link_device * dev )
static

Definition at line 184 of file sdlog_chibios.c.

References chibios_sdlog_filenames, chibios_sdlog_status, dev, NO_FILE_NAME, sdlog_report_status(), sdLogGetNbBytesWrittenToStorage(), sdLogGetStorageStatus(), and status.

Referenced by sdlog_chibios_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ thd_startlog()

Variable Documentation

◆ chibios_sdlog

struct chibios_sdlog chibios_sdlog

Definition at line 104 of file sdlog_chibios.c.

◆ chibios_sdlog_filenames

char chibios_sdlog_filenames[68]
static

sdlog filenames

Definition at line 122 of file sdlog_chibios.c.

Referenced by send_sdlog_status(), and thd_startlog().

◆ []

enum { ... } chibios_sdlog_status

◆ NO_FILE_NAME

char NO_FILE_NAME[] = "none"
static

Definition at line 123 of file sdlog_chibios.c.

Referenced by send_sdlog_status().

◆ PPRZ_LOG_DIR

const char PPRZ_LOG_DIR[] = "PPRZ"
static

Definition at line 73 of file sdlog_chibios.c.

Referenced by sdlog_chibios_init(), and thd_startlog().

◆ PPRZ_LOG_NAME

const char PPRZ_LOG_NAME[] = "pprzlog_"
static

Definition at line 72 of file sdlog_chibios.c.

Referenced by sdlog_chibios_init(), and thd_startlog().

◆ pprzLogFile

FileDes pprzLogFile = -1

Definition at line 102 of file sdlog_chibios.c.

◆ sdlog_conf_error

volatile SdioError sdlog_conf_error = SDLOG_OK
static

Result of writing the configuration, reported to the GCS.

Definition at line 84 of file sdlog_chibios.c.

Referenced by sdlog_chibios_init(), sdlog_report_status(), sdlog_report_status(), and thd_startlog().

◆ sdlog_error_cause

volatile SdioError sdlog_error_cause = SDLOG_OK
static

Definition at line 92 of file sdlog_chibios.c.

Referenced by sdlog_report_status(), sdlog_start_failed(), and thd_startlog().

◆ sdlog_error_events

volatile uint32_t sdlog_error_events = 0
static

Definition at line 91 of file sdlog_chibios.c.

Referenced by sdlog_report_status(), and thd_startlog().

◆ sdlog_start_error

volatile SdioError sdlog_start_error = SDLOG_OK
static

Definition at line 86 of file sdlog_chibios.c.

Referenced by sdlog_report_status(), sdlog_start_failed(), and thd_startlog().

◆ sdlog_start_fatfs

volatile uint8_t sdlog_start_fatfs = 0
static

Definition at line 88 of file sdlog_chibios.c.

Referenced by sdlog_report_status(), and sdlog_start_failed().

◆ sdlog_start_step

const char* sdlog_start_step = ""
static

Definition at line 87 of file sdlog_chibios.c.

Referenced by sdlog_report_status(), and sdlog_start_failed().

◆ sdOk

bool sdOk = false

Definition at line 100 of file sdlog_chibios.c.

Referenced by sdlog_start_failed(), and thd_startlog().