From 163ce27390f5ee43ffbb0ce23dfd8f9a3ba408ea Mon Sep 17 00:00:00 2001 From: Antonio Sanjurjo C <74329840+antonio-sc66@users.noreply.github.com> Date: Wed, 3 Jan 2024 22:33:03 +0100 Subject: [PATCH] Bugfix. Replace default isize enum representation. By default Rust uses isize to represent enum values. isize implementation depends on the `target_pointer_width` attribute. - Mavlink implementation for v2 requires message id with the range 0..16777215 --> u32 - Mavlink implementation requires u32 enum entry values --- README.md | 2 +- build/parser.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 37cf297673..45594840cd 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ with bindings for all message sets. Add to your Cargo.toml: ``` -mavlink = "0.10.1" +mavlink = "0.12.2" ``` ## Examples diff --git a/build/parser.rs b/build/parser.rs index 20a883a2eb..458482b31d 100644 --- a/build/parser.rs +++ b/build/parser.rs @@ -180,6 +180,7 @@ impl MavProfile { quote! { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(tag = "type"))] + #[repr(u32)] pub enum MavMessage { #(#enums(#structs),)* } @@ -390,6 +391,7 @@ impl MavEnum { #[derive(Debug, Copy, Clone, PartialEq, FromPrimitive, ToPrimitive)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(tag = "type"))] + #[repr(u32)] #description pub enum #enum_name { #(#defs)*