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);
142 struct transport_rx
trans;
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_transport mavlink_tp
struct transport_rx trans
static uint16_t mavlink_crc_calculate(const uint8_t *pBuffer, uint16_t length)
Calculates the X.25 checksum on a byte buffer.
#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.
#define X25_INIT_CRC
MAVLINK CHECKSUM.
static void mavlink_crc_accumulate(uint8_t data, uint16_t *crcAccum)
Accumulate the X.25 CRC by adding one char at a time.
static void mavlink_check_and_parse(struct link_device *dev, struct mavlink_transport *trans)
#define MAVLINK_SYS_ID_IDX
static void parse_mavlink(struct mavlink_transport *t, uint8_t c)
Mavlink character parser.
uint8_t mavlink_crc_extra[256]
mavlink_parse_state status
static void mavlink_parse_payload(struct mavlink_transport *t)
mavlink_parse_state
Receiving mavlink messages.
@ MAVLINK_PARSE_STATE_IDLE
@ MAVLINK_PARSE_STATE_GOT_LENGTH
@ MAVLINK_PARSE_STATE_GOT_CRC1
@ MAVLINK_PARSE_STATE_GOT_PAYLOAD
@ MAVLINK_PARSE_STATE_UNINIT
@ MAVLINK_PARSE_STATE_GOT_STX
static void mavlink_crc_init(uint16_t *crcAccum)
Initiliaze the buffer for the X.25 CRC.
#define MAVLINK_MSG_ID_IDX
#define MAVLINK_PAYLOAD_OFFSET
struct mavlink_msg_req * req
Mavlink v1.0 message structure.
Mavlink transport protocol.
static const struct usb_device_descriptor dev
Structure to submit a callback.
void(* callback)(struct mavlink_message *msg)
Callback function.
struct mavlink_msg_req * next
struct mavlink_message msg
Mavlink message.
uint8_t msg_id
Requested message ID.
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.