Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
mavlink_decoder.h File Reference

simple decoder of mavlink message More...

#include "std.h"
#include "subsystems/datalink/transport.h"
#include "mcu_periph/uart.h"
+ Include dependency graph for mavlink_decoder.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  mavlink_message
 Mavlink v1.0 message structure. More...
 
struct  mavlink_msg_req
 Structure to submit a callback. More...
 
struct  mavlink_transport
 Mavlink transport protocol. More...
 

Macros

#define STXMAV   0xFE
 
#define MAVLINK_PAYLOAD_OFFSET   4
 
#define MAVLINK_SEQ_IDX   0
 
#define MAVLINK_SYS_ID_IDX   1
 
#define MAVLINK_COMP_ID_IDX   2
 
#define MAVLINK_MSG_ID_IDX   3
 
#define X25_INIT_CRC   0xffff
 MAVLINK CHECKSUM. More...
 
#define MavlinkBuffer(_dev)   TransportLink(_dev,ChAvailable())
 
#define ReadMavlinkBuffer(_dev, _trans)   { while (TransportLink(_dev,ChAvailable())&&!(_trans.trans.msg_received)) parse_mavlink(&(_trans),TransportLink(_dev,Getch())); }
 
#define MavlinkCheckAndParse(_dev, _trans)
 
#define MavlinkDatalinkEvent()   MavlinkCheckAndParse(MAVLINK_UART, mavlink_tp)
 

Enumerations

enum  mavlink_parse_state {
  MAVLINK_PARSE_STATE_UNINIT =0, MAVLINK_PARSE_STATE_IDLE, MAVLINK_PARSE_STATE_GOT_STX, MAVLINK_PARSE_STATE_GOT_LENGTH,
  MAVLINK_PARSE_STATE_GOT_PAYLOAD, MAVLINK_PARSE_STATE_GOT_CRC1
}
 Receiving mavlink messages. More...
 

Functions

static void mavlink_crc_accumulate (uint8_t data, uint16_t *crcAccum)
 Accumulate the X.25 CRC by adding one char at a time. More...
 
static void mavlink_crc_init (uint16_t *crcAccum)
 Initiliaze the buffer for the X.25 CRC. More...
 
static uint16_t mavlink_crc_calculate (const uint8_t *pBuffer, uint16_t length)
 Calculates the X.25 checksum on a byte buffer. More...
 
static void mavlink_register_msg (struct mavlink_transport *t, struct mavlink_msg_req *req)
 Register a callback for a mavlink message. More...
 
static void parse_mavlink (struct mavlink_transport *t, uint8_t c)
 Mavlink character parser. More...
 
static void mavlink_parse_payload (struct mavlink_transport *t)
 

Variables

uint8_t mavlink_crc_extra [256]
 
struct mavlink_transport mavlink_tp
 

Detailed Description

simple decoder of mavlink message

Definition in file mavlink_decoder.h.

Macro Definition Documentation

#define MAVLINK_COMP_ID_IDX   2

Definition at line 60 of file mavlink_decoder.h.

Referenced by mavlink_parse_payload().

#define MAVLINK_MSG_ID_IDX   3

Definition at line 61 of file mavlink_decoder.h.

Referenced by mavlink_parse_payload(), and parse_mavlink().

#define MAVLINK_PAYLOAD_OFFSET   4

Definition at line 56 of file mavlink_decoder.h.

Referenced by mavlink_parse_payload(), and parse_mavlink().

#define MAVLINK_SEQ_IDX   0

Definition at line 58 of file mavlink_decoder.h.

Referenced by mavlink_parse_payload().

#define MAVLINK_SYS_ID_IDX   1

Definition at line 59 of file mavlink_decoder.h.

Referenced by mavlink_parse_payload().

#define MavlinkBuffer (   _dev)    TransportLink(_dev,ChAvailable())

Definition at line 247 of file mavlink_decoder.h.

#define MavlinkCheckAndParse (   _dev,
  _trans 
)
Value:
{ \
if (MavlinkBuffer(_dev)) { \
ReadMavlinkBuffer(_dev,_trans); \
if (_trans.trans.msg_received) { \
_trans.trans.msg_received = FALSE; \
} \
} \
}
if(PrimarySpektrumState.SpektrumTimer)--PrimarySpektrumState.SpektrumTimer
#define FALSE
Definition: imu_chimu.h:141

Definition at line 250 of file mavlink_decoder.h.

#define MavlinkDatalinkEvent ( )    MavlinkCheckAndParse(MAVLINK_UART, mavlink_tp)

Definition at line 261 of file mavlink_decoder.h.

#define ReadMavlinkBuffer (   _dev,
  _trans 
)    { while (TransportLink(_dev,ChAvailable())&&!(_trans.trans.msg_received)) parse_mavlink(&(_trans),TransportLink(_dev,Getch())); }

Definition at line 248 of file mavlink_decoder.h.

#define STXMAV   0xFE

Definition at line 38 of file mavlink_decoder.h.

Referenced by parse_mavlink().

#define X25_INIT_CRC   0xffff

MAVLINK CHECKSUM.

Definition at line 64 of file mavlink_decoder.h.

Referenced by mavlink_crc_init().

Enumeration Type Documentation

Receiving mavlink messages.

Enumerator
MAVLINK_PARSE_STATE_UNINIT 
MAVLINK_PARSE_STATE_IDLE 
MAVLINK_PARSE_STATE_GOT_STX 
MAVLINK_PARSE_STATE_GOT_LENGTH 
MAVLINK_PARSE_STATE_GOT_PAYLOAD 
MAVLINK_PARSE_STATE_GOT_CRC1 

Definition at line 120 of file mavlink_decoder.h.

Function Documentation

static void mavlink_crc_accumulate ( uint8_t  data,
uint16_t crcAccum 
)
inlinestatic

Accumulate the X.25 CRC by adding one char at a time.

The checksum function adds the hash of one char at a time to the 16 bit checksum (uint16_t).

Parameters
datanew char to hash
crcAccumthe already accumulated checksum

Definition at line 80 of file mavlink_decoder.h.

Referenced by mavlink_crc_calculate(), and parse_mavlink().

+ Here is the caller graph for this function:

static uint16_t mavlink_crc_calculate ( const uint8_t pBuffer,
uint16_t  length 
)
inlinestatic

Calculates the X.25 checksum on a byte buffer.

Parameters
pBufferbuffer containing the byte array to hash
lengthlength of the byte array
Returns
the checksum over the buffer bytes

Definition at line 107 of file mavlink_decoder.h.

References mavlink_crc_accumulate(), and mavlink_crc_init().

+ Here is the call graph for this function:

static void mavlink_crc_init ( uint16_t crcAccum)
inlinestatic

Initiliaze the buffer for the X.25 CRC.

Parameters
crcAccumthe 16 bit X.25 CRC

Definition at line 95 of file mavlink_decoder.h.

References X25_INIT_CRC.

Referenced by mavlink_crc_calculate(), and parse_mavlink().

+ Here is the caller graph for this function:

static void mavlink_register_msg ( struct mavlink_transport t,
struct mavlink_msg_req req 
)
inlinestatic

Register a callback for a mavlink message.

Definition at line 163 of file mavlink_decoder.h.

References mavlink_msg_req::next, req, and mavlink_transport::req.

Referenced by px4flow_init().

+ Here is the caller graph for this function:

Variable Documentation

uint8_t mavlink_crc_extra[256]

Definition at line 32 of file mavlink_decoder.c.

Referenced by parse_mavlink().

struct mavlink_transport mavlink_tp

Definition at line 29 of file mavlink_decoder.c.

Referenced by px4flow_init().