From 0c43e6a8f4a86b36658671e57b5810905f944e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ant=C3=B4nio=20Cardoso?= Date: Wed, 13 Nov 2024 23:03:57 -0300 Subject: [PATCH] src: drivers: fake: Move Fakesink driver to JSON --- src/lib/drivers/fake.rs | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/src/lib/drivers/fake.rs b/src/lib/drivers/fake.rs index f245a0e1..cb8fd6aa 100644 --- a/src/lib/drivers/fake.rs +++ b/src/lib/drivers/fake.rs @@ -78,32 +78,17 @@ impl Driver for FakeSink { } } - let version = match &**message { - Packet::V1(_) => mavlink::MavlinkVersion::V1, - Packet::V2(_) => mavlink::MavlinkVersion::V2, - }; - - let frame = match mavlink::MavFrame::::deser( - version, - message.as_slice(), - ) { - Ok(frame) => frame, - Err(error) => { - warn!("Failed to deserialize Mavlink Message: {error:?}"); - continue; - } + let Ok(mavlink_json) = message + .to_mavlink_json::() + .await + else { + continue; }; - let mavlink::MavFrame { - header, - msg: message, - protocol_version: _, - } = frame; - if self.print { - println!("Message received: {header:?} {message:?}"); + println!("Message received: {mavlink_json:#?}"); } else { - trace!("Message received: {header:?} {message:?}"); + trace!("Message received: {mavlink_json:#?}"); } }