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-cubepiTop issues
#156Discussion: A better `Message` trait20 comments · 2023-03-19#486Add profiling support for performance analysis10 comments · 2026-04-05#77PARAM_VALUE_DATA10 comments · 2020-09-09#352Any way to use udpin with SO_REUSEADDR?5 comments · 2025-07-24#188Project is not truncating trailing zeros for payload5 comments · 2023-08-07#321async implementation re-design3 comments · 2025-06-11#97component_id does not support mavlink::common::MavComponent3 comments · 2021-05-20#3480.15.0 bitflags serialization2 comments · 2025-07-10
Latest release
0.21.0 0.21.0 2026-10-23What'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