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::MavMessage
s 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 ardupilotmega
feature without also using the uavionix
, icarous
, common
features.
§Read Functions
The read_*
functions can be used to read a MAVLink message for a PeakReader
wrapping a [Read]
er.
They follow the pattern read_(v1|v2|any|versioned)_(raw_message|msg)[_async][_signed]<M, _>(..)
.
All read functions check for a valid STX
marker of the corresponding MAVLink version and verify that the message CRC checksum is correct.
They attempt to read until either a whole MAVLink message is read or an error occurrs.
While doing so data without STX marker, with an invalid CRC chechsum or invalid signature (if applicable) is discarded.
To determine for which dialect the message CRC should be verified it must be specified
by using the Message
enum of the dialect as the generic M
.
Unless further specified all combinations of the function name components exist. The components are described bellow:
v1
functions read only MAVLink 1 messagesv2
functions read only MAVLink 2 messagesany
functions read messages of either MAVLink versionversioned
functions read messages of the version specified in an aditionalversion
parameterraw_message
functions return an unparsed message asMAVLinkV1MessageRaw
,MAVLinkV2MessageRaw
orMAVLinkMessageRaw
msg
functions return a parsed message as a tupel ofMavHeader
and theMessage
of the specified dialect_async
functions, which are only enabled with thetokio-1
feature, are async and read from anAsyncPeakReader
instead._signed
functions, which are only enabled with thesigning
feature, have anOption<&SigningData>
parameter that allows the use of MAVLink 2 message signing. MAVLink 1 exclusive functions do not have a_signed
variant and functions that allow both MAVLink 1 and 2 messages treat MAVLink 1 messages as unsigned. When an invalidly signed message is received it is ignored.
§Read Errors
All read_
functions return Result<_,
MessageReadError
>
.
-
All functions will return
MessageReadError::Io
ofUnexpectedEof
when EOF is encountered before a message could be read. -
All functions will return
MessageReadError::Io
when an error occurs on the underlyingRead
er orAsyncRead
er. -
Functions that parse the received message will return
MessageReadError::Parse
when the read data could not be parsed as a MAVLink message
§Write Functions
The write_
functions are used to write a MAVLink to a Write
r.
They follow the pattern write_(v1|v2|versioned)_msg[_async][_signed](..)
:
v1
functions write messages using MAVLink 1 serialisationv2
functions write messages using MAVLink 2 serialisationversioned
functions write messages using the version specified in an aditionalversion
parameter_async
functions, which are only enabled with thetokio-1
feature, are async and write from an [tokio::io::AsyncWrite
]r instead._signed
functions, which are only enabled with thesigning
feature, have anOption<&SigningData>
parameter that allows the use of MAVLink 2 message signing.
§Write errors
All write_
functions return Result<_,
MessageWriteError
>
.
- When an error occurs on the underlying
Write
er orAsyncWrite
er other thenInterrupted
the function returnsMessageWriteError::Io
- When attempting to serialize a message with an ID over 255 with MAVLink 1 a
MessageWriteError::MAVLink2Only
is returned
Modules§
- async_
peek_ reader tokio-1
- This module implements a buffered/peekable reader using async I/O.
- error
- peek_
reader - This module implements a buffered/peekable reader.
- utils
- Utilities for processing MAVLink messages
Structs§
- File
Config std
- 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
- Serial
Config direct-serial
- MAVLink address for a serial connection
- Signing
Config signing
- Configuration used for MAVLink 2 messages signing as defined in https://mavlink.io/en/guide/message_signing.html.
- Signing
Data signing
- MAVLink 2 message signing data
- TcpConfig
tcp
- MAVLink connection address for a TCP server or client
- UdpConfig
udp
- MAVLink address for a UDP server client or broadcast connection
Enums§
- Connection
Address std
ortokio-1
- 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
- Read
Version - MAVLink Version selection when attempting to read
- TcpMode
tcp
- Type of TCP connection
- UdpMode
udp
- Type of UDP connection
Constants§
- MAV_STX
- Message framing marker for MAVLink 1
- MAV_
STX_ V2 - Message framing marker for MAVLink 2
- MAX_
FRAME_ SIZE - Maximum size of any MAVLink frame in bytes.
Traits§
- Async
Connectable tokio-1
- A MAVLink connection address that can be connected to, establishing an
AsyncMavConnection
- Async
MavConnection tokio-1
- An async MAVLink connection
- Connectable
std
- A MAVLink connection address that can be connected to, establishing a
MavConnection
- MavConnection
std
- 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
std
- Connect to a MAVLink node by address string.
- connect_
async tokio-1
- Connect asynchronously to a MAVLink node by address string.
- read_
any_ msg - Read and parse a MAVLink 1 or 2 message from a
PeekReader
. - read_
any_ msg_ async tokio-1
- Asynchronously read and parse a MAVLink 1 or 2 message from a
AsyncPeekReader
. - read_
any_ msg_ async_ signed tokio-1
andsigning
- Asynchronously read and parse a MAVLink 1 or 2 message from a
AsyncPeekReader
with signing support. - read_
any_ msg_ signed signing
- Read and parse a MAVLink 1 or 2 message from a
PeekReader
with signing support. - read_
any_ raw_ message - Read a raw MAVLink 1 or 2 message from a
PeekReader
. - read_
any_ raw_ message_ async tokio-1
- Asynchronously read a raw MAVLink 1 or 2 message from a
AsyncPeekReader
. - read_
any_ raw_ message_ async_ signed tokio-1
andsigning
- Asynchronously read a raw MAVLink 1 or 2 message from a
AsyncPeekReader
with signing support. - read_
any_ raw_ message_ signed signing
- Read a raw MAVLink 1 or 2 message from a
PeekReader
with signing support. - read_
v1_ msg - Read and parse a MAVLink 1 message from a
PeekReader
. - read_
v1_ msg_ async tokio-1
- Asynchronously read and parse a MAVLink 1 message from a
AsyncPeekReader
. - read_
v1_ raw_ message - Read a raw MAVLink 1 message from a
PeekReader
. - read_
v1_ raw_ message_ async tokio-1
- Asynchronously read a raw MAVLink 1 message from a
AsyncPeekReader
. - read_
v2_ msg - Read and parse a MAVLink 2 message from a
PeekReader
. - read_
v2_ msg_ async tokio-1
- Asynchronously read and parse a MAVLink 2 message from a
AsyncPeekReader
. - read_
v2_ msg_ async_ signed tokio-1
andsigning
- Asynchronously read and parse a MAVLink 2 message with signing support from a
AsyncPeekReader
. - read_
v2_ msg_ signed signing
- Read and parse a MAVLink 2 message from a
PeekReader
. - read_
v2_ raw_ message - Read a raw MAVLink 2 message from a
PeekReader
. - read_
v2_ raw_ message_ async tokio-1
- Asynchronously read a raw MAVLink 2 message from a
AsyncPeekReader
. - read_
v2_ raw_ message_ async_ signed tokio-1
andsigning
- Asynchronously read a raw MAVLink 2 message with signing support from a
AsyncPeekReader
- read_
v2_ raw_ message_ signed signing
- Read a raw MAVLink 2 message with signing support from a
PeekReader
. - read_
versioned_ msg - Read and parse a MAVLink message of the specified version from a
PeekReader
. - read_
versioned_ msg_ async tokio-1
- Asynchronously read and parse a MAVLink message of the specified version from a
AsyncPeekReader
. - read_
versioned_ msg_ async_ signed tokio-1
andsigning
- Asynchronously read and parse a MAVLink message of the specified version from a
AsyncPeekReader
with signing support. - read_
versioned_ msg_ signed signing
- Read and parse a MAVLink message of the specified version from a
PeekReader
with signing support. - read_
versioned_ raw_ message - Read and parse a MAVLink message of the specified version from a
PeekReader
. - read_
versioned_ raw_ message_ async tokio-1
- Asynchronously read and parse a MAVLinkMessageRaw of the specified version from a
AsyncPeekReader
. - read_
versioned_ raw_ message_ async_ signed tokio-1
andsigning
- Asynchronously read and parse a MAVLinkMessageRaw of the specified version from a
AsyncPeekReader
with signing support. - read_
versioned_ raw_ message_ signed signing
- Read and parse a MAVLinkMessageRaw of the specified version from a
PeekReader
with signing support. - write_
v1_ msg - Write a MAVLink 1 message to a
Write
r. - write_
v1_ msg_ async tokio-1
- Asynchronously write a MAVLink 1 message to a [
AsyncWrite
]r. - write_
v2_ msg - Write a MAVLink 2 message to a
Write
r. - write_
v2_ msg_ async tokio-1
- Asynchronously write a MAVLink 2 message to a [
AsyncWrite
]r. - write_
v2_ msg_ async_ signed signing
andtokio-1
- Write a MAVLink 2 message to a [
AsyncWrite
]r with signing support. - write_
v2_ msg_ signed signing
- Write a MAVLink 2 message to a
Write
r with signing support. - write_
versioned_ msg - Write a MAVLink message using the given mavlink version to a
Write
r. - write_
versioned_ msg_ async tokio-1
- Asynchronously write a MAVLink message using the given MAVLink version to a [
AsyncWrite
]r. - write_
versioned_ msg_ async_ signed tokio-1
andsigning
- Asynchronously write a MAVLink message using the given MAVLink version to a [
AsyncWrite
]r with signing support. - write_
versioned_ msg_ signed signing
- Write a MAVLink message using the given mavlink version to a
Write
r with signing support.