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§
- Pamoja
Mavlink Dialect - The
CRC_EXTRAseeds of a dialect beyond the common one. - Pamoja
Mavlink Field - One field of a message definition, as the
CRC_EXTRAderivation reads it. - Pamoja
Mavlink Frame - One MAVLink frame, assembled or received.
- Pamoja
Mavlink Header - The addressing fields a sender stamps on every frame.
- Pamoja
Mavlink Parser - A streaming frame parser, and the frames it has completed.
- Pamoja
Mavlink Signer - A signing key and the monotonic timestamp that goes with it.
- Pamoja
Mavlink Verifier - 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_EXTRAseed 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_EXTRAup 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_EXTRAthe common dialect publishes for a message id. - pamoja_
mavlink_ ⚠message_ crc_ extra - Derives the
CRC_EXTRAseed 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.