From da1d434e8c0b48b4d18ab731774336c342b7f9cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Mon, 20 Nov 2023 13:24:45 -0300 Subject: [PATCH 1/2] tests: Add more ser/deser test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira Co-authored-by: : Ihsen Bouallegue <48621967+IhsenBouallegue@users.noreply.github.com> --- tests/mav_frame_tests.rs | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tests/mav_frame_tests.rs b/tests/mav_frame_tests.rs index ef20068ffe..d1fac6193f 100644 --- a/tests/mav_frame_tests.rs +++ b/tests/mav_frame_tests.rs @@ -1,6 +1,10 @@ pub mod test_shared; mod mav_frame_tests { + use mavlink::ardupilotmega::MavMessage; + use mavlink::MavFrame; + use mavlink::MavHeader; + // NOTE: No header pub const HEARTBEAT_V2: &[u8] = &[ crate::test_shared::COMMON_MSG_HEADER.sequence, @@ -46,4 +50,53 @@ mod mav_frame_tests { assert_eq!(msg.system_status, heartbeat_msg.system_status); assert_eq!(msg.mavlink_version, heartbeat_msg.mavlink_version); } + + #[test] + pub fn test_deser_ser_message() { + let buf: &mut [u8; 255] = &mut [0; 255]; + + let mavlink_message = mavlink_message(); + let mavlink_frame = new(mavlink_message); + + let _len = mavlink_frame.ser(buf); + + let parsed_mavlink_frame = + MavFrame::::deser(mavlink::MavlinkVersion::V2, buf) + .unwrap(); + + assert_eq!( + format!("{mavlink_frame:?}"), + format!("{parsed_mavlink_frame:?}") + ); + } + + fn mavlink_message() -> mavlink::ardupilotmega::MavMessage { + mavlink::ardupilotmega::MavMessage::LINK_NODE_STATUS( + mavlink::ardupilotmega::LINK_NODE_STATUS_DATA { + timestamp: 92197916, + tx_rate: 0x11223344, + rx_rate: 0x55667788, + messages_sent: 0x99001122, + messages_received: 0x33445566, + messages_lost: 0x77889900, + rx_parse_err: 0x1122, + tx_overflows: 0x3355, + rx_overflows: 0x5566, + tx_buf: 0xff, + rx_buf: 0x11, + }, + ) + } + + fn new(msg: MavMessage) -> MavFrame { + MavFrame { + header: MavHeader { + system_id: 1, + component_id: 2, + sequence: 84, + }, + msg, + protocol_version: mavlink::MavlinkVersion::V2, + } + } } From e6edc301eb821768ae158dd92d9ee8ba1cd5ea63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Mon, 20 Nov 2023 13:30:28 -0300 Subject: [PATCH 2/2] Cargo: Update to 0.12.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index ef508f6cfd..8ae58048c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "mavlink" -version = "0.12.1" +version = "0.12.2" authors = ["Todd Stellanova", "Michal Podhradsky", "Kevin Mehall", "Tim Ryan", "Patrick José Pereira", "Ibiyemi Abiodun"] build = "build/main.rs" description = "Implements the MAVLink data interchange format for UAVs."