File syn_mavlink.h¶
FileList > proto > syn_mavlink.h
Go to the source code of this file
Zero-Heap MAVLink v2 Protocol Encoder & Streaming Decoder. More...
#include "syntropic/common/syn_defs.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_MAVLINK_Frame |
| struct | SYN_MAVLINK_Parser |
Public Types¶
| Type | Name |
|---|---|
| enum | SYN_MAVLINK_MsgId |
Public Functions¶
| Type | Name |
|---|---|
| uint16_t | syn_mavlink_crc_accumulate (uint8_t byte, uint16_t crc) Accumulate single byte into MAVLink X25 CRC. |
| SYN_Status | syn_mavlink_encode_msg (uint8_t sys_id, uint8_t comp_id, uint8_t seq, uint32_t msg_id, uint8_t crc_extra, const uint8_t * payload, uint8_t payload_len, uint8_t * buf_out, size_t * out_len) Encode a MAVLink v2 packet into raw byte buffer. |
| SYN_Status | syn_mavlink_init (SYN_MAVLINK_Parser * parser) Initialize MAVLink v2 parser instance. |
| SYN_Status | syn_mavlink_parse_byte (SYN_MAVLINK_Parser * parser, uint8_t byte, SYN_MAVLINK_Frame * frame) Process incoming byte from serial stream. |
Macros¶
| Type | Name |
|---|---|
| define | SYN_MAVLINK_HEADER_LEN 10U |
| define | SYN_MAVLINK_MAX_PAYLOAD_LEN 255U |
| define | SYN_MAVLINK_STX_V2 0xFD |
Detailed Description¶
MAVLink v2 Frame Specification: Header: [0xFD] + [Payload Len 1B] + [Incompat Flags 1B] + [Compat Flags 1B] + [Seq 1B] + [Sys ID 1B] + [Comp ID 1B] + [Msg ID 3B (Little-Endian)] Payload: [Payload N B] Checksum: [16-bit CRC-X25 over (Header_without_STX + Payload + CRC_Extra)]
Public Types Documentation¶
enum SYN_MAVLINK_MsgId¶
enum SYN_MAVLINK_MsgId {
SYN_MAVLINK_MSG_HEARTBEAT = 0U,
SYN_MAVLINK_MSG_SYS_STATUS = 1U,
SYN_MAVLINK_MSG_ATTITUDE = 30U,
SYN_MAVLINK_MSG_GLOBAL_POSITION_INT = 33U,
SYN_MAVLINK_MSG_VFR_HUD = 74U
};
MAVLink Message IDs.
Public Functions Documentation¶
function syn_mavlink_crc_accumulate¶
Accumulate single byte into MAVLink X25 CRC.
Parameters:
byteInput byte to accumulate.crcInitial CRC accumulator value.
Returns:
Updated 16-bit CRC value.
function syn_mavlink_encode_msg¶
Encode a MAVLink v2 packet into raw byte buffer.
SYN_Status syn_mavlink_encode_msg (
uint8_t sys_id,
uint8_t comp_id,
uint8_t seq,
uint32_t msg_id,
uint8_t crc_extra,
const uint8_t * payload,
uint8_t payload_len,
uint8_t * buf_out,
size_t * out_len
)
Parameters:
sys_idSystem ID (1..255).comp_idComponent ID (1..255).seqPacket sequence number.msg_idMessage ID.crc_extraCRC Extra byte for the specific message ID.payloadPointer to payload data buffer (or NULL if 0 len).payload_lenPayload byte length.buf_outOutput byte buffer (must hold at leastpayload_len + 12bytes).out_lenPointer to receive final encoded frame length.
Returns:
SYN_OK on success.
function syn_mavlink_init¶
Initialize MAVLink v2 parser instance.
Parameters:
parserPointer to parser struct.
Returns:
SYN_OK on success.
function syn_mavlink_parse_byte¶
Process incoming byte from serial stream.
SYN_Status syn_mavlink_parse_byte (
SYN_MAVLINK_Parser * parser,
uint8_t byte,
SYN_MAVLINK_Frame * frame
)
Parameters:
parserPointer to parser struct.byteIncoming byte.frameDestination frame struct (populated on valid complete packet).
Returns:
SYN_OK on complete valid frame, SYN_BUSY if processing, SYN_ERROR on CRC mismatch.
Macro Definition Documentation¶
define SYN_MAVLINK_HEADER_LEN¶
MAVLink v2 header length in bytes
define SYN_MAVLINK_MAX_PAYLOAD_LEN¶
Maximum MAVLink payload length in bytes
define SYN_MAVLINK_STX_V2¶
MAVLink v2 Start of Frame marker byte (0xFD)
The documentation for this class was generated from the following file src/syntropic/proto/syn_mavlink.h