Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
sdlog_chibios.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2013-2015 Gautier Hattenberger, Alexandre Bustico
3 *
4 * This file is part of paparazzi.
5 *
6 * paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, write to
18 * the Free Software Foundation, 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22/*
23 * @file modules/loggers/sdlog_chibios.c
24 * @brief sdlog process with battery monitoring
25 *
26 * The same interface is implemented for Linux and NPS in sdlog_linux.c
27 *
28 */
29
30#ifndef SDLOG_CHIBIOS_H
31#define SDLOG_CHIBIOS_H
32
33#include "std.h"
34#if USE_CHIBIOS_RTOS
36#else
38#endif
39#include "pprzlink/pprzlink_device.h"
40
41/*
42 what to be done :
43 * having an api to register new log
44 * keep internally a list of open file
45 * when power failure event occurs, close all logs
46 */
47
48#define DEST_INFO_MSG_ALL 0
49#define DEST_INFO_MSG_FLIGHT_RECORDER 1
50#define DEST_INFO_MSG_PPRZLOG 2
51
52extern FileDes pprzLogFile;
53
54#if FLIGHTRECORDER_SDLOG
55// if activated, will log specific telemetry process
56extern FileDes flightRecorderLogFile;
57#endif
58
59extern void sdlog_chibios_init(void);
60extern void sdlog_chibios_finish(bool flush);
61
63static inline const char *sdlog_error_string(SdioError error)
64{
65 switch (error) {
66 case SDLOG_OK: return "no error";
67 case SDLOG_NOCARD: return "no SD card";
68 case SDLOG_FATFS_ERROR: return "file system error";
69 case SDLOG_FATFS_NOENT: return "file or folder not found";
70 case SDLOG_FSFULL: return "SD card full";
71 case SDLOG_FDFULL: return "too many open files";
72 case SDLOG_QUEUEFULL: return "write queue full";
73 case SDLOG_MEMFULL: return "out of memory";
74 case SDLOG_NOTHREAD: return "logger thread not started";
75 case SDLOG_INTERNAL_ERROR: return "internal error";
76 case SDLOG_CANNOT_EXPAND: return "cannot reserve space on the SD card";
77 case SDLOG_LOGNUM_ERROR: return "too many log files";
78 case SDLOG_WAS_LAUNCHED: return "already started";
79 default: return "unknown error";
80 }
81}
82
88 struct link_device device;
89};
90
91extern struct chibios_sdlog chibios_sdlog;
92
95extern void chibios_sdlog_init(struct chibios_sdlog *sdlog, FileDes *file);
96
97extern void logger_log_msg_up(uint8_t* buf);
98#endif
static FILE * pprzLogFile
int8_t FileDes
Definition sdLog.h:128
SdioError
Definition sdLog.h:111
@ SDLOG_NOCARD
Definition sdLog.h:113
@ SDLOG_QUEUEFULL
Definition sdLog.h:118
@ SDLOG_LOGNUM_ERROR
Definition sdLog.h:123
@ SDLOG_FATFS_ERROR
Definition sdLog.h:114
@ SDLOG_FSFULL
Definition sdLog.h:116
@ SDLOG_WAS_LAUNCHED
Definition sdLog.h:124
@ SDLOG_OK
Definition sdLog.h:112
@ SDLOG_FDFULL
Definition sdLog.h:117
@ SDLOG_MEMFULL
Definition sdLog.h:119
@ SDLOG_FATFS_NOENT
Definition sdLog.h:115
@ SDLOG_NOTHREAD
Definition sdLog.h:120
@ SDLOG_INTERNAL_ERROR
Definition sdLog.h:121
@ SDLOG_CANNOT_EXPAND
Definition sdLog.h:122
void sdlog_chibios_finish(bool flush)
FileDes * file
struct link_device device
Generic device interface.
void logger_log_msg_up(uint8_t *buf)
static const char * sdlog_error_string(SdioError error)
Human readable cause of a logger error, for the messages to the GCS.
void chibios_sdlog_init(struct chibios_sdlog *sdlog, FileDes *file)
init chibios_sdlog structure
void sdlog_chibios_init(void)
chibios_sdlog structure
Linux (and NPS) replacement of the ChibiOS sdLog API.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.