Skip to main content

Module mavlink

Module mavlink 

Source
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§

AttitudeSetpoint
A single SET_ATTITUDE_TARGET payload, frame-independent.
GuidedSetpoint
A single guided-mode setpoint to send to the autopilot.
MavHeader
Metadata from a MAVLink packet header
SetpointError
A guided-setpoint validation failure. The message is a stable, human-readable string a caller can surface or log; it is not localized.
TunnelError
A TUNNEL build/parse failure with a stable, human-readable message (not localized).

Enums§

MavMessage
MavlinkError
MavlinkVersion
Versions of the MAVLink protocol that we support
SetpointKind
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_TARGET CRC_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 the CRC_EXTRA of any other id.
COMMAND_LONG_CRC_EXTRA
The COMMAND_LONG CRC_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 TUNNEL CRC_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_type value 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 is 32768..=65535.

Traits§

Message
A MAVLink message payload

Functions§

build_command_long_v2
Build a complete MAVLink v2 COMMAND_LONG frame for an ARBITRARY command id, returning the raw frame bytes ready to write to the MAVLink socket.
build_tunnel_v2
Build a complete MAVLink v2 TUNNEL frame carrying an opaque application payload tagged with a private payload_type, returning the raw frame bytes ready to write to the MAVLink socket.
decode_exact_frame
Decode frame as 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. false for 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), or None for 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 (0xFD for v2, 0xFE for 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 payload carried by a TUNNEL frame, reconstructed to its declared length. The symmetric decode of build_tunnel_v2: it reads the payload_length field and zero-pads the (MAVLink2 trailing-zero-truncated) wire bytes back to that length, so a caller gets exactly the payload slice that was built, even when the tail of that payload was zeros the transport truncated. Returns None when the frame is not a well-formed v2 TUNNEL.
tunnel_payload_type
The payload_type of a raw MAVLink frame if it is a TUNNEL (id 385), else None.