28 #ifndef MAVLINK_DECODER_H
29 #define MAVLINK_DECODER_H
32 #include "pprzlink/pprzlink_transport.h"
56 #define MAVLINK_PAYLOAD_OFFSET 4
58 #define MAVLINK_SEQ_IDX 0
59 #define MAVLINK_SYS_ID_IDX 1
60 #define MAVLINK_COMP_ID_IDX 2
61 #define MAVLINK_MSG_ID_IDX 3
64 #define X25_INIT_CRC 0xffff
66 #ifndef MAVLINK_NO_CRC_EXTRA
85 tmp = data ^ (
uint8_t)(*crcAccum & 0xff);
87 *crcAccum = (*crcAccum >> 8) ^ (tmp << 8) ^ (tmp << 3) ^ (tmp >> 4);
153 #if MAVLINK_DECODER_DEBUG
184 if (t->
trans.msg_received) {
188 t->
trans.payload_len = c +
203 #if MAVLINK_DECODER_DEBUG
204 mavlink_send_debug(t);
206 #ifndef MAVLINK_NO_CRC_EXTRA
219 t->
trans.msg_received =
true;
237 for (el = t->
req; el; el = el->
next) {
245 for (i = 0; i < t->
trans.payload_len; i++) {
256 if (dev->char_available(dev->periph)) {
257 while (dev->char_available(dev->periph) && !trans->
trans.msg_received) {
260 if (trans->
trans.msg_received) {
262 trans->
trans.msg_received =
false;
268 #define MavlinkDatalinkEvent() mavlink_check_and_parse(&(MAVLINK_UART).device, &mavlink_tp)
struct mavlink_msg_req * next
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
static void mavlink_crc_init(uint16_t *crcAccum)
Initiliaze the buffer for the X.25 CRC.
Mavlink v1.0 message structure.
static void parse_mavlink(struct mavlink_transport *t, uint8_t c)
Mavlink character parser.
mavlink_parse_state
Receiving mavlink messages.
static void mavlink_parse_payload(struct mavlink_transport *t)
uint8_t mavlink_crc_extra[256]
#define MAVLINK_PAYLOAD_OFFSET
#define MAVLINK_COMP_ID_IDX
static void mavlink_register_msg(struct mavlink_transport *t, struct mavlink_msg_req *req)
Register a callback for a mavlink message.
struct mavlink_transport mavlink_tp
struct mavlink_msg_req * req
struct mavlink_message msg
Mavlink message.
void(* callback)(struct mavlink_message *msg)
Callback function.
#define MAVLINK_MSG_ID_IDX
mavlink_parse_state status
struct transport_rx trans
static const struct usb_device_descriptor dev
#define X25_INIT_CRC
MAVLINK CHECKSUM.
static uint16_t mavlink_crc_calculate(const uint8_t *pBuffer, uint16_t length)
Calculates the X.25 checksum on a byte buffer.
Structure to submit a callback.
static void mavlink_crc_accumulate(uint8_t data, uint16_t *crcAccum)
Accumulate the X.25 CRC by adding one char at a time.
#define MAVLINK_SYS_ID_IDX
uint8_t msg_id
Requested message ID.
static void mavlink_check_and_parse(struct link_device *dev, struct mavlink_transport *trans)
Mavlink transport protocol.