|
Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
SD logger for Linux based autopilots (Bebop, ...) and NPS. More...
#include "modules/loggers/sdlog_chibios.h"#include "modules/loggers/sdlog_chibios/usbStorage.h"#include "mcu_periph/sys_time.h"#include "generated/airframe.h"#include <stdio.h>#include <stdlib.h>#include <stdarg.h>#include <string.h>#include <dirent.h>#include <errno.h>#include <sys/stat.h>#include <sys/types.h>#include "modules/datalink/telemetry.h"Go to the source code of this file.
Data Structures | |
| struct | sdlog_msg |
| Message under construction, one per thread so threads can't mix messages (the fd argument of the device functions is only used with PPRZLINK_ENABLE_FD). More... | |
Macros | |
| #define | SDLOG_DIR "/data/ftp/internal_000/sdlog" |
| Directory where the logs are stored, the default in simulation is $PAPARAZZI_HOME/var/logs/sdlog/<AIRCRAFT>. | |
| #define | SDLOG_AUTO_FLUSH_PERIOD 10 |
| Flush period in seconds. | |
| #define | SDLOG_MAX_FILES 4 |
| #define | SDLOG_MAX_MSG_LEN 512 |
| #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 } |
Functions | |
| void | usbStorage_enable_usb_storage (float e) |
| static FILE * | sdlog_file (FileDes fd) |
| static SdioError | sdlog_errno_error (int err) |
| Error of a failed write or close: only a full disk is "SD card full". | |
| static void | sdlog_write (FileDes fd, const uint8_t *data, size_t len) |
| SdioError | sdLogWriteLog (const FileDes fd, const char *fmt,...) |
| SdioError | sdLogWriteRaw (const FileDes fd, const uint8_t *buffer, const size_t len) |
| SdioError | sdLogWriteByte (const FileDes fd, const uint8_t value) |
| SdioError | sdLogFlushLog (const FileDes fd) |
| SdioError | sdLogFlushAllLogs (void) |
| size_t | sdLogGetNbBytesWrittenToStorage (void) |
| SdioError | sdLogGetStorageStatus (void) |
| static int | sdlog_check_free_space (struct chibios_sdlog *p, long *fd, uint16_t len) |
| static void | sdlog_put_buffer (struct chibios_sdlog *p, long fd, const uint8_t *data, uint16_t len) |
| static void | sdlog_put_byte (struct chibios_sdlog *p, long fd, uint8_t byte) |
| 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 | |
| static int | sdlog_mkdir (const char *path) |
| Create a directory and its parents. | |
| static int | sdlog_next_number (const char *dir, const char *prefix) |
| Remove the empty logs and get the next free log number. | |
| static FileDes | sdlog_open (const char *base, const char *dir, const char *prefix, char *name, size_t name_len) |
| Open the next log file in base/dir, returns the descriptor or -1. | |
| 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 void | sdlog_atexit (void) |
| void | sdlog_chibios_init (void) |
| void | sdlog_chibios_finish (const bool flush) |
| void | logger_log_msg_up (uint8_t *buf) |
Variables | |
| static const char | PPRZ_LOG_NAME [] = "pprzlog_" |
| static const char | PPRZ_LOG_DIR [] = "PPRZ" |
| static SdioError | sdlog_conf_error = SDLOG_OK |
| Result of writing the configuration, reported to the GCS. | |
| FileDes | pprzLogFile = -1 |
| struct chibios_sdlog | chibios_sdlog |
| float | usb_storage_status = 0 |
| Not available on Linux, only there for the settings. | |
| static FILE * | sdlog_files [SDLOG_MAX_FILES] |
| static size_t | sdlog_bytes = 0 |
| static float | sdlog_last_flush = 0 |
| static enum { ... } | sdlog_status = SDLOG_STOPPED |
| static SdioError | sdlog_error = SDLOG_OK |
| static char | sdlog_filenames [68] |
| static __thread struct sdlog_msg | sdlog_msg |
SD logger for Linux based autopilots (Bebop, ...) and NPS.
Same interface and file layout as the ChibiOS SD logger, so the same modules (flight recorder, high speed IMU logging, ...) can log, and the files can be converted with sd2log: <SDLOG_DIR>/PPRZ/pprzlog_0001.LOG <SDLOG_DIR>/FLIGHT_RECORDER/fr_0001.LOG
Definition in file sdlog_linux.c.
| struct sdlog_msg |
Message under construction, one per thread so threads can't mix messages (the fd argument of the device functions is only used with PPRZLINK_ENABLE_FD).
Definition at line 107 of file sdlog_linux.c.
| Data Fields | ||
|---|---|---|
| uint8_t | buf[SDLOG_MAX_MSG_LEN] | |
| uint16_t | len | |
| #define SDLOG_AUTO_FLUSH_PERIOD 10 |
Flush period in seconds.
Definition at line 61 of file sdlog_linux.c.
| #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 74 of file sdlog_linux.c.
| #define SDLOG_DIR "/data/ftp/internal_000/sdlog" |
Directory where the logs are stored, the default in simulation is $PAPARAZZI_HOME/var/logs/sdlog/<AIRCRAFT>.
Definition at line 52 of file sdlog_linux.c.
Referenced by sdlog_chibios_init().
| #define SDLOG_MAX_FILES 4 |
Definition at line 65 of file sdlog_linux.c.
Referenced by sdlog_chibios_finish(), sdlog_file(), sdlog_open(), and sdLogFlushAllLogs().
| #define SDLOG_MAX_MSG_LEN 512 |
Definition at line 66 of file sdlog_linux.c.
Referenced by sdlog_check_free_space(), sdlog_put_buffer(), and sdLogWriteLog().
| anonymous enum |
| Enumerator | |
|---|---|
| SDLOG_STOPPED | |
| SDLOG_RUNNING | |
| SDLOG_ERROR | |
Definition at line 97 of file sdlog_linux.c.
| void chibios_sdlog_init | ( | struct chibios_sdlog * | sdlog, |
| FileDes * | file ) |
init chibios_sdlog structure
Definition at line 245 of file sdlog_linux.c.
References chibios_sdlog::device, chibios_sdlog::file, null_byte_function(), null_function(), sdlog_check_free_space(), sdlog_put_buffer(), sdlog_put_byte(), and sdlog_send().
Referenced by sdlog_chibios_init().
| void logger_log_msg_up | ( | uint8_t * | buf | ) |
Definition at line 520 of file sdlog_linux.c.
References DEST_INFO_MSG_ALL, DEST_INFO_MSG_PPRZLOG, fd, msg, pprzLogFile, sdLogWriteByte(), and sdLogWriteRaw().
|
static |
Definition at line 243 of file sdlog_linux.c.
References p.
|
static |
Definition at line 242 of file sdlog_linux.c.
References p.
|
static |
Definition at line 450 of file sdlog_linux.c.
References sdlog_chibios_finish().
Referenced by sdlog_chibios_init().
|
static |
Definition at line 212 of file sdlog_linux.c.
References fd, sdlog_msg::len, p, sdlog_file(), and SDLOG_MAX_MSG_LEN.
| void sdlog_chibios_finish | ( | const bool | flush | ) |
Definition at line 502 of file sdlog_linux.c.
References pprzLogFile, sdlog_files, SDLOG_MAX_FILES, sdlog_status, and SDLOG_STOPPED.
Referenced by sdlog_atexit().
| void sdlog_chibios_init | ( | void | ) |
Definition at line 455 of file sdlog_linux.c.
References chibios_sdlog_init(), DefaultPeriodic, dir, get_sys_time_float(), PPRZ_LOG_DIR, PPRZ_LOG_NAME, pprzLogFile, preflight_check_register(), register_periodic_telemetry(), sdlog_atexit(), sdlog_conf_error, SDLOG_DIR, SDLOG_ERROR, sdlog_error, sdlog_filenames, sdlog_last_flush, SDLOG_OK, sdlog_open(), SDLOG_RUNNING, sdlog_status, and send_sdlog_status().
|
static |
Error of a failed write or close: only a full disk is "SD card full".
Definition at line 122 of file sdlog_linux.c.
References SDLOG_FATFS_ERROR, and SDLOG_FSFULL.
Referenced by sdlog_write().
|
static |
Definition at line 113 of file sdlog_linux.c.
References fd, sdlog_files, and SDLOG_MAX_FILES.
Referenced by sdlog_check_free_space(), sdlog_write(), and sdLogFlushLog().
|
static |
Create a directory and its parents.
Definition at line 260 of file sdlog_linux.c.
Referenced by sdlog_open().
|
static |
Remove the empty logs and get the next free log number.
Definition at line 280 of file sdlog_linux.c.
References dir.
Referenced by sdlog_open().
|
static |
Open the next log file in base/dir, returns the descriptor or -1.
Definition at line 310 of file sdlog_linux.c.
References dir, fd, sdlog_error, SDLOG_FATFS_ERROR, SDLOG_FDFULL, sdlog_files, SDLOG_LOGNUM_ERROR, SDLOG_MAX_FILES, sdlog_mkdir(), sdlog_next_number(), and SDLOG_NOCARD.
Referenced by sdlog_chibios_init().
|
static |
Definition at line 221 of file sdlog_linux.c.
References sdlog_msg::buf, fd, sdlog_msg::len, p, and SDLOG_MAX_MSG_LEN.
Referenced by chibios_sdlog_init(), and sdlog_put_byte().
|
static |
Definition at line 231 of file sdlog_linux.c.
References fd, p, and sdlog_put_buffer().
Referenced by chibios_sdlog_init().
|
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 411 of file sdlog_linux.c.
References dev, Min, msg, sdlog_conf_error, SDLOG_ERROR, sdlog_error, sdlog_error_string(), SDLOG_OK, SDLOG_RUNNING, sdlog_status, SDLOG_STOPPED, and status.
Referenced by send_sdlog_status().
|
static |
Definition at line 236 of file sdlog_linux.c.
References sdlog_msg::buf, fd, sdlog_msg::len, p, and sdlog_write().
Definition at line 132 of file sdlog_linux.c.
References f, fd, get_sys_time_float(), sdlog_msg::len, SDLOG_AUTO_FLUSH_PERIOD, sdlog_bytes, sdlog_errno_error(), SDLOG_ERROR, sdlog_error, sdlog_file(), sdlog_last_flush, sdlog_status, and sdLogFlushAllLogs().
Referenced by sdlog_send(), sdLogWriteByte(), sdLogWriteLog(), and sdLogWriteRaw().
| SdioError sdLogFlushAllLogs | ( | void | ) |
Definition at line 191 of file sdlog_linux.c.
References sdlog_error, sdlog_files, and SDLOG_MAX_FILES.
Referenced by sdlog_write().
Definition at line 182 of file sdlog_linux.c.
References f, fd, sdlog_error, and sdlog_file().
| size_t sdLogGetNbBytesWrittenToStorage | ( | void | ) |
Definition at line 201 of file sdlog_linux.c.
References sdlog_bytes.
Referenced by send_sdlog_status().
| SdioError sdLogGetStorageStatus | ( | void | ) |
Definition at line 206 of file sdlog_linux.c.
References sdlog_error.
Referenced by send_sdlog_status(), and thd_startlog().
Definition at line 176 of file sdlog_linux.c.
References fd, sdlog_error, and sdlog_write().
Referenced by gps_ubx_parse(), and logger_log_msg_up().
Definition at line 153 of file sdlog_linux.c.
References sdlog_msg::buf, fd, sdlog_msg::len, sdlog_error, SDLOG_INTERNAL_ERROR, SDLOG_MAX_MSG_LEN, and sdlog_write().
Referenced by airspeed_ets_read_event(), aoa_pwm_update(), apogee_baro_event(), humid_sht_periodic(), ins_float_invariant_propagate(), mf_ptu_periodic(), process_data(), temod_event(), and uwb_positioning_periodic().
Definition at line 170 of file sdlog_linux.c.
References fd, sdlog_msg::len, sdlog_error, and sdlog_write().
Referenced by logger_log_msg_up().
|
static |
Definition at line 436 of file sdlog_linux.c.
References dev, sdlog_bytes, sdlog_error, sdlog_filenames, sdlog_report_status(), sdlog_status, and status.
| void usbStorage_enable_usb_storage | ( | float | e | ) |
Definition at line 92 of file sdlog_linux.c.
References usb_storage_status.
| struct chibios_sdlog chibios_sdlog |
Definition at line 88 of file sdlog_linux.c.
|
static |
Definition at line 69 of file sdlog_linux.c.
|
static |
Definition at line 68 of file sdlog_linux.c.
| FileDes pprzLogFile = -1 |
Definition at line 87 of file sdlog_linux.c.
|
static |
Definition at line 95 of file sdlog_linux.c.
Referenced by sdlog_write(), sdLogGetNbBytesWrittenToStorage(), and send_sdlog_status().
Result of writing the configuration, reported to the GCS.
Definition at line 80 of file sdlog_linux.c.
Definition at line 102 of file sdlog_linux.c.
Referenced by sdlog_chibios_init(), sdlog_open(), sdlog_report_status(), sdlog_write(), sdLogFlushAllLogs(), sdLogFlushLog(), sdLogGetStorageStatus(), sdLogWriteByte(), sdLogWriteLog(), sdLogWriteRaw(), and send_sdlog_status().
|
static |
Definition at line 103 of file sdlog_linux.c.
Referenced by sdlog_chibios_init(), and send_sdlog_status().
|
static |
Definition at line 94 of file sdlog_linux.c.
Referenced by sdlog_chibios_finish(), sdlog_file(), sdlog_open(), and sdLogFlushAllLogs().
|
static |
Definition at line 96 of file sdlog_linux.c.
Referenced by sdlog_chibios_init(), and sdlog_write().
|
static |
Definition at line 111 of file sdlog_linux.c.
| enum { ... } sdlog_status |
Referenced by sdlog_chibios_finish(), sdlog_chibios_init(), sdlog_report_status(), sdlog_write(), and send_sdlog_status().
| float usb_storage_status = 0 |
Not available on Linux, only there for the settings.
Definition at line 91 of file sdlog_linux.c.