Skip to main content

Crate mavlink_core

Crate mavlink_core 

Source
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](..):

  • v1 functions write messages using MAVLink 1 serialisation
  • v2 functions write messages using MAVLink 2 serialisation
  • versioned functions write messages using the version specified in an aditional version parameter
  • _async functions, which are only enabled with the tokio feature, are async and write to a tokio::io::AsyncWrite instead.
  • _signed functions, which are only enabled with the mav2-message-signing feature, have an Option<&SigningData> parameter that allows the use of MAVLink 2 message signing.

§Write errors

All write_ functions return Result<_, MessageWriteError>.

Modules§

consts
MAVLink frame constants.
error
types
utils
Utilities for processing MAVLink messages

Structs§

AsyncDialectConnectiontokio and (std or tokio)
A concrete async connection using a dialect.
AsyncMavlinkReadertokio, or embedded and non-std
Incrementally reads complete MAVLink frames from an asynchronous byte stream.
DialectConnectionstd and (std or tokio)
A concrete blocking connection using a dialect.
FileConfigstd and (std or tokio)
MAVLink connection address for a file input
MAVLinkV1MessageRaw
Byte buffer containing the raw representation of a MAVLink 1 message beginning with the STX marker.
MAVLinkV2MessageRaw
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
MavlinkReader
Incrementally reads complete MAVLink frames from a blocking byte stream.
SerialConfigtransport-direct-serial and (std or tokio)
MAVLink address for a serial connection
SigningConfigmav2-message-signing
Configuration used for MAVLink 2 messages signing as defined in https://mavlink.io/en/guide/message_signing.html.
SigningDatamav2-message-signing
MAVLink 2 message signing data
TcpConfigtransport-tcp and (std or tokio)
MAVLink connection address for a TCP server or client
UdpConfigtransport-udp and (std or tokio)
MAVLink address for a UDP server client or broadcast connection

Enums§

ConnectionAddressstd or tokio
A parsed MAVLink connection address
MAVLinkMessageRaw
Raw byte representation of a MAVLink message of either version
MavlinkVersion
Versions of the MAVLink protocol that we support
TcpModetransport-tcp and (std or tokio)
Type of TCP connection
UdpModetransport-udp and (std or tokio)
Type of UDP connection

Constants§

MAV_STX
Message framing marker for MAVLink 1
MAV_STX_V2
Message framing marker for MAVLink 2

Traits§

AsyncConnectabletokio and (std or tokio)
A MAVLink connection address that can be connected to, establishing an AsyncMavConnection
AsyncMavConnectiontokio and (std or tokio)
An async MAVLink connection
Connectablestd and (std or tokio)
A MAVLink connection address that can be connected to, establishing a MavConnection
Dialect
An instance-backed MAVLink dialect.
MavConnectionstd and (std or tokio)
A MAVLink connection
Message
A MAVLink message payload
MessageData

Functions§

calculate_crc
Calculates the CRC checksum of a messages header, payload and the CRC_EXTRA byte.
connectstd and (std or tokio)
Connect to a MAVLink node by address string.
connect_asynctokio and (std or tokio)
Connect asynchronously to a MAVLink node by address string.
connect_async_with_dialecttokio and (std or tokio)
Connect asynchronously to a MAVLink node using a runtime-loaded dialect.
connect_with_dialectstd and (std or tokio)
Connect to a MAVLink node using a runtime-loaded dialect.
write_v1_msg
Write a MAVLink 1 message to a Writer.
write_v1_msg_asynctokio
Asynchronously write a MAVLink 1 message to a [AsyncWrite]r.
write_v2_msg
Write a MAVLink 2 message to a Writer.
write_v2_msg_asynctokio
Asynchronously write a MAVLink 2 message to a [AsyncWrite]r.
write_v2_msg_async_signedmav2-message-signing and tokio
Write a MAVLink 2 message to a [AsyncWrite]r with signing support.
write_v2_msg_signedmav2-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_asynctokio
Asynchronously write a MAVLink message using the given MAVLink version to a [AsyncWrite]r.
write_versioned_msg_async_signedmav2-message-signing and tokio
Asynchronously write a MAVLink message using the given MAVLink version to a [AsyncWrite]r with signing support.
write_versioned_msg_async_with_dialecttokio
Asynchronously write a message through an instance-backed dialect.
write_versioned_msg_async_with_dialect_signedmav2-message-signing and tokio
Asynchronously write a dialect message with MAVLink 2 signing when configured.
write_versioned_msg_signedmav2-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_signedmav2-message-signing
Write a dialect message with MAVLink 2 signing when configured.

Type Aliases§

AsyncConnectiontokio and (std or tokio)
A concrete async connection using generated messages.
Connectionstd and (std or tokio)
A concrete blocking connection using generated messages.