File syn_mavlink.c¶
FileList > proto > syn_mavlink.c
Go to the source code of this file
Zero-Heap MAVLink v2 Protocol Encoder & Streaming Decoder Implementation.
#include "syntropic/proto/syn_mavlink.h"#include <string.h>
Public Types¶
| Type | Name |
|---|---|
| enum | syn__mavlink_8c_1adc29c2ff13d900c2f185ee95427fb06c |
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. |
Public Static Functions¶
| Type | Name |
|---|---|
| uint8_t | get_crc_extra (uint32_t msg_id) Get CRC extra byte for specified MAVLink message ID. |
Public Types Documentation¶
enum syn__mavlink_8c_1adc29c2ff13d900c2f185ee95427fb06c¶
enum syn__mavlink_8c_1adc29c2ff13d900c2f185ee95427fb06c {
STATE_STX = 0,
STATE_LEN,
STATE_INCOMPAT,
STATE_COMPAT,
STATE_SEQ,
STATE_SYS_ID,
STATE_COMP_ID,
STATE_MSG_ID0,
STATE_MSG_ID1,
STATE_MSG_ID2,
STATE_PAYLOAD,
STATE_CRC0,
STATE_CRC1
};
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.
Public Static Functions Documentation¶
function get_crc_extra¶
Get CRC extra byte for specified MAVLink message ID.
Parameters:
msg_idMAVLink message ID.
Returns:
CRC extra seed byte.
The documentation for this class was generated from the following file src/syntropic/proto/syn_mavlink.c