Expand description
MAVLink v2 codec for the ardupilotmega dialect.
Behind the mavlink feature because the dialect is a large, slow-to-compile
generated enum and most consumers do not need it. This wraps rust-mavlink
with parse/serialize helpers over byte slices, which is what flows on the
MAVLink socket. The router (which owns the serial link and fans frames out
to the socket) builds on this; per the migration plan the decode is
validated against the ground station’s decoder before cutover, since
rust-mavlink is not assumed to be bit-identical to the audited decoder.
Modules§
- ardupilotmega
- MAVLink ardupilotmega dialect.
Structs§
- Attitude
Setpoint - A single
SET_ATTITUDE_TARGETpayload, frame-independent. - Guided
Setpoint - A single guided-mode setpoint to send to the autopilot.
- MavHeader
- Metadata from a MAVLink packet header
- Setpoint
Error - A guided-setpoint validation failure. The message is a stable, human-readable string a caller can surface or log; it is not localized.
- Tunnel
Error - A TUNNEL build/parse failure with a stable, human-readable message (not localized).
Enums§
- MavMessage
- Mavlink
Error - Mavlink
Version - Versions of the MAVLink protocol that we support
- Setpoint
Kind - Which of the two position-target messages a setpoint targets. The local message carries x/y/z metres in a local/body frame; the global message carries scaled lat/lon (1e7) plus an altitude in metres in a global frame. A single-shot send picks one and fills the fields the type mask does not ignore.
Constants§
- ATTITUDE_
TARGET_ CRC_ EXTRA - The
SET_ATTITUDE_TARGETCRC_EXTRA, the message-definition seed the X.25 checksum folds in last (the value the canonical dialect carries for the message; not the id). This is a distinct constant for this message — do not confuse it with theCRC_EXTRAof any other id. - COMMAND_
LONG_ CRC_ EXTRA - The
COMMAND_LONGCRC_EXTRA, the message-definition seed the X.25 checksum folds in last. This is the value the canonical dialect carries for the message (the same value the generated codec and the reference Python encoder use); it is NOT the message id. - MSG_
ID_ COMMAND_ LONG - MAVLink message id of
COMMAND_LONG(0x4C). - MSG_
ID_ SET_ ATTITUDE_ TARGET - MAVLink message id of
SET_ATTITUDE_TARGET. - MSG_
ID_ SET_ POSITION_ TARGET_ GLOBAL_ INT - MAVLink message id of
SET_POSITION_TARGET_GLOBAL_INT. - MSG_
ID_ SET_ POSITION_ TARGET_ LOCAL_ NED - MAVLink message id of
SET_POSITION_TARGET_LOCAL_NED. - MSG_
ID_ TUNNEL - MAVLink message id of
TUNNEL. - TUNNEL_
CRC_ EXTRA - The
TUNNELCRC_EXTRA, the message-definition seed the X.25 checksum folds in last (the value the canonical dialect carries for the message; not the id). - TUNNEL_
MAX_ PAYLOAD - Maximum bytes a single TUNNEL frame can carry: the fixed-size payload array.
- TUNNEL_
RESERVED_ PAYLOAD_ TYPE_ MAX - The highest
payload_typevalue reserved by the standard registry. Values at or below this are reserved; an application uses a value strictly above it so it can never collide with a registered type, and so an unrelated peer that does not recognize the value ignores the frame. The numeric field on the wire is a u16, so the usable application range is32768..=65535.
Traits§
- Message
- A MAVLink message payload
Functions§
- build_
command_ long_ v2 - Build a complete MAVLink v2
COMMAND_LONGframe for an ARBITRARYcommandid, returning the raw frame bytes ready to write to the MAVLink socket. - build_
tunnel_ v2 - Build a complete MAVLink v2
TUNNELframe carrying an opaque applicationpayloadtagged with a privatepayload_type, returning the raw frame bytes ready to write to the MAVLink socket. - decode_
exact_ frame - Decode
frameas exactly one whole MAVLink frame, with no resynchronisation. - frame_
checksum_ ok - Whether a complete MAVLink v1/v2 frame carries a valid checksum: the X.25
over every byte after the start-of-frame through the payload, folded with
the message’s CRC_EXTRA.
falsefor a truncated frame and for a message id outside the dialect, whose CRC_EXTRA is unknown: its checksum cannot be checked, and a byte-stream framer resyncing after line noise must not take an unverifiable candidate as a frame. - message_
id_ from_ name - The message id the ardupilotmega dialect assigns to
name(e.g."GLOBAL_POSITION_INT"→ 33), orNonefor a name the dialect does not define. - parse_
any - Parse one MAVLink frame of either protocol version, selected by the leading
start-of-frame magic byte (
0xFDfor v2,0xFEfor v1). The original frame bytes are unchanged and are not re-encoded. - parse_
v1 - Parse one MAVLink v1 frame (STX
0xFE) from a byte slice into its header and message. A v1 frame has a 6-byte header (STX, payload length, sequence, system id, component id, message id), the payload, and a 2-byte checksum. There are no incompat/compat flags and no signature block. - parse_
v2 - Parse one MAVLink v2 frame from a byte slice into its header and message.
- serialize_
v1 - Serialize a message into a complete MAVLink v1 frame (STX
0xFE). - serialize_
v2 - Serialize a message into a complete MAVLink v2 frame.
- tunnel_
payload - The opaque application
payloadcarried by aTUNNELframe, reconstructed to its declared length. The symmetric decode ofbuild_tunnel_v2: it reads thepayload_lengthfield and zero-pads the (MAVLink2 trailing-zero-truncated) wire bytes back to that length, so a caller gets exactly thepayloadslice that was built, even when the tail of that payload was zeros the transport truncated. ReturnsNonewhen the frame is not a well-formed v2 TUNNEL. - tunnel_
payload_ type - The
payload_typeof a raw MAVLink frame if it is aTUNNEL(id 385), elseNone.