Skip to main content

Module mavlink

Module mavlink 

Source
Expand description

The C ABI for the MAVLink wire protocol.

MAVLink is the language drones speak, so talking to a PX4 or ArduPilot autopilot means putting exactly the right bytes on the wire and trusting the bytes that come back. This is that byte layer: assembling and parsing v1 and v2 frames, the CRC-16/MCRF4XX checksum every frame carries, the per-message CRC_EXTRA seed that catches a frame whose shape does not match what the receiver expects, and MAVLink 2 signing.

§Any dialect, not only the common one

A receiver has to know a message’s CRC_EXTRA before it can check the frame carrying it. The common dialect’s seeds are built in, but a vehicle running a vendor or private dialect uses ids this build has never heard of. Two things keep those reachable: pamoja_mavlink_message_crc_extra derives a seed from a message definition the way the specification does, and a PamojaMavlinkDialect table carries the results, taking precedence over the built-in registry. Nothing here is limited to the ids this crate happens to type.

This module moves a message’s bytes. mavlink_schema is the layer above, which gives those bytes named fields, and mavlink_protocol the one above that, which turns single messages into the mission, command, and offboard exchanges.

Structs§

PamojaMavlinkDialect
The CRC_EXTRA seeds of a dialect beyond the common one.
PamojaMavlinkField
One field of a message definition, as the CRC_EXTRA derivation reads it.
PamojaMavlinkFrame
One MAVLink frame, assembled or received.
PamojaMavlinkHeader
The addressing fields a sender stamps on every frame.
PamojaMavlinkParser
A streaming frame parser, and the frames it has completed.
PamojaMavlinkSigner
A signing key and the monotonic timestamp that goes with it.
PamojaMavlinkVerifier
A signing key and the timestamps it has already accepted.

Constants§

PAMOJA_MAVLINK_DEFAULT_TIMESTAMP_WINDOW
The default window a verifier accepts a timestamp within, in microseconds.
PAMOJA_MAVLINK_EPOCH_OFFSET_SECS
The Unix time MAVLink counts signing timestamps from, in seconds.
PAMOJA_MAVLINK_IFLAG_SIGNED
The incompatibility flag that marks a v2 frame as signed.
PAMOJA_MAVLINK_KEY_LEN
The length of a signing key, in bytes.
PAMOJA_MAVLINK_MAGIC_V1
The start marker of a v1 frame.
PAMOJA_MAVLINK_MAGIC_V2
The start marker of a v2 frame.
PAMOJA_MAVLINK_MAX_FRAME
The largest frame, in bytes, header, checksum and signature included.
PAMOJA_MAVLINK_MAX_PAYLOAD
The largest payload a frame can carry, in bytes.
PAMOJA_MAVLINK_SIGNATURE_LEN
The length of a v2 signature block, in bytes.
PAMOJA_MAVLINK_VERSION_V1
The original wire format, with a six-byte header.
PAMOJA_MAVLINK_VERSION_V2
The current wire format, with a 24-bit message id, flags, and optional signing.

Functions§

pamoja_mavlink_crc16_mcrf4xx
Returns the CRC-16/MCRF4XX checksum of a byte string.
pamoja_mavlink_dialect_add
Adds or replaces the CRC_EXTRA seed for a message id.
pamoja_mavlink_dialect_crc_extra
Returns the seed a dialect resolves a message id to.
pamoja_mavlink_dialect_free
Releases a dialect table.
pamoja_mavlink_dialect_new
Creates an empty dialect table.
pamoja_mavlink_frame_bytes
Returns a pointer to a frame’s bytes, ready to put on the wire.
pamoja_mavlink_frame_encode
Assembles a frame carrying a message.
pamoja_mavlink_frame_free
Releases a frame.
pamoja_mavlink_frame_header
Returns the addressing fields a frame carries.
pamoja_mavlink_frame_incompat_flags
Returns the incompatibility flags a v2 frame declares.
pamoja_mavlink_frame_is_signed
Reports whether a frame carries a signature.
pamoja_mavlink_frame_message_id
Returns the id of the message a frame carries.
pamoja_mavlink_frame_parse
Parses one frame, checking it against a known CRC_EXTRA.
pamoja_mavlink_frame_parse_known
Parses one frame, looking its CRC_EXTRA up as it goes.
pamoja_mavlink_frame_payload
Returns a pointer to a frame’s payload.
pamoja_mavlink_frame_signature
Copies a frame’s signature block out.
pamoja_mavlink_frame_version
Returns the wire format a frame uses.
pamoja_mavlink_known_crc_extra
Returns the CRC_EXTRA the common dialect publishes for a message id.
pamoja_mavlink_message_crc_extra
Derives the CRC_EXTRA seed of a message from its definition.
pamoja_mavlink_parser_free
Releases a parser.
pamoja_mavlink_parser_new
Creates a parser with an empty buffer.
pamoja_mavlink_parser_next
Takes the next completed frame out of the parser.
pamoja_mavlink_parser_pending
Returns how many completed frames are waiting to be taken.
pamoja_mavlink_parser_push
Feeds bytes off a link into the parser.
pamoja_mavlink_raw_message_to_frame
Assembles a v2 frame carrying a message this build does not type.
pamoja_mavlink_signer_free
Releases a signer.
pamoja_mavlink_signer_link_id
Returns the link a signer signs on.
pamoja_mavlink_signer_new
Creates a signer.
pamoja_mavlink_signer_sign
Signs a message into a v2 frame.
pamoja_mavlink_timestamp_from_unix_micros
Converts Unix time into the timestamp MAVLink signing counts in.
pamoja_mavlink_verifier_free
Releases a verifier.
pamoja_mavlink_verifier_new
Creates a verifier.
pamoja_mavlink_verifier_set_window
Sets how far a timestamp may run ahead of the last one accepted.
pamoja_mavlink_verifier_verify
Checks a frame’s signature and its place in the timestamp sequence.