Expand description
The MAVLink message set.
§Message sets and the Message trait
Each message set has its own module with corresponding data types, including a MavMessage enum
that represents all possible messages in that message set. The Message trait is used to
represent messages in an abstract way, and each MavMessage enum implements this trait (for
example, ardupilotmega::MavMessage). This is then monomorphized to the specific message
set you are using in your application at compile-time via type parameters. If you expect
ArduPilotMega-flavored messages, then you will need a MavConnection<ardupilotmega::MavMessage>
and you will receive ardupilotmega::MavMessages from it.
Some message sets include others. For example, most message sets include the
common message set. These included values are not differently represented in the MavMessage enum: a message
in the common message set received on an ArduPilotMega connection will just be an
ardupilotmega::MavMessage.
If you want to enable a given message set, you do not have to enable the
feature for the message sets that it includes. For example, you can use the dialect-ardupilotmega
feature without also using the dialect-uavionix, dialect-icarous, dialect-common features.
§Reading
Use MavlinkReader for blocking input and AsyncMavlinkReader for
asynchronous input. Both readers retain partial frames and read-ahead data
between calls, discard invalid candidates, and verify message CRCs before
returning.
§Write Functions
The write_ functions are used to write a MAVLink to a Writer.
They follow the pattern write_(v1|v2|versioned)_msg[_async][_signed](..):
v1functions write messages using MAVLink 1 serialisationv2functions write messages using MAVLink 2 serialisationversionedfunctions write messages using the version specified in an aditionalversionparameter_asyncfunctions, which are only enabled with thetokiofeature, are async and write to atokio::io::AsyncWriteinstead._signedfunctions, which are only enabled with themav2-message-signingfeature, have anOption<&SigningData>parameter that allows the use of MAVLink 2 message signing.
§Write errors
All write_ functions return Result<_, MessageWriteError>.
- When an error other than
std::io::ErrorKind::Interruptedoccurs on the underlying writer, the function returnsMessageWriteError::Io - When attempting to serialize a message with an ID over 255 with MAVLink 1 a
MessageWriteError::MAVLink2Onlyis returned
Modules§
Structs§
- Async
Dialect Connection tokioand (stdortokio) - A concrete async connection using a dialect.
- Async
Mavlink Reader tokio, orembeddedand non-std - Incrementally reads complete MAVLink frames from an asynchronous byte stream.
- Dialect
Connection stdand (stdortokio) - A concrete blocking connection using a dialect.
- File
Config stdand (stdortokio) - MAVLink connection address for a file input
- MAVLink
V1Message Raw - Byte buffer containing the raw representation of a MAVLink 1 message beginning with the STX marker.
- MAVLink
V2Message Raw - Byte buffer containing the raw representation of a MAVLink 2 message beginning with the STX marker.
- MavFrame
- Encapsulation of the MAVLink message and the header, important to preserve information about the sender system and component id.
- MavHeader
- Metadata from a MAVLink packet header
- Mavlink
Reader - Incrementally reads complete MAVLink frames from a blocking byte stream.
- Serial
Config transport-direct-serialand (stdortokio) - MAVLink address for a serial connection
- Signing
Config mav2-message-signing - Configuration used for MAVLink 2 messages signing as defined in https://mavlink.io/en/guide/message_signing.html.
- Signing
Data mav2-message-signing - MAVLink 2 message signing data
- TcpConfig
transport-tcpand (stdortokio) - MAVLink connection address for a TCP server or client
- UdpConfig
transport-udpand (stdortokio) - MAVLink address for a UDP server client or broadcast connection
Enums§
- Connection
Address stdortokio - A parsed MAVLink connection address
- MAVLink
Message Raw - Raw byte representation of a MAVLink message of either version
- Mavlink
Version - Versions of the MAVLink protocol that we support
- TcpMode
transport-tcpand (stdortokio) - Type of TCP connection
- UdpMode
transport-udpand (stdortokio) - Type of UDP connection
Constants§
- MAV_STX
- Message framing marker for MAVLink 1
- MAV_
STX_ V2 - Message framing marker for MAVLink 2
Traits§
- Async
Connectable tokioand (stdortokio) - A MAVLink connection address that can be connected to, establishing an
AsyncMavConnection - Async
MavConnection tokioand (stdortokio) - An async MAVLink connection
- Connectable
stdand (stdortokio) - A MAVLink connection address that can be connected to, establishing a
MavConnection - Dialect
- An instance-backed MAVLink dialect.
- MavConnection
stdand (stdortokio) - A MAVLink connection
- Message
- A MAVLink message payload
- Message
Data
Functions§
- calculate_
crc - Calculates the CRC checksum of a messages header, payload and the CRC_EXTRA byte.
- connect
stdand (stdortokio) - Connect to a MAVLink node by address string.
- connect_
async tokioand (stdortokio) - Connect asynchronously to a MAVLink node by address string.
- connect_
async_ with_ dialect tokioand (stdortokio) - Connect asynchronously to a MAVLink node using a runtime-loaded dialect.
- connect_
with_ dialect stdand (stdortokio) - Connect to a MAVLink node using a runtime-loaded dialect.
- write_
v1_ msg - Write a MAVLink 1 message to a
Writer. - write_
v1_ msg_ async tokio - Asynchronously write a MAVLink 1 message to a [
AsyncWrite]r. - write_
v2_ msg - Write a MAVLink 2 message to a
Writer. - write_
v2_ msg_ async tokio - Asynchronously write a MAVLink 2 message to a [
AsyncWrite]r. - write_
v2_ msg_ async_ signed mav2-message-signingandtokio - Write a MAVLink 2 message to a [
AsyncWrite]r with signing support. - write_
v2_ msg_ signed mav2-message-signing - Write a MAVLink 2 message to a
Writer with signing support. - write_
versioned_ msg - Write a MAVLink message using the given mavlink version to a
Writer. - write_
versioned_ msg_ async tokio - Asynchronously write a MAVLink message using the given MAVLink version to a [
AsyncWrite]r. - write_
versioned_ msg_ async_ signed mav2-message-signingandtokio - Asynchronously write a MAVLink message using the given MAVLink version to a [
AsyncWrite]r with signing support. - write_
versioned_ msg_ async_ with_ dialect tokio - Asynchronously write a message through an instance-backed dialect.
- write_
versioned_ msg_ async_ with_ dialect_ signed mav2-message-signingandtokio - Asynchronously write a dialect message with MAVLink 2 signing when configured.
- write_
versioned_ msg_ signed mav2-message-signing - Write a MAVLink message using the given mavlink version to a
Writer with signing support. - write_
versioned_ msg_ with_ dialect - Write a MAVLink message using an instance-backed dialect.
- write_
versioned_ msg_ with_ dialect_ signed mav2-message-signing - Write a dialect message with MAVLink 2 signing when configured.
Type Aliases§
- Async
Connection tokioand (stdortokio) - A concrete async connection using generated messages.
- Connection
stdand (stdortokio) - A concrete blocking connection using generated messages.