AeroCoder Logo

Serialization, Routing, and Security

Serialization format

Little-endian encoding, zero-extension truncation in v2, and field ordering rules.

MAVLink serializes all fields in little-endian byte order. Fields are reordered in the wire encoding: largest types first (uint64 before uint32 before uint16 before uint8). This natural alignment avoids padding on most architectures.

In MAVLink 2, trailing zero bytes in the payload are truncated before transmission. The receiver pads the payload back with zeros based on the expected message length. This "zero-extension" can reduce bandwidth by 20–40% for sparse messages.

c

// C header field order example (generated by mavgen)
// XML order: uint8_t type, float lat, uint16_t alt, uint32_t time
// Wire order (re-sorted by size, descending):
typedef struct {
    uint32_t time;   // 4 bytes — largest first
    float    lat;    // 4 bytes
    uint16_t alt;    // 2 bytes
    uint8_t  type;   // 1 byte — smallest last
} mavlink_example_t;

CRC-16/MCRF4XX

The checksum covers bytes 1 through N (excluding STX), plus the CRC_EXTRA seed byte derived from the message schema. This ensures both sender and receiver agree on the field layout even if the message XML has diverged.

← Previous

File Transfer Protocol (FTP)

Next →

Message routing rules

Edit this page on mavlink.io ↗

On This Page

CRC-16/MCRF4XX

© 2024 AeroCoder. All rights reserved

TwitterYouTubeInstagram