|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
46 #ifndef SDLOG_START_DELAY
47 #define SDLOG_START_DELAY 30
51 #ifndef SDLOG_AUTO_FLUSH_PERIOD
52 #define SDLOG_AUTO_FLUSH_PERIOD 10
56 #ifndef SDLOG_CONTIGUOUS_STORAGE_MEM
57 #define SDLOG_CONTIGUOUS_STORAGE_MEM 50
60 #if (!defined USE_ADC_WATCHDOG) || (USE_ADC_WATCHDOG == 0)
61 #error sdlog_chibios need USE_ADC_WATCHDOG in order to properly close files when power is unplugged
64 #define DefaultAdcOfVoltage(voltage) ((uint32_t) (voltage/(DefaultVoltageOfAdc(1))))
73 static __attribute__((noreturn))
void thd_startlog(
void *arg);
90 #if FLIGHTRECORDER_SDLOG
91 static const char FLIGHTRECORDER_LOG_NAME[] =
"fr_";
92 static const char FR_LOG_DIR[] =
"FLIGHT_RECORDER";
93 FileDes flightRecorderLogFile = -1;
109 #if PERIODIC_TELEMETRY
121 size = strlen(filenames);
123 pprz_msg_send_LOGGER_STATUS(trans,
dev, AC_ID, &
status, &errno, &used, size, filenames);
146 sdLogSeekBufferFromSDB(sdb, 1);
152 memcpy(sdLogGetBufferFromSDB(sdb), data, len);
153 sdLogSeekBufferFromSDB(sdb, len);
159 sdLogWriteSDB(*(
p->file), sdb);
170 sdlog->
device.periph = (
void *)(sdlog);
183 #if PERIODIC_TELEMETRY
191 chThdCreateStatic(wa_thd_startlog,
sizeof(wa_thd_startlog),
210 #if FF_FS_REENTRANT == 0
211 sdLogCloseAllLogs(flush);
218 #if FLIGHTRECORDER_SDLOG
219 flightRecorderLogFile = 0;
228 chRegSetThreadName(
"start log");
229 char tmpFilename[32];
235 chThdSleepSeconds(20000);
254 #if FLIGHTRECORDER_SDLOG
256 if (sdLogOpenLog(&flightRecorderLogFile, FR_LOG_DIR, FLIGHTRECORDER_LOG_NAME,
268 chThdCreateStatic(wa_thd_bat_survey,
sizeof(wa_thd_bat_survey),
281 chThdSleepMilliseconds(
sdOk ==
true ? 1000 : 200);
282 if (sdLogGetStorageStatus() !=
SDLOG_OK) {
290 #if HAL_USE_RTC && USE_GPS
294 if (chVTGetSystemTime() - timestamp > 5000) {
295 timestamp = chVTGetSystemTime();
298 const uint32_t unixToGpsEpoch = 315964800;
300 time_t univTime = ((
gps.
week * 7 * 24 * 3600) + (
gps.
tow / 1000)) + unixToGpsEpoch;
301 gmtime_r(&univTime, &time_tm);
304 rtcConvertStructTmToDateTime(&time_tm, 0, &date);
305 rtcSetTime(&RTCD1, &date);
317 chRegSetThreadName(
"battery survey");
319 chThdSleepMilliseconds(2000);
323 chEvtWaitOne(EVENT_MASK(1));
328 chThdSleep(TIME_INFINITE);
void sdlog_chibios_finish(const bool flush)
static void sdlog_send(struct chibios_sdlog *p, long fd)
void sdlog_chibios_init(void)
uint32_t tow
GPS time of week in ms.
static void sdlog_transmit_buffer(struct chibios_sdlog *p, long fd, uint8_t *data, uint16_t len)
struct _SdLogBuffer SdLogBuffer
SdioError sdLogFinish(void)
unmount filesystem
void chibios_sdlog_init(struct chibios_sdlog *sdlog, FileDes *file)
init chibios_sdlog structure
static void thd_startlog(void *arg)
arch independent ADC (Analog to Digital Converter) API
void chsnprintf(char *buffer, size_t size, const char *fmt,...)
void usbStorageStartPolling(void)
event_listener_t powerOutageListener
static char chibios_sdlog_filenames[68]
sdlog filenames
Device independent GPS code (interface)
Mini printf-like functionality.
SdioError removeEmptyLogs(const char *directoryName, const char *prefix, const size_t sizeConsideredEmpty)
remove spurious log file left on sd
static void powerOutageIsr(void)
Arch independent mcu ( Micro Controller Unit ) utilities.
static const struct usb_device_descriptor dev
#define DefaultAdcOfVoltage(voltage)
struct link_device device
Generic device interface.
static int null_function(struct chibios_sdlog *p)
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
static void sdlog_transmit(struct chibios_sdlog *p, long fd, uint8_t byte)
static const char PPRZ_LOG_DIR[]
arch independent LED (Light Emitting Diodes) API
#define LOG_APPEND_TAG_AT_CLOSE_DISABLED
#define SDLOG_AUTO_FLUSH_PERIOD
uint16_t f
Camera baseline, in meters (i.e. horizontal distance between the two cameras of the stereo setup)
#define SDLOG_START_DELAY
static const uint16_t V_ALERT
#define SDLOG_CONTIGUOUS_STORAGE_MEM
static void thd_bat_survey(void *arg)
static uint8_t null_byte_function(struct chibios_sdlog *p)
bool usbStorageIsItRunning(void)
static const char PPRZ_LOG_NAME[]
void WEAK mcu_periph_energy_save(void)
Call board specific energy saving Can be necessary for closing on power off.
#define LOG_PREALLOCATION_DISABLED
static enum @293 chibios_sdlog_status
sdlog status
static void mcu_deep_sleep(void)
Put MCU into deep sleep mode.
static int sdlog_check_free_space(struct chibios_sdlog *p, long *fd, uint16_t len)
struct GpsState gps
global GPS state
static THD_WORKING_AREA(wa_thd_startlog, 2048)
SdioError sdLogInit(uint32_t *freeSpaceInKo)
initialise sdLog
#define DefaultPeriodic
Set default periodic telemetry.
static char NO_FILE_NAME[]
event_source_t powerOutageSource
static void send_sdlog_status(struct transport_tx *trans, struct link_device *dev)