Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
intermcu_ap.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Freek van Tienen <freek.v.tienen@gmail.com>
3 * Copyright (C) 2022 Gautier Hattenberger <gautier.hattenberger@enac.fr>
4 *
5 * This file is part of paparazzi.
6 *
7 * paparazzi is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * paparazzi is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with paparazzi; see the file COPYING. If not, see
19 * <http://www.gnu.org/licenses/>.
20 *
21 */
22
27#define PERIODIC_C_INTERMCU
28
30#include "pprzlink/intermcu_msg.h"
32#include "generated/modules.h"
33#include "autopilot.h"
34#if TELEMETRY_INTERMCU
36#endif
37#include "generated/periodic_telemetry.h"
38
39#if COMMANDS_NB > 8
40#warning "INTERMCU UART CAN ONLY SEND 8 COMMANDS OR THE UART MIGHT BE OVERFILLED"
41#endif
42
43
44/* Main InterMCU defines */
46 .device = (&((INTERMCU_LINK).device)),
47 .enabled = true,
48 .msg_available = false,
49};
50
52
54
55
56#if PERIODIC_TELEMETRY
58
59/* Send FBW status */
66#endif
67
68/* InterMCU initialization */
77
78/* Check for InterMCU loss */
80{
81 /* Check for interMCU loss */
84 } else {
86 }
87
88#ifdef TELEMETRY_PROCESS_InterMCU
89 // send periodic InterMCU if defined in telemetry file
91#endif
92}
93
94/* Check new characters */
96{
97 /* Parse incoming bytes */
98 if (intermcu.enabled) {
102 // reset intermcu timer, don't touch msg_available flag
104
106 // parse intermcu messages and call callbacks
108 } else {
109 // reset datalink_time if message is not intermcu class
110 datalink_time = 0;
112#if TELEMETRY_INTERMCU
113 // forward all other messages if needed
114 intermcu_dl_on_msg(imcu_msg_buf, intermcu.transport.trans_rx.payload_len);
115#endif
116 }
117 intermcu.msg_available = false;
118 }
119 }
120}
121
122/* Enable or disable the communication of the InterMCU */
123void intermcu_set_enabled(bool value)
124{
125 intermcu.enabled = value;
126}
127
128/* Send the commands to the FBW */
130{
131 if (!intermcu.enabled) {
132 return;
133 }
134
135 // Set the autopilot motors on status
138 }
139
140 // Send the message and reset cmd_status
142 AC_ID, &intermcu.cmd_status, COMMANDS_NB, command_values); //TODO: Append more status
144}
145
146/* Send the spektrum Bind message */
153
162
bool autopilot_get_motors_on(void)
get motors status
Definition autopilot.c:295
Core autopilot interface common to all firmwares.
struct Electrical electrical
Definition electrical.c:92
Interface for electrical status: supply voltage, current, battery status, etc.
float current
current in A
Definition electrical.h:47
float vsupply
supply voltage in V
Definition electrical.h:45
struct link_device * device
Device used for communication.
Definition intermcu.h:70
#define INTERMCU_SET_CMD_STATUS(_bit)
Definition intermcu.h:64
#define INTERMCU_LOST_CNT
Definition intermcu.h:35
@ INTERMCU_LOST
No interMCU communication anymore.
Definition intermcu.h:43
bool enabled
If the InterMCU communication is enabled.
Definition intermcu.h:74
@ INTERMCU_CMD_MOTORS_ON
The status of intermcu_ap_motors_on.
Definition intermcu.h:57
uint8_t cmd_status
Command status information that is transfered (intermcu_cmd_status)
Definition intermcu.h:76
enum intermcu_status status
Status of the INTERMCU.
Definition intermcu.h:72
bool msg_available
If we have an InterMCU message.
Definition intermcu.h:75
uint8_t time_since_last_frame
Time since last frame.
Definition intermcu.h:73
struct pprz_transport transport
Transport over communication line (PPRZ)
Definition intermcu.h:71
void intermcu_event(void)
Definition intermcu_ap.c:95
void intermcu_periodic(void)
Definition intermcu_ap.c:79
static void send_status(struct transport_tx *trans, struct link_device *dev)
Definition intermcu_ap.c:60
struct intermcu_t intermcu
Definition intermcu_ap.c:45
void intermcu_send_spektrum_bind(void)
send binding signal for spektrum receiver
void intermcu_set_enabled(bool value)
enable/disable intermcu link
void intermcu_parse_IMCU_FBW_STATUS(uint8_t *buf)
Datalink event functions.
uint8_t imcu_msg_buf[128]
The InterMCU message buffer.
Definition intermcu_ap.c:51
void intermcu_send_commands(pprz_t *command_values, uint8_t ap_mode)
send command vector over intermcu link instead of actuators
static struct fbw_status_t fbw_status
Definition intermcu_ap.c:53
void intermcu_init(void)
Definition intermcu_ap.c:69
Inter-MCU on the AP side.
uint8_t rc_status
Definition intermcu_ap.h:51
uint8_t mode
Definition intermcu_ap.h:53
uint8_t frame_rate
Definition intermcu_ap.h:52
void intermcu_dl_on_msg(uint8_t *msg, uint8_t size)
function to forward telemetry from AP to the ground
Definition intermcu_dl.c:79
datalink forwarder for InterMCU
uint16_t foo
Definition main_demo5.c:58
int16_t pprz_t
Definition paparazzi.h:6
void dl_parse_msg(struct link_device *dev, struct transport_tx *trans, uint8_t *buf)
Should be called when chars are available in dl_buffer.
static const struct usb_device_descriptor dev
Definition usb_ser_hw.c:74
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Definition telemetry.c:51
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.