mavlink /rust-mavlink

MAVLink implementation written in Rust

★ 298⑂ 116👁 25⑃ 431● 143▤ 27◈ 0
RustApache-2.0Created 2016-02-24mavlink.github.io/rust-mavlink/mavlink/
298
stars
116
forks
25
watchers
431
prs
143
issues
27
releases
0
discussions

README

rust-mavlink








Pure Rust implementation of the MAVLink UAV messaging protocol.
Provides strongly typed message bindings, frame encode/decode and connection APIs for serial,
UDP, TCP, file connection protocols with a rich set of features.

 What rust-mavlink provides

- Rust bindings for MAVLink dialects
- Read/write support for MAVLink v1 and v2
- TCP, UDP, Serial and File connection support. 
- Signing support.
- Blocking and async support.
- std and embedded support.
- Codegen tool mavlink-bindgen for creating Rust bindings from MAVLink XML dialect definitions.

 Workspace crates

| Crate | Purpose |
| --- | --- |
| mavlink | Main crate with generated dialect modules and high-level APIs |
| mavlink-core | Core protocol types, parser/serializer, and connection traits |
| mavlink-bindgen | XML-to-Rust code generator used by mavlink |

 Quick start

Add the crate:

toml
[dependencies]
mavlink = "0.21"


Simple code example:

rust
use mavlink::{dialects::ardupilotmega, MavConnection};

fn main() - Result {
    let conn = mavlink::connect::("udpin:0.0.0.0:14550")?;

    let heartbeat = ardupilotmega::MavMessage::HEARTBEAT(ardupilotmega::HEARTBEAT_DATA {
        custom_mode: 0,
        mavtype: ardupilotmega::MavType::MAV_TYPE_QUADROTOR,
        autopilot: ardupilotmega::MavAutopilot::MAV_AUTOPILOT_ARDUPILOTMEGA,
        base_mode: ardupilotmega::MavModeFlag::empty(),
        system_status: ardupilotmega::MavState::MAV_STATE_STANDBY,
        mavlink_version: 3,
    });

    conn.send(&mavlink::MavHeader::default(), &heartbeat)?;
    let (header, message) = conn.recv()?;

    println!(
        "received from sys={}, comp={}: {message:?}",
        header.system_id, header.component_id
    );

    Ok(())
}


 Supported address formats

- tcpin::: TCP server
- tcpout::: TCP client
- udpin::: UDP listener
- udpout::: UDP sender
- udpbcast::: UDP broadcast sender
- serial::: serial port connection
- file:: read MAVLink frames from a file

 Dialects

 Compile-time dialects

Features such as dialect-ardupilotmega and dialect-common generate strongly
typed Rust messages from XML definitions during the build. Use these when the
message set is known at compile time. Changing the definitions requires rebuilding
the application.

 Runtime dialects

The dialect-dynamic feature loads dialect XML definitions at runtime.

Runtime dialects are required when an application takes its dialect at runtime
(e.g. from user configuration) and rebuilding the application for each custom
dialect is not possible.

See the runtime-dialect example
for usage and testing it.

 Feature flags

Transport and runtime:

- embedded
- std
- tokio
- transport-direct-serial
- transport-tcp
- transport-udp

Protocol and code generation:

- arbitrary
- format-generated-code
- mav2-message-extensions
- mav2-message-signing
- serde
- ts-rs
- wip-messages

Dialects:

- dialect-all
- dialect-ardupilotmega
- dialect-asluav
- dialect-avssuas
- dialect-common
- dialect-csairlink
- dialect-cubepi

Top issues

Latest release

0.21.0 0.21.0 2026-10-23
What's Changed
 bindgen: error when enum entry value can not be parsed by @pv42 in https://github.com/mavlink/rust-mavlink/pull/559
 Add support for 32bit system id field in message header (IFLAG_SYSID32) by @pv42 in https://github.com/mavlink/rust-mavlink/pull/563
 Add Message::target_system_id_mut and target_component_id_mut by @mennovf in https://github.com/mavlink/rust-mavlink/pull/560

 New Contributors
 @mennovf made their first contribution in https://github.com/mavlink/rust-mavlink/pull/560

Full Changelog: https://github.com/mavlink/rust-mavlink/compare/0.20.0...0.20.1

Snapshot: 2026-11-11T15:31:17Z · Data license Apache-2.0 · JSON