Expand description
Β§MAVLink dialects for MAVSpec
MAVLink messages bindings based on MAVInspect.
This library is a part of MAVSpec code-generation toolchain and is intended to use alongside with it. However, nothing prevents you from using this crate independently.
Since MAVSpec is I/O agnostic, it and does not provide any
abstractions for transferring MAVLink messages. If you want to communicate with MAVLink devices,
use Mavio for embedded devices and simple tasks or
Maviola for advanced I/O in std
environments (for ground
control stations, communication layers, and so on).
Β§Usage
use dialect::enums::{MavAutopilot, MavModeFlag, MavState};
use dialect::messages::Heartbeat;
use dialect::Minimal as DialectMessage;
use mavlink_dialects::dialects::minimal as dialect;
use mavlink_dialects::spec::*;
let message = Heartbeat {
autopilot: MavAutopilot::Armazila,
base_mode: MavModeFlag::HIL_ENABLED,
system_status: MavState::Active,
..Default::default()
};
// Check that this message indeed supports `MAVLink 1`.
assert_eq!(message.min_supported_mavlink_version(), MavLinkVersion::V1);
// Encode to MAVLink payload.
let payload = message.encode(MavLinkVersion::V2).unwrap();
assert_eq!(payload.version(), MavLinkVersion::V2);
assert_eq!(payload.id(), message.id());
// Decode from MAVLink payload, now without .
let dialect_message = DialectMessage::decode(&payload).unwrap();
match dialect_message {
DialectMessage::Heartbeat(msg) => {
assert_eq!(msg.id(), Heartbeat::ID);
}
_ => panic!("Unexpected dialect message: {:?}", dialect_message),
}
Β§Features
This library provides MAVLink abstractions to work with MAVLink messages and dialects.
It also provides a set of additional tools to work with MAVLink microservices. Basic microservices support involves generation of sub-dialects which include only required entities. For some microservices, like mission, additional utilities are provided.
Β§Dialects
Standard MAVLink dialect can be bundled with MAVSpec. This can be enabled by the corresponding
dlct-<name>
feature flags.
minimal
β minimal dialect required to expose your presence to other MAVLink devices.standard
β a superset ofminimal
dialect, that expected to be used by almost all flight stack.common
β minimum viable dialect with most of the features, a building block for other future-rich dialects.ardupilotmega
β feature-full dialect used by ArduPilot. In most cases this dialect is the go-to choice if you want to recognize almost all MAVLink messages used by existing flight stacks.all
β meta-dialect which includes all other standard dialects including those which were created for testing purposes. It is guaranteed that namespaces of the dialects inall
family do not collide.- Other dialects from MAVLink XML definitions:
asluav
,avssuas
,csairlink
,cubepilot
,development
,icarous
,matrixpilot
,paparazzi
,ualberta
,uavionix
. These do not includepython_array_test
andtest
dialects which should be either generated manually or as a part ofall
meta-dialect.
Β§Default Dialect
When standard MAVLink dialects are used and at least dlct-minimal
Cargo feature is enabled,
this library exposes default_dialect
and DefaultDialect
entities that allow to access
the most feature-rich enabled MAVLink dialect.
Β§Microservices
MAVSpec allows to generate additional structures tailored for MAVLink
microservices. Each microservice is a subdialect with only
those messages and enums which are necessary. To generate microservice subdialects use msrv-*
feature flags.
At the moment, microservices are only generated for the default_dialect
and, if enabled,
are available at default_dialect::microservices
and as microservices
module of the
corresponding default dialect.
Β§Fingerprints
MAVSpec may skip code re-generation if dialects havenβt changed. It uses 64-bit CRC fingerprint to monitor
changes. Set fingerprints
feature flag to enable this behavior.
This feature is useful for reducing build time during development and CI runs. Make sure that your releases are clean and do not depend on fingerprints.
Β§Caveats
The API is straightforward and generally stable, however, incorrect use of certain features may lead to issues during deployment and development.
Β§Binary Size
For small applications that use only a small subset of messages, avoid using dialect enums as they contain all message variants. Instead, decode messages directly from frames:
This will help compiler to throw away unnecessary pieces of code.
Β§Unstable Features
Certain features are considered unstable and available only when unstable
feature flag is
enabled. Unstable features are marked with β
and are may be changed in futures
versions.
Β§Incompatible Features
- Specta requires
std
feature to be enabled.
Β§Feature Flags
In most of the cases you will be interested in dlct-*
and msrv-*
feature families, and
alloc
/ std
target specification. However, a more fine-grained control may be required.
Β§Generic features
-
default
β Default features (nothing is enabled) -
alloc
β Enablealloc
support -
std
β Enable standard library support -
metadata
β Add additional metadata to MAVLink entities. -
unstable
β β οΈ Enables unstable API features.Certain features wonβt take effect without this flag
Β§Code generation
Features required for dialects generation.
fingerprints
β Use protocol CRC-fingerprints to avoid re-generating files
Β§Serialization and reflection
These features enable serde and specta support.
Β§Dialects
These features control which MAVLink dialects will be considered by MAVSpec.
To enable standard MAVLink dialects as defined in XML
message definitions, use dlct-*
feature
family.
In case you want to patch
mavlink-message-definitions
, you might be interested in enabling extra-dialects
feature.
-
dlct-ardupilotmega
β Includeardupilotmega
dialect -
dlct-asluav
β IncludeASLUAV
dialect -
dlct-avssuas
β IncludeAVSSUAS
dialect -
dlct-common
β Includecommon
dialect -
dlct-cs_air_link
β IncludecsAirLink
dialect -
dlct-cubepilot
β Includecubepilot
dialect -
dlct-development
β Includedevelopment
dialect -
dlct-icarous
β Includeicarous
dialect -
dlct-matrixpilot
β Includematrixpilot
dialect -
dlct-minimal
β Includeminimal
dialect -
dlct-paparazzi
β Includepaparazzi
dialect -
dlct-standard
β Includestandard
dialect -
dlct-ualberta
β Includeualberta
dialect -
dlct-uavionix
β IncludeuAvionix
dialect -
dlct-all
β Includeall
meta-dialect -
extra-dialects
β Enables extra dialectsDownstream crates can patch
mavlink-message-definitions
adding extra MAVLink dialects. -
test-dialects
β Enables test dialectsThese dialects are useful for checking various test cases.
Β§MAVLink microservices
These features will control generation of MAVLink microservice-specific bindings.
msrv-all
β Support for all MavLink microservicesmsrv-heartbeat
β Heartbeat protocol supportmsrv-mission
β Mission microservice supportmsrv-parameter
β Parameter protocol supportmsrv-parameter-ext
β Extended parameter protocol supportmsrv-command
β Command protocol supportmsrv-manual-control
β Manual control protocol supportmsrv-camera
β Camera protocol v2 supportmsrv-gimbal-v1
β Gimbal protocol v1 supportmsrv-gimbal-v2
β Gimbal protocol v2 supportmsrv-arm-auth
β Arm authorization protocol supportmsrv-image-transmission
β Image transmission protocol supportmsrv-ftp
β File transfer protocol supportmsrv-landing-target
β Landing target protocol supportmsrv-ping
β Ping protocol supportmsrv-path-planning
β Path planning protocol supportmsrv-battery
β Battery protocol supportmsrv-terrain
β Terrain protocol supportmsrv-tunnel
β Tunnel protocol supportmsrv-open-drone-id
β Open Drone ID protocol supportmsrv-high-latency
β High latency protocol supportmsrv-component-metadata
β Component metadata protocol supportmsrv-payload
β Payload protocol supportmsrv-traffic-management
β Traffic management protocol supportmsrv-events-interface
β Events interface protocol supportmsrv-time-sync
β Time synchronization protocol support
Β§Technical features
These features should not be used directly.
-
msrv
β β Enable MAVLink microservices supportDo not use directly as this feature does not give access to any specific functionality by itself. Instead, use one of
msrv-*
features.
ModulesΒ§
- default_
dialect - Default standard MAVLink dialect module.
- derive
mavspec
MAVSpec Rust Procedural Macros- dialects
- Autogenerated MAVLink dialects
- rust
- Rust bindings specifications left for compatibility with MAVSpec.
- spec
mavspec
EnumsΒ§
- Default
Dialect - Default standard MAVLink dialect.
Enum containing all messages within
all
dialect.