Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
flight_recorder.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Gautier Hattenberger <gautier.hattenberger@enac.fr>
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, see
18  * <http://www.gnu.org/licenses/>.
19  */
26 #define PERIODIC_C_FLIGHTRECORDER
27 
29 
33 
34 #if FLIGHTRECORDER_SDLOG
36 struct chibios_sdlog flightrecorder_sdlog;
37 #ifndef FLIGHTRECORDER_DEVICE
38 #define FLIGHTRECORDER_DEVICE flightrecorder_sdlog
39 #else
40 #warning "SD log is activated, but FLIGHTRECORDER_DEVICE is alreay set (should not be defined)"
41 #endif
42 
43 #else
44 // include downlink for other devices
46 #endif
47 
48 #ifndef TELEMETRY_PROCESS_FlightRecorder
49 #error "You need to use a telemetry xml file with FlightRecorder process!"
50 #endif
51 
53 {
54 #if FLIGHTRECORDER_SDLOG
55  chibios_sdlog_init(&flightrecorder_sdlog, &flightRecorderLogFile);
56 #endif
57 }
58 
60 {
61 #if FLIGHTRECORDER_SDLOG
62  // test if sd log is ready
63  if (flightRecorderLogFile == -1) return;
64 #endif
65 
66 #if PERIODIC_TELEMETRY
67  periodic_telemetry_send_FlightRecorder(DefaultPeriodic, &pprzlog_tp.trans_tx, &(FLIGHTRECORDER_DEVICE).device);
68 #endif
69 }
70 
72  uint8_t ac_id = pprzlink_get_DL_INFO_MSG_UP_ac_id(buf);
73  if(ac_id != AC_ID && ac_id != 0xFF) {
74  return;
75  }
76  uint8_t fd = pprzlink_get_DL_INFO_MSG_UP_fd(buf);
78  uint8_t len = pprzlink_get_INFO_MSG_UP_msg_length(buf);
79  char* msg = pprzlink_get_DL_INFO_MSG_UP_msg(buf);
80  pprz_msg_send_INFO_MSG(&pprzlog_tp.trans_tx, &(FLIGHTRECORDER_DEVICE).device, AC_ID, len, msg);
81  }
82 }
83 
void flight_recorder_init()
Init function.
void flight_recorder_periodic()
Periodic function.
void flight_recorder_log_msg_up(uint8_t *buf)
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
struct pprzlog_transport pprzlog_tp
PPRZLOG transport structure.
Definition: pprzlog_tp.c:29
Initialize pprzlog transport.
void chibios_sdlog_init(struct chibios_sdlog *sdlog, FileDes *file)
init chibios_sdlog structure
#define DEST_INFO_MSG_ALL
Definition: sdlog_chibios.h:42
#define DEST_INFO_MSG_FLIGHT_RECORDER
Definition: sdlog_chibios.h:43
chibios_sdlog structure
Definition: sdlog_chibios.h:58
int fd
Definition: serial.c:26
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
Definition: telemetry.h:66
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98