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 ofminimaldialect, 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 inallfamily do not collide.- Other dialects from MAVLink XML definitions:
asluav,avssuas,csairlink,cubepilot,development,icarous,matrixpilot,paparazzi,ualberta,uavionix. These do not includepython_array_testandtestdialects which should be either generated manually or as a part ofallmeta-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
stdfeature 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β Enableallocsupport -
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β Includeardupilotmegadialect -
dlct-asluavβ IncludeASLUAVdialect -
dlct-avssuasβ IncludeAVSSUASdialect -
dlct-commonβ Includecommondialect -
dlct-cs_air_linkβ IncludecsAirLinkdialect -
dlct-cubepilotβ Includecubepilotdialect -
dlct-developmentβ Includedevelopmentdialect -
dlct-icarousβ Includeicarousdialect -
dlct-matrixpilotβ Includematrixpilotdialect -
dlct-minimalβ Includeminimaldialect -
dlct-paparazziβ Includepaparazzidialect -
dlct-standardβ Includestandarddialect -
dlct-ualbertaβ Includeualbertadialect -
dlct-uavionixβ IncludeuAvionixdialect -
dlct-allβ Includeallmeta-dialect -
extra-dialectsβ Enables extra dialectsDownstream crates can patch
mavlink-message-definitionsadding 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
mavspecMAVSpec 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
alldialect.