diff --git a/.github/workflows/generator.yaml b/.github/workflows/generator.yaml index 422c563158..efaf0ea900 100644 --- a/.github/workflows/generator.yaml +++ b/.github/workflows/generator.yaml @@ -33,7 +33,7 @@ jobs: - name: Generate tests run: | - rm c/test/auto_check_*.c c/test/cpp/auto_check_*.cc java/test/auto_check_*.java rust/sbp/tests/auto_check_*.rs + rm c/test/auto_check_*.c c/test/cpp/auto_check_*.cc java/test/auto_check_*.java rust/sbp/tests/integration/auto_check_*.rs make gen-c gen-java gen-rust - name: Check generated tests are up to date diff --git a/Makefile b/Makefile index 3bec486967..046a7157d9 100644 --- a/Makefile +++ b/Makefile @@ -368,6 +368,8 @@ test-haskell: test-rust: $(call announce-begin,"Running Rust tests") cargo test --verbose --all-features --all-targets + $(call announce-begin,"Running Rust doc tests") + cargo test --doc $(call announce-begin,"Building Rust examples") cargo build --examples --verbose --all-features --all-targets $(call announce-end,"Finished running Rust tests") diff --git a/generator/sbpg/generator.py b/generator/sbpg/generator.py index 44ed4fdf85..67092f0f70 100755 --- a/generator/sbpg/generator.py +++ b/generator/sbpg/generator.py @@ -207,6 +207,10 @@ def main(): elif args.test_c: test_c.render_check_suites(output_dir, all_specs) test_c.render_check_main(output_dir, all_specs) + if args.test_rust: + import sbpg.targets.test_rust as test_rs + test_rs.render_main(output_dir, all_specs) + except KeyboardInterrupt: pass diff --git a/generator/sbpg/targets/resources/sbp-cargo.toml b/generator/sbpg/targets/resources/sbp-cargo.toml index 94cd4633e9..68bf60f351 100644 --- a/generator/sbpg/targets/resources/sbp-cargo.toml +++ b/generator/sbpg/targets/resources/sbp-cargo.toml @@ -19,24 +19,19 @@ keywords = ["encoding", "parsing"] [features] default = [] async = ["futures", "dencode/async"] -sbp_serde = ["serde"] -json = ["sbp_serde", "serde_json", "base64"] +json = ["serde", "serde_json", "base64"] link = ["slotmap"] [lib] path = "src/lib.rs" [dependencies] -byteorder = "1.2" -bytes = "1.0" -crc16 = "*" +bytes = "1" +crc16 = "0.4" log = "0.4" -nom = "6.0" -thiserror = "1.0" [dependencies.swiftnav] -git = "https://github.com/swift-nav/swiftnav-rs" -tag = "v0.6.1" +version = "0.7" optional = true [dependencies.slotmap] @@ -61,7 +56,7 @@ version = "0.3" optional = true [dependencies.dencode] -version = "0.3.0" +version = "0.3" default-features = false [dev-dependencies] diff --git a/generator/sbpg/targets/resources/sbp_messages_mod.rs b/generator/sbpg/targets/resources/sbp_messages_mod.rs index 41d9b4175e..e778d8754d 100644 --- a/generator/sbpg/targets/resources/sbp_messages_mod.rs +++ b/generator/sbpg/targets/resources/sbp_messages_mod.rs @@ -7,6 +7,7 @@ // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, // EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. +//! SBP message definitions. ((*- for m in mods *)) pub mod (((m))); @@ -22,97 +23,128 @@ use self::(((p.identifier|mod_name)))::(((m.identifier|camel_case))); ((*- endfor *)) use self::unknown::Unknown; -use crate::serialize::SbpSerialize; +mod lib { + //! Common imports so we can just `use super::lib::*` in all the message files -pub trait SBPMessage: SbpSerialize { - fn get_message_name(&self) -> &'static str; - fn get_message_type(&self) -> u16; - fn get_sender_id(&self) -> Option; + pub use std::convert::{TryFrom, TryInto}; + + pub use crate::wire_format::{WireFormat, PayloadParseError}; + pub use crate::sbp_string::{SbpString, Unterminated, NullTerminated, Multipart, DoubleNullTerminated}; + + #[cfg(feature = "swiftnav")] + pub use crate::time; + + pub use super::{ConcreteMessage, Sbp, SbpMessage, TryFromSbpError}; +} + +use lib::*; + +/// Common functionality available to all SBP messages. +pub trait SbpMessage: WireFormat + Clone + Sized { + /// Get the message name. + fn message_name(&self) -> &'static str; + /// Get the message type. + fn message_type(&self) -> u16; + /// Get the sender_id if it is set. + fn sender_id(&self) -> Option; + /// Set the sender id. fn set_sender_id(&mut self, new_id: u16); - fn to_frame(&self) -> std::result::Result, crate::FramerError>; - fn write_frame(&self, buf: &mut Vec) -> std::result::Result<(), crate::FramerError>; + /// Get the GPS time associated with the message. #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { + fn gps_time(&self) -> Option> { None } } -pub trait ConcreteMessage: SBPMessage + std::convert::TryFrom + Clone + Sized { +/// Implemented by messages who's message name and type are known at compile time. +/// This is everything that implements [SbpMessage] except for [Sbp]. +pub trait ConcreteMessage: SbpMessage + TryFrom { + /// The message type. const MESSAGE_TYPE: u16; + /// The message name. const MESSAGE_NAME: &'static str; } +/// The error returned when using [TryFrom] to convert [Sbp] to the wrong message type. #[derive(Debug, Clone)] -pub struct TryFromSBPError; +pub struct TryFromSbpError; -impl std::fmt::Display for TryFromSBPError { +impl std::fmt::Display for TryFromSbpError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "invalid message type for conversion") } } -impl std::error::Error for TryFromSBPError {} +impl std::error::Error for TryFromSbpError {} -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize), serde(untagged))] +/// Represents any SBP message. +#[cfg_attr(feature = "serde", derive(serde::Serialize), serde(untagged))] #[derive(Debug, Clone)] -pub enum SBP { +#[non_exhaustive] +pub enum Sbp { ((*- for m in msgs *)) + /// (((m.short_desc | commentify(indent=2) ))) (((m.identifier|camel_case)))( (((m.identifier|camel_case))) ), ((*- endfor *)) + /// Unknown message type Unknown( Unknown ), } -impl SBP { - pub fn parse(msg_id: u16, sender_id: u16, payload: &mut &[u8]) -> Result { - match msg_id { +impl Sbp { + pub(crate) fn from_frame(mut frame: crate::de::Frame) -> Result { + match frame.msg_type { ((*- for m in msgs *)) - (((m.sbp_id))) => { - let mut msg = (((m.identifier|camel_case)))::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::(((m.identifier|camel_case)))(msg)) + (((m.identifier|camel_case)))::MESSAGE_TYPE => { + let mut msg = (((m.identifier|camel_case)))::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::(((m.identifier|camel_case)))(msg)) }, ((*- endfor *)) - _ => Ok(SBP::Unknown( Unknown{ msg_id: msg_id, sender_id: sender_id, payload: payload.to_vec() } )) + _ => { + let mut msg = Unknown::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::Unknown(msg)) + } } } } -impl crate::SBPMessage for SBP { - fn get_message_name(&self) -> &'static str { +impl SbpMessage for Sbp { + fn message_name(&self) -> &'static str { match self { ((*- for m in msgs *)) - SBP::(((m.identifier|camel_case)))(msg) => { - msg.get_message_name() + Sbp::(((m.identifier|camel_case)))(msg) => { + msg.message_name() }, ((*- endfor *)) - SBP::Unknown(msg) => { - msg.get_message_name() + Sbp::Unknown(msg) => { + msg.message_name() }, } } - fn get_message_type(&self) -> u16 { + fn message_type(&self) -> u16 { match self { ((*- for m in msgs *)) - SBP::(((m.identifier|camel_case)))(msg) => { - msg.get_message_type() + Sbp::(((m.identifier|camel_case)))(msg) => { + msg.message_type() }, ((*- endfor *)) - SBP::Unknown(msg) => { - msg.get_message_type() + Sbp::Unknown(msg) => { + msg.message_type() }, } } - fn get_sender_id(&self) -> Option { + fn sender_id(&self) -> Option { match self { ((*- for m in msgs *)) - SBP::(((m.identifier|camel_case)))(msg) => { - msg.get_sender_id() + Sbp::(((m.identifier|camel_case)))(msg) => { + msg.sender_id() }, ((*- endfor *)) - SBP::Unknown(msg) => { - msg.get_sender_id() + Sbp::Unknown(msg) => { + msg.sender_id() }, } } @@ -120,96 +152,75 @@ impl crate::SBPMessage for SBP { fn set_sender_id(&mut self, new_id: u16) { match self { ((*- for m in msgs *)) - SBP::(((m.identifier|camel_case)))(msg) => { + Sbp::(((m.identifier|camel_case)))(msg) => { msg.set_sender_id(new_id) }, ((*- endfor *)) - SBP::Unknown(msg) => { + Sbp::Unknown(msg) => { msg.set_sender_id(new_id) }, } } - fn to_frame(&self) -> Result, crate::FramerError> { - match self { - ((*- for m in msgs *)) - SBP::(((m.identifier|camel_case)))(msg) => { - msg.to_frame() - }, - ((*- endfor *)) - SBP::Unknown(msg) => { - msg.to_frame() - }, - } - } - - fn write_frame(&self, buf: &mut Vec) -> Result<(), crate::FramerError> { - match self { - ((*- for m in msgs *)) - SBP::(((m.identifier|camel_case)))(msg) => { - msg.write_frame(buf) - }, - ((*- endfor *)) - SBP::Unknown(msg) => { - msg.write_frame(buf) - }, - } - } - #[cfg(feature = "swiftnav")] fn gps_time(&self) -> Option> { match self { ((*- for m in msgs *)) - SBP::(((m.identifier|camel_case)))(msg) => { + Sbp::(((m.identifier|camel_case)))(msg) => { msg.gps_time() }, ((*- endfor *)) - SBP::Unknown(msg) => { + Sbp::Unknown(msg) => { msg.gps_time() }, } } } +impl WireFormat for Sbp { + const MIN_ENCODED_LEN: usize = crate::MAX_FRAME_LEN; + + fn parse_unchecked(_: &mut bytes::BytesMut) -> Self { + unimplemented!("Sbp must be parsed with Sbp::from_frame"); + } -impl crate::SbpSerialize for SBP { - fn append_to_sbp_buffer(&self, buf: &mut Vec) { + fn write(&self, buf: &mut bytes::BytesMut) { match self { ((*- for m in msgs *)) - SBP::(((m.identifier|camel_case)))(msg) => { - msg.append_to_sbp_buffer(buf) + Sbp::(((m.identifier|camel_case)))(msg) => { + WireFormat::write(msg, buf) }, ((*- endfor *)) - SBP::Unknown(msg) => { - msg.append_to_sbp_buffer(buf) + Sbp::Unknown(msg) => { + WireFormat::write(msg, buf) }, } } - fn sbp_size(&self) -> usize { + fn encoded_len(&self) -> usize { match self { ((*- for m in msgs *)) - SBP::(((m.identifier|camel_case)))(msg) => { - msg.sbp_size() + Sbp::(((m.identifier|camel_case)))(msg) => { + WireFormat::encoded_len(msg) }, ((*- endfor *)) - SBP::Unknown(msg) => { - msg.sbp_size() + Sbp::Unknown(msg) => { + WireFormat::encoded_len(msg) }, } } } -((*- for m in msgs *)) -impl From<(((m.identifier|camel_case)))> for SBP { +((* for m in msgs *)) +impl From<(((m.identifier|camel_case)))> for Sbp { fn from(msg: (((m.identifier|camel_case)))) -> Self { - SBP::(((m.identifier|camel_case)))(msg) + Sbp::(((m.identifier|camel_case)))(msg) } -} -((*- endfor *)) -impl From for SBP { +} +((* endfor *)) +impl From for Sbp { fn from(msg: Unknown) -> Self { - SBP::Unknown(msg) + Sbp::Unknown(msg) } } diff --git a/generator/sbpg/targets/resources/sbp_messages_template.rs b/generator/sbpg/targets/resources/sbp_messages_template.rs index 6818ebb351..c2dc7e6173 100644 --- a/generator/sbpg/targets/resources/sbp_messages_template.rs +++ b/generator/sbpg/targets/resources/sbp_messages_template.rs @@ -15,20 +15,11 @@ //! (((description | commentify(prefix="//! ") ))) -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian,ReadBytesExt}; - -#[allow(unused_imports)] -use crate::SbpString; -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; - -((*- for i in includes *)) +((* for i in includes *)) use super::(((i)))::*; -((*- endfor *)) +((* endfor *)) + +use super::lib::*; ((* for m in msgs *)) ((*- if m.desc *)) @@ -36,128 +27,93 @@ use super::(((i)))::*; /// /// (((m.desc | commentify))) /// +((*- elif m.short_desc *)) +/// (((m.short_desc))) ((*- endif *)) -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct (((m.identifier|camel_case))) { ((*- if m.is_real_message *)) - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, ((*- endif *)) ((*- for f in m.fields *)) ((*- if f.desc *)) /// (((f.desc | commentify(indent=2) ))) ((*- endif *)) - pub (((f.identifier))): (((f|type_map))), + #[cfg_attr(feature = "serde", serde(rename(serialize = "(((f.identifier)))")))] + pub (((f.identifier|snake_case))): (((f|type_map))), ((*- endfor *)) } -impl (((m.identifier|camel_case))) { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result<(((m.identifier|camel_case))), crate::Error> { - Ok( (((m.identifier|camel_case))){ - ((*- if m.is_real_message *)) - sender_id: None, - ((*- endif *)) - ((*- for f in m.fields *)) - (((f.identifier))): (((f|parse_type)))?, - ((*- endfor *)) - } ) - } - - ((*- if not m.is_real_message *)) - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push( (((m.identifier|camel_case)))::parse(buf)? ); - } - Ok(v) - } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push( (((m.identifier|camel_case)))::parse(buf)? ); - } - Ok(v) - } - ((*- endif *)) +((* if m.is_real_message *)) +impl ConcreteMessage for (((m.identifier|camel_case))) { + const MESSAGE_TYPE: u16 = (((m.sbp_id))); + const MESSAGE_NAME: &'static str = "(((m.identifier)))"; } -((*- if m.is_real_message *)) -impl super::SBPMessage for (((m.identifier|camel_case))) { - fn get_message_name(&self) -> &'static str { - "(((m.identifier)))" +impl SbpMessage for (((m.identifier|camel_case))) { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_message_type(&self) -> u16 { - (((m.sbp_id))) + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE } - - fn get_sender_id(&self) -> Option { + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame( - &self, - frame: &mut Vec, - ) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - (((m|gps_time(msgs)))) } -((*- endif *)) -((*- if m.is_real_message *)) -impl super::ConcreteMessage for (((m.identifier|camel_case))) { - const MESSAGE_TYPE: u16 = (((m.sbp_id))); - const MESSAGE_NAME: &'static str = "(((m.identifier)))"; -} -((*- endif *)) - -((*- if m.is_real_message *)) -impl TryFrom for (((m.identifier|camel_case))) { - type Error = super::TryFromSBPError; - - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for (((m.identifier|camel_case))) { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::(((m.identifier|camel_case)))(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::(((m.identifier|camel_case)))(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -((*- endif *)) - -impl crate::serialize::SbpSerialize for (((m.identifier|camel_case))) { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - ((*- for f in m.fields *)) - self.(((f.identifier))).append_to_sbp_buffer(buf); - ((*- endfor *)) - } - - fn sbp_size(&self) -> usize { +((* endif *)) + +impl WireFormat for (((m.identifier|camel_case))) { + const MIN_ENCODED_LEN: usize = + ((*- if not m.fields *)) + 0 + ((*- else *)) + < (((m.fields[0]|type_map))) as WireFormat>::MIN_ENCODED_LEN + ((*- for f in m.fields[1:] *)) + + < (((f|type_map))) as WireFormat>::MIN_ENCODED_LEN + ((*- endfor *)) + ((*- endif *)); + fn encoded_len(&self) -> usize { ((*- if not m.fields *)) 0 ((*- else *)) - let mut size = 0; + WireFormat::encoded_len( &self.(((m.fields[0].identifier|snake_case))) ) + ((*- for f in m.fields[1:] *)) + + WireFormat::encoded_len( &self.(((f.identifier|snake_case))) ) + ((*- endfor *)) + ((*- endif *)) + } + fn write(&self, ((*- if not m.fields *)) _buf ((*- else *)) buf ((*- endif *)): &mut bytes::BytesMut) { ((*- for f in m.fields *)) - size += self.(((f.identifier))).sbp_size(); + WireFormat::write( &self.(((f.identifier|snake_case))), buf); ((*- endfor *)) - size + } + fn parse_unchecked( ((*- if not m.fields *)) _buf ((*- else *)) buf ((*- endif *)): &mut bytes::BytesMut) -> Self { + (((m.identifier|camel_case))) { + ((*- if m.is_real_message *)) + sender_id: None, ((*- endif *)) + ((*- for f in m.fields *)) + (((f.identifier|snake_case))): WireFormat::parse_unchecked(buf), + ((*- endfor *)) + } } } ((* endfor *)) diff --git a/rust/sbp/tests/common.rs b/generator/sbpg/targets/resources/sbp_tests_main_template.rs similarity index 82% rename from rust/sbp/tests/common.rs rename to generator/sbpg/targets/resources/sbp_tests_main_template.rs index c86a43c1fb..7ab3cac93a 100644 --- a/rust/sbp/tests/common.rs +++ b/generator/sbpg/targets/resources/sbp_tests_main_template.rs @@ -9,6 +9,17 @@ // EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. +// This file was auto-generated. Do not modify by hand! + +((*- for test_name in test_names *)) +mod (((test_name))); +((*- endfor *)) + +pub use std::io::Cursor; + +pub use sbp::messages::SbpMessage; +pub use sbp::iter_messages; + pub trait AlmostEq { fn almost_eq(self, rhs: Self) -> bool; } diff --git a/generator/sbpg/targets/resources/sbp_tests_template.rs b/generator/sbpg/targets/resources/sbp_tests_template.rs index 1c9f8198f6..ff732a88ea 100644 --- a/generator/sbpg/targets/resources/sbp_tests_template.rs +++ b/generator/sbpg/targets/resources/sbp_tests_template.rs @@ -11,33 +11,26 @@ // This file was auto-generated from (((s.src_filename))) by generate.py. Do not modify by hand! -use sbp::messages::SBPMessage; -use sbp::iter_messages; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; ((*- macro compare_value(prefix, value) *)) ((*- if value is string_type *)) -assert_eq!(Into::::into(msg.(((prefix))).clone()), (((value|str_escape))), "incorrect value for msg.(((prefix))), expected string '{}', is '{}'", (((value|str_escape))), msg.(((prefix)))); +assert_eq!(msg.(((prefix|snake_case))).to_string(), (((value|str_escape))), "incorrect value for msg.(((prefix|snake_case))), expected string '{}', is '{}'", (((value|str_escape))), msg.(((prefix|snake_case)))); ((*- elif value is array_type *)) -((*- for ff in value *))((( compare_value( (((prefix))) + '[' + (((loop.index0|to_str))) + ']', (((ff))) ) )))((*- endfor *)) +((*- for ff in value *))((( compare_value( (((prefix|snake_case))) + '[' + (((loop.index0|to_str))) + ']', (((ff))) ) )))((*- endfor *)) ((*- elif value is dict_type *)) ((*- for k in (((value|sorted))) *))((( compare_value( (((prefix))) + '.' + (((k))), (((value[k]))) ) )))((*- endfor *)) ((*- elif value is float_type *))((= Note: the ("%.17e"|format(value)) filter is intended to preserve float literal precision accross all value ranges. =)) -assert!(msg.(((prefix))).almost_eq( ((("%.17e"|format(value)))) ), "incorrect value for (((prefix))), expected ((("%.17e"|format(value)))), is {:e}", msg.(((prefix)))); +assert!(msg.(((prefix|snake_case))).almost_eq( ((("%.17e"|format(value)))) ), "incorrect value for (((prefix|snake_case))), expected ((("%.17e"|format(value)))), is {:e}", msg.(((prefix|snake_case)))); ((*- else *)) -assert_eq!(msg.(((prefix))), (((value))), "incorrect value for (((prefix))), expected (((value))), is {}", msg.(((prefix)))); +assert_eq!(msg.(((prefix|snake_case))), (((value))), "incorrect value for (((prefix|snake_case))), expected (((value))), is {}", msg.(((prefix|snake_case)))); ((*- endif *)) ((*- endmacro *)) #[test] -fn test_(((s.suite_name)))() +fn test_(((s.suite_name|snake_case)))() { ((*- for t in s.tests *)) { @@ -51,15 +44,15 @@ fn test_(((s.suite_name)))() .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::(((t.msg.name)))(msg) => { - assert_eq!( msg.get_message_type(), (((t.msg_type))), "Incorrect message type, expected (((t.msg_type))), is {}", msg.get_message_type()); - let sender_id = msg.get_sender_id().unwrap(); + sbp::messages::Sbp::(((t.msg.name|lower_acronyms)))(msg) => { + assert_eq!( msg.message_type(), (((t.msg_type))), "Incorrect message type, expected (((t.msg_type))), is {}", msg.message_type()); + let sender_id = msg.sender_id().unwrap(); assert_eq!(sender_id, (((t.sbp.sender))), "incorrect sender id, expected (((t.sbp.sender))), is {}", sender_id); ((*- for f in t.fieldskeys *))(((compare_value( (((f))), (((t.fields[f]))) ))))((*- endfor *)) }, _ => panic!("Invalid message type! Expected a (((t.msg.name)))"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } ((*- endfor *)) diff --git a/generator/sbpg/targets/rust.py b/generator/sbpg/targets/rust.py index a957f060a6..96b4790870 100644 --- a/generator/sbpg/targets/rust.py +++ b/generator/sbpg/targets/rust.py @@ -16,7 +16,7 @@ from jinja2.environment import Environment from jinja2.utils import pass_environment -from sbpg.targets.templating import JENV, ACRONYMS, indented_wordwrap +from sbpg.targets.templating import JENV, ACRONYMS, LOWER_ACRONYMS, indented_wordwrap from sbpg import ReleaseVersion SBP_CARGO_TEMPLATE = "sbp-cargo.toml" @@ -27,29 +27,30 @@ GPS_TIME = """ let tow_s = (self.tow as f64) / 1000.0; -let wn = match i16::try_from(self.wn) { +#[allow(clippy::useless_conversion)] +let wn: i16 = match self.wn.try_into() { Ok(wn) => wn, Err(e) => return Some(Err(e.into())), }; -let gps_time = match crate::time::GpsTime::new(wn, tow_s) { +let gps_time = match time::GpsTime::new(wn, tow_s) { Ok(gps_time) => gps_time, Err(e) => return Some(Err(e.into())), }; """.strip() GPS_TIME_HEADER = """ let tow_s = (self.header.t.tow as f64) / 1000.0; -let wn = match i16::try_from(self.header.t.wn) { +let wn: i16 = match self.header.t.wn.try_into() { Ok(wn) => wn, Err(e) => return Some(Err(e.into())), }; -let gps_time = match crate::time::GpsTime::new(wn, tow_s) { +let gps_time = match time::GpsTime::new(wn, tow_s) { Ok(gps_time) => gps_time, Err(e) => return Some(Err(e.into())), }; """.strip() GPS_TIME_ONLY_TOW = """ let tow_s = (self.tow as f64) / 1000.0; -let gps_time = match crate::time::GpsTime::new(0, tow_s) { +let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; @@ -64,7 +65,7 @@ return None; } let tow_s = (self.tow as f64) / 1000.0; -let gps_time = match crate::time::GpsTime::new(0, tow_s) { +let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; @@ -76,7 +77,7 @@ return None; } let tow_s = (self.time as f64) / 1000000.0; -let gps_time = match crate::time::GpsTime::new(0, tow_s) { +let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; @@ -88,9 +89,24 @@ def camel_case(s): """ Makes a classname. """ - if '_' not in s: return s + if '_' not in s: return lower_acronyms(s) s = re.sub('([a-z])([A-Z])', r'\1_\2', s) - return ''.join(w if w in ACRONYMS else w.title() for w in s.split('_')) + return ''.join(w.title() for w in s.split('_')) + +def snake_case(s): + if "_" in s: + return "_".join(snake_case(p) for p in s.split('_')) + if len(s) == 1: + return s.lower() + s = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', s) + return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s).lower() + +def lower_acronyms(s): + acronyms = ACRONYMS + ["GNSS", "IMU"] + lower_acronyms = LOWER_ACRONYMS + ["Gnss", "Imu"] + for (i, a) in enumerate(acronyms): + s = s.replace(a, lower_acronyms[i]) + return s @pass_environment def commentify(environment: Environment, @@ -100,7 +116,27 @@ def commentify(environment: Environment, """ Builds a comment. """ - return indented_wordwrap(environment, value, indent=(" " * indent) + prefix, first=False, markdown=True) + value = indented_wordwrap(environment, value, indent=(" " * indent) + prefix, first=False, markdown=True) + value = wrap_urls(value) + value = escape_braces(value) + return value + +def wrap_urls(s): + urls = re.findall(r"\(?https?://[^\s\)]+\)?", s) + for url in urls: + if url.startswith("(") and url.endswith(")"): + continue + if url.endswith(")"): + s = s.replace(url, "<" + url[:-1] + ">)") + else: + s = s.replace(url, "<" + url + ">") + return s + +def escape_braces(s): + groups = re.findall(r"(\[[^\]]+\])[^\(]", s) + for group in groups: + s = s.replace(group, "\\" + group[:-1] + "\]") + return s TYPE_MAP = {'u8': 'u8', 'u16': 'u16', @@ -111,53 +147,41 @@ def commentify(environment: Environment, 's32': 'i32', 's64': 'i64', 'float': 'f32', - 'double': 'f64', - 'string': 'SbpString'} + 'double': 'f64'} def type_map(field): if field.type_id in TYPE_MAP: return TYPE_MAP[field.type_id] - elif field.type_id == 'array': - t = field.options['fill'].value - return "Vec<{}>".format(TYPE_MAP.get(t, t)) - else: - return field.type_id - -def mod_name(x): - return x.split('.', 2)[2] -def parse_type(field): - """ - Function to pull a type from the binary payload. - """ - if field.type_id == 'string': - if 'size' in field.options: - return "crate::parser::read_string_limit(_buf, %s)" % field.options['size'].value - else: - return "crate::parser::read_string(_buf)" - elif field.type_id == 'u8': - return '_buf.read_u8()' - elif field.type_id == 's8': - return '_buf.read_i8()' - elif field.type_id in TYPE_MAP.keys(): - # Primitive java types have extractor methods in SBPMessage.Parser - return '_buf.read_%s::()' % TYPE_MAP[field.type_id] if field.type_id == 'array': - # Call function to build array t = field.options['fill'].value - if t in TYPE_MAP.keys(): - if 'size' in field.options: - return 'crate::parser::read_%s_array_limit(_buf, %d)' % (t, field.options['size'].value) - else: - return 'crate::parser::read_%s_array(_buf)' % t + if 'size' in field.options: + return "[{}; {}]".format(TYPE_MAP.get(t, t), field.options['size'].value) + else: + return "Vec<{}>".format(TYPE_MAP.get(t, t)) + + if field.type_id == "string": + if 'encoding' in field.options: + e = field.options['encoding'].value + if e == "unterminated": + encoding = "Unterminated" + elif e == "null_terminated": + encoding = "NullTerminated" + elif e == "multipart": + encoding = "Multipart" + elif e == "double_null_terminated": + encoding = "DoubleNullTerminated" + else: + encoding = "Unterminated" + if 'size' in field.options: + return "SbpString<[u8; {}], {}>".format(field.options['size'].value, encoding) else: - if 'size' in field.options: - return '%s::parse_array_limit(_buf, %d)' % (t, field.options['size'].value) - else: - return '%s::parse_array(_buf)' % t - else: - # This is an inner class, call default constructor - return "%s::parse(_buf)" % field.type_id + return "SbpString, {}>".format(encoding) + + return lower_acronyms(field.type_id) + +def mod_name(x): + return x.split('.', 2)[2] def gps_time(msg, all_messages): def time_aware_header(type_id): @@ -194,7 +218,7 @@ def gen_body(): def gen_ret(): name = "Base" if msg.identifier in BASE_TIME_MSGS else "Rover" - return f"Some(Ok(crate::time::MessageTime::{name}(gps_time.into())))" + return f"Some(Ok(time::MessageTime::{name}(gps_time.into())))" body = gen_body() if body is None: @@ -204,18 +228,20 @@ def gen_ret(): return f""" #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> {{ + fn gps_time(&self) -> Option> {{ {body} {ret} }} """.strip() + JENV.filters['camel_case'] = camel_case JENV.filters['commentify'] = commentify JENV.filters['type_map'] = type_map JENV.filters['mod_name'] = mod_name -JENV.filters['parse_type'] = parse_type JENV.filters['gps_time'] = gps_time +JENV.filters['wrap_urls'] = wrap_urls +JENV.filters['snake_case'] = snake_case def render_source(output_dir, package_spec): """ diff --git a/generator/sbpg/targets/templating.py b/generator/sbpg/targets/templating.py index 5516231998..9a7bd4afbf 100755 --- a/generator/sbpg/targets/templating.py +++ b/generator/sbpg/targets/templating.py @@ -30,6 +30,7 @@ ) ACRONYMS = ['GPS', 'ECEF', 'LLH', 'NED', 'IO'] +LOWER_ACRONYMS = ['Gps', 'Ecef', 'Llh', 'Ned', 'Io'] INCLUDE_MAP = { "gnss": [ "CarrierPhase", diff --git a/generator/sbpg/targets/test_rust.py b/generator/sbpg/targets/test_rust.py index 679442f14c..a16192d1ff 100644 --- a/generator/sbpg/targets/test_rust.py +++ b/generator/sbpg/targets/test_rust.py @@ -13,11 +13,14 @@ Generator for rust tests target. """ +import re + from sbpg.targets.common import array_type, dict_type, float_type, is_empty, string_type, to_str from sbpg.targets.templating import JENV +from sbpg.targets.rust import lower_acronyms, snake_case TEST_TEMPLATE_NAME = "sbp_tests_template.rs" - +TEST_MAIN_TEMPLATE_NAME = "sbp_tests_main_template.rs" def str_escape(value): return "\"{}\".to_string()".format(value) @@ -29,6 +32,8 @@ def mod_name(value): JENV.filters['str_escape'] = str_escape JENV.filters['sorted'] = sorted JENV.filters['mod_name'] = mod_name +JENV.filters['lower_acronyms'] = lower_acronyms +JENV.filters['snake_case'] = snake_case JENV.tests['string_type'] = string_type JENV.tests['array_type'] = array_type @@ -41,7 +46,7 @@ def render_source(output_dir, package_spec): Render and output to a directory given a package specification. """ path, name = package_spec.filepath - destination_filename = "%s/%s.rs" % (output_dir, name) + destination_filename = "%s/integration/%s.rs" % (output_dir, snake_case(name)) py_template = JENV.get_template(TEST_TEMPLATE_NAME) with open(destination_filename, 'w') as f: f.write(py_template.render(s=package_spec, @@ -50,3 +55,9 @@ def render_source(output_dir, package_spec): include=package_spec.package.split('.')[1], filepath="/".join(package_spec.filepath) + ".yaml")) +def render_main(output_dir, package_specs): + destination_filename = "%s/integration/main.rs" % output_dir + py_template = JENV.get_template(TEST_MAIN_TEMPLATE_NAME) + test_names = [snake_case(p.filepath[1]) for p in package_specs] + with open(destination_filename, 'w') as f: + f.write(py_template.render(test_names=test_names)) diff --git a/rust/Dockerfile b/rust/Dockerfile index 53d68af664..13b8d2c236 100644 --- a/rust/Dockerfile +++ b/rust/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:slim-stretch +FROM rust:1.55-slim-buster ARG DEBIAN_FRONTEND=noninterative diff --git a/rust/sbp/Cargo.toml b/rust/sbp/Cargo.toml index 20d7e12a7f..810b94f15e 100644 --- a/rust/sbp/Cargo.toml +++ b/rust/sbp/Cargo.toml @@ -19,24 +19,19 @@ keywords = ["encoding", "parsing"] [features] default = [] async = ["futures", "dencode/async"] -sbp_serde = ["serde"] -json = ["sbp_serde", "serde_json", "base64"] +json = ["serde", "serde_json", "base64"] link = ["slotmap"] [lib] path = "src/lib.rs" [dependencies] -byteorder = "1.2" -bytes = "1.0" -crc16 = "*" +bytes = "1" +crc16 = "0.4" log = "0.4" -nom = "6.0" -thiserror = "1.0" [dependencies.swiftnav] -git = "https://github.com/swift-nav/swiftnav-rs" -tag = "v0.6.1" +version = "0.7" optional = true [dependencies.slotmap] @@ -61,7 +56,7 @@ version = "0.3" optional = true [dependencies.dencode] -version = "0.3.0" +version = "0.3" default-features = false [dev-dependencies] diff --git a/rust/sbp/examples/serial.rs b/rust/sbp/examples/serial.rs index 92efd1a707..7030715ec6 100644 --- a/rust/sbp/examples/serial.rs +++ b/rust/sbp/examples/serial.rs @@ -7,7 +7,7 @@ use std::time::Duration; use serialport::prelude::*; -use sbp::{iter_messages, messages::SBP, Error}; +use sbp::{iter_messages, Sbp}; fn main() { let s = SerialPortSettings { @@ -23,17 +23,13 @@ fn main() { for msg in iter_messages(&mut port) { match msg { - Ok(SBP::MsgLog(x)) => println!("{}", x.text), - Ok(SBP::MsgPosLLH(x)) => println!("{} {} {}", x.lat, x.lon, x.height), - Ok(_) => (), - - Err(Error::ParseError { .. }) => (), - Err(Error::IoError(ref x)) if x.kind() == std::io::ErrorKind::TimedOut => (), - + Ok(Sbp::MsgLog(x)) => println!("{}", x.text), + Ok(Sbp::MsgPosLlh(x)) => println!("{} {} {}", x.lat, x.lon, x.height), Err(e) => { - println!("{:?}", e); + eprintln!("{:?}", e); break; } + _ => {} } } } diff --git a/rust/sbp/rustfmt.toml b/rust/sbp/rustfmt.toml deleted file mode 100644 index a2b6833e12..0000000000 --- a/rust/sbp/rustfmt.toml +++ /dev/null @@ -1,2 +0,0 @@ -comment_width = 95 -wrap_comments = true diff --git a/rust/sbp/src/codec/json.rs b/rust/sbp/src/codec/json.rs deleted file mode 100644 index 2d0e13dbe4..0000000000 --- a/rust/sbp/src/codec/json.rs +++ /dev/null @@ -1,318 +0,0 @@ -use std::{borrow::Borrow, collections::HashMap}; - -use bytes::{Buf, BufMut, BytesMut}; -use dencode::{Decoder, Encoder, FramedWrite}; -use serde::{de::DeserializeOwned, Deserialize, Serialize}; -use serde_json::{ser::Formatter, Deserializer, Serializer, Value}; - -pub use serde_json::ser::CompactFormatter; - -const BASE64_SBP_MAX_PAYLOAD_SIZE: usize = crate::SBP_MAX_PAYLOAD_SIZE / 3 * 4 + 4; - -use crate::{ - messages::{SBPMessage, SBP}, - serialize::SbpSerialize, - Error, Result, -}; - -pub fn iter_messages( - input: R, -) -> impl Iterator> { - dencode::FramedRead::new(input, JsonDecoder::new()) -} - -#[cfg(feature = "async")] -pub fn stream_messages( - input: R, -) -> impl futures::Stream> { - dencode::FramedRead::new(input, JsonDecoder::new()) -} - -#[derive(Debug, Deserialize)] -#[serde(untagged)] -enum JsonInput { - Input(CommonJsonInput), - Nested { data: CommonJsonInput }, -} - -impl JsonInput { - pub fn into_inner(self) -> CommonJsonInput { - match self { - JsonInput::Input(data) | JsonInput::Nested { data } => data, - } - } -} - -#[derive(Debug, Deserialize)] -struct CommonJsonInput { - msg_type: u16, - payload: String, - sender: u16, -} - -pub struct JsonDecoder { - payload_buf: Vec, -} - -impl JsonDecoder { - pub fn new() -> Self { - JsonDecoder { - payload_buf: Vec::with_capacity(crate::SBP_MAX_PAYLOAD_SIZE), - } - } - - fn parse_json(&mut self, input: JsonInput) -> Result { - let data = input.into_inner(); - - self.payload_buf.clear(); - base64::decode_config_buf(data.payload, base64::STANDARD, &mut self.payload_buf).map_err( - |err| Error::JsonParseError { - details: format!("Invalid base64 payload: {}", err), - }, - )?; - let mut payload = self.payload_buf.as_slice(); - - SBP::parse(data.msg_type, data.sender, &mut payload) - } -} - -impl Decoder for JsonDecoder { - type Item = SBP; - type Error = Error; - - fn decode(&mut self, src: &mut BytesMut) -> Result> { - let value = match decode_one::(src)? { - Some(v) => v, - None => return Ok(None), - }; - self.parse_json(value).map(Option::Some) - } -} - -#[derive(Debug, Deserialize)] -pub struct Json2JsonInput { - data: OwnedCommonJson, - - #[serde(flatten)] - other: HashMap, -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct OwnedCommonJson { - crc: u16, - length: u8, - msg_type: u16, - payload: String, - preamble: u8, - sender: u16, -} - -pub struct Json2JsonDecoder {} - -impl Decoder for Json2JsonDecoder { - type Item = Json2JsonInput; - type Error = Error; - - fn decode(&mut self, src: &mut BytesMut) -> Result> { - decode_one::(src) - } -} - -fn decode_one(buf: &mut BytesMut) -> Result> { - let mut de = Deserializer::from_slice(&buf).into_iter::(); - let value = de.next(); - - let bytes_read = de.byte_offset(); - buf.advance(bytes_read); - - match value.transpose() { - Ok(v) => Ok(v), - Err(e) if e.is_eof() => Ok(None), - Err(e) => Err(e.into()), - } -} - -#[derive(Debug, Serialize, Deserialize)] -struct CommonJson<'a> { - crc: u16, - length: u8, - msg_type: u16, - payload: &'a str, - preamble: u8, - sender: u16, -} - -pub struct JsonEncoder { - payload_buf: String, - frame_buf: Vec, - formatter: F, -} - -impl JsonEncoder { - pub fn new(formatter: F) -> Self { - JsonEncoder { - frame_buf: Vec::with_capacity(crate::SBP_MAX_PAYLOAD_SIZE), - payload_buf: String::with_capacity(BASE64_SBP_MAX_PAYLOAD_SIZE), - formatter, - } - } - - pub fn framed(writer: W, formatter: F) -> FramedWrite { - FramedWrite::new(writer, Self::new(formatter)) - } -} - -#[derive(Debug, Serialize)] -struct JsonOutput<'a> { - #[serde(flatten)] - common: CommonJson<'a>, - - #[serde(flatten)] - msg: &'a SBP, -} - -impl Encoder for JsonEncoder -where - F: Formatter + Clone, - T: Borrow, -{ - type Error = Error; - - fn encode(&mut self, msg: T, dst: &mut BytesMut) -> Result<()> { - let msg = msg.borrow(); - let formatter = self.formatter.clone(); - let common = get_common_fields(&mut self.payload_buf, &mut self.frame_buf, msg)?; - let output = JsonOutput { common, msg }; - - let mut ser = Serializer::with_formatter(dst.writer(), formatter); - output.serialize(&mut ser)?; - dst.put_slice(b"\n"); - - Ok(()) - } -} - -#[derive(Debug, Serialize)] -struct Json2JsonOutput<'a> { - data: JsonOutput<'a>, - - #[serde(flatten)] - other: HashMap, -} - -pub struct Json2JsonEncoder { - payload_buf: String, - frame_buf: Vec, - formatter: F, -} - -impl Json2JsonEncoder { - pub fn new(formatter: F) -> Self { - Json2JsonEncoder { - frame_buf: Vec::with_capacity(crate::SBP_MAX_PAYLOAD_SIZE), - payload_buf: String::with_capacity(BASE64_SBP_MAX_PAYLOAD_SIZE), - formatter, - } - } -} - -impl Encoder for Json2JsonEncoder { - type Error = Error; - - fn encode(&mut self, input: Json2JsonInput, dst: &mut BytesMut) -> Result<()> { - let formatter = self.formatter.clone(); - - let payload = base64::decode(input.data.payload).map_err(|err| Error::JsonParseError { - details: format!("Invalid base64 payload: {}", err), - })?; - - let msg = { - let mut payload = payload.as_slice(); - SBP::parse(input.data.msg_type, input.data.sender, &mut payload)? - }; - - let output = Json2JsonOutput { - data: JsonOutput { - common: get_common_fields(&mut self.payload_buf, &mut self.frame_buf, &msg)?, - msg: &msg, - }, - other: input.other, - }; - - let mut ser = Serializer::with_formatter(dst.writer(), formatter); - output.serialize(&mut ser)?; - dst.put_slice(b"\n"); - - Ok(()) - } -} - -fn get_common_fields<'a>( - payload_buf: &'a mut String, - frame_buf: &'a mut Vec, - msg: &SBP, -) -> Result> { - payload_buf.clear(); - frame_buf.clear(); - - let length = msg.sbp_size(); - - msg.write_frame(frame_buf)?; - - let crc = { - let crc_b0 = frame_buf - [crate::MSG_HEADER_LEN + length..crate::MSG_HEADER_LEN + length + crate::MSG_CRC_LEN][0] - as u16; - let crc_b1 = frame_buf - [crate::MSG_HEADER_LEN + length..crate::MSG_HEADER_LEN + length + crate::MSG_CRC_LEN][1] - as u16; - (crc_b1 << 8) | crc_b0 - }; - - base64::encode_config_buf( - &frame_buf[crate::MSG_HEADER_LEN..crate::MSG_HEADER_LEN + length], - base64::STANDARD, - payload_buf, - ); - - Ok(CommonJson { - preamble: 0x55, - sender: msg.get_sender_id().unwrap_or(0), - msg_type: msg.get_message_type(), - length: length as u8, - payload: payload_buf, - crc, - }) -} - -/// Provide Haskell style formatting. Output should be similar to: https://hackage.haskell.org/package/base-4.8.2.0/docs/Numeric.html#v:showFloat -#[derive(Clone)] -pub struct HaskellishFloatFormatter {} - -macro_rules! show_float { - ($writer:expr, $value:expr) => { - if $value == 0.0 || $value.abs() >= 0.1 && $value.abs() <= 9_999_999.0 { - write!($writer, "{}", $value) - } else { - write!($writer, "{:e}", $value) - } - }; -} - -impl Formatter for HaskellishFloatFormatter { - #[inline] - fn write_f32(&mut self, writer: &mut W, value: f32) -> std::io::Result<()> - where - W: std::io::Write, - { - show_float!(writer, value) - } - - #[inline] - fn write_f64(&mut self, writer: &mut W, value: f64) -> std::io::Result<()> - where - W: std::io::Write, - { - show_float!(writer, value) - } -} diff --git a/rust/sbp/src/codec/mod.rs b/rust/sbp/src/codec/mod.rs deleted file mode 100644 index fd9a26bf42..0000000000 --- a/rust/sbp/src/codec/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub use dencode; - -#[cfg(feature = "json")] -pub mod json; -pub mod sbp; diff --git a/rust/sbp/src/codec/sbp.rs b/rust/sbp/src/codec/sbp.rs deleted file mode 100644 index 60dc55e84f..0000000000 --- a/rust/sbp/src/codec/sbp.rs +++ /dev/null @@ -1,124 +0,0 @@ -use std::borrow::Borrow; - -use bytes::{Buf, BufMut, BytesMut}; -use dencode::{Decoder, Encoder, FramedRead, FramedWrite}; - -use crate::{ - messages::{SBPMessage, SBP}, - parser::{parse_sbp, ParseResult}, - Error, Result, -}; - -const MAX_FRAME_LENGTH: usize = - crate::MSG_HEADER_LEN + crate::SBP_MAX_PAYLOAD_SIZE + crate::MSG_CRC_LEN; - -const PREAMBLE: u8 = 0x55; - -#[cfg(feature = "async")] -pub fn stream_messages( - input: R, -) -> impl futures::Stream> { - FramedRead::new(input, SbpDecoder::new()) -} - -pub fn iter_messages(input: R) -> impl Iterator> { - FramedRead::new(input, SbpDecoder::new()) -} - -pub struct SbpDecoder {} - -impl SbpDecoder { - pub fn new() -> Self { - Self {} - } -} - -impl Decoder for SbpDecoder { - type Item = SBP; - type Error = Error; - - fn decode(&mut self, src: &mut BytesMut) -> Result> { - let start = match src.iter().position(|b| b == &PREAMBLE) { - Some(idx) => idx, - None => { - src.clear(); - return Ok(None); - } - }; - - src.advance(start); - - match parse_sbp(&src) { - ParseResult::Ok((bytes_read, msg)) => { - src.advance(bytes_read); - log::trace!("{:?}", msg); - Ok(Some(msg)) - } - ParseResult::Err((bytes_read, err)) => { - src.advance(bytes_read); - Err(err) - } - ParseResult::Incomplete => { - src.reserve(MAX_FRAME_LENGTH); - Ok(None) - } - } - } - - fn decode_eof(&mut self, buf: &mut BytesMut) -> Result> { - let res = match self.decode(buf) { - Ok(Some(frame)) => Ok(Some(frame)), - _ => Ok(None), - }; - buf.clear(); - res - } -} - -pub struct SbpEncoder { - frame: Vec, -} - -impl SbpEncoder { - pub fn new() -> Self { - SbpEncoder { - frame: Vec::with_capacity(MAX_FRAME_LENGTH), - } - } - - pub fn framed(writer: W) -> FramedWrite { - FramedWrite::new(writer, Self::new()) - } -} - -impl Encoder for SbpEncoder -where - T: Borrow, -{ - type Error = Error; - - fn encode(&mut self, msg: T, dst: &mut BytesMut) -> Result<()> { - self.frame.clear(); - match msg.borrow().write_frame(&mut self.frame) { - Ok(_) => dst.put_slice(self.frame.as_slice()), - Err(err) => log::error!("Error converting sbp message to frame: {}", err), - } - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_parse_nothing() { - let mut decoder = SbpDecoder::new(); - let data = vec![0u8; 1000]; - let mut bytes = BytesMut::from(&data[..]); - - assert_eq!(bytes.len(), 1000); - assert!(matches!(decoder.decode(&mut bytes), Ok(None))); - assert!(bytes.is_empty()); - } -} diff --git a/rust/sbp/src/de.rs b/rust/sbp/src/de.rs new file mode 100644 index 0000000000..ec64f8a3bf --- /dev/null +++ b/rust/sbp/src/de.rs @@ -0,0 +1,341 @@ +use std::io; + +use bytes::{Buf, BytesMut}; +use dencode::{Decoder, FramedRead}; + +use crate::{wire_format, Sbp, CRC_LEN, HEADER_LEN, MAX_FRAME_LEN, PREAMBLE}; + +/// Deserialize the IO stream into an iterator of messages. +/// +/// # Example +/// +/// ``` +/// use std::io::Cursor; +/// +/// use sbp::messages::logging::MsgLog; +/// +/// fn main() -> Result<(), Box> { +/// let mut data = Vec::new(); +/// sbp::to_writer( +/// &mut data, +/// &MsgLog { +/// sender_id: Some(1), +/// level: 1, +/// text: String::from("hello").into(), +/// }, +/// )?; +/// sbp::to_writer( +/// &mut data, +/// &MsgLog { +/// sender_id: Some(1), +/// level: 1, +/// text: String::from("world").into(), +/// }, +/// )?; +/// let messages = sbp::iter_messages(Cursor::new(data)); +/// assert_eq!(messages.count(), 2); +/// Ok(()) +/// } +/// ``` +pub fn iter_messages(input: R) -> impl Iterator> { + SbpDecoder::framed(input) +} + +/// Deserialize the async IO stream into an stream of messages. +#[cfg(feature = "async")] +pub fn stream_messages( + input: R, +) -> impl futures::Stream> { + SbpDecoder::framed(input) +} + +pub fn parse_frame(buf: &mut BytesMut) -> Option> { + if buf.len() < HEADER_LEN { + return None; + } + // use a separate slice to parse the header so we don't advance the buffer + // until we know we have enough bytes to parse the payload + crc + let mut slice = &buf[1..]; + let msg_type = slice.get_u16_le(); + let sender_id = slice.get_u16_le(); + let payload_len = slice.get_u8() as usize; + if slice.len() < payload_len + CRC_LEN { + return None; + } + buf.advance(HEADER_LEN); + let payload = buf.split_to(payload_len); + let crc = buf.get_u16_le(); + if check_crc(msg_type, sender_id, &payload, crc) { + Some(Ok(Frame { + msg_type, + sender_id, + payload, + })) + } else { + Some(Err(CrcError { + msg_type, + sender_id, + crc, + })) + } +} + +fn check_crc(msg_type: u16, sender_id: u16, payload: &[u8], crc_in: u16) -> bool { + let mut crc = crc16::State::::new(); + crc.update(&msg_type.to_le_bytes()); + crc.update(&sender_id.to_le_bytes()); + crc.update(&[payload.len() as u8]); + crc.update(payload); + crc.get() == crc_in +} + +#[derive(Debug)] +pub struct Frame { + pub msg_type: u16, + pub sender_id: u16, + pub payload: BytesMut, +} + +/// All errors that can occur while reading messages. +#[derive(Debug)] +pub enum Error { + PayloadParseError(wire_format::PayloadParseError), + CrcError(CrcError), + IoError(io::Error), +} + +impl std::fmt::Display for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Error::PayloadParseError(e) => e.fmt(f), + Error::CrcError(e) => e.fmt(f), + Error::IoError(e) => e.fmt(f), + } + } +} + +impl std::error::Error for Error {} + +impl From for Error { + fn from(e: wire_format::PayloadParseError) -> Self { + Error::PayloadParseError(e) + } +} + +impl From for Error { + fn from(e: CrcError) -> Self { + Error::CrcError(e) + } +} + +impl From for Error { + fn from(e: io::Error) -> Self { + Error::IoError(e) + } +} + +#[derive(Debug, Clone)] +pub struct CrcError { + pub msg_type: u16, + pub sender_id: u16, + pub crc: u16, +} + +impl std::fmt::Display for CrcError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "crc validation failed: sender_id={:#02X?} msg_type={:#02X?} crc={:#02X?}", + self.msg_type, self.sender_id, self.crc + ) + } +} + +impl std::error::Error for CrcError {} + +#[derive(Debug, Clone, Default)] +struct SbpDecoder; + +impl SbpDecoder { + fn framed(writer: W) -> FramedRead { + FramedRead::new(writer, SbpDecoder) + } +} + +impl Decoder for SbpDecoder { + type Item = Sbp; + type Error = Error; + + fn decode(&mut self, src: &mut BytesMut) -> Result, Self::Error> { + let start = match src.iter().position(|b| b == &PREAMBLE) { + Some(idx) => idx, + None => { + src.clear(); + return Ok(None); + } + }; + src.advance(start); + match parse_frame(src) { + Some(Ok(frame)) => Ok(Some(Sbp::from_frame(frame)?)), + Some(Err(err)) => Err(err.into()), + None => { + src.reserve(MAX_FRAME_LEN); + Ok(None) + } + } + } + + fn decode_eof(&mut self, buf: &mut BytesMut) -> Result, Self::Error> { + let res = match self.decode(buf) { + Ok(Some(frame)) => Ok(Some(frame)), + _ => Ok(None), + }; + buf.clear(); + res + } +} + +#[cfg(test)] +mod tests { + use std::{convert::TryInto, io::Cursor}; + + use bytes::BufMut; + + use crate::{messages::navigation::MsgBaselineEcef, wire_format::WireFormat}; + + use super::*; + + /// Test parsing when we don't have enough data for a frame message + #[test] + fn test_parse_frame_incomplete() { + let packet = [ + 0x55u8, 0x0b, 0x02, 0xd3, 0x88, 0x14, 0x28, 0xf4, 0x7a, 0x13, 0x96, 0x62, 0xee, 0xff, + 0xbe, 0x40, 0x14, 0x00, 0xf6, 0xa3, 0x09, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xdb, + ]; + let missing_byte = 0xbf; + let mut buf = BytesMut::from(&packet[..]); + + let res = parse_frame(&mut buf); + assert!(res.is_none()); + assert_eq!(buf.len(), packet.len()); + + buf.put_u8(missing_byte); + + let res = parse_frame(&mut buf).unwrap().unwrap(); + assert_eq!(res.msg_type, 523); // 0x020B + assert_eq!(res.sender_id, 35027); // 0x88D3 + assert_eq!( + res.payload, + BytesMut::from(&packet[HEADER_LEN..packet.len() - 1]) + ); + assert!(buf.is_empty()); + } + + #[test] + fn test_parse_nothing() { + let data = vec![0u8; 1000]; + let mut bytes = BytesMut::from(&data[..]); + assert_eq!(bytes.len(), 1000); + assert!(matches!(SbpDecoder.decode(&mut bytes), Ok(None))); + assert!(bytes.is_empty()); + } + + #[test] + fn test_parse_bad_message() { + // Properly framed data but the payload isn't right given the message type + let data: Vec = vec![0x55, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x65, 0x8D]; + let mut bytes = BytesMut::from(&data[..]); + let actual = SbpDecoder.decode(&mut bytes); + assert!(matches!(actual, Err(Error::PayloadParseError(_)))); + assert!(bytes.is_empty()); + } + + #[test] + fn test_iter_messages() { + let mut payload = vec![ + 0x55u8, 0x0b, 0x02, 0xd3, 0x88, 0x14, 0x28, 0xf4, 0x7a, 0x13, 0x96, 0x62, 0xee, 0xff, + 0xbe, 0x40, 0x14, 0x00, 0xf6, 0xa3, 0x09, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xdb, 0xbf, + ]; + payload.append(&mut payload.clone()); + let input = Cursor::new(payload); + let mut count = 0; + for msg in iter_messages(input) { + assert!(msg.is_ok()); + count += 1; + } + assert_eq!(count, 2); + } + + #[test] + fn test_parse_crc_error() { + let packet = vec![ + // Start with a mostly valid message, with a single byte error + 0x55, 0x0c, // This byte should be 0x0b, changed to intentionally cause a CRC error + 0x02, 0xd3, 0x88, 0x14, 0x28, 0xf4, 0x7a, 0x13, 0x96, 0x62, 0xee, 0xff, 0xbe, 0x40, + 0x14, 0x00, 0xf6, 0xa3, 0x09, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xdb, 0xbf, 0xde, 0xad, + 0xbe, 0xef, // Include another valid message to properly parse + 0x55, 0x0b, 0x02, 0xd3, 0x88, 0x14, 0x28, 0xf4, 0x7a, 0x13, 0x96, 0x62, 0xee, 0xff, + 0xbe, 0x40, 0x14, 0x00, 0xf6, 0xa3, 0x09, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xdb, 0xbf, + 0xde, 0xad, 0xbe, 0xef, + ]; + let mut msgs = iter_messages(Cursor::new(packet)); + + let res = msgs.next().unwrap().unwrap_err(); + assert!(matches!(res, Error::CrcError(..))); + + let res = msgs.next().unwrap(); + assert!(res.is_ok()); + } + + #[test] + fn test_invalid_utf8() { + let packet = vec![ + 0x55, 0xa7, 0x0, 0x0, 0x10, 0x48, 0x8, 0x0, 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x69, 0x6f, + 0x6e, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xb6, 0xe8, 0xab, + ]; + let mut msgs = iter_messages(Cursor::new(packet)); + + let sbp_result = msgs.next().unwrap(); + assert!(sbp_result.is_ok()); + + let sbp_message = sbp_result.unwrap(); + assert_eq!(sbp_message.encoded_len(), 72); + } + + #[test] + fn test_decode_sbp() { + let mut packet = BytesMut::from( + &[ + 0x55u8, 0x0b, 0x02, 0xd3, 0x88, 0x14, 0x28, 0xf4, 0x7a, 0x13, 0x96, 0x62, 0xee, + 0xff, 0xbe, 0x40, 0x14, 0x00, 0xf6, 0xa3, 0x09, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xdb, + 0xbf, + ][..], + ); + let baseline_ecef_expectation = MsgBaselineEcef { + sender_id: Some(0x88d3), + accuracy: 0, + flags: 0, + n_sats: 14, + tow: 326825000, + x: -1154410, + y: 1327294, + z: 631798, + }; + + let msg = SbpDecoder.decode(&mut packet).unwrap().unwrap(); + assert!(packet.is_empty()); + + let msg: MsgBaselineEcef = msg.try_into().unwrap(); + assert_eq!(msg.sender_id, baseline_ecef_expectation.sender_id); + assert_eq!(msg.accuracy, baseline_ecef_expectation.accuracy); + assert_eq!(msg.flags, baseline_ecef_expectation.flags); + assert_eq!(msg.n_sats, baseline_ecef_expectation.n_sats); + assert_eq!(msg.tow, baseline_ecef_expectation.tow); + assert_eq!(msg.x, baseline_ecef_expectation.x); + assert_eq!(msg.y, baseline_ecef_expectation.y); + assert_eq!(msg.z, baseline_ecef_expectation.z); + } +} diff --git a/rust/sbp/src/json/de.rs b/rust/sbp/src/json/de.rs new file mode 100644 index 0000000000..a18d1e5424 --- /dev/null +++ b/rust/sbp/src/json/de.rs @@ -0,0 +1,108 @@ +use std::io; + +use bytes::{Buf, BytesMut}; +use dencode::{Decoder, FramedRead}; +use serde::de::DeserializeOwned; +use serde_json::Deserializer; + +use crate::{ + de::Frame, + json::{Json2JsonInput, JsonError, JsonInput}, + messages::Sbp, + MAX_PAYLOAD_LEN, +}; + +/// Deserialize the IO stream into an iterator of messages. +pub fn iter_messages(input: R) -> impl Iterator> { + JsonDecoder::framed(input) +} + +/// Deserialize the IO stream into an iterator of [Json2JsonInput] messages. +pub fn iter_json2json_messages( + input: R, +) -> impl Iterator> { + Json2JsonDecoder::framed(input) +} + +/// Deserialize the async IO stream into an stream of messages. +#[cfg(feature = "async")] +pub fn stream_messages( + input: R, +) -> impl futures::Stream> { + JsonDecoder::framed(input) +} + +#[derive(Debug, Default)] +struct JsonDecoder { + payload_buf: Vec, +} + +impl JsonDecoder { + fn new() -> Self { + JsonDecoder { + payload_buf: Vec::with_capacity(MAX_PAYLOAD_LEN), + } + } + + fn framed(input: R) -> FramedRead { + FramedRead::new(input, Self::new()) + } + + fn parse_json(&mut self, input: JsonInput) -> Result { + let data = input.into_inner(); + self.payload_buf.clear(); + base64::decode_config_buf(data.payload, base64::STANDARD, &mut self.payload_buf)?; + let msg = Sbp::from_frame(Frame { + msg_type: data.msg_type, + sender_id: data.sender, + payload: BytesMut::from(&self.payload_buf[..]), + })?; + Ok(msg) + } +} + +impl Decoder for JsonDecoder { + type Item = Sbp; + type Error = JsonError; + + fn decode(&mut self, src: &mut BytesMut) -> Result, Self::Error> { + let value = match decode_one::(src)? { + Some(v) => v, + None => return Ok(None), + }; + self.parse_json(value).map(Option::Some) + } +} + +#[derive(Debug)] +struct Json2JsonDecoder; + +impl Json2JsonDecoder { + fn framed(input: R) -> FramedRead { + FramedRead::new(input, Self) + } +} + +impl Decoder for Json2JsonDecoder { + type Item = Json2JsonInput; + type Error = JsonError; + + fn decode(&mut self, src: &mut BytesMut) -> Result, Self::Error> { + decode_one::(src).map_err(Into::into) + } +} + +fn decode_one(buf: &mut BytesMut) -> Result, serde_json::Error> +where + T: DeserializeOwned, +{ + let mut de = Deserializer::from_slice(&buf).into_iter::(); + let value = de.next(); + let bytes_read = de.byte_offset(); + buf.advance(bytes_read); + match value.transpose() { + Ok(v) => Ok(v), + Err(e) if e.is_eof() => Ok(None), + Err(e) => Err(e), + } +} diff --git a/rust/sbp/src/json/mod.rs b/rust/sbp/src/json/mod.rs new file mode 100644 index 0000000000..5bafe71688 --- /dev/null +++ b/rust/sbp/src/json/mod.rs @@ -0,0 +1,182 @@ +//! Encode/decode SBP messages as JSON. + +mod de; +mod ser; + +use std::collections::HashMap; +use std::io; + +use serde::{Deserialize, Serialize}; +use serde_json::{ser::Formatter, Value}; + +pub use serde_json::ser::CompactFormatter; + +#[cfg(feature = "async")] +pub use de::stream_messages; +pub use de::{iter_json2json_messages, iter_messages}; + +pub use ser::{to_vec, to_writer, Json2JsonEncoder, JsonEncoder}; + +#[derive(Debug, Deserialize)] +#[serde(untagged)] +enum JsonInput { + Input(CommonJsonInput), + Nested { data: CommonJsonInput }, +} + +impl JsonInput { + fn into_inner(self) -> CommonJsonInput { + match self { + JsonInput::Input(data) | JsonInput::Nested { data } => data, + } + } +} + +#[derive(Debug, Deserialize)] +struct CommonJsonInput { + msg_type: u16, + payload: String, + sender: u16, +} + +/// 'Compressed' Sbp JSON messages. Unlike normal SBP json these messages +/// just contain the base64 payload of the message, not the individual fields. +#[derive(Debug, Deserialize)] +pub struct Json2JsonInput { + data: OwnedCommonJson, + + #[serde(flatten)] + other: HashMap, +} + +#[derive(Debug, Serialize, Deserialize)] +struct OwnedCommonJson { + crc: u16, + length: u8, + msg_type: u16, + payload: String, + preamble: u8, + sender: u16, +} + +#[derive(Debug, Serialize)] +struct Json2JsonOutput<'a, M> { + data: JsonOutput<'a, M>, + + #[serde(flatten)] + other: HashMap, +} + +#[derive(Debug, Serialize, Deserialize)] +struct CommonJson<'a> { + crc: u16, + length: u8, + msg_type: u16, + payload: &'a str, + preamble: u8, + sender: u16, +} + +#[derive(Debug, Serialize)] +struct JsonOutput<'a, M> { + #[serde(flatten)] + common: CommonJson<'a>, + + #[serde(flatten)] + msg: &'a M, +} + +/// Provide Haskell style formatting. Output should be similar to: +/// +#[derive(Debug, Clone)] +pub struct HaskellishFloatFormatter; + +macro_rules! show_float { + ($writer:expr, $value:expr) => { + if $value == 0.0 || $value.abs() >= 0.1 && $value.abs() <= 9_999_999.0 { + write!($writer, "{}", $value) + } else { + write!($writer, "{:e}", $value) + } + }; +} + +impl Formatter for HaskellishFloatFormatter { + #[inline] + fn write_f32(&mut self, writer: &mut W, value: f32) -> io::Result<()> + where + W: io::Write + ?Sized, + { + show_float!(writer, value) + } + + #[inline] + fn write_f64(&mut self, writer: &mut W, value: f64) -> io::Result<()> + where + W: io::Write + ?Sized, + { + show_float!(writer, value) + } +} + +/// All possible error types when encoding/decoding a stream of json messages. +#[derive(Debug)] +pub enum JsonError { + PayloadParseError(crate::wire_format::PayloadParseError), + CrcError(crate::de::CrcError), + WriteFrameError(crate::ser::WriteFrameError), + IoError(io::Error), + Base64Error(base64::DecodeError), + SerdeJsonError(serde_json::Error), +} + +impl std::fmt::Display for JsonError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + JsonError::PayloadParseError(e) => e.fmt(f), + JsonError::CrcError(e) => e.fmt(f), + JsonError::WriteFrameError(e) => e.fmt(f), + JsonError::IoError(e) => e.fmt(f), + JsonError::Base64Error(e) => e.fmt(f), + JsonError::SerdeJsonError(e) => e.fmt(f), + } + } +} + +impl std::error::Error for JsonError {} + +impl From for JsonError { + fn from(e: crate::wire_format::PayloadParseError) -> Self { + JsonError::PayloadParseError(e) + } +} + +impl From for JsonError { + fn from(e: crate::de::CrcError) -> Self { + JsonError::CrcError(e) + } +} + +impl From for JsonError { + fn from(e: crate::ser::WriteFrameError) -> Self { + JsonError::WriteFrameError(e) + } +} + +impl From for JsonError { + fn from(e: io::Error) -> Self { + JsonError::IoError(e) + } +} + +impl From for JsonError { + fn from(e: base64::DecodeError) -> Self { + JsonError::Base64Error(e) + } +} + +impl From for JsonError { + fn from(e: serde_json::Error) -> Self { + JsonError::SerdeJsonError(e) + } +} diff --git a/rust/sbp/src/json/ser.rs b/rust/sbp/src/json/ser.rs new file mode 100644 index 0000000000..7f4dd85988 --- /dev/null +++ b/rust/sbp/src/json/ser.rs @@ -0,0 +1,243 @@ +use std::{borrow::Borrow, io}; + +use bytes::{BufMut, BytesMut}; +use dencode::{Encoder, FramedWrite, IterSinkExt}; +use serde::Serialize; +use serde_json::{ser::Formatter, Serializer}; + +use super::{JsonError, JsonOutput}; + +use crate::{ + de::Frame, + json::{CommonJson, HaskellishFloatFormatter, Json2JsonInput, Json2JsonOutput}, + messages::Sbp, + SbpMessage, CRC_LEN, HEADER_LEN, MAX_PAYLOAD_LEN, PREAMBLE, +}; + +const BASE64_MAX_PAYLOAD_LEN: usize = MAX_PAYLOAD_LEN / 3 * 4 + 4; + +/// Serialize the given message as JSON into the IO stream. +pub fn to_writer(mut writer: W, msg: &M) -> Result<(), JsonError> +where + W: io::Write, + M: SbpMessage + Serialize, +{ + let mut frame = BytesMut::new(); + let mut payload = String::new(); + let mut buf = BytesMut::new(); + to_buffer( + &mut frame, + &mut payload, + &mut buf, + HaskellishFloatFormatter, + msg, + )?; + writer.write_all(&buf)?; + Ok(()) +} + +/// Serialize the given message as a JSON byte vector. +pub fn to_vec(msg: &M) -> Result, JsonError> +where + M: SbpMessage + Serialize, +{ + let mut frame = BytesMut::new(); + let mut payload = String::new(); + let mut buf = BytesMut::new(); + to_buffer( + &mut frame, + &mut payload, + &mut buf, + HaskellishFloatFormatter, + msg, + )?; + Ok(buf.to_vec()) +} + +pub fn to_buffer( + frame_buf: &mut BytesMut, + payload_buf: &mut String, + dst: &mut BytesMut, + formatter: F, + msg: &M, +) -> Result<(), JsonError> +where + F: Formatter, + M: SbpMessage + Serialize, +{ + let output = JsonOutput { + common: get_common_fields(payload_buf, frame_buf, msg)?, + msg, + }; + let mut ser = Serializer::with_formatter(dst.writer(), formatter); + output.serialize(&mut ser)?; + dst.put_slice(b"\n"); + Ok(()) +} + +/// Writes [Sbp] messages as JSON into a writer. +#[derive(Debug)] +pub struct JsonEncoder(FramedWrite>); + +impl JsonEncoder +where + W: io::Write, + F: Formatter + Clone, +{ + /// Creates a new JsonEncoder. + pub fn new(writer: W, formatter: F) -> JsonEncoder { + Self(FramedWrite::new(writer, JsonEncoderInner::new(formatter))) + } + + /// Send a message to the underlying writer. If sending multiple messages at once + /// consider using [JsonEncoder::send_all] which buffers the writing. + pub fn send(&mut self, message: &Sbp) -> Result<(), JsonError> { + self.0.send(message) + } + + /// Sends an iterator of messages to the underlying writer. + pub fn send_all(&mut self, messages: I) -> Result<(), JsonError> + where + I: IntoIterator, + { + self.0.send_all(messages.into_iter().map(Result::Ok)) + } +} + +#[derive(Debug, Default)] +struct JsonEncoderInner { + payload_buf: String, + frame_buf: BytesMut, + formatter: F, +} + +impl JsonEncoderInner { + fn new(formatter: F) -> Self { + JsonEncoderInner { + frame_buf: BytesMut::with_capacity(MAX_PAYLOAD_LEN), + payload_buf: String::with_capacity(BASE64_MAX_PAYLOAD_LEN), + formatter, + } + } +} + +impl Encoder for JsonEncoderInner +where + F: Formatter + Clone, + T: Borrow, +{ + type Error = JsonError; + + fn encode(&mut self, msg: T, dst: &mut BytesMut) -> Result<(), Self::Error> { + to_buffer( + &mut self.frame_buf, + &mut self.payload_buf, + dst, + self.formatter.clone(), + msg.borrow(), + ) + } +} + +/// Writes [Json2JsonInput] messages as JSON into a writer. +#[derive(Debug)] +pub struct Json2JsonEncoder(FramedWrite>); + +impl Json2JsonEncoder +where + W: io::Write, + F: Formatter + Clone, +{ + /// Creates a new Json2JsonEncoder. + pub fn new(writer: W, formatter: F) -> Json2JsonEncoder { + Self(FramedWrite::new( + writer, + Json2JsonEncoderInner::new(formatter), + )) + } + + /// Send a message to the underlying writer. If sending multiple messages at once + /// consider using [Json2JsonEncoder::send_all] which buffers the writing. + pub fn send(&mut self, message: Json2JsonInput) -> Result<(), JsonError> { + self.0.send(message) + } + + /// Sends an iterator of messages to the underlying writer. + pub fn send_all(&mut self, messages: I) -> Result<(), JsonError> + where + I: IntoIterator, + { + self.0.send_all(messages.into_iter().map(Result::Ok)) + } +} + +#[derive(Debug, Default)] +struct Json2JsonEncoderInner { + payload_buf: String, + frame_buf: BytesMut, + formatter: F, +} + +impl Json2JsonEncoderInner { + fn new(formatter: F) -> Self { + Json2JsonEncoderInner { + frame_buf: BytesMut::with_capacity(MAX_PAYLOAD_LEN), + payload_buf: String::with_capacity(BASE64_MAX_PAYLOAD_LEN), + formatter, + } + } +} + +impl Encoder for Json2JsonEncoderInner { + type Error = JsonError; + + fn encode(&mut self, input: Json2JsonInput, dst: &mut BytesMut) -> Result<(), Self::Error> { + let formatter = self.formatter.clone(); + let payload = base64::decode(input.data.payload)?; + let msg = Sbp::from_frame(Frame { + msg_type: input.data.msg_type, + sender_id: input.data.sender, + payload: BytesMut::from(&payload[..]), + })?; + let output = Json2JsonOutput { + data: JsonOutput { + common: get_common_fields(&mut self.payload_buf, &mut self.frame_buf, &msg)?, + msg: &msg, + }, + other: input.other, + }; + let mut ser = Serializer::with_formatter(dst.writer(), formatter); + output.serialize(&mut ser)?; + dst.put_slice(b"\n"); + Ok(()) + } +} + +fn get_common_fields<'a, M: SbpMessage>( + payload_buf: &'a mut String, + mut frame_buf: &'a mut BytesMut, + msg: &M, +) -> Result, JsonError> { + payload_buf.clear(); + frame_buf.clear(); + let size = msg.encoded_len(); + crate::ser::to_buffer(&mut frame_buf, msg)?; + let crc = { + let crc_b0 = frame_buf[HEADER_LEN + size..HEADER_LEN + size + CRC_LEN][0] as u16; + let crc_b1 = frame_buf[HEADER_LEN + size..HEADER_LEN + size + CRC_LEN][1] as u16; + (crc_b1 << 8) | crc_b0 + }; + base64::encode_config_buf( + &frame_buf[HEADER_LEN..HEADER_LEN + size], + base64::STANDARD, + payload_buf, + ); + Ok(CommonJson { + preamble: PREAMBLE, + sender: msg.sender_id().unwrap_or(0), + msg_type: msg.message_type(), + length: size as u8, + payload: payload_buf, + crc, + }) +} diff --git a/rust/sbp/src/lib.rs b/rust/sbp/src/lib.rs index 5ba79abb44..b18b58a800 100644 --- a/rust/sbp/src/lib.rs +++ b/rust/sbp/src/lib.rs @@ -1,378 +1,123 @@ //! Native implementation of decoding of SBP (Swift Binary Protocol) used by products //! made by Swift Navigation. For language agnostic description of the protocol please -//! see the protocol specification documentation at https://github.com/swift-nav/libsbp/tree/master/docs +//! see the [protocol specification documentation](https://github.com/swift-nav/libsbp/tree/master/docs). +//! +//! # Example: Print log messages +//! +//! This example shows how to read messages from stdin and print the contents +//! of each message `MsgLog` to stderr. +//! +//! ```no_run +//! use std::convert::TryFrom; +//! use std::error::Error; +//! use std::io; +//! use std::process; +//! +//! use sbp::messages::logging::MsgLog; +//! +//! fn example() -> Result<(), Box> { +//! let messages = sbp::iter_messages(io::stdin()); +//! for msg in messages { +//! // The iterator yields Result, so we check the error here. +//! let msg = msg?; +//! match MsgLog::try_from(msg) { +//! Ok(msg) => eprintln!("{}", msg.text), +//! _ => {} +//! } +//! } +//! Ok(()) +//! } +//! +//! fn main() { +//! if let Err(err) = example() { +//! eprintln!("error: {}", err); +//! process::exit(1); +//! } +//! } +//! ``` +//! +//! # Example: Filter by sender id and write to stdout +//! +//! This example shows how to read messages from stdin and forward messages with a matching +//! sender_id to stdout. +//! +//! ```no_run +//! use std::error::Error; +//! use std::io; +//! use std::process; +//! +//! use sbp::{SbpEncoder, SbpMessage}; +//! +//! fn example(sender_id: u16) -> Result<(), Box> { +//! let messages = sbp::iter_messages(io::stdin()); +//! let messages = messages.filter_map(|msg| match msg { +//! Ok(msg) if msg.sender_id() == Some(sender_id) => Some(msg), +//! _ => None, +//! }); +//! SbpEncoder::new(io::stdout()).send_all(messages)?; +//! Ok(()) +//! } +//! +//! fn main() { +//! if let Err(err) = example(42) { +//! eprintln!("error: {}", err); +//! process::exit(1); +//! } +//! } +//! ``` -pub mod codec; -#[cfg(feature = "link")] -pub mod link; pub mod messages; -pub(crate) mod parser; -pub mod sbp_tools; -pub mod serialize; -#[cfg(feature = "swiftnav")] -pub mod time; - -use std::{fmt, result}; - -#[cfg(feature = "sbp_serde")] -use serde::{Deserialize, Deserializer, Serialize, Serializer}; - -use crate::{messages::SBPMessage, serialize::SbpSerialize}; - -pub const SBP_MAX_PAYLOAD_SIZE: usize = 255; -pub const MSG_HEADER_LEN: usize = 1 /*preamble*/ + 2 /*msg_type*/ + 2 /*sender_id*/ + 1 /*len*/; -pub const MSG_CRC_LEN: usize = 2; - -pub use codec::sbp::iter_messages; - -#[cfg(feature = "async")] -pub use codec::sbp::stream_messages; +pub mod sbp_iter_ext; #[cfg(feature = "json")] -pub mod json { - pub use crate::codec::json::iter_messages; - - #[cfg(feature = "async")] - pub use crate::codec::json::stream_messages; -} - -#[derive(Debug, Clone)] -pub struct SbpString(Vec); - -impl SbpString { - pub fn as_bytes(&self) -> &[u8] { - &self.0 - } - pub fn to_string(&self) -> String { - String::from_utf8_lossy(&self.0).into() - } -} - -#[cfg(feature = "sbp_serde")] -impl Serialize for SbpString { - fn serialize(&self, serializer: S) -> result::Result - where - S: Serializer, - { - let s: String = self.clone().into(); - serializer.serialize_str(&s) - } -} - -#[cfg(feature = "sbp_serde")] -impl<'de> Deserialize<'de> for SbpString { - fn deserialize(deserializer: D) -> result::Result - where - D: Deserializer<'de>, - { - Deserialize::deserialize(deserializer).map(|s: String| SbpString::from(s)) - } -} - -impl From for SbpString { - fn from(s: String) -> SbpString { - SbpString(s.as_bytes().to_vec()) - } -} - -impl Into for SbpString { - fn into(self) -> String { - self.to_string() - } -} - -impl Into for &SbpString { - fn into(self) -> String { - self.to_string() - } -} - -impl Into> for SbpString { - fn into(self) -> Vec { - self.0 - } -} - -impl fmt::Display for SbpString { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "SbpString({})", Into::::into(self.clone())) - } -} - -pub type Result = result::Result; - -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("An error occured during parsing. Error kind: {kind:?}")] - ParseError { kind: nom::error::ErrorKind }, - - #[cfg(feature = "json")] - #[error("Failed to parse sbp message from json: {details}")] - JsonParseError { details: String }, - - #[error( - "CRC validation failed: sender_id={sender_id:#02X?} msg_type={msg_type:#02X?} crc={crc:#02X?}" - )] - CrcError { - msg_type: u16, - sender_id: u16, - crc: u16, - }, - - #[error(transparent)] - FramerError(#[from] FramerError), - - #[cfg(feature = "json")] - #[error(transparent)] - SerdeJsonError(#[from] serde_json::error::Error), - - #[error(transparent)] - IoError(#[from] std::io::Error), -} +pub mod json; -pub(crate) fn write_frame( - msg: &M, - frame: &mut Vec, -) -> std::result::Result<(), FramerError> { - let len = msg.sbp_size(); - if len > SBP_MAX_PAYLOAD_SIZE { - return Err(crate::FramerError::TooLarge); - } - let sender_id = msg.get_sender_id().ok_or(FramerError::NoSenderId)?; - - frame.reserve(len); - - (0x55 as u8).append_to_sbp_buffer(frame); - msg.get_message_type().append_to_sbp_buffer(frame); - sender_id.append_to_sbp_buffer(frame); - (len as u8).append_to_sbp_buffer(frame); - msg.append_to_sbp_buffer(frame); - crc16::State::::calculate(&frame[1..]).append_to_sbp_buffer(frame); - - Ok(()) -} - -#[derive(Debug, Clone, thiserror::Error)] -pub enum FramerError { - #[error("Message is too large to fit into an SBP frame")] - TooLarge, - - #[error("No sender ID is present in the message bring framed")] - NoSenderId, -} +#[cfg(feature = "link")] +pub mod link; #[cfg(feature = "swiftnav")] -mod swiftnav_conversions { - use std::convert::{TryFrom, TryInto}; - - use crate::messages; - - #[derive(Debug, Clone, thiserror::Error)] - pub enum GpsTimeError { - #[error(transparent)] - InvalidGpsTime(#[from] swiftnav::time::InvalidGpsTime), - - #[error("Failed to convert week number to i16")] - TryFromIntError(#[from] std::num::TryFromIntError), - } - - impl From for GpsTimeError { - fn from(_: std::convert::Infallible) -> Self { - unreachable!() - } - } - - impl TryFrom for swiftnav::time::GpsTime { - type Error = swiftnav::time::InvalidGpsTime; - - fn try_from( - msg: messages::gnss::GPSTime, - ) -> Result { - let tow = (msg.tow as f64) * 1e-3 + (msg.ns_residual as f64) * 1e-9; - swiftnav::time::GpsTime::new(msg.wn as i16, tow) - } - } - - impl TryFrom for swiftnav::time::GpsTime { - type Error = swiftnav::time::InvalidGpsTime; - - fn try_from( - msg: messages::gnss::GPSTimeSec, - ) -> Result { - swiftnav::time::GpsTime::new(msg.wn as i16, msg.tow as f64) - } - } - - impl TryFrom for swiftnav::signal::GnssSignal { - type Error = swiftnav::signal::InvalidGnssSignal; - - fn try_from( - value: messages::gnss::GnssSignal, - ) -> Result { - swiftnav::signal::GnssSignal::new(value.sat as u16, value.code.try_into()?) - } - } - - impl TryFrom for swiftnav::ephemeris::Ephemeris { - type Error = EphemerisDecodeError; - - fn try_from( - eph: messages::observation::MsgEphemerisGPS, - ) -> Result { - Ok(swiftnav::ephemeris::Ephemeris::new( - eph.common.sid.try_into()?, - eph.common.toe.try_into()?, - eph.common.ura, - eph.common.fit_interval, - eph.common.valid, - eph.common.health_bits, - 0, - swiftnav::ephemeris::EphemerisTerms::new_kepler( - swiftnav::signal::Constellation::Gps, - [eph.tgd, 0.], - eph.c_rc as f64, - eph.c_rs as f64, - eph.c_uc as f64, - eph.c_us as f64, - eph.c_ic as f64, - eph.c_is as f64, - eph.dn, - eph.m0, - eph.ecc, - eph.sqrta, - eph.omega0, - eph.omegadot, - eph.w, - eph.inc, - eph.inc_dot, - eph.af0 as f64, - eph.af1 as f64, - eph.af2 as f64, - eph.toc.try_into()?, - eph.iodc, - eph.iode as u16, - ), - )) - } - } - - impl TryFrom for swiftnav::ephemeris::Ephemeris { - type Error = EphemerisDecodeError; - - fn try_from( - eph: messages::observation::MsgEphemerisGal, - ) -> Result { - Ok(swiftnav::ephemeris::Ephemeris::new( - eph.common.sid.try_into()?, - eph.common.toe.try_into()?, - eph.common.ura, - eph.common.fit_interval, - eph.common.valid, - eph.common.health_bits, - eph.source, - swiftnav::ephemeris::EphemerisTerms::new_kepler( - swiftnav::signal::Constellation::Gal, - [eph.bgd_e1e5a, eph.bgd_e1e5b], - eph.c_rc as f64, - eph.c_rs as f64, - eph.c_uc as f64, - eph.c_us as f64, - eph.c_ic as f64, - eph.c_is as f64, - eph.dn, - eph.m0, - eph.ecc, - eph.sqrta, - eph.omega0, - eph.omegadot, - eph.w, - eph.inc, - eph.inc_dot, - eph.af0 as f64, - eph.af1 as f64, - eph.af2 as f64, - eph.toc.try_into()?, - eph.iodc, - eph.iode as u16, - ), - )) - } - } - - #[derive(Debug, Copy, Clone, PartialOrd, PartialEq, thiserror::Error)] - pub enum EphemerisDecodeError { - #[error(transparent)] - InvalidTime(#[from] swiftnav::time::InvalidGpsTime), - - #[error(transparent)] - InvalidSignal(#[from] swiftnav::signal::InvalidGnssSignal), - } - - impl TryFrom for swiftnav::navmeas::NavigationMeasurement { - type Error = swiftnav::signal::InvalidGnssSignal; +mod swiftnav_conversions; +#[cfg(feature = "swiftnav")] +pub mod time; - fn try_from( - observation: messages::observation::PackedObsContent, - ) -> Result - { - let mut measurement = swiftnav::navmeas::NavigationMeasurement::new(); +pub(crate) mod de; +pub(crate) mod sbp_string; +pub(crate) mod ser; +pub(crate) mod wire_format; - measurement.set_lock_time(swiftnav::navmeas::decode_lock_time(observation.lock)); - measurement.set_sid(observation.sid.try_into()?); - // A CN0 of 0 is considered invalid - if observation.cn0 != 0 { - measurement.set_cn0(observation.cn0 as f64 / 4.); - } - if observation.flags & 0x01 != 0 { - measurement.set_pseudorange(observation.P as f64 / 5e1); - } - if observation.flags & 0x08 != 0 { - measurement - .set_measured_doppler(observation.D.i as f64 + (observation.D.f as f64) / 256.); - } - if observation.flags & 0x80 != 0 { - measurement.set_flags( - measurement.flags() | swiftnav::navmeas::NAV_MEAS_FLAG_RAIM_EXCLUSION, - ); - } +/// Denotes the start of frame transmission. +pub const PREAMBLE: u8 = 0x55; - Ok(measurement) - } - } -} +/// Length of the header section. +pub const HEADER_LEN: usize = 1 /*preamble*/ + 2 /*msg_type*/ + 2 /*sender_id*/ + 1 /*len*/; -#[cfg(test)] -mod tests { - #[test] - fn test_making_frame() { - use crate::messages::SBPMessage; +/// Max length of the variable-sized payload field. +pub const MAX_PAYLOAD_LEN: usize = 255; - let msg = crate::messages::system::MsgStartup { - sender_id: Some(250), - cause: 1, - startup_type: 45, - reserved: 0, - }; +/// Length of the crc of the payload. +pub const CRC_LEN: usize = 2; - let frame = msg.to_frame().unwrap(); +/// Max length of a frame (header + payload + crc). +pub const MAX_FRAME_LEN: usize = HEADER_LEN + MAX_PAYLOAD_LEN + CRC_LEN; - let expected_frame = b"\x55\x00\xFF\xFA\x00\x04\x01\x2D\x00\x00\xBC\x73"; +#[doc(inline)] +pub use messages::Sbp; - assert_eq!(frame, expected_frame); - } +#[doc(inline)] +pub use crate::messages::SbpMessage; - #[test] - fn test_sbp_string() { - use crate::SbpString; +#[doc(inline)] +pub use ser::{to_vec, to_writer, Error as SerializeError, SbpEncoder}; - let sbp_str = SbpString(b"1234".to_vec()); - let s = sbp_str.to_string(); +#[doc(inline)] +pub use de::{iter_messages, Error as DeserializeError}; - assert_eq!("1234", s); +#[cfg(feature = "async")] +#[doc(inline)] +pub use de::stream_messages; - let sbp_str = SbpString(b"1234\xFF".to_vec()); - let s = sbp_str.to_string(); +#[doc(inline)] +pub use sbp_iter_ext::SbpIterExt; - assert_eq!("1234\u{FFFD}", s); - } -} +#[doc(inline)] +pub use sbp_string::SbpString; diff --git a/rust/sbp/src/link.rs b/rust/sbp/src/link.rs index c954ef5d14..739344f0f6 100644 --- a/rust/sbp/src/link.rs +++ b/rust/sbp/src/link.rs @@ -1,3 +1,5 @@ +//! Callback based message handler. + use std::{ borrow::{Borrow, Cow}, convert::TryInto, @@ -6,8 +8,9 @@ use std::{ use slotmap::DenseSlotMap; -use crate::messages::{ConcreteMessage, SBPMessage, SBP}; +use crate::messages::{ConcreteMessage, Sbp, SbpMessage}; +/// Used to send messages to callbacks registered via [Link]s created from this `LinkSource`. pub struct LinkSource<'link, S = ()> { link: Link<'link, S>, stateless_link: Link<'link, ()>, @@ -17,6 +20,7 @@ impl<'link, S> LinkSource<'link, S> where S: 'link, { + /// Creates a new `LinkSource`. pub fn new() -> Self { Self { link: Link::new(), @@ -24,17 +28,21 @@ where } } + /// Creates a new [Link] associated with this source. pub fn link(&self) -> Link<'link, S> { self.link.clone() } + /// Creates a new [Link] associated with this source. Handlers attached via this link + /// will not receive the shared state associated with this LinkSource. pub fn stateless_link(&self) -> Link<'link, ()> { self.stateless_link.clone() } + /// Send a message with state to all the links associated with this source. pub fn send_with_state(&self, state: &S, msg: M) -> bool where - M: Borrow, + M: Borrow, { let msg = msg.borrow(); let mut sent = false; @@ -61,14 +69,25 @@ where } impl<'link> LinkSource<'link, ()> { + /// Send a message to all the links associated with this source. pub fn send(&self, msg: M) -> bool where - M: Borrow, + M: Borrow, { self.send_with_state(&(), msg) } } +impl<'link, S> Default for LinkSource<'link, S> +where + S: 'link, +{ + fn default() -> Self { + Self::new() + } +} + +/// Used to attach message handlers. pub struct Link<'link, S> { inner: Arc>, } @@ -82,6 +101,7 @@ impl<'link, S> Link<'link, S> { } } + /// Register a new callback. pub fn register(&self, callback: F) -> Key where E: Event, @@ -92,6 +112,7 @@ impl<'link, S> Link<'link, S> { Key { key } } + /// Register a new callback with manually specified message types. pub fn register_by_id(&self, msg_types: &[u16], callback: F) -> Key where E: Event, @@ -102,6 +123,7 @@ impl<'link, S> Link<'link, S> { Key { key } } + /// Remove a previously registered callback. pub fn unregister(&self, key: Key) { self.inner.handlers.lock().unwrap().remove(key.key); } @@ -119,18 +141,19 @@ struct LinkInner<'link, S> { handlers: Mutex>>, } +/// A message handler and the message ids it responds to. pub struct Handler<'link, S> { - func: Box, + func: Box, msg_types: Cow<'static, [u16]>, } impl<'link, S> Handler<'link, S> { - fn run(&mut self, state: &S, msg: SBP) { + fn run(&mut self, state: &S, msg: Sbp) { (self.func)(state, msg); } - fn can_run(&self, msg: &SBP) -> bool { - self.msg_types.contains(&msg.get_message_type()) || self.msg_types.is_empty() + fn can_run(&self, msg: &Sbp) -> bool { + self.msg_types.contains(&msg.message_type()) || self.msg_types.is_empty() } } @@ -139,6 +162,7 @@ pub trait IntoHandler<'link, S, E, HandlerKind = WithState> { fn into_handler_with_ids(self, msg_types: &[u16]) -> Handler<'link, S>; } +/// Marker type for handlers that receive the [LinkSource]'s shared state. pub struct WithState; impl<'link, S, E, F> IntoHandler<'link, S, E, WithState> for F @@ -167,6 +191,7 @@ where } } +/// Marker type for handlers that do not receive the [LinkSource]'s shared state. pub struct WithoutState; impl<'link, S, E, F> IntoHandler<'link, S, E, WithoutState> for F @@ -199,21 +224,26 @@ slotmap::new_key_type! { struct KeyInner; } +/// Returned when registering a callback. Can be used to unregister the callback. #[derive(Debug, Clone, Copy, PartialEq)] pub struct Key { key: KeyInner, } +/// Something derived from an SBP message. pub trait Event { + /// The message types that correspond to this event. An empty slice means all messages. const MESSAGE_TYPES: &'static [u16]; - fn from_sbp(msg: SBP) -> Self; + /// Create an instance of this event from an SBP message. This message will only be called + /// if the message type is in `Event::MESSAGE_TYPES`. + fn from_sbp(msg: Sbp) -> Self; } -impl Event for SBP { +impl Event for Sbp { const MESSAGE_TYPES: &'static [u16] = &[]; - fn from_sbp(msg: SBP) -> Self { + fn from_sbp(msg: Sbp) -> Self { msg } } @@ -224,7 +254,7 @@ where { const MESSAGE_TYPES: &'static [u16] = &[T::MESSAGE_TYPE]; - fn from_sbp(msg: SBP) -> Self { + fn from_sbp(msg: Sbp) -> Self { match msg.try_into() { Ok(event) => event, Err(_) => { @@ -253,10 +283,10 @@ mod tests { let source = LinkSource::new(); let link = source.link(); let triggered = RefCell::new(false); - link.register(|triggered: &RefCell, _: SBP| { + link.register(|triggered: &RefCell, _: Sbp| { *triggered.borrow_mut() = true; }); - source.send_with_state(&triggered, SBP::from(make_msg_obs())); + source.send_with_state(&triggered, Sbp::from(make_msg_obs())); assert!(*triggered.borrow()); } @@ -269,14 +299,14 @@ mod tests { let triggered = RefCell::new(false); let handle = thread::spawn(move || { - link.register(|triggered: &RefCell, _: SBP| { + link.register(|triggered: &RefCell, _: Sbp| { *triggered.borrow_mut() = true; }); s.send(()).unwrap(); }); r.recv_timeout(Duration::from_secs(1)).unwrap(); - source.send_with_state(&triggered, SBP::from(make_msg_obs())); + source.send_with_state(&triggered, Sbp::from(make_msg_obs())); handle.join().unwrap(); @@ -289,10 +319,10 @@ mod tests { { let source = LinkSource::new(); let link = source.link(); - link.register(|_: SBP| { + link.register(|_: Sbp| { triggered = true; }); - source.send(SBP::from(make_msg_obs())); + source.send(Sbp::from(make_msg_obs())); } assert!(triggered); } @@ -303,11 +333,11 @@ mod tests { let link = source.link(); let count = RefCell::new(0); - let key = link.register(|count: &RefCell, _: SBP| { + let key = link.register(|count: &RefCell, _: Sbp| { *count.borrow_mut() += 1; }); - let msg = SBP::from(make_msg_obs()); + let msg = Sbp::from(make_msg_obs()); source.send_with_state(&count, &msg); assert_eq!(*count.borrow(), 1); @@ -325,10 +355,10 @@ mod tests { impl Event for ObsMsg { const MESSAGE_TYPES: &'static [u16] = &[MsgObs::MESSAGE_TYPE, MsgObsDepA::MESSAGE_TYPE]; - fn from_sbp(msg: SBP) -> Self { + fn from_sbp(msg: Sbp) -> Self { match msg { - SBP::MsgObs(m) => ObsMsg::Obs(m), - SBP::MsgObsDepA(m) => ObsMsg::DepA(m), + Sbp::MsgObs(m) => ObsMsg::Obs(m), + Sbp::MsgObsDepA(m) => ObsMsg::DepA(m), _ => unreachable!("wrong event keys"), } } @@ -342,10 +372,10 @@ mod tests { *count.borrow_mut() += 1; }); - source.send_with_state(&count, SBP::from(make_msg_obs())); + source.send_with_state(&count, Sbp::from(make_msg_obs())); assert_eq!(*count.borrow(), 1); - source.send_with_state(&count, SBP::from(make_msg_obs_dep_a())); + source.send_with_state(&count, Sbp::from(make_msg_obs_dep_a())); assert_eq!(*count.borrow(), 2); } @@ -353,7 +383,7 @@ mod tests { MsgObs { sender_id: Some(1), header: ObservationHeader { - t: messages::gnss::GPSTime { + t: messages::gnss::GpsTime { tow: 1, ns_residual: 1, wn: 1, @@ -368,7 +398,7 @@ mod tests { MsgObsDepA { sender_id: Some(1), header: ObservationHeaderDep { - t: messages::gnss::GPSTimeDep { tow: 1, wn: 1 }, + t: messages::gnss::GpsTimeDep { tow: 1, wn: 1 }, n_obs: 1, }, obs: vec![], diff --git a/rust/sbp/src/messages/acquisition.rs b/rust/sbp/src/messages/acquisition.rs index 4e6eae093f..2afc610f10 100644 --- a/rust/sbp/src/messages/acquisition.rs +++ b/rust/sbp/src/messages/acquisition.rs @@ -14,17 +14,9 @@ //****************************************************************************/ //! Satellite acquisition messages from the device. -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - use super::gnss::*; -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; + +use super::lib::*; /// Acq perfomance measurement and debug /// @@ -32,103 +24,103 @@ use crate::SbpString; /// profile during acquisition time. The message is used to debug and measure /// the performance. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct AcqSvProfile { /// SV search job type (deep, fallback, etc) + #[cfg_attr(feature = "serde", serde(rename(serialize = "job_type")))] pub job_type: u8, /// Acquisition status 1 is Success, 0 is Failure + #[cfg_attr(feature = "serde", serde(rename(serialize = "status")))] pub status: u8, /// CN0 value. Only valid if status is '1' + #[cfg_attr(feature = "serde", serde(rename(serialize = "cn0")))] pub cn0: u16, /// Acquisition integration time + #[cfg_attr(feature = "serde", serde(rename(serialize = "int_time")))] pub int_time: u8, /// GNSS signal for which acquisition was attempted + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, /// Acq frequency bin width + #[cfg_attr(feature = "serde", serde(rename(serialize = "bin_width")))] pub bin_width: u16, /// Timestamp of the job complete event + #[cfg_attr(feature = "serde", serde(rename(serialize = "timestamp")))] pub timestamp: u32, /// Time spent to search for sid.code + #[cfg_attr(feature = "serde", serde(rename(serialize = "time_spent")))] pub time_spent: u32, /// Doppler range lowest frequency + #[cfg_attr(feature = "serde", serde(rename(serialize = "cf_min")))] pub cf_min: i32, /// Doppler range highest frequency + #[cfg_attr(feature = "serde", serde(rename(serialize = "cf_max")))] pub cf_max: i32, /// Doppler value of detected peak. Only valid if status is '1' + #[cfg_attr(feature = "serde", serde(rename(serialize = "cf")))] pub cf: i32, /// Codephase of detected peak. Only valid if status is '1' + #[cfg_attr(feature = "serde", serde(rename(serialize = "cp")))] pub cp: u32, } -impl AcqSvProfile { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( AcqSvProfile{ - job_type: _buf.read_u8()?, - status: _buf.read_u8()?, - cn0: _buf.read_u16::()?, - int_time: _buf.read_u8()?, - sid: GnssSignal::parse(_buf)?, - bin_width: _buf.read_u16::()?, - timestamp: _buf.read_u32::()?, - time_spent: _buf.read_u32::()?, - cf_min: _buf.read_i32::()?, - cf_max: _buf.read_i32::()?, - cf: _buf.read_i32::()?, - cp: _buf.read_u32::()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(AcqSvProfile::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(AcqSvProfile::parse(buf)?); +impl WireFormat for AcqSvProfile { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.job_type) + + WireFormat::encoded_len(&self.status) + + WireFormat::encoded_len(&self.cn0) + + WireFormat::encoded_len(&self.int_time) + + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.bin_width) + + WireFormat::encoded_len(&self.timestamp) + + WireFormat::encoded_len(&self.time_spent) + + WireFormat::encoded_len(&self.cf_min) + + WireFormat::encoded_len(&self.cf_max) + + WireFormat::encoded_len(&self.cf) + + WireFormat::encoded_len(&self.cp) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.job_type, buf); + WireFormat::write(&self.status, buf); + WireFormat::write(&self.cn0, buf); + WireFormat::write(&self.int_time, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.bin_width, buf); + WireFormat::write(&self.timestamp, buf); + WireFormat::write(&self.time_spent, buf); + WireFormat::write(&self.cf_min, buf); + WireFormat::write(&self.cf_max, buf); + WireFormat::write(&self.cf, buf); + WireFormat::write(&self.cp, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + AcqSvProfile { + job_type: WireFormat::parse_unchecked(buf), + status: WireFormat::parse_unchecked(buf), + cn0: WireFormat::parse_unchecked(buf), + int_time: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + bin_width: WireFormat::parse_unchecked(buf), + timestamp: WireFormat::parse_unchecked(buf), + time_spent: WireFormat::parse_unchecked(buf), + cf_min: WireFormat::parse_unchecked(buf), + cf_max: WireFormat::parse_unchecked(buf), + cf: WireFormat::parse_unchecked(buf), + cp: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for AcqSvProfile { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.job_type.append_to_sbp_buffer(buf); - self.status.append_to_sbp_buffer(buf); - self.cn0.append_to_sbp_buffer(buf); - self.int_time.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - self.bin_width.append_to_sbp_buffer(buf); - self.timestamp.append_to_sbp_buffer(buf); - self.time_spent.append_to_sbp_buffer(buf); - self.cf_min.append_to_sbp_buffer(buf); - self.cf_max.append_to_sbp_buffer(buf); - self.cf.append_to_sbp_buffer(buf); - self.cp.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.job_type.sbp_size(); - size += self.status.sbp_size(); - size += self.cn0.sbp_size(); - size += self.int_time.sbp_size(); - size += self.sid.sbp_size(); - size += self.bin_width.sbp_size(); - size += self.timestamp.sbp_size(); - size += self.time_spent.sbp_size(); - size += self.cf_min.sbp_size(); - size += self.cf_max.sbp_size(); - size += self.cf.sbp_size(); - size += self.cp.sbp_size(); - size } } @@ -136,106 +128,103 @@ impl crate::serialize::SbpSerialize for AcqSvProfile { /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct AcqSvProfileDep { /// SV search job type (deep, fallback, etc) + #[cfg_attr(feature = "serde", serde(rename(serialize = "job_type")))] pub job_type: u8, /// Acquisition status 1 is Success, 0 is Failure + #[cfg_attr(feature = "serde", serde(rename(serialize = "status")))] pub status: u8, /// CN0 value. Only valid if status is '1' + #[cfg_attr(feature = "serde", serde(rename(serialize = "cn0")))] pub cn0: u16, /// Acquisition integration time + #[cfg_attr(feature = "serde", serde(rename(serialize = "int_time")))] pub int_time: u8, /// GNSS signal for which acquisition was attempted + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignalDep, /// Acq frequency bin width + #[cfg_attr(feature = "serde", serde(rename(serialize = "bin_width")))] pub bin_width: u16, /// Timestamp of the job complete event + #[cfg_attr(feature = "serde", serde(rename(serialize = "timestamp")))] pub timestamp: u32, /// Time spent to search for sid.code + #[cfg_attr(feature = "serde", serde(rename(serialize = "time_spent")))] pub time_spent: u32, /// Doppler range lowest frequency + #[cfg_attr(feature = "serde", serde(rename(serialize = "cf_min")))] pub cf_min: i32, /// Doppler range highest frequency + #[cfg_attr(feature = "serde", serde(rename(serialize = "cf_max")))] pub cf_max: i32, /// Doppler value of detected peak. Only valid if status is '1' + #[cfg_attr(feature = "serde", serde(rename(serialize = "cf")))] pub cf: i32, /// Codephase of detected peak. Only valid if status is '1' + #[cfg_attr(feature = "serde", serde(rename(serialize = "cp")))] pub cp: u32, } -impl AcqSvProfileDep { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( AcqSvProfileDep{ - job_type: _buf.read_u8()?, - status: _buf.read_u8()?, - cn0: _buf.read_u16::()?, - int_time: _buf.read_u8()?, - sid: GnssSignalDep::parse(_buf)?, - bin_width: _buf.read_u16::()?, - timestamp: _buf.read_u32::()?, - time_spent: _buf.read_u32::()?, - cf_min: _buf.read_i32::()?, - cf_max: _buf.read_i32::()?, - cf: _buf.read_i32::()?, - cp: _buf.read_u32::()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(AcqSvProfileDep::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(AcqSvProfileDep::parse(buf)?); +impl WireFormat for AcqSvProfileDep { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.job_type) + + WireFormat::encoded_len(&self.status) + + WireFormat::encoded_len(&self.cn0) + + WireFormat::encoded_len(&self.int_time) + + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.bin_width) + + WireFormat::encoded_len(&self.timestamp) + + WireFormat::encoded_len(&self.time_spent) + + WireFormat::encoded_len(&self.cf_min) + + WireFormat::encoded_len(&self.cf_max) + + WireFormat::encoded_len(&self.cf) + + WireFormat::encoded_len(&self.cp) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.job_type, buf); + WireFormat::write(&self.status, buf); + WireFormat::write(&self.cn0, buf); + WireFormat::write(&self.int_time, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.bin_width, buf); + WireFormat::write(&self.timestamp, buf); + WireFormat::write(&self.time_spent, buf); + WireFormat::write(&self.cf_min, buf); + WireFormat::write(&self.cf_max, buf); + WireFormat::write(&self.cf, buf); + WireFormat::write(&self.cp, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + AcqSvProfileDep { + job_type: WireFormat::parse_unchecked(buf), + status: WireFormat::parse_unchecked(buf), + cn0: WireFormat::parse_unchecked(buf), + int_time: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + bin_width: WireFormat::parse_unchecked(buf), + timestamp: WireFormat::parse_unchecked(buf), + time_spent: WireFormat::parse_unchecked(buf), + cf_min: WireFormat::parse_unchecked(buf), + cf_max: WireFormat::parse_unchecked(buf), + cf: WireFormat::parse_unchecked(buf), + cp: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for AcqSvProfileDep { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.job_type.append_to_sbp_buffer(buf); - self.status.append_to_sbp_buffer(buf); - self.cn0.append_to_sbp_buffer(buf); - self.int_time.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - self.bin_width.append_to_sbp_buffer(buf); - self.timestamp.append_to_sbp_buffer(buf); - self.time_spent.append_to_sbp_buffer(buf); - self.cf_min.append_to_sbp_buffer(buf); - self.cf_max.append_to_sbp_buffer(buf); - self.cf.append_to_sbp_buffer(buf); - self.cp.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.job_type.sbp_size(); - size += self.status.sbp_size(); - size += self.cn0.sbp_size(); - size += self.int_time.sbp_size(); - size += self.sid.sbp_size(); - size += self.bin_width.sbp_size(); - size += self.timestamp.sbp_size(); - size += self.time_spent.sbp_size(); - size += self.cf_min.sbp_size(); - size += self.cf_max.sbp_size(); - size += self.cf.sbp_size(); - size += self.cp.sbp_size(); - size } } @@ -246,92 +235,81 @@ impl crate::serialize::SbpSerialize for AcqSvProfileDep { /// range. It contains the parameters of the point in the acquisition search /// space with the best carrier-to-noise (CN/0) ratio. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgAcqResult { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// CN/0 of best point + #[cfg_attr(feature = "serde", serde(rename(serialize = "cn0")))] pub cn0: f32, /// Code phase of best point + #[cfg_attr(feature = "serde", serde(rename(serialize = "cp")))] pub cp: f32, /// Carrier frequency of best point + #[cfg_attr(feature = "serde", serde(rename(serialize = "cf")))] pub cf: f32, /// GNSS signal for which acquisition was attempted + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, } -impl MsgAcqResult { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgAcqResult{ - sender_id: None, - cn0: _buf.read_f32::()?, - cp: _buf.read_f32::()?, - cf: _buf.read_f32::()?, - sid: GnssSignal::parse(_buf)?, - } ) - } +impl ConcreteMessage for MsgAcqResult { + const MESSAGE_TYPE: u16 = 47; + const MESSAGE_NAME: &'static str = "MSG_ACQ_RESULT"; } -impl super::SBPMessage for MsgAcqResult { - fn get_message_name(&self) -> &'static str { - "MSG_ACQ_RESULT" - } - fn get_message_type(&self) -> u16 { - 47 +impl SbpMessage for MsgAcqResult { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgAcqResult { - const MESSAGE_TYPE: u16 = 47; - const MESSAGE_NAME: &'static str = "MSG_ACQ_RESULT"; } -impl TryFrom for MsgAcqResult { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgAcqResult { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgAcqResult(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgAcqResult(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgAcqResult { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.cn0.append_to_sbp_buffer(buf); - self.cp.append_to_sbp_buffer(buf); - self.cf.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); +impl WireFormat for MsgAcqResult { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.cn0) + + WireFormat::encoded_len(&self.cp) + + WireFormat::encoded_len(&self.cf) + + WireFormat::encoded_len(&self.sid) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.cn0.sbp_size(); - size += self.cp.sbp_size(); - size += self.cf.sbp_size(); - size += self.sid.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.cn0, buf); + WireFormat::write(&self.cp, buf); + WireFormat::write(&self.cf, buf); + WireFormat::write(&self.sid, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgAcqResult { + sender_id: None, + cn0: WireFormat::parse_unchecked(buf), + cp: WireFormat::parse_unchecked(buf), + cf: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + } } } @@ -339,94 +317,83 @@ impl crate::serialize::SbpSerialize for MsgAcqResult { /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgAcqResultDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// SNR of best point. Currently dimensionless, but will have units of dB Hz /// in the revision of this message. + #[cfg_attr(feature = "serde", serde(rename(serialize = "snr")))] pub snr: f32, /// Code phase of best point + #[cfg_attr(feature = "serde", serde(rename(serialize = "cp")))] pub cp: f32, /// Carrier frequency of best point + #[cfg_attr(feature = "serde", serde(rename(serialize = "cf")))] pub cf: f32, /// PRN-1 identifier of the satellite signal for which acquisition was /// attempted + #[cfg_attr(feature = "serde", serde(rename(serialize = "prn")))] pub prn: u8, } -impl MsgAcqResultDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgAcqResultDepA{ - sender_id: None, - snr: _buf.read_f32::()?, - cp: _buf.read_f32::()?, - cf: _buf.read_f32::()?, - prn: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgAcqResultDepA { + const MESSAGE_TYPE: u16 = 21; + const MESSAGE_NAME: &'static str = "MSG_ACQ_RESULT_DEP_A"; } -impl super::SBPMessage for MsgAcqResultDepA { - fn get_message_name(&self) -> &'static str { - "MSG_ACQ_RESULT_DEP_A" - } - fn get_message_type(&self) -> u16 { - 21 +impl SbpMessage for MsgAcqResultDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgAcqResultDepA { - const MESSAGE_TYPE: u16 = 21; - const MESSAGE_NAME: &'static str = "MSG_ACQ_RESULT_DEP_A"; } -impl TryFrom for MsgAcqResultDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgAcqResultDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgAcqResultDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgAcqResultDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgAcqResultDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.snr.append_to_sbp_buffer(buf); - self.cp.append_to_sbp_buffer(buf); - self.cf.append_to_sbp_buffer(buf); - self.prn.append_to_sbp_buffer(buf); +impl WireFormat for MsgAcqResultDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.snr) + + WireFormat::encoded_len(&self.cp) + + WireFormat::encoded_len(&self.cf) + + WireFormat::encoded_len(&self.prn) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.snr.sbp_size(); - size += self.cp.sbp_size(); - size += self.cf.sbp_size(); - size += self.prn.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.snr, buf); + WireFormat::write(&self.cp, buf); + WireFormat::write(&self.cf, buf); + WireFormat::write(&self.prn, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgAcqResultDepA { + sender_id: None, + snr: WireFormat::parse_unchecked(buf), + cp: WireFormat::parse_unchecked(buf), + cf: WireFormat::parse_unchecked(buf), + prn: WireFormat::parse_unchecked(buf), + } } } @@ -434,93 +401,82 @@ impl crate::serialize::SbpSerialize for MsgAcqResultDepA { /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgAcqResultDepB { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// SNR of best point. Currently in arbitrary SNR points, but will be in /// units of dB Hz in a later revision of this message. + #[cfg_attr(feature = "serde", serde(rename(serialize = "snr")))] pub snr: f32, /// Code phase of best point + #[cfg_attr(feature = "serde", serde(rename(serialize = "cp")))] pub cp: f32, /// Carrier frequency of best point + #[cfg_attr(feature = "serde", serde(rename(serialize = "cf")))] pub cf: f32, /// GNSS signal for which acquisition was attempted + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignalDep, } -impl MsgAcqResultDepB { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgAcqResultDepB{ - sender_id: None, - snr: _buf.read_f32::()?, - cp: _buf.read_f32::()?, - cf: _buf.read_f32::()?, - sid: GnssSignalDep::parse(_buf)?, - } ) - } +impl ConcreteMessage for MsgAcqResultDepB { + const MESSAGE_TYPE: u16 = 20; + const MESSAGE_NAME: &'static str = "MSG_ACQ_RESULT_DEP_B"; } -impl super::SBPMessage for MsgAcqResultDepB { - fn get_message_name(&self) -> &'static str { - "MSG_ACQ_RESULT_DEP_B" - } - fn get_message_type(&self) -> u16 { - 20 +impl SbpMessage for MsgAcqResultDepB { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgAcqResultDepB { - const MESSAGE_TYPE: u16 = 20; - const MESSAGE_NAME: &'static str = "MSG_ACQ_RESULT_DEP_B"; } -impl TryFrom for MsgAcqResultDepB { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgAcqResultDepB { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgAcqResultDepB(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgAcqResultDepB(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgAcqResultDepB { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.snr.append_to_sbp_buffer(buf); - self.cp.append_to_sbp_buffer(buf); - self.cf.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); +impl WireFormat for MsgAcqResultDepB { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.snr) + + WireFormat::encoded_len(&self.cp) + + WireFormat::encoded_len(&self.cf) + + WireFormat::encoded_len(&self.sid) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.snr.sbp_size(); - size += self.cp.sbp_size(); - size += self.cf.sbp_size(); - size += self.sid.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.snr, buf); + WireFormat::write(&self.cp, buf); + WireFormat::write(&self.cf, buf); + WireFormat::write(&self.sid, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgAcqResultDepB { + sender_id: None, + snr: WireFormat::parse_unchecked(buf), + cp: WireFormat::parse_unchecked(buf), + cf: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + } } } @@ -528,92 +484,81 @@ impl crate::serialize::SbpSerialize for MsgAcqResultDepB { /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgAcqResultDepC { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// CN/0 of best point + #[cfg_attr(feature = "serde", serde(rename(serialize = "cn0")))] pub cn0: f32, /// Code phase of best point + #[cfg_attr(feature = "serde", serde(rename(serialize = "cp")))] pub cp: f32, /// Carrier frequency of best point + #[cfg_attr(feature = "serde", serde(rename(serialize = "cf")))] pub cf: f32, /// GNSS signal for which acquisition was attempted + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignalDep, } -impl MsgAcqResultDepC { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgAcqResultDepC{ - sender_id: None, - cn0: _buf.read_f32::()?, - cp: _buf.read_f32::()?, - cf: _buf.read_f32::()?, - sid: GnssSignalDep::parse(_buf)?, - } ) - } +impl ConcreteMessage for MsgAcqResultDepC { + const MESSAGE_TYPE: u16 = 31; + const MESSAGE_NAME: &'static str = "MSG_ACQ_RESULT_DEP_C"; } -impl super::SBPMessage for MsgAcqResultDepC { - fn get_message_name(&self) -> &'static str { - "MSG_ACQ_RESULT_DEP_C" - } - fn get_message_type(&self) -> u16 { - 31 +impl SbpMessage for MsgAcqResultDepC { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgAcqResultDepC { - const MESSAGE_TYPE: u16 = 31; - const MESSAGE_NAME: &'static str = "MSG_ACQ_RESULT_DEP_C"; -} -impl TryFrom for MsgAcqResultDepC { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgAcqResultDepC { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgAcqResultDepC(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgAcqResultDepC(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgAcqResultDepC { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.cn0.append_to_sbp_buffer(buf); - self.cp.append_to_sbp_buffer(buf); - self.cf.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); +impl WireFormat for MsgAcqResultDepC { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.cn0) + + WireFormat::encoded_len(&self.cp) + + WireFormat::encoded_len(&self.cf) + + WireFormat::encoded_len(&self.sid) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.cn0.sbp_size(); - size += self.cp.sbp_size(); - size += self.cf.sbp_size(); - size += self.sid.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.cn0, buf); + WireFormat::write(&self.cp, buf); + WireFormat::write(&self.cf, buf); + WireFormat::write(&self.sid, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgAcqResultDepC { + sender_id: None, + cn0: WireFormat::parse_unchecked(buf), + cp: WireFormat::parse_unchecked(buf), + cf: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + } } } @@ -622,77 +567,60 @@ impl crate::serialize::SbpSerialize for MsgAcqResultDepC { /// The message describes all SV profiles during acquisition time. The message /// is used to debug and measure the performance. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgAcqSvProfile { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// SV profiles during acquisition time + #[cfg_attr(feature = "serde", serde(rename(serialize = "acq_sv_profile")))] pub acq_sv_profile: Vec, } -impl MsgAcqSvProfile { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgAcqSvProfile{ - sender_id: None, - acq_sv_profile: AcqSvProfile::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgAcqSvProfile { + const MESSAGE_TYPE: u16 = 46; + const MESSAGE_NAME: &'static str = "MSG_ACQ_SV_PROFILE"; } -impl super::SBPMessage for MsgAcqSvProfile { - fn get_message_name(&self) -> &'static str { - "MSG_ACQ_SV_PROFILE" - } - fn get_message_type(&self) -> u16 { - 46 +impl SbpMessage for MsgAcqSvProfile { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgAcqSvProfile { - const MESSAGE_TYPE: u16 = 46; - const MESSAGE_NAME: &'static str = "MSG_ACQ_SV_PROFILE"; -} -impl TryFrom for MsgAcqSvProfile { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgAcqSvProfile { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgAcqSvProfile(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgAcqSvProfile(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgAcqSvProfile { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.acq_sv_profile.append_to_sbp_buffer(buf); +impl WireFormat for MsgAcqSvProfile { + const MIN_ENCODED_LEN: usize = as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.acq_sv_profile) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.acq_sv_profile.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.acq_sv_profile, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgAcqSvProfile { + sender_id: None, + acq_sv_profile: WireFormat::parse_unchecked(buf), + } } } @@ -700,76 +628,59 @@ impl crate::serialize::SbpSerialize for MsgAcqSvProfile { /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgAcqSvProfileDep { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// SV profiles during acquisition time + #[cfg_attr(feature = "serde", serde(rename(serialize = "acq_sv_profile")))] pub acq_sv_profile: Vec, } -impl MsgAcqSvProfileDep { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgAcqSvProfileDep{ - sender_id: None, - acq_sv_profile: AcqSvProfileDep::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgAcqSvProfileDep { + const MESSAGE_TYPE: u16 = 30; + const MESSAGE_NAME: &'static str = "MSG_ACQ_SV_PROFILE_DEP"; } -impl super::SBPMessage for MsgAcqSvProfileDep { - fn get_message_name(&self) -> &'static str { - "MSG_ACQ_SV_PROFILE_DEP" - } - fn get_message_type(&self) -> u16 { - 30 +impl SbpMessage for MsgAcqSvProfileDep { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgAcqSvProfileDep { - const MESSAGE_TYPE: u16 = 30; - const MESSAGE_NAME: &'static str = "MSG_ACQ_SV_PROFILE_DEP"; -} -impl TryFrom for MsgAcqSvProfileDep { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgAcqSvProfileDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgAcqSvProfileDep(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgAcqSvProfileDep(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgAcqSvProfileDep { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.acq_sv_profile.append_to_sbp_buffer(buf); +impl WireFormat for MsgAcqSvProfileDep { + const MIN_ENCODED_LEN: usize = as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.acq_sv_profile) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.acq_sv_profile.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.acq_sv_profile, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgAcqSvProfileDep { + sender_id: None, + acq_sv_profile: WireFormat::parse_unchecked(buf), + } } } diff --git a/rust/sbp/src/messages/bootload.rs b/rust/sbp/src/messages/bootload.rs index c1d17b5c37..84d1fd0c6b 100644 --- a/rust/sbp/src/messages/bootload.rs +++ b/rust/sbp/src/messages/bootload.rs @@ -18,92 +18,66 @@ //! Note that some of these messages share the same message type ID for both //! the host request and the device response. -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; +use super::lib::*; /// Deprecated /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgBootloaderHandshakeDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Version number string (not NULL terminated) + #[cfg_attr(feature = "serde", serde(rename(serialize = "handshake")))] pub handshake: Vec, } -impl MsgBootloaderHandshakeDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgBootloaderHandshakeDepA{ - sender_id: None, - handshake: crate::parser::read_u8_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgBootloaderHandshakeDepA { + const MESSAGE_TYPE: u16 = 176; + const MESSAGE_NAME: &'static str = "MSG_BOOTLOADER_HANDSHAKE_DEP_A"; } -impl super::SBPMessage for MsgBootloaderHandshakeDepA { - fn get_message_name(&self) -> &'static str { - "MSG_BOOTLOADER_HANDSHAKE_DEP_A" - } - fn get_message_type(&self) -> u16 { - 176 +impl SbpMessage for MsgBootloaderHandshakeDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgBootloaderHandshakeDepA { - const MESSAGE_TYPE: u16 = 176; - const MESSAGE_NAME: &'static str = "MSG_BOOTLOADER_HANDSHAKE_DEP_A"; -} -impl TryFrom for MsgBootloaderHandshakeDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgBootloaderHandshakeDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgBootloaderHandshakeDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgBootloaderHandshakeDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgBootloaderHandshakeDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.handshake.append_to_sbp_buffer(buf); +impl WireFormat for MsgBootloaderHandshakeDepA { + const MIN_ENCODED_LEN: usize = as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.handshake) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.handshake.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.handshake, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgBootloaderHandshakeDepA { + sender_id: None, + handshake: WireFormat::parse_unchecked(buf), + } } } @@ -113,71 +87,53 @@ impl crate::serialize::SbpSerialize for MsgBootloaderHandshakeDepA { /// between the device bootloader and the host. The response from the device /// is MSG_BOOTLOADER_HANDSHAKE_RESP. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgBootloaderHandshakeReq { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, } -impl MsgBootloaderHandshakeReq { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgBootloaderHandshakeReq{ - sender_id: None, - } ) - } +impl ConcreteMessage for MsgBootloaderHandshakeReq { + const MESSAGE_TYPE: u16 = 179; + const MESSAGE_NAME: &'static str = "MSG_BOOTLOADER_HANDSHAKE_REQ"; } -impl super::SBPMessage for MsgBootloaderHandshakeReq { - fn get_message_name(&self) -> &'static str { - "MSG_BOOTLOADER_HANDSHAKE_REQ" - } - fn get_message_type(&self) -> u16 { - 179 +impl SbpMessage for MsgBootloaderHandshakeReq { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgBootloaderHandshakeReq { - const MESSAGE_TYPE: u16 = 179; - const MESSAGE_NAME: &'static str = "MSG_BOOTLOADER_HANDSHAKE_REQ"; } -impl TryFrom for MsgBootloaderHandshakeReq { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgBootloaderHandshakeReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgBootloaderHandshakeReq(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgBootloaderHandshakeReq(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgBootloaderHandshakeReq { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) {} - - fn sbp_size(&self) -> usize { +impl WireFormat for MsgBootloaderHandshakeReq { + const MIN_ENCODED_LEN: usize = 0; + fn encoded_len(&self) -> usize { 0 } + fn write(&self, _buf: &mut bytes::BytesMut) {} + fn parse_unchecked(_buf: &mut bytes::BytesMut) -> Self { + MsgBootloaderHandshakeReq { sender_id: None } + } } /// Bootloading handshake response (host <= device) @@ -187,82 +143,66 @@ impl crate::serialize::SbpSerialize for MsgBootloaderHandshakeReq { /// MSG_BOOTLOADER_HANDSHAKE_REQ. The payload contains the bootloader version /// number and the SBP protocol version number. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgBootloaderHandshakeResp { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Bootloader flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u32, /// Bootloader version number - pub version: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "version")))] + pub version: SbpString, Unterminated>, } -impl MsgBootloaderHandshakeResp { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgBootloaderHandshakeResp{ - sender_id: None, - flags: _buf.read_u32::()?, - version: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgBootloaderHandshakeResp { + const MESSAGE_TYPE: u16 = 180; + const MESSAGE_NAME: &'static str = "MSG_BOOTLOADER_HANDSHAKE_RESP"; } -impl super::SBPMessage for MsgBootloaderHandshakeResp { - fn get_message_name(&self) -> &'static str { - "MSG_BOOTLOADER_HANDSHAKE_RESP" - } - fn get_message_type(&self) -> u16 { - 180 +impl SbpMessage for MsgBootloaderHandshakeResp { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgBootloaderHandshakeResp { - const MESSAGE_TYPE: u16 = 180; - const MESSAGE_NAME: &'static str = "MSG_BOOTLOADER_HANDSHAKE_RESP"; } -impl TryFrom for MsgBootloaderHandshakeResp { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgBootloaderHandshakeResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgBootloaderHandshakeResp(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgBootloaderHandshakeResp(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgBootloaderHandshakeResp { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.flags.append_to_sbp_buffer(buf); - self.version.append_to_sbp_buffer(buf); +impl WireFormat for MsgBootloaderHandshakeResp { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + , Unterminated> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.flags) + WireFormat::encoded_len(&self.version) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.flags.sbp_size(); - size += self.version.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.flags, buf); + WireFormat::write(&self.version, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgBootloaderHandshakeResp { + sender_id: None, + flags: WireFormat::parse_unchecked(buf), + version: WireFormat::parse_unchecked(buf), + } } } @@ -270,77 +210,60 @@ impl crate::serialize::SbpSerialize for MsgBootloaderHandshakeResp { /// /// The host initiates the bootloader to jump to the application. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgBootloaderJumpToApp { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Ignored by the device + #[cfg_attr(feature = "serde", serde(rename(serialize = "jump")))] pub jump: u8, } -impl MsgBootloaderJumpToApp { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgBootloaderJumpToApp{ - sender_id: None, - jump: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgBootloaderJumpToApp { + const MESSAGE_TYPE: u16 = 177; + const MESSAGE_NAME: &'static str = "MSG_BOOTLOADER_JUMP_TO_APP"; } -impl super::SBPMessage for MsgBootloaderJumpToApp { - fn get_message_name(&self) -> &'static str { - "MSG_BOOTLOADER_JUMP_TO_APP" - } - fn get_message_type(&self) -> u16 { - 177 +impl SbpMessage for MsgBootloaderJumpToApp { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgBootloaderJumpToApp { - const MESSAGE_TYPE: u16 = 177; - const MESSAGE_NAME: &'static str = "MSG_BOOTLOADER_JUMP_TO_APP"; } -impl TryFrom for MsgBootloaderJumpToApp { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgBootloaderJumpToApp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgBootloaderJumpToApp(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgBootloaderJumpToApp(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgBootloaderJumpToApp { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.jump.append_to_sbp_buffer(buf); +impl WireFormat for MsgBootloaderJumpToApp { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.jump) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.jump.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.jump, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgBootloaderJumpToApp { + sender_id: None, + jump: WireFormat::parse_unchecked(buf), + } } } @@ -353,71 +276,53 @@ impl crate::serialize::SbpSerialize for MsgBootloaderJumpToApp { /// that this ID is tied to the FPGA, and not related to the Piksi's serial /// number. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgNapDeviceDnaReq { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, } -impl MsgNapDeviceDnaReq { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgNapDeviceDnaReq{ - sender_id: None, - } ) - } +impl ConcreteMessage for MsgNapDeviceDnaReq { + const MESSAGE_TYPE: u16 = 222; + const MESSAGE_NAME: &'static str = "MSG_NAP_DEVICE_DNA_REQ"; } -impl super::SBPMessage for MsgNapDeviceDnaReq { - fn get_message_name(&self) -> &'static str { - "MSG_NAP_DEVICE_DNA_REQ" - } - fn get_message_type(&self) -> u16 { - 222 +impl SbpMessage for MsgNapDeviceDnaReq { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgNapDeviceDnaReq { - const MESSAGE_TYPE: u16 = 222; - const MESSAGE_NAME: &'static str = "MSG_NAP_DEVICE_DNA_REQ"; } -impl TryFrom for MsgNapDeviceDnaReq { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgNapDeviceDnaReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgNapDeviceDnaReq(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgNapDeviceDnaReq(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgNapDeviceDnaReq { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) {} - - fn sbp_size(&self) -> usize { +impl WireFormat for MsgNapDeviceDnaReq { + const MIN_ENCODED_LEN: usize = 0; + fn encoded_len(&self) -> usize { 0 } + fn write(&self, _buf: &mut bytes::BytesMut) {} + fn parse_unchecked(_buf: &mut bytes::BytesMut) -> Self { + MsgNapDeviceDnaReq { sender_id: None } + } } /// Read FPGA device ID over UART response (host <= device) @@ -429,76 +334,59 @@ impl crate::serialize::SbpSerialize for MsgNapDeviceDnaReq { /// that this ID is tied to the FPGA, and not related to the Piksi's serial /// number. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgNapDeviceDnaResp { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// 57-bit SwiftNAP FPGA Device ID. Remaining bits are padded on the right. - pub dna: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "dna")))] + pub dna: [u8; 8], } -impl MsgNapDeviceDnaResp { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgNapDeviceDnaResp{ - sender_id: None, - dna: crate::parser::read_u8_array_limit(_buf, 8)?, - } ) - } +impl ConcreteMessage for MsgNapDeviceDnaResp { + const MESSAGE_TYPE: u16 = 221; + const MESSAGE_NAME: &'static str = "MSG_NAP_DEVICE_DNA_RESP"; } -impl super::SBPMessage for MsgNapDeviceDnaResp { - fn get_message_name(&self) -> &'static str { - "MSG_NAP_DEVICE_DNA_RESP" - } - fn get_message_type(&self) -> u16 { - 221 +impl SbpMessage for MsgNapDeviceDnaResp { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgNapDeviceDnaResp { - const MESSAGE_TYPE: u16 = 221; - const MESSAGE_NAME: &'static str = "MSG_NAP_DEVICE_DNA_RESP"; -} -impl TryFrom for MsgNapDeviceDnaResp { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgNapDeviceDnaResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgNapDeviceDnaResp(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgNapDeviceDnaResp(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgNapDeviceDnaResp { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.dna.append_to_sbp_buffer(buf); +impl WireFormat for MsgNapDeviceDnaResp { + const MIN_ENCODED_LEN: usize = <[u8; 8] as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.dna) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.dna.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.dna, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgNapDeviceDnaResp { + sender_id: None, + dna: WireFormat::parse_unchecked(buf), + } } } diff --git a/rust/sbp/src/messages/ext_events.rs b/rust/sbp/src/messages/ext_events.rs index 2da912c55e..bf572f8b24 100644 --- a/rust/sbp/src/messages/ext_events.rs +++ b/rust/sbp/src/messages/ext_events.rs @@ -15,129 +15,109 @@ //! Messages reporting accurately-timestamped external events, e.g. camera //! shutter time. -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; +use super::lib::*; /// Reports timestamped external pin event /// /// Reports detection of an external event, the GPS time it occurred, which /// pin it was and whether it was rising or falling. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgExtEvent { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS week number + #[cfg_attr(feature = "serde", serde(rename(serialize = "wn")))] pub wn: u16, /// GPS time of week rounded to the nearest millisecond + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Nanosecond residual of millisecond-rounded TOW (ranges from -500000 to /// 500000) + #[cfg_attr(feature = "serde", serde(rename(serialize = "ns_residual")))] pub ns_residual: i32, /// Flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, /// Pin number. 0..9 = DEBUG0..9. + #[cfg_attr(feature = "serde", serde(rename(serialize = "pin")))] pub pin: u8, } -impl MsgExtEvent { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgExtEvent{ - sender_id: None, - wn: _buf.read_u16::()?, - tow: _buf.read_u32::()?, - ns_residual: _buf.read_i32::()?, - flags: _buf.read_u8()?, - pin: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgExtEvent { + const MESSAGE_TYPE: u16 = 257; + const MESSAGE_NAME: &'static str = "MSG_EXT_EVENT"; } -impl super::SBPMessage for MsgExtEvent { - fn get_message_name(&self) -> &'static str { - "MSG_EXT_EVENT" - } - fn get_message_type(&self) -> u16 { - 257 +impl SbpMessage for MsgExtEvent { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let wn = match i16::try_from(self.wn) { + #[allow(clippy::useless_conversion)] + let wn: i16 = match self.wn.try_into() { Ok(wn) => wn, Err(e) => return Some(Err(e.into())), }; - let gps_time = match crate::time::GpsTime::new(wn, tow_s) { + let gps_time = match time::GpsTime::new(wn, tow_s) { Ok(gps_time) => gps_time, Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgExtEvent { - const MESSAGE_TYPE: u16 = 257; - const MESSAGE_NAME: &'static str = "MSG_EXT_EVENT"; -} -impl TryFrom for MsgExtEvent { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgExtEvent { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgExtEvent(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgExtEvent(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgExtEvent { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.wn.append_to_sbp_buffer(buf); - self.tow.append_to_sbp_buffer(buf); - self.ns_residual.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - self.pin.append_to_sbp_buffer(buf); +impl WireFormat for MsgExtEvent { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.wn) + + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.ns_residual) + + WireFormat::encoded_len(&self.flags) + + WireFormat::encoded_len(&self.pin) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.wn.sbp_size(); - size += self.tow.sbp_size(); - size += self.ns_residual.sbp_size(); - size += self.flags.sbp_size(); - size += self.pin.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.wn, buf); + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.ns_residual, buf); + WireFormat::write(&self.flags, buf); + WireFormat::write(&self.pin, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgExtEvent { + sender_id: None, + wn: WireFormat::parse_unchecked(buf), + tow: WireFormat::parse_unchecked(buf), + ns_residual: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + pin: WireFormat::parse_unchecked(buf), + } } } diff --git a/rust/sbp/src/messages/file_io.rs b/rust/sbp/src/messages/file_io.rs index 5810a0397c..5161201b7b 100644 --- a/rust/sbp/src/messages/file_io.rs +++ b/rust/sbp/src/messages/file_io.rs @@ -21,16 +21,7 @@ //! Note that some of these messages share the same message type ID for both //! the host request and the device response. -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; +use super::lib::*; /// Request advice on the optimal configuration for FileIO /// @@ -39,77 +30,60 @@ use crate::SbpString; /// window of FileIO data that can be in-flight during read or write /// operations. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgFileioConfigReq { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Advice sequence number + #[cfg_attr(feature = "serde", serde(rename(serialize = "sequence")))] pub sequence: u32, } -impl MsgFileioConfigReq { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgFileioConfigReq{ - sender_id: None, - sequence: _buf.read_u32::()?, - } ) - } +impl ConcreteMessage for MsgFileioConfigReq { + const MESSAGE_TYPE: u16 = 4097; + const MESSAGE_NAME: &'static str = "MSG_FILEIO_CONFIG_REQ"; } -impl super::SBPMessage for MsgFileioConfigReq { - fn get_message_name(&self) -> &'static str { - "MSG_FILEIO_CONFIG_REQ" - } - fn get_message_type(&self) -> u16 { - 4097 +impl SbpMessage for MsgFileioConfigReq { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgFileioConfigReq { - const MESSAGE_TYPE: u16 = 4097; - const MESSAGE_NAME: &'static str = "MSG_FILEIO_CONFIG_REQ"; } -impl TryFrom for MsgFileioConfigReq { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgFileioConfigReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgFileioConfigReq(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgFileioConfigReq(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgFileioConfigReq { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sequence.append_to_sbp_buffer(buf); +impl WireFormat for MsgFileioConfigReq { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sequence) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sequence.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sequence, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgFileioConfigReq { + sender_id: None, + sequence: WireFormat::parse_unchecked(buf), + } } } @@ -121,92 +95,81 @@ impl crate::serialize::SbpSerialize for MsgFileioConfigReq { /// window of FileIO data that can be in-flight during read or write /// operations. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgFileioConfigResp { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Advice sequence number + #[cfg_attr(feature = "serde", serde(rename(serialize = "sequence")))] pub sequence: u32, /// The number of SBP packets in the data in-flight window + #[cfg_attr(feature = "serde", serde(rename(serialize = "window_size")))] pub window_size: u32, /// The number of SBP packets sent in one PDU + #[cfg_attr(feature = "serde", serde(rename(serialize = "batch_size")))] pub batch_size: u32, /// The version of FileIO that is supported + #[cfg_attr(feature = "serde", serde(rename(serialize = "fileio_version")))] pub fileio_version: u32, } -impl MsgFileioConfigResp { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgFileioConfigResp{ - sender_id: None, - sequence: _buf.read_u32::()?, - window_size: _buf.read_u32::()?, - batch_size: _buf.read_u32::()?, - fileio_version: _buf.read_u32::()?, - } ) - } +impl ConcreteMessage for MsgFileioConfigResp { + const MESSAGE_TYPE: u16 = 4098; + const MESSAGE_NAME: &'static str = "MSG_FILEIO_CONFIG_RESP"; } -impl super::SBPMessage for MsgFileioConfigResp { - fn get_message_name(&self) -> &'static str { - "MSG_FILEIO_CONFIG_RESP" - } - fn get_message_type(&self) -> u16 { - 4098 +impl SbpMessage for MsgFileioConfigResp { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgFileioConfigResp { - const MESSAGE_TYPE: u16 = 4098; - const MESSAGE_NAME: &'static str = "MSG_FILEIO_CONFIG_RESP"; -} -impl TryFrom for MsgFileioConfigResp { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgFileioConfigResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgFileioConfigResp(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgFileioConfigResp(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgFileioConfigResp { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sequence.append_to_sbp_buffer(buf); - self.window_size.append_to_sbp_buffer(buf); - self.batch_size.append_to_sbp_buffer(buf); - self.fileio_version.append_to_sbp_buffer(buf); +impl WireFormat for MsgFileioConfigResp { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sequence) + + WireFormat::encoded_len(&self.window_size) + + WireFormat::encoded_len(&self.batch_size) + + WireFormat::encoded_len(&self.fileio_version) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sequence.sbp_size(); - size += self.window_size.sbp_size(); - size += self.batch_size.sbp_size(); - size += self.fileio_version.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sequence, buf); + WireFormat::write(&self.window_size, buf); + WireFormat::write(&self.batch_size, buf); + WireFormat::write(&self.fileio_version, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgFileioConfigResp { + sender_id: None, + sequence: WireFormat::parse_unchecked(buf), + window_size: WireFormat::parse_unchecked(buf), + batch_size: WireFormat::parse_unchecked(buf), + fileio_version: WireFormat::parse_unchecked(buf), + } } } @@ -222,87 +185,74 @@ impl crate::serialize::SbpSerialize for MsgFileioConfigResp { /// device will only respond to this message when it is received from sender /// ID 0x42. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgFileioReadDirReq { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Read sequence number + #[cfg_attr(feature = "serde", serde(rename(serialize = "sequence")))] pub sequence: u32, /// The offset to skip the first n elements of the file list + #[cfg_attr(feature = "serde", serde(rename(serialize = "offset")))] pub offset: u32, /// Name of the directory to list - pub dirname: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "dirname")))] + pub dirname: SbpString, NullTerminated>, } -impl MsgFileioReadDirReq { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgFileioReadDirReq{ - sender_id: None, - sequence: _buf.read_u32::()?, - offset: _buf.read_u32::()?, - dirname: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgFileioReadDirReq { + const MESSAGE_TYPE: u16 = 169; + const MESSAGE_NAME: &'static str = "MSG_FILEIO_READ_DIR_REQ"; } -impl super::SBPMessage for MsgFileioReadDirReq { - fn get_message_name(&self) -> &'static str { - "MSG_FILEIO_READ_DIR_REQ" - } - fn get_message_type(&self) -> u16 { - 169 +impl SbpMessage for MsgFileioReadDirReq { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgFileioReadDirReq { - const MESSAGE_TYPE: u16 = 169; - const MESSAGE_NAME: &'static str = "MSG_FILEIO_READ_DIR_REQ"; } -impl TryFrom for MsgFileioReadDirReq { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgFileioReadDirReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgFileioReadDirReq(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgFileioReadDirReq(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgFileioReadDirReq { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sequence.append_to_sbp_buffer(buf); - self.offset.append_to_sbp_buffer(buf); - self.dirname.append_to_sbp_buffer(buf); +impl WireFormat for MsgFileioReadDirReq { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + , NullTerminated> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sequence) + + WireFormat::encoded_len(&self.offset) + + WireFormat::encoded_len(&self.dirname) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sequence.sbp_size(); - size += self.offset.sbp_size(); - size += self.dirname.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sequence, buf); + WireFormat::write(&self.offset, buf); + WireFormat::write(&self.dirname, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgFileioReadDirReq { + sender_id: None, + sequence: WireFormat::parse_unchecked(buf), + offset: WireFormat::parse_unchecked(buf), + dirname: WireFormat::parse_unchecked(buf), + } } } @@ -314,82 +264,66 @@ impl crate::serialize::SbpSerialize for MsgFileioReadDirReq { /// the end of the list is identified by an packet with no entries. The /// sequence number in the response is preserved from the request. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgFileioReadDirResp { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Read sequence number + #[cfg_attr(feature = "serde", serde(rename(serialize = "sequence")))] pub sequence: u32, /// Contents of read directory + #[cfg_attr(feature = "serde", serde(rename(serialize = "contents")))] pub contents: Vec, } -impl MsgFileioReadDirResp { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgFileioReadDirResp{ - sender_id: None, - sequence: _buf.read_u32::()?, - contents: crate::parser::read_u8_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgFileioReadDirResp { + const MESSAGE_TYPE: u16 = 170; + const MESSAGE_NAME: &'static str = "MSG_FILEIO_READ_DIR_RESP"; } -impl super::SBPMessage for MsgFileioReadDirResp { - fn get_message_name(&self) -> &'static str { - "MSG_FILEIO_READ_DIR_RESP" - } - fn get_message_type(&self) -> u16 { - 170 +impl SbpMessage for MsgFileioReadDirResp { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgFileioReadDirResp { - const MESSAGE_TYPE: u16 = 170; - const MESSAGE_NAME: &'static str = "MSG_FILEIO_READ_DIR_RESP"; -} -impl TryFrom for MsgFileioReadDirResp { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgFileioReadDirResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgFileioReadDirResp(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgFileioReadDirResp(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgFileioReadDirResp { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sequence.append_to_sbp_buffer(buf); - self.contents.append_to_sbp_buffer(buf); +impl WireFormat for MsgFileioReadDirResp { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sequence) + WireFormat::encoded_len(&self.contents) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sequence.sbp_size(); - size += self.contents.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sequence, buf); + WireFormat::write(&self.contents, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgFileioReadDirResp { + sender_id: None, + sequence: WireFormat::parse_unchecked(buf), + contents: WireFormat::parse_unchecked(buf), + } } } @@ -403,92 +337,81 @@ impl crate::serialize::SbpSerialize for MsgFileioReadDirResp { /// print "Invalid fileio read message". A device will only respond to this /// message when it is received from sender ID 0x42. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgFileioReadReq { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Read sequence number + #[cfg_attr(feature = "serde", serde(rename(serialize = "sequence")))] pub sequence: u32, /// File offset + #[cfg_attr(feature = "serde", serde(rename(serialize = "offset")))] pub offset: u32, /// Chunk size to read + #[cfg_attr(feature = "serde", serde(rename(serialize = "chunk_size")))] pub chunk_size: u8, /// Name of the file to read from - pub filename: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "filename")))] + pub filename: SbpString, NullTerminated>, } -impl MsgFileioReadReq { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgFileioReadReq{ - sender_id: None, - sequence: _buf.read_u32::()?, - offset: _buf.read_u32::()?, - chunk_size: _buf.read_u8()?, - filename: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgFileioReadReq { + const MESSAGE_TYPE: u16 = 168; + const MESSAGE_NAME: &'static str = "MSG_FILEIO_READ_REQ"; } -impl super::SBPMessage for MsgFileioReadReq { - fn get_message_name(&self) -> &'static str { - "MSG_FILEIO_READ_REQ" - } - fn get_message_type(&self) -> u16 { - 168 +impl SbpMessage for MsgFileioReadReq { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgFileioReadReq { - const MESSAGE_TYPE: u16 = 168; - const MESSAGE_NAME: &'static str = "MSG_FILEIO_READ_REQ"; } -impl TryFrom for MsgFileioReadReq { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgFileioReadReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgFileioReadReq(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgFileioReadReq(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgFileioReadReq { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sequence.append_to_sbp_buffer(buf); - self.offset.append_to_sbp_buffer(buf); - self.chunk_size.append_to_sbp_buffer(buf); - self.filename.append_to_sbp_buffer(buf); +impl WireFormat for MsgFileioReadReq { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + , NullTerminated> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sequence) + + WireFormat::encoded_len(&self.offset) + + WireFormat::encoded_len(&self.chunk_size) + + WireFormat::encoded_len(&self.filename) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sequence.sbp_size(); - size += self.offset.sbp_size(); - size += self.chunk_size.sbp_size(); - size += self.filename.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sequence, buf); + WireFormat::write(&self.offset, buf); + WireFormat::write(&self.chunk_size, buf); + WireFormat::write(&self.filename, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgFileioReadReq { + sender_id: None, + sequence: WireFormat::parse_unchecked(buf), + offset: WireFormat::parse_unchecked(buf), + chunk_size: WireFormat::parse_unchecked(buf), + filename: WireFormat::parse_unchecked(buf), + } } } @@ -499,82 +422,66 @@ impl crate::serialize::SbpSerialize for MsgFileioReadReq { /// message length field indicates how many bytes were successfully read. The /// sequence number in the response is preserved from the request. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgFileioReadResp { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Read sequence number + #[cfg_attr(feature = "serde", serde(rename(serialize = "sequence")))] pub sequence: u32, /// Contents of read file + #[cfg_attr(feature = "serde", serde(rename(serialize = "contents")))] pub contents: Vec, } -impl MsgFileioReadResp { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgFileioReadResp{ - sender_id: None, - sequence: _buf.read_u32::()?, - contents: crate::parser::read_u8_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgFileioReadResp { + const MESSAGE_TYPE: u16 = 163; + const MESSAGE_NAME: &'static str = "MSG_FILEIO_READ_RESP"; } -impl super::SBPMessage for MsgFileioReadResp { - fn get_message_name(&self) -> &'static str { - "MSG_FILEIO_READ_RESP" - } - fn get_message_type(&self) -> u16 { - 163 +impl SbpMessage for MsgFileioReadResp { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgFileioReadResp { - const MESSAGE_TYPE: u16 = 163; - const MESSAGE_NAME: &'static str = "MSG_FILEIO_READ_RESP"; -} -impl TryFrom for MsgFileioReadResp { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgFileioReadResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgFileioReadResp(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgFileioReadResp(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgFileioReadResp { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sequence.append_to_sbp_buffer(buf); - self.contents.append_to_sbp_buffer(buf); +impl WireFormat for MsgFileioReadResp { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sequence) + WireFormat::encoded_len(&self.contents) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sequence.sbp_size(); - size += self.contents.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sequence, buf); + WireFormat::write(&self.contents, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgFileioReadResp { + sender_id: None, + sequence: WireFormat::parse_unchecked(buf), + contents: WireFormat::parse_unchecked(buf), + } } } @@ -585,77 +492,61 @@ impl crate::serialize::SbpSerialize for MsgFileioReadResp { /// fileio remove message". A device will only process this message when it is /// received from sender ID 0x42. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgFileioRemove { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Name of the file to delete - pub filename: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "filename")))] + pub filename: SbpString, NullTerminated>, } -impl MsgFileioRemove { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgFileioRemove{ - sender_id: None, - filename: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgFileioRemove { + const MESSAGE_TYPE: u16 = 172; + const MESSAGE_NAME: &'static str = "MSG_FILEIO_REMOVE"; } -impl super::SBPMessage for MsgFileioRemove { - fn get_message_name(&self) -> &'static str { - "MSG_FILEIO_REMOVE" - } - fn get_message_type(&self) -> u16 { - 172 +impl SbpMessage for MsgFileioRemove { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgFileioRemove { - const MESSAGE_TYPE: u16 = 172; - const MESSAGE_NAME: &'static str = "MSG_FILEIO_REMOVE"; } -impl TryFrom for MsgFileioRemove { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgFileioRemove { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgFileioRemove(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgFileioRemove(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgFileioRemove { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.filename.append_to_sbp_buffer(buf); +impl WireFormat for MsgFileioRemove { + const MIN_ENCODED_LEN: usize = + , NullTerminated> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.filename) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.filename.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.filename, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgFileioRemove { + sender_id: None, + filename: WireFormat::parse_unchecked(buf), + } } } @@ -669,92 +560,81 @@ impl crate::serialize::SbpSerialize for MsgFileioRemove { /// fileio write message". A device will only process this message when it is /// received from sender ID 0x42. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgFileioWriteReq { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Write sequence number + #[cfg_attr(feature = "serde", serde(rename(serialize = "sequence")))] pub sequence: u32, /// Offset into the file at which to start writing in bytes + #[cfg_attr(feature = "serde", serde(rename(serialize = "offset")))] pub offset: u32, /// Name of the file to write to - pub filename: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "filename")))] + pub filename: SbpString, NullTerminated>, /// Variable-length array of data to write + #[cfg_attr(feature = "serde", serde(rename(serialize = "data")))] pub data: Vec, } -impl MsgFileioWriteReq { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgFileioWriteReq{ - sender_id: None, - sequence: _buf.read_u32::()?, - offset: _buf.read_u32::()?, - filename: crate::parser::read_string(_buf)?, - data: crate::parser::read_u8_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgFileioWriteReq { + const MESSAGE_TYPE: u16 = 173; + const MESSAGE_NAME: &'static str = "MSG_FILEIO_WRITE_REQ"; } -impl super::SBPMessage for MsgFileioWriteReq { - fn get_message_name(&self) -> &'static str { - "MSG_FILEIO_WRITE_REQ" - } - fn get_message_type(&self) -> u16 { - 173 +impl SbpMessage for MsgFileioWriteReq { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgFileioWriteReq { - const MESSAGE_TYPE: u16 = 173; - const MESSAGE_NAME: &'static str = "MSG_FILEIO_WRITE_REQ"; -} -impl TryFrom for MsgFileioWriteReq { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgFileioWriteReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgFileioWriteReq(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgFileioWriteReq(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgFileioWriteReq { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sequence.append_to_sbp_buffer(buf); - self.offset.append_to_sbp_buffer(buf); - self.filename.append_to_sbp_buffer(buf); - self.data.append_to_sbp_buffer(buf); +impl WireFormat for MsgFileioWriteReq { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + , NullTerminated> as WireFormat>::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sequence) + + WireFormat::encoded_len(&self.offset) + + WireFormat::encoded_len(&self.filename) + + WireFormat::encoded_len(&self.data) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sequence.sbp_size(); - size += self.offset.sbp_size(); - size += self.filename.sbp_size(); - size += self.data.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sequence, buf); + WireFormat::write(&self.offset, buf); + WireFormat::write(&self.filename, buf); + WireFormat::write(&self.data, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgFileioWriteReq { + sender_id: None, + sequence: WireFormat::parse_unchecked(buf), + offset: WireFormat::parse_unchecked(buf), + filename: WireFormat::parse_unchecked(buf), + data: WireFormat::parse_unchecked(buf), + } } } @@ -765,76 +645,59 @@ impl crate::serialize::SbpSerialize for MsgFileioWriteReq { /// MSG_FILEIO_WRITE_REQ message to check integrity of the write. The sequence /// number in the response is preserved from the request. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgFileioWriteResp { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Write sequence number + #[cfg_attr(feature = "serde", serde(rename(serialize = "sequence")))] pub sequence: u32, } -impl MsgFileioWriteResp { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgFileioWriteResp{ - sender_id: None, - sequence: _buf.read_u32::()?, - } ) - } +impl ConcreteMessage for MsgFileioWriteResp { + const MESSAGE_TYPE: u16 = 171; + const MESSAGE_NAME: &'static str = "MSG_FILEIO_WRITE_RESP"; } -impl super::SBPMessage for MsgFileioWriteResp { - fn get_message_name(&self) -> &'static str { - "MSG_FILEIO_WRITE_RESP" - } - fn get_message_type(&self) -> u16 { - 171 +impl SbpMessage for MsgFileioWriteResp { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgFileioWriteResp { - const MESSAGE_TYPE: u16 = 171; - const MESSAGE_NAME: &'static str = "MSG_FILEIO_WRITE_RESP"; } -impl TryFrom for MsgFileioWriteResp { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgFileioWriteResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgFileioWriteResp(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgFileioWriteResp(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgFileioWriteResp { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sequence.append_to_sbp_buffer(buf); +impl WireFormat for MsgFileioWriteResp { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sequence) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sequence.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sequence, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgFileioWriteResp { + sender_id: None, + sequence: WireFormat::parse_unchecked(buf), + } } } diff --git a/rust/sbp/src/messages/flash.rs b/rust/sbp/src/messages/flash.rs index 3efac527fa..ec09d4881c 100644 --- a/rust/sbp/src/messages/flash.rs +++ b/rust/sbp/src/messages/flash.rs @@ -17,16 +17,7 @@ //! Navigation devices: the STM32 flash and the M25Pxx FPGA configuration //! flash from Piksi 2.3.1. This module does not apply to Piksi Multi. -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; +use super::lib::*; /// Flash response message (host <= device) /// @@ -35,77 +26,60 @@ use crate::SbpString; /// messages, such as MSG_FLASH_READ_REQ, or MSG_FLASH_PROGRAM, may return /// this message on failure. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgFlashDone { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Response flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "response")))] pub response: u8, } -impl MsgFlashDone { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgFlashDone{ - sender_id: None, - response: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgFlashDone { + const MESSAGE_TYPE: u16 = 224; + const MESSAGE_NAME: &'static str = "MSG_FLASH_DONE"; } -impl super::SBPMessage for MsgFlashDone { - fn get_message_name(&self) -> &'static str { - "MSG_FLASH_DONE" - } - fn get_message_type(&self) -> u16 { - 224 +impl SbpMessage for MsgFlashDone { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgFlashDone { - const MESSAGE_TYPE: u16 = 224; - const MESSAGE_NAME: &'static str = "MSG_FLASH_DONE"; } -impl TryFrom for MsgFlashDone { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgFlashDone { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgFlashDone(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgFlashDone(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgFlashDone { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.response.append_to_sbp_buffer(buf); +impl WireFormat for MsgFlashDone { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.response) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.response.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.response, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgFlashDone { + sender_id: None, + response: WireFormat::parse_unchecked(buf), + } } } @@ -116,82 +90,66 @@ impl crate::serialize::SbpSerialize for MsgFlashDone { /// message containing the return code - FLASH_OK (0) on success or /// FLASH_INVALID_FLASH (1) if the flash specified is invalid. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgFlashErase { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Target flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "target")))] pub target: u8, /// Flash sector number to erase (0-11 for the STM, 0-15 for the M25) + #[cfg_attr(feature = "serde", serde(rename(serialize = "sector_num")))] pub sector_num: u32, } -impl MsgFlashErase { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgFlashErase{ - sender_id: None, - target: _buf.read_u8()?, - sector_num: _buf.read_u32::()?, - } ) - } +impl ConcreteMessage for MsgFlashErase { + const MESSAGE_TYPE: u16 = 226; + const MESSAGE_NAME: &'static str = "MSG_FLASH_ERASE"; } -impl super::SBPMessage for MsgFlashErase { - fn get_message_name(&self) -> &'static str { - "MSG_FLASH_ERASE" - } - fn get_message_type(&self) -> u16 { - 226 +impl SbpMessage for MsgFlashErase { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgFlashErase { - const MESSAGE_TYPE: u16 = 226; - const MESSAGE_NAME: &'static str = "MSG_FLASH_ERASE"; } -impl TryFrom for MsgFlashErase { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgFlashErase { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgFlashErase(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgFlashErase(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgFlashErase { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.target.append_to_sbp_buffer(buf); - self.sector_num.append_to_sbp_buffer(buf); +impl WireFormat for MsgFlashErase { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.target) + WireFormat::encoded_len(&self.sector_num) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.target.sbp_size(); - size += self.sector_num.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.target, buf); + WireFormat::write(&self.sector_num, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgFlashErase { + sender_id: None, + target: WireFormat::parse_unchecked(buf), + sector_num: WireFormat::parse_unchecked(buf), + } } } @@ -203,92 +161,81 @@ impl crate::serialize::SbpSerialize for MsgFlashErase { /// (2) if the maximum write size is exceeded. Note that the sector-containing /// addresses must be erased before addresses can be programmed. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgFlashProgram { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Target flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "target")))] pub target: u8, /// Starting address offset to program - pub addr_start: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "addr_start")))] + pub addr_start: [u8; 3], /// Length of set of addresses to program, counting up from starting address + #[cfg_attr(feature = "serde", serde(rename(serialize = "addr_len")))] pub addr_len: u8, /// Data to program addresses with, with length N=addr_len + #[cfg_attr(feature = "serde", serde(rename(serialize = "data")))] pub data: Vec, } -impl MsgFlashProgram { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgFlashProgram{ - sender_id: None, - target: _buf.read_u8()?, - addr_start: crate::parser::read_u8_array_limit(_buf, 3)?, - addr_len: _buf.read_u8()?, - data: crate::parser::read_u8_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgFlashProgram { + const MESSAGE_TYPE: u16 = 230; + const MESSAGE_NAME: &'static str = "MSG_FLASH_PROGRAM"; } -impl super::SBPMessage for MsgFlashProgram { - fn get_message_name(&self) -> &'static str { - "MSG_FLASH_PROGRAM" - } - fn get_message_type(&self) -> u16 { - 230 +impl SbpMessage for MsgFlashProgram { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgFlashProgram { - const MESSAGE_TYPE: u16 = 230; - const MESSAGE_NAME: &'static str = "MSG_FLASH_PROGRAM"; } -impl TryFrom for MsgFlashProgram { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgFlashProgram { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgFlashProgram(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgFlashProgram(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgFlashProgram { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.target.append_to_sbp_buffer(buf); - self.addr_start.append_to_sbp_buffer(buf); - self.addr_len.append_to_sbp_buffer(buf); - self.data.append_to_sbp_buffer(buf); +impl WireFormat for MsgFlashProgram { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + <[u8; 3] as WireFormat>::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.target) + + WireFormat::encoded_len(&self.addr_start) + + WireFormat::encoded_len(&self.addr_len) + + WireFormat::encoded_len(&self.data) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.target.sbp_size(); - size += self.addr_start.sbp_size(); - size += self.addr_len.sbp_size(); - size += self.data.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.target, buf); + WireFormat::write(&self.addr_start, buf); + WireFormat::write(&self.addr_len, buf); + WireFormat::write(&self.data, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgFlashProgram { + sender_id: None, + target: WireFormat::parse_unchecked(buf), + addr_start: WireFormat::parse_unchecked(buf), + addr_len: WireFormat::parse_unchecked(buf), + data: WireFormat::parse_unchecked(buf), + } } } @@ -301,87 +248,74 @@ impl crate::serialize::SbpSerialize for MsgFlashProgram { /// is exceeded or FLASH_INVALID_ADDR (3) if the address is outside of the /// allowed range. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgFlashReadReq { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Target flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "target")))] pub target: u8, /// Starting address offset to read from - pub addr_start: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "addr_start")))] + pub addr_start: [u8; 3], /// Length of set of addresses to read, counting up from starting address + #[cfg_attr(feature = "serde", serde(rename(serialize = "addr_len")))] pub addr_len: u8, } -impl MsgFlashReadReq { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgFlashReadReq{ - sender_id: None, - target: _buf.read_u8()?, - addr_start: crate::parser::read_u8_array_limit(_buf, 3)?, - addr_len: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgFlashReadReq { + const MESSAGE_TYPE: u16 = 231; + const MESSAGE_NAME: &'static str = "MSG_FLASH_READ_REQ"; } -impl super::SBPMessage for MsgFlashReadReq { - fn get_message_name(&self) -> &'static str { - "MSG_FLASH_READ_REQ" - } - fn get_message_type(&self) -> u16 { - 231 +impl SbpMessage for MsgFlashReadReq { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgFlashReadReq { - const MESSAGE_TYPE: u16 = 231; - const MESSAGE_NAME: &'static str = "MSG_FLASH_READ_REQ"; -} -impl TryFrom for MsgFlashReadReq { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgFlashReadReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgFlashReadReq(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgFlashReadReq(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgFlashReadReq { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.target.append_to_sbp_buffer(buf); - self.addr_start.append_to_sbp_buffer(buf); - self.addr_len.append_to_sbp_buffer(buf); +impl WireFormat for MsgFlashReadReq { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + <[u8; 3] as WireFormat>::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.target) + + WireFormat::encoded_len(&self.addr_start) + + WireFormat::encoded_len(&self.addr_len) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.target.sbp_size(); - size += self.addr_start.sbp_size(); - size += self.addr_len.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.target, buf); + WireFormat::write(&self.addr_start, buf); + WireFormat::write(&self.addr_len, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgFlashReadReq { + sender_id: None, + target: WireFormat::parse_unchecked(buf), + addr_start: WireFormat::parse_unchecked(buf), + addr_len: WireFormat::parse_unchecked(buf), + } } } @@ -394,87 +328,74 @@ impl crate::serialize::SbpSerialize for MsgFlashReadReq { /// is exceeded or FLASH_INVALID_ADDR (3) if the address is outside of the /// allowed range. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgFlashReadResp { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Target flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "target")))] pub target: u8, /// Starting address offset to read from - pub addr_start: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "addr_start")))] + pub addr_start: [u8; 3], /// Length of set of addresses to read, counting up from starting address + #[cfg_attr(feature = "serde", serde(rename(serialize = "addr_len")))] pub addr_len: u8, } -impl MsgFlashReadResp { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgFlashReadResp{ - sender_id: None, - target: _buf.read_u8()?, - addr_start: crate::parser::read_u8_array_limit(_buf, 3)?, - addr_len: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgFlashReadResp { + const MESSAGE_TYPE: u16 = 225; + const MESSAGE_NAME: &'static str = "MSG_FLASH_READ_RESP"; } -impl super::SBPMessage for MsgFlashReadResp { - fn get_message_name(&self) -> &'static str { - "MSG_FLASH_READ_RESP" - } - fn get_message_type(&self) -> u16 { - 225 +impl SbpMessage for MsgFlashReadResp { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgFlashReadResp { - const MESSAGE_TYPE: u16 = 225; - const MESSAGE_NAME: &'static str = "MSG_FLASH_READ_RESP"; -} -impl TryFrom for MsgFlashReadResp { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgFlashReadResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgFlashReadResp(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgFlashReadResp(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgFlashReadResp { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.target.append_to_sbp_buffer(buf); - self.addr_start.append_to_sbp_buffer(buf); - self.addr_len.append_to_sbp_buffer(buf); +impl WireFormat for MsgFlashReadResp { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + <[u8; 3] as WireFormat>::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.target) + + WireFormat::encoded_len(&self.addr_start) + + WireFormat::encoded_len(&self.addr_len) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.target.sbp_size(); - size += self.addr_start.sbp_size(); - size += self.addr_len.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.target, buf); + WireFormat::write(&self.addr_start, buf); + WireFormat::write(&self.addr_len, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgFlashReadResp { + sender_id: None, + target: WireFormat::parse_unchecked(buf), + addr_start: WireFormat::parse_unchecked(buf), + addr_len: WireFormat::parse_unchecked(buf), + } } } @@ -483,77 +404,60 @@ impl crate::serialize::SbpSerialize for MsgFlashReadResp { /// The flash status message writes to the 8-bit M25 flash status register. /// The device replies with a MSG_FLASH_DONE message. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgM25FlashWriteStatus { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Byte to write to the M25 flash status register - pub status: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "status")))] + pub status: [u8; 1], } -impl MsgM25FlashWriteStatus { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgM25FlashWriteStatus{ - sender_id: None, - status: crate::parser::read_u8_array_limit(_buf, 1)?, - } ) - } +impl ConcreteMessage for MsgM25FlashWriteStatus { + const MESSAGE_TYPE: u16 = 243; + const MESSAGE_NAME: &'static str = "MSG_M25_FLASH_WRITE_STATUS"; } -impl super::SBPMessage for MsgM25FlashWriteStatus { - fn get_message_name(&self) -> &'static str { - "MSG_M25_FLASH_WRITE_STATUS" - } - fn get_message_type(&self) -> u16 { - 243 +impl SbpMessage for MsgM25FlashWriteStatus { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgM25FlashWriteStatus { - const MESSAGE_TYPE: u16 = 243; - const MESSAGE_NAME: &'static str = "MSG_M25_FLASH_WRITE_STATUS"; } -impl TryFrom for MsgM25FlashWriteStatus { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgM25FlashWriteStatus { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgM25FlashWriteStatus(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgM25FlashWriteStatus(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgM25FlashWriteStatus { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.status.append_to_sbp_buffer(buf); +impl WireFormat for MsgM25FlashWriteStatus { + const MIN_ENCODED_LEN: usize = <[u8; 1] as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.status) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.status.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.status, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgM25FlashWriteStatus { + sender_id: None, + status: WireFormat::parse_unchecked(buf), + } } } @@ -562,77 +466,60 @@ impl crate::serialize::SbpSerialize for MsgM25FlashWriteStatus { /// The flash lock message locks a sector of the STM flash memory. The device /// replies with a MSG_FLASH_DONE message. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgStmFlashLockSector { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Flash sector number to lock + #[cfg_attr(feature = "serde", serde(rename(serialize = "sector")))] pub sector: u32, } -impl MsgStmFlashLockSector { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgStmFlashLockSector{ - sender_id: None, - sector: _buf.read_u32::()?, - } ) - } +impl ConcreteMessage for MsgStmFlashLockSector { + const MESSAGE_TYPE: u16 = 227; + const MESSAGE_NAME: &'static str = "MSG_STM_FLASH_LOCK_SECTOR"; } -impl super::SBPMessage for MsgStmFlashLockSector { - fn get_message_name(&self) -> &'static str { - "MSG_STM_FLASH_LOCK_SECTOR" - } - fn get_message_type(&self) -> u16 { - 227 +impl SbpMessage for MsgStmFlashLockSector { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgStmFlashLockSector { - const MESSAGE_TYPE: u16 = 227; - const MESSAGE_NAME: &'static str = "MSG_STM_FLASH_LOCK_SECTOR"; } -impl TryFrom for MsgStmFlashLockSector { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgStmFlashLockSector { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgStmFlashLockSector(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgStmFlashLockSector(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgStmFlashLockSector { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sector.append_to_sbp_buffer(buf); +impl WireFormat for MsgStmFlashLockSector { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sector) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sector.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sector, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgStmFlashLockSector { + sender_id: None, + sector: WireFormat::parse_unchecked(buf), + } } } @@ -641,77 +528,60 @@ impl crate::serialize::SbpSerialize for MsgStmFlashLockSector { /// The flash unlock message unlocks a sector of the STM flash memory. The /// device replies with a MSG_FLASH_DONE message. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgStmFlashUnlockSector { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Flash sector number to unlock + #[cfg_attr(feature = "serde", serde(rename(serialize = "sector")))] pub sector: u32, } -impl MsgStmFlashUnlockSector { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgStmFlashUnlockSector{ - sender_id: None, - sector: _buf.read_u32::()?, - } ) - } +impl ConcreteMessage for MsgStmFlashUnlockSector { + const MESSAGE_TYPE: u16 = 228; + const MESSAGE_NAME: &'static str = "MSG_STM_FLASH_UNLOCK_SECTOR"; } -impl super::SBPMessage for MsgStmFlashUnlockSector { - fn get_message_name(&self) -> &'static str { - "MSG_STM_FLASH_UNLOCK_SECTOR" - } - fn get_message_type(&self) -> u16 { - 228 +impl SbpMessage for MsgStmFlashUnlockSector { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgStmFlashUnlockSector { - const MESSAGE_TYPE: u16 = 228; - const MESSAGE_NAME: &'static str = "MSG_STM_FLASH_UNLOCK_SECTOR"; } -impl TryFrom for MsgStmFlashUnlockSector { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgStmFlashUnlockSector { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgStmFlashUnlockSector(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgStmFlashUnlockSector(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgStmFlashUnlockSector { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sector.append_to_sbp_buffer(buf); +impl WireFormat for MsgStmFlashUnlockSector { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sector) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sector.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sector, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgStmFlashUnlockSector { + sender_id: None, + sector: WireFormat::parse_unchecked(buf), + } } } @@ -722,71 +592,53 @@ impl crate::serialize::SbpSerialize for MsgStmFlashUnlockSector { /// the ID by sending a MSG_STM_UNIQUE_ID_REQ. The device responds with a /// MSG_STM_UNIQUE_ID_RESP with the 12-byte unique ID in the payload. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgStmUniqueIdReq { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, } -impl MsgStmUniqueIdReq { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgStmUniqueIdReq{ - sender_id: None, - } ) - } +impl ConcreteMessage for MsgStmUniqueIdReq { + const MESSAGE_TYPE: u16 = 232; + const MESSAGE_NAME: &'static str = "MSG_STM_UNIQUE_ID_REQ"; } -impl super::SBPMessage for MsgStmUniqueIdReq { - fn get_message_name(&self) -> &'static str { - "MSG_STM_UNIQUE_ID_REQ" - } - fn get_message_type(&self) -> u16 { - 232 +impl SbpMessage for MsgStmUniqueIdReq { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgStmUniqueIdReq { - const MESSAGE_TYPE: u16 = 232; - const MESSAGE_NAME: &'static str = "MSG_STM_UNIQUE_ID_REQ"; -} -impl TryFrom for MsgStmUniqueIdReq { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgStmUniqueIdReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgStmUniqueIdReq(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgStmUniqueIdReq(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgStmUniqueIdReq { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) {} - - fn sbp_size(&self) -> usize { +impl WireFormat for MsgStmUniqueIdReq { + const MIN_ENCODED_LEN: usize = 0; + fn encoded_len(&self) -> usize { 0 } + fn write(&self, _buf: &mut bytes::BytesMut) {} + fn parse_unchecked(_buf: &mut bytes::BytesMut) -> Self { + MsgStmUniqueIdReq { sender_id: None } + } } /// Read device's hard-coded unique ID response (host <= device) @@ -796,76 +648,59 @@ impl crate::serialize::SbpSerialize for MsgStmUniqueIdReq { /// the ID by sending a MSG_STM_UNIQUE_ID_REQ. The device responds with a /// MSG_STM_UNIQUE_ID_RESP with the 12-byte unique ID in the payload. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgStmUniqueIdResp { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Device unique ID - pub stm_id: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "stm_id")))] + pub stm_id: [u8; 12], } -impl MsgStmUniqueIdResp { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgStmUniqueIdResp{ - sender_id: None, - stm_id: crate::parser::read_u8_array_limit(_buf, 12)?, - } ) - } +impl ConcreteMessage for MsgStmUniqueIdResp { + const MESSAGE_TYPE: u16 = 229; + const MESSAGE_NAME: &'static str = "MSG_STM_UNIQUE_ID_RESP"; } -impl super::SBPMessage for MsgStmUniqueIdResp { - fn get_message_name(&self) -> &'static str { - "MSG_STM_UNIQUE_ID_RESP" - } - fn get_message_type(&self) -> u16 { - 229 +impl SbpMessage for MsgStmUniqueIdResp { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgStmUniqueIdResp { - const MESSAGE_TYPE: u16 = 229; - const MESSAGE_NAME: &'static str = "MSG_STM_UNIQUE_ID_RESP"; -} -impl TryFrom for MsgStmUniqueIdResp { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgStmUniqueIdResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgStmUniqueIdResp(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgStmUniqueIdResp(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgStmUniqueIdResp { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.stm_id.append_to_sbp_buffer(buf); +impl WireFormat for MsgStmUniqueIdResp { + const MIN_ENCODED_LEN: usize = <[u8; 12] as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.stm_id) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.stm_id.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.stm_id, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgStmUniqueIdResp { + sender_id: None, + stm_id: WireFormat::parse_unchecked(buf), + } } } diff --git a/rust/sbp/src/messages/gnss.rs b/rust/sbp/src/messages/gnss.rs index ad739803a5..824207cda6 100644 --- a/rust/sbp/src/messages/gnss.rs +++ b/rust/sbp/src/messages/gnss.rs @@ -14,16 +14,7 @@ //****************************************************************************/ //! Various structs shared between modules -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; +use super::lib::*; /// GNSS carrier phase measurement /// @@ -31,53 +22,32 @@ use crate::SbpString; /// number with Q32.8 layout, i.e. 32-bits of whole cycles and 8-bits of /// fractional cycles. This phase has the same sign as the pseudorange. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct CarrierPhase { /// Carrier phase whole cycles + #[cfg_attr(feature = "serde", serde(rename(serialize = "i")))] pub i: i32, /// Carrier phase fractional part + #[cfg_attr(feature = "serde", serde(rename(serialize = "f")))] pub f: u8, } -impl CarrierPhase { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( CarrierPhase{ - i: _buf.read_i32::()?, - f: _buf.read_u8()?, - } ) +impl WireFormat for CarrierPhase { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.i) + WireFormat::encoded_len(&self.f) } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(CarrierPhase::parse(buf)?); - } - Ok(v) + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.i, buf); + WireFormat::write(&self.f, buf); } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(CarrierPhase::parse(buf)?); + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + CarrierPhase { + i: WireFormat::parse_unchecked(buf), + f: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for CarrierPhase { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.i.append_to_sbp_buffer(buf); - self.f.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.i.sbp_size(); - size += self.f.sbp_size(); - size } } @@ -87,59 +57,41 @@ impl crate::serialize::SbpSerialize for CarrierPhase { /// beginning of the week on the Saturday/Sunday transition. In most cases, /// observations are epoch aligned so ns field will be 0. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct GPSTime { +pub struct GpsTime { /// Milliseconds since start of GPS week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Nanosecond residual of millisecond-rounded TOW (ranges from -500000 to /// 500000) + #[cfg_attr(feature = "serde", serde(rename(serialize = "ns_residual")))] pub ns_residual: i32, /// GPS week number + #[cfg_attr(feature = "serde", serde(rename(serialize = "wn")))] pub wn: u16, } -impl GPSTime { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( GPSTime{ - tow: _buf.read_u32::()?, - ns_residual: _buf.read_i32::()?, - wn: _buf.read_u16::()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(GPSTime::parse(buf)?); +impl WireFormat for GpsTime { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.ns_residual) + + WireFormat::encoded_len(&self.wn) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.ns_residual, buf); + WireFormat::write(&self.wn, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + GpsTime { + tow: WireFormat::parse_unchecked(buf), + ns_residual: WireFormat::parse_unchecked(buf), + wn: WireFormat::parse_unchecked(buf), } - Ok(v) - } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(GPSTime::parse(buf)?); - } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for GPSTime { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.ns_residual.append_to_sbp_buffer(buf); - self.wn.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.ns_residual.sbp_size(); - size += self.wn.sbp_size(); - size } } @@ -148,53 +100,32 @@ impl crate::serialize::SbpSerialize for GPSTime { /// A wire-appropriate GPS time, defined as the number of milliseconds since /// beginning of the week on the Saturday/Sunday transition. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct GPSTimeDep { +pub struct GpsTimeDep { /// Milliseconds since start of GPS week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// GPS week number + #[cfg_attr(feature = "serde", serde(rename(serialize = "wn")))] pub wn: u16, } -impl GPSTimeDep { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( GPSTimeDep{ - tow: _buf.read_u32::()?, - wn: _buf.read_u16::()?, - } ) +impl WireFormat for GpsTimeDep { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + WireFormat::encoded_len(&self.wn) } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(GPSTimeDep::parse(buf)?); - } - Ok(v) + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.wn, buf); } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(GPSTimeDep::parse(buf)?); + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + GpsTimeDep { + tow: WireFormat::parse_unchecked(buf), + wn: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for GPSTimeDep { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.wn.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.wn.sbp_size(); - size } } @@ -203,53 +134,32 @@ impl crate::serialize::SbpSerialize for GPSTimeDep { /// A GPS time, defined as the number of seconds since beginning of the week /// on the Saturday/Sunday transition. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct GPSTimeSec { +pub struct GpsTimeSec { /// Seconds since start of GPS week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// GPS week number + #[cfg_attr(feature = "serde", serde(rename(serialize = "wn")))] pub wn: u16, } -impl GPSTimeSec { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( GPSTimeSec{ - tow: _buf.read_u32::()?, - wn: _buf.read_u16::()?, - } ) +impl WireFormat for GpsTimeSec { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + WireFormat::encoded_len(&self.wn) } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(GPSTimeSec::parse(buf)?); - } - Ok(v) + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.wn, buf); } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(GPSTimeSec::parse(buf)?); + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + GpsTimeSec { + tow: WireFormat::parse_unchecked(buf), + wn: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for GPSTimeSec { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.wn.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.wn.sbp_size(); - size } } @@ -258,54 +168,33 @@ impl crate::serialize::SbpSerialize for GPSTimeSec { /// Signal identifier containing constellation, band, and satellite /// identifier. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct GnssSignal { /// Constellation-specific satellite identifier. This field for Glonass can - /// either be (100+FCN) where FCN is in [-7,+6] or the Slot ID in [1,28]. + /// either be (100+FCN) where FCN is in \[-7,+6\] or the Slot ID in \[1,28\]. + #[cfg_attr(feature = "serde", serde(rename(serialize = "sat")))] pub sat: u8, /// Signal constellation, band and code + #[cfg_attr(feature = "serde", serde(rename(serialize = "code")))] pub code: u8, } -impl GnssSignal { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( GnssSignal{ - sat: _buf.read_u8()?, - code: _buf.read_u8()?, - } ) +impl WireFormat for GnssSignal { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sat) + WireFormat::encoded_len(&self.code) } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(GnssSignal::parse(buf)?); - } - Ok(v) + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sat, buf); + WireFormat::write(&self.code, buf); } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(GnssSignal::parse(buf)?); + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + GnssSignal { + sat: WireFormat::parse_unchecked(buf), + code: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for GnssSignal { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sat.append_to_sbp_buffer(buf); - self.code.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sat.sbp_size(); - size += self.code.sbp_size(); - size } } @@ -313,64 +202,43 @@ impl crate::serialize::SbpSerialize for GnssSignal { /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct GnssSignalDep { /// Constellation-specific satellite identifier. /// /// Note: unlike GnssSignal, GPS satellites are encoded as (PRN - 1). Other /// constellations do not have this offset. + #[cfg_attr(feature = "serde", serde(rename(serialize = "sat")))] pub sat: u16, /// Signal constellation, band and code + #[cfg_attr(feature = "serde", serde(rename(serialize = "code")))] pub code: u8, /// Reserved + #[cfg_attr(feature = "serde", serde(rename(serialize = "reserved")))] pub reserved: u8, } -impl GnssSignalDep { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( GnssSignalDep{ - sat: _buf.read_u16::()?, - code: _buf.read_u8()?, - reserved: _buf.read_u8()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(GnssSignalDep::parse(buf)?); +impl WireFormat for GnssSignalDep { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sat) + + WireFormat::encoded_len(&self.code) + + WireFormat::encoded_len(&self.reserved) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sat, buf); + WireFormat::write(&self.code, buf); + WireFormat::write(&self.reserved, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + GnssSignalDep { + sat: WireFormat::parse_unchecked(buf), + code: WireFormat::parse_unchecked(buf), + reserved: WireFormat::parse_unchecked(buf), } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(GnssSignalDep::parse(buf)?); - } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for GnssSignalDep { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sat.append_to_sbp_buffer(buf); - self.code.append_to_sbp_buffer(buf); - self.reserved.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sat.sbp_size(); - size += self.code.sbp_size(); - size += self.reserved.sbp_size(); - size } } @@ -379,52 +247,31 @@ impl crate::serialize::SbpSerialize for GnssSignalDep { /// A (Constellation ID, satellite ID) tuple that uniquely identifies a space /// vehicle. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct SvId { /// ID of the space vehicle within its constellation - pub satId: u8, + #[cfg_attr(feature = "serde", serde(rename(serialize = "satId")))] + pub sat_id: u8, /// Constellation ID to which the SV belongs + #[cfg_attr(feature = "serde", serde(rename(serialize = "constellation")))] pub constellation: u8, } -impl SvId { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( SvId{ - satId: _buf.read_u8()?, - constellation: _buf.read_u8()?, - } ) +impl WireFormat for SvId { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sat_id) + WireFormat::encoded_len(&self.constellation) } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(SvId::parse(buf)?); - } - Ok(v) + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sat_id, buf); + WireFormat::write(&self.constellation, buf); } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(SvId::parse(buf)?); + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + SvId { + sat_id: WireFormat::parse_unchecked(buf), + constellation: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for SvId { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.satId.append_to_sbp_buffer(buf); - self.constellation.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.satId.sbp_size(); - size += self.constellation.sbp_size(); - size } } diff --git a/rust/sbp/src/messages/imu.rs b/rust/sbp/src/messages/imu.rs index cd2cf0b01b..bf166f09e3 100644 --- a/rust/sbp/src/messages/imu.rs +++ b/rust/sbp/src/messages/imu.rs @@ -14,16 +14,7 @@ //****************************************************************************/ //! Inertial Measurement Unit (IMU) messages. -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; +use super::lib::*; /// Auxiliary IMU data /// @@ -31,87 +22,74 @@ use crate::SbpString; /// always be consistent but the rest of the payload is device specific and /// depends on the value of `imu_type`. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgImuAux { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// IMU type + #[cfg_attr(feature = "serde", serde(rename(serialize = "imu_type")))] pub imu_type: u8, /// Raw IMU temperature + #[cfg_attr(feature = "serde", serde(rename(serialize = "temp")))] pub temp: i16, /// IMU configuration + #[cfg_attr(feature = "serde", serde(rename(serialize = "imu_conf")))] pub imu_conf: u8, } -impl MsgImuAux { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgImuAux{ - sender_id: None, - imu_type: _buf.read_u8()?, - temp: _buf.read_i16::()?, - imu_conf: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgImuAux { + const MESSAGE_TYPE: u16 = 2305; + const MESSAGE_NAME: &'static str = "MSG_IMU_AUX"; } -impl super::SBPMessage for MsgImuAux { - fn get_message_name(&self) -> &'static str { - "MSG_IMU_AUX" - } - fn get_message_type(&self) -> u16 { - 2305 +impl SbpMessage for MsgImuAux { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgImuAux { - const MESSAGE_TYPE: u16 = 2305; - const MESSAGE_NAME: &'static str = "MSG_IMU_AUX"; } -impl TryFrom for MsgImuAux { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgImuAux { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgImuAux(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgImuAux(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgImuAux { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.imu_type.append_to_sbp_buffer(buf); - self.temp.append_to_sbp_buffer(buf); - self.imu_conf.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.imu_type.sbp_size(); - size += self.temp.sbp_size(); - size += self.imu_conf.sbp_size(); - size +impl WireFormat for MsgImuAux { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.imu_type) + + WireFormat::encoded_len(&self.temp) + + WireFormat::encoded_len(&self.imu_conf) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.imu_type, buf); + WireFormat::write(&self.temp, buf); + WireFormat::write(&self.imu_conf, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgImuAux { + sender_id: None, + imu_type: WireFormat::parse_unchecked(buf), + temp: WireFormat::parse_unchecked(buf), + imu_conf: WireFormat::parse_unchecked(buf), + } } } @@ -128,127 +106,121 @@ impl crate::serialize::SbpSerialize for MsgImuAux { /// /// The time-tagging mode should not change throughout a run. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgImuRaw { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Milliseconds since reference epoch and time status. + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Milliseconds since reference epoch, fractional part + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow_f")))] pub tow_f: u8, /// Acceleration in the IMU frame X axis + #[cfg_attr(feature = "serde", serde(rename(serialize = "acc_x")))] pub acc_x: i16, /// Acceleration in the IMU frame Y axis + #[cfg_attr(feature = "serde", serde(rename(serialize = "acc_y")))] pub acc_y: i16, /// Acceleration in the IMU frame Z axis + #[cfg_attr(feature = "serde", serde(rename(serialize = "acc_z")))] pub acc_z: i16, /// Angular rate around IMU frame X axis + #[cfg_attr(feature = "serde", serde(rename(serialize = "gyr_x")))] pub gyr_x: i16, /// Angular rate around IMU frame Y axis + #[cfg_attr(feature = "serde", serde(rename(serialize = "gyr_y")))] pub gyr_y: i16, /// Angular rate around IMU frame Z axis + #[cfg_attr(feature = "serde", serde(rename(serialize = "gyr_z")))] pub gyr_z: i16, } -impl MsgImuRaw { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgImuRaw{ - sender_id: None, - tow: _buf.read_u32::()?, - tow_f: _buf.read_u8()?, - acc_x: _buf.read_i16::()?, - acc_y: _buf.read_i16::()?, - acc_z: _buf.read_i16::()?, - gyr_x: _buf.read_i16::()?, - gyr_y: _buf.read_i16::()?, - gyr_z: _buf.read_i16::()?, - } ) - } +impl ConcreteMessage for MsgImuRaw { + const MESSAGE_TYPE: u16 = 2304; + const MESSAGE_NAME: &'static str = "MSG_IMU_RAW"; } -impl super::SBPMessage for MsgImuRaw { - fn get_message_name(&self) -> &'static str { - "MSG_IMU_RAW" - } - fn get_message_type(&self) -> u16 { - 2304 +impl SbpMessage for MsgImuRaw { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { const IMU_RAW_TIME_STATUS_MASK: u32 = (1 << 30) | (1 << 31); if self.tow & IMU_RAW_TIME_STATUS_MASK != 0 { return None; } let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgImuRaw { - const MESSAGE_TYPE: u16 = 2304; - const MESSAGE_NAME: &'static str = "MSG_IMU_RAW"; -} -impl TryFrom for MsgImuRaw { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgImuRaw { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgImuRaw(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgImuRaw(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgImuRaw { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.tow_f.append_to_sbp_buffer(buf); - self.acc_x.append_to_sbp_buffer(buf); - self.acc_y.append_to_sbp_buffer(buf); - self.acc_z.append_to_sbp_buffer(buf); - self.gyr_x.append_to_sbp_buffer(buf); - self.gyr_y.append_to_sbp_buffer(buf); - self.gyr_z.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.tow_f.sbp_size(); - size += self.acc_x.sbp_size(); - size += self.acc_y.sbp_size(); - size += self.acc_z.sbp_size(); - size += self.gyr_x.sbp_size(); - size += self.gyr_y.sbp_size(); - size += self.gyr_z.sbp_size(); - size +impl WireFormat for MsgImuRaw { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.tow_f) + + WireFormat::encoded_len(&self.acc_x) + + WireFormat::encoded_len(&self.acc_y) + + WireFormat::encoded_len(&self.acc_z) + + WireFormat::encoded_len(&self.gyr_x) + + WireFormat::encoded_len(&self.gyr_y) + + WireFormat::encoded_len(&self.gyr_z) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.tow_f, buf); + WireFormat::write(&self.acc_x, buf); + WireFormat::write(&self.acc_y, buf); + WireFormat::write(&self.acc_z, buf); + WireFormat::write(&self.gyr_x, buf); + WireFormat::write(&self.gyr_y, buf); + WireFormat::write(&self.gyr_z, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgImuRaw { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + tow_f: WireFormat::parse_unchecked(buf), + acc_x: WireFormat::parse_unchecked(buf), + acc_y: WireFormat::parse_unchecked(buf), + acc_z: WireFormat::parse_unchecked(buf), + gyr_x: WireFormat::parse_unchecked(buf), + gyr_y: WireFormat::parse_unchecked(buf), + gyr_z: WireFormat::parse_unchecked(buf), + } } } diff --git a/rust/sbp/src/messages/linux.rs b/rust/sbp/src/messages/linux.rs index 9062013e3c..4ce537c965 100644 --- a/rust/sbp/src/messages/linux.rs +++ b/rust/sbp/src/messages/linux.rs @@ -14,123 +14,109 @@ //****************************************************************************/ //! Linux state monitoring. -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; +use super::lib::*; /// List CPU state on the system /// /// This message indicates the process state of the top 10 heaviest consumers /// of CPU on the system, including a timestamp. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgLinuxCpuState { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// sequence of this status message, values from 0-9 + #[cfg_attr(feature = "serde", serde(rename(serialize = "index")))] pub index: u8, /// the PID of the process + #[cfg_attr(feature = "serde", serde(rename(serialize = "pid")))] pub pid: u16, /// percent of CPU used, expressed as a fraction of 256 + #[cfg_attr(feature = "serde", serde(rename(serialize = "pcpu")))] pub pcpu: u8, /// timestamp of message, refer to flags field for how to interpret + #[cfg_attr(feature = "serde", serde(rename(serialize = "time")))] pub time: u32, /// flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, /// fixed length string representing the thread name - pub tname: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "tname")))] + pub tname: SbpString<[u8; 15], Unterminated>, /// the command line (as much as it fits in the remaining packet) - pub cmdline: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] + pub cmdline: SbpString, Unterminated>, } -impl MsgLinuxCpuState { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgLinuxCpuState{ - sender_id: None, - index: _buf.read_u8()?, - pid: _buf.read_u16::()?, - pcpu: _buf.read_u8()?, - time: _buf.read_u32::()?, - flags: _buf.read_u8()?, - tname: crate::parser::read_string_limit(_buf, 15)?, - cmdline: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgLinuxCpuState { + const MESSAGE_TYPE: u16 = 32520; + const MESSAGE_NAME: &'static str = "MSG_LINUX_CPU_STATE"; } -impl super::SBPMessage for MsgLinuxCpuState { - fn get_message_name(&self) -> &'static str { - "MSG_LINUX_CPU_STATE" - } - fn get_message_type(&self) -> u16 { - 32520 +impl SbpMessage for MsgLinuxCpuState { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgLinuxCpuState { - const MESSAGE_TYPE: u16 = 32520; - const MESSAGE_NAME: &'static str = "MSG_LINUX_CPU_STATE"; -} -impl TryFrom for MsgLinuxCpuState { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgLinuxCpuState { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgLinuxCpuState(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgLinuxCpuState(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgLinuxCpuState { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.index.append_to_sbp_buffer(buf); - self.pid.append_to_sbp_buffer(buf); - self.pcpu.append_to_sbp_buffer(buf); - self.time.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - self.tname.append_to_sbp_buffer(buf); - self.cmdline.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.index.sbp_size(); - size += self.pid.sbp_size(); - size += self.pcpu.sbp_size(); - size += self.time.sbp_size(); - size += self.flags.sbp_size(); - size += self.tname.sbp_size(); - size += self.cmdline.sbp_size(); - size +impl WireFormat for MsgLinuxCpuState { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN + + , Unterminated> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.index) + + WireFormat::encoded_len(&self.pid) + + WireFormat::encoded_len(&self.pcpu) + + WireFormat::encoded_len(&self.time) + + WireFormat::encoded_len(&self.flags) + + WireFormat::encoded_len(&self.tname) + + WireFormat::encoded_len(&self.cmdline) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.index, buf); + WireFormat::write(&self.pid, buf); + WireFormat::write(&self.pcpu, buf); + WireFormat::write(&self.time, buf); + WireFormat::write(&self.flags, buf); + WireFormat::write(&self.tname, buf); + WireFormat::write(&self.cmdline, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgLinuxCpuState { + sender_id: None, + index: WireFormat::parse_unchecked(buf), + pid: WireFormat::parse_unchecked(buf), + pcpu: WireFormat::parse_unchecked(buf), + time: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + tname: WireFormat::parse_unchecked(buf), + cmdline: WireFormat::parse_unchecked(buf), + } } } @@ -139,97 +125,88 @@ impl crate::serialize::SbpSerialize for MsgLinuxCpuState { /// This message indicates the process state of the top 10 heaviest consumers /// of CPU on the system. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgLinuxCpuStateDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// sequence of this status message, values from 0-9 + #[cfg_attr(feature = "serde", serde(rename(serialize = "index")))] pub index: u8, /// the PID of the process + #[cfg_attr(feature = "serde", serde(rename(serialize = "pid")))] pub pid: u16, /// percent of cpu used, expressed as a fraction of 256 + #[cfg_attr(feature = "serde", serde(rename(serialize = "pcpu")))] pub pcpu: u8, /// fixed length string representing the thread name - pub tname: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "tname")))] + pub tname: SbpString<[u8; 15], Unterminated>, /// the command line (as much as it fits in the remaining packet) - pub cmdline: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] + pub cmdline: SbpString, Unterminated>, } -impl MsgLinuxCpuStateDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgLinuxCpuStateDepA{ - sender_id: None, - index: _buf.read_u8()?, - pid: _buf.read_u16::()?, - pcpu: _buf.read_u8()?, - tname: crate::parser::read_string_limit(_buf, 15)?, - cmdline: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgLinuxCpuStateDepA { + const MESSAGE_TYPE: u16 = 32512; + const MESSAGE_NAME: &'static str = "MSG_LINUX_CPU_STATE_DEP_A"; } -impl super::SBPMessage for MsgLinuxCpuStateDepA { - fn get_message_name(&self) -> &'static str { - "MSG_LINUX_CPU_STATE_DEP_A" - } - fn get_message_type(&self) -> u16 { - 32512 +impl SbpMessage for MsgLinuxCpuStateDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgLinuxCpuStateDepA { - const MESSAGE_TYPE: u16 = 32512; - const MESSAGE_NAME: &'static str = "MSG_LINUX_CPU_STATE_DEP_A"; -} -impl TryFrom for MsgLinuxCpuStateDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgLinuxCpuStateDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgLinuxCpuStateDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgLinuxCpuStateDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgLinuxCpuStateDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.index.append_to_sbp_buffer(buf); - self.pid.append_to_sbp_buffer(buf); - self.pcpu.append_to_sbp_buffer(buf); - self.tname.append_to_sbp_buffer(buf); - self.cmdline.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.index.sbp_size(); - size += self.pid.sbp_size(); - size += self.pcpu.sbp_size(); - size += self.tname.sbp_size(); - size += self.cmdline.sbp_size(); - size +impl WireFormat for MsgLinuxCpuStateDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN + + , Unterminated> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.index) + + WireFormat::encoded_len(&self.pid) + + WireFormat::encoded_len(&self.pcpu) + + WireFormat::encoded_len(&self.tname) + + WireFormat::encoded_len(&self.cmdline) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.index, buf); + WireFormat::write(&self.pid, buf); + WireFormat::write(&self.pcpu, buf); + WireFormat::write(&self.tname, buf); + WireFormat::write(&self.cmdline, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgLinuxCpuStateDepA { + sender_id: None, + index: WireFormat::parse_unchecked(buf), + pid: WireFormat::parse_unchecked(buf), + pcpu: WireFormat::parse_unchecked(buf), + tname: WireFormat::parse_unchecked(buf), + cmdline: WireFormat::parse_unchecked(buf), + } } } @@ -238,107 +215,102 @@ impl crate::serialize::SbpSerialize for MsgLinuxCpuStateDepA { /// This message indicates the process state of the top 10 heaviest consumers /// of memory on the system, including a timestamp. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgLinuxMemState { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// sequence of this status message, values from 0-9 + #[cfg_attr(feature = "serde", serde(rename(serialize = "index")))] pub index: u8, /// the PID of the process + #[cfg_attr(feature = "serde", serde(rename(serialize = "pid")))] pub pid: u16, /// percent of memory used, expressed as a fraction of 256 + #[cfg_attr(feature = "serde", serde(rename(serialize = "pmem")))] pub pmem: u8, /// timestamp of message, refer to flags field for how to interpret + #[cfg_attr(feature = "serde", serde(rename(serialize = "time")))] pub time: u32, /// flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, /// fixed length string representing the thread name - pub tname: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "tname")))] + pub tname: SbpString<[u8; 15], Unterminated>, /// the command line (as much as it fits in the remaining packet) - pub cmdline: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] + pub cmdline: SbpString, Unterminated>, } -impl MsgLinuxMemState { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgLinuxMemState{ - sender_id: None, - index: _buf.read_u8()?, - pid: _buf.read_u16::()?, - pmem: _buf.read_u8()?, - time: _buf.read_u32::()?, - flags: _buf.read_u8()?, - tname: crate::parser::read_string_limit(_buf, 15)?, - cmdline: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgLinuxMemState { + const MESSAGE_TYPE: u16 = 32521; + const MESSAGE_NAME: &'static str = "MSG_LINUX_MEM_STATE"; } -impl super::SBPMessage for MsgLinuxMemState { - fn get_message_name(&self) -> &'static str { - "MSG_LINUX_MEM_STATE" - } - fn get_message_type(&self) -> u16 { - 32521 +impl SbpMessage for MsgLinuxMemState { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgLinuxMemState { - const MESSAGE_TYPE: u16 = 32521; - const MESSAGE_NAME: &'static str = "MSG_LINUX_MEM_STATE"; } -impl TryFrom for MsgLinuxMemState { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgLinuxMemState { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgLinuxMemState(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgLinuxMemState(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgLinuxMemState { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.index.append_to_sbp_buffer(buf); - self.pid.append_to_sbp_buffer(buf); - self.pmem.append_to_sbp_buffer(buf); - self.time.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - self.tname.append_to_sbp_buffer(buf); - self.cmdline.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.index.sbp_size(); - size += self.pid.sbp_size(); - size += self.pmem.sbp_size(); - size += self.time.sbp_size(); - size += self.flags.sbp_size(); - size += self.tname.sbp_size(); - size += self.cmdline.sbp_size(); - size +impl WireFormat for MsgLinuxMemState { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN + + , Unterminated> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.index) + + WireFormat::encoded_len(&self.pid) + + WireFormat::encoded_len(&self.pmem) + + WireFormat::encoded_len(&self.time) + + WireFormat::encoded_len(&self.flags) + + WireFormat::encoded_len(&self.tname) + + WireFormat::encoded_len(&self.cmdline) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.index, buf); + WireFormat::write(&self.pid, buf); + WireFormat::write(&self.pmem, buf); + WireFormat::write(&self.time, buf); + WireFormat::write(&self.flags, buf); + WireFormat::write(&self.tname, buf); + WireFormat::write(&self.cmdline, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgLinuxMemState { + sender_id: None, + index: WireFormat::parse_unchecked(buf), + pid: WireFormat::parse_unchecked(buf), + pmem: WireFormat::parse_unchecked(buf), + time: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + tname: WireFormat::parse_unchecked(buf), + cmdline: WireFormat::parse_unchecked(buf), + } } } @@ -347,97 +319,88 @@ impl crate::serialize::SbpSerialize for MsgLinuxMemState { /// This message indicates the process state of the top 10 heaviest consumers /// of memory on the system. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgLinuxMemStateDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// sequence of this status message, values from 0-9 + #[cfg_attr(feature = "serde", serde(rename(serialize = "index")))] pub index: u8, /// the PID of the process + #[cfg_attr(feature = "serde", serde(rename(serialize = "pid")))] pub pid: u16, /// percent of memory used, expressed as a fraction of 256 + #[cfg_attr(feature = "serde", serde(rename(serialize = "pmem")))] pub pmem: u8, /// fixed length string representing the thread name - pub tname: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "tname")))] + pub tname: SbpString<[u8; 15], Unterminated>, /// the command line (as much as it fits in the remaining packet) - pub cmdline: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] + pub cmdline: SbpString, Unterminated>, } -impl MsgLinuxMemStateDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgLinuxMemStateDepA{ - sender_id: None, - index: _buf.read_u8()?, - pid: _buf.read_u16::()?, - pmem: _buf.read_u8()?, - tname: crate::parser::read_string_limit(_buf, 15)?, - cmdline: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgLinuxMemStateDepA { + const MESSAGE_TYPE: u16 = 32513; + const MESSAGE_NAME: &'static str = "MSG_LINUX_MEM_STATE_DEP_A"; } -impl super::SBPMessage for MsgLinuxMemStateDepA { - fn get_message_name(&self) -> &'static str { - "MSG_LINUX_MEM_STATE_DEP_A" - } - fn get_message_type(&self) -> u16 { - 32513 +impl SbpMessage for MsgLinuxMemStateDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgLinuxMemStateDepA { - const MESSAGE_TYPE: u16 = 32513; - const MESSAGE_NAME: &'static str = "MSG_LINUX_MEM_STATE_DEP_A"; } -impl TryFrom for MsgLinuxMemStateDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgLinuxMemStateDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgLinuxMemStateDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgLinuxMemStateDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgLinuxMemStateDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.index.append_to_sbp_buffer(buf); - self.pid.append_to_sbp_buffer(buf); - self.pmem.append_to_sbp_buffer(buf); - self.tname.append_to_sbp_buffer(buf); - self.cmdline.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.index.sbp_size(); - size += self.pid.sbp_size(); - size += self.pmem.sbp_size(); - size += self.tname.sbp_size(); - size += self.cmdline.sbp_size(); - size +impl WireFormat for MsgLinuxMemStateDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN + + , Unterminated> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.index) + + WireFormat::encoded_len(&self.pid) + + WireFormat::encoded_len(&self.pmem) + + WireFormat::encoded_len(&self.tname) + + WireFormat::encoded_len(&self.cmdline) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.index, buf); + WireFormat::write(&self.pid, buf); + WireFormat::write(&self.pmem, buf); + WireFormat::write(&self.tname, buf); + WireFormat::write(&self.cmdline, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgLinuxMemStateDepA { + sender_id: None, + index: WireFormat::parse_unchecked(buf), + pid: WireFormat::parse_unchecked(buf), + pmem: WireFormat::parse_unchecked(buf), + tname: WireFormat::parse_unchecked(buf), + cmdline: WireFormat::parse_unchecked(buf), + } } } @@ -445,92 +408,81 @@ impl crate::serialize::SbpSerialize for MsgLinuxMemStateDepA { /// /// Top 10 list of processes with a large number of open file descriptors. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgLinuxProcessFdCount { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// sequence of this status message, values from 0-9 + #[cfg_attr(feature = "serde", serde(rename(serialize = "index")))] pub index: u8, /// the PID of the process in question + #[cfg_attr(feature = "serde", serde(rename(serialize = "pid")))] pub pid: u16, /// a count of the number of file descriptors opened by the process + #[cfg_attr(feature = "serde", serde(rename(serialize = "fd_count")))] pub fd_count: u16, /// the command line of the process in question - pub cmdline: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] + pub cmdline: SbpString, Unterminated>, } -impl MsgLinuxProcessFdCount { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgLinuxProcessFdCount{ - sender_id: None, - index: _buf.read_u8()?, - pid: _buf.read_u16::()?, - fd_count: _buf.read_u16::()?, - cmdline: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgLinuxProcessFdCount { + const MESSAGE_TYPE: u16 = 32518; + const MESSAGE_NAME: &'static str = "MSG_LINUX_PROCESS_FD_COUNT"; } -impl super::SBPMessage for MsgLinuxProcessFdCount { - fn get_message_name(&self) -> &'static str { - "MSG_LINUX_PROCESS_FD_COUNT" - } - fn get_message_type(&self) -> u16 { - 32518 +impl SbpMessage for MsgLinuxProcessFdCount { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgLinuxProcessFdCount { - const MESSAGE_TYPE: u16 = 32518; - const MESSAGE_NAME: &'static str = "MSG_LINUX_PROCESS_FD_COUNT"; } -impl TryFrom for MsgLinuxProcessFdCount { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgLinuxProcessFdCount { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgLinuxProcessFdCount(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgLinuxProcessFdCount(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgLinuxProcessFdCount { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.index.append_to_sbp_buffer(buf); - self.pid.append_to_sbp_buffer(buf); - self.fd_count.append_to_sbp_buffer(buf); - self.cmdline.append_to_sbp_buffer(buf); +impl WireFormat for MsgLinuxProcessFdCount { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + , Unterminated> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.index) + + WireFormat::encoded_len(&self.pid) + + WireFormat::encoded_len(&self.fd_count) + + WireFormat::encoded_len(&self.cmdline) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.index.sbp_size(); - size += self.pid.sbp_size(); - size += self.fd_count.sbp_size(); - size += self.cmdline.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.index, buf); + WireFormat::write(&self.pid, buf); + WireFormat::write(&self.fd_count, buf); + WireFormat::write(&self.cmdline, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgLinuxProcessFdCount { + sender_id: None, + index: WireFormat::parse_unchecked(buf), + pid: WireFormat::parse_unchecked(buf), + fd_count: WireFormat::parse_unchecked(buf), + cmdline: WireFormat::parse_unchecked(buf), + } } } @@ -538,86 +490,70 @@ impl crate::serialize::SbpSerialize for MsgLinuxProcessFdCount { /// /// Summary of open file descriptors on the system. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgLinuxProcessFdSummary { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// count of total FDs open on the system + #[cfg_attr(feature = "serde", serde(rename(serialize = "sys_fd_count")))] pub sys_fd_count: u32, /// A null delimited list of strings which alternates between a string /// representation of the process count and the file name whose count it /// being reported. That is, in C string syntax /// "32\0/var/log/syslog\012\0/tmp/foo\0" with the end of the list being 2 /// NULL terminators in a row. - pub most_opened: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "most_opened")))] + pub most_opened: SbpString, DoubleNullTerminated>, } -impl MsgLinuxProcessFdSummary { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgLinuxProcessFdSummary{ - sender_id: None, - sys_fd_count: _buf.read_u32::()?, - most_opened: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgLinuxProcessFdSummary { + const MESSAGE_TYPE: u16 = 32519; + const MESSAGE_NAME: &'static str = "MSG_LINUX_PROCESS_FD_SUMMARY"; } -impl super::SBPMessage for MsgLinuxProcessFdSummary { - fn get_message_name(&self) -> &'static str { - "MSG_LINUX_PROCESS_FD_SUMMARY" - } - fn get_message_type(&self) -> u16 { - 32519 +impl SbpMessage for MsgLinuxProcessFdSummary { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgLinuxProcessFdSummary { - const MESSAGE_TYPE: u16 = 32519; - const MESSAGE_NAME: &'static str = "MSG_LINUX_PROCESS_FD_SUMMARY"; -} -impl TryFrom for MsgLinuxProcessFdSummary { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgLinuxProcessFdSummary { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgLinuxProcessFdSummary(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgLinuxProcessFdSummary(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgLinuxProcessFdSummary { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sys_fd_count.append_to_sbp_buffer(buf); - self.most_opened.append_to_sbp_buffer(buf); +impl WireFormat for MsgLinuxProcessFdSummary { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + , DoubleNullTerminated> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sys_fd_count) + WireFormat::encoded_len(&self.most_opened) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sys_fd_count.sbp_size(); - size += self.most_opened.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sys_fd_count, buf); + WireFormat::write(&self.most_opened, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgLinuxProcessFdSummary { + sender_id: None, + sys_fd_count: WireFormat::parse_unchecked(buf), + most_opened: WireFormat::parse_unchecked(buf), + } } } @@ -625,106 +561,99 @@ impl crate::serialize::SbpSerialize for MsgLinuxProcessFdSummary { /// /// Top 10 list of processes with high socket counts. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgLinuxProcessSocketCounts { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// sequence of this status message, values from 0-9 + #[cfg_attr(feature = "serde", serde(rename(serialize = "index")))] pub index: u8, /// the PID of the process in question + #[cfg_attr(feature = "serde", serde(rename(serialize = "pid")))] pub pid: u16, /// the number of sockets the process is using + #[cfg_attr(feature = "serde", serde(rename(serialize = "socket_count")))] pub socket_count: u16, /// A bitfield indicating the socket types used: 0x1 (tcp), 0x2 (udp), 0x4 /// (unix stream), 0x8 (unix dgram), 0x10 (netlink), and 0x8000 (unknown) + #[cfg_attr(feature = "serde", serde(rename(serialize = "socket_types")))] pub socket_types: u16, /// A bitfield indicating the socket states: 0x1 (established), 0x2 (syn- /// sent), 0x4 (syn-recv), 0x8 (fin-wait-1), 0x10 (fin-wait-2), 0x20 (time- /// wait), 0x40 (closed), 0x80 (close-wait), 0x100 (last-ack), 0x200 /// (listen), 0x400 (closing), 0x800 (unconnected), and 0x8000 (unknown) + #[cfg_attr(feature = "serde", serde(rename(serialize = "socket_states")))] pub socket_states: u16, /// the command line of the process in question - pub cmdline: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] + pub cmdline: SbpString, Unterminated>, } -impl MsgLinuxProcessSocketCounts { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgLinuxProcessSocketCounts{ - sender_id: None, - index: _buf.read_u8()?, - pid: _buf.read_u16::()?, - socket_count: _buf.read_u16::()?, - socket_types: _buf.read_u16::()?, - socket_states: _buf.read_u16::()?, - cmdline: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgLinuxProcessSocketCounts { + const MESSAGE_TYPE: u16 = 32515; + const MESSAGE_NAME: &'static str = "MSG_LINUX_PROCESS_SOCKET_COUNTS"; } -impl super::SBPMessage for MsgLinuxProcessSocketCounts { - fn get_message_name(&self) -> &'static str { - "MSG_LINUX_PROCESS_SOCKET_COUNTS" - } - fn get_message_type(&self) -> u16 { - 32515 +impl SbpMessage for MsgLinuxProcessSocketCounts { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgLinuxProcessSocketCounts { - const MESSAGE_TYPE: u16 = 32515; - const MESSAGE_NAME: &'static str = "MSG_LINUX_PROCESS_SOCKET_COUNTS"; } -impl TryFrom for MsgLinuxProcessSocketCounts { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgLinuxProcessSocketCounts { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgLinuxProcessSocketCounts(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgLinuxProcessSocketCounts(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgLinuxProcessSocketCounts { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.index.append_to_sbp_buffer(buf); - self.pid.append_to_sbp_buffer(buf); - self.socket_count.append_to_sbp_buffer(buf); - self.socket_types.append_to_sbp_buffer(buf); - self.socket_states.append_to_sbp_buffer(buf); - self.cmdline.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.index.sbp_size(); - size += self.pid.sbp_size(); - size += self.socket_count.sbp_size(); - size += self.socket_types.sbp_size(); - size += self.socket_states.sbp_size(); - size += self.cmdline.sbp_size(); - size +impl WireFormat for MsgLinuxProcessSocketCounts { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + , Unterminated> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.index) + + WireFormat::encoded_len(&self.pid) + + WireFormat::encoded_len(&self.socket_count) + + WireFormat::encoded_len(&self.socket_types) + + WireFormat::encoded_len(&self.socket_states) + + WireFormat::encoded_len(&self.cmdline) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.index, buf); + WireFormat::write(&self.pid, buf); + WireFormat::write(&self.socket_count, buf); + WireFormat::write(&self.socket_types, buf); + WireFormat::write(&self.socket_states, buf); + WireFormat::write(&self.cmdline, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgLinuxProcessSocketCounts { + sender_id: None, + index: WireFormat::parse_unchecked(buf), + pid: WireFormat::parse_unchecked(buf), + socket_count: WireFormat::parse_unchecked(buf), + socket_types: WireFormat::parse_unchecked(buf), + socket_states: WireFormat::parse_unchecked(buf), + cmdline: WireFormat::parse_unchecked(buf), + } } } @@ -732,117 +661,114 @@ impl crate::serialize::SbpSerialize for MsgLinuxProcessSocketCounts { /// /// Top 10 list of sockets with deep queues. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgLinuxProcessSocketQueues { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// sequence of this status message, values from 0-9 + #[cfg_attr(feature = "serde", serde(rename(serialize = "index")))] pub index: u8, /// the PID of the process in question + #[cfg_attr(feature = "serde", serde(rename(serialize = "pid")))] pub pid: u16, /// the total amount of receive data queued for this process + #[cfg_attr(feature = "serde", serde(rename(serialize = "recv_queued")))] pub recv_queued: u16, /// the total amount of send data queued for this process + #[cfg_attr(feature = "serde", serde(rename(serialize = "send_queued")))] pub send_queued: u16, /// A bitfield indicating the socket types used: 0x1 (tcp), 0x2 (udp), 0x4 /// (unix stream), 0x8 (unix dgram), 0x10 (netlink), and 0x8000 (unknown) + #[cfg_attr(feature = "serde", serde(rename(serialize = "socket_types")))] pub socket_types: u16, /// A bitfield indicating the socket states: 0x1 (established), 0x2 (syn- /// sent), 0x4 (syn-recv), 0x8 (fin-wait-1), 0x10 (fin-wait-2), 0x20 (time- /// wait), 0x40 (closed), 0x80 (close-wait), 0x100 (last-ack), 0x200 /// (listen), 0x400 (closing), 0x800 (unconnected), and 0x8000 (unknown) + #[cfg_attr(feature = "serde", serde(rename(serialize = "socket_states")))] pub socket_states: u16, /// Address of the largest queue, remote or local depending on the /// directionality of the connection. - pub address_of_largest: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "address_of_largest")))] + pub address_of_largest: SbpString<[u8; 64], Unterminated>, /// the command line of the process in question - pub cmdline: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] + pub cmdline: SbpString, Unterminated>, } -impl MsgLinuxProcessSocketQueues { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgLinuxProcessSocketQueues{ - sender_id: None, - index: _buf.read_u8()?, - pid: _buf.read_u16::()?, - recv_queued: _buf.read_u16::()?, - send_queued: _buf.read_u16::()?, - socket_types: _buf.read_u16::()?, - socket_states: _buf.read_u16::()?, - address_of_largest: crate::parser::read_string_limit(_buf, 64)?, - cmdline: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgLinuxProcessSocketQueues { + const MESSAGE_TYPE: u16 = 32516; + const MESSAGE_NAME: &'static str = "MSG_LINUX_PROCESS_SOCKET_QUEUES"; } -impl super::SBPMessage for MsgLinuxProcessSocketQueues { - fn get_message_name(&self) -> &'static str { - "MSG_LINUX_PROCESS_SOCKET_QUEUES" - } - fn get_message_type(&self) -> u16 { - 32516 +impl SbpMessage for MsgLinuxProcessSocketQueues { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgLinuxProcessSocketQueues { - const MESSAGE_TYPE: u16 = 32516; - const MESSAGE_NAME: &'static str = "MSG_LINUX_PROCESS_SOCKET_QUEUES"; } -impl TryFrom for MsgLinuxProcessSocketQueues { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgLinuxProcessSocketQueues { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgLinuxProcessSocketQueues(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgLinuxProcessSocketQueues(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgLinuxProcessSocketQueues { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.index.append_to_sbp_buffer(buf); - self.pid.append_to_sbp_buffer(buf); - self.recv_queued.append_to_sbp_buffer(buf); - self.send_queued.append_to_sbp_buffer(buf); - self.socket_types.append_to_sbp_buffer(buf); - self.socket_states.append_to_sbp_buffer(buf); - self.address_of_largest.append_to_sbp_buffer(buf); - self.cmdline.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.index.sbp_size(); - size += self.pid.sbp_size(); - size += self.recv_queued.sbp_size(); - size += self.send_queued.sbp_size(); - size += self.socket_types.sbp_size(); - size += self.socket_states.sbp_size(); - size += self.address_of_largest.sbp_size(); - size += self.cmdline.sbp_size(); - size +impl WireFormat for MsgLinuxProcessSocketQueues { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN + + , Unterminated> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.index) + + WireFormat::encoded_len(&self.pid) + + WireFormat::encoded_len(&self.recv_queued) + + WireFormat::encoded_len(&self.send_queued) + + WireFormat::encoded_len(&self.socket_types) + + WireFormat::encoded_len(&self.socket_states) + + WireFormat::encoded_len(&self.address_of_largest) + + WireFormat::encoded_len(&self.cmdline) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.index, buf); + WireFormat::write(&self.pid, buf); + WireFormat::write(&self.recv_queued, buf); + WireFormat::write(&self.send_queued, buf); + WireFormat::write(&self.socket_types, buf); + WireFormat::write(&self.socket_states, buf); + WireFormat::write(&self.address_of_largest, buf); + WireFormat::write(&self.cmdline, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgLinuxProcessSocketQueues { + sender_id: None, + index: WireFormat::parse_unchecked(buf), + pid: WireFormat::parse_unchecked(buf), + recv_queued: WireFormat::parse_unchecked(buf), + send_queued: WireFormat::parse_unchecked(buf), + socket_types: WireFormat::parse_unchecked(buf), + socket_states: WireFormat::parse_unchecked(buf), + address_of_largest: WireFormat::parse_unchecked(buf), + cmdline: WireFormat::parse_unchecked(buf), + } } } @@ -850,96 +776,85 @@ impl crate::serialize::SbpSerialize for MsgLinuxProcessSocketQueues { /// /// Summaries the socket usage across the system. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgLinuxSocketUsage { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// average socket queue depths across all sockets on the system + #[cfg_attr(feature = "serde", serde(rename(serialize = "avg_queue_depth")))] pub avg_queue_depth: u32, /// the max queue depth seen within the reporting period + #[cfg_attr(feature = "serde", serde(rename(serialize = "max_queue_depth")))] pub max_queue_depth: u32, /// A count for each socket type reported in the `socket_types_reported` /// field, the first entry corresponds to the first enabled bit in /// `types_reported`. - pub socket_state_counts: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "socket_state_counts")))] + pub socket_state_counts: [u16; 16], /// A count for each socket type reported in the `socket_types_reported` /// field, the first entry corresponds to the first enabled bit in /// `types_reported`. - pub socket_type_counts: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "socket_type_counts")))] + pub socket_type_counts: [u16; 16], } -impl MsgLinuxSocketUsage { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgLinuxSocketUsage{ - sender_id: None, - avg_queue_depth: _buf.read_u32::()?, - max_queue_depth: _buf.read_u32::()?, - socket_state_counts: crate::parser::read_u16_array_limit(_buf, 16)?, - socket_type_counts: crate::parser::read_u16_array_limit(_buf, 16)?, - } ) - } +impl ConcreteMessage for MsgLinuxSocketUsage { + const MESSAGE_TYPE: u16 = 32517; + const MESSAGE_NAME: &'static str = "MSG_LINUX_SOCKET_USAGE"; } -impl super::SBPMessage for MsgLinuxSocketUsage { - fn get_message_name(&self) -> &'static str { - "MSG_LINUX_SOCKET_USAGE" - } - fn get_message_type(&self) -> u16 { - 32517 +impl SbpMessage for MsgLinuxSocketUsage { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgLinuxSocketUsage { - const MESSAGE_TYPE: u16 = 32517; - const MESSAGE_NAME: &'static str = "MSG_LINUX_SOCKET_USAGE"; -} -impl TryFrom for MsgLinuxSocketUsage { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgLinuxSocketUsage { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgLinuxSocketUsage(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgLinuxSocketUsage(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgLinuxSocketUsage { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.avg_queue_depth.append_to_sbp_buffer(buf); - self.max_queue_depth.append_to_sbp_buffer(buf); - self.socket_state_counts.append_to_sbp_buffer(buf); - self.socket_type_counts.append_to_sbp_buffer(buf); +impl WireFormat for MsgLinuxSocketUsage { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + <[u16; 16] as WireFormat>::MIN_ENCODED_LEN + + <[u16; 16] as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.avg_queue_depth) + + WireFormat::encoded_len(&self.max_queue_depth) + + WireFormat::encoded_len(&self.socket_state_counts) + + WireFormat::encoded_len(&self.socket_type_counts) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.avg_queue_depth.sbp_size(); - size += self.max_queue_depth.sbp_size(); - size += self.socket_state_counts.sbp_size(); - size += self.socket_type_counts.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.avg_queue_depth, buf); + WireFormat::write(&self.max_queue_depth, buf); + WireFormat::write(&self.socket_state_counts, buf); + WireFormat::write(&self.socket_type_counts, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgLinuxSocketUsage { + sender_id: None, + avg_queue_depth: WireFormat::parse_unchecked(buf), + max_queue_depth: WireFormat::parse_unchecked(buf), + socket_state_counts: WireFormat::parse_unchecked(buf), + socket_type_counts: WireFormat::parse_unchecked(buf), + } } } @@ -948,112 +863,109 @@ impl crate::serialize::SbpSerialize for MsgLinuxSocketUsage { /// This presents a summary of CPU and memory utilization, including a /// timestamp. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgLinuxSysState { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// total system memory, in MiB + #[cfg_attr(feature = "serde", serde(rename(serialize = "mem_total")))] pub mem_total: u16, /// percent of CPU used, expressed as a fraction of 256 + #[cfg_attr(feature = "serde", serde(rename(serialize = "pcpu")))] pub pcpu: u8, /// percent of memory used, expressed as a fraction of 256 + #[cfg_attr(feature = "serde", serde(rename(serialize = "pmem")))] pub pmem: u8, /// number of processes that started during collection phase + #[cfg_attr(feature = "serde", serde(rename(serialize = "procs_starting")))] pub procs_starting: u16, /// number of processes that stopped during collection phase + #[cfg_attr(feature = "serde", serde(rename(serialize = "procs_stopping")))] pub procs_stopping: u16, /// the count of processes on the system + #[cfg_attr(feature = "serde", serde(rename(serialize = "pid_count")))] pub pid_count: u16, /// timestamp of message, refer to flags field for how to interpret + #[cfg_attr(feature = "serde", serde(rename(serialize = "time")))] pub time: u32, /// flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgLinuxSysState { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgLinuxSysState{ - sender_id: None, - mem_total: _buf.read_u16::()?, - pcpu: _buf.read_u8()?, - pmem: _buf.read_u8()?, - procs_starting: _buf.read_u16::()?, - procs_stopping: _buf.read_u16::()?, - pid_count: _buf.read_u16::()?, - time: _buf.read_u32::()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgLinuxSysState { + const MESSAGE_TYPE: u16 = 32522; + const MESSAGE_NAME: &'static str = "MSG_LINUX_SYS_STATE"; } -impl super::SBPMessage for MsgLinuxSysState { - fn get_message_name(&self) -> &'static str { - "MSG_LINUX_SYS_STATE" - } - fn get_message_type(&self) -> u16 { - 32522 +impl SbpMessage for MsgLinuxSysState { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgLinuxSysState { - const MESSAGE_TYPE: u16 = 32522; - const MESSAGE_NAME: &'static str = "MSG_LINUX_SYS_STATE"; -} -impl TryFrom for MsgLinuxSysState { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgLinuxSysState { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgLinuxSysState(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgLinuxSysState(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgLinuxSysState { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.mem_total.append_to_sbp_buffer(buf); - self.pcpu.append_to_sbp_buffer(buf); - self.pmem.append_to_sbp_buffer(buf); - self.procs_starting.append_to_sbp_buffer(buf); - self.procs_stopping.append_to_sbp_buffer(buf); - self.pid_count.append_to_sbp_buffer(buf); - self.time.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.mem_total.sbp_size(); - size += self.pcpu.sbp_size(); - size += self.pmem.sbp_size(); - size += self.procs_starting.sbp_size(); - size += self.procs_stopping.sbp_size(); - size += self.pid_count.sbp_size(); - size += self.time.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgLinuxSysState { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.mem_total) + + WireFormat::encoded_len(&self.pcpu) + + WireFormat::encoded_len(&self.pmem) + + WireFormat::encoded_len(&self.procs_starting) + + WireFormat::encoded_len(&self.procs_stopping) + + WireFormat::encoded_len(&self.pid_count) + + WireFormat::encoded_len(&self.time) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.mem_total, buf); + WireFormat::write(&self.pcpu, buf); + WireFormat::write(&self.pmem, buf); + WireFormat::write(&self.procs_starting, buf); + WireFormat::write(&self.procs_stopping, buf); + WireFormat::write(&self.pid_count, buf); + WireFormat::write(&self.time, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgLinuxSysState { + sender_id: None, + mem_total: WireFormat::parse_unchecked(buf), + pcpu: WireFormat::parse_unchecked(buf), + pmem: WireFormat::parse_unchecked(buf), + procs_starting: WireFormat::parse_unchecked(buf), + procs_stopping: WireFormat::parse_unchecked(buf), + pid_count: WireFormat::parse_unchecked(buf), + time: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -1061,101 +973,94 @@ impl crate::serialize::SbpSerialize for MsgLinuxSysState { /// /// This presents a summary of CPU and memory utilization. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgLinuxSysStateDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// total system memory + #[cfg_attr(feature = "serde", serde(rename(serialize = "mem_total")))] pub mem_total: u16, /// percent of total cpu currently utilized + #[cfg_attr(feature = "serde", serde(rename(serialize = "pcpu")))] pub pcpu: u8, /// percent of total memory currently utilized + #[cfg_attr(feature = "serde", serde(rename(serialize = "pmem")))] pub pmem: u8, /// number of processes that started during collection phase + #[cfg_attr(feature = "serde", serde(rename(serialize = "procs_starting")))] pub procs_starting: u16, /// number of processes that stopped during collection phase + #[cfg_attr(feature = "serde", serde(rename(serialize = "procs_stopping")))] pub procs_stopping: u16, /// the count of processes on the system + #[cfg_attr(feature = "serde", serde(rename(serialize = "pid_count")))] pub pid_count: u16, } -impl MsgLinuxSysStateDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgLinuxSysStateDepA{ - sender_id: None, - mem_total: _buf.read_u16::()?, - pcpu: _buf.read_u8()?, - pmem: _buf.read_u8()?, - procs_starting: _buf.read_u16::()?, - procs_stopping: _buf.read_u16::()?, - pid_count: _buf.read_u16::()?, - } ) - } +impl ConcreteMessage for MsgLinuxSysStateDepA { + const MESSAGE_TYPE: u16 = 32514; + const MESSAGE_NAME: &'static str = "MSG_LINUX_SYS_STATE_DEP_A"; } -impl super::SBPMessage for MsgLinuxSysStateDepA { - fn get_message_name(&self) -> &'static str { - "MSG_LINUX_SYS_STATE_DEP_A" - } - fn get_message_type(&self) -> u16 { - 32514 +impl SbpMessage for MsgLinuxSysStateDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgLinuxSysStateDepA { - const MESSAGE_TYPE: u16 = 32514; - const MESSAGE_NAME: &'static str = "MSG_LINUX_SYS_STATE_DEP_A"; -} -impl TryFrom for MsgLinuxSysStateDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgLinuxSysStateDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgLinuxSysStateDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgLinuxSysStateDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgLinuxSysStateDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.mem_total.append_to_sbp_buffer(buf); - self.pcpu.append_to_sbp_buffer(buf); - self.pmem.append_to_sbp_buffer(buf); - self.procs_starting.append_to_sbp_buffer(buf); - self.procs_stopping.append_to_sbp_buffer(buf); - self.pid_count.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.mem_total.sbp_size(); - size += self.pcpu.sbp_size(); - size += self.pmem.sbp_size(); - size += self.procs_starting.sbp_size(); - size += self.procs_stopping.sbp_size(); - size += self.pid_count.sbp_size(); - size +impl WireFormat for MsgLinuxSysStateDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.mem_total) + + WireFormat::encoded_len(&self.pcpu) + + WireFormat::encoded_len(&self.pmem) + + WireFormat::encoded_len(&self.procs_starting) + + WireFormat::encoded_len(&self.procs_stopping) + + WireFormat::encoded_len(&self.pid_count) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.mem_total, buf); + WireFormat::write(&self.pcpu, buf); + WireFormat::write(&self.pmem, buf); + WireFormat::write(&self.procs_starting, buf); + WireFormat::write(&self.procs_stopping, buf); + WireFormat::write(&self.pid_count, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgLinuxSysStateDepA { + sender_id: None, + mem_total: WireFormat::parse_unchecked(buf), + pcpu: WireFormat::parse_unchecked(buf), + pmem: WireFormat::parse_unchecked(buf), + procs_starting: WireFormat::parse_unchecked(buf), + procs_stopping: WireFormat::parse_unchecked(buf), + pid_count: WireFormat::parse_unchecked(buf), + } } } diff --git a/rust/sbp/src/messages/logging.rs b/rust/sbp/src/messages/logging.rs index 6628257dbc..81dded4919 100644 --- a/rust/sbp/src/messages/logging.rs +++ b/rust/sbp/src/messages/logging.rs @@ -14,16 +14,7 @@ //****************************************************************************/ //! Logging and debugging messages from the device. -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; +use super::lib::*; /// Wrapper for FWD a separate stream of information over SBP /// @@ -36,87 +27,74 @@ use crate::SbpString; /// forwarded msg contains. Protocol 0 represents SBP and the remaining values /// are implementation defined. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgFwd { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// source identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "source")))] pub source: u8, /// protocol identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "protocol")))] pub protocol: u8, /// variable length wrapped binary message + #[cfg_attr(feature = "serde", serde(rename(serialize = "fwd_payload")))] pub fwd_payload: Vec, } -impl MsgFwd { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgFwd{ - sender_id: None, - source: _buf.read_u8()?, - protocol: _buf.read_u8()?, - fwd_payload: crate::parser::read_u8_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgFwd { + const MESSAGE_TYPE: u16 = 1026; + const MESSAGE_NAME: &'static str = "MSG_FWD"; } -impl super::SBPMessage for MsgFwd { - fn get_message_name(&self) -> &'static str { - "MSG_FWD" - } - fn get_message_type(&self) -> u16 { - 1026 +impl SbpMessage for MsgFwd { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgFwd { - const MESSAGE_TYPE: u16 = 1026; - const MESSAGE_NAME: &'static str = "MSG_FWD"; } -impl TryFrom for MsgFwd { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgFwd { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgFwd(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgFwd(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgFwd { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.source.append_to_sbp_buffer(buf); - self.protocol.append_to_sbp_buffer(buf); - self.fwd_payload.append_to_sbp_buffer(buf); +impl WireFormat for MsgFwd { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.source) + + WireFormat::encoded_len(&self.protocol) + + WireFormat::encoded_len(&self.fwd_payload) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.source.sbp_size(); - size += self.protocol.sbp_size(); - size += self.fwd_payload.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.source, buf); + WireFormat::write(&self.protocol, buf); + WireFormat::write(&self.fwd_payload, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgFwd { + sender_id: None, + source: WireFormat::parse_unchecked(buf), + protocol: WireFormat::parse_unchecked(buf), + fwd_payload: WireFormat::parse_unchecked(buf), + } } } @@ -126,82 +104,66 @@ impl crate::serialize::SbpSerialize for MsgFwd { /// containing errors, warnings and informational messages at ERROR, WARNING, /// DEBUG, INFO logging levels. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgLog { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Logging level + #[cfg_attr(feature = "serde", serde(rename(serialize = "level")))] pub level: u8, /// Human-readable string - pub text: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "text")))] + pub text: SbpString, Unterminated>, } -impl MsgLog { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgLog{ - sender_id: None, - level: _buf.read_u8()?, - text: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgLog { + const MESSAGE_TYPE: u16 = 1025; + const MESSAGE_NAME: &'static str = "MSG_LOG"; } -impl super::SBPMessage for MsgLog { - fn get_message_name(&self) -> &'static str { - "MSG_LOG" - } - fn get_message_type(&self) -> u16 { - 1025 +impl SbpMessage for MsgLog { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgLog { - const MESSAGE_TYPE: u16 = 1025; - const MESSAGE_NAME: &'static str = "MSG_LOG"; } -impl TryFrom for MsgLog { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgLog { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgLog(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgLog(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgLog { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.level.append_to_sbp_buffer(buf); - self.text.append_to_sbp_buffer(buf); +impl WireFormat for MsgLog { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + , Unterminated> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.level) + WireFormat::encoded_len(&self.text) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.level.sbp_size(); - size += self.text.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.level, buf); + WireFormat::write(&self.text, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgLog { + sender_id: None, + level: WireFormat::parse_unchecked(buf), + text: WireFormat::parse_unchecked(buf), + } } } @@ -209,76 +171,60 @@ impl crate::serialize::SbpSerialize for MsgLog { /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgPrintDep { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Human-readable string - pub text: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "text")))] + pub text: SbpString, Unterminated>, } -impl MsgPrintDep { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgPrintDep{ - sender_id: None, - text: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgPrintDep { + const MESSAGE_TYPE: u16 = 16; + const MESSAGE_NAME: &'static str = "MSG_PRINT_DEP"; } -impl super::SBPMessage for MsgPrintDep { - fn get_message_name(&self) -> &'static str { - "MSG_PRINT_DEP" - } - fn get_message_type(&self) -> u16 { - 16 +impl SbpMessage for MsgPrintDep { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgPrintDep { - const MESSAGE_TYPE: u16 = 16; - const MESSAGE_NAME: &'static str = "MSG_PRINT_DEP"; -} -impl TryFrom for MsgPrintDep { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgPrintDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgPrintDep(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgPrintDep(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgPrintDep { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.text.append_to_sbp_buffer(buf); +impl WireFormat for MsgPrintDep { + const MIN_ENCODED_LEN: usize = + , Unterminated> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.text) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.text.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.text, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgPrintDep { + sender_id: None, + text: WireFormat::parse_unchecked(buf), + } } } diff --git a/rust/sbp/src/messages/mag.rs b/rust/sbp/src/messages/mag.rs index 39a195437a..45ad4a1d7d 100644 --- a/rust/sbp/src/messages/mag.rs +++ b/rust/sbp/src/messages/mag.rs @@ -14,124 +14,103 @@ //****************************************************************************/ //! Magnetometer (mag) messages. -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; +use super::lib::*; /// Raw magnetometer data /// /// Raw data from the magnetometer. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgMagRaw { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Milliseconds since start of GPS week. If the high bit is set, the time /// is unknown or invalid. + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Milliseconds since start of GPS week, fractional part + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow_f")))] pub tow_f: u8, /// Magnetic field in the body frame X axis + #[cfg_attr(feature = "serde", serde(rename(serialize = "mag_x")))] pub mag_x: i16, /// Magnetic field in the body frame Y axis + #[cfg_attr(feature = "serde", serde(rename(serialize = "mag_y")))] pub mag_y: i16, /// Magnetic field in the body frame Z axis + #[cfg_attr(feature = "serde", serde(rename(serialize = "mag_z")))] pub mag_z: i16, } -impl MsgMagRaw { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgMagRaw{ - sender_id: None, - tow: _buf.read_u32::()?, - tow_f: _buf.read_u8()?, - mag_x: _buf.read_i16::()?, - mag_y: _buf.read_i16::()?, - mag_z: _buf.read_i16::()?, - } ) - } +impl ConcreteMessage for MsgMagRaw { + const MESSAGE_TYPE: u16 = 2306; + const MESSAGE_NAME: &'static str = "MSG_MAG_RAW"; } -impl super::SBPMessage for MsgMagRaw { - fn get_message_name(&self) -> &'static str { - "MSG_MAG_RAW" - } - fn get_message_type(&self) -> u16 { - 2306 +impl SbpMessage for MsgMagRaw { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgMagRaw { - const MESSAGE_TYPE: u16 = 2306; - const MESSAGE_NAME: &'static str = "MSG_MAG_RAW"; -} -impl TryFrom for MsgMagRaw { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgMagRaw { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgMagRaw(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgMagRaw(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgMagRaw { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.tow_f.append_to_sbp_buffer(buf); - self.mag_x.append_to_sbp_buffer(buf); - self.mag_y.append_to_sbp_buffer(buf); - self.mag_z.append_to_sbp_buffer(buf); +impl WireFormat for MsgMagRaw { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.tow_f) + + WireFormat::encoded_len(&self.mag_x) + + WireFormat::encoded_len(&self.mag_y) + + WireFormat::encoded_len(&self.mag_z) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.tow_f.sbp_size(); - size += self.mag_x.sbp_size(); - size += self.mag_y.sbp_size(); - size += self.mag_z.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.tow_f, buf); + WireFormat::write(&self.mag_x, buf); + WireFormat::write(&self.mag_y, buf); + WireFormat::write(&self.mag_z, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgMagRaw { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + tow_f: WireFormat::parse_unchecked(buf), + mag_x: WireFormat::parse_unchecked(buf), + mag_y: WireFormat::parse_unchecked(buf), + mag_z: WireFormat::parse_unchecked(buf), + } } } diff --git a/rust/sbp/src/messages/mod.rs b/rust/sbp/src/messages/mod.rs index 0363766a39..58b9efcd95 100644 --- a/rust/sbp/src/messages/mod.rs +++ b/rust/sbp/src/messages/mod.rs @@ -7,6 +7,7 @@ // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, // EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. +//! SBP message definitions. pub mod acquisition; pub mod bootload; pub mod ext_events; @@ -81,57 +82,54 @@ use self::logging::MsgLog; use self::logging::MsgPrintDep; use self::mag::MsgMagRaw; use self::navigation::MsgAgeCorrections; -use self::navigation::MsgBaselineECEF; -use self::navigation::MsgBaselineECEFDepA; +use self::navigation::MsgBaselineEcef; +use self::navigation::MsgBaselineEcefDepA; use self::navigation::MsgBaselineHeadingDepA; -use self::navigation::MsgBaselineNED; -use self::navigation::MsgBaselineNEDDepA; +use self::navigation::MsgBaselineNed; +use self::navigation::MsgBaselineNedDepA; use self::navigation::MsgDops; use self::navigation::MsgDopsDepA; -use self::navigation::MsgGPSTime; -use self::navigation::MsgGPSTimeDepA; -use self::navigation::MsgGPSTimeGnss; -use self::navigation::MsgPosECEF; -use self::navigation::MsgPosECEFCov; -use self::navigation::MsgPosECEFCovGnss; -use self::navigation::MsgPosECEFDepA; -use self::navigation::MsgPosECEFGnss; -use self::navigation::MsgPosLLH; -use self::navigation::MsgPosLLHAcc; -use self::navigation::MsgPosLLHCov; -use self::navigation::MsgPosLLHCovGnss; -use self::navigation::MsgPosLLHDepA; -use self::navigation::MsgPosLLHGnss; +use self::navigation::MsgGpsTime; +use self::navigation::MsgGpsTimeDepA; +use self::navigation::MsgGpsTimeGnss; +use self::navigation::MsgPosEcef; +use self::navigation::MsgPosEcefCov; +use self::navigation::MsgPosEcefCovGnss; +use self::navigation::MsgPosEcefDepA; +use self::navigation::MsgPosEcefGnss; +use self::navigation::MsgPosLlh; +use self::navigation::MsgPosLlhAcc; +use self::navigation::MsgPosLlhCov; +use self::navigation::MsgPosLlhCovGnss; +use self::navigation::MsgPosLlhDepA; +use self::navigation::MsgPosLlhGnss; use self::navigation::MsgProtectionLevel; use self::navigation::MsgProtectionLevelDepA; use self::navigation::MsgUtcTime; use self::navigation::MsgUtcTimeGnss; use self::navigation::MsgVelBody; -use self::navigation::MsgVelECEF; -use self::navigation::MsgVelECEFCov; -use self::navigation::MsgVelECEFCovGnss; -use self::navigation::MsgVelECEFDepA; -use self::navigation::MsgVelECEFGnss; -use self::navigation::MsgVelNED; -use self::navigation::MsgVelNEDCov; -use self::navigation::MsgVelNEDCovGnss; -use self::navigation::MsgVelNEDDepA; -use self::navigation::MsgVelNEDGnss; +use self::navigation::MsgVelEcef; +use self::navigation::MsgVelEcefCov; +use self::navigation::MsgVelEcefCovGnss; +use self::navigation::MsgVelEcefDepA; +use self::navigation::MsgVelEcefGnss; +use self::navigation::MsgVelNed; +use self::navigation::MsgVelNedCov; +use self::navigation::MsgVelNedCovGnss; +use self::navigation::MsgVelNedDepA; +use self::navigation::MsgVelNedGnss; use self::ndb::MsgNdbEvent; -use self::observation::MsgAlmanacGPS; -use self::observation::MsgAlmanacGPSDep; use self::observation::MsgAlmanacGlo; use self::observation::MsgAlmanacGloDep; -use self::observation::MsgBasePosECEF; -use self::observation::MsgBasePosLLH; +use self::observation::MsgAlmanacGps; +use self::observation::MsgAlmanacGpsDep; +use self::observation::MsgBasePosEcef; +use self::observation::MsgBasePosLlh; use self::observation::MsgEphemerisBds; use self::observation::MsgEphemerisDepA; use self::observation::MsgEphemerisDepB; use self::observation::MsgEphemerisDepC; use self::observation::MsgEphemerisDepD; -use self::observation::MsgEphemerisGPS; -use self::observation::MsgEphemerisGPSDepE; -use self::observation::MsgEphemerisGPSDepF; use self::observation::MsgEphemerisGal; use self::observation::MsgEphemerisGalDepA; use self::observation::MsgEphemerisGlo; @@ -139,6 +137,9 @@ use self::observation::MsgEphemerisGloDepA; use self::observation::MsgEphemerisGloDepB; use self::observation::MsgEphemerisGloDepC; use self::observation::MsgEphemerisGloDepD; +use self::observation::MsgEphemerisGps; +use self::observation::MsgEphemerisGpsDepE; +use self::observation::MsgEphemerisGpsDepF; use self::observation::MsgEphemerisQzss; use self::observation::MsgEphemerisSbas; use self::observation::MsgEphemerisSbasDepA; @@ -155,7 +156,7 @@ use self::observation::MsgObsDepB; use self::observation::MsgObsDepC; use self::observation::MsgOsr; use self::observation::MsgSvAzEl; -use self::observation::MsgSvConfigurationGPSDep; +use self::observation::MsgSvConfigurationGpsDep; use self::orientation::MsgAngularRate; use self::orientation::MsgBaselineHeading; use self::orientation::MsgOrientEuler; @@ -235,2517 +236,2327 @@ use self::user::MsgUserData; use self::vehicle::MsgOdometry; use self::vehicle::MsgWheeltick; -use crate::serialize::SbpSerialize; +mod lib { + //! Common imports so we can just `use super::lib::*` in all the message files -pub trait SBPMessage: SbpSerialize { - fn get_message_name(&self) -> &'static str; - fn get_message_type(&self) -> u16; - fn get_sender_id(&self) -> Option; + pub use std::convert::{TryFrom, TryInto}; + + pub use crate::sbp_string::{ + DoubleNullTerminated, Multipart, NullTerminated, SbpString, Unterminated, + }; + pub use crate::wire_format::{PayloadParseError, WireFormat}; + + #[cfg(feature = "swiftnav")] + pub use crate::time; + + pub use super::{ConcreteMessage, Sbp, SbpMessage, TryFromSbpError}; +} + +use lib::*; + +/// Common functionality available to all SBP messages. +pub trait SbpMessage: WireFormat + Clone + Sized { + /// Get the message name. + fn message_name(&self) -> &'static str; + /// Get the message type. + fn message_type(&self) -> u16; + /// Get the sender_id if it is set. + fn sender_id(&self) -> Option; + /// Set the sender id. fn set_sender_id(&mut self, new_id: u16); - fn to_frame(&self) -> std::result::Result, crate::FramerError>; - fn write_frame(&self, buf: &mut Vec) -> std::result::Result<(), crate::FramerError>; + /// Get the GPS time associated with the message. #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { None } } -pub trait ConcreteMessage: - SBPMessage + std::convert::TryFrom + Clone + Sized -{ +/// Implemented by messages who's message name and type are known at compile time. +/// This is everything that implements [SbpMessage] except for [Sbp]. +pub trait ConcreteMessage: SbpMessage + TryFrom { + /// The message type. const MESSAGE_TYPE: u16; + /// The message name. const MESSAGE_NAME: &'static str; } +/// The error returned when using [TryFrom] to convert [Sbp] to the wrong message type. #[derive(Debug, Clone)] -pub struct TryFromSBPError; +pub struct TryFromSbpError; -impl std::fmt::Display for TryFromSBPError { +impl std::fmt::Display for TryFromSbpError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "invalid message type for conversion") } } -impl std::error::Error for TryFromSBPError {} +impl std::error::Error for TryFromSbpError {} -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize), serde(untagged))] +/// Represents any SBP message. +#[cfg_attr(feature = "serde", derive(serde::Serialize), serde(untagged))] #[derive(Debug, Clone)] -pub enum SBP { +#[non_exhaustive] +pub enum Sbp { + /// Deprecated MsgPrintDep(MsgPrintDep), + /// Deprecated MsgTrackingStateDetailedDep(MsgTrackingStateDetailedDep), + /// Deprecated MsgTrackingStateDepB(MsgTrackingStateDepB), + /// Deprecated MsgAcqResultDepB(MsgAcqResultDepB), + /// Deprecated MsgAcqResultDepA(MsgAcqResultDepA), + /// Deprecated MsgTrackingStateDepA(MsgTrackingStateDepA), + /// State of an RTOS thread MsgThreadState(MsgThreadState), + /// Deprecated MsgUartStateDepa(MsgUartStateDepa), + /// State of the Integer Ambiguity Resolution (IAR) process MsgIarState(MsgIarState), + /// Deprecated MsgEphemerisDepA(MsgEphemerisDepA), + /// Deprecated MsgMaskSatelliteDep(MsgMaskSatelliteDep), + /// Deprecated MsgTrackingIqDepA(MsgTrackingIqDepA), + /// State of the UART channels MsgUartState(MsgUartState), + /// Deprecated MsgAcqSvProfileDep(MsgAcqSvProfileDep), + /// Deprecated MsgAcqResultDepC(MsgAcqResultDepC), + /// Detailed signal tracking channel states. DEPRECATED MsgTrackingStateDetailedDepA(MsgTrackingStateDetailedDepA), + /// Reset IAR filters (host => Piksi) MsgResetFilters(MsgResetFilters), + /// Deprecated MsgInitBaseDep(MsgInitBaseDep), + /// Mask a satellite from use in Piksi subsystems MsgMaskSatellite(MsgMaskSatellite), + /// Tracking channel correlations MsgTrackingIqDepB(MsgTrackingIqDepB), + /// Tracking channel correlations MsgTrackingIq(MsgTrackingIq), + /// Acquisition perfomance measurement and debug MsgAcqSvProfile(MsgAcqSvProfile), + /// Satellite acquisition result MsgAcqResult(MsgAcqResult), + /// Signal tracking channel states MsgTrackingState(MsgTrackingState), + /// Deprecated MsgObsDepB(MsgObsDepB), - MsgBasePosLLH(MsgBasePosLLH), + /// Base station position + MsgBasePosLlh(MsgBasePosLlh), + /// Deprecated MsgObsDepA(MsgObsDepA), + /// Deprecated MsgEphemerisDepB(MsgEphemerisDepB), + /// Satellite broadcast ephemeris MsgEphemerisDepC(MsgEphemerisDepC), - MsgBasePosECEF(MsgBasePosECEF), + /// Base station position in ECEF + MsgBasePosEcef(MsgBasePosEcef), + /// Deprecated MsgObsDepC(MsgObsDepC), + /// GPS satellite observations MsgObs(MsgObs), + /// Deprecated MsgSpecanDep(MsgSpecanDep), + /// Spectrum analyzer MsgSpecan(MsgSpecan), + /// Measurement Engine signal tracking channel states MsgMeasurementState(MsgMeasurementState), + /// Send GPS time from host (host => Piksi) MsgSetTime(MsgSetTime), + /// Legacy message to load satellite almanac (host => Piksi) MsgAlmanac(MsgAlmanac), - MsgAlmanacGPSDep(MsgAlmanacGPSDep), + /// Satellite broadcast ephemeris for GPS + MsgAlmanacGpsDep(MsgAlmanacGpsDep), + /// Satellite broadcast ephemeris for GLO MsgAlmanacGloDep(MsgAlmanacGloDep), - MsgAlmanacGPS(MsgAlmanacGPS), + /// Satellite broadcast ephemeris for GPS + MsgAlmanacGps(MsgAlmanacGps), + /// Satellite broadcast ephemeris for GLO MsgAlmanacGlo(MsgAlmanacGlo), + /// GLONASS L1/L2 Code-Phase biases MsgGloBiases(MsgGloBiases), + /// Satellite broadcast ephemeris MsgEphemerisDepD(MsgEphemerisDepD), - MsgEphemerisGPSDepE(MsgEphemerisGPSDepE), + /// Satellite broadcast ephemeris for GPS + MsgEphemerisGpsDepE(MsgEphemerisGpsDepE), + /// Satellite broadcast ephemeris for SBAS MsgEphemerisSbasDepA(MsgEphemerisSbasDepA), + /// Satellite broadcast ephemeris for GLO MsgEphemerisGloDepA(MsgEphemerisGloDepA), + /// Deprecated MsgEphemerisSbasDepB(MsgEphemerisSbasDepB), + /// Satellite broadcast ephemeris for GLO MsgEphemerisGloDepB(MsgEphemerisGloDepB), - MsgEphemerisGPSDepF(MsgEphemerisGPSDepF), + /// Deprecated + MsgEphemerisGpsDepF(MsgEphemerisGpsDepF), + /// Satellite broadcast ephemeris for GLO MsgEphemerisGloDepC(MsgEphemerisGloDepC), + /// Deprecated MsgEphemerisGloDepD(MsgEphemerisGloDepD), + /// Satellite broadcast ephemeris for BDS MsgEphemerisBds(MsgEphemerisBds), - MsgEphemerisGPS(MsgEphemerisGPS), + /// Satellite broadcast ephemeris for GPS + MsgEphemerisGps(MsgEphemerisGps), + /// Satellite broadcast ephemeris for GLO MsgEphemerisGlo(MsgEphemerisGlo), + /// Satellite broadcast ephemeris for SBAS MsgEphemerisSbas(MsgEphemerisSbas), + /// Satellite broadcast ephemeris for Galileo MsgEphemerisGal(MsgEphemerisGal), + /// Satellite broadcast ephemeris for QZSS MsgEphemerisQzss(MsgEphemerisQzss), + /// Iono corrections MsgIono(MsgIono), - MsgSvConfigurationGPSDep(MsgSvConfigurationGPSDep), + /// L2C capability mask + MsgSvConfigurationGpsDep(MsgSvConfigurationGpsDep), + /// Group Delay MsgGroupDelayDepA(MsgGroupDelayDepA), + /// Group Delay MsgGroupDelayDepB(MsgGroupDelayDepB), + /// Group Delay MsgGroupDelay(MsgGroupDelay), + /// Deprecated MsgEphemerisGalDepA(MsgEphemerisGalDepA), + /// GNSS capabilities MsgGnssCapb(MsgGnssCapb), + /// Satellite azimuths and elevations MsgSvAzEl(MsgSvAzEl), + /// Write device configuration settings (host => device) MsgSettingsWrite(MsgSettingsWrite), + /// Save settings to flash (host => device) MsgSettingsSave(MsgSettingsSave), + /// Read setting by direct index (host => device) MsgSettingsReadByIndexReq(MsgSettingsReadByIndexReq), + /// File read from the file system (host <= device) MsgFileioReadResp(MsgFileioReadResp), + /// Read device configuration settings (host => device) MsgSettingsReadReq(MsgSettingsReadReq), + /// Read device configuration settings (host <= device) MsgSettingsReadResp(MsgSettingsReadResp), + /// Finished reading settings (host <= device) MsgSettingsReadByIndexDone(MsgSettingsReadByIndexDone), + /// Read setting by direct index (host <= device) MsgSettingsReadByIndexResp(MsgSettingsReadByIndexResp), + /// Read file from the file system (host => device) MsgFileioReadReq(MsgFileioReadReq), + /// List files in a directory (host => device) MsgFileioReadDirReq(MsgFileioReadDirReq), + /// Files listed in a directory (host <= device) MsgFileioReadDirResp(MsgFileioReadDirResp), + /// File written to (host <= device) MsgFileioWriteResp(MsgFileioWriteResp), + /// Delete a file from the file system (host => device) MsgFileioRemove(MsgFileioRemove), + /// Write to file (host => device) MsgFileioWriteReq(MsgFileioWriteReq), + /// Register setting and default value (device => host) MsgSettingsRegister(MsgSettingsRegister), + /// Acknowledgement with status of MSG_SETTINGS_WRITE MsgSettingsWriteResp(MsgSettingsWriteResp), + /// Deprecated MsgBootloaderHandshakeDepA(MsgBootloaderHandshakeDepA), + /// Bootloader jump to application (host => device) MsgBootloaderJumpToApp(MsgBootloaderJumpToApp), + /// Reset the device (host => Piksi) MsgResetDep(MsgResetDep), + /// Bootloading handshake request (host => device) MsgBootloaderHandshakeReq(MsgBootloaderHandshakeReq), + /// Bootloading handshake response (host <= device) MsgBootloaderHandshakeResp(MsgBootloaderHandshakeResp), + /// Device temperature and voltage levels MsgDeviceMonitor(MsgDeviceMonitor), + /// Reset the device (host => Piksi) MsgReset(MsgReset), + /// Execute a command (host => device) MsgCommandReq(MsgCommandReq), + /// Exit code from executed command (device => host) MsgCommandResp(MsgCommandResp), + /// Request state of Piksi network interfaces MsgNetworkStateReq(MsgNetworkStateReq), + /// State of network interface MsgNetworkStateResp(MsgNetworkStateResp), + /// Command output MsgCommandOutput(MsgCommandOutput), + /// Bandwidth usage reporting message MsgNetworkBandwidthUsage(MsgNetworkBandwidthUsage), + /// Cell modem information update message MsgCellModemStatus(MsgCellModemStatus), + /// RF AGC status MsgFrontEndGain(MsgFrontEndGain), + /// Legacy message for CW interference channel (Piksi => host) MsgCwResults(MsgCwResults), + /// Legacy message for CW interference channel (host => Piksi) MsgCwStart(MsgCwStart), + /// Read FPGA device ID over UART response (host <= device) MsgNapDeviceDnaResp(MsgNapDeviceDnaResp), + /// Read FPGA device ID over UART request (host => device) MsgNapDeviceDnaReq(MsgNapDeviceDnaReq), + /// Flash response message (host <= device) MsgFlashDone(MsgFlashDone), + /// Read STM or M25 flash address response (host <= device) MsgFlashReadResp(MsgFlashReadResp), + /// Erase sector of device flash memory (host => device) MsgFlashErase(MsgFlashErase), + /// Lock sector of STM flash memory (host => device) MsgStmFlashLockSector(MsgStmFlashLockSector), + /// Unlock sector of STM flash memory (host => device) MsgStmFlashUnlockSector(MsgStmFlashUnlockSector), + /// Read device's hard-coded unique ID response (host <= device) MsgStmUniqueIdResp(MsgStmUniqueIdResp), + /// Program flash addresses MsgFlashProgram(MsgFlashProgram), + /// Read STM or M25 flash address request (host => device) MsgFlashReadReq(MsgFlashReadReq), + /// Read device's hard-coded unique ID request (host => device) MsgStmUniqueIdReq(MsgStmUniqueIdReq), + /// Write M25 flash status register (host => device) MsgM25FlashWriteStatus(MsgM25FlashWriteStatus), - MsgGPSTimeDepA(MsgGPSTimeDepA), + /// GPS Time (v1.0) + MsgGpsTimeDepA(MsgGpsTimeDepA), + /// Reports timestamped external pin event MsgExtEvent(MsgExtEvent), - MsgGPSTime(MsgGPSTime), + /// GPS Time + MsgGpsTime(MsgGpsTime), + /// UTC Time MsgUtcTime(MsgUtcTime), - MsgGPSTimeGnss(MsgGPSTimeGnss), + /// GPS Time + MsgGpsTimeGnss(MsgGpsTimeGnss), + /// UTC Time MsgUtcTimeGnss(MsgUtcTimeGnss), + /// Register setting and default value (device <= host) MsgSettingsRegisterResp(MsgSettingsRegisterResp), - MsgPosECEFDepA(MsgPosECEFDepA), - MsgPosLLHDepA(MsgPosLLHDepA), - MsgBaselineECEFDepA(MsgBaselineECEFDepA), - MsgBaselineNEDDepA(MsgBaselineNEDDepA), - MsgVelECEFDepA(MsgVelECEFDepA), - MsgVelNEDDepA(MsgVelNEDDepA), + /// Single-point position in ECEF + MsgPosEcefDepA(MsgPosEcefDepA), + /// Geodetic Position + MsgPosLlhDepA(MsgPosLlhDepA), + /// Baseline Position in ECEF + MsgBaselineEcefDepA(MsgBaselineEcefDepA), + /// Baseline in NED + MsgBaselineNedDepA(MsgBaselineNedDepA), + /// Velocity in ECEF + MsgVelEcefDepA(MsgVelEcefDepA), + /// Velocity in NED + MsgVelNedDepA(MsgVelNedDepA), + /// Dilution of Precision MsgDopsDepA(MsgDopsDepA), + /// Heading relative to True North MsgBaselineHeadingDepA(MsgBaselineHeadingDepA), + /// Dilution of Precision MsgDops(MsgDops), - MsgPosECEF(MsgPosECEF), - MsgPosLLH(MsgPosLLH), - MsgBaselineECEF(MsgBaselineECEF), - MsgBaselineNED(MsgBaselineNED), - MsgVelECEF(MsgVelECEF), - MsgVelNED(MsgVelNED), + /// Single-point position in ECEF + MsgPosEcef(MsgPosEcef), + /// Geodetic Position + MsgPosLlh(MsgPosLlh), + /// Baseline Position in ECEF + MsgBaselineEcef(MsgBaselineEcef), + /// Baseline in NED + MsgBaselineNed(MsgBaselineNed), + /// Velocity in ECEF + MsgVelEcef(MsgVelEcef), + /// Velocity in NED + MsgVelNed(MsgVelNed), + /// Heading relative to True North MsgBaselineHeading(MsgBaselineHeading), + /// Age of corrections MsgAgeCorrections(MsgAgeCorrections), - MsgPosLLHCov(MsgPosLLHCov), - MsgVelNEDCov(MsgVelNEDCov), + /// Geodetic Position + MsgPosLlhCov(MsgPosLlhCov), + /// Velocity in NED + MsgVelNedCov(MsgVelNedCov), + /// Velocity in User Frame MsgVelBody(MsgVelBody), - MsgPosECEFCov(MsgPosECEFCov), - MsgVelECEFCov(MsgVelECEFCov), + /// Single-point position in ECEF + MsgPosEcefCov(MsgPosEcefCov), + /// Velocity in ECEF + MsgVelEcefCov(MsgVelEcefCov), + /// Computed Position and Protection Level MsgProtectionLevelDepA(MsgProtectionLevelDepA), + /// Computed state and Protection Levels MsgProtectionLevel(MsgProtectionLevel), - MsgPosLLHAcc(MsgPosLLHAcc), + /// Geodetic Position and Accuracy + MsgPosLlhAcc(MsgPosLlhAcc), + /// Quaternion 4 component vector MsgOrientQuat(MsgOrientQuat), + /// Euler angles MsgOrientEuler(MsgOrientEuler), + /// Vehicle Body Frame instantaneous angular rates MsgAngularRate(MsgAngularRate), - MsgPosECEFGnss(MsgPosECEFGnss), - MsgPosLLHGnss(MsgPosLLHGnss), - MsgVelECEFGnss(MsgVelECEFGnss), - MsgVelNEDGnss(MsgVelNEDGnss), - MsgPosLLHCovGnss(MsgPosLLHCovGnss), - MsgVelNEDCovGnss(MsgVelNEDCovGnss), - MsgPosECEFCovGnss(MsgPosECEFCovGnss), - MsgVelECEFCovGnss(MsgVelECEFCovGnss), + /// GNSS-only Position in ECEF + MsgPosEcefGnss(MsgPosEcefGnss), + /// GNSS-only Geodetic Position + MsgPosLlhGnss(MsgPosLlhGnss), + /// GNSS-only Velocity in ECEF + MsgVelEcefGnss(MsgVelEcefGnss), + /// GNSS-only Velocity in NED + MsgVelNedGnss(MsgVelNedGnss), + /// GNSS-only Geodetic Position + MsgPosLlhCovGnss(MsgPosLlhCovGnss), + /// GNSS-only Velocity in NED + MsgVelNedCovGnss(MsgVelNedCovGnss), + /// GNSS-only Position in ECEF + MsgPosEcefCovGnss(MsgPosEcefCovGnss), + /// GNSS-only Velocity in ECEF + MsgVelEcefCovGnss(MsgVelEcefCovGnss), + /// Navigation DataBase Event MsgNdbEvent(MsgNdbEvent), + /// Plaintext logging messages with levels MsgLog(MsgLog), + /// Wrapper for FWD a separate stream of information over SBP MsgFwd(MsgFwd), + /// Deprecated MsgSsrOrbitClockDepA(MsgSsrOrbitClockDepA), + /// Precise orbit and clock correction MsgSsrOrbitClock(MsgSsrOrbitClock), + /// Precise code biases correction MsgSsrCodeBiases(MsgSsrCodeBiases), + /// Precise phase biases correction MsgSsrPhaseBiases(MsgSsrPhaseBiases), + /// Deprecated MsgSsrStecCorrectionDepA(MsgSsrStecCorrectionDepA), + /// Deprecated MsgSsrGriddedCorrectionNoStdDepA(MsgSsrGriddedCorrectionNoStdDepA), + /// Deprecated MsgSsrGridDefinitionDepA(MsgSsrGridDefinitionDepA), + /// Definition of a SSR atmospheric correction tile. MsgSsrTileDefinition(MsgSsrTileDefinition), + /// Deprecated MsgSsrGriddedCorrectionDepA(MsgSsrGriddedCorrectionDepA), + /// STEC correction polynomial coefficients MsgSsrStecCorrection(MsgSsrStecCorrection), + /// Gridded troposphere and STEC correction residuals MsgSsrGriddedCorrection(MsgSsrGriddedCorrection), + /// Satellite antenna phase center corrections MsgSsrSatelliteApc(MsgSsrSatelliteApc), + /// OSR corrections MsgOsr(MsgOsr), + /// User data MsgUserData(MsgUserData), + /// Raw IMU data MsgImuRaw(MsgImuRaw), + /// Auxiliary IMU data MsgImuAux(MsgImuAux), + /// Raw magnetometer data MsgMagRaw(MsgMagRaw), + /// Vehicle forward (x-axis) velocity MsgOdometry(MsgOdometry), + /// Accumulated wheeltick count message MsgWheeltick(MsgWheeltick), + /// Request advice on the optimal configuration for FileIO MsgFileioConfigReq(MsgFileioConfigReq), + /// Response with advice on the optimal configuration for FileIO. MsgFileioConfigResp(MsgFileioConfigResp), + /// Raw SBAS data MsgSbasRaw(MsgSbasRaw), + /// List CPU state on the system. DEPRECATED MsgLinuxCpuStateDepA(MsgLinuxCpuStateDepA), + /// List memory state on the system. DEPRECATED MsgLinuxMemStateDepA(MsgLinuxMemStateDepA), + /// CPU, Memory and Process Starts/Stops. DEPRECATED MsgLinuxSysStateDepA(MsgLinuxSysStateDepA), + /// A list of processes with high socket counts MsgLinuxProcessSocketCounts(MsgLinuxProcessSocketCounts), + /// A list of processes with deep socket queues MsgLinuxProcessSocketQueues(MsgLinuxProcessSocketQueues), + /// Summary of socket usage across the system MsgLinuxSocketUsage(MsgLinuxSocketUsage), + /// Summary of processes with large amounts of open file descriptors MsgLinuxProcessFdCount(MsgLinuxProcessFdCount), + /// Summary of open file descriptors on the system MsgLinuxProcessFdSummary(MsgLinuxProcessFdSummary), + /// List CPU state on the system MsgLinuxCpuState(MsgLinuxCpuState), + /// List memory state on the system MsgLinuxMemState(MsgLinuxMemState), + /// CPU, Memory and Process Starts/Stops MsgLinuxSysState(MsgLinuxSysState), + /// System start-up message MsgStartup(MsgStartup), + /// Status of received corrections MsgDgnssStatus(MsgDgnssStatus), + /// Inertial Navigation System status message MsgInsStatus(MsgInsStatus), + /// Experimental telemetry message MsgCsacTelemetry(MsgCsacTelemetry), + /// Experimental telemetry message labels MsgCsacTelemetryLabels(MsgCsacTelemetryLabels), + /// Inertial Navigation System update status message MsgInsUpdates(MsgInsUpdates), + /// Offset of the local time with respect to GNSS time MsgGnssTimeOffset(MsgGnssTimeOffset), + /// Local time at detection of PPS pulse MsgPpsTime(MsgPpsTime), + /// Solution Group Metadata MsgGroupMeta(MsgGroupMeta), + /// Solution Sensors Metadata MsgSolnMeta(MsgSolnMeta), + /// Deprecated MsgSolnMetaDepA(MsgSolnMetaDepA), + /// Status report message MsgStatusReport(MsgStatusReport), + /// System heartbeat message MsgHeartbeat(MsgHeartbeat), + /// Unknown message type Unknown(Unknown), } -impl SBP { - pub fn parse(msg_id: u16, sender_id: u16, payload: &mut &[u8]) -> Result { - match msg_id { - 16 => { - let mut msg = MsgPrintDep::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgPrintDep(msg)) - } - 17 => { - let mut msg = MsgTrackingStateDetailedDep::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgTrackingStateDetailedDep(msg)) - } - 19 => { - let mut msg = MsgTrackingStateDepB::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgTrackingStateDepB(msg)) - } - 20 => { - let mut msg = MsgAcqResultDepB::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgAcqResultDepB(msg)) - } - 21 => { - let mut msg = MsgAcqResultDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgAcqResultDepA(msg)) - } - 22 => { - let mut msg = MsgTrackingStateDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgTrackingStateDepA(msg)) - } - 23 => { - let mut msg = MsgThreadState::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgThreadState(msg)) - } - 24 => { - let mut msg = MsgUartStateDepa::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgUartStateDepa(msg)) - } - 25 => { - let mut msg = MsgIarState::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgIarState(msg)) - } - 26 => { - let mut msg = MsgEphemerisDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgEphemerisDepA(msg)) - } - 27 => { - let mut msg = MsgMaskSatelliteDep::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgMaskSatelliteDep(msg)) - } - 28 => { - let mut msg = MsgTrackingIqDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgTrackingIqDepA(msg)) - } - 29 => { - let mut msg = MsgUartState::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgUartState(msg)) - } - 30 => { - let mut msg = MsgAcqSvProfileDep::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgAcqSvProfileDep(msg)) - } - 31 => { - let mut msg = MsgAcqResultDepC::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgAcqResultDepC(msg)) - } - 33 => { - let mut msg = MsgTrackingStateDetailedDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgTrackingStateDetailedDepA(msg)) - } - 34 => { - let mut msg = MsgResetFilters::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgResetFilters(msg)) - } - 35 => { - let mut msg = MsgInitBaseDep::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgInitBaseDep(msg)) - } - 43 => { - let mut msg = MsgMaskSatellite::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgMaskSatellite(msg)) - } - 44 => { - let mut msg = MsgTrackingIqDepB::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgTrackingIqDepB(msg)) - } - 45 => { - let mut msg = MsgTrackingIq::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgTrackingIq(msg)) - } - 46 => { - let mut msg = MsgAcqSvProfile::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgAcqSvProfile(msg)) - } - 47 => { - let mut msg = MsgAcqResult::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgAcqResult(msg)) - } - 65 => { - let mut msg = MsgTrackingState::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgTrackingState(msg)) - } - 67 => { - let mut msg = MsgObsDepB::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgObsDepB(msg)) - } - 68 => { - let mut msg = MsgBasePosLLH::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgBasePosLLH(msg)) - } - 69 => { - let mut msg = MsgObsDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgObsDepA(msg)) - } - 70 => { - let mut msg = MsgEphemerisDepB::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgEphemerisDepB(msg)) - } - 71 => { - let mut msg = MsgEphemerisDepC::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgEphemerisDepC(msg)) - } - 72 => { - let mut msg = MsgBasePosECEF::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgBasePosECEF(msg)) - } - 73 => { - let mut msg = MsgObsDepC::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgObsDepC(msg)) - } - 74 => { - let mut msg = MsgObs::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgObs(msg)) - } - 80 => { - let mut msg = MsgSpecanDep::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSpecanDep(msg)) - } - 81 => { - let mut msg = MsgSpecan::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSpecan(msg)) - } - 97 => { - let mut msg = MsgMeasurementState::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgMeasurementState(msg)) - } - 104 => { - let mut msg = MsgSetTime::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSetTime(msg)) - } - 105 => { - let mut msg = MsgAlmanac::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgAlmanac(msg)) - } - 112 => { - let mut msg = MsgAlmanacGPSDep::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgAlmanacGPSDep(msg)) - } - 113 => { - let mut msg = MsgAlmanacGloDep::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgAlmanacGloDep(msg)) - } - 114 => { - let mut msg = MsgAlmanacGPS::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgAlmanacGPS(msg)) - } - 115 => { - let mut msg = MsgAlmanacGlo::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgAlmanacGlo(msg)) - } - 117 => { - let mut msg = MsgGloBiases::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgGloBiases(msg)) - } - 128 => { - let mut msg = MsgEphemerisDepD::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgEphemerisDepD(msg)) - } - 129 => { - let mut msg = MsgEphemerisGPSDepE::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgEphemerisGPSDepE(msg)) - } - 130 => { - let mut msg = MsgEphemerisSbasDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgEphemerisSbasDepA(msg)) - } - 131 => { - let mut msg = MsgEphemerisGloDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgEphemerisGloDepA(msg)) - } - 132 => { - let mut msg = MsgEphemerisSbasDepB::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgEphemerisSbasDepB(msg)) - } - 133 => { - let mut msg = MsgEphemerisGloDepB::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgEphemerisGloDepB(msg)) - } - 134 => { - let mut msg = MsgEphemerisGPSDepF::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgEphemerisGPSDepF(msg)) - } - 135 => { - let mut msg = MsgEphemerisGloDepC::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgEphemerisGloDepC(msg)) - } - 136 => { - let mut msg = MsgEphemerisGloDepD::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgEphemerisGloDepD(msg)) - } - 137 => { - let mut msg = MsgEphemerisBds::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgEphemerisBds(msg)) - } - 138 => { - let mut msg = MsgEphemerisGPS::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgEphemerisGPS(msg)) - } - 139 => { - let mut msg = MsgEphemerisGlo::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgEphemerisGlo(msg)) - } - 140 => { - let mut msg = MsgEphemerisSbas::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgEphemerisSbas(msg)) - } - 141 => { - let mut msg = MsgEphemerisGal::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgEphemerisGal(msg)) - } - 142 => { - let mut msg = MsgEphemerisQzss::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgEphemerisQzss(msg)) - } - 144 => { - let mut msg = MsgIono::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgIono(msg)) - } - 145 => { - let mut msg = MsgSvConfigurationGPSDep::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSvConfigurationGPSDep(msg)) - } - 146 => { - let mut msg = MsgGroupDelayDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgGroupDelayDepA(msg)) - } - 147 => { - let mut msg = MsgGroupDelayDepB::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgGroupDelayDepB(msg)) - } - 148 => { - let mut msg = MsgGroupDelay::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgGroupDelay(msg)) - } - 149 => { - let mut msg = MsgEphemerisGalDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgEphemerisGalDepA(msg)) - } - 150 => { - let mut msg = MsgGnssCapb::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgGnssCapb(msg)) - } - 151 => { - let mut msg = MsgSvAzEl::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSvAzEl(msg)) - } - 160 => { - let mut msg = MsgSettingsWrite::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSettingsWrite(msg)) - } - 161 => { - let mut msg = MsgSettingsSave::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSettingsSave(msg)) - } - 162 => { - let mut msg = MsgSettingsReadByIndexReq::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSettingsReadByIndexReq(msg)) - } - 163 => { - let mut msg = MsgFileioReadResp::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgFileioReadResp(msg)) - } - 164 => { - let mut msg = MsgSettingsReadReq::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSettingsReadReq(msg)) - } - 165 => { - let mut msg = MsgSettingsReadResp::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSettingsReadResp(msg)) - } - 166 => { - let mut msg = MsgSettingsReadByIndexDone::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSettingsReadByIndexDone(msg)) - } - 167 => { - let mut msg = MsgSettingsReadByIndexResp::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSettingsReadByIndexResp(msg)) - } - 168 => { - let mut msg = MsgFileioReadReq::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgFileioReadReq(msg)) - } - 169 => { - let mut msg = MsgFileioReadDirReq::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgFileioReadDirReq(msg)) - } - 170 => { - let mut msg = MsgFileioReadDirResp::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgFileioReadDirResp(msg)) - } - 171 => { - let mut msg = MsgFileioWriteResp::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgFileioWriteResp(msg)) - } - 172 => { - let mut msg = MsgFileioRemove::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgFileioRemove(msg)) - } - 173 => { - let mut msg = MsgFileioWriteReq::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgFileioWriteReq(msg)) - } - 174 => { - let mut msg = MsgSettingsRegister::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSettingsRegister(msg)) - } - 175 => { - let mut msg = MsgSettingsWriteResp::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSettingsWriteResp(msg)) - } - 176 => { - let mut msg = MsgBootloaderHandshakeDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgBootloaderHandshakeDepA(msg)) - } - 177 => { - let mut msg = MsgBootloaderJumpToApp::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgBootloaderJumpToApp(msg)) - } - 178 => { - let mut msg = MsgResetDep::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgResetDep(msg)) - } - 179 => { - let mut msg = MsgBootloaderHandshakeReq::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgBootloaderHandshakeReq(msg)) - } - 180 => { - let mut msg = MsgBootloaderHandshakeResp::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgBootloaderHandshakeResp(msg)) - } - 181 => { - let mut msg = MsgDeviceMonitor::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgDeviceMonitor(msg)) - } - 182 => { - let mut msg = MsgReset::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgReset(msg)) - } - 184 => { - let mut msg = MsgCommandReq::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgCommandReq(msg)) - } - 185 => { - let mut msg = MsgCommandResp::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgCommandResp(msg)) - } - 186 => { - let mut msg = MsgNetworkStateReq::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgNetworkStateReq(msg)) - } - 187 => { - let mut msg = MsgNetworkStateResp::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgNetworkStateResp(msg)) - } - 188 => { - let mut msg = MsgCommandOutput::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgCommandOutput(msg)) - } - 189 => { - let mut msg = MsgNetworkBandwidthUsage::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgNetworkBandwidthUsage(msg)) - } - 190 => { - let mut msg = MsgCellModemStatus::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgCellModemStatus(msg)) - } - 191 => { - let mut msg = MsgFrontEndGain::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgFrontEndGain(msg)) - } - 192 => { - let mut msg = MsgCwResults::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgCwResults(msg)) - } - 193 => { - let mut msg = MsgCwStart::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgCwStart(msg)) - } - 221 => { - let mut msg = MsgNapDeviceDnaResp::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgNapDeviceDnaResp(msg)) - } - 222 => { - let mut msg = MsgNapDeviceDnaReq::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgNapDeviceDnaReq(msg)) - } - 224 => { - let mut msg = MsgFlashDone::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgFlashDone(msg)) - } - 225 => { - let mut msg = MsgFlashReadResp::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgFlashReadResp(msg)) - } - 226 => { - let mut msg = MsgFlashErase::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgFlashErase(msg)) - } - 227 => { - let mut msg = MsgStmFlashLockSector::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgStmFlashLockSector(msg)) - } - 228 => { - let mut msg = MsgStmFlashUnlockSector::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgStmFlashUnlockSector(msg)) - } - 229 => { - let mut msg = MsgStmUniqueIdResp::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgStmUniqueIdResp(msg)) - } - 230 => { - let mut msg = MsgFlashProgram::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgFlashProgram(msg)) - } - 231 => { - let mut msg = MsgFlashReadReq::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgFlashReadReq(msg)) - } - 232 => { - let mut msg = MsgStmUniqueIdReq::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgStmUniqueIdReq(msg)) - } - 243 => { - let mut msg = MsgM25FlashWriteStatus::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgM25FlashWriteStatus(msg)) - } - 256 => { - let mut msg = MsgGPSTimeDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgGPSTimeDepA(msg)) - } - 257 => { - let mut msg = MsgExtEvent::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgExtEvent(msg)) - } - 258 => { - let mut msg = MsgGPSTime::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgGPSTime(msg)) - } - 259 => { - let mut msg = MsgUtcTime::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgUtcTime(msg)) - } - 260 => { - let mut msg = MsgGPSTimeGnss::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgGPSTimeGnss(msg)) - } - 261 => { - let mut msg = MsgUtcTimeGnss::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgUtcTimeGnss(msg)) - } - 431 => { - let mut msg = MsgSettingsRegisterResp::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSettingsRegisterResp(msg)) - } - 512 => { - let mut msg = MsgPosECEFDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgPosECEFDepA(msg)) - } - 513 => { - let mut msg = MsgPosLLHDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgPosLLHDepA(msg)) - } - 514 => { - let mut msg = MsgBaselineECEFDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgBaselineECEFDepA(msg)) - } - 515 => { - let mut msg = MsgBaselineNEDDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgBaselineNEDDepA(msg)) - } - 516 => { - let mut msg = MsgVelECEFDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgVelECEFDepA(msg)) - } - 517 => { - let mut msg = MsgVelNEDDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgVelNEDDepA(msg)) - } - 518 => { - let mut msg = MsgDopsDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgDopsDepA(msg)) - } - 519 => { - let mut msg = MsgBaselineHeadingDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgBaselineHeadingDepA(msg)) - } - 520 => { - let mut msg = MsgDops::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgDops(msg)) - } - 521 => { - let mut msg = MsgPosECEF::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgPosECEF(msg)) - } - 522 => { - let mut msg = MsgPosLLH::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgPosLLH(msg)) - } - 523 => { - let mut msg = MsgBaselineECEF::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgBaselineECEF(msg)) - } - 524 => { - let mut msg = MsgBaselineNED::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgBaselineNED(msg)) - } - 525 => { - let mut msg = MsgVelECEF::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgVelECEF(msg)) - } - 526 => { - let mut msg = MsgVelNED::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgVelNED(msg)) - } - 527 => { - let mut msg = MsgBaselineHeading::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgBaselineHeading(msg)) - } - 528 => { - let mut msg = MsgAgeCorrections::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgAgeCorrections(msg)) - } - 529 => { - let mut msg = MsgPosLLHCov::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgPosLLHCov(msg)) - } - 530 => { - let mut msg = MsgVelNEDCov::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgVelNEDCov(msg)) - } - 531 => { - let mut msg = MsgVelBody::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgVelBody(msg)) - } - 532 => { - let mut msg = MsgPosECEFCov::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgPosECEFCov(msg)) - } - 533 => { - let mut msg = MsgVelECEFCov::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgVelECEFCov(msg)) - } - 534 => { - let mut msg = MsgProtectionLevelDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgProtectionLevelDepA(msg)) - } - 535 => { - let mut msg = MsgProtectionLevel::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgProtectionLevel(msg)) - } - 536 => { - let mut msg = MsgPosLLHAcc::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgPosLLHAcc(msg)) - } - 544 => { - let mut msg = MsgOrientQuat::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgOrientQuat(msg)) - } - 545 => { - let mut msg = MsgOrientEuler::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgOrientEuler(msg)) - } - 546 => { - let mut msg = MsgAngularRate::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgAngularRate(msg)) - } - 553 => { - let mut msg = MsgPosECEFGnss::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgPosECEFGnss(msg)) - } - 554 => { - let mut msg = MsgPosLLHGnss::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgPosLLHGnss(msg)) - } - 557 => { - let mut msg = MsgVelECEFGnss::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgVelECEFGnss(msg)) - } - 558 => { - let mut msg = MsgVelNEDGnss::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgVelNEDGnss(msg)) - } - 561 => { - let mut msg = MsgPosLLHCovGnss::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgPosLLHCovGnss(msg)) - } - 562 => { - let mut msg = MsgVelNEDCovGnss::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgVelNEDCovGnss(msg)) - } - 564 => { - let mut msg = MsgPosECEFCovGnss::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgPosECEFCovGnss(msg)) - } - 565 => { - let mut msg = MsgVelECEFCovGnss::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgVelECEFCovGnss(msg)) - } - 1024 => { - let mut msg = MsgNdbEvent::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgNdbEvent(msg)) - } - 1025 => { - let mut msg = MsgLog::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgLog(msg)) - } - 1026 => { - let mut msg = MsgFwd::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgFwd(msg)) - } - 1500 => { - let mut msg = MsgSsrOrbitClockDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSsrOrbitClockDepA(msg)) - } - 1501 => { - let mut msg = MsgSsrOrbitClock::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSsrOrbitClock(msg)) - } - 1505 => { - let mut msg = MsgSsrCodeBiases::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSsrCodeBiases(msg)) - } - 1510 => { - let mut msg = MsgSsrPhaseBiases::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSsrPhaseBiases(msg)) - } - 1515 => { - let mut msg = MsgSsrStecCorrectionDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSsrStecCorrectionDepA(msg)) - } - 1520 => { - let mut msg = MsgSsrGriddedCorrectionNoStdDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSsrGriddedCorrectionNoStdDepA(msg)) - } - 1525 => { - let mut msg = MsgSsrGridDefinitionDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSsrGridDefinitionDepA(msg)) - } - 1526 => { - let mut msg = MsgSsrTileDefinition::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSsrTileDefinition(msg)) - } - 1530 => { - let mut msg = MsgSsrGriddedCorrectionDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSsrGriddedCorrectionDepA(msg)) - } - 1531 => { - let mut msg = MsgSsrStecCorrection::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSsrStecCorrection(msg)) - } - 1532 => { - let mut msg = MsgSsrGriddedCorrection::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSsrGriddedCorrection(msg)) - } - 1540 => { - let mut msg = MsgSsrSatelliteApc::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSsrSatelliteApc(msg)) - } - 1600 => { - let mut msg = MsgOsr::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgOsr(msg)) - } - 2048 => { - let mut msg = MsgUserData::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgUserData(msg)) - } - 2304 => { - let mut msg = MsgImuRaw::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgImuRaw(msg)) - } - 2305 => { - let mut msg = MsgImuAux::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgImuAux(msg)) - } - 2306 => { - let mut msg = MsgMagRaw::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgMagRaw(msg)) - } - 2307 => { - let mut msg = MsgOdometry::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgOdometry(msg)) - } - 2308 => { - let mut msg = MsgWheeltick::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgWheeltick(msg)) - } - 4097 => { - let mut msg = MsgFileioConfigReq::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgFileioConfigReq(msg)) - } - 4098 => { - let mut msg = MsgFileioConfigResp::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgFileioConfigResp(msg)) - } - 30583 => { - let mut msg = MsgSbasRaw::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSbasRaw(msg)) - } - 32512 => { - let mut msg = MsgLinuxCpuStateDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgLinuxCpuStateDepA(msg)) - } - 32513 => { - let mut msg = MsgLinuxMemStateDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgLinuxMemStateDepA(msg)) - } - 32514 => { - let mut msg = MsgLinuxSysStateDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgLinuxSysStateDepA(msg)) - } - 32515 => { - let mut msg = MsgLinuxProcessSocketCounts::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgLinuxProcessSocketCounts(msg)) - } - 32516 => { - let mut msg = MsgLinuxProcessSocketQueues::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgLinuxProcessSocketQueues(msg)) - } - 32517 => { - let mut msg = MsgLinuxSocketUsage::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgLinuxSocketUsage(msg)) - } - 32518 => { - let mut msg = MsgLinuxProcessFdCount::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgLinuxProcessFdCount(msg)) - } - 32519 => { - let mut msg = MsgLinuxProcessFdSummary::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgLinuxProcessFdSummary(msg)) - } - 32520 => { - let mut msg = MsgLinuxCpuState::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgLinuxCpuState(msg)) - } - 32521 => { - let mut msg = MsgLinuxMemState::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgLinuxMemState(msg)) - } - 32522 => { - let mut msg = MsgLinuxSysState::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgLinuxSysState(msg)) - } - 65280 => { - let mut msg = MsgStartup::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgStartup(msg)) - } - 65282 => { - let mut msg = MsgDgnssStatus::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgDgnssStatus(msg)) - } - 65283 => { - let mut msg = MsgInsStatus::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgInsStatus(msg)) - } - 65284 => { - let mut msg = MsgCsacTelemetry::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgCsacTelemetry(msg)) - } - 65285 => { - let mut msg = MsgCsacTelemetryLabels::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgCsacTelemetryLabels(msg)) - } - 65286 => { - let mut msg = MsgInsUpdates::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgInsUpdates(msg)) - } - 65287 => { - let mut msg = MsgGnssTimeOffset::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgGnssTimeOffset(msg)) - } - 65288 => { - let mut msg = MsgPpsTime::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgPpsTime(msg)) - } - 65290 => { - let mut msg = MsgGroupMeta::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgGroupMeta(msg)) - } - 65294 => { - let mut msg = MsgSolnMeta::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSolnMeta(msg)) - } - 65295 => { - let mut msg = MsgSolnMetaDepA::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgSolnMetaDepA(msg)) - } - 65534 => { - let mut msg = MsgStatusReport::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgStatusReport(msg)) - } - 65535 => { - let mut msg = MsgHeartbeat::parse(payload)?; - msg.set_sender_id(sender_id); - Ok(SBP::MsgHeartbeat(msg)) - } - _ => Ok(SBP::Unknown(Unknown { - msg_id: msg_id, - sender_id: sender_id, - payload: payload.to_vec(), - })), +impl Sbp { + pub(crate) fn from_frame(mut frame: crate::de::Frame) -> Result { + match frame.msg_type { + MsgPrintDep::MESSAGE_TYPE => { + let mut msg = MsgPrintDep::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgPrintDep(msg)) + } + MsgTrackingStateDetailedDep::MESSAGE_TYPE => { + let mut msg = MsgTrackingStateDetailedDep::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgTrackingStateDetailedDep(msg)) + } + MsgTrackingStateDepB::MESSAGE_TYPE => { + let mut msg = MsgTrackingStateDepB::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgTrackingStateDepB(msg)) + } + MsgAcqResultDepB::MESSAGE_TYPE => { + let mut msg = MsgAcqResultDepB::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgAcqResultDepB(msg)) + } + MsgAcqResultDepA::MESSAGE_TYPE => { + let mut msg = MsgAcqResultDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgAcqResultDepA(msg)) + } + MsgTrackingStateDepA::MESSAGE_TYPE => { + let mut msg = MsgTrackingStateDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgTrackingStateDepA(msg)) + } + MsgThreadState::MESSAGE_TYPE => { + let mut msg = MsgThreadState::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgThreadState(msg)) + } + MsgUartStateDepa::MESSAGE_TYPE => { + let mut msg = MsgUartStateDepa::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgUartStateDepa(msg)) + } + MsgIarState::MESSAGE_TYPE => { + let mut msg = MsgIarState::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgIarState(msg)) + } + MsgEphemerisDepA::MESSAGE_TYPE => { + let mut msg = MsgEphemerisDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgEphemerisDepA(msg)) + } + MsgMaskSatelliteDep::MESSAGE_TYPE => { + let mut msg = MsgMaskSatelliteDep::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgMaskSatelliteDep(msg)) + } + MsgTrackingIqDepA::MESSAGE_TYPE => { + let mut msg = MsgTrackingIqDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgTrackingIqDepA(msg)) + } + MsgUartState::MESSAGE_TYPE => { + let mut msg = MsgUartState::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgUartState(msg)) + } + MsgAcqSvProfileDep::MESSAGE_TYPE => { + let mut msg = MsgAcqSvProfileDep::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgAcqSvProfileDep(msg)) + } + MsgAcqResultDepC::MESSAGE_TYPE => { + let mut msg = MsgAcqResultDepC::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgAcqResultDepC(msg)) + } + MsgTrackingStateDetailedDepA::MESSAGE_TYPE => { + let mut msg = MsgTrackingStateDetailedDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgTrackingStateDetailedDepA(msg)) + } + MsgResetFilters::MESSAGE_TYPE => { + let mut msg = MsgResetFilters::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgResetFilters(msg)) + } + MsgInitBaseDep::MESSAGE_TYPE => { + let mut msg = MsgInitBaseDep::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgInitBaseDep(msg)) + } + MsgMaskSatellite::MESSAGE_TYPE => { + let mut msg = MsgMaskSatellite::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgMaskSatellite(msg)) + } + MsgTrackingIqDepB::MESSAGE_TYPE => { + let mut msg = MsgTrackingIqDepB::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgTrackingIqDepB(msg)) + } + MsgTrackingIq::MESSAGE_TYPE => { + let mut msg = MsgTrackingIq::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgTrackingIq(msg)) + } + MsgAcqSvProfile::MESSAGE_TYPE => { + let mut msg = MsgAcqSvProfile::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgAcqSvProfile(msg)) + } + MsgAcqResult::MESSAGE_TYPE => { + let mut msg = MsgAcqResult::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgAcqResult(msg)) + } + MsgTrackingState::MESSAGE_TYPE => { + let mut msg = MsgTrackingState::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgTrackingState(msg)) + } + MsgObsDepB::MESSAGE_TYPE => { + let mut msg = MsgObsDepB::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgObsDepB(msg)) + } + MsgBasePosLlh::MESSAGE_TYPE => { + let mut msg = MsgBasePosLlh::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgBasePosLlh(msg)) + } + MsgObsDepA::MESSAGE_TYPE => { + let mut msg = MsgObsDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgObsDepA(msg)) + } + MsgEphemerisDepB::MESSAGE_TYPE => { + let mut msg = MsgEphemerisDepB::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgEphemerisDepB(msg)) + } + MsgEphemerisDepC::MESSAGE_TYPE => { + let mut msg = MsgEphemerisDepC::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgEphemerisDepC(msg)) + } + MsgBasePosEcef::MESSAGE_TYPE => { + let mut msg = MsgBasePosEcef::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgBasePosEcef(msg)) + } + MsgObsDepC::MESSAGE_TYPE => { + let mut msg = MsgObsDepC::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgObsDepC(msg)) + } + MsgObs::MESSAGE_TYPE => { + let mut msg = MsgObs::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgObs(msg)) + } + MsgSpecanDep::MESSAGE_TYPE => { + let mut msg = MsgSpecanDep::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSpecanDep(msg)) + } + MsgSpecan::MESSAGE_TYPE => { + let mut msg = MsgSpecan::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSpecan(msg)) + } + MsgMeasurementState::MESSAGE_TYPE => { + let mut msg = MsgMeasurementState::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgMeasurementState(msg)) + } + MsgSetTime::MESSAGE_TYPE => { + let mut msg = MsgSetTime::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSetTime(msg)) + } + MsgAlmanac::MESSAGE_TYPE => { + let mut msg = MsgAlmanac::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgAlmanac(msg)) + } + MsgAlmanacGpsDep::MESSAGE_TYPE => { + let mut msg = MsgAlmanacGpsDep::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgAlmanacGpsDep(msg)) + } + MsgAlmanacGloDep::MESSAGE_TYPE => { + let mut msg = MsgAlmanacGloDep::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgAlmanacGloDep(msg)) + } + MsgAlmanacGps::MESSAGE_TYPE => { + let mut msg = MsgAlmanacGps::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgAlmanacGps(msg)) + } + MsgAlmanacGlo::MESSAGE_TYPE => { + let mut msg = MsgAlmanacGlo::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgAlmanacGlo(msg)) + } + MsgGloBiases::MESSAGE_TYPE => { + let mut msg = MsgGloBiases::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgGloBiases(msg)) + } + MsgEphemerisDepD::MESSAGE_TYPE => { + let mut msg = MsgEphemerisDepD::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgEphemerisDepD(msg)) + } + MsgEphemerisGpsDepE::MESSAGE_TYPE => { + let mut msg = MsgEphemerisGpsDepE::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgEphemerisGpsDepE(msg)) + } + MsgEphemerisSbasDepA::MESSAGE_TYPE => { + let mut msg = MsgEphemerisSbasDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgEphemerisSbasDepA(msg)) + } + MsgEphemerisGloDepA::MESSAGE_TYPE => { + let mut msg = MsgEphemerisGloDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgEphemerisGloDepA(msg)) + } + MsgEphemerisSbasDepB::MESSAGE_TYPE => { + let mut msg = MsgEphemerisSbasDepB::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgEphemerisSbasDepB(msg)) + } + MsgEphemerisGloDepB::MESSAGE_TYPE => { + let mut msg = MsgEphemerisGloDepB::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgEphemerisGloDepB(msg)) + } + MsgEphemerisGpsDepF::MESSAGE_TYPE => { + let mut msg = MsgEphemerisGpsDepF::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgEphemerisGpsDepF(msg)) + } + MsgEphemerisGloDepC::MESSAGE_TYPE => { + let mut msg = MsgEphemerisGloDepC::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgEphemerisGloDepC(msg)) + } + MsgEphemerisGloDepD::MESSAGE_TYPE => { + let mut msg = MsgEphemerisGloDepD::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgEphemerisGloDepD(msg)) + } + MsgEphemerisBds::MESSAGE_TYPE => { + let mut msg = MsgEphemerisBds::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgEphemerisBds(msg)) + } + MsgEphemerisGps::MESSAGE_TYPE => { + let mut msg = MsgEphemerisGps::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgEphemerisGps(msg)) + } + MsgEphemerisGlo::MESSAGE_TYPE => { + let mut msg = MsgEphemerisGlo::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgEphemerisGlo(msg)) + } + MsgEphemerisSbas::MESSAGE_TYPE => { + let mut msg = MsgEphemerisSbas::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgEphemerisSbas(msg)) + } + MsgEphemerisGal::MESSAGE_TYPE => { + let mut msg = MsgEphemerisGal::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgEphemerisGal(msg)) + } + MsgEphemerisQzss::MESSAGE_TYPE => { + let mut msg = MsgEphemerisQzss::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgEphemerisQzss(msg)) + } + MsgIono::MESSAGE_TYPE => { + let mut msg = MsgIono::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgIono(msg)) + } + MsgSvConfigurationGpsDep::MESSAGE_TYPE => { + let mut msg = MsgSvConfigurationGpsDep::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSvConfigurationGpsDep(msg)) + } + MsgGroupDelayDepA::MESSAGE_TYPE => { + let mut msg = MsgGroupDelayDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgGroupDelayDepA(msg)) + } + MsgGroupDelayDepB::MESSAGE_TYPE => { + let mut msg = MsgGroupDelayDepB::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgGroupDelayDepB(msg)) + } + MsgGroupDelay::MESSAGE_TYPE => { + let mut msg = MsgGroupDelay::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgGroupDelay(msg)) + } + MsgEphemerisGalDepA::MESSAGE_TYPE => { + let mut msg = MsgEphemerisGalDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgEphemerisGalDepA(msg)) + } + MsgGnssCapb::MESSAGE_TYPE => { + let mut msg = MsgGnssCapb::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgGnssCapb(msg)) + } + MsgSvAzEl::MESSAGE_TYPE => { + let mut msg = MsgSvAzEl::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSvAzEl(msg)) + } + MsgSettingsWrite::MESSAGE_TYPE => { + let mut msg = MsgSettingsWrite::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSettingsWrite(msg)) + } + MsgSettingsSave::MESSAGE_TYPE => { + let mut msg = MsgSettingsSave::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSettingsSave(msg)) + } + MsgSettingsReadByIndexReq::MESSAGE_TYPE => { + let mut msg = MsgSettingsReadByIndexReq::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSettingsReadByIndexReq(msg)) + } + MsgFileioReadResp::MESSAGE_TYPE => { + let mut msg = MsgFileioReadResp::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgFileioReadResp(msg)) + } + MsgSettingsReadReq::MESSAGE_TYPE => { + let mut msg = MsgSettingsReadReq::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSettingsReadReq(msg)) + } + MsgSettingsReadResp::MESSAGE_TYPE => { + let mut msg = MsgSettingsReadResp::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSettingsReadResp(msg)) + } + MsgSettingsReadByIndexDone::MESSAGE_TYPE => { + let mut msg = MsgSettingsReadByIndexDone::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSettingsReadByIndexDone(msg)) + } + MsgSettingsReadByIndexResp::MESSAGE_TYPE => { + let mut msg = MsgSettingsReadByIndexResp::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSettingsReadByIndexResp(msg)) + } + MsgFileioReadReq::MESSAGE_TYPE => { + let mut msg = MsgFileioReadReq::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgFileioReadReq(msg)) + } + MsgFileioReadDirReq::MESSAGE_TYPE => { + let mut msg = MsgFileioReadDirReq::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgFileioReadDirReq(msg)) + } + MsgFileioReadDirResp::MESSAGE_TYPE => { + let mut msg = MsgFileioReadDirResp::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgFileioReadDirResp(msg)) + } + MsgFileioWriteResp::MESSAGE_TYPE => { + let mut msg = MsgFileioWriteResp::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgFileioWriteResp(msg)) + } + MsgFileioRemove::MESSAGE_TYPE => { + let mut msg = MsgFileioRemove::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgFileioRemove(msg)) + } + MsgFileioWriteReq::MESSAGE_TYPE => { + let mut msg = MsgFileioWriteReq::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgFileioWriteReq(msg)) + } + MsgSettingsRegister::MESSAGE_TYPE => { + let mut msg = MsgSettingsRegister::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSettingsRegister(msg)) + } + MsgSettingsWriteResp::MESSAGE_TYPE => { + let mut msg = MsgSettingsWriteResp::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSettingsWriteResp(msg)) + } + MsgBootloaderHandshakeDepA::MESSAGE_TYPE => { + let mut msg = MsgBootloaderHandshakeDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgBootloaderHandshakeDepA(msg)) + } + MsgBootloaderJumpToApp::MESSAGE_TYPE => { + let mut msg = MsgBootloaderJumpToApp::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgBootloaderJumpToApp(msg)) + } + MsgResetDep::MESSAGE_TYPE => { + let mut msg = MsgResetDep::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgResetDep(msg)) + } + MsgBootloaderHandshakeReq::MESSAGE_TYPE => { + let mut msg = MsgBootloaderHandshakeReq::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgBootloaderHandshakeReq(msg)) + } + MsgBootloaderHandshakeResp::MESSAGE_TYPE => { + let mut msg = MsgBootloaderHandshakeResp::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgBootloaderHandshakeResp(msg)) + } + MsgDeviceMonitor::MESSAGE_TYPE => { + let mut msg = MsgDeviceMonitor::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgDeviceMonitor(msg)) + } + MsgReset::MESSAGE_TYPE => { + let mut msg = MsgReset::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgReset(msg)) + } + MsgCommandReq::MESSAGE_TYPE => { + let mut msg = MsgCommandReq::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgCommandReq(msg)) + } + MsgCommandResp::MESSAGE_TYPE => { + let mut msg = MsgCommandResp::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgCommandResp(msg)) + } + MsgNetworkStateReq::MESSAGE_TYPE => { + let mut msg = MsgNetworkStateReq::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgNetworkStateReq(msg)) + } + MsgNetworkStateResp::MESSAGE_TYPE => { + let mut msg = MsgNetworkStateResp::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgNetworkStateResp(msg)) + } + MsgCommandOutput::MESSAGE_TYPE => { + let mut msg = MsgCommandOutput::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgCommandOutput(msg)) + } + MsgNetworkBandwidthUsage::MESSAGE_TYPE => { + let mut msg = MsgNetworkBandwidthUsage::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgNetworkBandwidthUsage(msg)) + } + MsgCellModemStatus::MESSAGE_TYPE => { + let mut msg = MsgCellModemStatus::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgCellModemStatus(msg)) + } + MsgFrontEndGain::MESSAGE_TYPE => { + let mut msg = MsgFrontEndGain::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgFrontEndGain(msg)) + } + MsgCwResults::MESSAGE_TYPE => { + let mut msg = MsgCwResults::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgCwResults(msg)) + } + MsgCwStart::MESSAGE_TYPE => { + let mut msg = MsgCwStart::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgCwStart(msg)) + } + MsgNapDeviceDnaResp::MESSAGE_TYPE => { + let mut msg = MsgNapDeviceDnaResp::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgNapDeviceDnaResp(msg)) + } + MsgNapDeviceDnaReq::MESSAGE_TYPE => { + let mut msg = MsgNapDeviceDnaReq::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgNapDeviceDnaReq(msg)) + } + MsgFlashDone::MESSAGE_TYPE => { + let mut msg = MsgFlashDone::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgFlashDone(msg)) + } + MsgFlashReadResp::MESSAGE_TYPE => { + let mut msg = MsgFlashReadResp::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgFlashReadResp(msg)) + } + MsgFlashErase::MESSAGE_TYPE => { + let mut msg = MsgFlashErase::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgFlashErase(msg)) + } + MsgStmFlashLockSector::MESSAGE_TYPE => { + let mut msg = MsgStmFlashLockSector::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgStmFlashLockSector(msg)) + } + MsgStmFlashUnlockSector::MESSAGE_TYPE => { + let mut msg = MsgStmFlashUnlockSector::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgStmFlashUnlockSector(msg)) + } + MsgStmUniqueIdResp::MESSAGE_TYPE => { + let mut msg = MsgStmUniqueIdResp::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgStmUniqueIdResp(msg)) + } + MsgFlashProgram::MESSAGE_TYPE => { + let mut msg = MsgFlashProgram::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgFlashProgram(msg)) + } + MsgFlashReadReq::MESSAGE_TYPE => { + let mut msg = MsgFlashReadReq::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgFlashReadReq(msg)) + } + MsgStmUniqueIdReq::MESSAGE_TYPE => { + let mut msg = MsgStmUniqueIdReq::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgStmUniqueIdReq(msg)) + } + MsgM25FlashWriteStatus::MESSAGE_TYPE => { + let mut msg = MsgM25FlashWriteStatus::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgM25FlashWriteStatus(msg)) + } + MsgGpsTimeDepA::MESSAGE_TYPE => { + let mut msg = MsgGpsTimeDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgGpsTimeDepA(msg)) + } + MsgExtEvent::MESSAGE_TYPE => { + let mut msg = MsgExtEvent::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgExtEvent(msg)) + } + MsgGpsTime::MESSAGE_TYPE => { + let mut msg = MsgGpsTime::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgGpsTime(msg)) + } + MsgUtcTime::MESSAGE_TYPE => { + let mut msg = MsgUtcTime::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgUtcTime(msg)) + } + MsgGpsTimeGnss::MESSAGE_TYPE => { + let mut msg = MsgGpsTimeGnss::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgGpsTimeGnss(msg)) + } + MsgUtcTimeGnss::MESSAGE_TYPE => { + let mut msg = MsgUtcTimeGnss::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgUtcTimeGnss(msg)) + } + MsgSettingsRegisterResp::MESSAGE_TYPE => { + let mut msg = MsgSettingsRegisterResp::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSettingsRegisterResp(msg)) + } + MsgPosEcefDepA::MESSAGE_TYPE => { + let mut msg = MsgPosEcefDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgPosEcefDepA(msg)) + } + MsgPosLlhDepA::MESSAGE_TYPE => { + let mut msg = MsgPosLlhDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgPosLlhDepA(msg)) + } + MsgBaselineEcefDepA::MESSAGE_TYPE => { + let mut msg = MsgBaselineEcefDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgBaselineEcefDepA(msg)) + } + MsgBaselineNedDepA::MESSAGE_TYPE => { + let mut msg = MsgBaselineNedDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgBaselineNedDepA(msg)) + } + MsgVelEcefDepA::MESSAGE_TYPE => { + let mut msg = MsgVelEcefDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgVelEcefDepA(msg)) + } + MsgVelNedDepA::MESSAGE_TYPE => { + let mut msg = MsgVelNedDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgVelNedDepA(msg)) + } + MsgDopsDepA::MESSAGE_TYPE => { + let mut msg = MsgDopsDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgDopsDepA(msg)) + } + MsgBaselineHeadingDepA::MESSAGE_TYPE => { + let mut msg = MsgBaselineHeadingDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgBaselineHeadingDepA(msg)) + } + MsgDops::MESSAGE_TYPE => { + let mut msg = MsgDops::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgDops(msg)) + } + MsgPosEcef::MESSAGE_TYPE => { + let mut msg = MsgPosEcef::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgPosEcef(msg)) + } + MsgPosLlh::MESSAGE_TYPE => { + let mut msg = MsgPosLlh::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgPosLlh(msg)) + } + MsgBaselineEcef::MESSAGE_TYPE => { + let mut msg = MsgBaselineEcef::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgBaselineEcef(msg)) + } + MsgBaselineNed::MESSAGE_TYPE => { + let mut msg = MsgBaselineNed::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgBaselineNed(msg)) + } + MsgVelEcef::MESSAGE_TYPE => { + let mut msg = MsgVelEcef::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgVelEcef(msg)) + } + MsgVelNed::MESSAGE_TYPE => { + let mut msg = MsgVelNed::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgVelNed(msg)) + } + MsgBaselineHeading::MESSAGE_TYPE => { + let mut msg = MsgBaselineHeading::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgBaselineHeading(msg)) + } + MsgAgeCorrections::MESSAGE_TYPE => { + let mut msg = MsgAgeCorrections::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgAgeCorrections(msg)) + } + MsgPosLlhCov::MESSAGE_TYPE => { + let mut msg = MsgPosLlhCov::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgPosLlhCov(msg)) + } + MsgVelNedCov::MESSAGE_TYPE => { + let mut msg = MsgVelNedCov::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgVelNedCov(msg)) + } + MsgVelBody::MESSAGE_TYPE => { + let mut msg = MsgVelBody::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgVelBody(msg)) + } + MsgPosEcefCov::MESSAGE_TYPE => { + let mut msg = MsgPosEcefCov::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgPosEcefCov(msg)) + } + MsgVelEcefCov::MESSAGE_TYPE => { + let mut msg = MsgVelEcefCov::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgVelEcefCov(msg)) + } + MsgProtectionLevelDepA::MESSAGE_TYPE => { + let mut msg = MsgProtectionLevelDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgProtectionLevelDepA(msg)) + } + MsgProtectionLevel::MESSAGE_TYPE => { + let mut msg = MsgProtectionLevel::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgProtectionLevel(msg)) + } + MsgPosLlhAcc::MESSAGE_TYPE => { + let mut msg = MsgPosLlhAcc::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgPosLlhAcc(msg)) + } + MsgOrientQuat::MESSAGE_TYPE => { + let mut msg = MsgOrientQuat::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgOrientQuat(msg)) + } + MsgOrientEuler::MESSAGE_TYPE => { + let mut msg = MsgOrientEuler::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgOrientEuler(msg)) + } + MsgAngularRate::MESSAGE_TYPE => { + let mut msg = MsgAngularRate::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgAngularRate(msg)) + } + MsgPosEcefGnss::MESSAGE_TYPE => { + let mut msg = MsgPosEcefGnss::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgPosEcefGnss(msg)) + } + MsgPosLlhGnss::MESSAGE_TYPE => { + let mut msg = MsgPosLlhGnss::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgPosLlhGnss(msg)) + } + MsgVelEcefGnss::MESSAGE_TYPE => { + let mut msg = MsgVelEcefGnss::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgVelEcefGnss(msg)) + } + MsgVelNedGnss::MESSAGE_TYPE => { + let mut msg = MsgVelNedGnss::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgVelNedGnss(msg)) + } + MsgPosLlhCovGnss::MESSAGE_TYPE => { + let mut msg = MsgPosLlhCovGnss::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgPosLlhCovGnss(msg)) + } + MsgVelNedCovGnss::MESSAGE_TYPE => { + let mut msg = MsgVelNedCovGnss::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgVelNedCovGnss(msg)) + } + MsgPosEcefCovGnss::MESSAGE_TYPE => { + let mut msg = MsgPosEcefCovGnss::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgPosEcefCovGnss(msg)) + } + MsgVelEcefCovGnss::MESSAGE_TYPE => { + let mut msg = MsgVelEcefCovGnss::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgVelEcefCovGnss(msg)) + } + MsgNdbEvent::MESSAGE_TYPE => { + let mut msg = MsgNdbEvent::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgNdbEvent(msg)) + } + MsgLog::MESSAGE_TYPE => { + let mut msg = MsgLog::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgLog(msg)) + } + MsgFwd::MESSAGE_TYPE => { + let mut msg = MsgFwd::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgFwd(msg)) + } + MsgSsrOrbitClockDepA::MESSAGE_TYPE => { + let mut msg = MsgSsrOrbitClockDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSsrOrbitClockDepA(msg)) + } + MsgSsrOrbitClock::MESSAGE_TYPE => { + let mut msg = MsgSsrOrbitClock::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSsrOrbitClock(msg)) + } + MsgSsrCodeBiases::MESSAGE_TYPE => { + let mut msg = MsgSsrCodeBiases::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSsrCodeBiases(msg)) + } + MsgSsrPhaseBiases::MESSAGE_TYPE => { + let mut msg = MsgSsrPhaseBiases::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSsrPhaseBiases(msg)) + } + MsgSsrStecCorrectionDepA::MESSAGE_TYPE => { + let mut msg = MsgSsrStecCorrectionDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSsrStecCorrectionDepA(msg)) + } + MsgSsrGriddedCorrectionNoStdDepA::MESSAGE_TYPE => { + let mut msg = MsgSsrGriddedCorrectionNoStdDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSsrGriddedCorrectionNoStdDepA(msg)) + } + MsgSsrGridDefinitionDepA::MESSAGE_TYPE => { + let mut msg = MsgSsrGridDefinitionDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSsrGridDefinitionDepA(msg)) + } + MsgSsrTileDefinition::MESSAGE_TYPE => { + let mut msg = MsgSsrTileDefinition::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSsrTileDefinition(msg)) + } + MsgSsrGriddedCorrectionDepA::MESSAGE_TYPE => { + let mut msg = MsgSsrGriddedCorrectionDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSsrGriddedCorrectionDepA(msg)) + } + MsgSsrStecCorrection::MESSAGE_TYPE => { + let mut msg = MsgSsrStecCorrection::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSsrStecCorrection(msg)) + } + MsgSsrGriddedCorrection::MESSAGE_TYPE => { + let mut msg = MsgSsrGriddedCorrection::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSsrGriddedCorrection(msg)) + } + MsgSsrSatelliteApc::MESSAGE_TYPE => { + let mut msg = MsgSsrSatelliteApc::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSsrSatelliteApc(msg)) + } + MsgOsr::MESSAGE_TYPE => { + let mut msg = MsgOsr::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgOsr(msg)) + } + MsgUserData::MESSAGE_TYPE => { + let mut msg = MsgUserData::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgUserData(msg)) + } + MsgImuRaw::MESSAGE_TYPE => { + let mut msg = MsgImuRaw::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgImuRaw(msg)) + } + MsgImuAux::MESSAGE_TYPE => { + let mut msg = MsgImuAux::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgImuAux(msg)) + } + MsgMagRaw::MESSAGE_TYPE => { + let mut msg = MsgMagRaw::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgMagRaw(msg)) + } + MsgOdometry::MESSAGE_TYPE => { + let mut msg = MsgOdometry::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgOdometry(msg)) + } + MsgWheeltick::MESSAGE_TYPE => { + let mut msg = MsgWheeltick::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgWheeltick(msg)) + } + MsgFileioConfigReq::MESSAGE_TYPE => { + let mut msg = MsgFileioConfigReq::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgFileioConfigReq(msg)) + } + MsgFileioConfigResp::MESSAGE_TYPE => { + let mut msg = MsgFileioConfigResp::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgFileioConfigResp(msg)) + } + MsgSbasRaw::MESSAGE_TYPE => { + let mut msg = MsgSbasRaw::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSbasRaw(msg)) + } + MsgLinuxCpuStateDepA::MESSAGE_TYPE => { + let mut msg = MsgLinuxCpuStateDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgLinuxCpuStateDepA(msg)) + } + MsgLinuxMemStateDepA::MESSAGE_TYPE => { + let mut msg = MsgLinuxMemStateDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgLinuxMemStateDepA(msg)) + } + MsgLinuxSysStateDepA::MESSAGE_TYPE => { + let mut msg = MsgLinuxSysStateDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgLinuxSysStateDepA(msg)) + } + MsgLinuxProcessSocketCounts::MESSAGE_TYPE => { + let mut msg = MsgLinuxProcessSocketCounts::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgLinuxProcessSocketCounts(msg)) + } + MsgLinuxProcessSocketQueues::MESSAGE_TYPE => { + let mut msg = MsgLinuxProcessSocketQueues::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgLinuxProcessSocketQueues(msg)) + } + MsgLinuxSocketUsage::MESSAGE_TYPE => { + let mut msg = MsgLinuxSocketUsage::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgLinuxSocketUsage(msg)) + } + MsgLinuxProcessFdCount::MESSAGE_TYPE => { + let mut msg = MsgLinuxProcessFdCount::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgLinuxProcessFdCount(msg)) + } + MsgLinuxProcessFdSummary::MESSAGE_TYPE => { + let mut msg = MsgLinuxProcessFdSummary::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgLinuxProcessFdSummary(msg)) + } + MsgLinuxCpuState::MESSAGE_TYPE => { + let mut msg = MsgLinuxCpuState::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgLinuxCpuState(msg)) + } + MsgLinuxMemState::MESSAGE_TYPE => { + let mut msg = MsgLinuxMemState::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgLinuxMemState(msg)) + } + MsgLinuxSysState::MESSAGE_TYPE => { + let mut msg = MsgLinuxSysState::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgLinuxSysState(msg)) + } + MsgStartup::MESSAGE_TYPE => { + let mut msg = MsgStartup::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgStartup(msg)) + } + MsgDgnssStatus::MESSAGE_TYPE => { + let mut msg = MsgDgnssStatus::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgDgnssStatus(msg)) + } + MsgInsStatus::MESSAGE_TYPE => { + let mut msg = MsgInsStatus::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgInsStatus(msg)) + } + MsgCsacTelemetry::MESSAGE_TYPE => { + let mut msg = MsgCsacTelemetry::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgCsacTelemetry(msg)) + } + MsgCsacTelemetryLabels::MESSAGE_TYPE => { + let mut msg = MsgCsacTelemetryLabels::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgCsacTelemetryLabels(msg)) + } + MsgInsUpdates::MESSAGE_TYPE => { + let mut msg = MsgInsUpdates::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgInsUpdates(msg)) + } + MsgGnssTimeOffset::MESSAGE_TYPE => { + let mut msg = MsgGnssTimeOffset::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgGnssTimeOffset(msg)) + } + MsgPpsTime::MESSAGE_TYPE => { + let mut msg = MsgPpsTime::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgPpsTime(msg)) + } + MsgGroupMeta::MESSAGE_TYPE => { + let mut msg = MsgGroupMeta::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgGroupMeta(msg)) + } + MsgSolnMeta::MESSAGE_TYPE => { + let mut msg = MsgSolnMeta::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSolnMeta(msg)) + } + MsgSolnMetaDepA::MESSAGE_TYPE => { + let mut msg = MsgSolnMetaDepA::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgSolnMetaDepA(msg)) + } + MsgStatusReport::MESSAGE_TYPE => { + let mut msg = MsgStatusReport::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgStatusReport(msg)) + } + MsgHeartbeat::MESSAGE_TYPE => { + let mut msg = MsgHeartbeat::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::MsgHeartbeat(msg)) + } + _ => { + let mut msg = Unknown::parse(&mut frame.payload)?; + msg.set_sender_id(frame.sender_id); + Ok(Sbp::Unknown(msg)) + } } } } -impl crate::SBPMessage for SBP { - fn get_message_name(&self) -> &'static str { +impl SbpMessage for Sbp { + fn message_name(&self) -> &'static str { match self { - SBP::MsgPrintDep(msg) => msg.get_message_name(), - SBP::MsgTrackingStateDetailedDep(msg) => msg.get_message_name(), - SBP::MsgTrackingStateDepB(msg) => msg.get_message_name(), - SBP::MsgAcqResultDepB(msg) => msg.get_message_name(), - SBP::MsgAcqResultDepA(msg) => msg.get_message_name(), - SBP::MsgTrackingStateDepA(msg) => msg.get_message_name(), - SBP::MsgThreadState(msg) => msg.get_message_name(), - SBP::MsgUartStateDepa(msg) => msg.get_message_name(), - SBP::MsgIarState(msg) => msg.get_message_name(), - SBP::MsgEphemerisDepA(msg) => msg.get_message_name(), - SBP::MsgMaskSatelliteDep(msg) => msg.get_message_name(), - SBP::MsgTrackingIqDepA(msg) => msg.get_message_name(), - SBP::MsgUartState(msg) => msg.get_message_name(), - SBP::MsgAcqSvProfileDep(msg) => msg.get_message_name(), - SBP::MsgAcqResultDepC(msg) => msg.get_message_name(), - SBP::MsgTrackingStateDetailedDepA(msg) => msg.get_message_name(), - SBP::MsgResetFilters(msg) => msg.get_message_name(), - SBP::MsgInitBaseDep(msg) => msg.get_message_name(), - SBP::MsgMaskSatellite(msg) => msg.get_message_name(), - SBP::MsgTrackingIqDepB(msg) => msg.get_message_name(), - SBP::MsgTrackingIq(msg) => msg.get_message_name(), - SBP::MsgAcqSvProfile(msg) => msg.get_message_name(), - SBP::MsgAcqResult(msg) => msg.get_message_name(), - SBP::MsgTrackingState(msg) => msg.get_message_name(), - SBP::MsgObsDepB(msg) => msg.get_message_name(), - SBP::MsgBasePosLLH(msg) => msg.get_message_name(), - SBP::MsgObsDepA(msg) => msg.get_message_name(), - SBP::MsgEphemerisDepB(msg) => msg.get_message_name(), - SBP::MsgEphemerisDepC(msg) => msg.get_message_name(), - SBP::MsgBasePosECEF(msg) => msg.get_message_name(), - SBP::MsgObsDepC(msg) => msg.get_message_name(), - SBP::MsgObs(msg) => msg.get_message_name(), - SBP::MsgSpecanDep(msg) => msg.get_message_name(), - SBP::MsgSpecan(msg) => msg.get_message_name(), - SBP::MsgMeasurementState(msg) => msg.get_message_name(), - SBP::MsgSetTime(msg) => msg.get_message_name(), - SBP::MsgAlmanac(msg) => msg.get_message_name(), - SBP::MsgAlmanacGPSDep(msg) => msg.get_message_name(), - SBP::MsgAlmanacGloDep(msg) => msg.get_message_name(), - SBP::MsgAlmanacGPS(msg) => msg.get_message_name(), - SBP::MsgAlmanacGlo(msg) => msg.get_message_name(), - SBP::MsgGloBiases(msg) => msg.get_message_name(), - SBP::MsgEphemerisDepD(msg) => msg.get_message_name(), - SBP::MsgEphemerisGPSDepE(msg) => msg.get_message_name(), - SBP::MsgEphemerisSbasDepA(msg) => msg.get_message_name(), - SBP::MsgEphemerisGloDepA(msg) => msg.get_message_name(), - SBP::MsgEphemerisSbasDepB(msg) => msg.get_message_name(), - SBP::MsgEphemerisGloDepB(msg) => msg.get_message_name(), - SBP::MsgEphemerisGPSDepF(msg) => msg.get_message_name(), - SBP::MsgEphemerisGloDepC(msg) => msg.get_message_name(), - SBP::MsgEphemerisGloDepD(msg) => msg.get_message_name(), - SBP::MsgEphemerisBds(msg) => msg.get_message_name(), - SBP::MsgEphemerisGPS(msg) => msg.get_message_name(), - SBP::MsgEphemerisGlo(msg) => msg.get_message_name(), - SBP::MsgEphemerisSbas(msg) => msg.get_message_name(), - SBP::MsgEphemerisGal(msg) => msg.get_message_name(), - SBP::MsgEphemerisQzss(msg) => msg.get_message_name(), - SBP::MsgIono(msg) => msg.get_message_name(), - SBP::MsgSvConfigurationGPSDep(msg) => msg.get_message_name(), - SBP::MsgGroupDelayDepA(msg) => msg.get_message_name(), - SBP::MsgGroupDelayDepB(msg) => msg.get_message_name(), - SBP::MsgGroupDelay(msg) => msg.get_message_name(), - SBP::MsgEphemerisGalDepA(msg) => msg.get_message_name(), - SBP::MsgGnssCapb(msg) => msg.get_message_name(), - SBP::MsgSvAzEl(msg) => msg.get_message_name(), - SBP::MsgSettingsWrite(msg) => msg.get_message_name(), - SBP::MsgSettingsSave(msg) => msg.get_message_name(), - SBP::MsgSettingsReadByIndexReq(msg) => msg.get_message_name(), - SBP::MsgFileioReadResp(msg) => msg.get_message_name(), - SBP::MsgSettingsReadReq(msg) => msg.get_message_name(), - SBP::MsgSettingsReadResp(msg) => msg.get_message_name(), - SBP::MsgSettingsReadByIndexDone(msg) => msg.get_message_name(), - SBP::MsgSettingsReadByIndexResp(msg) => msg.get_message_name(), - SBP::MsgFileioReadReq(msg) => msg.get_message_name(), - SBP::MsgFileioReadDirReq(msg) => msg.get_message_name(), - SBP::MsgFileioReadDirResp(msg) => msg.get_message_name(), - SBP::MsgFileioWriteResp(msg) => msg.get_message_name(), - SBP::MsgFileioRemove(msg) => msg.get_message_name(), - SBP::MsgFileioWriteReq(msg) => msg.get_message_name(), - SBP::MsgSettingsRegister(msg) => msg.get_message_name(), - SBP::MsgSettingsWriteResp(msg) => msg.get_message_name(), - SBP::MsgBootloaderHandshakeDepA(msg) => msg.get_message_name(), - SBP::MsgBootloaderJumpToApp(msg) => msg.get_message_name(), - SBP::MsgResetDep(msg) => msg.get_message_name(), - SBP::MsgBootloaderHandshakeReq(msg) => msg.get_message_name(), - SBP::MsgBootloaderHandshakeResp(msg) => msg.get_message_name(), - SBP::MsgDeviceMonitor(msg) => msg.get_message_name(), - SBP::MsgReset(msg) => msg.get_message_name(), - SBP::MsgCommandReq(msg) => msg.get_message_name(), - SBP::MsgCommandResp(msg) => msg.get_message_name(), - SBP::MsgNetworkStateReq(msg) => msg.get_message_name(), - SBP::MsgNetworkStateResp(msg) => msg.get_message_name(), - SBP::MsgCommandOutput(msg) => msg.get_message_name(), - SBP::MsgNetworkBandwidthUsage(msg) => msg.get_message_name(), - SBP::MsgCellModemStatus(msg) => msg.get_message_name(), - SBP::MsgFrontEndGain(msg) => msg.get_message_name(), - SBP::MsgCwResults(msg) => msg.get_message_name(), - SBP::MsgCwStart(msg) => msg.get_message_name(), - SBP::MsgNapDeviceDnaResp(msg) => msg.get_message_name(), - SBP::MsgNapDeviceDnaReq(msg) => msg.get_message_name(), - SBP::MsgFlashDone(msg) => msg.get_message_name(), - SBP::MsgFlashReadResp(msg) => msg.get_message_name(), - SBP::MsgFlashErase(msg) => msg.get_message_name(), - SBP::MsgStmFlashLockSector(msg) => msg.get_message_name(), - SBP::MsgStmFlashUnlockSector(msg) => msg.get_message_name(), - SBP::MsgStmUniqueIdResp(msg) => msg.get_message_name(), - SBP::MsgFlashProgram(msg) => msg.get_message_name(), - SBP::MsgFlashReadReq(msg) => msg.get_message_name(), - SBP::MsgStmUniqueIdReq(msg) => msg.get_message_name(), - SBP::MsgM25FlashWriteStatus(msg) => msg.get_message_name(), - SBP::MsgGPSTimeDepA(msg) => msg.get_message_name(), - SBP::MsgExtEvent(msg) => msg.get_message_name(), - SBP::MsgGPSTime(msg) => msg.get_message_name(), - SBP::MsgUtcTime(msg) => msg.get_message_name(), - SBP::MsgGPSTimeGnss(msg) => msg.get_message_name(), - SBP::MsgUtcTimeGnss(msg) => msg.get_message_name(), - SBP::MsgSettingsRegisterResp(msg) => msg.get_message_name(), - SBP::MsgPosECEFDepA(msg) => msg.get_message_name(), - SBP::MsgPosLLHDepA(msg) => msg.get_message_name(), - SBP::MsgBaselineECEFDepA(msg) => msg.get_message_name(), - SBP::MsgBaselineNEDDepA(msg) => msg.get_message_name(), - SBP::MsgVelECEFDepA(msg) => msg.get_message_name(), - SBP::MsgVelNEDDepA(msg) => msg.get_message_name(), - SBP::MsgDopsDepA(msg) => msg.get_message_name(), - SBP::MsgBaselineHeadingDepA(msg) => msg.get_message_name(), - SBP::MsgDops(msg) => msg.get_message_name(), - SBP::MsgPosECEF(msg) => msg.get_message_name(), - SBP::MsgPosLLH(msg) => msg.get_message_name(), - SBP::MsgBaselineECEF(msg) => msg.get_message_name(), - SBP::MsgBaselineNED(msg) => msg.get_message_name(), - SBP::MsgVelECEF(msg) => msg.get_message_name(), - SBP::MsgVelNED(msg) => msg.get_message_name(), - SBP::MsgBaselineHeading(msg) => msg.get_message_name(), - SBP::MsgAgeCorrections(msg) => msg.get_message_name(), - SBP::MsgPosLLHCov(msg) => msg.get_message_name(), - SBP::MsgVelNEDCov(msg) => msg.get_message_name(), - SBP::MsgVelBody(msg) => msg.get_message_name(), - SBP::MsgPosECEFCov(msg) => msg.get_message_name(), - SBP::MsgVelECEFCov(msg) => msg.get_message_name(), - SBP::MsgProtectionLevelDepA(msg) => msg.get_message_name(), - SBP::MsgProtectionLevel(msg) => msg.get_message_name(), - SBP::MsgPosLLHAcc(msg) => msg.get_message_name(), - SBP::MsgOrientQuat(msg) => msg.get_message_name(), - SBP::MsgOrientEuler(msg) => msg.get_message_name(), - SBP::MsgAngularRate(msg) => msg.get_message_name(), - SBP::MsgPosECEFGnss(msg) => msg.get_message_name(), - SBP::MsgPosLLHGnss(msg) => msg.get_message_name(), - SBP::MsgVelECEFGnss(msg) => msg.get_message_name(), - SBP::MsgVelNEDGnss(msg) => msg.get_message_name(), - SBP::MsgPosLLHCovGnss(msg) => msg.get_message_name(), - SBP::MsgVelNEDCovGnss(msg) => msg.get_message_name(), - SBP::MsgPosECEFCovGnss(msg) => msg.get_message_name(), - SBP::MsgVelECEFCovGnss(msg) => msg.get_message_name(), - SBP::MsgNdbEvent(msg) => msg.get_message_name(), - SBP::MsgLog(msg) => msg.get_message_name(), - SBP::MsgFwd(msg) => msg.get_message_name(), - SBP::MsgSsrOrbitClockDepA(msg) => msg.get_message_name(), - SBP::MsgSsrOrbitClock(msg) => msg.get_message_name(), - SBP::MsgSsrCodeBiases(msg) => msg.get_message_name(), - SBP::MsgSsrPhaseBiases(msg) => msg.get_message_name(), - SBP::MsgSsrStecCorrectionDepA(msg) => msg.get_message_name(), - SBP::MsgSsrGriddedCorrectionNoStdDepA(msg) => msg.get_message_name(), - SBP::MsgSsrGridDefinitionDepA(msg) => msg.get_message_name(), - SBP::MsgSsrTileDefinition(msg) => msg.get_message_name(), - SBP::MsgSsrGriddedCorrectionDepA(msg) => msg.get_message_name(), - SBP::MsgSsrStecCorrection(msg) => msg.get_message_name(), - SBP::MsgSsrGriddedCorrection(msg) => msg.get_message_name(), - SBP::MsgSsrSatelliteApc(msg) => msg.get_message_name(), - SBP::MsgOsr(msg) => msg.get_message_name(), - SBP::MsgUserData(msg) => msg.get_message_name(), - SBP::MsgImuRaw(msg) => msg.get_message_name(), - SBP::MsgImuAux(msg) => msg.get_message_name(), - SBP::MsgMagRaw(msg) => msg.get_message_name(), - SBP::MsgOdometry(msg) => msg.get_message_name(), - SBP::MsgWheeltick(msg) => msg.get_message_name(), - SBP::MsgFileioConfigReq(msg) => msg.get_message_name(), - SBP::MsgFileioConfigResp(msg) => msg.get_message_name(), - SBP::MsgSbasRaw(msg) => msg.get_message_name(), - SBP::MsgLinuxCpuStateDepA(msg) => msg.get_message_name(), - SBP::MsgLinuxMemStateDepA(msg) => msg.get_message_name(), - SBP::MsgLinuxSysStateDepA(msg) => msg.get_message_name(), - SBP::MsgLinuxProcessSocketCounts(msg) => msg.get_message_name(), - SBP::MsgLinuxProcessSocketQueues(msg) => msg.get_message_name(), - SBP::MsgLinuxSocketUsage(msg) => msg.get_message_name(), - SBP::MsgLinuxProcessFdCount(msg) => msg.get_message_name(), - SBP::MsgLinuxProcessFdSummary(msg) => msg.get_message_name(), - SBP::MsgLinuxCpuState(msg) => msg.get_message_name(), - SBP::MsgLinuxMemState(msg) => msg.get_message_name(), - SBP::MsgLinuxSysState(msg) => msg.get_message_name(), - SBP::MsgStartup(msg) => msg.get_message_name(), - SBP::MsgDgnssStatus(msg) => msg.get_message_name(), - SBP::MsgInsStatus(msg) => msg.get_message_name(), - SBP::MsgCsacTelemetry(msg) => msg.get_message_name(), - SBP::MsgCsacTelemetryLabels(msg) => msg.get_message_name(), - SBP::MsgInsUpdates(msg) => msg.get_message_name(), - SBP::MsgGnssTimeOffset(msg) => msg.get_message_name(), - SBP::MsgPpsTime(msg) => msg.get_message_name(), - SBP::MsgGroupMeta(msg) => msg.get_message_name(), - SBP::MsgSolnMeta(msg) => msg.get_message_name(), - SBP::MsgSolnMetaDepA(msg) => msg.get_message_name(), - SBP::MsgStatusReport(msg) => msg.get_message_name(), - SBP::MsgHeartbeat(msg) => msg.get_message_name(), - SBP::Unknown(msg) => msg.get_message_name(), + Sbp::MsgPrintDep(msg) => msg.message_name(), + Sbp::MsgTrackingStateDetailedDep(msg) => msg.message_name(), + Sbp::MsgTrackingStateDepB(msg) => msg.message_name(), + Sbp::MsgAcqResultDepB(msg) => msg.message_name(), + Sbp::MsgAcqResultDepA(msg) => msg.message_name(), + Sbp::MsgTrackingStateDepA(msg) => msg.message_name(), + Sbp::MsgThreadState(msg) => msg.message_name(), + Sbp::MsgUartStateDepa(msg) => msg.message_name(), + Sbp::MsgIarState(msg) => msg.message_name(), + Sbp::MsgEphemerisDepA(msg) => msg.message_name(), + Sbp::MsgMaskSatelliteDep(msg) => msg.message_name(), + Sbp::MsgTrackingIqDepA(msg) => msg.message_name(), + Sbp::MsgUartState(msg) => msg.message_name(), + Sbp::MsgAcqSvProfileDep(msg) => msg.message_name(), + Sbp::MsgAcqResultDepC(msg) => msg.message_name(), + Sbp::MsgTrackingStateDetailedDepA(msg) => msg.message_name(), + Sbp::MsgResetFilters(msg) => msg.message_name(), + Sbp::MsgInitBaseDep(msg) => msg.message_name(), + Sbp::MsgMaskSatellite(msg) => msg.message_name(), + Sbp::MsgTrackingIqDepB(msg) => msg.message_name(), + Sbp::MsgTrackingIq(msg) => msg.message_name(), + Sbp::MsgAcqSvProfile(msg) => msg.message_name(), + Sbp::MsgAcqResult(msg) => msg.message_name(), + Sbp::MsgTrackingState(msg) => msg.message_name(), + Sbp::MsgObsDepB(msg) => msg.message_name(), + Sbp::MsgBasePosLlh(msg) => msg.message_name(), + Sbp::MsgObsDepA(msg) => msg.message_name(), + Sbp::MsgEphemerisDepB(msg) => msg.message_name(), + Sbp::MsgEphemerisDepC(msg) => msg.message_name(), + Sbp::MsgBasePosEcef(msg) => msg.message_name(), + Sbp::MsgObsDepC(msg) => msg.message_name(), + Sbp::MsgObs(msg) => msg.message_name(), + Sbp::MsgSpecanDep(msg) => msg.message_name(), + Sbp::MsgSpecan(msg) => msg.message_name(), + Sbp::MsgMeasurementState(msg) => msg.message_name(), + Sbp::MsgSetTime(msg) => msg.message_name(), + Sbp::MsgAlmanac(msg) => msg.message_name(), + Sbp::MsgAlmanacGpsDep(msg) => msg.message_name(), + Sbp::MsgAlmanacGloDep(msg) => msg.message_name(), + Sbp::MsgAlmanacGps(msg) => msg.message_name(), + Sbp::MsgAlmanacGlo(msg) => msg.message_name(), + Sbp::MsgGloBiases(msg) => msg.message_name(), + Sbp::MsgEphemerisDepD(msg) => msg.message_name(), + Sbp::MsgEphemerisGpsDepE(msg) => msg.message_name(), + Sbp::MsgEphemerisSbasDepA(msg) => msg.message_name(), + Sbp::MsgEphemerisGloDepA(msg) => msg.message_name(), + Sbp::MsgEphemerisSbasDepB(msg) => msg.message_name(), + Sbp::MsgEphemerisGloDepB(msg) => msg.message_name(), + Sbp::MsgEphemerisGpsDepF(msg) => msg.message_name(), + Sbp::MsgEphemerisGloDepC(msg) => msg.message_name(), + Sbp::MsgEphemerisGloDepD(msg) => msg.message_name(), + Sbp::MsgEphemerisBds(msg) => msg.message_name(), + Sbp::MsgEphemerisGps(msg) => msg.message_name(), + Sbp::MsgEphemerisGlo(msg) => msg.message_name(), + Sbp::MsgEphemerisSbas(msg) => msg.message_name(), + Sbp::MsgEphemerisGal(msg) => msg.message_name(), + Sbp::MsgEphemerisQzss(msg) => msg.message_name(), + Sbp::MsgIono(msg) => msg.message_name(), + Sbp::MsgSvConfigurationGpsDep(msg) => msg.message_name(), + Sbp::MsgGroupDelayDepA(msg) => msg.message_name(), + Sbp::MsgGroupDelayDepB(msg) => msg.message_name(), + Sbp::MsgGroupDelay(msg) => msg.message_name(), + Sbp::MsgEphemerisGalDepA(msg) => msg.message_name(), + Sbp::MsgGnssCapb(msg) => msg.message_name(), + Sbp::MsgSvAzEl(msg) => msg.message_name(), + Sbp::MsgSettingsWrite(msg) => msg.message_name(), + Sbp::MsgSettingsSave(msg) => msg.message_name(), + Sbp::MsgSettingsReadByIndexReq(msg) => msg.message_name(), + Sbp::MsgFileioReadResp(msg) => msg.message_name(), + Sbp::MsgSettingsReadReq(msg) => msg.message_name(), + Sbp::MsgSettingsReadResp(msg) => msg.message_name(), + Sbp::MsgSettingsReadByIndexDone(msg) => msg.message_name(), + Sbp::MsgSettingsReadByIndexResp(msg) => msg.message_name(), + Sbp::MsgFileioReadReq(msg) => msg.message_name(), + Sbp::MsgFileioReadDirReq(msg) => msg.message_name(), + Sbp::MsgFileioReadDirResp(msg) => msg.message_name(), + Sbp::MsgFileioWriteResp(msg) => msg.message_name(), + Sbp::MsgFileioRemove(msg) => msg.message_name(), + Sbp::MsgFileioWriteReq(msg) => msg.message_name(), + Sbp::MsgSettingsRegister(msg) => msg.message_name(), + Sbp::MsgSettingsWriteResp(msg) => msg.message_name(), + Sbp::MsgBootloaderHandshakeDepA(msg) => msg.message_name(), + Sbp::MsgBootloaderJumpToApp(msg) => msg.message_name(), + Sbp::MsgResetDep(msg) => msg.message_name(), + Sbp::MsgBootloaderHandshakeReq(msg) => msg.message_name(), + Sbp::MsgBootloaderHandshakeResp(msg) => msg.message_name(), + Sbp::MsgDeviceMonitor(msg) => msg.message_name(), + Sbp::MsgReset(msg) => msg.message_name(), + Sbp::MsgCommandReq(msg) => msg.message_name(), + Sbp::MsgCommandResp(msg) => msg.message_name(), + Sbp::MsgNetworkStateReq(msg) => msg.message_name(), + Sbp::MsgNetworkStateResp(msg) => msg.message_name(), + Sbp::MsgCommandOutput(msg) => msg.message_name(), + Sbp::MsgNetworkBandwidthUsage(msg) => msg.message_name(), + Sbp::MsgCellModemStatus(msg) => msg.message_name(), + Sbp::MsgFrontEndGain(msg) => msg.message_name(), + Sbp::MsgCwResults(msg) => msg.message_name(), + Sbp::MsgCwStart(msg) => msg.message_name(), + Sbp::MsgNapDeviceDnaResp(msg) => msg.message_name(), + Sbp::MsgNapDeviceDnaReq(msg) => msg.message_name(), + Sbp::MsgFlashDone(msg) => msg.message_name(), + Sbp::MsgFlashReadResp(msg) => msg.message_name(), + Sbp::MsgFlashErase(msg) => msg.message_name(), + Sbp::MsgStmFlashLockSector(msg) => msg.message_name(), + Sbp::MsgStmFlashUnlockSector(msg) => msg.message_name(), + Sbp::MsgStmUniqueIdResp(msg) => msg.message_name(), + Sbp::MsgFlashProgram(msg) => msg.message_name(), + Sbp::MsgFlashReadReq(msg) => msg.message_name(), + Sbp::MsgStmUniqueIdReq(msg) => msg.message_name(), + Sbp::MsgM25FlashWriteStatus(msg) => msg.message_name(), + Sbp::MsgGpsTimeDepA(msg) => msg.message_name(), + Sbp::MsgExtEvent(msg) => msg.message_name(), + Sbp::MsgGpsTime(msg) => msg.message_name(), + Sbp::MsgUtcTime(msg) => msg.message_name(), + Sbp::MsgGpsTimeGnss(msg) => msg.message_name(), + Sbp::MsgUtcTimeGnss(msg) => msg.message_name(), + Sbp::MsgSettingsRegisterResp(msg) => msg.message_name(), + Sbp::MsgPosEcefDepA(msg) => msg.message_name(), + Sbp::MsgPosLlhDepA(msg) => msg.message_name(), + Sbp::MsgBaselineEcefDepA(msg) => msg.message_name(), + Sbp::MsgBaselineNedDepA(msg) => msg.message_name(), + Sbp::MsgVelEcefDepA(msg) => msg.message_name(), + Sbp::MsgVelNedDepA(msg) => msg.message_name(), + Sbp::MsgDopsDepA(msg) => msg.message_name(), + Sbp::MsgBaselineHeadingDepA(msg) => msg.message_name(), + Sbp::MsgDops(msg) => msg.message_name(), + Sbp::MsgPosEcef(msg) => msg.message_name(), + Sbp::MsgPosLlh(msg) => msg.message_name(), + Sbp::MsgBaselineEcef(msg) => msg.message_name(), + Sbp::MsgBaselineNed(msg) => msg.message_name(), + Sbp::MsgVelEcef(msg) => msg.message_name(), + Sbp::MsgVelNed(msg) => msg.message_name(), + Sbp::MsgBaselineHeading(msg) => msg.message_name(), + Sbp::MsgAgeCorrections(msg) => msg.message_name(), + Sbp::MsgPosLlhCov(msg) => msg.message_name(), + Sbp::MsgVelNedCov(msg) => msg.message_name(), + Sbp::MsgVelBody(msg) => msg.message_name(), + Sbp::MsgPosEcefCov(msg) => msg.message_name(), + Sbp::MsgVelEcefCov(msg) => msg.message_name(), + Sbp::MsgProtectionLevelDepA(msg) => msg.message_name(), + Sbp::MsgProtectionLevel(msg) => msg.message_name(), + Sbp::MsgPosLlhAcc(msg) => msg.message_name(), + Sbp::MsgOrientQuat(msg) => msg.message_name(), + Sbp::MsgOrientEuler(msg) => msg.message_name(), + Sbp::MsgAngularRate(msg) => msg.message_name(), + Sbp::MsgPosEcefGnss(msg) => msg.message_name(), + Sbp::MsgPosLlhGnss(msg) => msg.message_name(), + Sbp::MsgVelEcefGnss(msg) => msg.message_name(), + Sbp::MsgVelNedGnss(msg) => msg.message_name(), + Sbp::MsgPosLlhCovGnss(msg) => msg.message_name(), + Sbp::MsgVelNedCovGnss(msg) => msg.message_name(), + Sbp::MsgPosEcefCovGnss(msg) => msg.message_name(), + Sbp::MsgVelEcefCovGnss(msg) => msg.message_name(), + Sbp::MsgNdbEvent(msg) => msg.message_name(), + Sbp::MsgLog(msg) => msg.message_name(), + Sbp::MsgFwd(msg) => msg.message_name(), + Sbp::MsgSsrOrbitClockDepA(msg) => msg.message_name(), + Sbp::MsgSsrOrbitClock(msg) => msg.message_name(), + Sbp::MsgSsrCodeBiases(msg) => msg.message_name(), + Sbp::MsgSsrPhaseBiases(msg) => msg.message_name(), + Sbp::MsgSsrStecCorrectionDepA(msg) => msg.message_name(), + Sbp::MsgSsrGriddedCorrectionNoStdDepA(msg) => msg.message_name(), + Sbp::MsgSsrGridDefinitionDepA(msg) => msg.message_name(), + Sbp::MsgSsrTileDefinition(msg) => msg.message_name(), + Sbp::MsgSsrGriddedCorrectionDepA(msg) => msg.message_name(), + Sbp::MsgSsrStecCorrection(msg) => msg.message_name(), + Sbp::MsgSsrGriddedCorrection(msg) => msg.message_name(), + Sbp::MsgSsrSatelliteApc(msg) => msg.message_name(), + Sbp::MsgOsr(msg) => msg.message_name(), + Sbp::MsgUserData(msg) => msg.message_name(), + Sbp::MsgImuRaw(msg) => msg.message_name(), + Sbp::MsgImuAux(msg) => msg.message_name(), + Sbp::MsgMagRaw(msg) => msg.message_name(), + Sbp::MsgOdometry(msg) => msg.message_name(), + Sbp::MsgWheeltick(msg) => msg.message_name(), + Sbp::MsgFileioConfigReq(msg) => msg.message_name(), + Sbp::MsgFileioConfigResp(msg) => msg.message_name(), + Sbp::MsgSbasRaw(msg) => msg.message_name(), + Sbp::MsgLinuxCpuStateDepA(msg) => msg.message_name(), + Sbp::MsgLinuxMemStateDepA(msg) => msg.message_name(), + Sbp::MsgLinuxSysStateDepA(msg) => msg.message_name(), + Sbp::MsgLinuxProcessSocketCounts(msg) => msg.message_name(), + Sbp::MsgLinuxProcessSocketQueues(msg) => msg.message_name(), + Sbp::MsgLinuxSocketUsage(msg) => msg.message_name(), + Sbp::MsgLinuxProcessFdCount(msg) => msg.message_name(), + Sbp::MsgLinuxProcessFdSummary(msg) => msg.message_name(), + Sbp::MsgLinuxCpuState(msg) => msg.message_name(), + Sbp::MsgLinuxMemState(msg) => msg.message_name(), + Sbp::MsgLinuxSysState(msg) => msg.message_name(), + Sbp::MsgStartup(msg) => msg.message_name(), + Sbp::MsgDgnssStatus(msg) => msg.message_name(), + Sbp::MsgInsStatus(msg) => msg.message_name(), + Sbp::MsgCsacTelemetry(msg) => msg.message_name(), + Sbp::MsgCsacTelemetryLabels(msg) => msg.message_name(), + Sbp::MsgInsUpdates(msg) => msg.message_name(), + Sbp::MsgGnssTimeOffset(msg) => msg.message_name(), + Sbp::MsgPpsTime(msg) => msg.message_name(), + Sbp::MsgGroupMeta(msg) => msg.message_name(), + Sbp::MsgSolnMeta(msg) => msg.message_name(), + Sbp::MsgSolnMetaDepA(msg) => msg.message_name(), + Sbp::MsgStatusReport(msg) => msg.message_name(), + Sbp::MsgHeartbeat(msg) => msg.message_name(), + Sbp::Unknown(msg) => msg.message_name(), } } - fn get_message_type(&self) -> u16 { + fn message_type(&self) -> u16 { match self { - SBP::MsgPrintDep(msg) => msg.get_message_type(), - SBP::MsgTrackingStateDetailedDep(msg) => msg.get_message_type(), - SBP::MsgTrackingStateDepB(msg) => msg.get_message_type(), - SBP::MsgAcqResultDepB(msg) => msg.get_message_type(), - SBP::MsgAcqResultDepA(msg) => msg.get_message_type(), - SBP::MsgTrackingStateDepA(msg) => msg.get_message_type(), - SBP::MsgThreadState(msg) => msg.get_message_type(), - SBP::MsgUartStateDepa(msg) => msg.get_message_type(), - SBP::MsgIarState(msg) => msg.get_message_type(), - SBP::MsgEphemerisDepA(msg) => msg.get_message_type(), - SBP::MsgMaskSatelliteDep(msg) => msg.get_message_type(), - SBP::MsgTrackingIqDepA(msg) => msg.get_message_type(), - SBP::MsgUartState(msg) => msg.get_message_type(), - SBP::MsgAcqSvProfileDep(msg) => msg.get_message_type(), - SBP::MsgAcqResultDepC(msg) => msg.get_message_type(), - SBP::MsgTrackingStateDetailedDepA(msg) => msg.get_message_type(), - SBP::MsgResetFilters(msg) => msg.get_message_type(), - SBP::MsgInitBaseDep(msg) => msg.get_message_type(), - SBP::MsgMaskSatellite(msg) => msg.get_message_type(), - SBP::MsgTrackingIqDepB(msg) => msg.get_message_type(), - SBP::MsgTrackingIq(msg) => msg.get_message_type(), - SBP::MsgAcqSvProfile(msg) => msg.get_message_type(), - SBP::MsgAcqResult(msg) => msg.get_message_type(), - SBP::MsgTrackingState(msg) => msg.get_message_type(), - SBP::MsgObsDepB(msg) => msg.get_message_type(), - SBP::MsgBasePosLLH(msg) => msg.get_message_type(), - SBP::MsgObsDepA(msg) => msg.get_message_type(), - SBP::MsgEphemerisDepB(msg) => msg.get_message_type(), - SBP::MsgEphemerisDepC(msg) => msg.get_message_type(), - SBP::MsgBasePosECEF(msg) => msg.get_message_type(), - SBP::MsgObsDepC(msg) => msg.get_message_type(), - SBP::MsgObs(msg) => msg.get_message_type(), - SBP::MsgSpecanDep(msg) => msg.get_message_type(), - SBP::MsgSpecan(msg) => msg.get_message_type(), - SBP::MsgMeasurementState(msg) => msg.get_message_type(), - SBP::MsgSetTime(msg) => msg.get_message_type(), - SBP::MsgAlmanac(msg) => msg.get_message_type(), - SBP::MsgAlmanacGPSDep(msg) => msg.get_message_type(), - SBP::MsgAlmanacGloDep(msg) => msg.get_message_type(), - SBP::MsgAlmanacGPS(msg) => msg.get_message_type(), - SBP::MsgAlmanacGlo(msg) => msg.get_message_type(), - SBP::MsgGloBiases(msg) => msg.get_message_type(), - SBP::MsgEphemerisDepD(msg) => msg.get_message_type(), - SBP::MsgEphemerisGPSDepE(msg) => msg.get_message_type(), - SBP::MsgEphemerisSbasDepA(msg) => msg.get_message_type(), - SBP::MsgEphemerisGloDepA(msg) => msg.get_message_type(), - SBP::MsgEphemerisSbasDepB(msg) => msg.get_message_type(), - SBP::MsgEphemerisGloDepB(msg) => msg.get_message_type(), - SBP::MsgEphemerisGPSDepF(msg) => msg.get_message_type(), - SBP::MsgEphemerisGloDepC(msg) => msg.get_message_type(), - SBP::MsgEphemerisGloDepD(msg) => msg.get_message_type(), - SBP::MsgEphemerisBds(msg) => msg.get_message_type(), - SBP::MsgEphemerisGPS(msg) => msg.get_message_type(), - SBP::MsgEphemerisGlo(msg) => msg.get_message_type(), - SBP::MsgEphemerisSbas(msg) => msg.get_message_type(), - SBP::MsgEphemerisGal(msg) => msg.get_message_type(), - SBP::MsgEphemerisQzss(msg) => msg.get_message_type(), - SBP::MsgIono(msg) => msg.get_message_type(), - SBP::MsgSvConfigurationGPSDep(msg) => msg.get_message_type(), - SBP::MsgGroupDelayDepA(msg) => msg.get_message_type(), - SBP::MsgGroupDelayDepB(msg) => msg.get_message_type(), - SBP::MsgGroupDelay(msg) => msg.get_message_type(), - SBP::MsgEphemerisGalDepA(msg) => msg.get_message_type(), - SBP::MsgGnssCapb(msg) => msg.get_message_type(), - SBP::MsgSvAzEl(msg) => msg.get_message_type(), - SBP::MsgSettingsWrite(msg) => msg.get_message_type(), - SBP::MsgSettingsSave(msg) => msg.get_message_type(), - SBP::MsgSettingsReadByIndexReq(msg) => msg.get_message_type(), - SBP::MsgFileioReadResp(msg) => msg.get_message_type(), - SBP::MsgSettingsReadReq(msg) => msg.get_message_type(), - SBP::MsgSettingsReadResp(msg) => msg.get_message_type(), - SBP::MsgSettingsReadByIndexDone(msg) => msg.get_message_type(), - SBP::MsgSettingsReadByIndexResp(msg) => msg.get_message_type(), - SBP::MsgFileioReadReq(msg) => msg.get_message_type(), - SBP::MsgFileioReadDirReq(msg) => msg.get_message_type(), - SBP::MsgFileioReadDirResp(msg) => msg.get_message_type(), - SBP::MsgFileioWriteResp(msg) => msg.get_message_type(), - SBP::MsgFileioRemove(msg) => msg.get_message_type(), - SBP::MsgFileioWriteReq(msg) => msg.get_message_type(), - SBP::MsgSettingsRegister(msg) => msg.get_message_type(), - SBP::MsgSettingsWriteResp(msg) => msg.get_message_type(), - SBP::MsgBootloaderHandshakeDepA(msg) => msg.get_message_type(), - SBP::MsgBootloaderJumpToApp(msg) => msg.get_message_type(), - SBP::MsgResetDep(msg) => msg.get_message_type(), - SBP::MsgBootloaderHandshakeReq(msg) => msg.get_message_type(), - SBP::MsgBootloaderHandshakeResp(msg) => msg.get_message_type(), - SBP::MsgDeviceMonitor(msg) => msg.get_message_type(), - SBP::MsgReset(msg) => msg.get_message_type(), - SBP::MsgCommandReq(msg) => msg.get_message_type(), - SBP::MsgCommandResp(msg) => msg.get_message_type(), - SBP::MsgNetworkStateReq(msg) => msg.get_message_type(), - SBP::MsgNetworkStateResp(msg) => msg.get_message_type(), - SBP::MsgCommandOutput(msg) => msg.get_message_type(), - SBP::MsgNetworkBandwidthUsage(msg) => msg.get_message_type(), - SBP::MsgCellModemStatus(msg) => msg.get_message_type(), - SBP::MsgFrontEndGain(msg) => msg.get_message_type(), - SBP::MsgCwResults(msg) => msg.get_message_type(), - SBP::MsgCwStart(msg) => msg.get_message_type(), - SBP::MsgNapDeviceDnaResp(msg) => msg.get_message_type(), - SBP::MsgNapDeviceDnaReq(msg) => msg.get_message_type(), - SBP::MsgFlashDone(msg) => msg.get_message_type(), - SBP::MsgFlashReadResp(msg) => msg.get_message_type(), - SBP::MsgFlashErase(msg) => msg.get_message_type(), - SBP::MsgStmFlashLockSector(msg) => msg.get_message_type(), - SBP::MsgStmFlashUnlockSector(msg) => msg.get_message_type(), - SBP::MsgStmUniqueIdResp(msg) => msg.get_message_type(), - SBP::MsgFlashProgram(msg) => msg.get_message_type(), - SBP::MsgFlashReadReq(msg) => msg.get_message_type(), - SBP::MsgStmUniqueIdReq(msg) => msg.get_message_type(), - SBP::MsgM25FlashWriteStatus(msg) => msg.get_message_type(), - SBP::MsgGPSTimeDepA(msg) => msg.get_message_type(), - SBP::MsgExtEvent(msg) => msg.get_message_type(), - SBP::MsgGPSTime(msg) => msg.get_message_type(), - SBP::MsgUtcTime(msg) => msg.get_message_type(), - SBP::MsgGPSTimeGnss(msg) => msg.get_message_type(), - SBP::MsgUtcTimeGnss(msg) => msg.get_message_type(), - SBP::MsgSettingsRegisterResp(msg) => msg.get_message_type(), - SBP::MsgPosECEFDepA(msg) => msg.get_message_type(), - SBP::MsgPosLLHDepA(msg) => msg.get_message_type(), - SBP::MsgBaselineECEFDepA(msg) => msg.get_message_type(), - SBP::MsgBaselineNEDDepA(msg) => msg.get_message_type(), - SBP::MsgVelECEFDepA(msg) => msg.get_message_type(), - SBP::MsgVelNEDDepA(msg) => msg.get_message_type(), - SBP::MsgDopsDepA(msg) => msg.get_message_type(), - SBP::MsgBaselineHeadingDepA(msg) => msg.get_message_type(), - SBP::MsgDops(msg) => msg.get_message_type(), - SBP::MsgPosECEF(msg) => msg.get_message_type(), - SBP::MsgPosLLH(msg) => msg.get_message_type(), - SBP::MsgBaselineECEF(msg) => msg.get_message_type(), - SBP::MsgBaselineNED(msg) => msg.get_message_type(), - SBP::MsgVelECEF(msg) => msg.get_message_type(), - SBP::MsgVelNED(msg) => msg.get_message_type(), - SBP::MsgBaselineHeading(msg) => msg.get_message_type(), - SBP::MsgAgeCorrections(msg) => msg.get_message_type(), - SBP::MsgPosLLHCov(msg) => msg.get_message_type(), - SBP::MsgVelNEDCov(msg) => msg.get_message_type(), - SBP::MsgVelBody(msg) => msg.get_message_type(), - SBP::MsgPosECEFCov(msg) => msg.get_message_type(), - SBP::MsgVelECEFCov(msg) => msg.get_message_type(), - SBP::MsgProtectionLevelDepA(msg) => msg.get_message_type(), - SBP::MsgProtectionLevel(msg) => msg.get_message_type(), - SBP::MsgPosLLHAcc(msg) => msg.get_message_type(), - SBP::MsgOrientQuat(msg) => msg.get_message_type(), - SBP::MsgOrientEuler(msg) => msg.get_message_type(), - SBP::MsgAngularRate(msg) => msg.get_message_type(), - SBP::MsgPosECEFGnss(msg) => msg.get_message_type(), - SBP::MsgPosLLHGnss(msg) => msg.get_message_type(), - SBP::MsgVelECEFGnss(msg) => msg.get_message_type(), - SBP::MsgVelNEDGnss(msg) => msg.get_message_type(), - SBP::MsgPosLLHCovGnss(msg) => msg.get_message_type(), - SBP::MsgVelNEDCovGnss(msg) => msg.get_message_type(), - SBP::MsgPosECEFCovGnss(msg) => msg.get_message_type(), - SBP::MsgVelECEFCovGnss(msg) => msg.get_message_type(), - SBP::MsgNdbEvent(msg) => msg.get_message_type(), - SBP::MsgLog(msg) => msg.get_message_type(), - SBP::MsgFwd(msg) => msg.get_message_type(), - SBP::MsgSsrOrbitClockDepA(msg) => msg.get_message_type(), - SBP::MsgSsrOrbitClock(msg) => msg.get_message_type(), - SBP::MsgSsrCodeBiases(msg) => msg.get_message_type(), - SBP::MsgSsrPhaseBiases(msg) => msg.get_message_type(), - SBP::MsgSsrStecCorrectionDepA(msg) => msg.get_message_type(), - SBP::MsgSsrGriddedCorrectionNoStdDepA(msg) => msg.get_message_type(), - SBP::MsgSsrGridDefinitionDepA(msg) => msg.get_message_type(), - SBP::MsgSsrTileDefinition(msg) => msg.get_message_type(), - SBP::MsgSsrGriddedCorrectionDepA(msg) => msg.get_message_type(), - SBP::MsgSsrStecCorrection(msg) => msg.get_message_type(), - SBP::MsgSsrGriddedCorrection(msg) => msg.get_message_type(), - SBP::MsgSsrSatelliteApc(msg) => msg.get_message_type(), - SBP::MsgOsr(msg) => msg.get_message_type(), - SBP::MsgUserData(msg) => msg.get_message_type(), - SBP::MsgImuRaw(msg) => msg.get_message_type(), - SBP::MsgImuAux(msg) => msg.get_message_type(), - SBP::MsgMagRaw(msg) => msg.get_message_type(), - SBP::MsgOdometry(msg) => msg.get_message_type(), - SBP::MsgWheeltick(msg) => msg.get_message_type(), - SBP::MsgFileioConfigReq(msg) => msg.get_message_type(), - SBP::MsgFileioConfigResp(msg) => msg.get_message_type(), - SBP::MsgSbasRaw(msg) => msg.get_message_type(), - SBP::MsgLinuxCpuStateDepA(msg) => msg.get_message_type(), - SBP::MsgLinuxMemStateDepA(msg) => msg.get_message_type(), - SBP::MsgLinuxSysStateDepA(msg) => msg.get_message_type(), - SBP::MsgLinuxProcessSocketCounts(msg) => msg.get_message_type(), - SBP::MsgLinuxProcessSocketQueues(msg) => msg.get_message_type(), - SBP::MsgLinuxSocketUsage(msg) => msg.get_message_type(), - SBP::MsgLinuxProcessFdCount(msg) => msg.get_message_type(), - SBP::MsgLinuxProcessFdSummary(msg) => msg.get_message_type(), - SBP::MsgLinuxCpuState(msg) => msg.get_message_type(), - SBP::MsgLinuxMemState(msg) => msg.get_message_type(), - SBP::MsgLinuxSysState(msg) => msg.get_message_type(), - SBP::MsgStartup(msg) => msg.get_message_type(), - SBP::MsgDgnssStatus(msg) => msg.get_message_type(), - SBP::MsgInsStatus(msg) => msg.get_message_type(), - SBP::MsgCsacTelemetry(msg) => msg.get_message_type(), - SBP::MsgCsacTelemetryLabels(msg) => msg.get_message_type(), - SBP::MsgInsUpdates(msg) => msg.get_message_type(), - SBP::MsgGnssTimeOffset(msg) => msg.get_message_type(), - SBP::MsgPpsTime(msg) => msg.get_message_type(), - SBP::MsgGroupMeta(msg) => msg.get_message_type(), - SBP::MsgSolnMeta(msg) => msg.get_message_type(), - SBP::MsgSolnMetaDepA(msg) => msg.get_message_type(), - SBP::MsgStatusReport(msg) => msg.get_message_type(), - SBP::MsgHeartbeat(msg) => msg.get_message_type(), - SBP::Unknown(msg) => msg.get_message_type(), + Sbp::MsgPrintDep(msg) => msg.message_type(), + Sbp::MsgTrackingStateDetailedDep(msg) => msg.message_type(), + Sbp::MsgTrackingStateDepB(msg) => msg.message_type(), + Sbp::MsgAcqResultDepB(msg) => msg.message_type(), + Sbp::MsgAcqResultDepA(msg) => msg.message_type(), + Sbp::MsgTrackingStateDepA(msg) => msg.message_type(), + Sbp::MsgThreadState(msg) => msg.message_type(), + Sbp::MsgUartStateDepa(msg) => msg.message_type(), + Sbp::MsgIarState(msg) => msg.message_type(), + Sbp::MsgEphemerisDepA(msg) => msg.message_type(), + Sbp::MsgMaskSatelliteDep(msg) => msg.message_type(), + Sbp::MsgTrackingIqDepA(msg) => msg.message_type(), + Sbp::MsgUartState(msg) => msg.message_type(), + Sbp::MsgAcqSvProfileDep(msg) => msg.message_type(), + Sbp::MsgAcqResultDepC(msg) => msg.message_type(), + Sbp::MsgTrackingStateDetailedDepA(msg) => msg.message_type(), + Sbp::MsgResetFilters(msg) => msg.message_type(), + Sbp::MsgInitBaseDep(msg) => msg.message_type(), + Sbp::MsgMaskSatellite(msg) => msg.message_type(), + Sbp::MsgTrackingIqDepB(msg) => msg.message_type(), + Sbp::MsgTrackingIq(msg) => msg.message_type(), + Sbp::MsgAcqSvProfile(msg) => msg.message_type(), + Sbp::MsgAcqResult(msg) => msg.message_type(), + Sbp::MsgTrackingState(msg) => msg.message_type(), + Sbp::MsgObsDepB(msg) => msg.message_type(), + Sbp::MsgBasePosLlh(msg) => msg.message_type(), + Sbp::MsgObsDepA(msg) => msg.message_type(), + Sbp::MsgEphemerisDepB(msg) => msg.message_type(), + Sbp::MsgEphemerisDepC(msg) => msg.message_type(), + Sbp::MsgBasePosEcef(msg) => msg.message_type(), + Sbp::MsgObsDepC(msg) => msg.message_type(), + Sbp::MsgObs(msg) => msg.message_type(), + Sbp::MsgSpecanDep(msg) => msg.message_type(), + Sbp::MsgSpecan(msg) => msg.message_type(), + Sbp::MsgMeasurementState(msg) => msg.message_type(), + Sbp::MsgSetTime(msg) => msg.message_type(), + Sbp::MsgAlmanac(msg) => msg.message_type(), + Sbp::MsgAlmanacGpsDep(msg) => msg.message_type(), + Sbp::MsgAlmanacGloDep(msg) => msg.message_type(), + Sbp::MsgAlmanacGps(msg) => msg.message_type(), + Sbp::MsgAlmanacGlo(msg) => msg.message_type(), + Sbp::MsgGloBiases(msg) => msg.message_type(), + Sbp::MsgEphemerisDepD(msg) => msg.message_type(), + Sbp::MsgEphemerisGpsDepE(msg) => msg.message_type(), + Sbp::MsgEphemerisSbasDepA(msg) => msg.message_type(), + Sbp::MsgEphemerisGloDepA(msg) => msg.message_type(), + Sbp::MsgEphemerisSbasDepB(msg) => msg.message_type(), + Sbp::MsgEphemerisGloDepB(msg) => msg.message_type(), + Sbp::MsgEphemerisGpsDepF(msg) => msg.message_type(), + Sbp::MsgEphemerisGloDepC(msg) => msg.message_type(), + Sbp::MsgEphemerisGloDepD(msg) => msg.message_type(), + Sbp::MsgEphemerisBds(msg) => msg.message_type(), + Sbp::MsgEphemerisGps(msg) => msg.message_type(), + Sbp::MsgEphemerisGlo(msg) => msg.message_type(), + Sbp::MsgEphemerisSbas(msg) => msg.message_type(), + Sbp::MsgEphemerisGal(msg) => msg.message_type(), + Sbp::MsgEphemerisQzss(msg) => msg.message_type(), + Sbp::MsgIono(msg) => msg.message_type(), + Sbp::MsgSvConfigurationGpsDep(msg) => msg.message_type(), + Sbp::MsgGroupDelayDepA(msg) => msg.message_type(), + Sbp::MsgGroupDelayDepB(msg) => msg.message_type(), + Sbp::MsgGroupDelay(msg) => msg.message_type(), + Sbp::MsgEphemerisGalDepA(msg) => msg.message_type(), + Sbp::MsgGnssCapb(msg) => msg.message_type(), + Sbp::MsgSvAzEl(msg) => msg.message_type(), + Sbp::MsgSettingsWrite(msg) => msg.message_type(), + Sbp::MsgSettingsSave(msg) => msg.message_type(), + Sbp::MsgSettingsReadByIndexReq(msg) => msg.message_type(), + Sbp::MsgFileioReadResp(msg) => msg.message_type(), + Sbp::MsgSettingsReadReq(msg) => msg.message_type(), + Sbp::MsgSettingsReadResp(msg) => msg.message_type(), + Sbp::MsgSettingsReadByIndexDone(msg) => msg.message_type(), + Sbp::MsgSettingsReadByIndexResp(msg) => msg.message_type(), + Sbp::MsgFileioReadReq(msg) => msg.message_type(), + Sbp::MsgFileioReadDirReq(msg) => msg.message_type(), + Sbp::MsgFileioReadDirResp(msg) => msg.message_type(), + Sbp::MsgFileioWriteResp(msg) => msg.message_type(), + Sbp::MsgFileioRemove(msg) => msg.message_type(), + Sbp::MsgFileioWriteReq(msg) => msg.message_type(), + Sbp::MsgSettingsRegister(msg) => msg.message_type(), + Sbp::MsgSettingsWriteResp(msg) => msg.message_type(), + Sbp::MsgBootloaderHandshakeDepA(msg) => msg.message_type(), + Sbp::MsgBootloaderJumpToApp(msg) => msg.message_type(), + Sbp::MsgResetDep(msg) => msg.message_type(), + Sbp::MsgBootloaderHandshakeReq(msg) => msg.message_type(), + Sbp::MsgBootloaderHandshakeResp(msg) => msg.message_type(), + Sbp::MsgDeviceMonitor(msg) => msg.message_type(), + Sbp::MsgReset(msg) => msg.message_type(), + Sbp::MsgCommandReq(msg) => msg.message_type(), + Sbp::MsgCommandResp(msg) => msg.message_type(), + Sbp::MsgNetworkStateReq(msg) => msg.message_type(), + Sbp::MsgNetworkStateResp(msg) => msg.message_type(), + Sbp::MsgCommandOutput(msg) => msg.message_type(), + Sbp::MsgNetworkBandwidthUsage(msg) => msg.message_type(), + Sbp::MsgCellModemStatus(msg) => msg.message_type(), + Sbp::MsgFrontEndGain(msg) => msg.message_type(), + Sbp::MsgCwResults(msg) => msg.message_type(), + Sbp::MsgCwStart(msg) => msg.message_type(), + Sbp::MsgNapDeviceDnaResp(msg) => msg.message_type(), + Sbp::MsgNapDeviceDnaReq(msg) => msg.message_type(), + Sbp::MsgFlashDone(msg) => msg.message_type(), + Sbp::MsgFlashReadResp(msg) => msg.message_type(), + Sbp::MsgFlashErase(msg) => msg.message_type(), + Sbp::MsgStmFlashLockSector(msg) => msg.message_type(), + Sbp::MsgStmFlashUnlockSector(msg) => msg.message_type(), + Sbp::MsgStmUniqueIdResp(msg) => msg.message_type(), + Sbp::MsgFlashProgram(msg) => msg.message_type(), + Sbp::MsgFlashReadReq(msg) => msg.message_type(), + Sbp::MsgStmUniqueIdReq(msg) => msg.message_type(), + Sbp::MsgM25FlashWriteStatus(msg) => msg.message_type(), + Sbp::MsgGpsTimeDepA(msg) => msg.message_type(), + Sbp::MsgExtEvent(msg) => msg.message_type(), + Sbp::MsgGpsTime(msg) => msg.message_type(), + Sbp::MsgUtcTime(msg) => msg.message_type(), + Sbp::MsgGpsTimeGnss(msg) => msg.message_type(), + Sbp::MsgUtcTimeGnss(msg) => msg.message_type(), + Sbp::MsgSettingsRegisterResp(msg) => msg.message_type(), + Sbp::MsgPosEcefDepA(msg) => msg.message_type(), + Sbp::MsgPosLlhDepA(msg) => msg.message_type(), + Sbp::MsgBaselineEcefDepA(msg) => msg.message_type(), + Sbp::MsgBaselineNedDepA(msg) => msg.message_type(), + Sbp::MsgVelEcefDepA(msg) => msg.message_type(), + Sbp::MsgVelNedDepA(msg) => msg.message_type(), + Sbp::MsgDopsDepA(msg) => msg.message_type(), + Sbp::MsgBaselineHeadingDepA(msg) => msg.message_type(), + Sbp::MsgDops(msg) => msg.message_type(), + Sbp::MsgPosEcef(msg) => msg.message_type(), + Sbp::MsgPosLlh(msg) => msg.message_type(), + Sbp::MsgBaselineEcef(msg) => msg.message_type(), + Sbp::MsgBaselineNed(msg) => msg.message_type(), + Sbp::MsgVelEcef(msg) => msg.message_type(), + Sbp::MsgVelNed(msg) => msg.message_type(), + Sbp::MsgBaselineHeading(msg) => msg.message_type(), + Sbp::MsgAgeCorrections(msg) => msg.message_type(), + Sbp::MsgPosLlhCov(msg) => msg.message_type(), + Sbp::MsgVelNedCov(msg) => msg.message_type(), + Sbp::MsgVelBody(msg) => msg.message_type(), + Sbp::MsgPosEcefCov(msg) => msg.message_type(), + Sbp::MsgVelEcefCov(msg) => msg.message_type(), + Sbp::MsgProtectionLevelDepA(msg) => msg.message_type(), + Sbp::MsgProtectionLevel(msg) => msg.message_type(), + Sbp::MsgPosLlhAcc(msg) => msg.message_type(), + Sbp::MsgOrientQuat(msg) => msg.message_type(), + Sbp::MsgOrientEuler(msg) => msg.message_type(), + Sbp::MsgAngularRate(msg) => msg.message_type(), + Sbp::MsgPosEcefGnss(msg) => msg.message_type(), + Sbp::MsgPosLlhGnss(msg) => msg.message_type(), + Sbp::MsgVelEcefGnss(msg) => msg.message_type(), + Sbp::MsgVelNedGnss(msg) => msg.message_type(), + Sbp::MsgPosLlhCovGnss(msg) => msg.message_type(), + Sbp::MsgVelNedCovGnss(msg) => msg.message_type(), + Sbp::MsgPosEcefCovGnss(msg) => msg.message_type(), + Sbp::MsgVelEcefCovGnss(msg) => msg.message_type(), + Sbp::MsgNdbEvent(msg) => msg.message_type(), + Sbp::MsgLog(msg) => msg.message_type(), + Sbp::MsgFwd(msg) => msg.message_type(), + Sbp::MsgSsrOrbitClockDepA(msg) => msg.message_type(), + Sbp::MsgSsrOrbitClock(msg) => msg.message_type(), + Sbp::MsgSsrCodeBiases(msg) => msg.message_type(), + Sbp::MsgSsrPhaseBiases(msg) => msg.message_type(), + Sbp::MsgSsrStecCorrectionDepA(msg) => msg.message_type(), + Sbp::MsgSsrGriddedCorrectionNoStdDepA(msg) => msg.message_type(), + Sbp::MsgSsrGridDefinitionDepA(msg) => msg.message_type(), + Sbp::MsgSsrTileDefinition(msg) => msg.message_type(), + Sbp::MsgSsrGriddedCorrectionDepA(msg) => msg.message_type(), + Sbp::MsgSsrStecCorrection(msg) => msg.message_type(), + Sbp::MsgSsrGriddedCorrection(msg) => msg.message_type(), + Sbp::MsgSsrSatelliteApc(msg) => msg.message_type(), + Sbp::MsgOsr(msg) => msg.message_type(), + Sbp::MsgUserData(msg) => msg.message_type(), + Sbp::MsgImuRaw(msg) => msg.message_type(), + Sbp::MsgImuAux(msg) => msg.message_type(), + Sbp::MsgMagRaw(msg) => msg.message_type(), + Sbp::MsgOdometry(msg) => msg.message_type(), + Sbp::MsgWheeltick(msg) => msg.message_type(), + Sbp::MsgFileioConfigReq(msg) => msg.message_type(), + Sbp::MsgFileioConfigResp(msg) => msg.message_type(), + Sbp::MsgSbasRaw(msg) => msg.message_type(), + Sbp::MsgLinuxCpuStateDepA(msg) => msg.message_type(), + Sbp::MsgLinuxMemStateDepA(msg) => msg.message_type(), + Sbp::MsgLinuxSysStateDepA(msg) => msg.message_type(), + Sbp::MsgLinuxProcessSocketCounts(msg) => msg.message_type(), + Sbp::MsgLinuxProcessSocketQueues(msg) => msg.message_type(), + Sbp::MsgLinuxSocketUsage(msg) => msg.message_type(), + Sbp::MsgLinuxProcessFdCount(msg) => msg.message_type(), + Sbp::MsgLinuxProcessFdSummary(msg) => msg.message_type(), + Sbp::MsgLinuxCpuState(msg) => msg.message_type(), + Sbp::MsgLinuxMemState(msg) => msg.message_type(), + Sbp::MsgLinuxSysState(msg) => msg.message_type(), + Sbp::MsgStartup(msg) => msg.message_type(), + Sbp::MsgDgnssStatus(msg) => msg.message_type(), + Sbp::MsgInsStatus(msg) => msg.message_type(), + Sbp::MsgCsacTelemetry(msg) => msg.message_type(), + Sbp::MsgCsacTelemetryLabels(msg) => msg.message_type(), + Sbp::MsgInsUpdates(msg) => msg.message_type(), + Sbp::MsgGnssTimeOffset(msg) => msg.message_type(), + Sbp::MsgPpsTime(msg) => msg.message_type(), + Sbp::MsgGroupMeta(msg) => msg.message_type(), + Sbp::MsgSolnMeta(msg) => msg.message_type(), + Sbp::MsgSolnMetaDepA(msg) => msg.message_type(), + Sbp::MsgStatusReport(msg) => msg.message_type(), + Sbp::MsgHeartbeat(msg) => msg.message_type(), + Sbp::Unknown(msg) => msg.message_type(), } } - fn get_sender_id(&self) -> Option { + fn sender_id(&self) -> Option { match self { - SBP::MsgPrintDep(msg) => msg.get_sender_id(), - SBP::MsgTrackingStateDetailedDep(msg) => msg.get_sender_id(), - SBP::MsgTrackingStateDepB(msg) => msg.get_sender_id(), - SBP::MsgAcqResultDepB(msg) => msg.get_sender_id(), - SBP::MsgAcqResultDepA(msg) => msg.get_sender_id(), - SBP::MsgTrackingStateDepA(msg) => msg.get_sender_id(), - SBP::MsgThreadState(msg) => msg.get_sender_id(), - SBP::MsgUartStateDepa(msg) => msg.get_sender_id(), - SBP::MsgIarState(msg) => msg.get_sender_id(), - SBP::MsgEphemerisDepA(msg) => msg.get_sender_id(), - SBP::MsgMaskSatelliteDep(msg) => msg.get_sender_id(), - SBP::MsgTrackingIqDepA(msg) => msg.get_sender_id(), - SBP::MsgUartState(msg) => msg.get_sender_id(), - SBP::MsgAcqSvProfileDep(msg) => msg.get_sender_id(), - SBP::MsgAcqResultDepC(msg) => msg.get_sender_id(), - SBP::MsgTrackingStateDetailedDepA(msg) => msg.get_sender_id(), - SBP::MsgResetFilters(msg) => msg.get_sender_id(), - SBP::MsgInitBaseDep(msg) => msg.get_sender_id(), - SBP::MsgMaskSatellite(msg) => msg.get_sender_id(), - SBP::MsgTrackingIqDepB(msg) => msg.get_sender_id(), - SBP::MsgTrackingIq(msg) => msg.get_sender_id(), - SBP::MsgAcqSvProfile(msg) => msg.get_sender_id(), - SBP::MsgAcqResult(msg) => msg.get_sender_id(), - SBP::MsgTrackingState(msg) => msg.get_sender_id(), - SBP::MsgObsDepB(msg) => msg.get_sender_id(), - SBP::MsgBasePosLLH(msg) => msg.get_sender_id(), - SBP::MsgObsDepA(msg) => msg.get_sender_id(), - SBP::MsgEphemerisDepB(msg) => msg.get_sender_id(), - SBP::MsgEphemerisDepC(msg) => msg.get_sender_id(), - SBP::MsgBasePosECEF(msg) => msg.get_sender_id(), - SBP::MsgObsDepC(msg) => msg.get_sender_id(), - SBP::MsgObs(msg) => msg.get_sender_id(), - SBP::MsgSpecanDep(msg) => msg.get_sender_id(), - SBP::MsgSpecan(msg) => msg.get_sender_id(), - SBP::MsgMeasurementState(msg) => msg.get_sender_id(), - SBP::MsgSetTime(msg) => msg.get_sender_id(), - SBP::MsgAlmanac(msg) => msg.get_sender_id(), - SBP::MsgAlmanacGPSDep(msg) => msg.get_sender_id(), - SBP::MsgAlmanacGloDep(msg) => msg.get_sender_id(), - SBP::MsgAlmanacGPS(msg) => msg.get_sender_id(), - SBP::MsgAlmanacGlo(msg) => msg.get_sender_id(), - SBP::MsgGloBiases(msg) => msg.get_sender_id(), - SBP::MsgEphemerisDepD(msg) => msg.get_sender_id(), - SBP::MsgEphemerisGPSDepE(msg) => msg.get_sender_id(), - SBP::MsgEphemerisSbasDepA(msg) => msg.get_sender_id(), - SBP::MsgEphemerisGloDepA(msg) => msg.get_sender_id(), - SBP::MsgEphemerisSbasDepB(msg) => msg.get_sender_id(), - SBP::MsgEphemerisGloDepB(msg) => msg.get_sender_id(), - SBP::MsgEphemerisGPSDepF(msg) => msg.get_sender_id(), - SBP::MsgEphemerisGloDepC(msg) => msg.get_sender_id(), - SBP::MsgEphemerisGloDepD(msg) => msg.get_sender_id(), - SBP::MsgEphemerisBds(msg) => msg.get_sender_id(), - SBP::MsgEphemerisGPS(msg) => msg.get_sender_id(), - SBP::MsgEphemerisGlo(msg) => msg.get_sender_id(), - SBP::MsgEphemerisSbas(msg) => msg.get_sender_id(), - SBP::MsgEphemerisGal(msg) => msg.get_sender_id(), - SBP::MsgEphemerisQzss(msg) => msg.get_sender_id(), - SBP::MsgIono(msg) => msg.get_sender_id(), - SBP::MsgSvConfigurationGPSDep(msg) => msg.get_sender_id(), - SBP::MsgGroupDelayDepA(msg) => msg.get_sender_id(), - SBP::MsgGroupDelayDepB(msg) => msg.get_sender_id(), - SBP::MsgGroupDelay(msg) => msg.get_sender_id(), - SBP::MsgEphemerisGalDepA(msg) => msg.get_sender_id(), - SBP::MsgGnssCapb(msg) => msg.get_sender_id(), - SBP::MsgSvAzEl(msg) => msg.get_sender_id(), - SBP::MsgSettingsWrite(msg) => msg.get_sender_id(), - SBP::MsgSettingsSave(msg) => msg.get_sender_id(), - SBP::MsgSettingsReadByIndexReq(msg) => msg.get_sender_id(), - SBP::MsgFileioReadResp(msg) => msg.get_sender_id(), - SBP::MsgSettingsReadReq(msg) => msg.get_sender_id(), - SBP::MsgSettingsReadResp(msg) => msg.get_sender_id(), - SBP::MsgSettingsReadByIndexDone(msg) => msg.get_sender_id(), - SBP::MsgSettingsReadByIndexResp(msg) => msg.get_sender_id(), - SBP::MsgFileioReadReq(msg) => msg.get_sender_id(), - SBP::MsgFileioReadDirReq(msg) => msg.get_sender_id(), - SBP::MsgFileioReadDirResp(msg) => msg.get_sender_id(), - SBP::MsgFileioWriteResp(msg) => msg.get_sender_id(), - SBP::MsgFileioRemove(msg) => msg.get_sender_id(), - SBP::MsgFileioWriteReq(msg) => msg.get_sender_id(), - SBP::MsgSettingsRegister(msg) => msg.get_sender_id(), - SBP::MsgSettingsWriteResp(msg) => msg.get_sender_id(), - SBP::MsgBootloaderHandshakeDepA(msg) => msg.get_sender_id(), - SBP::MsgBootloaderJumpToApp(msg) => msg.get_sender_id(), - SBP::MsgResetDep(msg) => msg.get_sender_id(), - SBP::MsgBootloaderHandshakeReq(msg) => msg.get_sender_id(), - SBP::MsgBootloaderHandshakeResp(msg) => msg.get_sender_id(), - SBP::MsgDeviceMonitor(msg) => msg.get_sender_id(), - SBP::MsgReset(msg) => msg.get_sender_id(), - SBP::MsgCommandReq(msg) => msg.get_sender_id(), - SBP::MsgCommandResp(msg) => msg.get_sender_id(), - SBP::MsgNetworkStateReq(msg) => msg.get_sender_id(), - SBP::MsgNetworkStateResp(msg) => msg.get_sender_id(), - SBP::MsgCommandOutput(msg) => msg.get_sender_id(), - SBP::MsgNetworkBandwidthUsage(msg) => msg.get_sender_id(), - SBP::MsgCellModemStatus(msg) => msg.get_sender_id(), - SBP::MsgFrontEndGain(msg) => msg.get_sender_id(), - SBP::MsgCwResults(msg) => msg.get_sender_id(), - SBP::MsgCwStart(msg) => msg.get_sender_id(), - SBP::MsgNapDeviceDnaResp(msg) => msg.get_sender_id(), - SBP::MsgNapDeviceDnaReq(msg) => msg.get_sender_id(), - SBP::MsgFlashDone(msg) => msg.get_sender_id(), - SBP::MsgFlashReadResp(msg) => msg.get_sender_id(), - SBP::MsgFlashErase(msg) => msg.get_sender_id(), - SBP::MsgStmFlashLockSector(msg) => msg.get_sender_id(), - SBP::MsgStmFlashUnlockSector(msg) => msg.get_sender_id(), - SBP::MsgStmUniqueIdResp(msg) => msg.get_sender_id(), - SBP::MsgFlashProgram(msg) => msg.get_sender_id(), - SBP::MsgFlashReadReq(msg) => msg.get_sender_id(), - SBP::MsgStmUniqueIdReq(msg) => msg.get_sender_id(), - SBP::MsgM25FlashWriteStatus(msg) => msg.get_sender_id(), - SBP::MsgGPSTimeDepA(msg) => msg.get_sender_id(), - SBP::MsgExtEvent(msg) => msg.get_sender_id(), - SBP::MsgGPSTime(msg) => msg.get_sender_id(), - SBP::MsgUtcTime(msg) => msg.get_sender_id(), - SBP::MsgGPSTimeGnss(msg) => msg.get_sender_id(), - SBP::MsgUtcTimeGnss(msg) => msg.get_sender_id(), - SBP::MsgSettingsRegisterResp(msg) => msg.get_sender_id(), - SBP::MsgPosECEFDepA(msg) => msg.get_sender_id(), - SBP::MsgPosLLHDepA(msg) => msg.get_sender_id(), - SBP::MsgBaselineECEFDepA(msg) => msg.get_sender_id(), - SBP::MsgBaselineNEDDepA(msg) => msg.get_sender_id(), - SBP::MsgVelECEFDepA(msg) => msg.get_sender_id(), - SBP::MsgVelNEDDepA(msg) => msg.get_sender_id(), - SBP::MsgDopsDepA(msg) => msg.get_sender_id(), - SBP::MsgBaselineHeadingDepA(msg) => msg.get_sender_id(), - SBP::MsgDops(msg) => msg.get_sender_id(), - SBP::MsgPosECEF(msg) => msg.get_sender_id(), - SBP::MsgPosLLH(msg) => msg.get_sender_id(), - SBP::MsgBaselineECEF(msg) => msg.get_sender_id(), - SBP::MsgBaselineNED(msg) => msg.get_sender_id(), - SBP::MsgVelECEF(msg) => msg.get_sender_id(), - SBP::MsgVelNED(msg) => msg.get_sender_id(), - SBP::MsgBaselineHeading(msg) => msg.get_sender_id(), - SBP::MsgAgeCorrections(msg) => msg.get_sender_id(), - SBP::MsgPosLLHCov(msg) => msg.get_sender_id(), - SBP::MsgVelNEDCov(msg) => msg.get_sender_id(), - SBP::MsgVelBody(msg) => msg.get_sender_id(), - SBP::MsgPosECEFCov(msg) => msg.get_sender_id(), - SBP::MsgVelECEFCov(msg) => msg.get_sender_id(), - SBP::MsgProtectionLevelDepA(msg) => msg.get_sender_id(), - SBP::MsgProtectionLevel(msg) => msg.get_sender_id(), - SBP::MsgPosLLHAcc(msg) => msg.get_sender_id(), - SBP::MsgOrientQuat(msg) => msg.get_sender_id(), - SBP::MsgOrientEuler(msg) => msg.get_sender_id(), - SBP::MsgAngularRate(msg) => msg.get_sender_id(), - SBP::MsgPosECEFGnss(msg) => msg.get_sender_id(), - SBP::MsgPosLLHGnss(msg) => msg.get_sender_id(), - SBP::MsgVelECEFGnss(msg) => msg.get_sender_id(), - SBP::MsgVelNEDGnss(msg) => msg.get_sender_id(), - SBP::MsgPosLLHCovGnss(msg) => msg.get_sender_id(), - SBP::MsgVelNEDCovGnss(msg) => msg.get_sender_id(), - SBP::MsgPosECEFCovGnss(msg) => msg.get_sender_id(), - SBP::MsgVelECEFCovGnss(msg) => msg.get_sender_id(), - SBP::MsgNdbEvent(msg) => msg.get_sender_id(), - SBP::MsgLog(msg) => msg.get_sender_id(), - SBP::MsgFwd(msg) => msg.get_sender_id(), - SBP::MsgSsrOrbitClockDepA(msg) => msg.get_sender_id(), - SBP::MsgSsrOrbitClock(msg) => msg.get_sender_id(), - SBP::MsgSsrCodeBiases(msg) => msg.get_sender_id(), - SBP::MsgSsrPhaseBiases(msg) => msg.get_sender_id(), - SBP::MsgSsrStecCorrectionDepA(msg) => msg.get_sender_id(), - SBP::MsgSsrGriddedCorrectionNoStdDepA(msg) => msg.get_sender_id(), - SBP::MsgSsrGridDefinitionDepA(msg) => msg.get_sender_id(), - SBP::MsgSsrTileDefinition(msg) => msg.get_sender_id(), - SBP::MsgSsrGriddedCorrectionDepA(msg) => msg.get_sender_id(), - SBP::MsgSsrStecCorrection(msg) => msg.get_sender_id(), - SBP::MsgSsrGriddedCorrection(msg) => msg.get_sender_id(), - SBP::MsgSsrSatelliteApc(msg) => msg.get_sender_id(), - SBP::MsgOsr(msg) => msg.get_sender_id(), - SBP::MsgUserData(msg) => msg.get_sender_id(), - SBP::MsgImuRaw(msg) => msg.get_sender_id(), - SBP::MsgImuAux(msg) => msg.get_sender_id(), - SBP::MsgMagRaw(msg) => msg.get_sender_id(), - SBP::MsgOdometry(msg) => msg.get_sender_id(), - SBP::MsgWheeltick(msg) => msg.get_sender_id(), - SBP::MsgFileioConfigReq(msg) => msg.get_sender_id(), - SBP::MsgFileioConfigResp(msg) => msg.get_sender_id(), - SBP::MsgSbasRaw(msg) => msg.get_sender_id(), - SBP::MsgLinuxCpuStateDepA(msg) => msg.get_sender_id(), - SBP::MsgLinuxMemStateDepA(msg) => msg.get_sender_id(), - SBP::MsgLinuxSysStateDepA(msg) => msg.get_sender_id(), - SBP::MsgLinuxProcessSocketCounts(msg) => msg.get_sender_id(), - SBP::MsgLinuxProcessSocketQueues(msg) => msg.get_sender_id(), - SBP::MsgLinuxSocketUsage(msg) => msg.get_sender_id(), - SBP::MsgLinuxProcessFdCount(msg) => msg.get_sender_id(), - SBP::MsgLinuxProcessFdSummary(msg) => msg.get_sender_id(), - SBP::MsgLinuxCpuState(msg) => msg.get_sender_id(), - SBP::MsgLinuxMemState(msg) => msg.get_sender_id(), - SBP::MsgLinuxSysState(msg) => msg.get_sender_id(), - SBP::MsgStartup(msg) => msg.get_sender_id(), - SBP::MsgDgnssStatus(msg) => msg.get_sender_id(), - SBP::MsgInsStatus(msg) => msg.get_sender_id(), - SBP::MsgCsacTelemetry(msg) => msg.get_sender_id(), - SBP::MsgCsacTelemetryLabels(msg) => msg.get_sender_id(), - SBP::MsgInsUpdates(msg) => msg.get_sender_id(), - SBP::MsgGnssTimeOffset(msg) => msg.get_sender_id(), - SBP::MsgPpsTime(msg) => msg.get_sender_id(), - SBP::MsgGroupMeta(msg) => msg.get_sender_id(), - SBP::MsgSolnMeta(msg) => msg.get_sender_id(), - SBP::MsgSolnMetaDepA(msg) => msg.get_sender_id(), - SBP::MsgStatusReport(msg) => msg.get_sender_id(), - SBP::MsgHeartbeat(msg) => msg.get_sender_id(), - SBP::Unknown(msg) => msg.get_sender_id(), + Sbp::MsgPrintDep(msg) => msg.sender_id(), + Sbp::MsgTrackingStateDetailedDep(msg) => msg.sender_id(), + Sbp::MsgTrackingStateDepB(msg) => msg.sender_id(), + Sbp::MsgAcqResultDepB(msg) => msg.sender_id(), + Sbp::MsgAcqResultDepA(msg) => msg.sender_id(), + Sbp::MsgTrackingStateDepA(msg) => msg.sender_id(), + Sbp::MsgThreadState(msg) => msg.sender_id(), + Sbp::MsgUartStateDepa(msg) => msg.sender_id(), + Sbp::MsgIarState(msg) => msg.sender_id(), + Sbp::MsgEphemerisDepA(msg) => msg.sender_id(), + Sbp::MsgMaskSatelliteDep(msg) => msg.sender_id(), + Sbp::MsgTrackingIqDepA(msg) => msg.sender_id(), + Sbp::MsgUartState(msg) => msg.sender_id(), + Sbp::MsgAcqSvProfileDep(msg) => msg.sender_id(), + Sbp::MsgAcqResultDepC(msg) => msg.sender_id(), + Sbp::MsgTrackingStateDetailedDepA(msg) => msg.sender_id(), + Sbp::MsgResetFilters(msg) => msg.sender_id(), + Sbp::MsgInitBaseDep(msg) => msg.sender_id(), + Sbp::MsgMaskSatellite(msg) => msg.sender_id(), + Sbp::MsgTrackingIqDepB(msg) => msg.sender_id(), + Sbp::MsgTrackingIq(msg) => msg.sender_id(), + Sbp::MsgAcqSvProfile(msg) => msg.sender_id(), + Sbp::MsgAcqResult(msg) => msg.sender_id(), + Sbp::MsgTrackingState(msg) => msg.sender_id(), + Sbp::MsgObsDepB(msg) => msg.sender_id(), + Sbp::MsgBasePosLlh(msg) => msg.sender_id(), + Sbp::MsgObsDepA(msg) => msg.sender_id(), + Sbp::MsgEphemerisDepB(msg) => msg.sender_id(), + Sbp::MsgEphemerisDepC(msg) => msg.sender_id(), + Sbp::MsgBasePosEcef(msg) => msg.sender_id(), + Sbp::MsgObsDepC(msg) => msg.sender_id(), + Sbp::MsgObs(msg) => msg.sender_id(), + Sbp::MsgSpecanDep(msg) => msg.sender_id(), + Sbp::MsgSpecan(msg) => msg.sender_id(), + Sbp::MsgMeasurementState(msg) => msg.sender_id(), + Sbp::MsgSetTime(msg) => msg.sender_id(), + Sbp::MsgAlmanac(msg) => msg.sender_id(), + Sbp::MsgAlmanacGpsDep(msg) => msg.sender_id(), + Sbp::MsgAlmanacGloDep(msg) => msg.sender_id(), + Sbp::MsgAlmanacGps(msg) => msg.sender_id(), + Sbp::MsgAlmanacGlo(msg) => msg.sender_id(), + Sbp::MsgGloBiases(msg) => msg.sender_id(), + Sbp::MsgEphemerisDepD(msg) => msg.sender_id(), + Sbp::MsgEphemerisGpsDepE(msg) => msg.sender_id(), + Sbp::MsgEphemerisSbasDepA(msg) => msg.sender_id(), + Sbp::MsgEphemerisGloDepA(msg) => msg.sender_id(), + Sbp::MsgEphemerisSbasDepB(msg) => msg.sender_id(), + Sbp::MsgEphemerisGloDepB(msg) => msg.sender_id(), + Sbp::MsgEphemerisGpsDepF(msg) => msg.sender_id(), + Sbp::MsgEphemerisGloDepC(msg) => msg.sender_id(), + Sbp::MsgEphemerisGloDepD(msg) => msg.sender_id(), + Sbp::MsgEphemerisBds(msg) => msg.sender_id(), + Sbp::MsgEphemerisGps(msg) => msg.sender_id(), + Sbp::MsgEphemerisGlo(msg) => msg.sender_id(), + Sbp::MsgEphemerisSbas(msg) => msg.sender_id(), + Sbp::MsgEphemerisGal(msg) => msg.sender_id(), + Sbp::MsgEphemerisQzss(msg) => msg.sender_id(), + Sbp::MsgIono(msg) => msg.sender_id(), + Sbp::MsgSvConfigurationGpsDep(msg) => msg.sender_id(), + Sbp::MsgGroupDelayDepA(msg) => msg.sender_id(), + Sbp::MsgGroupDelayDepB(msg) => msg.sender_id(), + Sbp::MsgGroupDelay(msg) => msg.sender_id(), + Sbp::MsgEphemerisGalDepA(msg) => msg.sender_id(), + Sbp::MsgGnssCapb(msg) => msg.sender_id(), + Sbp::MsgSvAzEl(msg) => msg.sender_id(), + Sbp::MsgSettingsWrite(msg) => msg.sender_id(), + Sbp::MsgSettingsSave(msg) => msg.sender_id(), + Sbp::MsgSettingsReadByIndexReq(msg) => msg.sender_id(), + Sbp::MsgFileioReadResp(msg) => msg.sender_id(), + Sbp::MsgSettingsReadReq(msg) => msg.sender_id(), + Sbp::MsgSettingsReadResp(msg) => msg.sender_id(), + Sbp::MsgSettingsReadByIndexDone(msg) => msg.sender_id(), + Sbp::MsgSettingsReadByIndexResp(msg) => msg.sender_id(), + Sbp::MsgFileioReadReq(msg) => msg.sender_id(), + Sbp::MsgFileioReadDirReq(msg) => msg.sender_id(), + Sbp::MsgFileioReadDirResp(msg) => msg.sender_id(), + Sbp::MsgFileioWriteResp(msg) => msg.sender_id(), + Sbp::MsgFileioRemove(msg) => msg.sender_id(), + Sbp::MsgFileioWriteReq(msg) => msg.sender_id(), + Sbp::MsgSettingsRegister(msg) => msg.sender_id(), + Sbp::MsgSettingsWriteResp(msg) => msg.sender_id(), + Sbp::MsgBootloaderHandshakeDepA(msg) => msg.sender_id(), + Sbp::MsgBootloaderJumpToApp(msg) => msg.sender_id(), + Sbp::MsgResetDep(msg) => msg.sender_id(), + Sbp::MsgBootloaderHandshakeReq(msg) => msg.sender_id(), + Sbp::MsgBootloaderHandshakeResp(msg) => msg.sender_id(), + Sbp::MsgDeviceMonitor(msg) => msg.sender_id(), + Sbp::MsgReset(msg) => msg.sender_id(), + Sbp::MsgCommandReq(msg) => msg.sender_id(), + Sbp::MsgCommandResp(msg) => msg.sender_id(), + Sbp::MsgNetworkStateReq(msg) => msg.sender_id(), + Sbp::MsgNetworkStateResp(msg) => msg.sender_id(), + Sbp::MsgCommandOutput(msg) => msg.sender_id(), + Sbp::MsgNetworkBandwidthUsage(msg) => msg.sender_id(), + Sbp::MsgCellModemStatus(msg) => msg.sender_id(), + Sbp::MsgFrontEndGain(msg) => msg.sender_id(), + Sbp::MsgCwResults(msg) => msg.sender_id(), + Sbp::MsgCwStart(msg) => msg.sender_id(), + Sbp::MsgNapDeviceDnaResp(msg) => msg.sender_id(), + Sbp::MsgNapDeviceDnaReq(msg) => msg.sender_id(), + Sbp::MsgFlashDone(msg) => msg.sender_id(), + Sbp::MsgFlashReadResp(msg) => msg.sender_id(), + Sbp::MsgFlashErase(msg) => msg.sender_id(), + Sbp::MsgStmFlashLockSector(msg) => msg.sender_id(), + Sbp::MsgStmFlashUnlockSector(msg) => msg.sender_id(), + Sbp::MsgStmUniqueIdResp(msg) => msg.sender_id(), + Sbp::MsgFlashProgram(msg) => msg.sender_id(), + Sbp::MsgFlashReadReq(msg) => msg.sender_id(), + Sbp::MsgStmUniqueIdReq(msg) => msg.sender_id(), + Sbp::MsgM25FlashWriteStatus(msg) => msg.sender_id(), + Sbp::MsgGpsTimeDepA(msg) => msg.sender_id(), + Sbp::MsgExtEvent(msg) => msg.sender_id(), + Sbp::MsgGpsTime(msg) => msg.sender_id(), + Sbp::MsgUtcTime(msg) => msg.sender_id(), + Sbp::MsgGpsTimeGnss(msg) => msg.sender_id(), + Sbp::MsgUtcTimeGnss(msg) => msg.sender_id(), + Sbp::MsgSettingsRegisterResp(msg) => msg.sender_id(), + Sbp::MsgPosEcefDepA(msg) => msg.sender_id(), + Sbp::MsgPosLlhDepA(msg) => msg.sender_id(), + Sbp::MsgBaselineEcefDepA(msg) => msg.sender_id(), + Sbp::MsgBaselineNedDepA(msg) => msg.sender_id(), + Sbp::MsgVelEcefDepA(msg) => msg.sender_id(), + Sbp::MsgVelNedDepA(msg) => msg.sender_id(), + Sbp::MsgDopsDepA(msg) => msg.sender_id(), + Sbp::MsgBaselineHeadingDepA(msg) => msg.sender_id(), + Sbp::MsgDops(msg) => msg.sender_id(), + Sbp::MsgPosEcef(msg) => msg.sender_id(), + Sbp::MsgPosLlh(msg) => msg.sender_id(), + Sbp::MsgBaselineEcef(msg) => msg.sender_id(), + Sbp::MsgBaselineNed(msg) => msg.sender_id(), + Sbp::MsgVelEcef(msg) => msg.sender_id(), + Sbp::MsgVelNed(msg) => msg.sender_id(), + Sbp::MsgBaselineHeading(msg) => msg.sender_id(), + Sbp::MsgAgeCorrections(msg) => msg.sender_id(), + Sbp::MsgPosLlhCov(msg) => msg.sender_id(), + Sbp::MsgVelNedCov(msg) => msg.sender_id(), + Sbp::MsgVelBody(msg) => msg.sender_id(), + Sbp::MsgPosEcefCov(msg) => msg.sender_id(), + Sbp::MsgVelEcefCov(msg) => msg.sender_id(), + Sbp::MsgProtectionLevelDepA(msg) => msg.sender_id(), + Sbp::MsgProtectionLevel(msg) => msg.sender_id(), + Sbp::MsgPosLlhAcc(msg) => msg.sender_id(), + Sbp::MsgOrientQuat(msg) => msg.sender_id(), + Sbp::MsgOrientEuler(msg) => msg.sender_id(), + Sbp::MsgAngularRate(msg) => msg.sender_id(), + Sbp::MsgPosEcefGnss(msg) => msg.sender_id(), + Sbp::MsgPosLlhGnss(msg) => msg.sender_id(), + Sbp::MsgVelEcefGnss(msg) => msg.sender_id(), + Sbp::MsgVelNedGnss(msg) => msg.sender_id(), + Sbp::MsgPosLlhCovGnss(msg) => msg.sender_id(), + Sbp::MsgVelNedCovGnss(msg) => msg.sender_id(), + Sbp::MsgPosEcefCovGnss(msg) => msg.sender_id(), + Sbp::MsgVelEcefCovGnss(msg) => msg.sender_id(), + Sbp::MsgNdbEvent(msg) => msg.sender_id(), + Sbp::MsgLog(msg) => msg.sender_id(), + Sbp::MsgFwd(msg) => msg.sender_id(), + Sbp::MsgSsrOrbitClockDepA(msg) => msg.sender_id(), + Sbp::MsgSsrOrbitClock(msg) => msg.sender_id(), + Sbp::MsgSsrCodeBiases(msg) => msg.sender_id(), + Sbp::MsgSsrPhaseBiases(msg) => msg.sender_id(), + Sbp::MsgSsrStecCorrectionDepA(msg) => msg.sender_id(), + Sbp::MsgSsrGriddedCorrectionNoStdDepA(msg) => msg.sender_id(), + Sbp::MsgSsrGridDefinitionDepA(msg) => msg.sender_id(), + Sbp::MsgSsrTileDefinition(msg) => msg.sender_id(), + Sbp::MsgSsrGriddedCorrectionDepA(msg) => msg.sender_id(), + Sbp::MsgSsrStecCorrection(msg) => msg.sender_id(), + Sbp::MsgSsrGriddedCorrection(msg) => msg.sender_id(), + Sbp::MsgSsrSatelliteApc(msg) => msg.sender_id(), + Sbp::MsgOsr(msg) => msg.sender_id(), + Sbp::MsgUserData(msg) => msg.sender_id(), + Sbp::MsgImuRaw(msg) => msg.sender_id(), + Sbp::MsgImuAux(msg) => msg.sender_id(), + Sbp::MsgMagRaw(msg) => msg.sender_id(), + Sbp::MsgOdometry(msg) => msg.sender_id(), + Sbp::MsgWheeltick(msg) => msg.sender_id(), + Sbp::MsgFileioConfigReq(msg) => msg.sender_id(), + Sbp::MsgFileioConfigResp(msg) => msg.sender_id(), + Sbp::MsgSbasRaw(msg) => msg.sender_id(), + Sbp::MsgLinuxCpuStateDepA(msg) => msg.sender_id(), + Sbp::MsgLinuxMemStateDepA(msg) => msg.sender_id(), + Sbp::MsgLinuxSysStateDepA(msg) => msg.sender_id(), + Sbp::MsgLinuxProcessSocketCounts(msg) => msg.sender_id(), + Sbp::MsgLinuxProcessSocketQueues(msg) => msg.sender_id(), + Sbp::MsgLinuxSocketUsage(msg) => msg.sender_id(), + Sbp::MsgLinuxProcessFdCount(msg) => msg.sender_id(), + Sbp::MsgLinuxProcessFdSummary(msg) => msg.sender_id(), + Sbp::MsgLinuxCpuState(msg) => msg.sender_id(), + Sbp::MsgLinuxMemState(msg) => msg.sender_id(), + Sbp::MsgLinuxSysState(msg) => msg.sender_id(), + Sbp::MsgStartup(msg) => msg.sender_id(), + Sbp::MsgDgnssStatus(msg) => msg.sender_id(), + Sbp::MsgInsStatus(msg) => msg.sender_id(), + Sbp::MsgCsacTelemetry(msg) => msg.sender_id(), + Sbp::MsgCsacTelemetryLabels(msg) => msg.sender_id(), + Sbp::MsgInsUpdates(msg) => msg.sender_id(), + Sbp::MsgGnssTimeOffset(msg) => msg.sender_id(), + Sbp::MsgPpsTime(msg) => msg.sender_id(), + Sbp::MsgGroupMeta(msg) => msg.sender_id(), + Sbp::MsgSolnMeta(msg) => msg.sender_id(), + Sbp::MsgSolnMetaDepA(msg) => msg.sender_id(), + Sbp::MsgStatusReport(msg) => msg.sender_id(), + Sbp::MsgHeartbeat(msg) => msg.sender_id(), + Sbp::Unknown(msg) => msg.sender_id(), } } fn set_sender_id(&mut self, new_id: u16) { match self { - SBP::MsgPrintDep(msg) => msg.set_sender_id(new_id), - SBP::MsgTrackingStateDetailedDep(msg) => msg.set_sender_id(new_id), - SBP::MsgTrackingStateDepB(msg) => msg.set_sender_id(new_id), - SBP::MsgAcqResultDepB(msg) => msg.set_sender_id(new_id), - SBP::MsgAcqResultDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgTrackingStateDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgThreadState(msg) => msg.set_sender_id(new_id), - SBP::MsgUartStateDepa(msg) => msg.set_sender_id(new_id), - SBP::MsgIarState(msg) => msg.set_sender_id(new_id), - SBP::MsgEphemerisDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgMaskSatelliteDep(msg) => msg.set_sender_id(new_id), - SBP::MsgTrackingIqDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgUartState(msg) => msg.set_sender_id(new_id), - SBP::MsgAcqSvProfileDep(msg) => msg.set_sender_id(new_id), - SBP::MsgAcqResultDepC(msg) => msg.set_sender_id(new_id), - SBP::MsgTrackingStateDetailedDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgResetFilters(msg) => msg.set_sender_id(new_id), - SBP::MsgInitBaseDep(msg) => msg.set_sender_id(new_id), - SBP::MsgMaskSatellite(msg) => msg.set_sender_id(new_id), - SBP::MsgTrackingIqDepB(msg) => msg.set_sender_id(new_id), - SBP::MsgTrackingIq(msg) => msg.set_sender_id(new_id), - SBP::MsgAcqSvProfile(msg) => msg.set_sender_id(new_id), - SBP::MsgAcqResult(msg) => msg.set_sender_id(new_id), - SBP::MsgTrackingState(msg) => msg.set_sender_id(new_id), - SBP::MsgObsDepB(msg) => msg.set_sender_id(new_id), - SBP::MsgBasePosLLH(msg) => msg.set_sender_id(new_id), - SBP::MsgObsDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgEphemerisDepB(msg) => msg.set_sender_id(new_id), - SBP::MsgEphemerisDepC(msg) => msg.set_sender_id(new_id), - SBP::MsgBasePosECEF(msg) => msg.set_sender_id(new_id), - SBP::MsgObsDepC(msg) => msg.set_sender_id(new_id), - SBP::MsgObs(msg) => msg.set_sender_id(new_id), - SBP::MsgSpecanDep(msg) => msg.set_sender_id(new_id), - SBP::MsgSpecan(msg) => msg.set_sender_id(new_id), - SBP::MsgMeasurementState(msg) => msg.set_sender_id(new_id), - SBP::MsgSetTime(msg) => msg.set_sender_id(new_id), - SBP::MsgAlmanac(msg) => msg.set_sender_id(new_id), - SBP::MsgAlmanacGPSDep(msg) => msg.set_sender_id(new_id), - SBP::MsgAlmanacGloDep(msg) => msg.set_sender_id(new_id), - SBP::MsgAlmanacGPS(msg) => msg.set_sender_id(new_id), - SBP::MsgAlmanacGlo(msg) => msg.set_sender_id(new_id), - SBP::MsgGloBiases(msg) => msg.set_sender_id(new_id), - SBP::MsgEphemerisDepD(msg) => msg.set_sender_id(new_id), - SBP::MsgEphemerisGPSDepE(msg) => msg.set_sender_id(new_id), - SBP::MsgEphemerisSbasDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgEphemerisGloDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgEphemerisSbasDepB(msg) => msg.set_sender_id(new_id), - SBP::MsgEphemerisGloDepB(msg) => msg.set_sender_id(new_id), - SBP::MsgEphemerisGPSDepF(msg) => msg.set_sender_id(new_id), - SBP::MsgEphemerisGloDepC(msg) => msg.set_sender_id(new_id), - SBP::MsgEphemerisGloDepD(msg) => msg.set_sender_id(new_id), - SBP::MsgEphemerisBds(msg) => msg.set_sender_id(new_id), - SBP::MsgEphemerisGPS(msg) => msg.set_sender_id(new_id), - SBP::MsgEphemerisGlo(msg) => msg.set_sender_id(new_id), - SBP::MsgEphemerisSbas(msg) => msg.set_sender_id(new_id), - SBP::MsgEphemerisGal(msg) => msg.set_sender_id(new_id), - SBP::MsgEphemerisQzss(msg) => msg.set_sender_id(new_id), - SBP::MsgIono(msg) => msg.set_sender_id(new_id), - SBP::MsgSvConfigurationGPSDep(msg) => msg.set_sender_id(new_id), - SBP::MsgGroupDelayDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgGroupDelayDepB(msg) => msg.set_sender_id(new_id), - SBP::MsgGroupDelay(msg) => msg.set_sender_id(new_id), - SBP::MsgEphemerisGalDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgGnssCapb(msg) => msg.set_sender_id(new_id), - SBP::MsgSvAzEl(msg) => msg.set_sender_id(new_id), - SBP::MsgSettingsWrite(msg) => msg.set_sender_id(new_id), - SBP::MsgSettingsSave(msg) => msg.set_sender_id(new_id), - SBP::MsgSettingsReadByIndexReq(msg) => msg.set_sender_id(new_id), - SBP::MsgFileioReadResp(msg) => msg.set_sender_id(new_id), - SBP::MsgSettingsReadReq(msg) => msg.set_sender_id(new_id), - SBP::MsgSettingsReadResp(msg) => msg.set_sender_id(new_id), - SBP::MsgSettingsReadByIndexDone(msg) => msg.set_sender_id(new_id), - SBP::MsgSettingsReadByIndexResp(msg) => msg.set_sender_id(new_id), - SBP::MsgFileioReadReq(msg) => msg.set_sender_id(new_id), - SBP::MsgFileioReadDirReq(msg) => msg.set_sender_id(new_id), - SBP::MsgFileioReadDirResp(msg) => msg.set_sender_id(new_id), - SBP::MsgFileioWriteResp(msg) => msg.set_sender_id(new_id), - SBP::MsgFileioRemove(msg) => msg.set_sender_id(new_id), - SBP::MsgFileioWriteReq(msg) => msg.set_sender_id(new_id), - SBP::MsgSettingsRegister(msg) => msg.set_sender_id(new_id), - SBP::MsgSettingsWriteResp(msg) => msg.set_sender_id(new_id), - SBP::MsgBootloaderHandshakeDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgBootloaderJumpToApp(msg) => msg.set_sender_id(new_id), - SBP::MsgResetDep(msg) => msg.set_sender_id(new_id), - SBP::MsgBootloaderHandshakeReq(msg) => msg.set_sender_id(new_id), - SBP::MsgBootloaderHandshakeResp(msg) => msg.set_sender_id(new_id), - SBP::MsgDeviceMonitor(msg) => msg.set_sender_id(new_id), - SBP::MsgReset(msg) => msg.set_sender_id(new_id), - SBP::MsgCommandReq(msg) => msg.set_sender_id(new_id), - SBP::MsgCommandResp(msg) => msg.set_sender_id(new_id), - SBP::MsgNetworkStateReq(msg) => msg.set_sender_id(new_id), - SBP::MsgNetworkStateResp(msg) => msg.set_sender_id(new_id), - SBP::MsgCommandOutput(msg) => msg.set_sender_id(new_id), - SBP::MsgNetworkBandwidthUsage(msg) => msg.set_sender_id(new_id), - SBP::MsgCellModemStatus(msg) => msg.set_sender_id(new_id), - SBP::MsgFrontEndGain(msg) => msg.set_sender_id(new_id), - SBP::MsgCwResults(msg) => msg.set_sender_id(new_id), - SBP::MsgCwStart(msg) => msg.set_sender_id(new_id), - SBP::MsgNapDeviceDnaResp(msg) => msg.set_sender_id(new_id), - SBP::MsgNapDeviceDnaReq(msg) => msg.set_sender_id(new_id), - SBP::MsgFlashDone(msg) => msg.set_sender_id(new_id), - SBP::MsgFlashReadResp(msg) => msg.set_sender_id(new_id), - SBP::MsgFlashErase(msg) => msg.set_sender_id(new_id), - SBP::MsgStmFlashLockSector(msg) => msg.set_sender_id(new_id), - SBP::MsgStmFlashUnlockSector(msg) => msg.set_sender_id(new_id), - SBP::MsgStmUniqueIdResp(msg) => msg.set_sender_id(new_id), - SBP::MsgFlashProgram(msg) => msg.set_sender_id(new_id), - SBP::MsgFlashReadReq(msg) => msg.set_sender_id(new_id), - SBP::MsgStmUniqueIdReq(msg) => msg.set_sender_id(new_id), - SBP::MsgM25FlashWriteStatus(msg) => msg.set_sender_id(new_id), - SBP::MsgGPSTimeDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgExtEvent(msg) => msg.set_sender_id(new_id), - SBP::MsgGPSTime(msg) => msg.set_sender_id(new_id), - SBP::MsgUtcTime(msg) => msg.set_sender_id(new_id), - SBP::MsgGPSTimeGnss(msg) => msg.set_sender_id(new_id), - SBP::MsgUtcTimeGnss(msg) => msg.set_sender_id(new_id), - SBP::MsgSettingsRegisterResp(msg) => msg.set_sender_id(new_id), - SBP::MsgPosECEFDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgPosLLHDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgBaselineECEFDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgBaselineNEDDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgVelECEFDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgVelNEDDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgDopsDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgBaselineHeadingDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgDops(msg) => msg.set_sender_id(new_id), - SBP::MsgPosECEF(msg) => msg.set_sender_id(new_id), - SBP::MsgPosLLH(msg) => msg.set_sender_id(new_id), - SBP::MsgBaselineECEF(msg) => msg.set_sender_id(new_id), - SBP::MsgBaselineNED(msg) => msg.set_sender_id(new_id), - SBP::MsgVelECEF(msg) => msg.set_sender_id(new_id), - SBP::MsgVelNED(msg) => msg.set_sender_id(new_id), - SBP::MsgBaselineHeading(msg) => msg.set_sender_id(new_id), - SBP::MsgAgeCorrections(msg) => msg.set_sender_id(new_id), - SBP::MsgPosLLHCov(msg) => msg.set_sender_id(new_id), - SBP::MsgVelNEDCov(msg) => msg.set_sender_id(new_id), - SBP::MsgVelBody(msg) => msg.set_sender_id(new_id), - SBP::MsgPosECEFCov(msg) => msg.set_sender_id(new_id), - SBP::MsgVelECEFCov(msg) => msg.set_sender_id(new_id), - SBP::MsgProtectionLevelDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgProtectionLevel(msg) => msg.set_sender_id(new_id), - SBP::MsgPosLLHAcc(msg) => msg.set_sender_id(new_id), - SBP::MsgOrientQuat(msg) => msg.set_sender_id(new_id), - SBP::MsgOrientEuler(msg) => msg.set_sender_id(new_id), - SBP::MsgAngularRate(msg) => msg.set_sender_id(new_id), - SBP::MsgPosECEFGnss(msg) => msg.set_sender_id(new_id), - SBP::MsgPosLLHGnss(msg) => msg.set_sender_id(new_id), - SBP::MsgVelECEFGnss(msg) => msg.set_sender_id(new_id), - SBP::MsgVelNEDGnss(msg) => msg.set_sender_id(new_id), - SBP::MsgPosLLHCovGnss(msg) => msg.set_sender_id(new_id), - SBP::MsgVelNEDCovGnss(msg) => msg.set_sender_id(new_id), - SBP::MsgPosECEFCovGnss(msg) => msg.set_sender_id(new_id), - SBP::MsgVelECEFCovGnss(msg) => msg.set_sender_id(new_id), - SBP::MsgNdbEvent(msg) => msg.set_sender_id(new_id), - SBP::MsgLog(msg) => msg.set_sender_id(new_id), - SBP::MsgFwd(msg) => msg.set_sender_id(new_id), - SBP::MsgSsrOrbitClockDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgSsrOrbitClock(msg) => msg.set_sender_id(new_id), - SBP::MsgSsrCodeBiases(msg) => msg.set_sender_id(new_id), - SBP::MsgSsrPhaseBiases(msg) => msg.set_sender_id(new_id), - SBP::MsgSsrStecCorrectionDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgSsrGriddedCorrectionNoStdDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgSsrGridDefinitionDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgSsrTileDefinition(msg) => msg.set_sender_id(new_id), - SBP::MsgSsrGriddedCorrectionDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgSsrStecCorrection(msg) => msg.set_sender_id(new_id), - SBP::MsgSsrGriddedCorrection(msg) => msg.set_sender_id(new_id), - SBP::MsgSsrSatelliteApc(msg) => msg.set_sender_id(new_id), - SBP::MsgOsr(msg) => msg.set_sender_id(new_id), - SBP::MsgUserData(msg) => msg.set_sender_id(new_id), - SBP::MsgImuRaw(msg) => msg.set_sender_id(new_id), - SBP::MsgImuAux(msg) => msg.set_sender_id(new_id), - SBP::MsgMagRaw(msg) => msg.set_sender_id(new_id), - SBP::MsgOdometry(msg) => msg.set_sender_id(new_id), - SBP::MsgWheeltick(msg) => msg.set_sender_id(new_id), - SBP::MsgFileioConfigReq(msg) => msg.set_sender_id(new_id), - SBP::MsgFileioConfigResp(msg) => msg.set_sender_id(new_id), - SBP::MsgSbasRaw(msg) => msg.set_sender_id(new_id), - SBP::MsgLinuxCpuStateDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgLinuxMemStateDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgLinuxSysStateDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgLinuxProcessSocketCounts(msg) => msg.set_sender_id(new_id), - SBP::MsgLinuxProcessSocketQueues(msg) => msg.set_sender_id(new_id), - SBP::MsgLinuxSocketUsage(msg) => msg.set_sender_id(new_id), - SBP::MsgLinuxProcessFdCount(msg) => msg.set_sender_id(new_id), - SBP::MsgLinuxProcessFdSummary(msg) => msg.set_sender_id(new_id), - SBP::MsgLinuxCpuState(msg) => msg.set_sender_id(new_id), - SBP::MsgLinuxMemState(msg) => msg.set_sender_id(new_id), - SBP::MsgLinuxSysState(msg) => msg.set_sender_id(new_id), - SBP::MsgStartup(msg) => msg.set_sender_id(new_id), - SBP::MsgDgnssStatus(msg) => msg.set_sender_id(new_id), - SBP::MsgInsStatus(msg) => msg.set_sender_id(new_id), - SBP::MsgCsacTelemetry(msg) => msg.set_sender_id(new_id), - SBP::MsgCsacTelemetryLabels(msg) => msg.set_sender_id(new_id), - SBP::MsgInsUpdates(msg) => msg.set_sender_id(new_id), - SBP::MsgGnssTimeOffset(msg) => msg.set_sender_id(new_id), - SBP::MsgPpsTime(msg) => msg.set_sender_id(new_id), - SBP::MsgGroupMeta(msg) => msg.set_sender_id(new_id), - SBP::MsgSolnMeta(msg) => msg.set_sender_id(new_id), - SBP::MsgSolnMetaDepA(msg) => msg.set_sender_id(new_id), - SBP::MsgStatusReport(msg) => msg.set_sender_id(new_id), - SBP::MsgHeartbeat(msg) => msg.set_sender_id(new_id), - SBP::Unknown(msg) => msg.set_sender_id(new_id), - } - } - - fn to_frame(&self) -> Result, crate::FramerError> { - match self { - SBP::MsgPrintDep(msg) => msg.to_frame(), - SBP::MsgTrackingStateDetailedDep(msg) => msg.to_frame(), - SBP::MsgTrackingStateDepB(msg) => msg.to_frame(), - SBP::MsgAcqResultDepB(msg) => msg.to_frame(), - SBP::MsgAcqResultDepA(msg) => msg.to_frame(), - SBP::MsgTrackingStateDepA(msg) => msg.to_frame(), - SBP::MsgThreadState(msg) => msg.to_frame(), - SBP::MsgUartStateDepa(msg) => msg.to_frame(), - SBP::MsgIarState(msg) => msg.to_frame(), - SBP::MsgEphemerisDepA(msg) => msg.to_frame(), - SBP::MsgMaskSatelliteDep(msg) => msg.to_frame(), - SBP::MsgTrackingIqDepA(msg) => msg.to_frame(), - SBP::MsgUartState(msg) => msg.to_frame(), - SBP::MsgAcqSvProfileDep(msg) => msg.to_frame(), - SBP::MsgAcqResultDepC(msg) => msg.to_frame(), - SBP::MsgTrackingStateDetailedDepA(msg) => msg.to_frame(), - SBP::MsgResetFilters(msg) => msg.to_frame(), - SBP::MsgInitBaseDep(msg) => msg.to_frame(), - SBP::MsgMaskSatellite(msg) => msg.to_frame(), - SBP::MsgTrackingIqDepB(msg) => msg.to_frame(), - SBP::MsgTrackingIq(msg) => msg.to_frame(), - SBP::MsgAcqSvProfile(msg) => msg.to_frame(), - SBP::MsgAcqResult(msg) => msg.to_frame(), - SBP::MsgTrackingState(msg) => msg.to_frame(), - SBP::MsgObsDepB(msg) => msg.to_frame(), - SBP::MsgBasePosLLH(msg) => msg.to_frame(), - SBP::MsgObsDepA(msg) => msg.to_frame(), - SBP::MsgEphemerisDepB(msg) => msg.to_frame(), - SBP::MsgEphemerisDepC(msg) => msg.to_frame(), - SBP::MsgBasePosECEF(msg) => msg.to_frame(), - SBP::MsgObsDepC(msg) => msg.to_frame(), - SBP::MsgObs(msg) => msg.to_frame(), - SBP::MsgSpecanDep(msg) => msg.to_frame(), - SBP::MsgSpecan(msg) => msg.to_frame(), - SBP::MsgMeasurementState(msg) => msg.to_frame(), - SBP::MsgSetTime(msg) => msg.to_frame(), - SBP::MsgAlmanac(msg) => msg.to_frame(), - SBP::MsgAlmanacGPSDep(msg) => msg.to_frame(), - SBP::MsgAlmanacGloDep(msg) => msg.to_frame(), - SBP::MsgAlmanacGPS(msg) => msg.to_frame(), - SBP::MsgAlmanacGlo(msg) => msg.to_frame(), - SBP::MsgGloBiases(msg) => msg.to_frame(), - SBP::MsgEphemerisDepD(msg) => msg.to_frame(), - SBP::MsgEphemerisGPSDepE(msg) => msg.to_frame(), - SBP::MsgEphemerisSbasDepA(msg) => msg.to_frame(), - SBP::MsgEphemerisGloDepA(msg) => msg.to_frame(), - SBP::MsgEphemerisSbasDepB(msg) => msg.to_frame(), - SBP::MsgEphemerisGloDepB(msg) => msg.to_frame(), - SBP::MsgEphemerisGPSDepF(msg) => msg.to_frame(), - SBP::MsgEphemerisGloDepC(msg) => msg.to_frame(), - SBP::MsgEphemerisGloDepD(msg) => msg.to_frame(), - SBP::MsgEphemerisBds(msg) => msg.to_frame(), - SBP::MsgEphemerisGPS(msg) => msg.to_frame(), - SBP::MsgEphemerisGlo(msg) => msg.to_frame(), - SBP::MsgEphemerisSbas(msg) => msg.to_frame(), - SBP::MsgEphemerisGal(msg) => msg.to_frame(), - SBP::MsgEphemerisQzss(msg) => msg.to_frame(), - SBP::MsgIono(msg) => msg.to_frame(), - SBP::MsgSvConfigurationGPSDep(msg) => msg.to_frame(), - SBP::MsgGroupDelayDepA(msg) => msg.to_frame(), - SBP::MsgGroupDelayDepB(msg) => msg.to_frame(), - SBP::MsgGroupDelay(msg) => msg.to_frame(), - SBP::MsgEphemerisGalDepA(msg) => msg.to_frame(), - SBP::MsgGnssCapb(msg) => msg.to_frame(), - SBP::MsgSvAzEl(msg) => msg.to_frame(), - SBP::MsgSettingsWrite(msg) => msg.to_frame(), - SBP::MsgSettingsSave(msg) => msg.to_frame(), - SBP::MsgSettingsReadByIndexReq(msg) => msg.to_frame(), - SBP::MsgFileioReadResp(msg) => msg.to_frame(), - SBP::MsgSettingsReadReq(msg) => msg.to_frame(), - SBP::MsgSettingsReadResp(msg) => msg.to_frame(), - SBP::MsgSettingsReadByIndexDone(msg) => msg.to_frame(), - SBP::MsgSettingsReadByIndexResp(msg) => msg.to_frame(), - SBP::MsgFileioReadReq(msg) => msg.to_frame(), - SBP::MsgFileioReadDirReq(msg) => msg.to_frame(), - SBP::MsgFileioReadDirResp(msg) => msg.to_frame(), - SBP::MsgFileioWriteResp(msg) => msg.to_frame(), - SBP::MsgFileioRemove(msg) => msg.to_frame(), - SBP::MsgFileioWriteReq(msg) => msg.to_frame(), - SBP::MsgSettingsRegister(msg) => msg.to_frame(), - SBP::MsgSettingsWriteResp(msg) => msg.to_frame(), - SBP::MsgBootloaderHandshakeDepA(msg) => msg.to_frame(), - SBP::MsgBootloaderJumpToApp(msg) => msg.to_frame(), - SBP::MsgResetDep(msg) => msg.to_frame(), - SBP::MsgBootloaderHandshakeReq(msg) => msg.to_frame(), - SBP::MsgBootloaderHandshakeResp(msg) => msg.to_frame(), - SBP::MsgDeviceMonitor(msg) => msg.to_frame(), - SBP::MsgReset(msg) => msg.to_frame(), - SBP::MsgCommandReq(msg) => msg.to_frame(), - SBP::MsgCommandResp(msg) => msg.to_frame(), - SBP::MsgNetworkStateReq(msg) => msg.to_frame(), - SBP::MsgNetworkStateResp(msg) => msg.to_frame(), - SBP::MsgCommandOutput(msg) => msg.to_frame(), - SBP::MsgNetworkBandwidthUsage(msg) => msg.to_frame(), - SBP::MsgCellModemStatus(msg) => msg.to_frame(), - SBP::MsgFrontEndGain(msg) => msg.to_frame(), - SBP::MsgCwResults(msg) => msg.to_frame(), - SBP::MsgCwStart(msg) => msg.to_frame(), - SBP::MsgNapDeviceDnaResp(msg) => msg.to_frame(), - SBP::MsgNapDeviceDnaReq(msg) => msg.to_frame(), - SBP::MsgFlashDone(msg) => msg.to_frame(), - SBP::MsgFlashReadResp(msg) => msg.to_frame(), - SBP::MsgFlashErase(msg) => msg.to_frame(), - SBP::MsgStmFlashLockSector(msg) => msg.to_frame(), - SBP::MsgStmFlashUnlockSector(msg) => msg.to_frame(), - SBP::MsgStmUniqueIdResp(msg) => msg.to_frame(), - SBP::MsgFlashProgram(msg) => msg.to_frame(), - SBP::MsgFlashReadReq(msg) => msg.to_frame(), - SBP::MsgStmUniqueIdReq(msg) => msg.to_frame(), - SBP::MsgM25FlashWriteStatus(msg) => msg.to_frame(), - SBP::MsgGPSTimeDepA(msg) => msg.to_frame(), - SBP::MsgExtEvent(msg) => msg.to_frame(), - SBP::MsgGPSTime(msg) => msg.to_frame(), - SBP::MsgUtcTime(msg) => msg.to_frame(), - SBP::MsgGPSTimeGnss(msg) => msg.to_frame(), - SBP::MsgUtcTimeGnss(msg) => msg.to_frame(), - SBP::MsgSettingsRegisterResp(msg) => msg.to_frame(), - SBP::MsgPosECEFDepA(msg) => msg.to_frame(), - SBP::MsgPosLLHDepA(msg) => msg.to_frame(), - SBP::MsgBaselineECEFDepA(msg) => msg.to_frame(), - SBP::MsgBaselineNEDDepA(msg) => msg.to_frame(), - SBP::MsgVelECEFDepA(msg) => msg.to_frame(), - SBP::MsgVelNEDDepA(msg) => msg.to_frame(), - SBP::MsgDopsDepA(msg) => msg.to_frame(), - SBP::MsgBaselineHeadingDepA(msg) => msg.to_frame(), - SBP::MsgDops(msg) => msg.to_frame(), - SBP::MsgPosECEF(msg) => msg.to_frame(), - SBP::MsgPosLLH(msg) => msg.to_frame(), - SBP::MsgBaselineECEF(msg) => msg.to_frame(), - SBP::MsgBaselineNED(msg) => msg.to_frame(), - SBP::MsgVelECEF(msg) => msg.to_frame(), - SBP::MsgVelNED(msg) => msg.to_frame(), - SBP::MsgBaselineHeading(msg) => msg.to_frame(), - SBP::MsgAgeCorrections(msg) => msg.to_frame(), - SBP::MsgPosLLHCov(msg) => msg.to_frame(), - SBP::MsgVelNEDCov(msg) => msg.to_frame(), - SBP::MsgVelBody(msg) => msg.to_frame(), - SBP::MsgPosECEFCov(msg) => msg.to_frame(), - SBP::MsgVelECEFCov(msg) => msg.to_frame(), - SBP::MsgProtectionLevelDepA(msg) => msg.to_frame(), - SBP::MsgProtectionLevel(msg) => msg.to_frame(), - SBP::MsgPosLLHAcc(msg) => msg.to_frame(), - SBP::MsgOrientQuat(msg) => msg.to_frame(), - SBP::MsgOrientEuler(msg) => msg.to_frame(), - SBP::MsgAngularRate(msg) => msg.to_frame(), - SBP::MsgPosECEFGnss(msg) => msg.to_frame(), - SBP::MsgPosLLHGnss(msg) => msg.to_frame(), - SBP::MsgVelECEFGnss(msg) => msg.to_frame(), - SBP::MsgVelNEDGnss(msg) => msg.to_frame(), - SBP::MsgPosLLHCovGnss(msg) => msg.to_frame(), - SBP::MsgVelNEDCovGnss(msg) => msg.to_frame(), - SBP::MsgPosECEFCovGnss(msg) => msg.to_frame(), - SBP::MsgVelECEFCovGnss(msg) => msg.to_frame(), - SBP::MsgNdbEvent(msg) => msg.to_frame(), - SBP::MsgLog(msg) => msg.to_frame(), - SBP::MsgFwd(msg) => msg.to_frame(), - SBP::MsgSsrOrbitClockDepA(msg) => msg.to_frame(), - SBP::MsgSsrOrbitClock(msg) => msg.to_frame(), - SBP::MsgSsrCodeBiases(msg) => msg.to_frame(), - SBP::MsgSsrPhaseBiases(msg) => msg.to_frame(), - SBP::MsgSsrStecCorrectionDepA(msg) => msg.to_frame(), - SBP::MsgSsrGriddedCorrectionNoStdDepA(msg) => msg.to_frame(), - SBP::MsgSsrGridDefinitionDepA(msg) => msg.to_frame(), - SBP::MsgSsrTileDefinition(msg) => msg.to_frame(), - SBP::MsgSsrGriddedCorrectionDepA(msg) => msg.to_frame(), - SBP::MsgSsrStecCorrection(msg) => msg.to_frame(), - SBP::MsgSsrGriddedCorrection(msg) => msg.to_frame(), - SBP::MsgSsrSatelliteApc(msg) => msg.to_frame(), - SBP::MsgOsr(msg) => msg.to_frame(), - SBP::MsgUserData(msg) => msg.to_frame(), - SBP::MsgImuRaw(msg) => msg.to_frame(), - SBP::MsgImuAux(msg) => msg.to_frame(), - SBP::MsgMagRaw(msg) => msg.to_frame(), - SBP::MsgOdometry(msg) => msg.to_frame(), - SBP::MsgWheeltick(msg) => msg.to_frame(), - SBP::MsgFileioConfigReq(msg) => msg.to_frame(), - SBP::MsgFileioConfigResp(msg) => msg.to_frame(), - SBP::MsgSbasRaw(msg) => msg.to_frame(), - SBP::MsgLinuxCpuStateDepA(msg) => msg.to_frame(), - SBP::MsgLinuxMemStateDepA(msg) => msg.to_frame(), - SBP::MsgLinuxSysStateDepA(msg) => msg.to_frame(), - SBP::MsgLinuxProcessSocketCounts(msg) => msg.to_frame(), - SBP::MsgLinuxProcessSocketQueues(msg) => msg.to_frame(), - SBP::MsgLinuxSocketUsage(msg) => msg.to_frame(), - SBP::MsgLinuxProcessFdCount(msg) => msg.to_frame(), - SBP::MsgLinuxProcessFdSummary(msg) => msg.to_frame(), - SBP::MsgLinuxCpuState(msg) => msg.to_frame(), - SBP::MsgLinuxMemState(msg) => msg.to_frame(), - SBP::MsgLinuxSysState(msg) => msg.to_frame(), - SBP::MsgStartup(msg) => msg.to_frame(), - SBP::MsgDgnssStatus(msg) => msg.to_frame(), - SBP::MsgInsStatus(msg) => msg.to_frame(), - SBP::MsgCsacTelemetry(msg) => msg.to_frame(), - SBP::MsgCsacTelemetryLabels(msg) => msg.to_frame(), - SBP::MsgInsUpdates(msg) => msg.to_frame(), - SBP::MsgGnssTimeOffset(msg) => msg.to_frame(), - SBP::MsgPpsTime(msg) => msg.to_frame(), - SBP::MsgGroupMeta(msg) => msg.to_frame(), - SBP::MsgSolnMeta(msg) => msg.to_frame(), - SBP::MsgSolnMetaDepA(msg) => msg.to_frame(), - SBP::MsgStatusReport(msg) => msg.to_frame(), - SBP::MsgHeartbeat(msg) => msg.to_frame(), - SBP::Unknown(msg) => msg.to_frame(), - } - } - - fn write_frame(&self, buf: &mut Vec) -> Result<(), crate::FramerError> { - match self { - SBP::MsgPrintDep(msg) => msg.write_frame(buf), - SBP::MsgTrackingStateDetailedDep(msg) => msg.write_frame(buf), - SBP::MsgTrackingStateDepB(msg) => msg.write_frame(buf), - SBP::MsgAcqResultDepB(msg) => msg.write_frame(buf), - SBP::MsgAcqResultDepA(msg) => msg.write_frame(buf), - SBP::MsgTrackingStateDepA(msg) => msg.write_frame(buf), - SBP::MsgThreadState(msg) => msg.write_frame(buf), - SBP::MsgUartStateDepa(msg) => msg.write_frame(buf), - SBP::MsgIarState(msg) => msg.write_frame(buf), - SBP::MsgEphemerisDepA(msg) => msg.write_frame(buf), - SBP::MsgMaskSatelliteDep(msg) => msg.write_frame(buf), - SBP::MsgTrackingIqDepA(msg) => msg.write_frame(buf), - SBP::MsgUartState(msg) => msg.write_frame(buf), - SBP::MsgAcqSvProfileDep(msg) => msg.write_frame(buf), - SBP::MsgAcqResultDepC(msg) => msg.write_frame(buf), - SBP::MsgTrackingStateDetailedDepA(msg) => msg.write_frame(buf), - SBP::MsgResetFilters(msg) => msg.write_frame(buf), - SBP::MsgInitBaseDep(msg) => msg.write_frame(buf), - SBP::MsgMaskSatellite(msg) => msg.write_frame(buf), - SBP::MsgTrackingIqDepB(msg) => msg.write_frame(buf), - SBP::MsgTrackingIq(msg) => msg.write_frame(buf), - SBP::MsgAcqSvProfile(msg) => msg.write_frame(buf), - SBP::MsgAcqResult(msg) => msg.write_frame(buf), - SBP::MsgTrackingState(msg) => msg.write_frame(buf), - SBP::MsgObsDepB(msg) => msg.write_frame(buf), - SBP::MsgBasePosLLH(msg) => msg.write_frame(buf), - SBP::MsgObsDepA(msg) => msg.write_frame(buf), - SBP::MsgEphemerisDepB(msg) => msg.write_frame(buf), - SBP::MsgEphemerisDepC(msg) => msg.write_frame(buf), - SBP::MsgBasePosECEF(msg) => msg.write_frame(buf), - SBP::MsgObsDepC(msg) => msg.write_frame(buf), - SBP::MsgObs(msg) => msg.write_frame(buf), - SBP::MsgSpecanDep(msg) => msg.write_frame(buf), - SBP::MsgSpecan(msg) => msg.write_frame(buf), - SBP::MsgMeasurementState(msg) => msg.write_frame(buf), - SBP::MsgSetTime(msg) => msg.write_frame(buf), - SBP::MsgAlmanac(msg) => msg.write_frame(buf), - SBP::MsgAlmanacGPSDep(msg) => msg.write_frame(buf), - SBP::MsgAlmanacGloDep(msg) => msg.write_frame(buf), - SBP::MsgAlmanacGPS(msg) => msg.write_frame(buf), - SBP::MsgAlmanacGlo(msg) => msg.write_frame(buf), - SBP::MsgGloBiases(msg) => msg.write_frame(buf), - SBP::MsgEphemerisDepD(msg) => msg.write_frame(buf), - SBP::MsgEphemerisGPSDepE(msg) => msg.write_frame(buf), - SBP::MsgEphemerisSbasDepA(msg) => msg.write_frame(buf), - SBP::MsgEphemerisGloDepA(msg) => msg.write_frame(buf), - SBP::MsgEphemerisSbasDepB(msg) => msg.write_frame(buf), - SBP::MsgEphemerisGloDepB(msg) => msg.write_frame(buf), - SBP::MsgEphemerisGPSDepF(msg) => msg.write_frame(buf), - SBP::MsgEphemerisGloDepC(msg) => msg.write_frame(buf), - SBP::MsgEphemerisGloDepD(msg) => msg.write_frame(buf), - SBP::MsgEphemerisBds(msg) => msg.write_frame(buf), - SBP::MsgEphemerisGPS(msg) => msg.write_frame(buf), - SBP::MsgEphemerisGlo(msg) => msg.write_frame(buf), - SBP::MsgEphemerisSbas(msg) => msg.write_frame(buf), - SBP::MsgEphemerisGal(msg) => msg.write_frame(buf), - SBP::MsgEphemerisQzss(msg) => msg.write_frame(buf), - SBP::MsgIono(msg) => msg.write_frame(buf), - SBP::MsgSvConfigurationGPSDep(msg) => msg.write_frame(buf), - SBP::MsgGroupDelayDepA(msg) => msg.write_frame(buf), - SBP::MsgGroupDelayDepB(msg) => msg.write_frame(buf), - SBP::MsgGroupDelay(msg) => msg.write_frame(buf), - SBP::MsgEphemerisGalDepA(msg) => msg.write_frame(buf), - SBP::MsgGnssCapb(msg) => msg.write_frame(buf), - SBP::MsgSvAzEl(msg) => msg.write_frame(buf), - SBP::MsgSettingsWrite(msg) => msg.write_frame(buf), - SBP::MsgSettingsSave(msg) => msg.write_frame(buf), - SBP::MsgSettingsReadByIndexReq(msg) => msg.write_frame(buf), - SBP::MsgFileioReadResp(msg) => msg.write_frame(buf), - SBP::MsgSettingsReadReq(msg) => msg.write_frame(buf), - SBP::MsgSettingsReadResp(msg) => msg.write_frame(buf), - SBP::MsgSettingsReadByIndexDone(msg) => msg.write_frame(buf), - SBP::MsgSettingsReadByIndexResp(msg) => msg.write_frame(buf), - SBP::MsgFileioReadReq(msg) => msg.write_frame(buf), - SBP::MsgFileioReadDirReq(msg) => msg.write_frame(buf), - SBP::MsgFileioReadDirResp(msg) => msg.write_frame(buf), - SBP::MsgFileioWriteResp(msg) => msg.write_frame(buf), - SBP::MsgFileioRemove(msg) => msg.write_frame(buf), - SBP::MsgFileioWriteReq(msg) => msg.write_frame(buf), - SBP::MsgSettingsRegister(msg) => msg.write_frame(buf), - SBP::MsgSettingsWriteResp(msg) => msg.write_frame(buf), - SBP::MsgBootloaderHandshakeDepA(msg) => msg.write_frame(buf), - SBP::MsgBootloaderJumpToApp(msg) => msg.write_frame(buf), - SBP::MsgResetDep(msg) => msg.write_frame(buf), - SBP::MsgBootloaderHandshakeReq(msg) => msg.write_frame(buf), - SBP::MsgBootloaderHandshakeResp(msg) => msg.write_frame(buf), - SBP::MsgDeviceMonitor(msg) => msg.write_frame(buf), - SBP::MsgReset(msg) => msg.write_frame(buf), - SBP::MsgCommandReq(msg) => msg.write_frame(buf), - SBP::MsgCommandResp(msg) => msg.write_frame(buf), - SBP::MsgNetworkStateReq(msg) => msg.write_frame(buf), - SBP::MsgNetworkStateResp(msg) => msg.write_frame(buf), - SBP::MsgCommandOutput(msg) => msg.write_frame(buf), - SBP::MsgNetworkBandwidthUsage(msg) => msg.write_frame(buf), - SBP::MsgCellModemStatus(msg) => msg.write_frame(buf), - SBP::MsgFrontEndGain(msg) => msg.write_frame(buf), - SBP::MsgCwResults(msg) => msg.write_frame(buf), - SBP::MsgCwStart(msg) => msg.write_frame(buf), - SBP::MsgNapDeviceDnaResp(msg) => msg.write_frame(buf), - SBP::MsgNapDeviceDnaReq(msg) => msg.write_frame(buf), - SBP::MsgFlashDone(msg) => msg.write_frame(buf), - SBP::MsgFlashReadResp(msg) => msg.write_frame(buf), - SBP::MsgFlashErase(msg) => msg.write_frame(buf), - SBP::MsgStmFlashLockSector(msg) => msg.write_frame(buf), - SBP::MsgStmFlashUnlockSector(msg) => msg.write_frame(buf), - SBP::MsgStmUniqueIdResp(msg) => msg.write_frame(buf), - SBP::MsgFlashProgram(msg) => msg.write_frame(buf), - SBP::MsgFlashReadReq(msg) => msg.write_frame(buf), - SBP::MsgStmUniqueIdReq(msg) => msg.write_frame(buf), - SBP::MsgM25FlashWriteStatus(msg) => msg.write_frame(buf), - SBP::MsgGPSTimeDepA(msg) => msg.write_frame(buf), - SBP::MsgExtEvent(msg) => msg.write_frame(buf), - SBP::MsgGPSTime(msg) => msg.write_frame(buf), - SBP::MsgUtcTime(msg) => msg.write_frame(buf), - SBP::MsgGPSTimeGnss(msg) => msg.write_frame(buf), - SBP::MsgUtcTimeGnss(msg) => msg.write_frame(buf), - SBP::MsgSettingsRegisterResp(msg) => msg.write_frame(buf), - SBP::MsgPosECEFDepA(msg) => msg.write_frame(buf), - SBP::MsgPosLLHDepA(msg) => msg.write_frame(buf), - SBP::MsgBaselineECEFDepA(msg) => msg.write_frame(buf), - SBP::MsgBaselineNEDDepA(msg) => msg.write_frame(buf), - SBP::MsgVelECEFDepA(msg) => msg.write_frame(buf), - SBP::MsgVelNEDDepA(msg) => msg.write_frame(buf), - SBP::MsgDopsDepA(msg) => msg.write_frame(buf), - SBP::MsgBaselineHeadingDepA(msg) => msg.write_frame(buf), - SBP::MsgDops(msg) => msg.write_frame(buf), - SBP::MsgPosECEF(msg) => msg.write_frame(buf), - SBP::MsgPosLLH(msg) => msg.write_frame(buf), - SBP::MsgBaselineECEF(msg) => msg.write_frame(buf), - SBP::MsgBaselineNED(msg) => msg.write_frame(buf), - SBP::MsgVelECEF(msg) => msg.write_frame(buf), - SBP::MsgVelNED(msg) => msg.write_frame(buf), - SBP::MsgBaselineHeading(msg) => msg.write_frame(buf), - SBP::MsgAgeCorrections(msg) => msg.write_frame(buf), - SBP::MsgPosLLHCov(msg) => msg.write_frame(buf), - SBP::MsgVelNEDCov(msg) => msg.write_frame(buf), - SBP::MsgVelBody(msg) => msg.write_frame(buf), - SBP::MsgPosECEFCov(msg) => msg.write_frame(buf), - SBP::MsgVelECEFCov(msg) => msg.write_frame(buf), - SBP::MsgProtectionLevelDepA(msg) => msg.write_frame(buf), - SBP::MsgProtectionLevel(msg) => msg.write_frame(buf), - SBP::MsgPosLLHAcc(msg) => msg.write_frame(buf), - SBP::MsgOrientQuat(msg) => msg.write_frame(buf), - SBP::MsgOrientEuler(msg) => msg.write_frame(buf), - SBP::MsgAngularRate(msg) => msg.write_frame(buf), - SBP::MsgPosECEFGnss(msg) => msg.write_frame(buf), - SBP::MsgPosLLHGnss(msg) => msg.write_frame(buf), - SBP::MsgVelECEFGnss(msg) => msg.write_frame(buf), - SBP::MsgVelNEDGnss(msg) => msg.write_frame(buf), - SBP::MsgPosLLHCovGnss(msg) => msg.write_frame(buf), - SBP::MsgVelNEDCovGnss(msg) => msg.write_frame(buf), - SBP::MsgPosECEFCovGnss(msg) => msg.write_frame(buf), - SBP::MsgVelECEFCovGnss(msg) => msg.write_frame(buf), - SBP::MsgNdbEvent(msg) => msg.write_frame(buf), - SBP::MsgLog(msg) => msg.write_frame(buf), - SBP::MsgFwd(msg) => msg.write_frame(buf), - SBP::MsgSsrOrbitClockDepA(msg) => msg.write_frame(buf), - SBP::MsgSsrOrbitClock(msg) => msg.write_frame(buf), - SBP::MsgSsrCodeBiases(msg) => msg.write_frame(buf), - SBP::MsgSsrPhaseBiases(msg) => msg.write_frame(buf), - SBP::MsgSsrStecCorrectionDepA(msg) => msg.write_frame(buf), - SBP::MsgSsrGriddedCorrectionNoStdDepA(msg) => msg.write_frame(buf), - SBP::MsgSsrGridDefinitionDepA(msg) => msg.write_frame(buf), - SBP::MsgSsrTileDefinition(msg) => msg.write_frame(buf), - SBP::MsgSsrGriddedCorrectionDepA(msg) => msg.write_frame(buf), - SBP::MsgSsrStecCorrection(msg) => msg.write_frame(buf), - SBP::MsgSsrGriddedCorrection(msg) => msg.write_frame(buf), - SBP::MsgSsrSatelliteApc(msg) => msg.write_frame(buf), - SBP::MsgOsr(msg) => msg.write_frame(buf), - SBP::MsgUserData(msg) => msg.write_frame(buf), - SBP::MsgImuRaw(msg) => msg.write_frame(buf), - SBP::MsgImuAux(msg) => msg.write_frame(buf), - SBP::MsgMagRaw(msg) => msg.write_frame(buf), - SBP::MsgOdometry(msg) => msg.write_frame(buf), - SBP::MsgWheeltick(msg) => msg.write_frame(buf), - SBP::MsgFileioConfigReq(msg) => msg.write_frame(buf), - SBP::MsgFileioConfigResp(msg) => msg.write_frame(buf), - SBP::MsgSbasRaw(msg) => msg.write_frame(buf), - SBP::MsgLinuxCpuStateDepA(msg) => msg.write_frame(buf), - SBP::MsgLinuxMemStateDepA(msg) => msg.write_frame(buf), - SBP::MsgLinuxSysStateDepA(msg) => msg.write_frame(buf), - SBP::MsgLinuxProcessSocketCounts(msg) => msg.write_frame(buf), - SBP::MsgLinuxProcessSocketQueues(msg) => msg.write_frame(buf), - SBP::MsgLinuxSocketUsage(msg) => msg.write_frame(buf), - SBP::MsgLinuxProcessFdCount(msg) => msg.write_frame(buf), - SBP::MsgLinuxProcessFdSummary(msg) => msg.write_frame(buf), - SBP::MsgLinuxCpuState(msg) => msg.write_frame(buf), - SBP::MsgLinuxMemState(msg) => msg.write_frame(buf), - SBP::MsgLinuxSysState(msg) => msg.write_frame(buf), - SBP::MsgStartup(msg) => msg.write_frame(buf), - SBP::MsgDgnssStatus(msg) => msg.write_frame(buf), - SBP::MsgInsStatus(msg) => msg.write_frame(buf), - SBP::MsgCsacTelemetry(msg) => msg.write_frame(buf), - SBP::MsgCsacTelemetryLabels(msg) => msg.write_frame(buf), - SBP::MsgInsUpdates(msg) => msg.write_frame(buf), - SBP::MsgGnssTimeOffset(msg) => msg.write_frame(buf), - SBP::MsgPpsTime(msg) => msg.write_frame(buf), - SBP::MsgGroupMeta(msg) => msg.write_frame(buf), - SBP::MsgSolnMeta(msg) => msg.write_frame(buf), - SBP::MsgSolnMetaDepA(msg) => msg.write_frame(buf), - SBP::MsgStatusReport(msg) => msg.write_frame(buf), - SBP::MsgHeartbeat(msg) => msg.write_frame(buf), - SBP::Unknown(msg) => msg.write_frame(buf), + Sbp::MsgPrintDep(msg) => msg.set_sender_id(new_id), + Sbp::MsgTrackingStateDetailedDep(msg) => msg.set_sender_id(new_id), + Sbp::MsgTrackingStateDepB(msg) => msg.set_sender_id(new_id), + Sbp::MsgAcqResultDepB(msg) => msg.set_sender_id(new_id), + Sbp::MsgAcqResultDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgTrackingStateDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgThreadState(msg) => msg.set_sender_id(new_id), + Sbp::MsgUartStateDepa(msg) => msg.set_sender_id(new_id), + Sbp::MsgIarState(msg) => msg.set_sender_id(new_id), + Sbp::MsgEphemerisDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgMaskSatelliteDep(msg) => msg.set_sender_id(new_id), + Sbp::MsgTrackingIqDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgUartState(msg) => msg.set_sender_id(new_id), + Sbp::MsgAcqSvProfileDep(msg) => msg.set_sender_id(new_id), + Sbp::MsgAcqResultDepC(msg) => msg.set_sender_id(new_id), + Sbp::MsgTrackingStateDetailedDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgResetFilters(msg) => msg.set_sender_id(new_id), + Sbp::MsgInitBaseDep(msg) => msg.set_sender_id(new_id), + Sbp::MsgMaskSatellite(msg) => msg.set_sender_id(new_id), + Sbp::MsgTrackingIqDepB(msg) => msg.set_sender_id(new_id), + Sbp::MsgTrackingIq(msg) => msg.set_sender_id(new_id), + Sbp::MsgAcqSvProfile(msg) => msg.set_sender_id(new_id), + Sbp::MsgAcqResult(msg) => msg.set_sender_id(new_id), + Sbp::MsgTrackingState(msg) => msg.set_sender_id(new_id), + Sbp::MsgObsDepB(msg) => msg.set_sender_id(new_id), + Sbp::MsgBasePosLlh(msg) => msg.set_sender_id(new_id), + Sbp::MsgObsDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgEphemerisDepB(msg) => msg.set_sender_id(new_id), + Sbp::MsgEphemerisDepC(msg) => msg.set_sender_id(new_id), + Sbp::MsgBasePosEcef(msg) => msg.set_sender_id(new_id), + Sbp::MsgObsDepC(msg) => msg.set_sender_id(new_id), + Sbp::MsgObs(msg) => msg.set_sender_id(new_id), + Sbp::MsgSpecanDep(msg) => msg.set_sender_id(new_id), + Sbp::MsgSpecan(msg) => msg.set_sender_id(new_id), + Sbp::MsgMeasurementState(msg) => msg.set_sender_id(new_id), + Sbp::MsgSetTime(msg) => msg.set_sender_id(new_id), + Sbp::MsgAlmanac(msg) => msg.set_sender_id(new_id), + Sbp::MsgAlmanacGpsDep(msg) => msg.set_sender_id(new_id), + Sbp::MsgAlmanacGloDep(msg) => msg.set_sender_id(new_id), + Sbp::MsgAlmanacGps(msg) => msg.set_sender_id(new_id), + Sbp::MsgAlmanacGlo(msg) => msg.set_sender_id(new_id), + Sbp::MsgGloBiases(msg) => msg.set_sender_id(new_id), + Sbp::MsgEphemerisDepD(msg) => msg.set_sender_id(new_id), + Sbp::MsgEphemerisGpsDepE(msg) => msg.set_sender_id(new_id), + Sbp::MsgEphemerisSbasDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgEphemerisGloDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgEphemerisSbasDepB(msg) => msg.set_sender_id(new_id), + Sbp::MsgEphemerisGloDepB(msg) => msg.set_sender_id(new_id), + Sbp::MsgEphemerisGpsDepF(msg) => msg.set_sender_id(new_id), + Sbp::MsgEphemerisGloDepC(msg) => msg.set_sender_id(new_id), + Sbp::MsgEphemerisGloDepD(msg) => msg.set_sender_id(new_id), + Sbp::MsgEphemerisBds(msg) => msg.set_sender_id(new_id), + Sbp::MsgEphemerisGps(msg) => msg.set_sender_id(new_id), + Sbp::MsgEphemerisGlo(msg) => msg.set_sender_id(new_id), + Sbp::MsgEphemerisSbas(msg) => msg.set_sender_id(new_id), + Sbp::MsgEphemerisGal(msg) => msg.set_sender_id(new_id), + Sbp::MsgEphemerisQzss(msg) => msg.set_sender_id(new_id), + Sbp::MsgIono(msg) => msg.set_sender_id(new_id), + Sbp::MsgSvConfigurationGpsDep(msg) => msg.set_sender_id(new_id), + Sbp::MsgGroupDelayDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgGroupDelayDepB(msg) => msg.set_sender_id(new_id), + Sbp::MsgGroupDelay(msg) => msg.set_sender_id(new_id), + Sbp::MsgEphemerisGalDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgGnssCapb(msg) => msg.set_sender_id(new_id), + Sbp::MsgSvAzEl(msg) => msg.set_sender_id(new_id), + Sbp::MsgSettingsWrite(msg) => msg.set_sender_id(new_id), + Sbp::MsgSettingsSave(msg) => msg.set_sender_id(new_id), + Sbp::MsgSettingsReadByIndexReq(msg) => msg.set_sender_id(new_id), + Sbp::MsgFileioReadResp(msg) => msg.set_sender_id(new_id), + Sbp::MsgSettingsReadReq(msg) => msg.set_sender_id(new_id), + Sbp::MsgSettingsReadResp(msg) => msg.set_sender_id(new_id), + Sbp::MsgSettingsReadByIndexDone(msg) => msg.set_sender_id(new_id), + Sbp::MsgSettingsReadByIndexResp(msg) => msg.set_sender_id(new_id), + Sbp::MsgFileioReadReq(msg) => msg.set_sender_id(new_id), + Sbp::MsgFileioReadDirReq(msg) => msg.set_sender_id(new_id), + Sbp::MsgFileioReadDirResp(msg) => msg.set_sender_id(new_id), + Sbp::MsgFileioWriteResp(msg) => msg.set_sender_id(new_id), + Sbp::MsgFileioRemove(msg) => msg.set_sender_id(new_id), + Sbp::MsgFileioWriteReq(msg) => msg.set_sender_id(new_id), + Sbp::MsgSettingsRegister(msg) => msg.set_sender_id(new_id), + Sbp::MsgSettingsWriteResp(msg) => msg.set_sender_id(new_id), + Sbp::MsgBootloaderHandshakeDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgBootloaderJumpToApp(msg) => msg.set_sender_id(new_id), + Sbp::MsgResetDep(msg) => msg.set_sender_id(new_id), + Sbp::MsgBootloaderHandshakeReq(msg) => msg.set_sender_id(new_id), + Sbp::MsgBootloaderHandshakeResp(msg) => msg.set_sender_id(new_id), + Sbp::MsgDeviceMonitor(msg) => msg.set_sender_id(new_id), + Sbp::MsgReset(msg) => msg.set_sender_id(new_id), + Sbp::MsgCommandReq(msg) => msg.set_sender_id(new_id), + Sbp::MsgCommandResp(msg) => msg.set_sender_id(new_id), + Sbp::MsgNetworkStateReq(msg) => msg.set_sender_id(new_id), + Sbp::MsgNetworkStateResp(msg) => msg.set_sender_id(new_id), + Sbp::MsgCommandOutput(msg) => msg.set_sender_id(new_id), + Sbp::MsgNetworkBandwidthUsage(msg) => msg.set_sender_id(new_id), + Sbp::MsgCellModemStatus(msg) => msg.set_sender_id(new_id), + Sbp::MsgFrontEndGain(msg) => msg.set_sender_id(new_id), + Sbp::MsgCwResults(msg) => msg.set_sender_id(new_id), + Sbp::MsgCwStart(msg) => msg.set_sender_id(new_id), + Sbp::MsgNapDeviceDnaResp(msg) => msg.set_sender_id(new_id), + Sbp::MsgNapDeviceDnaReq(msg) => msg.set_sender_id(new_id), + Sbp::MsgFlashDone(msg) => msg.set_sender_id(new_id), + Sbp::MsgFlashReadResp(msg) => msg.set_sender_id(new_id), + Sbp::MsgFlashErase(msg) => msg.set_sender_id(new_id), + Sbp::MsgStmFlashLockSector(msg) => msg.set_sender_id(new_id), + Sbp::MsgStmFlashUnlockSector(msg) => msg.set_sender_id(new_id), + Sbp::MsgStmUniqueIdResp(msg) => msg.set_sender_id(new_id), + Sbp::MsgFlashProgram(msg) => msg.set_sender_id(new_id), + Sbp::MsgFlashReadReq(msg) => msg.set_sender_id(new_id), + Sbp::MsgStmUniqueIdReq(msg) => msg.set_sender_id(new_id), + Sbp::MsgM25FlashWriteStatus(msg) => msg.set_sender_id(new_id), + Sbp::MsgGpsTimeDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgExtEvent(msg) => msg.set_sender_id(new_id), + Sbp::MsgGpsTime(msg) => msg.set_sender_id(new_id), + Sbp::MsgUtcTime(msg) => msg.set_sender_id(new_id), + Sbp::MsgGpsTimeGnss(msg) => msg.set_sender_id(new_id), + Sbp::MsgUtcTimeGnss(msg) => msg.set_sender_id(new_id), + Sbp::MsgSettingsRegisterResp(msg) => msg.set_sender_id(new_id), + Sbp::MsgPosEcefDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgPosLlhDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgBaselineEcefDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgBaselineNedDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgVelEcefDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgVelNedDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgDopsDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgBaselineHeadingDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgDops(msg) => msg.set_sender_id(new_id), + Sbp::MsgPosEcef(msg) => msg.set_sender_id(new_id), + Sbp::MsgPosLlh(msg) => msg.set_sender_id(new_id), + Sbp::MsgBaselineEcef(msg) => msg.set_sender_id(new_id), + Sbp::MsgBaselineNed(msg) => msg.set_sender_id(new_id), + Sbp::MsgVelEcef(msg) => msg.set_sender_id(new_id), + Sbp::MsgVelNed(msg) => msg.set_sender_id(new_id), + Sbp::MsgBaselineHeading(msg) => msg.set_sender_id(new_id), + Sbp::MsgAgeCorrections(msg) => msg.set_sender_id(new_id), + Sbp::MsgPosLlhCov(msg) => msg.set_sender_id(new_id), + Sbp::MsgVelNedCov(msg) => msg.set_sender_id(new_id), + Sbp::MsgVelBody(msg) => msg.set_sender_id(new_id), + Sbp::MsgPosEcefCov(msg) => msg.set_sender_id(new_id), + Sbp::MsgVelEcefCov(msg) => msg.set_sender_id(new_id), + Sbp::MsgProtectionLevelDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgProtectionLevel(msg) => msg.set_sender_id(new_id), + Sbp::MsgPosLlhAcc(msg) => msg.set_sender_id(new_id), + Sbp::MsgOrientQuat(msg) => msg.set_sender_id(new_id), + Sbp::MsgOrientEuler(msg) => msg.set_sender_id(new_id), + Sbp::MsgAngularRate(msg) => msg.set_sender_id(new_id), + Sbp::MsgPosEcefGnss(msg) => msg.set_sender_id(new_id), + Sbp::MsgPosLlhGnss(msg) => msg.set_sender_id(new_id), + Sbp::MsgVelEcefGnss(msg) => msg.set_sender_id(new_id), + Sbp::MsgVelNedGnss(msg) => msg.set_sender_id(new_id), + Sbp::MsgPosLlhCovGnss(msg) => msg.set_sender_id(new_id), + Sbp::MsgVelNedCovGnss(msg) => msg.set_sender_id(new_id), + Sbp::MsgPosEcefCovGnss(msg) => msg.set_sender_id(new_id), + Sbp::MsgVelEcefCovGnss(msg) => msg.set_sender_id(new_id), + Sbp::MsgNdbEvent(msg) => msg.set_sender_id(new_id), + Sbp::MsgLog(msg) => msg.set_sender_id(new_id), + Sbp::MsgFwd(msg) => msg.set_sender_id(new_id), + Sbp::MsgSsrOrbitClockDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgSsrOrbitClock(msg) => msg.set_sender_id(new_id), + Sbp::MsgSsrCodeBiases(msg) => msg.set_sender_id(new_id), + Sbp::MsgSsrPhaseBiases(msg) => msg.set_sender_id(new_id), + Sbp::MsgSsrStecCorrectionDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgSsrGriddedCorrectionNoStdDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgSsrGridDefinitionDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgSsrTileDefinition(msg) => msg.set_sender_id(new_id), + Sbp::MsgSsrGriddedCorrectionDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgSsrStecCorrection(msg) => msg.set_sender_id(new_id), + Sbp::MsgSsrGriddedCorrection(msg) => msg.set_sender_id(new_id), + Sbp::MsgSsrSatelliteApc(msg) => msg.set_sender_id(new_id), + Sbp::MsgOsr(msg) => msg.set_sender_id(new_id), + Sbp::MsgUserData(msg) => msg.set_sender_id(new_id), + Sbp::MsgImuRaw(msg) => msg.set_sender_id(new_id), + Sbp::MsgImuAux(msg) => msg.set_sender_id(new_id), + Sbp::MsgMagRaw(msg) => msg.set_sender_id(new_id), + Sbp::MsgOdometry(msg) => msg.set_sender_id(new_id), + Sbp::MsgWheeltick(msg) => msg.set_sender_id(new_id), + Sbp::MsgFileioConfigReq(msg) => msg.set_sender_id(new_id), + Sbp::MsgFileioConfigResp(msg) => msg.set_sender_id(new_id), + Sbp::MsgSbasRaw(msg) => msg.set_sender_id(new_id), + Sbp::MsgLinuxCpuStateDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgLinuxMemStateDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgLinuxSysStateDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgLinuxProcessSocketCounts(msg) => msg.set_sender_id(new_id), + Sbp::MsgLinuxProcessSocketQueues(msg) => msg.set_sender_id(new_id), + Sbp::MsgLinuxSocketUsage(msg) => msg.set_sender_id(new_id), + Sbp::MsgLinuxProcessFdCount(msg) => msg.set_sender_id(new_id), + Sbp::MsgLinuxProcessFdSummary(msg) => msg.set_sender_id(new_id), + Sbp::MsgLinuxCpuState(msg) => msg.set_sender_id(new_id), + Sbp::MsgLinuxMemState(msg) => msg.set_sender_id(new_id), + Sbp::MsgLinuxSysState(msg) => msg.set_sender_id(new_id), + Sbp::MsgStartup(msg) => msg.set_sender_id(new_id), + Sbp::MsgDgnssStatus(msg) => msg.set_sender_id(new_id), + Sbp::MsgInsStatus(msg) => msg.set_sender_id(new_id), + Sbp::MsgCsacTelemetry(msg) => msg.set_sender_id(new_id), + Sbp::MsgCsacTelemetryLabels(msg) => msg.set_sender_id(new_id), + Sbp::MsgInsUpdates(msg) => msg.set_sender_id(new_id), + Sbp::MsgGnssTimeOffset(msg) => msg.set_sender_id(new_id), + Sbp::MsgPpsTime(msg) => msg.set_sender_id(new_id), + Sbp::MsgGroupMeta(msg) => msg.set_sender_id(new_id), + Sbp::MsgSolnMeta(msg) => msg.set_sender_id(new_id), + Sbp::MsgSolnMetaDepA(msg) => msg.set_sender_id(new_id), + Sbp::MsgStatusReport(msg) => msg.set_sender_id(new_id), + Sbp::MsgHeartbeat(msg) => msg.set_sender_id(new_id), + Sbp::Unknown(msg) => msg.set_sender_id(new_id), } } @@ -2754,1643 +2565,1851 @@ impl crate::SBPMessage for SBP { &self, ) -> Option> { match self { - SBP::MsgPrintDep(msg) => msg.gps_time(), - SBP::MsgTrackingStateDetailedDep(msg) => msg.gps_time(), - SBP::MsgTrackingStateDepB(msg) => msg.gps_time(), - SBP::MsgAcqResultDepB(msg) => msg.gps_time(), - SBP::MsgAcqResultDepA(msg) => msg.gps_time(), - SBP::MsgTrackingStateDepA(msg) => msg.gps_time(), - SBP::MsgThreadState(msg) => msg.gps_time(), - SBP::MsgUartStateDepa(msg) => msg.gps_time(), - SBP::MsgIarState(msg) => msg.gps_time(), - SBP::MsgEphemerisDepA(msg) => msg.gps_time(), - SBP::MsgMaskSatelliteDep(msg) => msg.gps_time(), - SBP::MsgTrackingIqDepA(msg) => msg.gps_time(), - SBP::MsgUartState(msg) => msg.gps_time(), - SBP::MsgAcqSvProfileDep(msg) => msg.gps_time(), - SBP::MsgAcqResultDepC(msg) => msg.gps_time(), - SBP::MsgTrackingStateDetailedDepA(msg) => msg.gps_time(), - SBP::MsgResetFilters(msg) => msg.gps_time(), - SBP::MsgInitBaseDep(msg) => msg.gps_time(), - SBP::MsgMaskSatellite(msg) => msg.gps_time(), - SBP::MsgTrackingIqDepB(msg) => msg.gps_time(), - SBP::MsgTrackingIq(msg) => msg.gps_time(), - SBP::MsgAcqSvProfile(msg) => msg.gps_time(), - SBP::MsgAcqResult(msg) => msg.gps_time(), - SBP::MsgTrackingState(msg) => msg.gps_time(), - SBP::MsgObsDepB(msg) => msg.gps_time(), - SBP::MsgBasePosLLH(msg) => msg.gps_time(), - SBP::MsgObsDepA(msg) => msg.gps_time(), - SBP::MsgEphemerisDepB(msg) => msg.gps_time(), - SBP::MsgEphemerisDepC(msg) => msg.gps_time(), - SBP::MsgBasePosECEF(msg) => msg.gps_time(), - SBP::MsgObsDepC(msg) => msg.gps_time(), - SBP::MsgObs(msg) => msg.gps_time(), - SBP::MsgSpecanDep(msg) => msg.gps_time(), - SBP::MsgSpecan(msg) => msg.gps_time(), - SBP::MsgMeasurementState(msg) => msg.gps_time(), - SBP::MsgSetTime(msg) => msg.gps_time(), - SBP::MsgAlmanac(msg) => msg.gps_time(), - SBP::MsgAlmanacGPSDep(msg) => msg.gps_time(), - SBP::MsgAlmanacGloDep(msg) => msg.gps_time(), - SBP::MsgAlmanacGPS(msg) => msg.gps_time(), - SBP::MsgAlmanacGlo(msg) => msg.gps_time(), - SBP::MsgGloBiases(msg) => msg.gps_time(), - SBP::MsgEphemerisDepD(msg) => msg.gps_time(), - SBP::MsgEphemerisGPSDepE(msg) => msg.gps_time(), - SBP::MsgEphemerisSbasDepA(msg) => msg.gps_time(), - SBP::MsgEphemerisGloDepA(msg) => msg.gps_time(), - SBP::MsgEphemerisSbasDepB(msg) => msg.gps_time(), - SBP::MsgEphemerisGloDepB(msg) => msg.gps_time(), - SBP::MsgEphemerisGPSDepF(msg) => msg.gps_time(), - SBP::MsgEphemerisGloDepC(msg) => msg.gps_time(), - SBP::MsgEphemerisGloDepD(msg) => msg.gps_time(), - SBP::MsgEphemerisBds(msg) => msg.gps_time(), - SBP::MsgEphemerisGPS(msg) => msg.gps_time(), - SBP::MsgEphemerisGlo(msg) => msg.gps_time(), - SBP::MsgEphemerisSbas(msg) => msg.gps_time(), - SBP::MsgEphemerisGal(msg) => msg.gps_time(), - SBP::MsgEphemerisQzss(msg) => msg.gps_time(), - SBP::MsgIono(msg) => msg.gps_time(), - SBP::MsgSvConfigurationGPSDep(msg) => msg.gps_time(), - SBP::MsgGroupDelayDepA(msg) => msg.gps_time(), - SBP::MsgGroupDelayDepB(msg) => msg.gps_time(), - SBP::MsgGroupDelay(msg) => msg.gps_time(), - SBP::MsgEphemerisGalDepA(msg) => msg.gps_time(), - SBP::MsgGnssCapb(msg) => msg.gps_time(), - SBP::MsgSvAzEl(msg) => msg.gps_time(), - SBP::MsgSettingsWrite(msg) => msg.gps_time(), - SBP::MsgSettingsSave(msg) => msg.gps_time(), - SBP::MsgSettingsReadByIndexReq(msg) => msg.gps_time(), - SBP::MsgFileioReadResp(msg) => msg.gps_time(), - SBP::MsgSettingsReadReq(msg) => msg.gps_time(), - SBP::MsgSettingsReadResp(msg) => msg.gps_time(), - SBP::MsgSettingsReadByIndexDone(msg) => msg.gps_time(), - SBP::MsgSettingsReadByIndexResp(msg) => msg.gps_time(), - SBP::MsgFileioReadReq(msg) => msg.gps_time(), - SBP::MsgFileioReadDirReq(msg) => msg.gps_time(), - SBP::MsgFileioReadDirResp(msg) => msg.gps_time(), - SBP::MsgFileioWriteResp(msg) => msg.gps_time(), - SBP::MsgFileioRemove(msg) => msg.gps_time(), - SBP::MsgFileioWriteReq(msg) => msg.gps_time(), - SBP::MsgSettingsRegister(msg) => msg.gps_time(), - SBP::MsgSettingsWriteResp(msg) => msg.gps_time(), - SBP::MsgBootloaderHandshakeDepA(msg) => msg.gps_time(), - SBP::MsgBootloaderJumpToApp(msg) => msg.gps_time(), - SBP::MsgResetDep(msg) => msg.gps_time(), - SBP::MsgBootloaderHandshakeReq(msg) => msg.gps_time(), - SBP::MsgBootloaderHandshakeResp(msg) => msg.gps_time(), - SBP::MsgDeviceMonitor(msg) => msg.gps_time(), - SBP::MsgReset(msg) => msg.gps_time(), - SBP::MsgCommandReq(msg) => msg.gps_time(), - SBP::MsgCommandResp(msg) => msg.gps_time(), - SBP::MsgNetworkStateReq(msg) => msg.gps_time(), - SBP::MsgNetworkStateResp(msg) => msg.gps_time(), - SBP::MsgCommandOutput(msg) => msg.gps_time(), - SBP::MsgNetworkBandwidthUsage(msg) => msg.gps_time(), - SBP::MsgCellModemStatus(msg) => msg.gps_time(), - SBP::MsgFrontEndGain(msg) => msg.gps_time(), - SBP::MsgCwResults(msg) => msg.gps_time(), - SBP::MsgCwStart(msg) => msg.gps_time(), - SBP::MsgNapDeviceDnaResp(msg) => msg.gps_time(), - SBP::MsgNapDeviceDnaReq(msg) => msg.gps_time(), - SBP::MsgFlashDone(msg) => msg.gps_time(), - SBP::MsgFlashReadResp(msg) => msg.gps_time(), - SBP::MsgFlashErase(msg) => msg.gps_time(), - SBP::MsgStmFlashLockSector(msg) => msg.gps_time(), - SBP::MsgStmFlashUnlockSector(msg) => msg.gps_time(), - SBP::MsgStmUniqueIdResp(msg) => msg.gps_time(), - SBP::MsgFlashProgram(msg) => msg.gps_time(), - SBP::MsgFlashReadReq(msg) => msg.gps_time(), - SBP::MsgStmUniqueIdReq(msg) => msg.gps_time(), - SBP::MsgM25FlashWriteStatus(msg) => msg.gps_time(), - SBP::MsgGPSTimeDepA(msg) => msg.gps_time(), - SBP::MsgExtEvent(msg) => msg.gps_time(), - SBP::MsgGPSTime(msg) => msg.gps_time(), - SBP::MsgUtcTime(msg) => msg.gps_time(), - SBP::MsgGPSTimeGnss(msg) => msg.gps_time(), - SBP::MsgUtcTimeGnss(msg) => msg.gps_time(), - SBP::MsgSettingsRegisterResp(msg) => msg.gps_time(), - SBP::MsgPosECEFDepA(msg) => msg.gps_time(), - SBP::MsgPosLLHDepA(msg) => msg.gps_time(), - SBP::MsgBaselineECEFDepA(msg) => msg.gps_time(), - SBP::MsgBaselineNEDDepA(msg) => msg.gps_time(), - SBP::MsgVelECEFDepA(msg) => msg.gps_time(), - SBP::MsgVelNEDDepA(msg) => msg.gps_time(), - SBP::MsgDopsDepA(msg) => msg.gps_time(), - SBP::MsgBaselineHeadingDepA(msg) => msg.gps_time(), - SBP::MsgDops(msg) => msg.gps_time(), - SBP::MsgPosECEF(msg) => msg.gps_time(), - SBP::MsgPosLLH(msg) => msg.gps_time(), - SBP::MsgBaselineECEF(msg) => msg.gps_time(), - SBP::MsgBaselineNED(msg) => msg.gps_time(), - SBP::MsgVelECEF(msg) => msg.gps_time(), - SBP::MsgVelNED(msg) => msg.gps_time(), - SBP::MsgBaselineHeading(msg) => msg.gps_time(), - SBP::MsgAgeCorrections(msg) => msg.gps_time(), - SBP::MsgPosLLHCov(msg) => msg.gps_time(), - SBP::MsgVelNEDCov(msg) => msg.gps_time(), - SBP::MsgVelBody(msg) => msg.gps_time(), - SBP::MsgPosECEFCov(msg) => msg.gps_time(), - SBP::MsgVelECEFCov(msg) => msg.gps_time(), - SBP::MsgProtectionLevelDepA(msg) => msg.gps_time(), - SBP::MsgProtectionLevel(msg) => msg.gps_time(), - SBP::MsgPosLLHAcc(msg) => msg.gps_time(), - SBP::MsgOrientQuat(msg) => msg.gps_time(), - SBP::MsgOrientEuler(msg) => msg.gps_time(), - SBP::MsgAngularRate(msg) => msg.gps_time(), - SBP::MsgPosECEFGnss(msg) => msg.gps_time(), - SBP::MsgPosLLHGnss(msg) => msg.gps_time(), - SBP::MsgVelECEFGnss(msg) => msg.gps_time(), - SBP::MsgVelNEDGnss(msg) => msg.gps_time(), - SBP::MsgPosLLHCovGnss(msg) => msg.gps_time(), - SBP::MsgVelNEDCovGnss(msg) => msg.gps_time(), - SBP::MsgPosECEFCovGnss(msg) => msg.gps_time(), - SBP::MsgVelECEFCovGnss(msg) => msg.gps_time(), - SBP::MsgNdbEvent(msg) => msg.gps_time(), - SBP::MsgLog(msg) => msg.gps_time(), - SBP::MsgFwd(msg) => msg.gps_time(), - SBP::MsgSsrOrbitClockDepA(msg) => msg.gps_time(), - SBP::MsgSsrOrbitClock(msg) => msg.gps_time(), - SBP::MsgSsrCodeBiases(msg) => msg.gps_time(), - SBP::MsgSsrPhaseBiases(msg) => msg.gps_time(), - SBP::MsgSsrStecCorrectionDepA(msg) => msg.gps_time(), - SBP::MsgSsrGriddedCorrectionNoStdDepA(msg) => msg.gps_time(), - SBP::MsgSsrGridDefinitionDepA(msg) => msg.gps_time(), - SBP::MsgSsrTileDefinition(msg) => msg.gps_time(), - SBP::MsgSsrGriddedCorrectionDepA(msg) => msg.gps_time(), - SBP::MsgSsrStecCorrection(msg) => msg.gps_time(), - SBP::MsgSsrGriddedCorrection(msg) => msg.gps_time(), - SBP::MsgSsrSatelliteApc(msg) => msg.gps_time(), - SBP::MsgOsr(msg) => msg.gps_time(), - SBP::MsgUserData(msg) => msg.gps_time(), - SBP::MsgImuRaw(msg) => msg.gps_time(), - SBP::MsgImuAux(msg) => msg.gps_time(), - SBP::MsgMagRaw(msg) => msg.gps_time(), - SBP::MsgOdometry(msg) => msg.gps_time(), - SBP::MsgWheeltick(msg) => msg.gps_time(), - SBP::MsgFileioConfigReq(msg) => msg.gps_time(), - SBP::MsgFileioConfigResp(msg) => msg.gps_time(), - SBP::MsgSbasRaw(msg) => msg.gps_time(), - SBP::MsgLinuxCpuStateDepA(msg) => msg.gps_time(), - SBP::MsgLinuxMemStateDepA(msg) => msg.gps_time(), - SBP::MsgLinuxSysStateDepA(msg) => msg.gps_time(), - SBP::MsgLinuxProcessSocketCounts(msg) => msg.gps_time(), - SBP::MsgLinuxProcessSocketQueues(msg) => msg.gps_time(), - SBP::MsgLinuxSocketUsage(msg) => msg.gps_time(), - SBP::MsgLinuxProcessFdCount(msg) => msg.gps_time(), - SBP::MsgLinuxProcessFdSummary(msg) => msg.gps_time(), - SBP::MsgLinuxCpuState(msg) => msg.gps_time(), - SBP::MsgLinuxMemState(msg) => msg.gps_time(), - SBP::MsgLinuxSysState(msg) => msg.gps_time(), - SBP::MsgStartup(msg) => msg.gps_time(), - SBP::MsgDgnssStatus(msg) => msg.gps_time(), - SBP::MsgInsStatus(msg) => msg.gps_time(), - SBP::MsgCsacTelemetry(msg) => msg.gps_time(), - SBP::MsgCsacTelemetryLabels(msg) => msg.gps_time(), - SBP::MsgInsUpdates(msg) => msg.gps_time(), - SBP::MsgGnssTimeOffset(msg) => msg.gps_time(), - SBP::MsgPpsTime(msg) => msg.gps_time(), - SBP::MsgGroupMeta(msg) => msg.gps_time(), - SBP::MsgSolnMeta(msg) => msg.gps_time(), - SBP::MsgSolnMetaDepA(msg) => msg.gps_time(), - SBP::MsgStatusReport(msg) => msg.gps_time(), - SBP::MsgHeartbeat(msg) => msg.gps_time(), - SBP::Unknown(msg) => msg.gps_time(), + Sbp::MsgPrintDep(msg) => msg.gps_time(), + Sbp::MsgTrackingStateDetailedDep(msg) => msg.gps_time(), + Sbp::MsgTrackingStateDepB(msg) => msg.gps_time(), + Sbp::MsgAcqResultDepB(msg) => msg.gps_time(), + Sbp::MsgAcqResultDepA(msg) => msg.gps_time(), + Sbp::MsgTrackingStateDepA(msg) => msg.gps_time(), + Sbp::MsgThreadState(msg) => msg.gps_time(), + Sbp::MsgUartStateDepa(msg) => msg.gps_time(), + Sbp::MsgIarState(msg) => msg.gps_time(), + Sbp::MsgEphemerisDepA(msg) => msg.gps_time(), + Sbp::MsgMaskSatelliteDep(msg) => msg.gps_time(), + Sbp::MsgTrackingIqDepA(msg) => msg.gps_time(), + Sbp::MsgUartState(msg) => msg.gps_time(), + Sbp::MsgAcqSvProfileDep(msg) => msg.gps_time(), + Sbp::MsgAcqResultDepC(msg) => msg.gps_time(), + Sbp::MsgTrackingStateDetailedDepA(msg) => msg.gps_time(), + Sbp::MsgResetFilters(msg) => msg.gps_time(), + Sbp::MsgInitBaseDep(msg) => msg.gps_time(), + Sbp::MsgMaskSatellite(msg) => msg.gps_time(), + Sbp::MsgTrackingIqDepB(msg) => msg.gps_time(), + Sbp::MsgTrackingIq(msg) => msg.gps_time(), + Sbp::MsgAcqSvProfile(msg) => msg.gps_time(), + Sbp::MsgAcqResult(msg) => msg.gps_time(), + Sbp::MsgTrackingState(msg) => msg.gps_time(), + Sbp::MsgObsDepB(msg) => msg.gps_time(), + Sbp::MsgBasePosLlh(msg) => msg.gps_time(), + Sbp::MsgObsDepA(msg) => msg.gps_time(), + Sbp::MsgEphemerisDepB(msg) => msg.gps_time(), + Sbp::MsgEphemerisDepC(msg) => msg.gps_time(), + Sbp::MsgBasePosEcef(msg) => msg.gps_time(), + Sbp::MsgObsDepC(msg) => msg.gps_time(), + Sbp::MsgObs(msg) => msg.gps_time(), + Sbp::MsgSpecanDep(msg) => msg.gps_time(), + Sbp::MsgSpecan(msg) => msg.gps_time(), + Sbp::MsgMeasurementState(msg) => msg.gps_time(), + Sbp::MsgSetTime(msg) => msg.gps_time(), + Sbp::MsgAlmanac(msg) => msg.gps_time(), + Sbp::MsgAlmanacGpsDep(msg) => msg.gps_time(), + Sbp::MsgAlmanacGloDep(msg) => msg.gps_time(), + Sbp::MsgAlmanacGps(msg) => msg.gps_time(), + Sbp::MsgAlmanacGlo(msg) => msg.gps_time(), + Sbp::MsgGloBiases(msg) => msg.gps_time(), + Sbp::MsgEphemerisDepD(msg) => msg.gps_time(), + Sbp::MsgEphemerisGpsDepE(msg) => msg.gps_time(), + Sbp::MsgEphemerisSbasDepA(msg) => msg.gps_time(), + Sbp::MsgEphemerisGloDepA(msg) => msg.gps_time(), + Sbp::MsgEphemerisSbasDepB(msg) => msg.gps_time(), + Sbp::MsgEphemerisGloDepB(msg) => msg.gps_time(), + Sbp::MsgEphemerisGpsDepF(msg) => msg.gps_time(), + Sbp::MsgEphemerisGloDepC(msg) => msg.gps_time(), + Sbp::MsgEphemerisGloDepD(msg) => msg.gps_time(), + Sbp::MsgEphemerisBds(msg) => msg.gps_time(), + Sbp::MsgEphemerisGps(msg) => msg.gps_time(), + Sbp::MsgEphemerisGlo(msg) => msg.gps_time(), + Sbp::MsgEphemerisSbas(msg) => msg.gps_time(), + Sbp::MsgEphemerisGal(msg) => msg.gps_time(), + Sbp::MsgEphemerisQzss(msg) => msg.gps_time(), + Sbp::MsgIono(msg) => msg.gps_time(), + Sbp::MsgSvConfigurationGpsDep(msg) => msg.gps_time(), + Sbp::MsgGroupDelayDepA(msg) => msg.gps_time(), + Sbp::MsgGroupDelayDepB(msg) => msg.gps_time(), + Sbp::MsgGroupDelay(msg) => msg.gps_time(), + Sbp::MsgEphemerisGalDepA(msg) => msg.gps_time(), + Sbp::MsgGnssCapb(msg) => msg.gps_time(), + Sbp::MsgSvAzEl(msg) => msg.gps_time(), + Sbp::MsgSettingsWrite(msg) => msg.gps_time(), + Sbp::MsgSettingsSave(msg) => msg.gps_time(), + Sbp::MsgSettingsReadByIndexReq(msg) => msg.gps_time(), + Sbp::MsgFileioReadResp(msg) => msg.gps_time(), + Sbp::MsgSettingsReadReq(msg) => msg.gps_time(), + Sbp::MsgSettingsReadResp(msg) => msg.gps_time(), + Sbp::MsgSettingsReadByIndexDone(msg) => msg.gps_time(), + Sbp::MsgSettingsReadByIndexResp(msg) => msg.gps_time(), + Sbp::MsgFileioReadReq(msg) => msg.gps_time(), + Sbp::MsgFileioReadDirReq(msg) => msg.gps_time(), + Sbp::MsgFileioReadDirResp(msg) => msg.gps_time(), + Sbp::MsgFileioWriteResp(msg) => msg.gps_time(), + Sbp::MsgFileioRemove(msg) => msg.gps_time(), + Sbp::MsgFileioWriteReq(msg) => msg.gps_time(), + Sbp::MsgSettingsRegister(msg) => msg.gps_time(), + Sbp::MsgSettingsWriteResp(msg) => msg.gps_time(), + Sbp::MsgBootloaderHandshakeDepA(msg) => msg.gps_time(), + Sbp::MsgBootloaderJumpToApp(msg) => msg.gps_time(), + Sbp::MsgResetDep(msg) => msg.gps_time(), + Sbp::MsgBootloaderHandshakeReq(msg) => msg.gps_time(), + Sbp::MsgBootloaderHandshakeResp(msg) => msg.gps_time(), + Sbp::MsgDeviceMonitor(msg) => msg.gps_time(), + Sbp::MsgReset(msg) => msg.gps_time(), + Sbp::MsgCommandReq(msg) => msg.gps_time(), + Sbp::MsgCommandResp(msg) => msg.gps_time(), + Sbp::MsgNetworkStateReq(msg) => msg.gps_time(), + Sbp::MsgNetworkStateResp(msg) => msg.gps_time(), + Sbp::MsgCommandOutput(msg) => msg.gps_time(), + Sbp::MsgNetworkBandwidthUsage(msg) => msg.gps_time(), + Sbp::MsgCellModemStatus(msg) => msg.gps_time(), + Sbp::MsgFrontEndGain(msg) => msg.gps_time(), + Sbp::MsgCwResults(msg) => msg.gps_time(), + Sbp::MsgCwStart(msg) => msg.gps_time(), + Sbp::MsgNapDeviceDnaResp(msg) => msg.gps_time(), + Sbp::MsgNapDeviceDnaReq(msg) => msg.gps_time(), + Sbp::MsgFlashDone(msg) => msg.gps_time(), + Sbp::MsgFlashReadResp(msg) => msg.gps_time(), + Sbp::MsgFlashErase(msg) => msg.gps_time(), + Sbp::MsgStmFlashLockSector(msg) => msg.gps_time(), + Sbp::MsgStmFlashUnlockSector(msg) => msg.gps_time(), + Sbp::MsgStmUniqueIdResp(msg) => msg.gps_time(), + Sbp::MsgFlashProgram(msg) => msg.gps_time(), + Sbp::MsgFlashReadReq(msg) => msg.gps_time(), + Sbp::MsgStmUniqueIdReq(msg) => msg.gps_time(), + Sbp::MsgM25FlashWriteStatus(msg) => msg.gps_time(), + Sbp::MsgGpsTimeDepA(msg) => msg.gps_time(), + Sbp::MsgExtEvent(msg) => msg.gps_time(), + Sbp::MsgGpsTime(msg) => msg.gps_time(), + Sbp::MsgUtcTime(msg) => msg.gps_time(), + Sbp::MsgGpsTimeGnss(msg) => msg.gps_time(), + Sbp::MsgUtcTimeGnss(msg) => msg.gps_time(), + Sbp::MsgSettingsRegisterResp(msg) => msg.gps_time(), + Sbp::MsgPosEcefDepA(msg) => msg.gps_time(), + Sbp::MsgPosLlhDepA(msg) => msg.gps_time(), + Sbp::MsgBaselineEcefDepA(msg) => msg.gps_time(), + Sbp::MsgBaselineNedDepA(msg) => msg.gps_time(), + Sbp::MsgVelEcefDepA(msg) => msg.gps_time(), + Sbp::MsgVelNedDepA(msg) => msg.gps_time(), + Sbp::MsgDopsDepA(msg) => msg.gps_time(), + Sbp::MsgBaselineHeadingDepA(msg) => msg.gps_time(), + Sbp::MsgDops(msg) => msg.gps_time(), + Sbp::MsgPosEcef(msg) => msg.gps_time(), + Sbp::MsgPosLlh(msg) => msg.gps_time(), + Sbp::MsgBaselineEcef(msg) => msg.gps_time(), + Sbp::MsgBaselineNed(msg) => msg.gps_time(), + Sbp::MsgVelEcef(msg) => msg.gps_time(), + Sbp::MsgVelNed(msg) => msg.gps_time(), + Sbp::MsgBaselineHeading(msg) => msg.gps_time(), + Sbp::MsgAgeCorrections(msg) => msg.gps_time(), + Sbp::MsgPosLlhCov(msg) => msg.gps_time(), + Sbp::MsgVelNedCov(msg) => msg.gps_time(), + Sbp::MsgVelBody(msg) => msg.gps_time(), + Sbp::MsgPosEcefCov(msg) => msg.gps_time(), + Sbp::MsgVelEcefCov(msg) => msg.gps_time(), + Sbp::MsgProtectionLevelDepA(msg) => msg.gps_time(), + Sbp::MsgProtectionLevel(msg) => msg.gps_time(), + Sbp::MsgPosLlhAcc(msg) => msg.gps_time(), + Sbp::MsgOrientQuat(msg) => msg.gps_time(), + Sbp::MsgOrientEuler(msg) => msg.gps_time(), + Sbp::MsgAngularRate(msg) => msg.gps_time(), + Sbp::MsgPosEcefGnss(msg) => msg.gps_time(), + Sbp::MsgPosLlhGnss(msg) => msg.gps_time(), + Sbp::MsgVelEcefGnss(msg) => msg.gps_time(), + Sbp::MsgVelNedGnss(msg) => msg.gps_time(), + Sbp::MsgPosLlhCovGnss(msg) => msg.gps_time(), + Sbp::MsgVelNedCovGnss(msg) => msg.gps_time(), + Sbp::MsgPosEcefCovGnss(msg) => msg.gps_time(), + Sbp::MsgVelEcefCovGnss(msg) => msg.gps_time(), + Sbp::MsgNdbEvent(msg) => msg.gps_time(), + Sbp::MsgLog(msg) => msg.gps_time(), + Sbp::MsgFwd(msg) => msg.gps_time(), + Sbp::MsgSsrOrbitClockDepA(msg) => msg.gps_time(), + Sbp::MsgSsrOrbitClock(msg) => msg.gps_time(), + Sbp::MsgSsrCodeBiases(msg) => msg.gps_time(), + Sbp::MsgSsrPhaseBiases(msg) => msg.gps_time(), + Sbp::MsgSsrStecCorrectionDepA(msg) => msg.gps_time(), + Sbp::MsgSsrGriddedCorrectionNoStdDepA(msg) => msg.gps_time(), + Sbp::MsgSsrGridDefinitionDepA(msg) => msg.gps_time(), + Sbp::MsgSsrTileDefinition(msg) => msg.gps_time(), + Sbp::MsgSsrGriddedCorrectionDepA(msg) => msg.gps_time(), + Sbp::MsgSsrStecCorrection(msg) => msg.gps_time(), + Sbp::MsgSsrGriddedCorrection(msg) => msg.gps_time(), + Sbp::MsgSsrSatelliteApc(msg) => msg.gps_time(), + Sbp::MsgOsr(msg) => msg.gps_time(), + Sbp::MsgUserData(msg) => msg.gps_time(), + Sbp::MsgImuRaw(msg) => msg.gps_time(), + Sbp::MsgImuAux(msg) => msg.gps_time(), + Sbp::MsgMagRaw(msg) => msg.gps_time(), + Sbp::MsgOdometry(msg) => msg.gps_time(), + Sbp::MsgWheeltick(msg) => msg.gps_time(), + Sbp::MsgFileioConfigReq(msg) => msg.gps_time(), + Sbp::MsgFileioConfigResp(msg) => msg.gps_time(), + Sbp::MsgSbasRaw(msg) => msg.gps_time(), + Sbp::MsgLinuxCpuStateDepA(msg) => msg.gps_time(), + Sbp::MsgLinuxMemStateDepA(msg) => msg.gps_time(), + Sbp::MsgLinuxSysStateDepA(msg) => msg.gps_time(), + Sbp::MsgLinuxProcessSocketCounts(msg) => msg.gps_time(), + Sbp::MsgLinuxProcessSocketQueues(msg) => msg.gps_time(), + Sbp::MsgLinuxSocketUsage(msg) => msg.gps_time(), + Sbp::MsgLinuxProcessFdCount(msg) => msg.gps_time(), + Sbp::MsgLinuxProcessFdSummary(msg) => msg.gps_time(), + Sbp::MsgLinuxCpuState(msg) => msg.gps_time(), + Sbp::MsgLinuxMemState(msg) => msg.gps_time(), + Sbp::MsgLinuxSysState(msg) => msg.gps_time(), + Sbp::MsgStartup(msg) => msg.gps_time(), + Sbp::MsgDgnssStatus(msg) => msg.gps_time(), + Sbp::MsgInsStatus(msg) => msg.gps_time(), + Sbp::MsgCsacTelemetry(msg) => msg.gps_time(), + Sbp::MsgCsacTelemetryLabels(msg) => msg.gps_time(), + Sbp::MsgInsUpdates(msg) => msg.gps_time(), + Sbp::MsgGnssTimeOffset(msg) => msg.gps_time(), + Sbp::MsgPpsTime(msg) => msg.gps_time(), + Sbp::MsgGroupMeta(msg) => msg.gps_time(), + Sbp::MsgSolnMeta(msg) => msg.gps_time(), + Sbp::MsgSolnMetaDepA(msg) => msg.gps_time(), + Sbp::MsgStatusReport(msg) => msg.gps_time(), + Sbp::MsgHeartbeat(msg) => msg.gps_time(), + Sbp::Unknown(msg) => msg.gps_time(), } } } -impl crate::SbpSerialize for SBP { - fn append_to_sbp_buffer(&self, buf: &mut Vec) { +impl WireFormat for Sbp { + const MIN_ENCODED_LEN: usize = crate::MAX_FRAME_LEN; + + fn parse_unchecked(_: &mut bytes::BytesMut) -> Self { + unimplemented!("Sbp must be parsed with Sbp::from_frame"); + } + + fn write(&self, buf: &mut bytes::BytesMut) { match self { - SBP::MsgPrintDep(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgTrackingStateDetailedDep(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgTrackingStateDepB(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgAcqResultDepB(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgAcqResultDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgTrackingStateDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgThreadState(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgUartStateDepa(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgIarState(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgEphemerisDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgMaskSatelliteDep(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgTrackingIqDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgUartState(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgAcqSvProfileDep(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgAcqResultDepC(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgTrackingStateDetailedDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgResetFilters(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgInitBaseDep(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgMaskSatellite(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgTrackingIqDepB(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgTrackingIq(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgAcqSvProfile(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgAcqResult(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgTrackingState(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgObsDepB(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgBasePosLLH(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgObsDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgEphemerisDepB(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgEphemerisDepC(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgBasePosECEF(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgObsDepC(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgObs(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSpecanDep(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSpecan(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgMeasurementState(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSetTime(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgAlmanac(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgAlmanacGPSDep(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgAlmanacGloDep(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgAlmanacGPS(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgAlmanacGlo(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgGloBiases(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgEphemerisDepD(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgEphemerisGPSDepE(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgEphemerisSbasDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgEphemerisGloDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgEphemerisSbasDepB(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgEphemerisGloDepB(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgEphemerisGPSDepF(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgEphemerisGloDepC(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgEphemerisGloDepD(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgEphemerisBds(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgEphemerisGPS(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgEphemerisGlo(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgEphemerisSbas(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgEphemerisGal(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgEphemerisQzss(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgIono(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSvConfigurationGPSDep(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgGroupDelayDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgGroupDelayDepB(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgGroupDelay(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgEphemerisGalDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgGnssCapb(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSvAzEl(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSettingsWrite(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSettingsSave(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSettingsReadByIndexReq(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgFileioReadResp(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSettingsReadReq(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSettingsReadResp(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSettingsReadByIndexDone(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSettingsReadByIndexResp(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgFileioReadReq(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgFileioReadDirReq(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgFileioReadDirResp(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgFileioWriteResp(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgFileioRemove(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgFileioWriteReq(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSettingsRegister(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSettingsWriteResp(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgBootloaderHandshakeDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgBootloaderJumpToApp(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgResetDep(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgBootloaderHandshakeReq(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgBootloaderHandshakeResp(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgDeviceMonitor(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgReset(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgCommandReq(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgCommandResp(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgNetworkStateReq(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgNetworkStateResp(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgCommandOutput(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgNetworkBandwidthUsage(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgCellModemStatus(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgFrontEndGain(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgCwResults(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgCwStart(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgNapDeviceDnaResp(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgNapDeviceDnaReq(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgFlashDone(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgFlashReadResp(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgFlashErase(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgStmFlashLockSector(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgStmFlashUnlockSector(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgStmUniqueIdResp(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgFlashProgram(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgFlashReadReq(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgStmUniqueIdReq(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgM25FlashWriteStatus(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgGPSTimeDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgExtEvent(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgGPSTime(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgUtcTime(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgGPSTimeGnss(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgUtcTimeGnss(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSettingsRegisterResp(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgPosECEFDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgPosLLHDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgBaselineECEFDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgBaselineNEDDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgVelECEFDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgVelNEDDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgDopsDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgBaselineHeadingDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgDops(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgPosECEF(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgPosLLH(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgBaselineECEF(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgBaselineNED(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgVelECEF(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgVelNED(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgBaselineHeading(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgAgeCorrections(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgPosLLHCov(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgVelNEDCov(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgVelBody(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgPosECEFCov(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgVelECEFCov(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgProtectionLevelDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgProtectionLevel(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgPosLLHAcc(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgOrientQuat(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgOrientEuler(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgAngularRate(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgPosECEFGnss(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgPosLLHGnss(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgVelECEFGnss(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgVelNEDGnss(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgPosLLHCovGnss(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgVelNEDCovGnss(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgPosECEFCovGnss(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgVelECEFCovGnss(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgNdbEvent(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgLog(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgFwd(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSsrOrbitClockDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSsrOrbitClock(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSsrCodeBiases(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSsrPhaseBiases(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSsrStecCorrectionDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSsrGriddedCorrectionNoStdDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSsrGridDefinitionDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSsrTileDefinition(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSsrGriddedCorrectionDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSsrStecCorrection(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSsrGriddedCorrection(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSsrSatelliteApc(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgOsr(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgUserData(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgImuRaw(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgImuAux(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgMagRaw(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgOdometry(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgWheeltick(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgFileioConfigReq(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgFileioConfigResp(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSbasRaw(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgLinuxCpuStateDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgLinuxMemStateDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgLinuxSysStateDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgLinuxProcessSocketCounts(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgLinuxProcessSocketQueues(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgLinuxSocketUsage(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgLinuxProcessFdCount(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgLinuxProcessFdSummary(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgLinuxCpuState(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgLinuxMemState(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgLinuxSysState(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgStartup(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgDgnssStatus(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgInsStatus(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgCsacTelemetry(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgCsacTelemetryLabels(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgInsUpdates(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgGnssTimeOffset(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgPpsTime(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgGroupMeta(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSolnMeta(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgSolnMetaDepA(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgStatusReport(msg) => msg.append_to_sbp_buffer(buf), - SBP::MsgHeartbeat(msg) => msg.append_to_sbp_buffer(buf), - SBP::Unknown(msg) => msg.append_to_sbp_buffer(buf), + Sbp::MsgPrintDep(msg) => WireFormat::write(msg, buf), + Sbp::MsgTrackingStateDetailedDep(msg) => WireFormat::write(msg, buf), + Sbp::MsgTrackingStateDepB(msg) => WireFormat::write(msg, buf), + Sbp::MsgAcqResultDepB(msg) => WireFormat::write(msg, buf), + Sbp::MsgAcqResultDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgTrackingStateDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgThreadState(msg) => WireFormat::write(msg, buf), + Sbp::MsgUartStateDepa(msg) => WireFormat::write(msg, buf), + Sbp::MsgIarState(msg) => WireFormat::write(msg, buf), + Sbp::MsgEphemerisDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgMaskSatelliteDep(msg) => WireFormat::write(msg, buf), + Sbp::MsgTrackingIqDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgUartState(msg) => WireFormat::write(msg, buf), + Sbp::MsgAcqSvProfileDep(msg) => WireFormat::write(msg, buf), + Sbp::MsgAcqResultDepC(msg) => WireFormat::write(msg, buf), + Sbp::MsgTrackingStateDetailedDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgResetFilters(msg) => WireFormat::write(msg, buf), + Sbp::MsgInitBaseDep(msg) => WireFormat::write(msg, buf), + Sbp::MsgMaskSatellite(msg) => WireFormat::write(msg, buf), + Sbp::MsgTrackingIqDepB(msg) => WireFormat::write(msg, buf), + Sbp::MsgTrackingIq(msg) => WireFormat::write(msg, buf), + Sbp::MsgAcqSvProfile(msg) => WireFormat::write(msg, buf), + Sbp::MsgAcqResult(msg) => WireFormat::write(msg, buf), + Sbp::MsgTrackingState(msg) => WireFormat::write(msg, buf), + Sbp::MsgObsDepB(msg) => WireFormat::write(msg, buf), + Sbp::MsgBasePosLlh(msg) => WireFormat::write(msg, buf), + Sbp::MsgObsDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgEphemerisDepB(msg) => WireFormat::write(msg, buf), + Sbp::MsgEphemerisDepC(msg) => WireFormat::write(msg, buf), + Sbp::MsgBasePosEcef(msg) => WireFormat::write(msg, buf), + Sbp::MsgObsDepC(msg) => WireFormat::write(msg, buf), + Sbp::MsgObs(msg) => WireFormat::write(msg, buf), + Sbp::MsgSpecanDep(msg) => WireFormat::write(msg, buf), + Sbp::MsgSpecan(msg) => WireFormat::write(msg, buf), + Sbp::MsgMeasurementState(msg) => WireFormat::write(msg, buf), + Sbp::MsgSetTime(msg) => WireFormat::write(msg, buf), + Sbp::MsgAlmanac(msg) => WireFormat::write(msg, buf), + Sbp::MsgAlmanacGpsDep(msg) => WireFormat::write(msg, buf), + Sbp::MsgAlmanacGloDep(msg) => WireFormat::write(msg, buf), + Sbp::MsgAlmanacGps(msg) => WireFormat::write(msg, buf), + Sbp::MsgAlmanacGlo(msg) => WireFormat::write(msg, buf), + Sbp::MsgGloBiases(msg) => WireFormat::write(msg, buf), + Sbp::MsgEphemerisDepD(msg) => WireFormat::write(msg, buf), + Sbp::MsgEphemerisGpsDepE(msg) => WireFormat::write(msg, buf), + Sbp::MsgEphemerisSbasDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgEphemerisGloDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgEphemerisSbasDepB(msg) => WireFormat::write(msg, buf), + Sbp::MsgEphemerisGloDepB(msg) => WireFormat::write(msg, buf), + Sbp::MsgEphemerisGpsDepF(msg) => WireFormat::write(msg, buf), + Sbp::MsgEphemerisGloDepC(msg) => WireFormat::write(msg, buf), + Sbp::MsgEphemerisGloDepD(msg) => WireFormat::write(msg, buf), + Sbp::MsgEphemerisBds(msg) => WireFormat::write(msg, buf), + Sbp::MsgEphemerisGps(msg) => WireFormat::write(msg, buf), + Sbp::MsgEphemerisGlo(msg) => WireFormat::write(msg, buf), + Sbp::MsgEphemerisSbas(msg) => WireFormat::write(msg, buf), + Sbp::MsgEphemerisGal(msg) => WireFormat::write(msg, buf), + Sbp::MsgEphemerisQzss(msg) => WireFormat::write(msg, buf), + Sbp::MsgIono(msg) => WireFormat::write(msg, buf), + Sbp::MsgSvConfigurationGpsDep(msg) => WireFormat::write(msg, buf), + Sbp::MsgGroupDelayDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgGroupDelayDepB(msg) => WireFormat::write(msg, buf), + Sbp::MsgGroupDelay(msg) => WireFormat::write(msg, buf), + Sbp::MsgEphemerisGalDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgGnssCapb(msg) => WireFormat::write(msg, buf), + Sbp::MsgSvAzEl(msg) => WireFormat::write(msg, buf), + Sbp::MsgSettingsWrite(msg) => WireFormat::write(msg, buf), + Sbp::MsgSettingsSave(msg) => WireFormat::write(msg, buf), + Sbp::MsgSettingsReadByIndexReq(msg) => WireFormat::write(msg, buf), + Sbp::MsgFileioReadResp(msg) => WireFormat::write(msg, buf), + Sbp::MsgSettingsReadReq(msg) => WireFormat::write(msg, buf), + Sbp::MsgSettingsReadResp(msg) => WireFormat::write(msg, buf), + Sbp::MsgSettingsReadByIndexDone(msg) => WireFormat::write(msg, buf), + Sbp::MsgSettingsReadByIndexResp(msg) => WireFormat::write(msg, buf), + Sbp::MsgFileioReadReq(msg) => WireFormat::write(msg, buf), + Sbp::MsgFileioReadDirReq(msg) => WireFormat::write(msg, buf), + Sbp::MsgFileioReadDirResp(msg) => WireFormat::write(msg, buf), + Sbp::MsgFileioWriteResp(msg) => WireFormat::write(msg, buf), + Sbp::MsgFileioRemove(msg) => WireFormat::write(msg, buf), + Sbp::MsgFileioWriteReq(msg) => WireFormat::write(msg, buf), + Sbp::MsgSettingsRegister(msg) => WireFormat::write(msg, buf), + Sbp::MsgSettingsWriteResp(msg) => WireFormat::write(msg, buf), + Sbp::MsgBootloaderHandshakeDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgBootloaderJumpToApp(msg) => WireFormat::write(msg, buf), + Sbp::MsgResetDep(msg) => WireFormat::write(msg, buf), + Sbp::MsgBootloaderHandshakeReq(msg) => WireFormat::write(msg, buf), + Sbp::MsgBootloaderHandshakeResp(msg) => WireFormat::write(msg, buf), + Sbp::MsgDeviceMonitor(msg) => WireFormat::write(msg, buf), + Sbp::MsgReset(msg) => WireFormat::write(msg, buf), + Sbp::MsgCommandReq(msg) => WireFormat::write(msg, buf), + Sbp::MsgCommandResp(msg) => WireFormat::write(msg, buf), + Sbp::MsgNetworkStateReq(msg) => WireFormat::write(msg, buf), + Sbp::MsgNetworkStateResp(msg) => WireFormat::write(msg, buf), + Sbp::MsgCommandOutput(msg) => WireFormat::write(msg, buf), + Sbp::MsgNetworkBandwidthUsage(msg) => WireFormat::write(msg, buf), + Sbp::MsgCellModemStatus(msg) => WireFormat::write(msg, buf), + Sbp::MsgFrontEndGain(msg) => WireFormat::write(msg, buf), + Sbp::MsgCwResults(msg) => WireFormat::write(msg, buf), + Sbp::MsgCwStart(msg) => WireFormat::write(msg, buf), + Sbp::MsgNapDeviceDnaResp(msg) => WireFormat::write(msg, buf), + Sbp::MsgNapDeviceDnaReq(msg) => WireFormat::write(msg, buf), + Sbp::MsgFlashDone(msg) => WireFormat::write(msg, buf), + Sbp::MsgFlashReadResp(msg) => WireFormat::write(msg, buf), + Sbp::MsgFlashErase(msg) => WireFormat::write(msg, buf), + Sbp::MsgStmFlashLockSector(msg) => WireFormat::write(msg, buf), + Sbp::MsgStmFlashUnlockSector(msg) => WireFormat::write(msg, buf), + Sbp::MsgStmUniqueIdResp(msg) => WireFormat::write(msg, buf), + Sbp::MsgFlashProgram(msg) => WireFormat::write(msg, buf), + Sbp::MsgFlashReadReq(msg) => WireFormat::write(msg, buf), + Sbp::MsgStmUniqueIdReq(msg) => WireFormat::write(msg, buf), + Sbp::MsgM25FlashWriteStatus(msg) => WireFormat::write(msg, buf), + Sbp::MsgGpsTimeDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgExtEvent(msg) => WireFormat::write(msg, buf), + Sbp::MsgGpsTime(msg) => WireFormat::write(msg, buf), + Sbp::MsgUtcTime(msg) => WireFormat::write(msg, buf), + Sbp::MsgGpsTimeGnss(msg) => WireFormat::write(msg, buf), + Sbp::MsgUtcTimeGnss(msg) => WireFormat::write(msg, buf), + Sbp::MsgSettingsRegisterResp(msg) => WireFormat::write(msg, buf), + Sbp::MsgPosEcefDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgPosLlhDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgBaselineEcefDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgBaselineNedDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgVelEcefDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgVelNedDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgDopsDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgBaselineHeadingDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgDops(msg) => WireFormat::write(msg, buf), + Sbp::MsgPosEcef(msg) => WireFormat::write(msg, buf), + Sbp::MsgPosLlh(msg) => WireFormat::write(msg, buf), + Sbp::MsgBaselineEcef(msg) => WireFormat::write(msg, buf), + Sbp::MsgBaselineNed(msg) => WireFormat::write(msg, buf), + Sbp::MsgVelEcef(msg) => WireFormat::write(msg, buf), + Sbp::MsgVelNed(msg) => WireFormat::write(msg, buf), + Sbp::MsgBaselineHeading(msg) => WireFormat::write(msg, buf), + Sbp::MsgAgeCorrections(msg) => WireFormat::write(msg, buf), + Sbp::MsgPosLlhCov(msg) => WireFormat::write(msg, buf), + Sbp::MsgVelNedCov(msg) => WireFormat::write(msg, buf), + Sbp::MsgVelBody(msg) => WireFormat::write(msg, buf), + Sbp::MsgPosEcefCov(msg) => WireFormat::write(msg, buf), + Sbp::MsgVelEcefCov(msg) => WireFormat::write(msg, buf), + Sbp::MsgProtectionLevelDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgProtectionLevel(msg) => WireFormat::write(msg, buf), + Sbp::MsgPosLlhAcc(msg) => WireFormat::write(msg, buf), + Sbp::MsgOrientQuat(msg) => WireFormat::write(msg, buf), + Sbp::MsgOrientEuler(msg) => WireFormat::write(msg, buf), + Sbp::MsgAngularRate(msg) => WireFormat::write(msg, buf), + Sbp::MsgPosEcefGnss(msg) => WireFormat::write(msg, buf), + Sbp::MsgPosLlhGnss(msg) => WireFormat::write(msg, buf), + Sbp::MsgVelEcefGnss(msg) => WireFormat::write(msg, buf), + Sbp::MsgVelNedGnss(msg) => WireFormat::write(msg, buf), + Sbp::MsgPosLlhCovGnss(msg) => WireFormat::write(msg, buf), + Sbp::MsgVelNedCovGnss(msg) => WireFormat::write(msg, buf), + Sbp::MsgPosEcefCovGnss(msg) => WireFormat::write(msg, buf), + Sbp::MsgVelEcefCovGnss(msg) => WireFormat::write(msg, buf), + Sbp::MsgNdbEvent(msg) => WireFormat::write(msg, buf), + Sbp::MsgLog(msg) => WireFormat::write(msg, buf), + Sbp::MsgFwd(msg) => WireFormat::write(msg, buf), + Sbp::MsgSsrOrbitClockDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgSsrOrbitClock(msg) => WireFormat::write(msg, buf), + Sbp::MsgSsrCodeBiases(msg) => WireFormat::write(msg, buf), + Sbp::MsgSsrPhaseBiases(msg) => WireFormat::write(msg, buf), + Sbp::MsgSsrStecCorrectionDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgSsrGriddedCorrectionNoStdDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgSsrGridDefinitionDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgSsrTileDefinition(msg) => WireFormat::write(msg, buf), + Sbp::MsgSsrGriddedCorrectionDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgSsrStecCorrection(msg) => WireFormat::write(msg, buf), + Sbp::MsgSsrGriddedCorrection(msg) => WireFormat::write(msg, buf), + Sbp::MsgSsrSatelliteApc(msg) => WireFormat::write(msg, buf), + Sbp::MsgOsr(msg) => WireFormat::write(msg, buf), + Sbp::MsgUserData(msg) => WireFormat::write(msg, buf), + Sbp::MsgImuRaw(msg) => WireFormat::write(msg, buf), + Sbp::MsgImuAux(msg) => WireFormat::write(msg, buf), + Sbp::MsgMagRaw(msg) => WireFormat::write(msg, buf), + Sbp::MsgOdometry(msg) => WireFormat::write(msg, buf), + Sbp::MsgWheeltick(msg) => WireFormat::write(msg, buf), + Sbp::MsgFileioConfigReq(msg) => WireFormat::write(msg, buf), + Sbp::MsgFileioConfigResp(msg) => WireFormat::write(msg, buf), + Sbp::MsgSbasRaw(msg) => WireFormat::write(msg, buf), + Sbp::MsgLinuxCpuStateDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgLinuxMemStateDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgLinuxSysStateDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgLinuxProcessSocketCounts(msg) => WireFormat::write(msg, buf), + Sbp::MsgLinuxProcessSocketQueues(msg) => WireFormat::write(msg, buf), + Sbp::MsgLinuxSocketUsage(msg) => WireFormat::write(msg, buf), + Sbp::MsgLinuxProcessFdCount(msg) => WireFormat::write(msg, buf), + Sbp::MsgLinuxProcessFdSummary(msg) => WireFormat::write(msg, buf), + Sbp::MsgLinuxCpuState(msg) => WireFormat::write(msg, buf), + Sbp::MsgLinuxMemState(msg) => WireFormat::write(msg, buf), + Sbp::MsgLinuxSysState(msg) => WireFormat::write(msg, buf), + Sbp::MsgStartup(msg) => WireFormat::write(msg, buf), + Sbp::MsgDgnssStatus(msg) => WireFormat::write(msg, buf), + Sbp::MsgInsStatus(msg) => WireFormat::write(msg, buf), + Sbp::MsgCsacTelemetry(msg) => WireFormat::write(msg, buf), + Sbp::MsgCsacTelemetryLabels(msg) => WireFormat::write(msg, buf), + Sbp::MsgInsUpdates(msg) => WireFormat::write(msg, buf), + Sbp::MsgGnssTimeOffset(msg) => WireFormat::write(msg, buf), + Sbp::MsgPpsTime(msg) => WireFormat::write(msg, buf), + Sbp::MsgGroupMeta(msg) => WireFormat::write(msg, buf), + Sbp::MsgSolnMeta(msg) => WireFormat::write(msg, buf), + Sbp::MsgSolnMetaDepA(msg) => WireFormat::write(msg, buf), + Sbp::MsgStatusReport(msg) => WireFormat::write(msg, buf), + Sbp::MsgHeartbeat(msg) => WireFormat::write(msg, buf), + Sbp::Unknown(msg) => WireFormat::write(msg, buf), } } - fn sbp_size(&self) -> usize { + fn encoded_len(&self) -> usize { match self { - SBP::MsgPrintDep(msg) => msg.sbp_size(), - SBP::MsgTrackingStateDetailedDep(msg) => msg.sbp_size(), - SBP::MsgTrackingStateDepB(msg) => msg.sbp_size(), - SBP::MsgAcqResultDepB(msg) => msg.sbp_size(), - SBP::MsgAcqResultDepA(msg) => msg.sbp_size(), - SBP::MsgTrackingStateDepA(msg) => msg.sbp_size(), - SBP::MsgThreadState(msg) => msg.sbp_size(), - SBP::MsgUartStateDepa(msg) => msg.sbp_size(), - SBP::MsgIarState(msg) => msg.sbp_size(), - SBP::MsgEphemerisDepA(msg) => msg.sbp_size(), - SBP::MsgMaskSatelliteDep(msg) => msg.sbp_size(), - SBP::MsgTrackingIqDepA(msg) => msg.sbp_size(), - SBP::MsgUartState(msg) => msg.sbp_size(), - SBP::MsgAcqSvProfileDep(msg) => msg.sbp_size(), - SBP::MsgAcqResultDepC(msg) => msg.sbp_size(), - SBP::MsgTrackingStateDetailedDepA(msg) => msg.sbp_size(), - SBP::MsgResetFilters(msg) => msg.sbp_size(), - SBP::MsgInitBaseDep(msg) => msg.sbp_size(), - SBP::MsgMaskSatellite(msg) => msg.sbp_size(), - SBP::MsgTrackingIqDepB(msg) => msg.sbp_size(), - SBP::MsgTrackingIq(msg) => msg.sbp_size(), - SBP::MsgAcqSvProfile(msg) => msg.sbp_size(), - SBP::MsgAcqResult(msg) => msg.sbp_size(), - SBP::MsgTrackingState(msg) => msg.sbp_size(), - SBP::MsgObsDepB(msg) => msg.sbp_size(), - SBP::MsgBasePosLLH(msg) => msg.sbp_size(), - SBP::MsgObsDepA(msg) => msg.sbp_size(), - SBP::MsgEphemerisDepB(msg) => msg.sbp_size(), - SBP::MsgEphemerisDepC(msg) => msg.sbp_size(), - SBP::MsgBasePosECEF(msg) => msg.sbp_size(), - SBP::MsgObsDepC(msg) => msg.sbp_size(), - SBP::MsgObs(msg) => msg.sbp_size(), - SBP::MsgSpecanDep(msg) => msg.sbp_size(), - SBP::MsgSpecan(msg) => msg.sbp_size(), - SBP::MsgMeasurementState(msg) => msg.sbp_size(), - SBP::MsgSetTime(msg) => msg.sbp_size(), - SBP::MsgAlmanac(msg) => msg.sbp_size(), - SBP::MsgAlmanacGPSDep(msg) => msg.sbp_size(), - SBP::MsgAlmanacGloDep(msg) => msg.sbp_size(), - SBP::MsgAlmanacGPS(msg) => msg.sbp_size(), - SBP::MsgAlmanacGlo(msg) => msg.sbp_size(), - SBP::MsgGloBiases(msg) => msg.sbp_size(), - SBP::MsgEphemerisDepD(msg) => msg.sbp_size(), - SBP::MsgEphemerisGPSDepE(msg) => msg.sbp_size(), - SBP::MsgEphemerisSbasDepA(msg) => msg.sbp_size(), - SBP::MsgEphemerisGloDepA(msg) => msg.sbp_size(), - SBP::MsgEphemerisSbasDepB(msg) => msg.sbp_size(), - SBP::MsgEphemerisGloDepB(msg) => msg.sbp_size(), - SBP::MsgEphemerisGPSDepF(msg) => msg.sbp_size(), - SBP::MsgEphemerisGloDepC(msg) => msg.sbp_size(), - SBP::MsgEphemerisGloDepD(msg) => msg.sbp_size(), - SBP::MsgEphemerisBds(msg) => msg.sbp_size(), - SBP::MsgEphemerisGPS(msg) => msg.sbp_size(), - SBP::MsgEphemerisGlo(msg) => msg.sbp_size(), - SBP::MsgEphemerisSbas(msg) => msg.sbp_size(), - SBP::MsgEphemerisGal(msg) => msg.sbp_size(), - SBP::MsgEphemerisQzss(msg) => msg.sbp_size(), - SBP::MsgIono(msg) => msg.sbp_size(), - SBP::MsgSvConfigurationGPSDep(msg) => msg.sbp_size(), - SBP::MsgGroupDelayDepA(msg) => msg.sbp_size(), - SBP::MsgGroupDelayDepB(msg) => msg.sbp_size(), - SBP::MsgGroupDelay(msg) => msg.sbp_size(), - SBP::MsgEphemerisGalDepA(msg) => msg.sbp_size(), - SBP::MsgGnssCapb(msg) => msg.sbp_size(), - SBP::MsgSvAzEl(msg) => msg.sbp_size(), - SBP::MsgSettingsWrite(msg) => msg.sbp_size(), - SBP::MsgSettingsSave(msg) => msg.sbp_size(), - SBP::MsgSettingsReadByIndexReq(msg) => msg.sbp_size(), - SBP::MsgFileioReadResp(msg) => msg.sbp_size(), - SBP::MsgSettingsReadReq(msg) => msg.sbp_size(), - SBP::MsgSettingsReadResp(msg) => msg.sbp_size(), - SBP::MsgSettingsReadByIndexDone(msg) => msg.sbp_size(), - SBP::MsgSettingsReadByIndexResp(msg) => msg.sbp_size(), - SBP::MsgFileioReadReq(msg) => msg.sbp_size(), - SBP::MsgFileioReadDirReq(msg) => msg.sbp_size(), - SBP::MsgFileioReadDirResp(msg) => msg.sbp_size(), - SBP::MsgFileioWriteResp(msg) => msg.sbp_size(), - SBP::MsgFileioRemove(msg) => msg.sbp_size(), - SBP::MsgFileioWriteReq(msg) => msg.sbp_size(), - SBP::MsgSettingsRegister(msg) => msg.sbp_size(), - SBP::MsgSettingsWriteResp(msg) => msg.sbp_size(), - SBP::MsgBootloaderHandshakeDepA(msg) => msg.sbp_size(), - SBP::MsgBootloaderJumpToApp(msg) => msg.sbp_size(), - SBP::MsgResetDep(msg) => msg.sbp_size(), - SBP::MsgBootloaderHandshakeReq(msg) => msg.sbp_size(), - SBP::MsgBootloaderHandshakeResp(msg) => msg.sbp_size(), - SBP::MsgDeviceMonitor(msg) => msg.sbp_size(), - SBP::MsgReset(msg) => msg.sbp_size(), - SBP::MsgCommandReq(msg) => msg.sbp_size(), - SBP::MsgCommandResp(msg) => msg.sbp_size(), - SBP::MsgNetworkStateReq(msg) => msg.sbp_size(), - SBP::MsgNetworkStateResp(msg) => msg.sbp_size(), - SBP::MsgCommandOutput(msg) => msg.sbp_size(), - SBP::MsgNetworkBandwidthUsage(msg) => msg.sbp_size(), - SBP::MsgCellModemStatus(msg) => msg.sbp_size(), - SBP::MsgFrontEndGain(msg) => msg.sbp_size(), - SBP::MsgCwResults(msg) => msg.sbp_size(), - SBP::MsgCwStart(msg) => msg.sbp_size(), - SBP::MsgNapDeviceDnaResp(msg) => msg.sbp_size(), - SBP::MsgNapDeviceDnaReq(msg) => msg.sbp_size(), - SBP::MsgFlashDone(msg) => msg.sbp_size(), - SBP::MsgFlashReadResp(msg) => msg.sbp_size(), - SBP::MsgFlashErase(msg) => msg.sbp_size(), - SBP::MsgStmFlashLockSector(msg) => msg.sbp_size(), - SBP::MsgStmFlashUnlockSector(msg) => msg.sbp_size(), - SBP::MsgStmUniqueIdResp(msg) => msg.sbp_size(), - SBP::MsgFlashProgram(msg) => msg.sbp_size(), - SBP::MsgFlashReadReq(msg) => msg.sbp_size(), - SBP::MsgStmUniqueIdReq(msg) => msg.sbp_size(), - SBP::MsgM25FlashWriteStatus(msg) => msg.sbp_size(), - SBP::MsgGPSTimeDepA(msg) => msg.sbp_size(), - SBP::MsgExtEvent(msg) => msg.sbp_size(), - SBP::MsgGPSTime(msg) => msg.sbp_size(), - SBP::MsgUtcTime(msg) => msg.sbp_size(), - SBP::MsgGPSTimeGnss(msg) => msg.sbp_size(), - SBP::MsgUtcTimeGnss(msg) => msg.sbp_size(), - SBP::MsgSettingsRegisterResp(msg) => msg.sbp_size(), - SBP::MsgPosECEFDepA(msg) => msg.sbp_size(), - SBP::MsgPosLLHDepA(msg) => msg.sbp_size(), - SBP::MsgBaselineECEFDepA(msg) => msg.sbp_size(), - SBP::MsgBaselineNEDDepA(msg) => msg.sbp_size(), - SBP::MsgVelECEFDepA(msg) => msg.sbp_size(), - SBP::MsgVelNEDDepA(msg) => msg.sbp_size(), - SBP::MsgDopsDepA(msg) => msg.sbp_size(), - SBP::MsgBaselineHeadingDepA(msg) => msg.sbp_size(), - SBP::MsgDops(msg) => msg.sbp_size(), - SBP::MsgPosECEF(msg) => msg.sbp_size(), - SBP::MsgPosLLH(msg) => msg.sbp_size(), - SBP::MsgBaselineECEF(msg) => msg.sbp_size(), - SBP::MsgBaselineNED(msg) => msg.sbp_size(), - SBP::MsgVelECEF(msg) => msg.sbp_size(), - SBP::MsgVelNED(msg) => msg.sbp_size(), - SBP::MsgBaselineHeading(msg) => msg.sbp_size(), - SBP::MsgAgeCorrections(msg) => msg.sbp_size(), - SBP::MsgPosLLHCov(msg) => msg.sbp_size(), - SBP::MsgVelNEDCov(msg) => msg.sbp_size(), - SBP::MsgVelBody(msg) => msg.sbp_size(), - SBP::MsgPosECEFCov(msg) => msg.sbp_size(), - SBP::MsgVelECEFCov(msg) => msg.sbp_size(), - SBP::MsgProtectionLevelDepA(msg) => msg.sbp_size(), - SBP::MsgProtectionLevel(msg) => msg.sbp_size(), - SBP::MsgPosLLHAcc(msg) => msg.sbp_size(), - SBP::MsgOrientQuat(msg) => msg.sbp_size(), - SBP::MsgOrientEuler(msg) => msg.sbp_size(), - SBP::MsgAngularRate(msg) => msg.sbp_size(), - SBP::MsgPosECEFGnss(msg) => msg.sbp_size(), - SBP::MsgPosLLHGnss(msg) => msg.sbp_size(), - SBP::MsgVelECEFGnss(msg) => msg.sbp_size(), - SBP::MsgVelNEDGnss(msg) => msg.sbp_size(), - SBP::MsgPosLLHCovGnss(msg) => msg.sbp_size(), - SBP::MsgVelNEDCovGnss(msg) => msg.sbp_size(), - SBP::MsgPosECEFCovGnss(msg) => msg.sbp_size(), - SBP::MsgVelECEFCovGnss(msg) => msg.sbp_size(), - SBP::MsgNdbEvent(msg) => msg.sbp_size(), - SBP::MsgLog(msg) => msg.sbp_size(), - SBP::MsgFwd(msg) => msg.sbp_size(), - SBP::MsgSsrOrbitClockDepA(msg) => msg.sbp_size(), - SBP::MsgSsrOrbitClock(msg) => msg.sbp_size(), - SBP::MsgSsrCodeBiases(msg) => msg.sbp_size(), - SBP::MsgSsrPhaseBiases(msg) => msg.sbp_size(), - SBP::MsgSsrStecCorrectionDepA(msg) => msg.sbp_size(), - SBP::MsgSsrGriddedCorrectionNoStdDepA(msg) => msg.sbp_size(), - SBP::MsgSsrGridDefinitionDepA(msg) => msg.sbp_size(), - SBP::MsgSsrTileDefinition(msg) => msg.sbp_size(), - SBP::MsgSsrGriddedCorrectionDepA(msg) => msg.sbp_size(), - SBP::MsgSsrStecCorrection(msg) => msg.sbp_size(), - SBP::MsgSsrGriddedCorrection(msg) => msg.sbp_size(), - SBP::MsgSsrSatelliteApc(msg) => msg.sbp_size(), - SBP::MsgOsr(msg) => msg.sbp_size(), - SBP::MsgUserData(msg) => msg.sbp_size(), - SBP::MsgImuRaw(msg) => msg.sbp_size(), - SBP::MsgImuAux(msg) => msg.sbp_size(), - SBP::MsgMagRaw(msg) => msg.sbp_size(), - SBP::MsgOdometry(msg) => msg.sbp_size(), - SBP::MsgWheeltick(msg) => msg.sbp_size(), - SBP::MsgFileioConfigReq(msg) => msg.sbp_size(), - SBP::MsgFileioConfigResp(msg) => msg.sbp_size(), - SBP::MsgSbasRaw(msg) => msg.sbp_size(), - SBP::MsgLinuxCpuStateDepA(msg) => msg.sbp_size(), - SBP::MsgLinuxMemStateDepA(msg) => msg.sbp_size(), - SBP::MsgLinuxSysStateDepA(msg) => msg.sbp_size(), - SBP::MsgLinuxProcessSocketCounts(msg) => msg.sbp_size(), - SBP::MsgLinuxProcessSocketQueues(msg) => msg.sbp_size(), - SBP::MsgLinuxSocketUsage(msg) => msg.sbp_size(), - SBP::MsgLinuxProcessFdCount(msg) => msg.sbp_size(), - SBP::MsgLinuxProcessFdSummary(msg) => msg.sbp_size(), - SBP::MsgLinuxCpuState(msg) => msg.sbp_size(), - SBP::MsgLinuxMemState(msg) => msg.sbp_size(), - SBP::MsgLinuxSysState(msg) => msg.sbp_size(), - SBP::MsgStartup(msg) => msg.sbp_size(), - SBP::MsgDgnssStatus(msg) => msg.sbp_size(), - SBP::MsgInsStatus(msg) => msg.sbp_size(), - SBP::MsgCsacTelemetry(msg) => msg.sbp_size(), - SBP::MsgCsacTelemetryLabels(msg) => msg.sbp_size(), - SBP::MsgInsUpdates(msg) => msg.sbp_size(), - SBP::MsgGnssTimeOffset(msg) => msg.sbp_size(), - SBP::MsgPpsTime(msg) => msg.sbp_size(), - SBP::MsgGroupMeta(msg) => msg.sbp_size(), - SBP::MsgSolnMeta(msg) => msg.sbp_size(), - SBP::MsgSolnMetaDepA(msg) => msg.sbp_size(), - SBP::MsgStatusReport(msg) => msg.sbp_size(), - SBP::MsgHeartbeat(msg) => msg.sbp_size(), - SBP::Unknown(msg) => msg.sbp_size(), + Sbp::MsgPrintDep(msg) => WireFormat::encoded_len(msg), + Sbp::MsgTrackingStateDetailedDep(msg) => WireFormat::encoded_len(msg), + Sbp::MsgTrackingStateDepB(msg) => WireFormat::encoded_len(msg), + Sbp::MsgAcqResultDepB(msg) => WireFormat::encoded_len(msg), + Sbp::MsgAcqResultDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgTrackingStateDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgThreadState(msg) => WireFormat::encoded_len(msg), + Sbp::MsgUartStateDepa(msg) => WireFormat::encoded_len(msg), + Sbp::MsgIarState(msg) => WireFormat::encoded_len(msg), + Sbp::MsgEphemerisDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgMaskSatelliteDep(msg) => WireFormat::encoded_len(msg), + Sbp::MsgTrackingIqDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgUartState(msg) => WireFormat::encoded_len(msg), + Sbp::MsgAcqSvProfileDep(msg) => WireFormat::encoded_len(msg), + Sbp::MsgAcqResultDepC(msg) => WireFormat::encoded_len(msg), + Sbp::MsgTrackingStateDetailedDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgResetFilters(msg) => WireFormat::encoded_len(msg), + Sbp::MsgInitBaseDep(msg) => WireFormat::encoded_len(msg), + Sbp::MsgMaskSatellite(msg) => WireFormat::encoded_len(msg), + Sbp::MsgTrackingIqDepB(msg) => WireFormat::encoded_len(msg), + Sbp::MsgTrackingIq(msg) => WireFormat::encoded_len(msg), + Sbp::MsgAcqSvProfile(msg) => WireFormat::encoded_len(msg), + Sbp::MsgAcqResult(msg) => WireFormat::encoded_len(msg), + Sbp::MsgTrackingState(msg) => WireFormat::encoded_len(msg), + Sbp::MsgObsDepB(msg) => WireFormat::encoded_len(msg), + Sbp::MsgBasePosLlh(msg) => WireFormat::encoded_len(msg), + Sbp::MsgObsDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgEphemerisDepB(msg) => WireFormat::encoded_len(msg), + Sbp::MsgEphemerisDepC(msg) => WireFormat::encoded_len(msg), + Sbp::MsgBasePosEcef(msg) => WireFormat::encoded_len(msg), + Sbp::MsgObsDepC(msg) => WireFormat::encoded_len(msg), + Sbp::MsgObs(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSpecanDep(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSpecan(msg) => WireFormat::encoded_len(msg), + Sbp::MsgMeasurementState(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSetTime(msg) => WireFormat::encoded_len(msg), + Sbp::MsgAlmanac(msg) => WireFormat::encoded_len(msg), + Sbp::MsgAlmanacGpsDep(msg) => WireFormat::encoded_len(msg), + Sbp::MsgAlmanacGloDep(msg) => WireFormat::encoded_len(msg), + Sbp::MsgAlmanacGps(msg) => WireFormat::encoded_len(msg), + Sbp::MsgAlmanacGlo(msg) => WireFormat::encoded_len(msg), + Sbp::MsgGloBiases(msg) => WireFormat::encoded_len(msg), + Sbp::MsgEphemerisDepD(msg) => WireFormat::encoded_len(msg), + Sbp::MsgEphemerisGpsDepE(msg) => WireFormat::encoded_len(msg), + Sbp::MsgEphemerisSbasDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgEphemerisGloDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgEphemerisSbasDepB(msg) => WireFormat::encoded_len(msg), + Sbp::MsgEphemerisGloDepB(msg) => WireFormat::encoded_len(msg), + Sbp::MsgEphemerisGpsDepF(msg) => WireFormat::encoded_len(msg), + Sbp::MsgEphemerisGloDepC(msg) => WireFormat::encoded_len(msg), + Sbp::MsgEphemerisGloDepD(msg) => WireFormat::encoded_len(msg), + Sbp::MsgEphemerisBds(msg) => WireFormat::encoded_len(msg), + Sbp::MsgEphemerisGps(msg) => WireFormat::encoded_len(msg), + Sbp::MsgEphemerisGlo(msg) => WireFormat::encoded_len(msg), + Sbp::MsgEphemerisSbas(msg) => WireFormat::encoded_len(msg), + Sbp::MsgEphemerisGal(msg) => WireFormat::encoded_len(msg), + Sbp::MsgEphemerisQzss(msg) => WireFormat::encoded_len(msg), + Sbp::MsgIono(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSvConfigurationGpsDep(msg) => WireFormat::encoded_len(msg), + Sbp::MsgGroupDelayDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgGroupDelayDepB(msg) => WireFormat::encoded_len(msg), + Sbp::MsgGroupDelay(msg) => WireFormat::encoded_len(msg), + Sbp::MsgEphemerisGalDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgGnssCapb(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSvAzEl(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSettingsWrite(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSettingsSave(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSettingsReadByIndexReq(msg) => WireFormat::encoded_len(msg), + Sbp::MsgFileioReadResp(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSettingsReadReq(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSettingsReadResp(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSettingsReadByIndexDone(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSettingsReadByIndexResp(msg) => WireFormat::encoded_len(msg), + Sbp::MsgFileioReadReq(msg) => WireFormat::encoded_len(msg), + Sbp::MsgFileioReadDirReq(msg) => WireFormat::encoded_len(msg), + Sbp::MsgFileioReadDirResp(msg) => WireFormat::encoded_len(msg), + Sbp::MsgFileioWriteResp(msg) => WireFormat::encoded_len(msg), + Sbp::MsgFileioRemove(msg) => WireFormat::encoded_len(msg), + Sbp::MsgFileioWriteReq(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSettingsRegister(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSettingsWriteResp(msg) => WireFormat::encoded_len(msg), + Sbp::MsgBootloaderHandshakeDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgBootloaderJumpToApp(msg) => WireFormat::encoded_len(msg), + Sbp::MsgResetDep(msg) => WireFormat::encoded_len(msg), + Sbp::MsgBootloaderHandshakeReq(msg) => WireFormat::encoded_len(msg), + Sbp::MsgBootloaderHandshakeResp(msg) => WireFormat::encoded_len(msg), + Sbp::MsgDeviceMonitor(msg) => WireFormat::encoded_len(msg), + Sbp::MsgReset(msg) => WireFormat::encoded_len(msg), + Sbp::MsgCommandReq(msg) => WireFormat::encoded_len(msg), + Sbp::MsgCommandResp(msg) => WireFormat::encoded_len(msg), + Sbp::MsgNetworkStateReq(msg) => WireFormat::encoded_len(msg), + Sbp::MsgNetworkStateResp(msg) => WireFormat::encoded_len(msg), + Sbp::MsgCommandOutput(msg) => WireFormat::encoded_len(msg), + Sbp::MsgNetworkBandwidthUsage(msg) => WireFormat::encoded_len(msg), + Sbp::MsgCellModemStatus(msg) => WireFormat::encoded_len(msg), + Sbp::MsgFrontEndGain(msg) => WireFormat::encoded_len(msg), + Sbp::MsgCwResults(msg) => WireFormat::encoded_len(msg), + Sbp::MsgCwStart(msg) => WireFormat::encoded_len(msg), + Sbp::MsgNapDeviceDnaResp(msg) => WireFormat::encoded_len(msg), + Sbp::MsgNapDeviceDnaReq(msg) => WireFormat::encoded_len(msg), + Sbp::MsgFlashDone(msg) => WireFormat::encoded_len(msg), + Sbp::MsgFlashReadResp(msg) => WireFormat::encoded_len(msg), + Sbp::MsgFlashErase(msg) => WireFormat::encoded_len(msg), + Sbp::MsgStmFlashLockSector(msg) => WireFormat::encoded_len(msg), + Sbp::MsgStmFlashUnlockSector(msg) => WireFormat::encoded_len(msg), + Sbp::MsgStmUniqueIdResp(msg) => WireFormat::encoded_len(msg), + Sbp::MsgFlashProgram(msg) => WireFormat::encoded_len(msg), + Sbp::MsgFlashReadReq(msg) => WireFormat::encoded_len(msg), + Sbp::MsgStmUniqueIdReq(msg) => WireFormat::encoded_len(msg), + Sbp::MsgM25FlashWriteStatus(msg) => WireFormat::encoded_len(msg), + Sbp::MsgGpsTimeDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgExtEvent(msg) => WireFormat::encoded_len(msg), + Sbp::MsgGpsTime(msg) => WireFormat::encoded_len(msg), + Sbp::MsgUtcTime(msg) => WireFormat::encoded_len(msg), + Sbp::MsgGpsTimeGnss(msg) => WireFormat::encoded_len(msg), + Sbp::MsgUtcTimeGnss(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSettingsRegisterResp(msg) => WireFormat::encoded_len(msg), + Sbp::MsgPosEcefDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgPosLlhDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgBaselineEcefDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgBaselineNedDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgVelEcefDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgVelNedDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgDopsDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgBaselineHeadingDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgDops(msg) => WireFormat::encoded_len(msg), + Sbp::MsgPosEcef(msg) => WireFormat::encoded_len(msg), + Sbp::MsgPosLlh(msg) => WireFormat::encoded_len(msg), + Sbp::MsgBaselineEcef(msg) => WireFormat::encoded_len(msg), + Sbp::MsgBaselineNed(msg) => WireFormat::encoded_len(msg), + Sbp::MsgVelEcef(msg) => WireFormat::encoded_len(msg), + Sbp::MsgVelNed(msg) => WireFormat::encoded_len(msg), + Sbp::MsgBaselineHeading(msg) => WireFormat::encoded_len(msg), + Sbp::MsgAgeCorrections(msg) => WireFormat::encoded_len(msg), + Sbp::MsgPosLlhCov(msg) => WireFormat::encoded_len(msg), + Sbp::MsgVelNedCov(msg) => WireFormat::encoded_len(msg), + Sbp::MsgVelBody(msg) => WireFormat::encoded_len(msg), + Sbp::MsgPosEcefCov(msg) => WireFormat::encoded_len(msg), + Sbp::MsgVelEcefCov(msg) => WireFormat::encoded_len(msg), + Sbp::MsgProtectionLevelDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgProtectionLevel(msg) => WireFormat::encoded_len(msg), + Sbp::MsgPosLlhAcc(msg) => WireFormat::encoded_len(msg), + Sbp::MsgOrientQuat(msg) => WireFormat::encoded_len(msg), + Sbp::MsgOrientEuler(msg) => WireFormat::encoded_len(msg), + Sbp::MsgAngularRate(msg) => WireFormat::encoded_len(msg), + Sbp::MsgPosEcefGnss(msg) => WireFormat::encoded_len(msg), + Sbp::MsgPosLlhGnss(msg) => WireFormat::encoded_len(msg), + Sbp::MsgVelEcefGnss(msg) => WireFormat::encoded_len(msg), + Sbp::MsgVelNedGnss(msg) => WireFormat::encoded_len(msg), + Sbp::MsgPosLlhCovGnss(msg) => WireFormat::encoded_len(msg), + Sbp::MsgVelNedCovGnss(msg) => WireFormat::encoded_len(msg), + Sbp::MsgPosEcefCovGnss(msg) => WireFormat::encoded_len(msg), + Sbp::MsgVelEcefCovGnss(msg) => WireFormat::encoded_len(msg), + Sbp::MsgNdbEvent(msg) => WireFormat::encoded_len(msg), + Sbp::MsgLog(msg) => WireFormat::encoded_len(msg), + Sbp::MsgFwd(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSsrOrbitClockDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSsrOrbitClock(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSsrCodeBiases(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSsrPhaseBiases(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSsrStecCorrectionDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSsrGriddedCorrectionNoStdDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSsrGridDefinitionDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSsrTileDefinition(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSsrGriddedCorrectionDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSsrStecCorrection(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSsrGriddedCorrection(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSsrSatelliteApc(msg) => WireFormat::encoded_len(msg), + Sbp::MsgOsr(msg) => WireFormat::encoded_len(msg), + Sbp::MsgUserData(msg) => WireFormat::encoded_len(msg), + Sbp::MsgImuRaw(msg) => WireFormat::encoded_len(msg), + Sbp::MsgImuAux(msg) => WireFormat::encoded_len(msg), + Sbp::MsgMagRaw(msg) => WireFormat::encoded_len(msg), + Sbp::MsgOdometry(msg) => WireFormat::encoded_len(msg), + Sbp::MsgWheeltick(msg) => WireFormat::encoded_len(msg), + Sbp::MsgFileioConfigReq(msg) => WireFormat::encoded_len(msg), + Sbp::MsgFileioConfigResp(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSbasRaw(msg) => WireFormat::encoded_len(msg), + Sbp::MsgLinuxCpuStateDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgLinuxMemStateDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgLinuxSysStateDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgLinuxProcessSocketCounts(msg) => WireFormat::encoded_len(msg), + Sbp::MsgLinuxProcessSocketQueues(msg) => WireFormat::encoded_len(msg), + Sbp::MsgLinuxSocketUsage(msg) => WireFormat::encoded_len(msg), + Sbp::MsgLinuxProcessFdCount(msg) => WireFormat::encoded_len(msg), + Sbp::MsgLinuxProcessFdSummary(msg) => WireFormat::encoded_len(msg), + Sbp::MsgLinuxCpuState(msg) => WireFormat::encoded_len(msg), + Sbp::MsgLinuxMemState(msg) => WireFormat::encoded_len(msg), + Sbp::MsgLinuxSysState(msg) => WireFormat::encoded_len(msg), + Sbp::MsgStartup(msg) => WireFormat::encoded_len(msg), + Sbp::MsgDgnssStatus(msg) => WireFormat::encoded_len(msg), + Sbp::MsgInsStatus(msg) => WireFormat::encoded_len(msg), + Sbp::MsgCsacTelemetry(msg) => WireFormat::encoded_len(msg), + Sbp::MsgCsacTelemetryLabels(msg) => WireFormat::encoded_len(msg), + Sbp::MsgInsUpdates(msg) => WireFormat::encoded_len(msg), + Sbp::MsgGnssTimeOffset(msg) => WireFormat::encoded_len(msg), + Sbp::MsgPpsTime(msg) => WireFormat::encoded_len(msg), + Sbp::MsgGroupMeta(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSolnMeta(msg) => WireFormat::encoded_len(msg), + Sbp::MsgSolnMetaDepA(msg) => WireFormat::encoded_len(msg), + Sbp::MsgStatusReport(msg) => WireFormat::encoded_len(msg), + Sbp::MsgHeartbeat(msg) => WireFormat::encoded_len(msg), + Sbp::Unknown(msg) => WireFormat::encoded_len(msg), } } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgPrintDep) -> Self { - SBP::MsgPrintDep(msg) + Sbp::MsgPrintDep(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgTrackingStateDetailedDep) -> Self { - SBP::MsgTrackingStateDetailedDep(msg) + Sbp::MsgTrackingStateDetailedDep(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgTrackingStateDepB) -> Self { - SBP::MsgTrackingStateDepB(msg) + Sbp::MsgTrackingStateDepB(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgAcqResultDepB) -> Self { - SBP::MsgAcqResultDepB(msg) + Sbp::MsgAcqResultDepB(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgAcqResultDepA) -> Self { - SBP::MsgAcqResultDepA(msg) + Sbp::MsgAcqResultDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgTrackingStateDepA) -> Self { - SBP::MsgTrackingStateDepA(msg) + Sbp::MsgTrackingStateDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgThreadState) -> Self { - SBP::MsgThreadState(msg) + Sbp::MsgThreadState(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgUartStateDepa) -> Self { - SBP::MsgUartStateDepa(msg) + Sbp::MsgUartStateDepa(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgIarState) -> Self { - SBP::MsgIarState(msg) + Sbp::MsgIarState(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgEphemerisDepA) -> Self { - SBP::MsgEphemerisDepA(msg) + Sbp::MsgEphemerisDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgMaskSatelliteDep) -> Self { - SBP::MsgMaskSatelliteDep(msg) + Sbp::MsgMaskSatelliteDep(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgTrackingIqDepA) -> Self { - SBP::MsgTrackingIqDepA(msg) + Sbp::MsgTrackingIqDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgUartState) -> Self { - SBP::MsgUartState(msg) + Sbp::MsgUartState(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgAcqSvProfileDep) -> Self { - SBP::MsgAcqSvProfileDep(msg) + Sbp::MsgAcqSvProfileDep(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgAcqResultDepC) -> Self { - SBP::MsgAcqResultDepC(msg) + Sbp::MsgAcqResultDepC(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgTrackingStateDetailedDepA) -> Self { - SBP::MsgTrackingStateDetailedDepA(msg) + Sbp::MsgTrackingStateDetailedDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgResetFilters) -> Self { - SBP::MsgResetFilters(msg) + Sbp::MsgResetFilters(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgInitBaseDep) -> Self { - SBP::MsgInitBaseDep(msg) + Sbp::MsgInitBaseDep(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgMaskSatellite) -> Self { - SBP::MsgMaskSatellite(msg) + Sbp::MsgMaskSatellite(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgTrackingIqDepB) -> Self { - SBP::MsgTrackingIqDepB(msg) + Sbp::MsgTrackingIqDepB(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgTrackingIq) -> Self { - SBP::MsgTrackingIq(msg) + Sbp::MsgTrackingIq(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgAcqSvProfile) -> Self { - SBP::MsgAcqSvProfile(msg) + Sbp::MsgAcqSvProfile(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgAcqResult) -> Self { - SBP::MsgAcqResult(msg) + Sbp::MsgAcqResult(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgTrackingState) -> Self { - SBP::MsgTrackingState(msg) + Sbp::MsgTrackingState(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgObsDepB) -> Self { - SBP::MsgObsDepB(msg) + Sbp::MsgObsDepB(msg) } } -impl From for SBP { - fn from(msg: MsgBasePosLLH) -> Self { - SBP::MsgBasePosLLH(msg) + +impl From for Sbp { + fn from(msg: MsgBasePosLlh) -> Self { + Sbp::MsgBasePosLlh(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgObsDepA) -> Self { - SBP::MsgObsDepA(msg) + Sbp::MsgObsDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgEphemerisDepB) -> Self { - SBP::MsgEphemerisDepB(msg) + Sbp::MsgEphemerisDepB(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgEphemerisDepC) -> Self { - SBP::MsgEphemerisDepC(msg) + Sbp::MsgEphemerisDepC(msg) } } -impl From for SBP { - fn from(msg: MsgBasePosECEF) -> Self { - SBP::MsgBasePosECEF(msg) + +impl From for Sbp { + fn from(msg: MsgBasePosEcef) -> Self { + Sbp::MsgBasePosEcef(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgObsDepC) -> Self { - SBP::MsgObsDepC(msg) + Sbp::MsgObsDepC(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgObs) -> Self { - SBP::MsgObs(msg) + Sbp::MsgObs(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSpecanDep) -> Self { - SBP::MsgSpecanDep(msg) + Sbp::MsgSpecanDep(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSpecan) -> Self { - SBP::MsgSpecan(msg) + Sbp::MsgSpecan(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgMeasurementState) -> Self { - SBP::MsgMeasurementState(msg) + Sbp::MsgMeasurementState(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSetTime) -> Self { - SBP::MsgSetTime(msg) + Sbp::MsgSetTime(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgAlmanac) -> Self { - SBP::MsgAlmanac(msg) + Sbp::MsgAlmanac(msg) } } -impl From for SBP { - fn from(msg: MsgAlmanacGPSDep) -> Self { - SBP::MsgAlmanacGPSDep(msg) + +impl From for Sbp { + fn from(msg: MsgAlmanacGpsDep) -> Self { + Sbp::MsgAlmanacGpsDep(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgAlmanacGloDep) -> Self { - SBP::MsgAlmanacGloDep(msg) + Sbp::MsgAlmanacGloDep(msg) } } -impl From for SBP { - fn from(msg: MsgAlmanacGPS) -> Self { - SBP::MsgAlmanacGPS(msg) + +impl From for Sbp { + fn from(msg: MsgAlmanacGps) -> Self { + Sbp::MsgAlmanacGps(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgAlmanacGlo) -> Self { - SBP::MsgAlmanacGlo(msg) + Sbp::MsgAlmanacGlo(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgGloBiases) -> Self { - SBP::MsgGloBiases(msg) + Sbp::MsgGloBiases(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgEphemerisDepD) -> Self { - SBP::MsgEphemerisDepD(msg) + Sbp::MsgEphemerisDepD(msg) } } -impl From for SBP { - fn from(msg: MsgEphemerisGPSDepE) -> Self { - SBP::MsgEphemerisGPSDepE(msg) + +impl From for Sbp { + fn from(msg: MsgEphemerisGpsDepE) -> Self { + Sbp::MsgEphemerisGpsDepE(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgEphemerisSbasDepA) -> Self { - SBP::MsgEphemerisSbasDepA(msg) + Sbp::MsgEphemerisSbasDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgEphemerisGloDepA) -> Self { - SBP::MsgEphemerisGloDepA(msg) + Sbp::MsgEphemerisGloDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgEphemerisSbasDepB) -> Self { - SBP::MsgEphemerisSbasDepB(msg) + Sbp::MsgEphemerisSbasDepB(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgEphemerisGloDepB) -> Self { - SBP::MsgEphemerisGloDepB(msg) + Sbp::MsgEphemerisGloDepB(msg) } } -impl From for SBP { - fn from(msg: MsgEphemerisGPSDepF) -> Self { - SBP::MsgEphemerisGPSDepF(msg) + +impl From for Sbp { + fn from(msg: MsgEphemerisGpsDepF) -> Self { + Sbp::MsgEphemerisGpsDepF(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgEphemerisGloDepC) -> Self { - SBP::MsgEphemerisGloDepC(msg) + Sbp::MsgEphemerisGloDepC(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgEphemerisGloDepD) -> Self { - SBP::MsgEphemerisGloDepD(msg) + Sbp::MsgEphemerisGloDepD(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgEphemerisBds) -> Self { - SBP::MsgEphemerisBds(msg) + Sbp::MsgEphemerisBds(msg) } } -impl From for SBP { - fn from(msg: MsgEphemerisGPS) -> Self { - SBP::MsgEphemerisGPS(msg) + +impl From for Sbp { + fn from(msg: MsgEphemerisGps) -> Self { + Sbp::MsgEphemerisGps(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgEphemerisGlo) -> Self { - SBP::MsgEphemerisGlo(msg) + Sbp::MsgEphemerisGlo(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgEphemerisSbas) -> Self { - SBP::MsgEphemerisSbas(msg) + Sbp::MsgEphemerisSbas(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgEphemerisGal) -> Self { - SBP::MsgEphemerisGal(msg) + Sbp::MsgEphemerisGal(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgEphemerisQzss) -> Self { - SBP::MsgEphemerisQzss(msg) + Sbp::MsgEphemerisQzss(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgIono) -> Self { - SBP::MsgIono(msg) + Sbp::MsgIono(msg) } } -impl From for SBP { - fn from(msg: MsgSvConfigurationGPSDep) -> Self { - SBP::MsgSvConfigurationGPSDep(msg) + +impl From for Sbp { + fn from(msg: MsgSvConfigurationGpsDep) -> Self { + Sbp::MsgSvConfigurationGpsDep(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgGroupDelayDepA) -> Self { - SBP::MsgGroupDelayDepA(msg) + Sbp::MsgGroupDelayDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgGroupDelayDepB) -> Self { - SBP::MsgGroupDelayDepB(msg) + Sbp::MsgGroupDelayDepB(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgGroupDelay) -> Self { - SBP::MsgGroupDelay(msg) + Sbp::MsgGroupDelay(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgEphemerisGalDepA) -> Self { - SBP::MsgEphemerisGalDepA(msg) + Sbp::MsgEphemerisGalDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgGnssCapb) -> Self { - SBP::MsgGnssCapb(msg) + Sbp::MsgGnssCapb(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSvAzEl) -> Self { - SBP::MsgSvAzEl(msg) + Sbp::MsgSvAzEl(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSettingsWrite) -> Self { - SBP::MsgSettingsWrite(msg) + Sbp::MsgSettingsWrite(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSettingsSave) -> Self { - SBP::MsgSettingsSave(msg) + Sbp::MsgSettingsSave(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSettingsReadByIndexReq) -> Self { - SBP::MsgSettingsReadByIndexReq(msg) + Sbp::MsgSettingsReadByIndexReq(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgFileioReadResp) -> Self { - SBP::MsgFileioReadResp(msg) + Sbp::MsgFileioReadResp(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSettingsReadReq) -> Self { - SBP::MsgSettingsReadReq(msg) + Sbp::MsgSettingsReadReq(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSettingsReadResp) -> Self { - SBP::MsgSettingsReadResp(msg) + Sbp::MsgSettingsReadResp(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSettingsReadByIndexDone) -> Self { - SBP::MsgSettingsReadByIndexDone(msg) + Sbp::MsgSettingsReadByIndexDone(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSettingsReadByIndexResp) -> Self { - SBP::MsgSettingsReadByIndexResp(msg) + Sbp::MsgSettingsReadByIndexResp(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgFileioReadReq) -> Self { - SBP::MsgFileioReadReq(msg) + Sbp::MsgFileioReadReq(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgFileioReadDirReq) -> Self { - SBP::MsgFileioReadDirReq(msg) + Sbp::MsgFileioReadDirReq(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgFileioReadDirResp) -> Self { - SBP::MsgFileioReadDirResp(msg) + Sbp::MsgFileioReadDirResp(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgFileioWriteResp) -> Self { - SBP::MsgFileioWriteResp(msg) + Sbp::MsgFileioWriteResp(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgFileioRemove) -> Self { - SBP::MsgFileioRemove(msg) + Sbp::MsgFileioRemove(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgFileioWriteReq) -> Self { - SBP::MsgFileioWriteReq(msg) + Sbp::MsgFileioWriteReq(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSettingsRegister) -> Self { - SBP::MsgSettingsRegister(msg) + Sbp::MsgSettingsRegister(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSettingsWriteResp) -> Self { - SBP::MsgSettingsWriteResp(msg) + Sbp::MsgSettingsWriteResp(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgBootloaderHandshakeDepA) -> Self { - SBP::MsgBootloaderHandshakeDepA(msg) + Sbp::MsgBootloaderHandshakeDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgBootloaderJumpToApp) -> Self { - SBP::MsgBootloaderJumpToApp(msg) + Sbp::MsgBootloaderJumpToApp(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgResetDep) -> Self { - SBP::MsgResetDep(msg) + Sbp::MsgResetDep(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgBootloaderHandshakeReq) -> Self { - SBP::MsgBootloaderHandshakeReq(msg) + Sbp::MsgBootloaderHandshakeReq(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgBootloaderHandshakeResp) -> Self { - SBP::MsgBootloaderHandshakeResp(msg) + Sbp::MsgBootloaderHandshakeResp(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgDeviceMonitor) -> Self { - SBP::MsgDeviceMonitor(msg) + Sbp::MsgDeviceMonitor(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgReset) -> Self { - SBP::MsgReset(msg) + Sbp::MsgReset(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgCommandReq) -> Self { - SBP::MsgCommandReq(msg) + Sbp::MsgCommandReq(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgCommandResp) -> Self { - SBP::MsgCommandResp(msg) + Sbp::MsgCommandResp(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgNetworkStateReq) -> Self { - SBP::MsgNetworkStateReq(msg) + Sbp::MsgNetworkStateReq(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgNetworkStateResp) -> Self { - SBP::MsgNetworkStateResp(msg) + Sbp::MsgNetworkStateResp(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgCommandOutput) -> Self { - SBP::MsgCommandOutput(msg) + Sbp::MsgCommandOutput(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgNetworkBandwidthUsage) -> Self { - SBP::MsgNetworkBandwidthUsage(msg) + Sbp::MsgNetworkBandwidthUsage(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgCellModemStatus) -> Self { - SBP::MsgCellModemStatus(msg) + Sbp::MsgCellModemStatus(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgFrontEndGain) -> Self { - SBP::MsgFrontEndGain(msg) + Sbp::MsgFrontEndGain(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgCwResults) -> Self { - SBP::MsgCwResults(msg) + Sbp::MsgCwResults(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgCwStart) -> Self { - SBP::MsgCwStart(msg) + Sbp::MsgCwStart(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgNapDeviceDnaResp) -> Self { - SBP::MsgNapDeviceDnaResp(msg) + Sbp::MsgNapDeviceDnaResp(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgNapDeviceDnaReq) -> Self { - SBP::MsgNapDeviceDnaReq(msg) + Sbp::MsgNapDeviceDnaReq(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgFlashDone) -> Self { - SBP::MsgFlashDone(msg) + Sbp::MsgFlashDone(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgFlashReadResp) -> Self { - SBP::MsgFlashReadResp(msg) + Sbp::MsgFlashReadResp(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgFlashErase) -> Self { - SBP::MsgFlashErase(msg) + Sbp::MsgFlashErase(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgStmFlashLockSector) -> Self { - SBP::MsgStmFlashLockSector(msg) + Sbp::MsgStmFlashLockSector(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgStmFlashUnlockSector) -> Self { - SBP::MsgStmFlashUnlockSector(msg) + Sbp::MsgStmFlashUnlockSector(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgStmUniqueIdResp) -> Self { - SBP::MsgStmUniqueIdResp(msg) + Sbp::MsgStmUniqueIdResp(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgFlashProgram) -> Self { - SBP::MsgFlashProgram(msg) + Sbp::MsgFlashProgram(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgFlashReadReq) -> Self { - SBP::MsgFlashReadReq(msg) + Sbp::MsgFlashReadReq(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgStmUniqueIdReq) -> Self { - SBP::MsgStmUniqueIdReq(msg) + Sbp::MsgStmUniqueIdReq(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgM25FlashWriteStatus) -> Self { - SBP::MsgM25FlashWriteStatus(msg) + Sbp::MsgM25FlashWriteStatus(msg) } } -impl From for SBP { - fn from(msg: MsgGPSTimeDepA) -> Self { - SBP::MsgGPSTimeDepA(msg) + +impl From for Sbp { + fn from(msg: MsgGpsTimeDepA) -> Self { + Sbp::MsgGpsTimeDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgExtEvent) -> Self { - SBP::MsgExtEvent(msg) + Sbp::MsgExtEvent(msg) } } -impl From for SBP { - fn from(msg: MsgGPSTime) -> Self { - SBP::MsgGPSTime(msg) + +impl From for Sbp { + fn from(msg: MsgGpsTime) -> Self { + Sbp::MsgGpsTime(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgUtcTime) -> Self { - SBP::MsgUtcTime(msg) + Sbp::MsgUtcTime(msg) } } -impl From for SBP { - fn from(msg: MsgGPSTimeGnss) -> Self { - SBP::MsgGPSTimeGnss(msg) + +impl From for Sbp { + fn from(msg: MsgGpsTimeGnss) -> Self { + Sbp::MsgGpsTimeGnss(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgUtcTimeGnss) -> Self { - SBP::MsgUtcTimeGnss(msg) + Sbp::MsgUtcTimeGnss(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSettingsRegisterResp) -> Self { - SBP::MsgSettingsRegisterResp(msg) + Sbp::MsgSettingsRegisterResp(msg) } } -impl From for SBP { - fn from(msg: MsgPosECEFDepA) -> Self { - SBP::MsgPosECEFDepA(msg) + +impl From for Sbp { + fn from(msg: MsgPosEcefDepA) -> Self { + Sbp::MsgPosEcefDepA(msg) } } -impl From for SBP { - fn from(msg: MsgPosLLHDepA) -> Self { - SBP::MsgPosLLHDepA(msg) + +impl From for Sbp { + fn from(msg: MsgPosLlhDepA) -> Self { + Sbp::MsgPosLlhDepA(msg) } } -impl From for SBP { - fn from(msg: MsgBaselineECEFDepA) -> Self { - SBP::MsgBaselineECEFDepA(msg) + +impl From for Sbp { + fn from(msg: MsgBaselineEcefDepA) -> Self { + Sbp::MsgBaselineEcefDepA(msg) } } -impl From for SBP { - fn from(msg: MsgBaselineNEDDepA) -> Self { - SBP::MsgBaselineNEDDepA(msg) + +impl From for Sbp { + fn from(msg: MsgBaselineNedDepA) -> Self { + Sbp::MsgBaselineNedDepA(msg) } } -impl From for SBP { - fn from(msg: MsgVelECEFDepA) -> Self { - SBP::MsgVelECEFDepA(msg) + +impl From for Sbp { + fn from(msg: MsgVelEcefDepA) -> Self { + Sbp::MsgVelEcefDepA(msg) } } -impl From for SBP { - fn from(msg: MsgVelNEDDepA) -> Self { - SBP::MsgVelNEDDepA(msg) + +impl From for Sbp { + fn from(msg: MsgVelNedDepA) -> Self { + Sbp::MsgVelNedDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgDopsDepA) -> Self { - SBP::MsgDopsDepA(msg) + Sbp::MsgDopsDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgBaselineHeadingDepA) -> Self { - SBP::MsgBaselineHeadingDepA(msg) + Sbp::MsgBaselineHeadingDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgDops) -> Self { - SBP::MsgDops(msg) + Sbp::MsgDops(msg) } } -impl From for SBP { - fn from(msg: MsgPosECEF) -> Self { - SBP::MsgPosECEF(msg) + +impl From for Sbp { + fn from(msg: MsgPosEcef) -> Self { + Sbp::MsgPosEcef(msg) } } -impl From for SBP { - fn from(msg: MsgPosLLH) -> Self { - SBP::MsgPosLLH(msg) + +impl From for Sbp { + fn from(msg: MsgPosLlh) -> Self { + Sbp::MsgPosLlh(msg) } } -impl From for SBP { - fn from(msg: MsgBaselineECEF) -> Self { - SBP::MsgBaselineECEF(msg) + +impl From for Sbp { + fn from(msg: MsgBaselineEcef) -> Self { + Sbp::MsgBaselineEcef(msg) } } -impl From for SBP { - fn from(msg: MsgBaselineNED) -> Self { - SBP::MsgBaselineNED(msg) + +impl From for Sbp { + fn from(msg: MsgBaselineNed) -> Self { + Sbp::MsgBaselineNed(msg) } } -impl From for SBP { - fn from(msg: MsgVelECEF) -> Self { - SBP::MsgVelECEF(msg) + +impl From for Sbp { + fn from(msg: MsgVelEcef) -> Self { + Sbp::MsgVelEcef(msg) } } -impl From for SBP { - fn from(msg: MsgVelNED) -> Self { - SBP::MsgVelNED(msg) + +impl From for Sbp { + fn from(msg: MsgVelNed) -> Self { + Sbp::MsgVelNed(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgBaselineHeading) -> Self { - SBP::MsgBaselineHeading(msg) + Sbp::MsgBaselineHeading(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgAgeCorrections) -> Self { - SBP::MsgAgeCorrections(msg) + Sbp::MsgAgeCorrections(msg) } } -impl From for SBP { - fn from(msg: MsgPosLLHCov) -> Self { - SBP::MsgPosLLHCov(msg) + +impl From for Sbp { + fn from(msg: MsgPosLlhCov) -> Self { + Sbp::MsgPosLlhCov(msg) } } -impl From for SBP { - fn from(msg: MsgVelNEDCov) -> Self { - SBP::MsgVelNEDCov(msg) + +impl From for Sbp { + fn from(msg: MsgVelNedCov) -> Self { + Sbp::MsgVelNedCov(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgVelBody) -> Self { - SBP::MsgVelBody(msg) + Sbp::MsgVelBody(msg) } } -impl From for SBP { - fn from(msg: MsgPosECEFCov) -> Self { - SBP::MsgPosECEFCov(msg) + +impl From for Sbp { + fn from(msg: MsgPosEcefCov) -> Self { + Sbp::MsgPosEcefCov(msg) } } -impl From for SBP { - fn from(msg: MsgVelECEFCov) -> Self { - SBP::MsgVelECEFCov(msg) + +impl From for Sbp { + fn from(msg: MsgVelEcefCov) -> Self { + Sbp::MsgVelEcefCov(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgProtectionLevelDepA) -> Self { - SBP::MsgProtectionLevelDepA(msg) + Sbp::MsgProtectionLevelDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgProtectionLevel) -> Self { - SBP::MsgProtectionLevel(msg) + Sbp::MsgProtectionLevel(msg) } } -impl From for SBP { - fn from(msg: MsgPosLLHAcc) -> Self { - SBP::MsgPosLLHAcc(msg) + +impl From for Sbp { + fn from(msg: MsgPosLlhAcc) -> Self { + Sbp::MsgPosLlhAcc(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgOrientQuat) -> Self { - SBP::MsgOrientQuat(msg) + Sbp::MsgOrientQuat(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgOrientEuler) -> Self { - SBP::MsgOrientEuler(msg) + Sbp::MsgOrientEuler(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgAngularRate) -> Self { - SBP::MsgAngularRate(msg) + Sbp::MsgAngularRate(msg) } } -impl From for SBP { - fn from(msg: MsgPosECEFGnss) -> Self { - SBP::MsgPosECEFGnss(msg) + +impl From for Sbp { + fn from(msg: MsgPosEcefGnss) -> Self { + Sbp::MsgPosEcefGnss(msg) } } -impl From for SBP { - fn from(msg: MsgPosLLHGnss) -> Self { - SBP::MsgPosLLHGnss(msg) + +impl From for Sbp { + fn from(msg: MsgPosLlhGnss) -> Self { + Sbp::MsgPosLlhGnss(msg) } } -impl From for SBP { - fn from(msg: MsgVelECEFGnss) -> Self { - SBP::MsgVelECEFGnss(msg) + +impl From for Sbp { + fn from(msg: MsgVelEcefGnss) -> Self { + Sbp::MsgVelEcefGnss(msg) } } -impl From for SBP { - fn from(msg: MsgVelNEDGnss) -> Self { - SBP::MsgVelNEDGnss(msg) + +impl From for Sbp { + fn from(msg: MsgVelNedGnss) -> Self { + Sbp::MsgVelNedGnss(msg) } } -impl From for SBP { - fn from(msg: MsgPosLLHCovGnss) -> Self { - SBP::MsgPosLLHCovGnss(msg) + +impl From for Sbp { + fn from(msg: MsgPosLlhCovGnss) -> Self { + Sbp::MsgPosLlhCovGnss(msg) } } -impl From for SBP { - fn from(msg: MsgVelNEDCovGnss) -> Self { - SBP::MsgVelNEDCovGnss(msg) + +impl From for Sbp { + fn from(msg: MsgVelNedCovGnss) -> Self { + Sbp::MsgVelNedCovGnss(msg) } } -impl From for SBP { - fn from(msg: MsgPosECEFCovGnss) -> Self { - SBP::MsgPosECEFCovGnss(msg) + +impl From for Sbp { + fn from(msg: MsgPosEcefCovGnss) -> Self { + Sbp::MsgPosEcefCovGnss(msg) } } -impl From for SBP { - fn from(msg: MsgVelECEFCovGnss) -> Self { - SBP::MsgVelECEFCovGnss(msg) + +impl From for Sbp { + fn from(msg: MsgVelEcefCovGnss) -> Self { + Sbp::MsgVelEcefCovGnss(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgNdbEvent) -> Self { - SBP::MsgNdbEvent(msg) + Sbp::MsgNdbEvent(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgLog) -> Self { - SBP::MsgLog(msg) + Sbp::MsgLog(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgFwd) -> Self { - SBP::MsgFwd(msg) + Sbp::MsgFwd(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSsrOrbitClockDepA) -> Self { - SBP::MsgSsrOrbitClockDepA(msg) + Sbp::MsgSsrOrbitClockDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSsrOrbitClock) -> Self { - SBP::MsgSsrOrbitClock(msg) + Sbp::MsgSsrOrbitClock(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSsrCodeBiases) -> Self { - SBP::MsgSsrCodeBiases(msg) + Sbp::MsgSsrCodeBiases(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSsrPhaseBiases) -> Self { - SBP::MsgSsrPhaseBiases(msg) + Sbp::MsgSsrPhaseBiases(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSsrStecCorrectionDepA) -> Self { - SBP::MsgSsrStecCorrectionDepA(msg) + Sbp::MsgSsrStecCorrectionDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSsrGriddedCorrectionNoStdDepA) -> Self { - SBP::MsgSsrGriddedCorrectionNoStdDepA(msg) + Sbp::MsgSsrGriddedCorrectionNoStdDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSsrGridDefinitionDepA) -> Self { - SBP::MsgSsrGridDefinitionDepA(msg) + Sbp::MsgSsrGridDefinitionDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSsrTileDefinition) -> Self { - SBP::MsgSsrTileDefinition(msg) + Sbp::MsgSsrTileDefinition(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSsrGriddedCorrectionDepA) -> Self { - SBP::MsgSsrGriddedCorrectionDepA(msg) + Sbp::MsgSsrGriddedCorrectionDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSsrStecCorrection) -> Self { - SBP::MsgSsrStecCorrection(msg) + Sbp::MsgSsrStecCorrection(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSsrGriddedCorrection) -> Self { - SBP::MsgSsrGriddedCorrection(msg) + Sbp::MsgSsrGriddedCorrection(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSsrSatelliteApc) -> Self { - SBP::MsgSsrSatelliteApc(msg) + Sbp::MsgSsrSatelliteApc(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgOsr) -> Self { - SBP::MsgOsr(msg) + Sbp::MsgOsr(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgUserData) -> Self { - SBP::MsgUserData(msg) + Sbp::MsgUserData(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgImuRaw) -> Self { - SBP::MsgImuRaw(msg) + Sbp::MsgImuRaw(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgImuAux) -> Self { - SBP::MsgImuAux(msg) + Sbp::MsgImuAux(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgMagRaw) -> Self { - SBP::MsgMagRaw(msg) + Sbp::MsgMagRaw(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgOdometry) -> Self { - SBP::MsgOdometry(msg) + Sbp::MsgOdometry(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgWheeltick) -> Self { - SBP::MsgWheeltick(msg) + Sbp::MsgWheeltick(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgFileioConfigReq) -> Self { - SBP::MsgFileioConfigReq(msg) + Sbp::MsgFileioConfigReq(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgFileioConfigResp) -> Self { - SBP::MsgFileioConfigResp(msg) + Sbp::MsgFileioConfigResp(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSbasRaw) -> Self { - SBP::MsgSbasRaw(msg) + Sbp::MsgSbasRaw(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgLinuxCpuStateDepA) -> Self { - SBP::MsgLinuxCpuStateDepA(msg) + Sbp::MsgLinuxCpuStateDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgLinuxMemStateDepA) -> Self { - SBP::MsgLinuxMemStateDepA(msg) + Sbp::MsgLinuxMemStateDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgLinuxSysStateDepA) -> Self { - SBP::MsgLinuxSysStateDepA(msg) + Sbp::MsgLinuxSysStateDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgLinuxProcessSocketCounts) -> Self { - SBP::MsgLinuxProcessSocketCounts(msg) + Sbp::MsgLinuxProcessSocketCounts(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgLinuxProcessSocketQueues) -> Self { - SBP::MsgLinuxProcessSocketQueues(msg) + Sbp::MsgLinuxProcessSocketQueues(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgLinuxSocketUsage) -> Self { - SBP::MsgLinuxSocketUsage(msg) + Sbp::MsgLinuxSocketUsage(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgLinuxProcessFdCount) -> Self { - SBP::MsgLinuxProcessFdCount(msg) + Sbp::MsgLinuxProcessFdCount(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgLinuxProcessFdSummary) -> Self { - SBP::MsgLinuxProcessFdSummary(msg) + Sbp::MsgLinuxProcessFdSummary(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgLinuxCpuState) -> Self { - SBP::MsgLinuxCpuState(msg) + Sbp::MsgLinuxCpuState(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgLinuxMemState) -> Self { - SBP::MsgLinuxMemState(msg) + Sbp::MsgLinuxMemState(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgLinuxSysState) -> Self { - SBP::MsgLinuxSysState(msg) + Sbp::MsgLinuxSysState(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgStartup) -> Self { - SBP::MsgStartup(msg) + Sbp::MsgStartup(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgDgnssStatus) -> Self { - SBP::MsgDgnssStatus(msg) + Sbp::MsgDgnssStatus(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgInsStatus) -> Self { - SBP::MsgInsStatus(msg) + Sbp::MsgInsStatus(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgCsacTelemetry) -> Self { - SBP::MsgCsacTelemetry(msg) + Sbp::MsgCsacTelemetry(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgCsacTelemetryLabels) -> Self { - SBP::MsgCsacTelemetryLabels(msg) + Sbp::MsgCsacTelemetryLabels(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgInsUpdates) -> Self { - SBP::MsgInsUpdates(msg) + Sbp::MsgInsUpdates(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgGnssTimeOffset) -> Self { - SBP::MsgGnssTimeOffset(msg) + Sbp::MsgGnssTimeOffset(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgPpsTime) -> Self { - SBP::MsgPpsTime(msg) + Sbp::MsgPpsTime(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgGroupMeta) -> Self { - SBP::MsgGroupMeta(msg) + Sbp::MsgGroupMeta(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSolnMeta) -> Self { - SBP::MsgSolnMeta(msg) + Sbp::MsgSolnMeta(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgSolnMetaDepA) -> Self { - SBP::MsgSolnMetaDepA(msg) + Sbp::MsgSolnMetaDepA(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgStatusReport) -> Self { - SBP::MsgStatusReport(msg) + Sbp::MsgStatusReport(msg) } } -impl From for SBP { + +impl From for Sbp { fn from(msg: MsgHeartbeat) -> Self { - SBP::MsgHeartbeat(msg) + Sbp::MsgHeartbeat(msg) } } -impl From for SBP { +impl From for Sbp { fn from(msg: Unknown) -> Self { - SBP::Unknown(msg) + Sbp::Unknown(msg) } } diff --git a/rust/sbp/src/messages/navigation.rs b/rust/sbp/src/messages/navigation.rs index 972e2e391b..d7200bf6dd 100644 --- a/rust/sbp/src/messages/navigation.rs +++ b/rust/sbp/src/messages/navigation.rs @@ -37,77 +37,46 @@ //! system timestamp, irrespective of the time reference (GPS Week or else), //! but not a Time of Measurement. -#[allow(unused_imports)] -use std::convert::TryFrom; +use super::lib::*; -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; - -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +/// Horizontal estimated error ellipse +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct EstimatedHorizontalErrorEllipse { /// The semi major axis of the estimated horizontal error ellipse at the /// user-configured confidence level; zero implies invalid. + #[cfg_attr(feature = "serde", serde(rename(serialize = "semi_major")))] pub semi_major: f32, /// The semi minor axis of the estimated horizontal error ellipse at the /// user-configured confidence level; zero implies invalid. + #[cfg_attr(feature = "serde", serde(rename(serialize = "semi_minor")))] pub semi_minor: f32, /// The orientation of the semi major axis of the estimated horizontal error /// ellipse with respect to North. + #[cfg_attr(feature = "serde", serde(rename(serialize = "orientation")))] pub orientation: f32, } -impl EstimatedHorizontalErrorEllipse { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( EstimatedHorizontalErrorEllipse{ - semi_major: _buf.read_f32::()?, - semi_minor: _buf.read_f32::()?, - orientation: _buf.read_f32::()?, - } ) - } - pub fn parse_array( - buf: &mut &[u8], - ) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(EstimatedHorizontalErrorEllipse::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(EstimatedHorizontalErrorEllipse::parse(buf)?); +impl WireFormat for EstimatedHorizontalErrorEllipse { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.semi_major) + + WireFormat::encoded_len(&self.semi_minor) + + WireFormat::encoded_len(&self.orientation) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.semi_major, buf); + WireFormat::write(&self.semi_minor, buf); + WireFormat::write(&self.orientation, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + EstimatedHorizontalErrorEllipse { + semi_major: WireFormat::parse_unchecked(buf), + semi_minor: WireFormat::parse_unchecked(buf), + orientation: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for EstimatedHorizontalErrorEllipse { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.semi_major.append_to_sbp_buffer(buf); - self.semi_minor.append_to_sbp_buffer(buf); - self.orientation.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.semi_major.sbp_size(); - size += self.semi_minor.sbp_size(); - size += self.orientation.sbp_size(); - size } } @@ -116,94 +85,75 @@ impl crate::serialize::SbpSerialize for EstimatedHorizontalErrorEllipse { /// This message reports the Age of the corrections used for the current /// Differential solution. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgAgeCorrections { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Age of the corrections (0xFFFF indicates invalid) + #[cfg_attr(feature = "serde", serde(rename(serialize = "age")))] pub age: u16, } -impl MsgAgeCorrections { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgAgeCorrections{ - sender_id: None, - tow: _buf.read_u32::()?, - age: _buf.read_u16::()?, - } ) - } +impl ConcreteMessage for MsgAgeCorrections { + const MESSAGE_TYPE: u16 = 528; + const MESSAGE_NAME: &'static str = "MSG_AGE_CORRECTIONS"; } -impl super::SBPMessage for MsgAgeCorrections { - fn get_message_name(&self) -> &'static str { - "MSG_AGE_CORRECTIONS" - } - fn get_message_type(&self) -> u16 { - 528 +impl SbpMessage for MsgAgeCorrections { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgAgeCorrections { - const MESSAGE_TYPE: u16 = 528; - const MESSAGE_NAME: &'static str = "MSG_AGE_CORRECTIONS"; -} -impl TryFrom for MsgAgeCorrections { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgAgeCorrections { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgAgeCorrections(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgAgeCorrections(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgAgeCorrections { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.age.append_to_sbp_buffer(buf); +impl WireFormat for MsgAgeCorrections { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + WireFormat::encoded_len(&self.age) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.age.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.age, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgAgeCorrections { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + age: WireFormat::parse_unchecked(buf), + } } } @@ -214,119 +164,111 @@ impl crate::serialize::SbpSerialize for MsgAgeCorrections { /// base station to the rover receiver. The full GPS time is given by the /// preceding MSG_GPS_TIME with the matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgBaselineECEF { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgBaselineEcef { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Baseline ECEF X coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "x")))] pub x: i32, /// Baseline ECEF Y coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "y")))] pub y: i32, /// Baseline ECEF Z coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "z")))] pub z: i32, /// Position estimated standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "accuracy")))] pub accuracy: u16, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgBaselineECEF { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgBaselineECEF{ - sender_id: None, - tow: _buf.read_u32::()?, - x: _buf.read_i32::()?, - y: _buf.read_i32::()?, - z: _buf.read_i32::()?, - accuracy: _buf.read_u16::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgBaselineEcef { + const MESSAGE_TYPE: u16 = 523; + const MESSAGE_NAME: &'static str = "MSG_BASELINE_ECEF"; } -impl super::SBPMessage for MsgBaselineECEF { - fn get_message_name(&self) -> &'static str { - "MSG_BASELINE_ECEF" - } - fn get_message_type(&self) -> u16 { - 523 +impl SbpMessage for MsgBaselineEcef { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgBaselineECEF { - const MESSAGE_TYPE: u16 = 523; - const MESSAGE_NAME: &'static str = "MSG_BASELINE_ECEF"; -} -impl TryFrom for MsgBaselineECEF { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgBaselineEcef { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgBaselineECEF(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgBaselineEcef(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgBaselineECEF { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.x.append_to_sbp_buffer(buf); - self.y.append_to_sbp_buffer(buf); - self.z.append_to_sbp_buffer(buf); - self.accuracy.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.x.sbp_size(); - size += self.y.sbp_size(); - size += self.z.sbp_size(); - size += self.accuracy.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgBaselineEcef { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.x) + + WireFormat::encoded_len(&self.y) + + WireFormat::encoded_len(&self.z) + + WireFormat::encoded_len(&self.accuracy) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.x, buf); + WireFormat::write(&self.y, buf); + WireFormat::write(&self.z, buf); + WireFormat::write(&self.accuracy, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgBaselineEcef { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + x: WireFormat::parse_unchecked(buf), + y: WireFormat::parse_unchecked(buf), + z: WireFormat::parse_unchecked(buf), + accuracy: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -337,119 +279,111 @@ impl crate::serialize::SbpSerialize for MsgBaselineECEF { /// base station to the rover receiver. The full GPS time is given by the /// preceding MSG_GPS_TIME with the matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgBaselineECEFDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgBaselineEcefDepA { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Baseline ECEF X coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "x")))] pub x: i32, /// Baseline ECEF Y coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "y")))] pub y: i32, /// Baseline ECEF Z coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "z")))] pub z: i32, /// Position accuracy estimate + #[cfg_attr(feature = "serde", serde(rename(serialize = "accuracy")))] pub accuracy: u16, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgBaselineECEFDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgBaselineECEFDepA{ - sender_id: None, - tow: _buf.read_u32::()?, - x: _buf.read_i32::()?, - y: _buf.read_i32::()?, - z: _buf.read_i32::()?, - accuracy: _buf.read_u16::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgBaselineEcefDepA { + const MESSAGE_TYPE: u16 = 514; + const MESSAGE_NAME: &'static str = "MSG_BASELINE_ECEF_DEP_A"; } -impl super::SBPMessage for MsgBaselineECEFDepA { - fn get_message_name(&self) -> &'static str { - "MSG_BASELINE_ECEF_DEP_A" - } - fn get_message_type(&self) -> u16 { - 514 +impl SbpMessage for MsgBaselineEcefDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgBaselineECEFDepA { - const MESSAGE_TYPE: u16 = 514; - const MESSAGE_NAME: &'static str = "MSG_BASELINE_ECEF_DEP_A"; -} -impl TryFrom for MsgBaselineECEFDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgBaselineEcefDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgBaselineECEFDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgBaselineEcefDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgBaselineECEFDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.x.append_to_sbp_buffer(buf); - self.y.append_to_sbp_buffer(buf); - self.z.append_to_sbp_buffer(buf); - self.accuracy.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.x.sbp_size(); - size += self.y.sbp_size(); - size += self.z.sbp_size(); - size += self.accuracy.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgBaselineEcefDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.x) + + WireFormat::encoded_len(&self.y) + + WireFormat::encoded_len(&self.z) + + WireFormat::encoded_len(&self.accuracy) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.x, buf); + WireFormat::write(&self.y, buf); + WireFormat::write(&self.z, buf); + WireFormat::write(&self.accuracy, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgBaselineEcefDepA { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + x: WireFormat::parse_unchecked(buf), + y: WireFormat::parse_unchecked(buf), + z: WireFormat::parse_unchecked(buf), + accuracy: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -459,104 +393,90 @@ impl crate::serialize::SbpSerialize for MsgBaselineECEFDepA { /// to the rover relative to True North. The full GPS time is given by the /// preceding MSG_GPS_TIME with the matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgBaselineHeadingDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Heading + #[cfg_attr(feature = "serde", serde(rename(serialize = "heading")))] pub heading: u32, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgBaselineHeadingDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgBaselineHeadingDepA{ - sender_id: None, - tow: _buf.read_u32::()?, - heading: _buf.read_u32::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgBaselineHeadingDepA { + const MESSAGE_TYPE: u16 = 519; + const MESSAGE_NAME: &'static str = "MSG_BASELINE_HEADING_DEP_A"; } -impl super::SBPMessage for MsgBaselineHeadingDepA { - fn get_message_name(&self) -> &'static str { - "MSG_BASELINE_HEADING_DEP_A" - } - fn get_message_type(&self) -> u16 { - 519 +impl SbpMessage for MsgBaselineHeadingDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgBaselineHeadingDepA { - const MESSAGE_TYPE: u16 = 519; - const MESSAGE_NAME: &'static str = "MSG_BASELINE_HEADING_DEP_A"; -} -impl TryFrom for MsgBaselineHeadingDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgBaselineHeadingDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgBaselineHeadingDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgBaselineHeadingDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgBaselineHeadingDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.heading.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); +impl WireFormat for MsgBaselineHeadingDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.heading) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.heading.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.heading, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgBaselineHeadingDepA { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + heading: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -569,124 +489,118 @@ impl crate::serialize::SbpSerialize for MsgBaselineHeadingDepA { /// GPS time is given by the preceding MSG_GPS_TIME with the matching time-of- /// week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgBaselineNED { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgBaselineNed { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Baseline North coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "n")))] pub n: i32, /// Baseline East coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "e")))] pub e: i32, /// Baseline Down coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "d")))] pub d: i32, /// Horizontal position estimated standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "h_accuracy")))] pub h_accuracy: u16, /// Vertical position estimated standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "v_accuracy")))] pub v_accuracy: u16, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgBaselineNED { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgBaselineNED{ - sender_id: None, - tow: _buf.read_u32::()?, - n: _buf.read_i32::()?, - e: _buf.read_i32::()?, - d: _buf.read_i32::()?, - h_accuracy: _buf.read_u16::()?, - v_accuracy: _buf.read_u16::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgBaselineNed { + const MESSAGE_TYPE: u16 = 524; + const MESSAGE_NAME: &'static str = "MSG_BASELINE_NED"; } -impl super::SBPMessage for MsgBaselineNED { - fn get_message_name(&self) -> &'static str { - "MSG_BASELINE_NED" - } - fn get_message_type(&self) -> u16 { - 524 +impl SbpMessage for MsgBaselineNed { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgBaselineNED { - const MESSAGE_TYPE: u16 = 524; - const MESSAGE_NAME: &'static str = "MSG_BASELINE_NED"; -} -impl TryFrom for MsgBaselineNED { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgBaselineNed { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgBaselineNED(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgBaselineNed(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgBaselineNED { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.n.append_to_sbp_buffer(buf); - self.e.append_to_sbp_buffer(buf); - self.d.append_to_sbp_buffer(buf); - self.h_accuracy.append_to_sbp_buffer(buf); - self.v_accuracy.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.n.sbp_size(); - size += self.e.sbp_size(); - size += self.d.sbp_size(); - size += self.h_accuracy.sbp_size(); - size += self.v_accuracy.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgBaselineNed { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.n) + + WireFormat::encoded_len(&self.e) + + WireFormat::encoded_len(&self.d) + + WireFormat::encoded_len(&self.h_accuracy) + + WireFormat::encoded_len(&self.v_accuracy) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.n, buf); + WireFormat::write(&self.e, buf); + WireFormat::write(&self.d, buf); + WireFormat::write(&self.h_accuracy, buf); + WireFormat::write(&self.v_accuracy, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgBaselineNed { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + n: WireFormat::parse_unchecked(buf), + e: WireFormat::parse_unchecked(buf), + d: WireFormat::parse_unchecked(buf), + h_accuracy: WireFormat::parse_unchecked(buf), + v_accuracy: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -699,124 +613,118 @@ impl crate::serialize::SbpSerialize for MsgBaselineNED { /// GPS time is given by the preceding MSG_GPS_TIME with the matching time-of- /// week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgBaselineNEDDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgBaselineNedDepA { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Baseline North coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "n")))] pub n: i32, /// Baseline East coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "e")))] pub e: i32, /// Baseline Down coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "d")))] pub d: i32, /// Horizontal position accuracy estimate (not implemented). Defaults to 0. + #[cfg_attr(feature = "serde", serde(rename(serialize = "h_accuracy")))] pub h_accuracy: u16, /// Vertical position accuracy estimate (not implemented). Defaults to 0. + #[cfg_attr(feature = "serde", serde(rename(serialize = "v_accuracy")))] pub v_accuracy: u16, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgBaselineNEDDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgBaselineNEDDepA{ - sender_id: None, - tow: _buf.read_u32::()?, - n: _buf.read_i32::()?, - e: _buf.read_i32::()?, - d: _buf.read_i32::()?, - h_accuracy: _buf.read_u16::()?, - v_accuracy: _buf.read_u16::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgBaselineNedDepA { + const MESSAGE_TYPE: u16 = 515; + const MESSAGE_NAME: &'static str = "MSG_BASELINE_NED_DEP_A"; } -impl super::SBPMessage for MsgBaselineNEDDepA { - fn get_message_name(&self) -> &'static str { - "MSG_BASELINE_NED_DEP_A" - } - fn get_message_type(&self) -> u16 { - 515 +impl SbpMessage for MsgBaselineNedDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgBaselineNEDDepA { - const MESSAGE_TYPE: u16 = 515; - const MESSAGE_NAME: &'static str = "MSG_BASELINE_NED_DEP_A"; -} -impl TryFrom for MsgBaselineNEDDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgBaselineNedDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgBaselineNEDDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgBaselineNedDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgBaselineNEDDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.n.append_to_sbp_buffer(buf); - self.e.append_to_sbp_buffer(buf); - self.d.append_to_sbp_buffer(buf); - self.h_accuracy.append_to_sbp_buffer(buf); - self.v_accuracy.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.n.sbp_size(); - size += self.e.sbp_size(); - size += self.d.sbp_size(); - size += self.h_accuracy.sbp_size(); - size += self.v_accuracy.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgBaselineNedDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.n) + + WireFormat::encoded_len(&self.e) + + WireFormat::encoded_len(&self.d) + + WireFormat::encoded_len(&self.h_accuracy) + + WireFormat::encoded_len(&self.v_accuracy) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.n, buf); + WireFormat::write(&self.e, buf); + WireFormat::write(&self.d, buf); + WireFormat::write(&self.h_accuracy, buf); + WireFormat::write(&self.v_accuracy, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgBaselineNedDepA { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + n: WireFormat::parse_unchecked(buf), + e: WireFormat::parse_unchecked(buf), + d: WireFormat::parse_unchecked(buf), + h_accuracy: WireFormat::parse_unchecked(buf), + v_accuracy: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -827,119 +735,111 @@ impl crate::serialize::SbpSerialize for MsgBaselineNEDDepA { /// flags field indicated whether the DOP reported corresponds to differential /// or SPP solution. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgDops { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Geometric Dilution of Precision + #[cfg_attr(feature = "serde", serde(rename(serialize = "gdop")))] pub gdop: u16, /// Position Dilution of Precision + #[cfg_attr(feature = "serde", serde(rename(serialize = "pdop")))] pub pdop: u16, /// Time Dilution of Precision + #[cfg_attr(feature = "serde", serde(rename(serialize = "tdop")))] pub tdop: u16, /// Horizontal Dilution of Precision + #[cfg_attr(feature = "serde", serde(rename(serialize = "hdop")))] pub hdop: u16, /// Vertical Dilution of Precision + #[cfg_attr(feature = "serde", serde(rename(serialize = "vdop")))] pub vdop: u16, /// Indicates the position solution with which the DOPS message corresponds + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgDops { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgDops{ - sender_id: None, - tow: _buf.read_u32::()?, - gdop: _buf.read_u16::()?, - pdop: _buf.read_u16::()?, - tdop: _buf.read_u16::()?, - hdop: _buf.read_u16::()?, - vdop: _buf.read_u16::()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgDops { + const MESSAGE_TYPE: u16 = 520; + const MESSAGE_NAME: &'static str = "MSG_DOPS"; } -impl super::SBPMessage for MsgDops { - fn get_message_name(&self) -> &'static str { - "MSG_DOPS" - } - fn get_message_type(&self) -> u16 { - 520 +impl SbpMessage for MsgDops { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgDops { - const MESSAGE_TYPE: u16 = 520; - const MESSAGE_NAME: &'static str = "MSG_DOPS"; -} -impl TryFrom for MsgDops { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgDops { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgDops(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgDops(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgDops { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.gdop.append_to_sbp_buffer(buf); - self.pdop.append_to_sbp_buffer(buf); - self.tdop.append_to_sbp_buffer(buf); - self.hdop.append_to_sbp_buffer(buf); - self.vdop.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.gdop.sbp_size(); - size += self.pdop.sbp_size(); - size += self.tdop.sbp_size(); - size += self.hdop.sbp_size(); - size += self.vdop.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgDops { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.gdop) + + WireFormat::encoded_len(&self.pdop) + + WireFormat::encoded_len(&self.tdop) + + WireFormat::encoded_len(&self.hdop) + + WireFormat::encoded_len(&self.vdop) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.gdop, buf); + WireFormat::write(&self.pdop, buf); + WireFormat::write(&self.tdop, buf); + WireFormat::write(&self.hdop, buf); + WireFormat::write(&self.vdop, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgDops { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + gdop: WireFormat::parse_unchecked(buf), + pdop: WireFormat::parse_unchecked(buf), + tdop: WireFormat::parse_unchecked(buf), + hdop: WireFormat::parse_unchecked(buf), + vdop: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -948,114 +848,104 @@ impl crate::serialize::SbpSerialize for MsgDops { /// This dilution of precision (DOP) message describes the effect of /// navigation satellite geometry on positional measurement precision. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgDopsDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Geometric Dilution of Precision + #[cfg_attr(feature = "serde", serde(rename(serialize = "gdop")))] pub gdop: u16, /// Position Dilution of Precision + #[cfg_attr(feature = "serde", serde(rename(serialize = "pdop")))] pub pdop: u16, /// Time Dilution of Precision + #[cfg_attr(feature = "serde", serde(rename(serialize = "tdop")))] pub tdop: u16, /// Horizontal Dilution of Precision + #[cfg_attr(feature = "serde", serde(rename(serialize = "hdop")))] pub hdop: u16, /// Vertical Dilution of Precision + #[cfg_attr(feature = "serde", serde(rename(serialize = "vdop")))] pub vdop: u16, } -impl MsgDopsDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgDopsDepA{ - sender_id: None, - tow: _buf.read_u32::()?, - gdop: _buf.read_u16::()?, - pdop: _buf.read_u16::()?, - tdop: _buf.read_u16::()?, - hdop: _buf.read_u16::()?, - vdop: _buf.read_u16::()?, - } ) - } +impl ConcreteMessage for MsgDopsDepA { + const MESSAGE_TYPE: u16 = 518; + const MESSAGE_NAME: &'static str = "MSG_DOPS_DEP_A"; } -impl super::SBPMessage for MsgDopsDepA { - fn get_message_name(&self) -> &'static str { - "MSG_DOPS_DEP_A" - } - fn get_message_type(&self) -> u16 { - 518 +impl SbpMessage for MsgDopsDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgDopsDepA { - const MESSAGE_TYPE: u16 = 518; - const MESSAGE_NAME: &'static str = "MSG_DOPS_DEP_A"; -} -impl TryFrom for MsgDopsDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgDopsDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgDopsDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgDopsDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgDopsDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.gdop.append_to_sbp_buffer(buf); - self.pdop.append_to_sbp_buffer(buf); - self.tdop.append_to_sbp_buffer(buf); - self.hdop.append_to_sbp_buffer(buf); - self.vdop.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.gdop.sbp_size(); - size += self.pdop.sbp_size(); - size += self.tdop.sbp_size(); - size += self.hdop.sbp_size(); - size += self.vdop.sbp_size(); - size +impl WireFormat for MsgDopsDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.gdop) + + WireFormat::encoded_len(&self.pdop) + + WireFormat::encoded_len(&self.tdop) + + WireFormat::encoded_len(&self.hdop) + + WireFormat::encoded_len(&self.vdop) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.gdop, buf); + WireFormat::write(&self.pdop, buf); + WireFormat::write(&self.tdop, buf); + WireFormat::write(&self.hdop, buf); + WireFormat::write(&self.vdop, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgDopsDepA { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + gdop: WireFormat::parse_unchecked(buf), + pdop: WireFormat::parse_unchecked(buf), + tdop: WireFormat::parse_unchecked(buf), + hdop: WireFormat::parse_unchecked(buf), + vdop: WireFormat::parse_unchecked(buf), + } } } @@ -1073,109 +963,96 @@ impl crate::serialize::SbpSerialize for MsgDopsDepA { /// same time (but lacking the ns field) and indicates a more precise time of /// these messages. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgGPSTime { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgGpsTime { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS week number + #[cfg_attr(feature = "serde", serde(rename(serialize = "wn")))] pub wn: u16, /// GPS time of week rounded to the nearest millisecond + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Nanosecond residual of millisecond-rounded TOW (ranges from -500000 to /// 500000) + #[cfg_attr(feature = "serde", serde(rename(serialize = "ns_residual")))] pub ns_residual: i32, /// Status flags (reserved) + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgGPSTime { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgGPSTime{ - sender_id: None, - wn: _buf.read_u16::()?, - tow: _buf.read_u32::()?, - ns_residual: _buf.read_i32::()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgGpsTime { + const MESSAGE_TYPE: u16 = 258; + const MESSAGE_NAME: &'static str = "MSG_GPS_TIME"; } -impl super::SBPMessage for MsgGPSTime { - fn get_message_name(&self) -> &'static str { - "MSG_GPS_TIME" - } - fn get_message_type(&self) -> u16 { - 258 +impl SbpMessage for MsgGpsTime { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let wn = match i16::try_from(self.wn) { + #[allow(clippy::useless_conversion)] + let wn: i16 = match self.wn.try_into() { Ok(wn) => wn, Err(e) => return Some(Err(e.into())), }; - let gps_time = match crate::time::GpsTime::new(wn, tow_s) { + let gps_time = match time::GpsTime::new(wn, tow_s) { Ok(gps_time) => gps_time, Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgGPSTime { - const MESSAGE_TYPE: u16 = 258; - const MESSAGE_NAME: &'static str = "MSG_GPS_TIME"; -} -impl TryFrom for MsgGPSTime { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgGpsTime { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgGPSTime(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgGpsTime(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgGPSTime { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.wn.append_to_sbp_buffer(buf); - self.tow.append_to_sbp_buffer(buf); - self.ns_residual.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); +impl WireFormat for MsgGpsTime { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.wn) + + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.ns_residual) + + WireFormat::encoded_len(&self.flags) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.wn.sbp_size(); - size += self.tow.sbp_size(); - size += self.ns_residual.sbp_size(); - size += self.flags.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.wn, buf); + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.ns_residual, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgGpsTime { + sender_id: None, + wn: WireFormat::parse_unchecked(buf), + tow: WireFormat::parse_unchecked(buf), + ns_residual: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -1193,109 +1070,96 @@ impl crate::serialize::SbpSerialize for MsgGPSTime { /// same time (but lacking the ns field) and indicates a more precise time of /// these messages. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgGPSTimeDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgGpsTimeDepA { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS week number + #[cfg_attr(feature = "serde", serde(rename(serialize = "wn")))] pub wn: u16, /// GPS time of week rounded to the nearest millisecond + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Nanosecond residual of millisecond-rounded TOW (ranges from -500000 to /// 500000) + #[cfg_attr(feature = "serde", serde(rename(serialize = "ns_residual")))] pub ns_residual: i32, /// Status flags (reserved) + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgGPSTimeDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgGPSTimeDepA{ - sender_id: None, - wn: _buf.read_u16::()?, - tow: _buf.read_u32::()?, - ns_residual: _buf.read_i32::()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgGpsTimeDepA { + const MESSAGE_TYPE: u16 = 256; + const MESSAGE_NAME: &'static str = "MSG_GPS_TIME_DEP_A"; } -impl super::SBPMessage for MsgGPSTimeDepA { - fn get_message_name(&self) -> &'static str { - "MSG_GPS_TIME_DEP_A" - } - fn get_message_type(&self) -> u16 { - 256 +impl SbpMessage for MsgGpsTimeDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let wn = match i16::try_from(self.wn) { + #[allow(clippy::useless_conversion)] + let wn: i16 = match self.wn.try_into() { Ok(wn) => wn, Err(e) => return Some(Err(e.into())), }; - let gps_time = match crate::time::GpsTime::new(wn, tow_s) { + let gps_time = match time::GpsTime::new(wn, tow_s) { Ok(gps_time) => gps_time, Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgGPSTimeDepA { - const MESSAGE_TYPE: u16 = 256; - const MESSAGE_NAME: &'static str = "MSG_GPS_TIME_DEP_A"; -} -impl TryFrom for MsgGPSTimeDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgGpsTimeDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgGPSTimeDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgGpsTimeDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgGPSTimeDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.wn.append_to_sbp_buffer(buf); - self.tow.append_to_sbp_buffer(buf); - self.ns_residual.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); +impl WireFormat for MsgGpsTimeDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.wn) + + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.ns_residual) + + WireFormat::encoded_len(&self.flags) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.wn.sbp_size(); - size += self.tow.sbp_size(); - size += self.ns_residual.sbp_size(); - size += self.flags.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.wn, buf); + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.ns_residual, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgGpsTimeDepA { + sender_id: None, + wn: WireFormat::parse_unchecked(buf), + tow: WireFormat::parse_unchecked(buf), + ns_residual: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -1313,109 +1177,96 @@ impl crate::serialize::SbpSerialize for MsgGPSTimeDepA { /// same time (but lacking the ns field) and indicates a more precise time of /// these messages. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgGPSTimeGnss { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgGpsTimeGnss { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS week number + #[cfg_attr(feature = "serde", serde(rename(serialize = "wn")))] pub wn: u16, /// GPS time of week rounded to the nearest millisecond + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Nanosecond residual of millisecond-rounded TOW (ranges from -500000 to /// 500000) + #[cfg_attr(feature = "serde", serde(rename(serialize = "ns_residual")))] pub ns_residual: i32, /// Status flags (reserved) + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgGPSTimeGnss { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgGPSTimeGnss{ - sender_id: None, - wn: _buf.read_u16::()?, - tow: _buf.read_u32::()?, - ns_residual: _buf.read_i32::()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgGpsTimeGnss { + const MESSAGE_TYPE: u16 = 260; + const MESSAGE_NAME: &'static str = "MSG_GPS_TIME_GNSS"; } -impl super::SBPMessage for MsgGPSTimeGnss { - fn get_message_name(&self) -> &'static str { - "MSG_GPS_TIME_GNSS" - } - fn get_message_type(&self) -> u16 { - 260 +impl SbpMessage for MsgGpsTimeGnss { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let wn = match i16::try_from(self.wn) { + #[allow(clippy::useless_conversion)] + let wn: i16 = match self.wn.try_into() { Ok(wn) => wn, Err(e) => return Some(Err(e.into())), }; - let gps_time = match crate::time::GpsTime::new(wn, tow_s) { + let gps_time = match time::GpsTime::new(wn, tow_s) { Ok(gps_time) => gps_time, Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgGPSTimeGnss { - const MESSAGE_TYPE: u16 = 260; - const MESSAGE_NAME: &'static str = "MSG_GPS_TIME_GNSS"; -} -impl TryFrom for MsgGPSTimeGnss { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgGpsTimeGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgGPSTimeGnss(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgGpsTimeGnss(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgGPSTimeGnss { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.wn.append_to_sbp_buffer(buf); - self.tow.append_to_sbp_buffer(buf); - self.ns_residual.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); +impl WireFormat for MsgGpsTimeGnss { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.wn) + + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.ns_residual) + + WireFormat::encoded_len(&self.flags) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.wn.sbp_size(); - size += self.tow.sbp_size(); - size += self.ns_residual.sbp_size(); - size += self.flags.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.wn, buf); + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.ns_residual, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgGpsTimeGnss { + sender_id: None, + wn: WireFormat::parse_unchecked(buf), + tow: WireFormat::parse_unchecked(buf), + ns_residual: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -1429,119 +1280,111 @@ impl crate::serialize::SbpSerialize for MsgGPSTimeGnss { /// RTK baseline vector. The full GPS time is given by the preceding /// MSG_GPS_TIME with the matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgPosECEF { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgPosEcef { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// ECEF X coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "x")))] pub x: f64, /// ECEF Y coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "y")))] pub y: f64, /// ECEF Z coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "z")))] pub z: f64, /// Position estimated standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "accuracy")))] pub accuracy: u16, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgPosECEF { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgPosECEF{ - sender_id: None, - tow: _buf.read_u32::()?, - x: _buf.read_f64::()?, - y: _buf.read_f64::()?, - z: _buf.read_f64::()?, - accuracy: _buf.read_u16::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgPosEcef { + const MESSAGE_TYPE: u16 = 521; + const MESSAGE_NAME: &'static str = "MSG_POS_ECEF"; } -impl super::SBPMessage for MsgPosECEF { - fn get_message_name(&self) -> &'static str { - "MSG_POS_ECEF" - } - fn get_message_type(&self) -> u16 { - 521 +impl SbpMessage for MsgPosEcef { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgPosECEF { - const MESSAGE_TYPE: u16 = 521; - const MESSAGE_NAME: &'static str = "MSG_POS_ECEF"; -} -impl TryFrom for MsgPosECEF { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgPosEcef { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgPosECEF(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgPosEcef(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgPosECEF { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.x.append_to_sbp_buffer(buf); - self.y.append_to_sbp_buffer(buf); - self.z.append_to_sbp_buffer(buf); - self.accuracy.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.x.sbp_size(); - size += self.y.sbp_size(); - size += self.z.sbp_size(); - size += self.accuracy.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgPosEcef { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.x) + + WireFormat::encoded_len(&self.y) + + WireFormat::encoded_len(&self.z) + + WireFormat::encoded_len(&self.accuracy) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.x, buf); + WireFormat::write(&self.y, buf); + WireFormat::write(&self.z, buf); + WireFormat::write(&self.accuracy, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgPosEcef { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + x: WireFormat::parse_unchecked(buf), + y: WireFormat::parse_unchecked(buf), + z: WireFormat::parse_unchecked(buf), + accuracy: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -1556,144 +1399,146 @@ impl crate::serialize::SbpSerialize for MsgPosECEF { /// rover's RTK baseline vector. The full GPS time is given by the preceding /// MSG_GPS_TIME with the matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgPosECEFCov { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgPosEcefCov { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// ECEF X coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "x")))] pub x: f64, /// ECEF Y coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "y")))] pub y: f64, /// ECEF Z coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "z")))] pub z: f64, /// Estimated variance of x + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_x_x")))] pub cov_x_x: f32, /// Estimated covariance of x and y + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_x_y")))] pub cov_x_y: f32, /// Estimated covariance of x and z + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_x_z")))] pub cov_x_z: f32, /// Estimated variance of y + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_y_y")))] pub cov_y_y: f32, /// Estimated covariance of y and z + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_y_z")))] pub cov_y_z: f32, /// Estimated variance of z + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_z_z")))] pub cov_z_z: f32, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgPosECEFCov { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgPosECEFCov{ - sender_id: None, - tow: _buf.read_u32::()?, - x: _buf.read_f64::()?, - y: _buf.read_f64::()?, - z: _buf.read_f64::()?, - cov_x_x: _buf.read_f32::()?, - cov_x_y: _buf.read_f32::()?, - cov_x_z: _buf.read_f32::()?, - cov_y_y: _buf.read_f32::()?, - cov_y_z: _buf.read_f32::()?, - cov_z_z: _buf.read_f32::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgPosEcefCov { + const MESSAGE_TYPE: u16 = 532; + const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_COV"; } -impl super::SBPMessage for MsgPosECEFCov { - fn get_message_name(&self) -> &'static str { - "MSG_POS_ECEF_COV" - } - fn get_message_type(&self) -> u16 { - 532 +impl SbpMessage for MsgPosEcefCov { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgPosECEFCov { - const MESSAGE_TYPE: u16 = 532; - const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_COV"; -} -impl TryFrom for MsgPosECEFCov { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgPosEcefCov { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgPosECEFCov(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgPosEcefCov(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgPosECEFCov { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.x.append_to_sbp_buffer(buf); - self.y.append_to_sbp_buffer(buf); - self.z.append_to_sbp_buffer(buf); - self.cov_x_x.append_to_sbp_buffer(buf); - self.cov_x_y.append_to_sbp_buffer(buf); - self.cov_x_z.append_to_sbp_buffer(buf); - self.cov_y_y.append_to_sbp_buffer(buf); - self.cov_y_z.append_to_sbp_buffer(buf); - self.cov_z_z.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.x.sbp_size(); - size += self.y.sbp_size(); - size += self.z.sbp_size(); - size += self.cov_x_x.sbp_size(); - size += self.cov_x_y.sbp_size(); - size += self.cov_x_z.sbp_size(); - size += self.cov_y_y.sbp_size(); - size += self.cov_y_z.sbp_size(); - size += self.cov_z_z.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgPosEcefCov { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.x) + + WireFormat::encoded_len(&self.y) + + WireFormat::encoded_len(&self.z) + + WireFormat::encoded_len(&self.cov_x_x) + + WireFormat::encoded_len(&self.cov_x_y) + + WireFormat::encoded_len(&self.cov_x_z) + + WireFormat::encoded_len(&self.cov_y_y) + + WireFormat::encoded_len(&self.cov_y_z) + + WireFormat::encoded_len(&self.cov_z_z) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.x, buf); + WireFormat::write(&self.y, buf); + WireFormat::write(&self.z, buf); + WireFormat::write(&self.cov_x_x, buf); + WireFormat::write(&self.cov_x_y, buf); + WireFormat::write(&self.cov_x_z, buf); + WireFormat::write(&self.cov_y_y, buf); + WireFormat::write(&self.cov_y_z, buf); + WireFormat::write(&self.cov_z_z, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgPosEcefCov { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + x: WireFormat::parse_unchecked(buf), + y: WireFormat::parse_unchecked(buf), + z: WireFormat::parse_unchecked(buf), + cov_x_x: WireFormat::parse_unchecked(buf), + cov_x_y: WireFormat::parse_unchecked(buf), + cov_x_z: WireFormat::parse_unchecked(buf), + cov_y_y: WireFormat::parse_unchecked(buf), + cov_y_z: WireFormat::parse_unchecked(buf), + cov_z_z: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -1708,144 +1553,146 @@ impl crate::serialize::SbpSerialize for MsgPosECEFCov { /// rover's RTK baseline vector. The full GPS time is given by the preceding /// MSG_GPS_TIME with the matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgPosECEFCovGnss { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgPosEcefCovGnss { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// ECEF X coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "x")))] pub x: f64, /// ECEF Y coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "y")))] pub y: f64, /// ECEF Z coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "z")))] pub z: f64, /// Estimated variance of x + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_x_x")))] pub cov_x_x: f32, /// Estimated covariance of x and y + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_x_y")))] pub cov_x_y: f32, /// Estimated covariance of x and z + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_x_z")))] pub cov_x_z: f32, /// Estimated variance of y + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_y_y")))] pub cov_y_y: f32, /// Estimated covariance of y and z + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_y_z")))] pub cov_y_z: f32, /// Estimated variance of z + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_z_z")))] pub cov_z_z: f32, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgPosECEFCovGnss { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgPosECEFCovGnss{ - sender_id: None, - tow: _buf.read_u32::()?, - x: _buf.read_f64::()?, - y: _buf.read_f64::()?, - z: _buf.read_f64::()?, - cov_x_x: _buf.read_f32::()?, - cov_x_y: _buf.read_f32::()?, - cov_x_z: _buf.read_f32::()?, - cov_y_y: _buf.read_f32::()?, - cov_y_z: _buf.read_f32::()?, - cov_z_z: _buf.read_f32::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgPosEcefCovGnss { + const MESSAGE_TYPE: u16 = 564; + const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_COV_GNSS"; } -impl super::SBPMessage for MsgPosECEFCovGnss { - fn get_message_name(&self) -> &'static str { - "MSG_POS_ECEF_COV_GNSS" - } - fn get_message_type(&self) -> u16 { - 564 +impl SbpMessage for MsgPosEcefCovGnss { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgPosECEFCovGnss { - const MESSAGE_TYPE: u16 = 564; - const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_COV_GNSS"; -} -impl TryFrom for MsgPosECEFCovGnss { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgPosEcefCovGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgPosECEFCovGnss(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgPosEcefCovGnss(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgPosECEFCovGnss { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.x.append_to_sbp_buffer(buf); - self.y.append_to_sbp_buffer(buf); - self.z.append_to_sbp_buffer(buf); - self.cov_x_x.append_to_sbp_buffer(buf); - self.cov_x_y.append_to_sbp_buffer(buf); - self.cov_x_z.append_to_sbp_buffer(buf); - self.cov_y_y.append_to_sbp_buffer(buf); - self.cov_y_z.append_to_sbp_buffer(buf); - self.cov_z_z.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.x.sbp_size(); - size += self.y.sbp_size(); - size += self.z.sbp_size(); - size += self.cov_x_x.sbp_size(); - size += self.cov_x_y.sbp_size(); - size += self.cov_x_z.sbp_size(); - size += self.cov_y_y.sbp_size(); - size += self.cov_y_z.sbp_size(); - size += self.cov_z_z.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgPosEcefCovGnss { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.x) + + WireFormat::encoded_len(&self.y) + + WireFormat::encoded_len(&self.z) + + WireFormat::encoded_len(&self.cov_x_x) + + WireFormat::encoded_len(&self.cov_x_y) + + WireFormat::encoded_len(&self.cov_x_z) + + WireFormat::encoded_len(&self.cov_y_y) + + WireFormat::encoded_len(&self.cov_y_z) + + WireFormat::encoded_len(&self.cov_z_z) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.x, buf); + WireFormat::write(&self.y, buf); + WireFormat::write(&self.z, buf); + WireFormat::write(&self.cov_x_x, buf); + WireFormat::write(&self.cov_x_y, buf); + WireFormat::write(&self.cov_x_z, buf); + WireFormat::write(&self.cov_y_y, buf); + WireFormat::write(&self.cov_y_z, buf); + WireFormat::write(&self.cov_z_z, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgPosEcefCovGnss { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + x: WireFormat::parse_unchecked(buf), + y: WireFormat::parse_unchecked(buf), + z: WireFormat::parse_unchecked(buf), + cov_x_x: WireFormat::parse_unchecked(buf), + cov_x_y: WireFormat::parse_unchecked(buf), + cov_x_z: WireFormat::parse_unchecked(buf), + cov_y_y: WireFormat::parse_unchecked(buf), + cov_y_z: WireFormat::parse_unchecked(buf), + cov_z_z: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -1859,119 +1706,111 @@ impl crate::serialize::SbpSerialize for MsgPosECEFCovGnss { /// RTK baseline vector. The full GPS time is given by the preceding /// MSG_GPS_TIME with the matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgPosECEFDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgPosEcefDepA { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// ECEF X coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "x")))] pub x: f64, /// ECEF Y coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "y")))] pub y: f64, /// ECEF Z coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "z")))] pub z: f64, /// Position accuracy estimate (not implemented). Defaults to 0. + #[cfg_attr(feature = "serde", serde(rename(serialize = "accuracy")))] pub accuracy: u16, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgPosECEFDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgPosECEFDepA{ - sender_id: None, - tow: _buf.read_u32::()?, - x: _buf.read_f64::()?, - y: _buf.read_f64::()?, - z: _buf.read_f64::()?, - accuracy: _buf.read_u16::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgPosEcefDepA { + const MESSAGE_TYPE: u16 = 512; + const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_DEP_A"; } -impl super::SBPMessage for MsgPosECEFDepA { - fn get_message_name(&self) -> &'static str { - "MSG_POS_ECEF_DEP_A" - } - fn get_message_type(&self) -> u16 { - 512 +impl SbpMessage for MsgPosEcefDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgPosECEFDepA { - const MESSAGE_TYPE: u16 = 512; - const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_DEP_A"; -} -impl TryFrom for MsgPosECEFDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgPosEcefDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgPosECEFDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgPosEcefDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgPosECEFDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.x.append_to_sbp_buffer(buf); - self.y.append_to_sbp_buffer(buf); - self.z.append_to_sbp_buffer(buf); - self.accuracy.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.x.sbp_size(); - size += self.y.sbp_size(); - size += self.z.sbp_size(); - size += self.accuracy.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgPosEcefDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.x) + + WireFormat::encoded_len(&self.y) + + WireFormat::encoded_len(&self.z) + + WireFormat::encoded_len(&self.accuracy) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.x, buf); + WireFormat::write(&self.y, buf); + WireFormat::write(&self.z, buf); + WireFormat::write(&self.accuracy, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgPosEcefDepA { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + x: WireFormat::parse_unchecked(buf), + y: WireFormat::parse_unchecked(buf), + z: WireFormat::parse_unchecked(buf), + accuracy: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -1985,119 +1824,111 @@ impl crate::serialize::SbpSerialize for MsgPosECEFDepA { /// RTK baseline vector. The full GPS time is given by the preceding /// MSG_GPS_TIME with the matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgPosECEFGnss { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgPosEcefGnss { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// ECEF X coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "x")))] pub x: f64, /// ECEF Y coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "y")))] pub y: f64, /// ECEF Z coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "z")))] pub z: f64, /// Position estimated standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "accuracy")))] pub accuracy: u16, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgPosECEFGnss { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgPosECEFGnss{ - sender_id: None, - tow: _buf.read_u32::()?, - x: _buf.read_f64::()?, - y: _buf.read_f64::()?, - z: _buf.read_f64::()?, - accuracy: _buf.read_u16::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgPosEcefGnss { + const MESSAGE_TYPE: u16 = 553; + const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_GNSS"; } -impl super::SBPMessage for MsgPosECEFGnss { - fn get_message_name(&self) -> &'static str { - "MSG_POS_ECEF_GNSS" - } - fn get_message_type(&self) -> u16 { - 553 +impl SbpMessage for MsgPosEcefGnss { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgPosECEFGnss { - const MESSAGE_TYPE: u16 = 553; - const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_GNSS"; -} -impl TryFrom for MsgPosECEFGnss { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgPosEcefGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgPosECEFGnss(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgPosEcefGnss(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgPosECEFGnss { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.x.append_to_sbp_buffer(buf); - self.y.append_to_sbp_buffer(buf); - self.z.append_to_sbp_buffer(buf); - self.accuracy.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.x.sbp_size(); - size += self.y.sbp_size(); - size += self.z.sbp_size(); - size += self.accuracy.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgPosEcefGnss { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.x) + + WireFormat::encoded_len(&self.y) + + WireFormat::encoded_len(&self.z) + + WireFormat::encoded_len(&self.accuracy) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.x, buf); + WireFormat::write(&self.y, buf); + WireFormat::write(&self.z, buf); + WireFormat::write(&self.accuracy, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgPosEcefGnss { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + x: WireFormat::parse_unchecked(buf), + y: WireFormat::parse_unchecked(buf), + z: WireFormat::parse_unchecked(buf), + accuracy: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -2111,124 +1942,118 @@ impl crate::serialize::SbpSerialize for MsgPosECEFGnss { /// vector. The full GPS time is given by the preceding MSG_GPS_TIME with the /// matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgPosLLH { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgPosLlh { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "lat")))] pub lat: f64, /// Longitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "lon")))] pub lon: f64, /// Height above WGS84 ellipsoid + #[cfg_attr(feature = "serde", serde(rename(serialize = "height")))] pub height: f64, /// Horizontal position estimated standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "h_accuracy")))] pub h_accuracy: u16, /// Vertical position estimated standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "v_accuracy")))] pub v_accuracy: u16, /// Number of satellites used in solution. + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgPosLLH { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgPosLLH{ - sender_id: None, - tow: _buf.read_u32::()?, - lat: _buf.read_f64::()?, - lon: _buf.read_f64::()?, - height: _buf.read_f64::()?, - h_accuracy: _buf.read_u16::()?, - v_accuracy: _buf.read_u16::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgPosLlh { + const MESSAGE_TYPE: u16 = 522; + const MESSAGE_NAME: &'static str = "MSG_POS_LLH"; } -impl super::SBPMessage for MsgPosLLH { - fn get_message_name(&self) -> &'static str { - "MSG_POS_LLH" - } - fn get_message_type(&self) -> u16 { - 522 +impl SbpMessage for MsgPosLlh { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgPosLLH { - const MESSAGE_TYPE: u16 = 522; - const MESSAGE_NAME: &'static str = "MSG_POS_LLH"; -} -impl TryFrom for MsgPosLLH { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgPosLlh { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgPosLLH(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgPosLlh(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgPosLLH { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.lat.append_to_sbp_buffer(buf); - self.lon.append_to_sbp_buffer(buf); - self.height.append_to_sbp_buffer(buf); - self.h_accuracy.append_to_sbp_buffer(buf); - self.v_accuracy.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.lat.sbp_size(); - size += self.lon.sbp_size(); - size += self.height.sbp_size(); - size += self.h_accuracy.sbp_size(); - size += self.v_accuracy.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgPosLlh { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.lat) + + WireFormat::encoded_len(&self.lon) + + WireFormat::encoded_len(&self.height) + + WireFormat::encoded_len(&self.h_accuracy) + + WireFormat::encoded_len(&self.v_accuracy) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.lat, buf); + WireFormat::write(&self.lon, buf); + WireFormat::write(&self.height, buf); + WireFormat::write(&self.h_accuracy, buf); + WireFormat::write(&self.v_accuracy, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgPosLlh { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + lat: WireFormat::parse_unchecked(buf), + lon: WireFormat::parse_unchecked(buf), + height: WireFormat::parse_unchecked(buf), + h_accuracy: WireFormat::parse_unchecked(buf), + v_accuracy: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -2245,157 +2070,161 @@ impl crate::serialize::SbpSerialize for MsgPosLLH { /// The estimated errors are reported at a user-configurable confidence level. /// The user-configured percentile is encoded in the percentile field. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgPosLLHAcc { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgPosLlhAcc { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "lat")))] pub lat: f64, /// Longitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "lon")))] pub lon: f64, /// Height above WGS84 ellipsoid + #[cfg_attr(feature = "serde", serde(rename(serialize = "height")))] pub height: f64, /// Height above the geoid (i.e. height above mean sea level). See /// confidence_and_geoid for geoid model used. + #[cfg_attr(feature = "serde", serde(rename(serialize = "orthometric_height")))] pub orthometric_height: f64, /// Estimated horizontal error at the user-configured confidence level; zero /// implies invalid. + #[cfg_attr(feature = "serde", serde(rename(serialize = "h_accuracy")))] pub h_accuracy: f32, /// Estimated vertical error at the user-configured confidence level; zero /// implies invalid. + #[cfg_attr(feature = "serde", serde(rename(serialize = "v_accuracy")))] pub v_accuracy: f32, /// Estimated cross-track error at the user-configured confidence level; /// zero implies invalid. + #[cfg_attr(feature = "serde", serde(rename(serialize = "ct_accuracy")))] pub ct_accuracy: f32, /// Estimated along-track error at the user-configured confidence level; /// zero implies invalid. + #[cfg_attr(feature = "serde", serde(rename(serialize = "at_accuracy")))] pub at_accuracy: f32, /// The estimated horizontal error ellipse at the user-configured confidence /// level. + #[cfg_attr(feature = "serde", serde(rename(serialize = "h_ellipse")))] pub h_ellipse: EstimatedHorizontalErrorEllipse, /// The lower bits describe the configured confidence level for the /// estimated position error. The middle bits describe the geoid model used /// to calculate the orthometric height. + #[cfg_attr(feature = "serde", serde(rename(serialize = "confidence_and_geoid")))] pub confidence_and_geoid: u8, /// Number of satellites used in solution. + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgPosLLHAcc { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgPosLLHAcc{ - sender_id: None, - tow: _buf.read_u32::()?, - lat: _buf.read_f64::()?, - lon: _buf.read_f64::()?, - height: _buf.read_f64::()?, - orthometric_height: _buf.read_f64::()?, - h_accuracy: _buf.read_f32::()?, - v_accuracy: _buf.read_f32::()?, - ct_accuracy: _buf.read_f32::()?, - at_accuracy: _buf.read_f32::()?, - h_ellipse: EstimatedHorizontalErrorEllipse::parse(_buf)?, - confidence_and_geoid: _buf.read_u8()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgPosLlhAcc { + const MESSAGE_TYPE: u16 = 536; + const MESSAGE_NAME: &'static str = "MSG_POS_LLH_ACC"; } -impl super::SBPMessage for MsgPosLLHAcc { - fn get_message_name(&self) -> &'static str { - "MSG_POS_LLH_ACC" - } - fn get_message_type(&self) -> u16 { - 536 +impl SbpMessage for MsgPosLlhAcc { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgPosLLHAcc { - const MESSAGE_TYPE: u16 = 536; - const MESSAGE_NAME: &'static str = "MSG_POS_LLH_ACC"; -} -impl TryFrom for MsgPosLLHAcc { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgPosLlhAcc { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgPosLLHAcc(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgPosLlhAcc(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgPosLLHAcc { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.lat.append_to_sbp_buffer(buf); - self.lon.append_to_sbp_buffer(buf); - self.height.append_to_sbp_buffer(buf); - self.orthometric_height.append_to_sbp_buffer(buf); - self.h_accuracy.append_to_sbp_buffer(buf); - self.v_accuracy.append_to_sbp_buffer(buf); - self.ct_accuracy.append_to_sbp_buffer(buf); - self.at_accuracy.append_to_sbp_buffer(buf); - self.h_ellipse.append_to_sbp_buffer(buf); - self.confidence_and_geoid.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.lat.sbp_size(); - size += self.lon.sbp_size(); - size += self.height.sbp_size(); - size += self.orthometric_height.sbp_size(); - size += self.h_accuracy.sbp_size(); - size += self.v_accuracy.sbp_size(); - size += self.ct_accuracy.sbp_size(); - size += self.at_accuracy.sbp_size(); - size += self.h_ellipse.sbp_size(); - size += self.confidence_and_geoid.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgPosLlhAcc { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.lat) + + WireFormat::encoded_len(&self.lon) + + WireFormat::encoded_len(&self.height) + + WireFormat::encoded_len(&self.orthometric_height) + + WireFormat::encoded_len(&self.h_accuracy) + + WireFormat::encoded_len(&self.v_accuracy) + + WireFormat::encoded_len(&self.ct_accuracy) + + WireFormat::encoded_len(&self.at_accuracy) + + WireFormat::encoded_len(&self.h_ellipse) + + WireFormat::encoded_len(&self.confidence_and_geoid) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.lat, buf); + WireFormat::write(&self.lon, buf); + WireFormat::write(&self.height, buf); + WireFormat::write(&self.orthometric_height, buf); + WireFormat::write(&self.h_accuracy, buf); + WireFormat::write(&self.v_accuracy, buf); + WireFormat::write(&self.ct_accuracy, buf); + WireFormat::write(&self.at_accuracy, buf); + WireFormat::write(&self.h_ellipse, buf); + WireFormat::write(&self.confidence_and_geoid, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgPosLlhAcc { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + lat: WireFormat::parse_unchecked(buf), + lon: WireFormat::parse_unchecked(buf), + height: WireFormat::parse_unchecked(buf), + orthometric_height: WireFormat::parse_unchecked(buf), + h_accuracy: WireFormat::parse_unchecked(buf), + v_accuracy: WireFormat::parse_unchecked(buf), + ct_accuracy: WireFormat::parse_unchecked(buf), + at_accuracy: WireFormat::parse_unchecked(buf), + h_ellipse: WireFormat::parse_unchecked(buf), + confidence_and_geoid: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -2410,144 +2239,146 @@ impl crate::serialize::SbpSerialize for MsgPosLLHAcc { /// are reported against the "downward" measurement and care should be taken /// with the sign convention. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgPosLLHCov { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgPosLlhCov { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "lat")))] pub lat: f64, /// Longitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "lon")))] pub lon: f64, /// Height above WGS84 ellipsoid + #[cfg_attr(feature = "serde", serde(rename(serialize = "height")))] pub height: f64, /// Estimated variance of northing + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_n_n")))] pub cov_n_n: f32, /// Covariance of northing and easting + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_n_e")))] pub cov_n_e: f32, /// Covariance of northing and downward measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_n_d")))] pub cov_n_d: f32, /// Estimated variance of easting + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_e_e")))] pub cov_e_e: f32, /// Covariance of easting and downward measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_e_d")))] pub cov_e_d: f32, /// Estimated variance of downward measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_d_d")))] pub cov_d_d: f32, /// Number of satellites used in solution. + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgPosLLHCov { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgPosLLHCov{ - sender_id: None, - tow: _buf.read_u32::()?, - lat: _buf.read_f64::()?, - lon: _buf.read_f64::()?, - height: _buf.read_f64::()?, - cov_n_n: _buf.read_f32::()?, - cov_n_e: _buf.read_f32::()?, - cov_n_d: _buf.read_f32::()?, - cov_e_e: _buf.read_f32::()?, - cov_e_d: _buf.read_f32::()?, - cov_d_d: _buf.read_f32::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgPosLlhCov { + const MESSAGE_TYPE: u16 = 529; + const MESSAGE_NAME: &'static str = "MSG_POS_LLH_COV"; } -impl super::SBPMessage for MsgPosLLHCov { - fn get_message_name(&self) -> &'static str { - "MSG_POS_LLH_COV" - } - fn get_message_type(&self) -> u16 { - 529 +impl SbpMessage for MsgPosLlhCov { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgPosLLHCov { - const MESSAGE_TYPE: u16 = 529; - const MESSAGE_NAME: &'static str = "MSG_POS_LLH_COV"; -} -impl TryFrom for MsgPosLLHCov { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgPosLlhCov { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgPosLLHCov(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgPosLlhCov(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgPosLLHCov { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.lat.append_to_sbp_buffer(buf); - self.lon.append_to_sbp_buffer(buf); - self.height.append_to_sbp_buffer(buf); - self.cov_n_n.append_to_sbp_buffer(buf); - self.cov_n_e.append_to_sbp_buffer(buf); - self.cov_n_d.append_to_sbp_buffer(buf); - self.cov_e_e.append_to_sbp_buffer(buf); - self.cov_e_d.append_to_sbp_buffer(buf); - self.cov_d_d.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.lat.sbp_size(); - size += self.lon.sbp_size(); - size += self.height.sbp_size(); - size += self.cov_n_n.sbp_size(); - size += self.cov_n_e.sbp_size(); - size += self.cov_n_d.sbp_size(); - size += self.cov_e_e.sbp_size(); - size += self.cov_e_d.sbp_size(); - size += self.cov_d_d.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgPosLlhCov { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.lat) + + WireFormat::encoded_len(&self.lon) + + WireFormat::encoded_len(&self.height) + + WireFormat::encoded_len(&self.cov_n_n) + + WireFormat::encoded_len(&self.cov_n_e) + + WireFormat::encoded_len(&self.cov_n_d) + + WireFormat::encoded_len(&self.cov_e_e) + + WireFormat::encoded_len(&self.cov_e_d) + + WireFormat::encoded_len(&self.cov_d_d) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.lat, buf); + WireFormat::write(&self.lon, buf); + WireFormat::write(&self.height, buf); + WireFormat::write(&self.cov_n_n, buf); + WireFormat::write(&self.cov_n_e, buf); + WireFormat::write(&self.cov_n_d, buf); + WireFormat::write(&self.cov_e_e, buf); + WireFormat::write(&self.cov_e_d, buf); + WireFormat::write(&self.cov_d_d, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgPosLlhCov { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + lat: WireFormat::parse_unchecked(buf), + lon: WireFormat::parse_unchecked(buf), + height: WireFormat::parse_unchecked(buf), + cov_n_n: WireFormat::parse_unchecked(buf), + cov_n_e: WireFormat::parse_unchecked(buf), + cov_n_d: WireFormat::parse_unchecked(buf), + cov_e_e: WireFormat::parse_unchecked(buf), + cov_e_d: WireFormat::parse_unchecked(buf), + cov_d_d: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -2562,144 +2393,146 @@ impl crate::serialize::SbpSerialize for MsgPosLLHCov { /// Thus, covariances are reported against the "downward" measurement and care /// should be taken with the sign convention. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgPosLLHCovGnss { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgPosLlhCovGnss { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "lat")))] pub lat: f64, /// Longitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "lon")))] pub lon: f64, /// Height above WGS84 ellipsoid + #[cfg_attr(feature = "serde", serde(rename(serialize = "height")))] pub height: f64, /// Estimated variance of northing + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_n_n")))] pub cov_n_n: f32, /// Covariance of northing and easting + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_n_e")))] pub cov_n_e: f32, /// Covariance of northing and downward measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_n_d")))] pub cov_n_d: f32, /// Estimated variance of easting + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_e_e")))] pub cov_e_e: f32, /// Covariance of easting and downward measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_e_d")))] pub cov_e_d: f32, /// Estimated variance of downward measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_d_d")))] pub cov_d_d: f32, /// Number of satellites used in solution. + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgPosLLHCovGnss { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgPosLLHCovGnss{ - sender_id: None, - tow: _buf.read_u32::()?, - lat: _buf.read_f64::()?, - lon: _buf.read_f64::()?, - height: _buf.read_f64::()?, - cov_n_n: _buf.read_f32::()?, - cov_n_e: _buf.read_f32::()?, - cov_n_d: _buf.read_f32::()?, - cov_e_e: _buf.read_f32::()?, - cov_e_d: _buf.read_f32::()?, - cov_d_d: _buf.read_f32::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgPosLlhCovGnss { + const MESSAGE_TYPE: u16 = 561; + const MESSAGE_NAME: &'static str = "MSG_POS_LLH_COV_GNSS"; } -impl super::SBPMessage for MsgPosLLHCovGnss { - fn get_message_name(&self) -> &'static str { - "MSG_POS_LLH_COV_GNSS" - } - fn get_message_type(&self) -> u16 { - 561 +impl SbpMessage for MsgPosLlhCovGnss { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgPosLLHCovGnss { - const MESSAGE_TYPE: u16 = 561; - const MESSAGE_NAME: &'static str = "MSG_POS_LLH_COV_GNSS"; -} -impl TryFrom for MsgPosLLHCovGnss { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgPosLlhCovGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgPosLLHCovGnss(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgPosLlhCovGnss(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgPosLLHCovGnss { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.lat.append_to_sbp_buffer(buf); - self.lon.append_to_sbp_buffer(buf); - self.height.append_to_sbp_buffer(buf); - self.cov_n_n.append_to_sbp_buffer(buf); - self.cov_n_e.append_to_sbp_buffer(buf); - self.cov_n_d.append_to_sbp_buffer(buf); - self.cov_e_e.append_to_sbp_buffer(buf); - self.cov_e_d.append_to_sbp_buffer(buf); - self.cov_d_d.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.lat.sbp_size(); - size += self.lon.sbp_size(); - size += self.height.sbp_size(); - size += self.cov_n_n.sbp_size(); - size += self.cov_n_e.sbp_size(); - size += self.cov_n_d.sbp_size(); - size += self.cov_e_e.sbp_size(); - size += self.cov_e_d.sbp_size(); - size += self.cov_d_d.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgPosLlhCovGnss { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.lat) + + WireFormat::encoded_len(&self.lon) + + WireFormat::encoded_len(&self.height) + + WireFormat::encoded_len(&self.cov_n_n) + + WireFormat::encoded_len(&self.cov_n_e) + + WireFormat::encoded_len(&self.cov_n_d) + + WireFormat::encoded_len(&self.cov_e_e) + + WireFormat::encoded_len(&self.cov_e_d) + + WireFormat::encoded_len(&self.cov_d_d) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.lat, buf); + WireFormat::write(&self.lon, buf); + WireFormat::write(&self.height, buf); + WireFormat::write(&self.cov_n_n, buf); + WireFormat::write(&self.cov_n_e, buf); + WireFormat::write(&self.cov_n_d, buf); + WireFormat::write(&self.cov_e_e, buf); + WireFormat::write(&self.cov_e_d, buf); + WireFormat::write(&self.cov_d_d, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgPosLlhCovGnss { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + lat: WireFormat::parse_unchecked(buf), + lon: WireFormat::parse_unchecked(buf), + height: WireFormat::parse_unchecked(buf), + cov_n_n: WireFormat::parse_unchecked(buf), + cov_n_e: WireFormat::parse_unchecked(buf), + cov_n_d: WireFormat::parse_unchecked(buf), + cov_e_e: WireFormat::parse_unchecked(buf), + cov_e_d: WireFormat::parse_unchecked(buf), + cov_d_d: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -2713,124 +2546,118 @@ impl crate::serialize::SbpSerialize for MsgPosLLHCovGnss { /// vector. The full GPS time is given by the preceding MSG_GPS_TIME with the /// matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgPosLLHDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgPosLlhDepA { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "lat")))] pub lat: f64, /// Longitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "lon")))] pub lon: f64, /// Height + #[cfg_attr(feature = "serde", serde(rename(serialize = "height")))] pub height: f64, /// Horizontal position accuracy estimate (not implemented). Defaults to 0. + #[cfg_attr(feature = "serde", serde(rename(serialize = "h_accuracy")))] pub h_accuracy: u16, /// Vertical position accuracy estimate (not implemented). Defaults to 0. + #[cfg_attr(feature = "serde", serde(rename(serialize = "v_accuracy")))] pub v_accuracy: u16, /// Number of satellites used in solution. + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgPosLLHDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgPosLLHDepA{ - sender_id: None, - tow: _buf.read_u32::()?, - lat: _buf.read_f64::()?, - lon: _buf.read_f64::()?, - height: _buf.read_f64::()?, - h_accuracy: _buf.read_u16::()?, - v_accuracy: _buf.read_u16::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgPosLlhDepA { + const MESSAGE_TYPE: u16 = 513; + const MESSAGE_NAME: &'static str = "MSG_POS_LLH_DEP_A"; } -impl super::SBPMessage for MsgPosLLHDepA { - fn get_message_name(&self) -> &'static str { - "MSG_POS_LLH_DEP_A" - } - fn get_message_type(&self) -> u16 { - 513 +impl SbpMessage for MsgPosLlhDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgPosLLHDepA { - const MESSAGE_TYPE: u16 = 513; - const MESSAGE_NAME: &'static str = "MSG_POS_LLH_DEP_A"; -} -impl TryFrom for MsgPosLLHDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgPosLlhDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgPosLLHDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgPosLlhDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgPosLLHDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.lat.append_to_sbp_buffer(buf); - self.lon.append_to_sbp_buffer(buf); - self.height.append_to_sbp_buffer(buf); - self.h_accuracy.append_to_sbp_buffer(buf); - self.v_accuracy.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.lat.sbp_size(); - size += self.lon.sbp_size(); - size += self.height.sbp_size(); - size += self.h_accuracy.sbp_size(); - size += self.v_accuracy.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgPosLlhDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.lat) + + WireFormat::encoded_len(&self.lon) + + WireFormat::encoded_len(&self.height) + + WireFormat::encoded_len(&self.h_accuracy) + + WireFormat::encoded_len(&self.v_accuracy) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.lat, buf); + WireFormat::write(&self.lon, buf); + WireFormat::write(&self.height, buf); + WireFormat::write(&self.h_accuracy, buf); + WireFormat::write(&self.v_accuracy, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgPosLlhDepA { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + lat: WireFormat::parse_unchecked(buf), + lon: WireFormat::parse_unchecked(buf), + height: WireFormat::parse_unchecked(buf), + h_accuracy: WireFormat::parse_unchecked(buf), + v_accuracy: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -2844,124 +2671,118 @@ impl crate::serialize::SbpSerialize for MsgPosLLHDepA { /// vector. The full GPS time is given by the preceding MSG_GPS_TIME with the /// matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgPosLLHGnss { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgPosLlhGnss { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "lat")))] pub lat: f64, /// Longitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "lon")))] pub lon: f64, /// Height above WGS84 ellipsoid + #[cfg_attr(feature = "serde", serde(rename(serialize = "height")))] pub height: f64, /// Horizontal position estimated standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "h_accuracy")))] pub h_accuracy: u16, /// Vertical position estimated standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "v_accuracy")))] pub v_accuracy: u16, /// Number of satellites used in solution. + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgPosLLHGnss { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgPosLLHGnss{ - sender_id: None, - tow: _buf.read_u32::()?, - lat: _buf.read_f64::()?, - lon: _buf.read_f64::()?, - height: _buf.read_f64::()?, - h_accuracy: _buf.read_u16::()?, - v_accuracy: _buf.read_u16::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgPosLlhGnss { + const MESSAGE_TYPE: u16 = 554; + const MESSAGE_NAME: &'static str = "MSG_POS_LLH_GNSS"; } -impl super::SBPMessage for MsgPosLLHGnss { - fn get_message_name(&self) -> &'static str { - "MSG_POS_LLH_GNSS" - } - fn get_message_type(&self) -> u16 { - 554 +impl SbpMessage for MsgPosLlhGnss { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgPosLLHGnss { - const MESSAGE_TYPE: u16 = 554; - const MESSAGE_NAME: &'static str = "MSG_POS_LLH_GNSS"; -} -impl TryFrom for MsgPosLLHGnss { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgPosLlhGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgPosLLHGnss(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgPosLlhGnss(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgPosLLHGnss { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.lat.append_to_sbp_buffer(buf); - self.lon.append_to_sbp_buffer(buf); - self.height.append_to_sbp_buffer(buf); - self.h_accuracy.append_to_sbp_buffer(buf); - self.v_accuracy.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.lat.sbp_size(); - size += self.lon.sbp_size(); - size += self.height.sbp_size(); - size += self.h_accuracy.sbp_size(); - size += self.v_accuracy.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgPosLlhGnss { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.lat) + + WireFormat::encoded_len(&self.lon) + + WireFormat::encoded_len(&self.height) + + WireFormat::encoded_len(&self.h_accuracy) + + WireFormat::encoded_len(&self.v_accuracy) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.lat, buf); + WireFormat::write(&self.lon, buf); + WireFormat::write(&self.height, buf); + WireFormat::write(&self.h_accuracy, buf); + WireFormat::write(&self.v_accuracy, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgPosLlhGnss { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + lat: WireFormat::parse_unchecked(buf), + lon: WireFormat::parse_unchecked(buf), + height: WireFormat::parse_unchecked(buf), + h_accuracy: WireFormat::parse_unchecked(buf), + v_accuracy: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -2971,195 +2792,216 @@ impl crate::serialize::SbpSerialize for MsgPosLLHGnss { /// estimate. The full GPS time is given by the preceding MSG_GPS_TIME with /// the matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgProtectionLevel { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// GPS week number + #[cfg_attr(feature = "serde", serde(rename(serialize = "wn")))] pub wn: i16, /// Horizontal protection level + #[cfg_attr(feature = "serde", serde(rename(serialize = "hpl")))] pub hpl: u16, /// Vertical protection level + #[cfg_attr(feature = "serde", serde(rename(serialize = "vpl")))] pub vpl: u16, /// Along-track position error protection level + #[cfg_attr(feature = "serde", serde(rename(serialize = "atpl")))] pub atpl: u16, /// Cross-track position error protection level + #[cfg_attr(feature = "serde", serde(rename(serialize = "ctpl")))] pub ctpl: u16, /// Protection level for the error vector between estimated and true /// along/cross track velocity vector + #[cfg_attr(feature = "serde", serde(rename(serialize = "hvpl")))] pub hvpl: u16, /// Protection level for the velocity in vehicle upright direction /// (different from vertical direction if on a slope) + #[cfg_attr(feature = "serde", serde(rename(serialize = "vvpl")))] pub vvpl: u16, /// Heading orientation protection level + #[cfg_attr(feature = "serde", serde(rename(serialize = "hopl")))] pub hopl: u16, /// Pitch orientation protection level + #[cfg_attr(feature = "serde", serde(rename(serialize = "popl")))] pub popl: u16, /// Roll orientation protection level + #[cfg_attr(feature = "serde", serde(rename(serialize = "ropl")))] pub ropl: u16, /// Latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "lat")))] pub lat: f64, /// Longitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "lon")))] pub lon: f64, /// Height + #[cfg_attr(feature = "serde", serde(rename(serialize = "height")))] pub height: f64, /// Velocity in vehicle x direction + #[cfg_attr(feature = "serde", serde(rename(serialize = "v_x")))] pub v_x: i32, /// Velocity in vehicle y direction + #[cfg_attr(feature = "serde", serde(rename(serialize = "v_y")))] pub v_y: i32, /// Velocity in vehicle z direction + #[cfg_attr(feature = "serde", serde(rename(serialize = "v_z")))] pub v_z: i32, /// Roll angle + #[cfg_attr(feature = "serde", serde(rename(serialize = "roll")))] pub roll: i32, /// Pitch angle + #[cfg_attr(feature = "serde", serde(rename(serialize = "pitch")))] pub pitch: i32, /// Heading angle + #[cfg_attr(feature = "serde", serde(rename(serialize = "heading")))] pub heading: i32, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u32, } -impl MsgProtectionLevel { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgProtectionLevel{ - sender_id: None, - tow: _buf.read_u32::()?, - wn: _buf.read_i16::()?, - hpl: _buf.read_u16::()?, - vpl: _buf.read_u16::()?, - atpl: _buf.read_u16::()?, - ctpl: _buf.read_u16::()?, - hvpl: _buf.read_u16::()?, - vvpl: _buf.read_u16::()?, - hopl: _buf.read_u16::()?, - popl: _buf.read_u16::()?, - ropl: _buf.read_u16::()?, - lat: _buf.read_f64::()?, - lon: _buf.read_f64::()?, - height: _buf.read_f64::()?, - v_x: _buf.read_i32::()?, - v_y: _buf.read_i32::()?, - v_z: _buf.read_i32::()?, - roll: _buf.read_i32::()?, - pitch: _buf.read_i32::()?, - heading: _buf.read_i32::()?, - flags: _buf.read_u32::()?, - } ) - } -} -impl super::SBPMessage for MsgProtectionLevel { - fn get_message_name(&self) -> &'static str { - "MSG_PROTECTION_LEVEL" - } - - fn get_message_type(&self) -> u16 { - 535 - } - - fn get_sender_id(&self) -> Option { +impl ConcreteMessage for MsgProtectionLevel { + const MESSAGE_TYPE: u16 = 535; + const MESSAGE_NAME: &'static str = "MSG_PROTECTION_LEVEL"; +} + +impl SbpMessage for MsgProtectionLevel { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME + } + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let wn = match i16::try_from(self.wn) { + #[allow(clippy::useless_conversion)] + let wn: i16 = match self.wn.try_into() { Ok(wn) => wn, Err(e) => return Some(Err(e.into())), }; - let gps_time = match crate::time::GpsTime::new(wn, tow_s) { + let gps_time = match time::GpsTime::new(wn, tow_s) { Ok(gps_time) => gps_time, Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgProtectionLevel { - const MESSAGE_TYPE: u16 = 535; - const MESSAGE_NAME: &'static str = "MSG_PROTECTION_LEVEL"; -} -impl TryFrom for MsgProtectionLevel { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgProtectionLevel { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgProtectionLevel(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgProtectionLevel(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgProtectionLevel { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.wn.append_to_sbp_buffer(buf); - self.hpl.append_to_sbp_buffer(buf); - self.vpl.append_to_sbp_buffer(buf); - self.atpl.append_to_sbp_buffer(buf); - self.ctpl.append_to_sbp_buffer(buf); - self.hvpl.append_to_sbp_buffer(buf); - self.vvpl.append_to_sbp_buffer(buf); - self.hopl.append_to_sbp_buffer(buf); - self.popl.append_to_sbp_buffer(buf); - self.ropl.append_to_sbp_buffer(buf); - self.lat.append_to_sbp_buffer(buf); - self.lon.append_to_sbp_buffer(buf); - self.height.append_to_sbp_buffer(buf); - self.v_x.append_to_sbp_buffer(buf); - self.v_y.append_to_sbp_buffer(buf); - self.v_z.append_to_sbp_buffer(buf); - self.roll.append_to_sbp_buffer(buf); - self.pitch.append_to_sbp_buffer(buf); - self.heading.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.wn.sbp_size(); - size += self.hpl.sbp_size(); - size += self.vpl.sbp_size(); - size += self.atpl.sbp_size(); - size += self.ctpl.sbp_size(); - size += self.hvpl.sbp_size(); - size += self.vvpl.sbp_size(); - size += self.hopl.sbp_size(); - size += self.popl.sbp_size(); - size += self.ropl.sbp_size(); - size += self.lat.sbp_size(); - size += self.lon.sbp_size(); - size += self.height.sbp_size(); - size += self.v_x.sbp_size(); - size += self.v_y.sbp_size(); - size += self.v_z.sbp_size(); - size += self.roll.sbp_size(); - size += self.pitch.sbp_size(); - size += self.heading.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgProtectionLevel { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.wn) + + WireFormat::encoded_len(&self.hpl) + + WireFormat::encoded_len(&self.vpl) + + WireFormat::encoded_len(&self.atpl) + + WireFormat::encoded_len(&self.ctpl) + + WireFormat::encoded_len(&self.hvpl) + + WireFormat::encoded_len(&self.vvpl) + + WireFormat::encoded_len(&self.hopl) + + WireFormat::encoded_len(&self.popl) + + WireFormat::encoded_len(&self.ropl) + + WireFormat::encoded_len(&self.lat) + + WireFormat::encoded_len(&self.lon) + + WireFormat::encoded_len(&self.height) + + WireFormat::encoded_len(&self.v_x) + + WireFormat::encoded_len(&self.v_y) + + WireFormat::encoded_len(&self.v_z) + + WireFormat::encoded_len(&self.roll) + + WireFormat::encoded_len(&self.pitch) + + WireFormat::encoded_len(&self.heading) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.wn, buf); + WireFormat::write(&self.hpl, buf); + WireFormat::write(&self.vpl, buf); + WireFormat::write(&self.atpl, buf); + WireFormat::write(&self.ctpl, buf); + WireFormat::write(&self.hvpl, buf); + WireFormat::write(&self.vvpl, buf); + WireFormat::write(&self.hopl, buf); + WireFormat::write(&self.popl, buf); + WireFormat::write(&self.ropl, buf); + WireFormat::write(&self.lat, buf); + WireFormat::write(&self.lon, buf); + WireFormat::write(&self.height, buf); + WireFormat::write(&self.v_x, buf); + WireFormat::write(&self.v_y, buf); + WireFormat::write(&self.v_z, buf); + WireFormat::write(&self.roll, buf); + WireFormat::write(&self.pitch, buf); + WireFormat::write(&self.heading, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgProtectionLevel { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + wn: WireFormat::parse_unchecked(buf), + hpl: WireFormat::parse_unchecked(buf), + vpl: WireFormat::parse_unchecked(buf), + atpl: WireFormat::parse_unchecked(buf), + ctpl: WireFormat::parse_unchecked(buf), + hvpl: WireFormat::parse_unchecked(buf), + vvpl: WireFormat::parse_unchecked(buf), + hopl: WireFormat::parse_unchecked(buf), + popl: WireFormat::parse_unchecked(buf), + ropl: WireFormat::parse_unchecked(buf), + lat: WireFormat::parse_unchecked(buf), + lon: WireFormat::parse_unchecked(buf), + height: WireFormat::parse_unchecked(buf), + v_x: WireFormat::parse_unchecked(buf), + v_y: WireFormat::parse_unchecked(buf), + v_z: WireFormat::parse_unchecked(buf), + roll: WireFormat::parse_unchecked(buf), + pitch: WireFormat::parse_unchecked(buf), + heading: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -3169,119 +3011,111 @@ impl crate::serialize::SbpSerialize for MsgProtectionLevel { /// associated with a given LLH position solution. The full GPS time is given /// by the preceding MSG_GPS_TIME with the matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgProtectionLevelDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Vertical protection level + #[cfg_attr(feature = "serde", serde(rename(serialize = "vpl")))] pub vpl: u16, /// Horizontal protection level + #[cfg_attr(feature = "serde", serde(rename(serialize = "hpl")))] pub hpl: u16, /// Latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "lat")))] pub lat: f64, /// Longitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "lon")))] pub lon: f64, /// Height + #[cfg_attr(feature = "serde", serde(rename(serialize = "height")))] pub height: f64, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgProtectionLevelDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgProtectionLevelDepA{ - sender_id: None, - tow: _buf.read_u32::()?, - vpl: _buf.read_u16::()?, - hpl: _buf.read_u16::()?, - lat: _buf.read_f64::()?, - lon: _buf.read_f64::()?, - height: _buf.read_f64::()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgProtectionLevelDepA { + const MESSAGE_TYPE: u16 = 534; + const MESSAGE_NAME: &'static str = "MSG_PROTECTION_LEVEL_DEP_A"; } -impl super::SBPMessage for MsgProtectionLevelDepA { - fn get_message_name(&self) -> &'static str { - "MSG_PROTECTION_LEVEL_DEP_A" - } - fn get_message_type(&self) -> u16 { - 534 +impl SbpMessage for MsgProtectionLevelDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgProtectionLevelDepA { - const MESSAGE_TYPE: u16 = 534; - const MESSAGE_NAME: &'static str = "MSG_PROTECTION_LEVEL_DEP_A"; -} -impl TryFrom for MsgProtectionLevelDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgProtectionLevelDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgProtectionLevelDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgProtectionLevelDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgProtectionLevelDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.vpl.append_to_sbp_buffer(buf); - self.hpl.append_to_sbp_buffer(buf); - self.lat.append_to_sbp_buffer(buf); - self.lon.append_to_sbp_buffer(buf); - self.height.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.vpl.sbp_size(); - size += self.hpl.sbp_size(); - size += self.lat.sbp_size(); - size += self.lon.sbp_size(); - size += self.height.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgProtectionLevelDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.vpl) + + WireFormat::encoded_len(&self.hpl) + + WireFormat::encoded_len(&self.lat) + + WireFormat::encoded_len(&self.lon) + + WireFormat::encoded_len(&self.height) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.vpl, buf); + WireFormat::write(&self.hpl, buf); + WireFormat::write(&self.lat, buf); + WireFormat::write(&self.lon, buf); + WireFormat::write(&self.height, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgProtectionLevelDepA { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + vpl: WireFormat::parse_unchecked(buf), + hpl: WireFormat::parse_unchecked(buf), + lat: WireFormat::parse_unchecked(buf), + lon: WireFormat::parse_unchecked(buf), + height: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -3291,129 +3125,125 @@ impl crate::serialize::SbpSerialize for MsgProtectionLevelDepA { /// which indicate the source of the UTC offset value and source of the time /// fix. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgUtcTime { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Indicates source and time validity + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, /// GPS time of week rounded to the nearest millisecond + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Year + #[cfg_attr(feature = "serde", serde(rename(serialize = "year")))] pub year: u16, /// Month (range 1 .. 12) + #[cfg_attr(feature = "serde", serde(rename(serialize = "month")))] pub month: u8, /// days in the month (range 1-31) + #[cfg_attr(feature = "serde", serde(rename(serialize = "day")))] pub day: u8, /// hours of day (range 0-23) + #[cfg_attr(feature = "serde", serde(rename(serialize = "hours")))] pub hours: u8, /// minutes of hour (range 0-59) + #[cfg_attr(feature = "serde", serde(rename(serialize = "minutes")))] pub minutes: u8, /// seconds of minute (range 0-60) rounded down + #[cfg_attr(feature = "serde", serde(rename(serialize = "seconds")))] pub seconds: u8, /// nanoseconds of second (range 0-999999999) + #[cfg_attr(feature = "serde", serde(rename(serialize = "ns")))] pub ns: u32, } -impl MsgUtcTime { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgUtcTime{ - sender_id: None, - flags: _buf.read_u8()?, - tow: _buf.read_u32::()?, - year: _buf.read_u16::()?, - month: _buf.read_u8()?, - day: _buf.read_u8()?, - hours: _buf.read_u8()?, - minutes: _buf.read_u8()?, - seconds: _buf.read_u8()?, - ns: _buf.read_u32::()?, - } ) - } +impl ConcreteMessage for MsgUtcTime { + const MESSAGE_TYPE: u16 = 259; + const MESSAGE_NAME: &'static str = "MSG_UTC_TIME"; } -impl super::SBPMessage for MsgUtcTime { - fn get_message_name(&self) -> &'static str { - "MSG_UTC_TIME" - } - fn get_message_type(&self) -> u16 { - 259 +impl SbpMessage for MsgUtcTime { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgUtcTime { - const MESSAGE_TYPE: u16 = 259; - const MESSAGE_NAME: &'static str = "MSG_UTC_TIME"; -} -impl TryFrom for MsgUtcTime { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgUtcTime { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgUtcTime(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgUtcTime(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgUtcTime { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.flags.append_to_sbp_buffer(buf); - self.tow.append_to_sbp_buffer(buf); - self.year.append_to_sbp_buffer(buf); - self.month.append_to_sbp_buffer(buf); - self.day.append_to_sbp_buffer(buf); - self.hours.append_to_sbp_buffer(buf); - self.minutes.append_to_sbp_buffer(buf); - self.seconds.append_to_sbp_buffer(buf); - self.ns.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.flags.sbp_size(); - size += self.tow.sbp_size(); - size += self.year.sbp_size(); - size += self.month.sbp_size(); - size += self.day.sbp_size(); - size += self.hours.sbp_size(); - size += self.minutes.sbp_size(); - size += self.seconds.sbp_size(); - size += self.ns.sbp_size(); - size +impl WireFormat for MsgUtcTime { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.flags) + + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.year) + + WireFormat::encoded_len(&self.month) + + WireFormat::encoded_len(&self.day) + + WireFormat::encoded_len(&self.hours) + + WireFormat::encoded_len(&self.minutes) + + WireFormat::encoded_len(&self.seconds) + + WireFormat::encoded_len(&self.ns) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.flags, buf); + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.year, buf); + WireFormat::write(&self.month, buf); + WireFormat::write(&self.day, buf); + WireFormat::write(&self.hours, buf); + WireFormat::write(&self.minutes, buf); + WireFormat::write(&self.seconds, buf); + WireFormat::write(&self.ns, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgUtcTime { + sender_id: None, + flags: WireFormat::parse_unchecked(buf), + tow: WireFormat::parse_unchecked(buf), + year: WireFormat::parse_unchecked(buf), + month: WireFormat::parse_unchecked(buf), + day: WireFormat::parse_unchecked(buf), + hours: WireFormat::parse_unchecked(buf), + minutes: WireFormat::parse_unchecked(buf), + seconds: WireFormat::parse_unchecked(buf), + ns: WireFormat::parse_unchecked(buf), + } } } @@ -3423,129 +3253,125 @@ impl crate::serialize::SbpSerialize for MsgUtcTime { /// which indicate the source of the UTC offset value and source of the time /// fix. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgUtcTimeGnss { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Indicates source and time validity + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, /// GPS time of week rounded to the nearest millisecond + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Year + #[cfg_attr(feature = "serde", serde(rename(serialize = "year")))] pub year: u16, /// Month (range 1 .. 12) + #[cfg_attr(feature = "serde", serde(rename(serialize = "month")))] pub month: u8, /// days in the month (range 1-31) + #[cfg_attr(feature = "serde", serde(rename(serialize = "day")))] pub day: u8, /// hours of day (range 0-23) + #[cfg_attr(feature = "serde", serde(rename(serialize = "hours")))] pub hours: u8, /// minutes of hour (range 0-59) + #[cfg_attr(feature = "serde", serde(rename(serialize = "minutes")))] pub minutes: u8, /// seconds of minute (range 0-60) rounded down + #[cfg_attr(feature = "serde", serde(rename(serialize = "seconds")))] pub seconds: u8, /// nanoseconds of second (range 0-999999999) + #[cfg_attr(feature = "serde", serde(rename(serialize = "ns")))] pub ns: u32, } -impl MsgUtcTimeGnss { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgUtcTimeGnss{ - sender_id: None, - flags: _buf.read_u8()?, - tow: _buf.read_u32::()?, - year: _buf.read_u16::()?, - month: _buf.read_u8()?, - day: _buf.read_u8()?, - hours: _buf.read_u8()?, - minutes: _buf.read_u8()?, - seconds: _buf.read_u8()?, - ns: _buf.read_u32::()?, - } ) - } +impl ConcreteMessage for MsgUtcTimeGnss { + const MESSAGE_TYPE: u16 = 261; + const MESSAGE_NAME: &'static str = "MSG_UTC_TIME_GNSS"; } -impl super::SBPMessage for MsgUtcTimeGnss { - fn get_message_name(&self) -> &'static str { - "MSG_UTC_TIME_GNSS" - } - fn get_message_type(&self) -> u16 { - 261 +impl SbpMessage for MsgUtcTimeGnss { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgUtcTimeGnss { - const MESSAGE_TYPE: u16 = 261; - const MESSAGE_NAME: &'static str = "MSG_UTC_TIME_GNSS"; -} -impl TryFrom for MsgUtcTimeGnss { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgUtcTimeGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgUtcTimeGnss(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgUtcTimeGnss(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgUtcTimeGnss { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.flags.append_to_sbp_buffer(buf); - self.tow.append_to_sbp_buffer(buf); - self.year.append_to_sbp_buffer(buf); - self.month.append_to_sbp_buffer(buf); - self.day.append_to_sbp_buffer(buf); - self.hours.append_to_sbp_buffer(buf); - self.minutes.append_to_sbp_buffer(buf); - self.seconds.append_to_sbp_buffer(buf); - self.ns.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.flags.sbp_size(); - size += self.tow.sbp_size(); - size += self.year.sbp_size(); - size += self.month.sbp_size(); - size += self.day.sbp_size(); - size += self.hours.sbp_size(); - size += self.minutes.sbp_size(); - size += self.seconds.sbp_size(); - size += self.ns.sbp_size(); - size +impl WireFormat for MsgUtcTimeGnss { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.flags) + + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.year) + + WireFormat::encoded_len(&self.month) + + WireFormat::encoded_len(&self.day) + + WireFormat::encoded_len(&self.hours) + + WireFormat::encoded_len(&self.minutes) + + WireFormat::encoded_len(&self.seconds) + + WireFormat::encoded_len(&self.ns) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.flags, buf); + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.year, buf); + WireFormat::write(&self.month, buf); + WireFormat::write(&self.day, buf); + WireFormat::write(&self.hours, buf); + WireFormat::write(&self.minutes, buf); + WireFormat::write(&self.seconds, buf); + WireFormat::write(&self.ns, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgUtcTimeGnss { + sender_id: None, + flags: WireFormat::parse_unchecked(buf), + tow: WireFormat::parse_unchecked(buf), + year: WireFormat::parse_unchecked(buf), + month: WireFormat::parse_unchecked(buf), + day: WireFormat::parse_unchecked(buf), + hours: WireFormat::parse_unchecked(buf), + minutes: WireFormat::parse_unchecked(buf), + seconds: WireFormat::parse_unchecked(buf), + ns: WireFormat::parse_unchecked(buf), + } } } @@ -3561,144 +3387,146 @@ impl crate::serialize::SbpSerialize for MsgUtcTimeGnss { /// (tow). This message is only produced by inertial versions of Swift /// products and is not available from Piksi Multi or Duro. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgVelBody { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Velocity in x direction + #[cfg_attr(feature = "serde", serde(rename(serialize = "x")))] pub x: i32, /// Velocity in y direction + #[cfg_attr(feature = "serde", serde(rename(serialize = "y")))] pub y: i32, /// Velocity in z direction + #[cfg_attr(feature = "serde", serde(rename(serialize = "z")))] pub z: i32, /// Estimated variance of x + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_x_x")))] pub cov_x_x: f32, /// Covariance of x and y + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_x_y")))] pub cov_x_y: f32, /// Covariance of x and z + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_x_z")))] pub cov_x_z: f32, /// Estimated variance of y + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_y_y")))] pub cov_y_y: f32, /// Covariance of y and z + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_y_z")))] pub cov_y_z: f32, /// Estimated variance of z + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_z_z")))] pub cov_z_z: f32, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgVelBody { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgVelBody{ - sender_id: None, - tow: _buf.read_u32::()?, - x: _buf.read_i32::()?, - y: _buf.read_i32::()?, - z: _buf.read_i32::()?, - cov_x_x: _buf.read_f32::()?, - cov_x_y: _buf.read_f32::()?, - cov_x_z: _buf.read_f32::()?, - cov_y_y: _buf.read_f32::()?, - cov_y_z: _buf.read_f32::()?, - cov_z_z: _buf.read_f32::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgVelBody { + const MESSAGE_TYPE: u16 = 531; + const MESSAGE_NAME: &'static str = "MSG_VEL_BODY"; } -impl super::SBPMessage for MsgVelBody { - fn get_message_name(&self) -> &'static str { - "MSG_VEL_BODY" - } - fn get_message_type(&self) -> u16 { - 531 +impl SbpMessage for MsgVelBody { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgVelBody { - const MESSAGE_TYPE: u16 = 531; - const MESSAGE_NAME: &'static str = "MSG_VEL_BODY"; -} -impl TryFrom for MsgVelBody { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgVelBody { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgVelBody(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgVelBody(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgVelBody { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.x.append_to_sbp_buffer(buf); - self.y.append_to_sbp_buffer(buf); - self.z.append_to_sbp_buffer(buf); - self.cov_x_x.append_to_sbp_buffer(buf); - self.cov_x_y.append_to_sbp_buffer(buf); - self.cov_x_z.append_to_sbp_buffer(buf); - self.cov_y_y.append_to_sbp_buffer(buf); - self.cov_y_z.append_to_sbp_buffer(buf); - self.cov_z_z.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.x.sbp_size(); - size += self.y.sbp_size(); - size += self.z.sbp_size(); - size += self.cov_x_x.sbp_size(); - size += self.cov_x_y.sbp_size(); - size += self.cov_x_z.sbp_size(); - size += self.cov_y_y.sbp_size(); - size += self.cov_y_z.sbp_size(); - size += self.cov_z_z.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgVelBody { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.x) + + WireFormat::encoded_len(&self.y) + + WireFormat::encoded_len(&self.z) + + WireFormat::encoded_len(&self.cov_x_x) + + WireFormat::encoded_len(&self.cov_x_y) + + WireFormat::encoded_len(&self.cov_x_z) + + WireFormat::encoded_len(&self.cov_y_y) + + WireFormat::encoded_len(&self.cov_y_z) + + WireFormat::encoded_len(&self.cov_z_z) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.x, buf); + WireFormat::write(&self.y, buf); + WireFormat::write(&self.z, buf); + WireFormat::write(&self.cov_x_x, buf); + WireFormat::write(&self.cov_x_y, buf); + WireFormat::write(&self.cov_x_z, buf); + WireFormat::write(&self.cov_y_y, buf); + WireFormat::write(&self.cov_y_z, buf); + WireFormat::write(&self.cov_z_z, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgVelBody { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + x: WireFormat::parse_unchecked(buf), + y: WireFormat::parse_unchecked(buf), + z: WireFormat::parse_unchecked(buf), + cov_x_x: WireFormat::parse_unchecked(buf), + cov_x_y: WireFormat::parse_unchecked(buf), + cov_x_z: WireFormat::parse_unchecked(buf), + cov_y_y: WireFormat::parse_unchecked(buf), + cov_y_z: WireFormat::parse_unchecked(buf), + cov_z_z: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -3708,119 +3536,111 @@ impl crate::serialize::SbpSerialize for MsgVelBody { /// coordinates. The full GPS time is given by the preceding MSG_GPS_TIME with /// the matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgVelECEF { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgVelEcef { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Velocity ECEF X coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "x")))] pub x: i32, /// Velocity ECEF Y coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "y")))] pub y: i32, /// Velocity ECEF Z coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "z")))] pub z: i32, /// Velocity estimated standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "accuracy")))] pub accuracy: u16, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgVelECEF { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgVelECEF{ - sender_id: None, - tow: _buf.read_u32::()?, - x: _buf.read_i32::()?, - y: _buf.read_i32::()?, - z: _buf.read_i32::()?, - accuracy: _buf.read_u16::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgVelEcef { + const MESSAGE_TYPE: u16 = 525; + const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF"; } -impl super::SBPMessage for MsgVelECEF { - fn get_message_name(&self) -> &'static str { - "MSG_VEL_ECEF" - } - fn get_message_type(&self) -> u16 { - 525 +impl SbpMessage for MsgVelEcef { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgVelECEF { - const MESSAGE_TYPE: u16 = 525; - const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF"; -} -impl TryFrom for MsgVelECEF { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgVelEcef { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgVelECEF(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgVelEcef(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgVelECEF { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.x.append_to_sbp_buffer(buf); - self.y.append_to_sbp_buffer(buf); - self.z.append_to_sbp_buffer(buf); - self.accuracy.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.x.sbp_size(); - size += self.y.sbp_size(); - size += self.z.sbp_size(); - size += self.accuracy.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgVelEcef { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.x) + + WireFormat::encoded_len(&self.y) + + WireFormat::encoded_len(&self.z) + + WireFormat::encoded_len(&self.accuracy) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.x, buf); + WireFormat::write(&self.y, buf); + WireFormat::write(&self.z, buf); + WireFormat::write(&self.accuracy, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgVelEcef { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + x: WireFormat::parse_unchecked(buf), + y: WireFormat::parse_unchecked(buf), + z: WireFormat::parse_unchecked(buf), + accuracy: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -3830,144 +3650,146 @@ impl crate::serialize::SbpSerialize for MsgVelECEF { /// coordinates. The full GPS time is given by the preceding MSG_GPS_TIME with /// the matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgVelECEFCov { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgVelEcefCov { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Velocity ECEF X coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "x")))] pub x: i32, /// Velocity ECEF Y coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "y")))] pub y: i32, /// Velocity ECEF Z coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "z")))] pub z: i32, /// Estimated variance of x + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_x_x")))] pub cov_x_x: f32, /// Estimated covariance of x and y + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_x_y")))] pub cov_x_y: f32, /// Estimated covariance of x and z + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_x_z")))] pub cov_x_z: f32, /// Estimated variance of y + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_y_y")))] pub cov_y_y: f32, /// Estimated covariance of y and z + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_y_z")))] pub cov_y_z: f32, /// Estimated variance of z + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_z_z")))] pub cov_z_z: f32, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgVelECEFCov { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgVelECEFCov{ - sender_id: None, - tow: _buf.read_u32::()?, - x: _buf.read_i32::()?, - y: _buf.read_i32::()?, - z: _buf.read_i32::()?, - cov_x_x: _buf.read_f32::()?, - cov_x_y: _buf.read_f32::()?, - cov_x_z: _buf.read_f32::()?, - cov_y_y: _buf.read_f32::()?, - cov_y_z: _buf.read_f32::()?, - cov_z_z: _buf.read_f32::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgVelEcefCov { + const MESSAGE_TYPE: u16 = 533; + const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF_COV"; } -impl super::SBPMessage for MsgVelECEFCov { - fn get_message_name(&self) -> &'static str { - "MSG_VEL_ECEF_COV" - } - fn get_message_type(&self) -> u16 { - 533 +impl SbpMessage for MsgVelEcefCov { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgVelECEFCov { - const MESSAGE_TYPE: u16 = 533; - const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF_COV"; -} -impl TryFrom for MsgVelECEFCov { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgVelEcefCov { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgVelECEFCov(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgVelEcefCov(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgVelECEFCov { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.x.append_to_sbp_buffer(buf); - self.y.append_to_sbp_buffer(buf); - self.z.append_to_sbp_buffer(buf); - self.cov_x_x.append_to_sbp_buffer(buf); - self.cov_x_y.append_to_sbp_buffer(buf); - self.cov_x_z.append_to_sbp_buffer(buf); - self.cov_y_y.append_to_sbp_buffer(buf); - self.cov_y_z.append_to_sbp_buffer(buf); - self.cov_z_z.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.x.sbp_size(); - size += self.y.sbp_size(); - size += self.z.sbp_size(); - size += self.cov_x_x.sbp_size(); - size += self.cov_x_y.sbp_size(); - size += self.cov_x_z.sbp_size(); - size += self.cov_y_y.sbp_size(); - size += self.cov_y_z.sbp_size(); - size += self.cov_z_z.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgVelEcefCov { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.x) + + WireFormat::encoded_len(&self.y) + + WireFormat::encoded_len(&self.z) + + WireFormat::encoded_len(&self.cov_x_x) + + WireFormat::encoded_len(&self.cov_x_y) + + WireFormat::encoded_len(&self.cov_x_z) + + WireFormat::encoded_len(&self.cov_y_y) + + WireFormat::encoded_len(&self.cov_y_z) + + WireFormat::encoded_len(&self.cov_z_z) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.x, buf); + WireFormat::write(&self.y, buf); + WireFormat::write(&self.z, buf); + WireFormat::write(&self.cov_x_x, buf); + WireFormat::write(&self.cov_x_y, buf); + WireFormat::write(&self.cov_x_z, buf); + WireFormat::write(&self.cov_y_y, buf); + WireFormat::write(&self.cov_y_z, buf); + WireFormat::write(&self.cov_z_z, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgVelEcefCov { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + x: WireFormat::parse_unchecked(buf), + y: WireFormat::parse_unchecked(buf), + z: WireFormat::parse_unchecked(buf), + cov_x_x: WireFormat::parse_unchecked(buf), + cov_x_y: WireFormat::parse_unchecked(buf), + cov_x_z: WireFormat::parse_unchecked(buf), + cov_y_y: WireFormat::parse_unchecked(buf), + cov_y_z: WireFormat::parse_unchecked(buf), + cov_z_z: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -3977,144 +3799,146 @@ impl crate::serialize::SbpSerialize for MsgVelECEFCov { /// coordinates. The full GPS time is given by the preceding MSG_GPS_TIME with /// the matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgVelECEFCovGnss { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgVelEcefCovGnss { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Velocity ECEF X coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "x")))] pub x: i32, /// Velocity ECEF Y coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "y")))] pub y: i32, /// Velocity ECEF Z coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "z")))] pub z: i32, /// Estimated variance of x + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_x_x")))] pub cov_x_x: f32, /// Estimated covariance of x and y + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_x_y")))] pub cov_x_y: f32, /// Estimated covariance of x and z + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_x_z")))] pub cov_x_z: f32, /// Estimated variance of y + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_y_y")))] pub cov_y_y: f32, /// Estimated covariance of y and z + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_y_z")))] pub cov_y_z: f32, /// Estimated variance of z + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_z_z")))] pub cov_z_z: f32, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgVelECEFCovGnss { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgVelECEFCovGnss{ - sender_id: None, - tow: _buf.read_u32::()?, - x: _buf.read_i32::()?, - y: _buf.read_i32::()?, - z: _buf.read_i32::()?, - cov_x_x: _buf.read_f32::()?, - cov_x_y: _buf.read_f32::()?, - cov_x_z: _buf.read_f32::()?, - cov_y_y: _buf.read_f32::()?, - cov_y_z: _buf.read_f32::()?, - cov_z_z: _buf.read_f32::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgVelEcefCovGnss { + const MESSAGE_TYPE: u16 = 565; + const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF_COV_GNSS"; } -impl super::SBPMessage for MsgVelECEFCovGnss { - fn get_message_name(&self) -> &'static str { - "MSG_VEL_ECEF_COV_GNSS" - } - fn get_message_type(&self) -> u16 { - 565 +impl SbpMessage for MsgVelEcefCovGnss { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgVelECEFCovGnss { - const MESSAGE_TYPE: u16 = 565; - const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF_COV_GNSS"; -} -impl TryFrom for MsgVelECEFCovGnss { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgVelEcefCovGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgVelECEFCovGnss(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgVelEcefCovGnss(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgVelECEFCovGnss { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.x.append_to_sbp_buffer(buf); - self.y.append_to_sbp_buffer(buf); - self.z.append_to_sbp_buffer(buf); - self.cov_x_x.append_to_sbp_buffer(buf); - self.cov_x_y.append_to_sbp_buffer(buf); - self.cov_x_z.append_to_sbp_buffer(buf); - self.cov_y_y.append_to_sbp_buffer(buf); - self.cov_y_z.append_to_sbp_buffer(buf); - self.cov_z_z.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.x.sbp_size(); - size += self.y.sbp_size(); - size += self.z.sbp_size(); - size += self.cov_x_x.sbp_size(); - size += self.cov_x_y.sbp_size(); - size += self.cov_x_z.sbp_size(); - size += self.cov_y_y.sbp_size(); - size += self.cov_y_z.sbp_size(); - size += self.cov_z_z.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgVelEcefCovGnss { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.x) + + WireFormat::encoded_len(&self.y) + + WireFormat::encoded_len(&self.z) + + WireFormat::encoded_len(&self.cov_x_x) + + WireFormat::encoded_len(&self.cov_x_y) + + WireFormat::encoded_len(&self.cov_x_z) + + WireFormat::encoded_len(&self.cov_y_y) + + WireFormat::encoded_len(&self.cov_y_z) + + WireFormat::encoded_len(&self.cov_z_z) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.x, buf); + WireFormat::write(&self.y, buf); + WireFormat::write(&self.z, buf); + WireFormat::write(&self.cov_x_x, buf); + WireFormat::write(&self.cov_x_y, buf); + WireFormat::write(&self.cov_x_z, buf); + WireFormat::write(&self.cov_y_y, buf); + WireFormat::write(&self.cov_y_z, buf); + WireFormat::write(&self.cov_z_z, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgVelEcefCovGnss { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + x: WireFormat::parse_unchecked(buf), + y: WireFormat::parse_unchecked(buf), + z: WireFormat::parse_unchecked(buf), + cov_x_x: WireFormat::parse_unchecked(buf), + cov_x_y: WireFormat::parse_unchecked(buf), + cov_x_z: WireFormat::parse_unchecked(buf), + cov_y_y: WireFormat::parse_unchecked(buf), + cov_y_z: WireFormat::parse_unchecked(buf), + cov_z_z: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -4124,119 +3948,111 @@ impl crate::serialize::SbpSerialize for MsgVelECEFCovGnss { /// coordinates. The full GPS time is given by the preceding MSG_GPS_TIME with /// the matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgVelECEFDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgVelEcefDepA { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Velocity ECEF X coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "x")))] pub x: i32, /// Velocity ECEF Y coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "y")))] pub y: i32, /// Velocity ECEF Z coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "z")))] pub z: i32, /// Velocity accuracy estimate (not implemented). Defaults to 0. + #[cfg_attr(feature = "serde", serde(rename(serialize = "accuracy")))] pub accuracy: u16, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags (reserved) + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgVelECEFDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgVelECEFDepA{ - sender_id: None, - tow: _buf.read_u32::()?, - x: _buf.read_i32::()?, - y: _buf.read_i32::()?, - z: _buf.read_i32::()?, - accuracy: _buf.read_u16::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgVelEcefDepA { + const MESSAGE_TYPE: u16 = 516; + const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF_DEP_A"; } -impl super::SBPMessage for MsgVelECEFDepA { - fn get_message_name(&self) -> &'static str { - "MSG_VEL_ECEF_DEP_A" - } - fn get_message_type(&self) -> u16 { - 516 +impl SbpMessage for MsgVelEcefDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgVelECEFDepA { - const MESSAGE_TYPE: u16 = 516; - const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF_DEP_A"; -} -impl TryFrom for MsgVelECEFDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgVelEcefDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgVelECEFDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgVelEcefDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgVelECEFDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.x.append_to_sbp_buffer(buf); - self.y.append_to_sbp_buffer(buf); - self.z.append_to_sbp_buffer(buf); - self.accuracy.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.x.sbp_size(); - size += self.y.sbp_size(); - size += self.z.sbp_size(); - size += self.accuracy.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgVelEcefDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.x) + + WireFormat::encoded_len(&self.y) + + WireFormat::encoded_len(&self.z) + + WireFormat::encoded_len(&self.accuracy) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.x, buf); + WireFormat::write(&self.y, buf); + WireFormat::write(&self.z, buf); + WireFormat::write(&self.accuracy, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgVelEcefDepA { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + x: WireFormat::parse_unchecked(buf), + y: WireFormat::parse_unchecked(buf), + z: WireFormat::parse_unchecked(buf), + accuracy: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -4246,119 +4062,111 @@ impl crate::serialize::SbpSerialize for MsgVelECEFDepA { /// coordinates. The full GPS time is given by the preceding MSG_GPS_TIME with /// the matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgVelECEFGnss { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgVelEcefGnss { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Velocity ECEF X coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "x")))] pub x: i32, /// Velocity ECEF Y coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "y")))] pub y: i32, /// Velocity ECEF Z coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "z")))] pub z: i32, /// Velocity estimated standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "accuracy")))] pub accuracy: u16, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgVelECEFGnss { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgVelECEFGnss{ - sender_id: None, - tow: _buf.read_u32::()?, - x: _buf.read_i32::()?, - y: _buf.read_i32::()?, - z: _buf.read_i32::()?, - accuracy: _buf.read_u16::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgVelEcefGnss { + const MESSAGE_TYPE: u16 = 557; + const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF_GNSS"; } -impl super::SBPMessage for MsgVelECEFGnss { - fn get_message_name(&self) -> &'static str { - "MSG_VEL_ECEF_GNSS" - } - fn get_message_type(&self) -> u16 { - 557 +impl SbpMessage for MsgVelEcefGnss { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgVelECEFGnss { - const MESSAGE_TYPE: u16 = 557; - const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF_GNSS"; -} -impl TryFrom for MsgVelECEFGnss { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgVelEcefGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgVelECEFGnss(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgVelEcefGnss(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgVelECEFGnss { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.x.append_to_sbp_buffer(buf); - self.y.append_to_sbp_buffer(buf); - self.z.append_to_sbp_buffer(buf); - self.accuracy.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.x.sbp_size(); - size += self.y.sbp_size(); - size += self.z.sbp_size(); - size += self.accuracy.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgVelEcefGnss { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.x) + + WireFormat::encoded_len(&self.y) + + WireFormat::encoded_len(&self.z) + + WireFormat::encoded_len(&self.accuracy) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.x, buf); + WireFormat::write(&self.y, buf); + WireFormat::write(&self.z, buf); + WireFormat::write(&self.accuracy, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgVelEcefGnss { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + x: WireFormat::parse_unchecked(buf), + y: WireFormat::parse_unchecked(buf), + z: WireFormat::parse_unchecked(buf), + accuracy: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -4369,124 +4177,118 @@ impl crate::serialize::SbpSerialize for MsgVelECEFGnss { /// tangent plane centered at the current position. The full GPS time is given /// by the preceding MSG_GPS_TIME with the matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgVelNED { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgVelNed { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Velocity North coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "n")))] pub n: i32, /// Velocity East coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "e")))] pub e: i32, /// Velocity Down coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "d")))] pub d: i32, /// Horizontal velocity estimated standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "h_accuracy")))] pub h_accuracy: u16, /// Vertical velocity estimated standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "v_accuracy")))] pub v_accuracy: u16, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgVelNED { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgVelNED{ - sender_id: None, - tow: _buf.read_u32::()?, - n: _buf.read_i32::()?, - e: _buf.read_i32::()?, - d: _buf.read_i32::()?, - h_accuracy: _buf.read_u16::()?, - v_accuracy: _buf.read_u16::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgVelNed { + const MESSAGE_TYPE: u16 = 526; + const MESSAGE_NAME: &'static str = "MSG_VEL_NED"; } -impl super::SBPMessage for MsgVelNED { - fn get_message_name(&self) -> &'static str { - "MSG_VEL_NED" - } - fn get_message_type(&self) -> u16 { - 526 +impl SbpMessage for MsgVelNed { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgVelNED { - const MESSAGE_TYPE: u16 = 526; - const MESSAGE_NAME: &'static str = "MSG_VEL_NED"; -} -impl TryFrom for MsgVelNED { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgVelNed { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgVelNED(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgVelNed(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgVelNED { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.n.append_to_sbp_buffer(buf); - self.e.append_to_sbp_buffer(buf); - self.d.append_to_sbp_buffer(buf); - self.h_accuracy.append_to_sbp_buffer(buf); - self.v_accuracy.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.n.sbp_size(); - size += self.e.sbp_size(); - size += self.d.sbp_size(); - size += self.h_accuracy.sbp_size(); - size += self.v_accuracy.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgVelNed { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.n) + + WireFormat::encoded_len(&self.e) + + WireFormat::encoded_len(&self.d) + + WireFormat::encoded_len(&self.h_accuracy) + + WireFormat::encoded_len(&self.v_accuracy) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.n, buf); + WireFormat::write(&self.e, buf); + WireFormat::write(&self.d, buf); + WireFormat::write(&self.h_accuracy, buf); + WireFormat::write(&self.v_accuracy, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgVelNed { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + n: WireFormat::parse_unchecked(buf), + e: WireFormat::parse_unchecked(buf), + d: WireFormat::parse_unchecked(buf), + h_accuracy: WireFormat::parse_unchecked(buf), + v_accuracy: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -4499,144 +4301,146 @@ impl crate::serialize::SbpSerialize for MsgVelNED { /// message is similar to the MSG_VEL_NED, but it includes the upper /// triangular portion of the 3x3 covariance matrix. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgVelNEDCov { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgVelNedCov { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Velocity North coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "n")))] pub n: i32, /// Velocity East coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "e")))] pub e: i32, /// Velocity Down coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "d")))] pub d: i32, /// Estimated variance of northward measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_n_n")))] pub cov_n_n: f32, /// Covariance of northward and eastward measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_n_e")))] pub cov_n_e: f32, /// Covariance of northward and downward measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_n_d")))] pub cov_n_d: f32, /// Estimated variance of eastward measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_e_e")))] pub cov_e_e: f32, /// Covariance of eastward and downward measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_e_d")))] pub cov_e_d: f32, /// Estimated variance of downward measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_d_d")))] pub cov_d_d: f32, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgVelNEDCov { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgVelNEDCov{ - sender_id: None, - tow: _buf.read_u32::()?, - n: _buf.read_i32::()?, - e: _buf.read_i32::()?, - d: _buf.read_i32::()?, - cov_n_n: _buf.read_f32::()?, - cov_n_e: _buf.read_f32::()?, - cov_n_d: _buf.read_f32::()?, - cov_e_e: _buf.read_f32::()?, - cov_e_d: _buf.read_f32::()?, - cov_d_d: _buf.read_f32::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgVelNedCov { + const MESSAGE_TYPE: u16 = 530; + const MESSAGE_NAME: &'static str = "MSG_VEL_NED_COV"; } -impl super::SBPMessage for MsgVelNEDCov { - fn get_message_name(&self) -> &'static str { - "MSG_VEL_NED_COV" - } - fn get_message_type(&self) -> u16 { - 530 +impl SbpMessage for MsgVelNedCov { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgVelNEDCov { - const MESSAGE_TYPE: u16 = 530; - const MESSAGE_NAME: &'static str = "MSG_VEL_NED_COV"; -} -impl TryFrom for MsgVelNEDCov { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgVelNedCov { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgVelNEDCov(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgVelNedCov(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgVelNEDCov { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.n.append_to_sbp_buffer(buf); - self.e.append_to_sbp_buffer(buf); - self.d.append_to_sbp_buffer(buf); - self.cov_n_n.append_to_sbp_buffer(buf); - self.cov_n_e.append_to_sbp_buffer(buf); - self.cov_n_d.append_to_sbp_buffer(buf); - self.cov_e_e.append_to_sbp_buffer(buf); - self.cov_e_d.append_to_sbp_buffer(buf); - self.cov_d_d.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.n.sbp_size(); - size += self.e.sbp_size(); - size += self.d.sbp_size(); - size += self.cov_n_n.sbp_size(); - size += self.cov_n_e.sbp_size(); - size += self.cov_n_d.sbp_size(); - size += self.cov_e_e.sbp_size(); - size += self.cov_e_d.sbp_size(); - size += self.cov_d_d.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgVelNedCov { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.n) + + WireFormat::encoded_len(&self.e) + + WireFormat::encoded_len(&self.d) + + WireFormat::encoded_len(&self.cov_n_n) + + WireFormat::encoded_len(&self.cov_n_e) + + WireFormat::encoded_len(&self.cov_n_d) + + WireFormat::encoded_len(&self.cov_e_e) + + WireFormat::encoded_len(&self.cov_e_d) + + WireFormat::encoded_len(&self.cov_d_d) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.n, buf); + WireFormat::write(&self.e, buf); + WireFormat::write(&self.d, buf); + WireFormat::write(&self.cov_n_n, buf); + WireFormat::write(&self.cov_n_e, buf); + WireFormat::write(&self.cov_n_d, buf); + WireFormat::write(&self.cov_e_e, buf); + WireFormat::write(&self.cov_e_d, buf); + WireFormat::write(&self.cov_d_d, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgVelNedCov { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + n: WireFormat::parse_unchecked(buf), + e: WireFormat::parse_unchecked(buf), + d: WireFormat::parse_unchecked(buf), + cov_n_n: WireFormat::parse_unchecked(buf), + cov_n_e: WireFormat::parse_unchecked(buf), + cov_n_d: WireFormat::parse_unchecked(buf), + cov_e_e: WireFormat::parse_unchecked(buf), + cov_e_d: WireFormat::parse_unchecked(buf), + cov_d_d: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -4649,144 +4453,146 @@ impl crate::serialize::SbpSerialize for MsgVelNEDCov { /// message is similar to the MSG_VEL_NED, but it includes the upper /// triangular portion of the 3x3 covariance matrix. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgVelNEDCovGnss { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgVelNedCovGnss { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Velocity North coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "n")))] pub n: i32, /// Velocity East coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "e")))] pub e: i32, /// Velocity Down coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "d")))] pub d: i32, /// Estimated variance of northward measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_n_n")))] pub cov_n_n: f32, /// Covariance of northward and eastward measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_n_e")))] pub cov_n_e: f32, /// Covariance of northward and downward measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_n_d")))] pub cov_n_d: f32, /// Estimated variance of eastward measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_e_e")))] pub cov_e_e: f32, /// Covariance of eastward and downward measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_e_d")))] pub cov_e_d: f32, /// Estimated variance of downward measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "cov_d_d")))] pub cov_d_d: f32, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgVelNEDCovGnss { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgVelNEDCovGnss{ - sender_id: None, - tow: _buf.read_u32::()?, - n: _buf.read_i32::()?, - e: _buf.read_i32::()?, - d: _buf.read_i32::()?, - cov_n_n: _buf.read_f32::()?, - cov_n_e: _buf.read_f32::()?, - cov_n_d: _buf.read_f32::()?, - cov_e_e: _buf.read_f32::()?, - cov_e_d: _buf.read_f32::()?, - cov_d_d: _buf.read_f32::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgVelNedCovGnss { + const MESSAGE_TYPE: u16 = 562; + const MESSAGE_NAME: &'static str = "MSG_VEL_NED_COV_GNSS"; } -impl super::SBPMessage for MsgVelNEDCovGnss { - fn get_message_name(&self) -> &'static str { - "MSG_VEL_NED_COV_GNSS" - } - fn get_message_type(&self) -> u16 { - 562 +impl SbpMessage for MsgVelNedCovGnss { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgVelNEDCovGnss { - const MESSAGE_TYPE: u16 = 562; - const MESSAGE_NAME: &'static str = "MSG_VEL_NED_COV_GNSS"; -} -impl TryFrom for MsgVelNEDCovGnss { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgVelNedCovGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgVelNEDCovGnss(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgVelNedCovGnss(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgVelNEDCovGnss { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.n.append_to_sbp_buffer(buf); - self.e.append_to_sbp_buffer(buf); - self.d.append_to_sbp_buffer(buf); - self.cov_n_n.append_to_sbp_buffer(buf); - self.cov_n_e.append_to_sbp_buffer(buf); - self.cov_n_d.append_to_sbp_buffer(buf); - self.cov_e_e.append_to_sbp_buffer(buf); - self.cov_e_d.append_to_sbp_buffer(buf); - self.cov_d_d.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.n.sbp_size(); - size += self.e.sbp_size(); - size += self.d.sbp_size(); - size += self.cov_n_n.sbp_size(); - size += self.cov_n_e.sbp_size(); - size += self.cov_n_d.sbp_size(); - size += self.cov_e_e.sbp_size(); - size += self.cov_e_d.sbp_size(); - size += self.cov_d_d.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgVelNedCovGnss { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.n) + + WireFormat::encoded_len(&self.e) + + WireFormat::encoded_len(&self.d) + + WireFormat::encoded_len(&self.cov_n_n) + + WireFormat::encoded_len(&self.cov_n_e) + + WireFormat::encoded_len(&self.cov_n_d) + + WireFormat::encoded_len(&self.cov_e_e) + + WireFormat::encoded_len(&self.cov_e_d) + + WireFormat::encoded_len(&self.cov_d_d) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.n, buf); + WireFormat::write(&self.e, buf); + WireFormat::write(&self.d, buf); + WireFormat::write(&self.cov_n_n, buf); + WireFormat::write(&self.cov_n_e, buf); + WireFormat::write(&self.cov_n_d, buf); + WireFormat::write(&self.cov_e_e, buf); + WireFormat::write(&self.cov_e_d, buf); + WireFormat::write(&self.cov_d_d, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgVelNedCovGnss { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + n: WireFormat::parse_unchecked(buf), + e: WireFormat::parse_unchecked(buf), + d: WireFormat::parse_unchecked(buf), + cov_n_n: WireFormat::parse_unchecked(buf), + cov_n_e: WireFormat::parse_unchecked(buf), + cov_n_d: WireFormat::parse_unchecked(buf), + cov_e_e: WireFormat::parse_unchecked(buf), + cov_e_d: WireFormat::parse_unchecked(buf), + cov_d_d: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -4797,124 +4603,118 @@ impl crate::serialize::SbpSerialize for MsgVelNEDCovGnss { /// tangent plane centered at the current position. The full GPS time is given /// by the preceding MSG_GPS_TIME with the matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgVelNEDDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgVelNedDepA { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Velocity North coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "n")))] pub n: i32, /// Velocity East coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "e")))] pub e: i32, /// Velocity Down coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "d")))] pub d: i32, /// Horizontal velocity accuracy estimate (not implemented). Defaults to 0. + #[cfg_attr(feature = "serde", serde(rename(serialize = "h_accuracy")))] pub h_accuracy: u16, /// Vertical velocity accuracy estimate (not implemented). Defaults to 0. + #[cfg_attr(feature = "serde", serde(rename(serialize = "v_accuracy")))] pub v_accuracy: u16, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags (reserved) + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgVelNEDDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgVelNEDDepA{ - sender_id: None, - tow: _buf.read_u32::()?, - n: _buf.read_i32::()?, - e: _buf.read_i32::()?, - d: _buf.read_i32::()?, - h_accuracy: _buf.read_u16::()?, - v_accuracy: _buf.read_u16::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgVelNedDepA { + const MESSAGE_TYPE: u16 = 517; + const MESSAGE_NAME: &'static str = "MSG_VEL_NED_DEP_A"; } -impl super::SBPMessage for MsgVelNEDDepA { - fn get_message_name(&self) -> &'static str { - "MSG_VEL_NED_DEP_A" - } - fn get_message_type(&self) -> u16 { - 517 +impl SbpMessage for MsgVelNedDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgVelNEDDepA { - const MESSAGE_TYPE: u16 = 517; - const MESSAGE_NAME: &'static str = "MSG_VEL_NED_DEP_A"; -} -impl TryFrom for MsgVelNEDDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgVelNedDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgVelNEDDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgVelNedDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgVelNEDDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.n.append_to_sbp_buffer(buf); - self.e.append_to_sbp_buffer(buf); - self.d.append_to_sbp_buffer(buf); - self.h_accuracy.append_to_sbp_buffer(buf); - self.v_accuracy.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.n.sbp_size(); - size += self.e.sbp_size(); - size += self.d.sbp_size(); - size += self.h_accuracy.sbp_size(); - size += self.v_accuracy.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgVelNedDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.n) + + WireFormat::encoded_len(&self.e) + + WireFormat::encoded_len(&self.d) + + WireFormat::encoded_len(&self.h_accuracy) + + WireFormat::encoded_len(&self.v_accuracy) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.n, buf); + WireFormat::write(&self.e, buf); + WireFormat::write(&self.d, buf); + WireFormat::write(&self.h_accuracy, buf); + WireFormat::write(&self.v_accuracy, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgVelNedDepA { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + n: WireFormat::parse_unchecked(buf), + e: WireFormat::parse_unchecked(buf), + d: WireFormat::parse_unchecked(buf), + h_accuracy: WireFormat::parse_unchecked(buf), + v_accuracy: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -4925,123 +4725,117 @@ impl crate::serialize::SbpSerialize for MsgVelNEDDepA { /// tangent plane centered at the current position. The full GPS time is given /// by the preceding MSG_GPS_TIME with the matching time-of-week (tow). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgVelNEDGnss { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgVelNedGnss { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Velocity North coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "n")))] pub n: i32, /// Velocity East coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "e")))] pub e: i32, /// Velocity Down coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "d")))] pub d: i32, /// Horizontal velocity estimated standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "h_accuracy")))] pub h_accuracy: u16, /// Vertical velocity estimated standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "v_accuracy")))] pub v_accuracy: u16, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgVelNEDGnss { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgVelNEDGnss{ - sender_id: None, - tow: _buf.read_u32::()?, - n: _buf.read_i32::()?, - e: _buf.read_i32::()?, - d: _buf.read_i32::()?, - h_accuracy: _buf.read_u16::()?, - v_accuracy: _buf.read_u16::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgVelNedGnss { + const MESSAGE_TYPE: u16 = 558; + const MESSAGE_NAME: &'static str = "MSG_VEL_NED_GNSS"; } -impl super::SBPMessage for MsgVelNEDGnss { - fn get_message_name(&self) -> &'static str { - "MSG_VEL_NED_GNSS" - } - fn get_message_type(&self) -> u16 { - 558 +impl SbpMessage for MsgVelNedGnss { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgVelNEDGnss { - const MESSAGE_TYPE: u16 = 558; - const MESSAGE_NAME: &'static str = "MSG_VEL_NED_GNSS"; -} -impl TryFrom for MsgVelNEDGnss { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgVelNedGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgVelNEDGnss(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgVelNedGnss(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgVelNEDGnss { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.n.append_to_sbp_buffer(buf); - self.e.append_to_sbp_buffer(buf); - self.d.append_to_sbp_buffer(buf); - self.h_accuracy.append_to_sbp_buffer(buf); - self.v_accuracy.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.n.sbp_size(); - size += self.e.sbp_size(); - size += self.d.sbp_size(); - size += self.h_accuracy.sbp_size(); - size += self.v_accuracy.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgVelNedGnss { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.n) + + WireFormat::encoded_len(&self.e) + + WireFormat::encoded_len(&self.d) + + WireFormat::encoded_len(&self.h_accuracy) + + WireFormat::encoded_len(&self.v_accuracy) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.n, buf); + WireFormat::write(&self.e, buf); + WireFormat::write(&self.d, buf); + WireFormat::write(&self.h_accuracy, buf); + WireFormat::write(&self.v_accuracy, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgVelNedGnss { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + n: WireFormat::parse_unchecked(buf), + e: WireFormat::parse_unchecked(buf), + d: WireFormat::parse_unchecked(buf), + h_accuracy: WireFormat::parse_unchecked(buf), + v_accuracy: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } diff --git a/rust/sbp/src/messages/ndb.rs b/rust/sbp/src/messages/ndb.rs index 95737d9b12..a851ab3e9f 100644 --- a/rust/sbp/src/messages/ndb.rs +++ b/rust/sbp/src/messages/ndb.rs @@ -14,134 +14,123 @@ //****************************************************************************/ //! Messages for logging NDB events. -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - use super::gnss::*; -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; + +use super::lib::*; /// Navigation DataBase Event /// /// This message is sent out when an object is stored into NDB. If needed /// message could also be sent out when fetching an object from NDB. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgNdbEvent { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// HW time in milliseconds. + #[cfg_attr(feature = "serde", serde(rename(serialize = "recv_time")))] pub recv_time: u64, /// Event type. + #[cfg_attr(feature = "serde", serde(rename(serialize = "event")))] pub event: u8, /// Event object type. + #[cfg_attr(feature = "serde", serde(rename(serialize = "object_type")))] pub object_type: u8, /// Event result. + #[cfg_attr(feature = "serde", serde(rename(serialize = "result")))] pub result: u8, /// Data source for STORE event, reserved for other events. + #[cfg_attr(feature = "serde", serde(rename(serialize = "data_source")))] pub data_source: u8, /// GNSS signal identifier, If object_type is Ephemeris OR Almanac, sid /// indicates for which signal the object belongs to. Reserved in other /// cases. + #[cfg_attr(feature = "serde", serde(rename(serialize = "object_sid")))] pub object_sid: GnssSignal, /// GNSS signal identifier, If object_type is Almanac, Almanac WN, Iono OR /// L2C capabilities AND data_source is NDB_DS_RECEIVER sid indicates from /// which SV data was decoded. Reserved in other cases. + #[cfg_attr(feature = "serde", serde(rename(serialize = "src_sid")))] pub src_sid: GnssSignal, /// A unique identifier of the sending hardware. For v1.0, set to the 2 /// least significant bytes of the device serial number, valid only if /// data_source is NDB_DS_SBP. Reserved in case of other data_source. + #[cfg_attr(feature = "serde", serde(rename(serialize = "original_sender")))] pub original_sender: u16, } -impl MsgNdbEvent { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgNdbEvent{ - sender_id: None, - recv_time: _buf.read_u64::()?, - event: _buf.read_u8()?, - object_type: _buf.read_u8()?, - result: _buf.read_u8()?, - data_source: _buf.read_u8()?, - object_sid: GnssSignal::parse(_buf)?, - src_sid: GnssSignal::parse(_buf)?, - original_sender: _buf.read_u16::()?, - } ) - } +impl ConcreteMessage for MsgNdbEvent { + const MESSAGE_TYPE: u16 = 1024; + const MESSAGE_NAME: &'static str = "MSG_NDB_EVENT"; } -impl super::SBPMessage for MsgNdbEvent { - fn get_message_name(&self) -> &'static str { - "MSG_NDB_EVENT" - } - fn get_message_type(&self) -> u16 { - 1024 +impl SbpMessage for MsgNdbEvent { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgNdbEvent { - const MESSAGE_TYPE: u16 = 1024; - const MESSAGE_NAME: &'static str = "MSG_NDB_EVENT"; -} -impl TryFrom for MsgNdbEvent { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgNdbEvent { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgNdbEvent(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgNdbEvent(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgNdbEvent { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.recv_time.append_to_sbp_buffer(buf); - self.event.append_to_sbp_buffer(buf); - self.object_type.append_to_sbp_buffer(buf); - self.result.append_to_sbp_buffer(buf); - self.data_source.append_to_sbp_buffer(buf); - self.object_sid.append_to_sbp_buffer(buf); - self.src_sid.append_to_sbp_buffer(buf); - self.original_sender.append_to_sbp_buffer(buf); +impl WireFormat for MsgNdbEvent { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.recv_time) + + WireFormat::encoded_len(&self.event) + + WireFormat::encoded_len(&self.object_type) + + WireFormat::encoded_len(&self.result) + + WireFormat::encoded_len(&self.data_source) + + WireFormat::encoded_len(&self.object_sid) + + WireFormat::encoded_len(&self.src_sid) + + WireFormat::encoded_len(&self.original_sender) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.recv_time.sbp_size(); - size += self.event.sbp_size(); - size += self.object_type.sbp_size(); - size += self.result.sbp_size(); - size += self.data_source.sbp_size(); - size += self.object_sid.sbp_size(); - size += self.src_sid.sbp_size(); - size += self.original_sender.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.recv_time, buf); + WireFormat::write(&self.event, buf); + WireFormat::write(&self.object_type, buf); + WireFormat::write(&self.result, buf); + WireFormat::write(&self.data_source, buf); + WireFormat::write(&self.object_sid, buf); + WireFormat::write(&self.src_sid, buf); + WireFormat::write(&self.original_sender, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgNdbEvent { + sender_id: None, + recv_time: WireFormat::parse_unchecked(buf), + event: WireFormat::parse_unchecked(buf), + object_type: WireFormat::parse_unchecked(buf), + result: WireFormat::parse_unchecked(buf), + data_source: WireFormat::parse_unchecked(buf), + object_sid: WireFormat::parse_unchecked(buf), + src_sid: WireFormat::parse_unchecked(buf), + original_sender: WireFormat::parse_unchecked(buf), + } } } diff --git a/rust/sbp/src/messages/observation.rs b/rust/sbp/src/messages/observation.rs index c0b7201113..1dfc06099f 100644 --- a/rust/sbp/src/messages/observation.rs +++ b/rust/sbp/src/messages/observation.rs @@ -16,31 +16,28 @@ //! indicates remote observations from a GNSS base station, correction //! network, or Skylark, Swift's cloud GNSS correction product. -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - use super::gnss::*; -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +use super::lib::*; + +/// Common fields for every almanac message +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct AlmanacCommonContent { /// GNSS signal identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, /// Reference time of almanac - pub toa: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "toa")))] + pub toa: GpsTimeSec, /// User Range Accuracy + #[cfg_attr(feature = "serde", serde(rename(serialize = "ura")))] pub ura: f64, /// Curve fit interval + #[cfg_attr(feature = "serde", serde(rename(serialize = "fit_interval")))] pub fit_interval: u32, /// Status of almanac, 1 = valid, 0 = invalid + #[cfg_attr(feature = "serde", serde(rename(serialize = "valid")))] pub valid: u8, /// Satellite health status for GPS: /// - bits 5-7: NAV data health status. See IS-GPS-200H @@ -56,77 +53,63 @@ pub struct AlmanacCommonContent { /// '1' indicates that n-satellite is operational. /// - bit 1: Bn(ln), '0' indicates the satellite is operational /// and suitable for navigation. + #[cfg_attr(feature = "serde", serde(rename(serialize = "health_bits")))] pub health_bits: u8, } -impl AlmanacCommonContent { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( AlmanacCommonContent{ - sid: GnssSignal::parse(_buf)?, - toa: GPSTimeSec::parse(_buf)?, - ura: _buf.read_f64::()?, - fit_interval: _buf.read_u32::()?, - valid: _buf.read_u8()?, - health_bits: _buf.read_u8()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(AlmanacCommonContent::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(AlmanacCommonContent::parse(buf)?); +impl WireFormat for AlmanacCommonContent { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.toa) + + WireFormat::encoded_len(&self.ura) + + WireFormat::encoded_len(&self.fit_interval) + + WireFormat::encoded_len(&self.valid) + + WireFormat::encoded_len(&self.health_bits) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.toa, buf); + WireFormat::write(&self.ura, buf); + WireFormat::write(&self.fit_interval, buf); + WireFormat::write(&self.valid, buf); + WireFormat::write(&self.health_bits, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + AlmanacCommonContent { + sid: WireFormat::parse_unchecked(buf), + toa: WireFormat::parse_unchecked(buf), + ura: WireFormat::parse_unchecked(buf), + fit_interval: WireFormat::parse_unchecked(buf), + valid: WireFormat::parse_unchecked(buf), + health_bits: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for AlmanacCommonContent { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sid.append_to_sbp_buffer(buf); - self.toa.append_to_sbp_buffer(buf); - self.ura.append_to_sbp_buffer(buf); - self.fit_interval.append_to_sbp_buffer(buf); - self.valid.append_to_sbp_buffer(buf); - self.health_bits.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sid.sbp_size(); - size += self.toa.sbp_size(); - size += self.ura.sbp_size(); - size += self.fit_interval.sbp_size(); - size += self.valid.sbp_size(); - size += self.health_bits.sbp_size(); - size } } -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +/// Common fields for every almanac message +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct AlmanacCommonContentDep { /// GNSS signal identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignalDep, /// Reference time of almanac - pub toa: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "toa")))] + pub toa: GpsTimeSec, /// User Range Accuracy + #[cfg_attr(feature = "serde", serde(rename(serialize = "ura")))] pub ura: f64, /// Curve fit interval + #[cfg_attr(feature = "serde", serde(rename(serialize = "fit_interval")))] pub fit_interval: u32, /// Status of almanac, 1 = valid, 0 = invalid + #[cfg_attr(feature = "serde", serde(rename(serialize = "valid")))] pub valid: u8, /// Satellite health status for GPS: /// - bits 5-7: NAV data health status. See IS-GPS-200H @@ -142,61 +125,42 @@ pub struct AlmanacCommonContentDep { /// '1' indicates that n-satellite is operational. /// - bit 1: Bn(ln), '0' indicates the satellite is operational /// and suitable for navigation. + #[cfg_attr(feature = "serde", serde(rename(serialize = "health_bits")))] pub health_bits: u8, } -impl AlmanacCommonContentDep { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( AlmanacCommonContentDep{ - sid: GnssSignalDep::parse(_buf)?, - toa: GPSTimeSec::parse(_buf)?, - ura: _buf.read_f64::()?, - fit_interval: _buf.read_u32::()?, - valid: _buf.read_u8()?, - health_bits: _buf.read_u8()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(AlmanacCommonContentDep::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(AlmanacCommonContentDep::parse(buf)?); +impl WireFormat for AlmanacCommonContentDep { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.toa) + + WireFormat::encoded_len(&self.ura) + + WireFormat::encoded_len(&self.fit_interval) + + WireFormat::encoded_len(&self.valid) + + WireFormat::encoded_len(&self.health_bits) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.toa, buf); + WireFormat::write(&self.ura, buf); + WireFormat::write(&self.fit_interval, buf); + WireFormat::write(&self.valid, buf); + WireFormat::write(&self.health_bits, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + AlmanacCommonContentDep { + sid: WireFormat::parse_unchecked(buf), + toa: WireFormat::parse_unchecked(buf), + ura: WireFormat::parse_unchecked(buf), + fit_interval: WireFormat::parse_unchecked(buf), + valid: WireFormat::parse_unchecked(buf), + health_bits: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for AlmanacCommonContentDep { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sid.append_to_sbp_buffer(buf); - self.toa.append_to_sbp_buffer(buf); - self.ura.append_to_sbp_buffer(buf); - self.fit_interval.append_to_sbp_buffer(buf); - self.valid.append_to_sbp_buffer(buf); - self.health_bits.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sid.sbp_size(); - size += self.toa.sbp_size(); - size += self.ura.sbp_size(); - size += self.fit_interval.sbp_size(); - size += self.valid.sbp_size(); - size += self.health_bits.sbp_size(); - size } } @@ -207,56 +171,32 @@ impl crate::serialize::SbpSerialize for AlmanacCommonContentDep { /// fractional cycles. This has the opposite sign convention than a typical /// GPS receiver and the phase has the opposite sign as the pseudorange. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct CarrierPhaseDepA { /// Carrier phase whole cycles + #[cfg_attr(feature = "serde", serde(rename(serialize = "i")))] pub i: i32, /// Carrier phase fractional part + #[cfg_attr(feature = "serde", serde(rename(serialize = "f")))] pub f: u8, } -impl CarrierPhaseDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( CarrierPhaseDepA{ - i: _buf.read_i32::()?, - f: _buf.read_u8()?, - } ) +impl WireFormat for CarrierPhaseDepA { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.i) + WireFormat::encoded_len(&self.f) } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(CarrierPhaseDepA::parse(buf)?); - } - Ok(v) + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.i, buf); + WireFormat::write(&self.f, buf); } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(CarrierPhaseDepA::parse(buf)?); + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + CarrierPhaseDepA { + i: WireFormat::parse_unchecked(buf), + f: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for CarrierPhaseDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.i.append_to_sbp_buffer(buf); - self.f.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.i.sbp_size(); - size += self.f.sbp_size(); - size } } @@ -266,397 +206,341 @@ impl crate::serialize::SbpSerialize for CarrierPhaseDepA { /// Q16.8 layout, i.e. 16-bits of whole doppler and 8-bits of fractional /// doppler. This doppler is defined as positive for approaching satellites. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct Doppler { /// Doppler whole Hz + #[cfg_attr(feature = "serde", serde(rename(serialize = "i")))] pub i: i16, /// Doppler fractional part + #[cfg_attr(feature = "serde", serde(rename(serialize = "f")))] pub f: u8, } -impl Doppler { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( Doppler{ - i: _buf.read_i16::()?, - f: _buf.read_u8()?, - } ) +impl WireFormat for Doppler { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.i) + WireFormat::encoded_len(&self.f) } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(Doppler::parse(buf)?); - } - Ok(v) + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.i, buf); + WireFormat::write(&self.f, buf); } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(Doppler::parse(buf)?); + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + Doppler { + i: WireFormat::parse_unchecked(buf), + f: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for Doppler { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.i.append_to_sbp_buffer(buf); - self.f.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.i.sbp_size(); - size += self.f.sbp_size(); - size } } -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +/// Common fields for every ephemeris message +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct EphemerisCommonContent { /// GNSS signal identifier (16 bit) + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, /// Time of Ephemerides - pub toe: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "toe")))] + pub toe: GpsTimeSec, /// User Range Accuracy + #[cfg_attr(feature = "serde", serde(rename(serialize = "ura")))] pub ura: f32, /// Curve fit interval + #[cfg_attr(feature = "serde", serde(rename(serialize = "fit_interval")))] pub fit_interval: u32, /// Status of ephemeris, 1 = valid, 0 = invalid + #[cfg_attr(feature = "serde", serde(rename(serialize = "valid")))] pub valid: u8, /// Satellite health status. /// GPS: ICD-GPS-200, chapter 20.3.3.3.1.4 /// SBAS: 0 = valid, non-zero = invalid /// GLO: 0 = valid, non-zero = invalid + #[cfg_attr(feature = "serde", serde(rename(serialize = "health_bits")))] pub health_bits: u8, } -impl EphemerisCommonContent { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( EphemerisCommonContent{ - sid: GnssSignal::parse(_buf)?, - toe: GPSTimeSec::parse(_buf)?, - ura: _buf.read_f32::()?, - fit_interval: _buf.read_u32::()?, - valid: _buf.read_u8()?, - health_bits: _buf.read_u8()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(EphemerisCommonContent::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(EphemerisCommonContent::parse(buf)?); +impl WireFormat for EphemerisCommonContent { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.toe) + + WireFormat::encoded_len(&self.ura) + + WireFormat::encoded_len(&self.fit_interval) + + WireFormat::encoded_len(&self.valid) + + WireFormat::encoded_len(&self.health_bits) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.toe, buf); + WireFormat::write(&self.ura, buf); + WireFormat::write(&self.fit_interval, buf); + WireFormat::write(&self.valid, buf); + WireFormat::write(&self.health_bits, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + EphemerisCommonContent { + sid: WireFormat::parse_unchecked(buf), + toe: WireFormat::parse_unchecked(buf), + ura: WireFormat::parse_unchecked(buf), + fit_interval: WireFormat::parse_unchecked(buf), + valid: WireFormat::parse_unchecked(buf), + health_bits: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for EphemerisCommonContent { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sid.append_to_sbp_buffer(buf); - self.toe.append_to_sbp_buffer(buf); - self.ura.append_to_sbp_buffer(buf); - self.fit_interval.append_to_sbp_buffer(buf); - self.valid.append_to_sbp_buffer(buf); - self.health_bits.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sid.sbp_size(); - size += self.toe.sbp_size(); - size += self.ura.sbp_size(); - size += self.fit_interval.sbp_size(); - size += self.valid.sbp_size(); - size += self.health_bits.sbp_size(); - size } } -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +/// Common fields for every ephemeris message +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct EphemerisCommonContentDepA { /// GNSS signal identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignalDep, /// Time of Ephemerides - pub toe: GPSTimeDep, + #[cfg_attr(feature = "serde", serde(rename(serialize = "toe")))] + pub toe: GpsTimeDep, /// User Range Accuracy + #[cfg_attr(feature = "serde", serde(rename(serialize = "ura")))] pub ura: f64, /// Curve fit interval + #[cfg_attr(feature = "serde", serde(rename(serialize = "fit_interval")))] pub fit_interval: u32, /// Status of ephemeris, 1 = valid, 0 = invalid + #[cfg_attr(feature = "serde", serde(rename(serialize = "valid")))] pub valid: u8, /// Satellite health status. /// GPS: ICD-GPS-200, chapter 20.3.3.3.1.4 /// SBAS: 0 = valid, non-zero = invalid /// GLO: 0 = valid, non-zero = invalid + #[cfg_attr(feature = "serde", serde(rename(serialize = "health_bits")))] pub health_bits: u8, } -impl EphemerisCommonContentDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( EphemerisCommonContentDepA{ - sid: GnssSignalDep::parse(_buf)?, - toe: GPSTimeDep::parse(_buf)?, - ura: _buf.read_f64::()?, - fit_interval: _buf.read_u32::()?, - valid: _buf.read_u8()?, - health_bits: _buf.read_u8()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(EphemerisCommonContentDepA::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(EphemerisCommonContentDepA::parse(buf)?); +impl WireFormat for EphemerisCommonContentDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.toe) + + WireFormat::encoded_len(&self.ura) + + WireFormat::encoded_len(&self.fit_interval) + + WireFormat::encoded_len(&self.valid) + + WireFormat::encoded_len(&self.health_bits) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.toe, buf); + WireFormat::write(&self.ura, buf); + WireFormat::write(&self.fit_interval, buf); + WireFormat::write(&self.valid, buf); + WireFormat::write(&self.health_bits, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + EphemerisCommonContentDepA { + sid: WireFormat::parse_unchecked(buf), + toe: WireFormat::parse_unchecked(buf), + ura: WireFormat::parse_unchecked(buf), + fit_interval: WireFormat::parse_unchecked(buf), + valid: WireFormat::parse_unchecked(buf), + health_bits: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for EphemerisCommonContentDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sid.append_to_sbp_buffer(buf); - self.toe.append_to_sbp_buffer(buf); - self.ura.append_to_sbp_buffer(buf); - self.fit_interval.append_to_sbp_buffer(buf); - self.valid.append_to_sbp_buffer(buf); - self.health_bits.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sid.sbp_size(); - size += self.toe.sbp_size(); - size += self.ura.sbp_size(); - size += self.fit_interval.sbp_size(); - size += self.valid.sbp_size(); - size += self.health_bits.sbp_size(); - size } } -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +/// Common fields for every ephemeris message +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct EphemerisCommonContentDepB { /// GNSS signal identifier (16 bit) + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, /// Time of Ephemerides - pub toe: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "toe")))] + pub toe: GpsTimeSec, /// User Range Accuracy + #[cfg_attr(feature = "serde", serde(rename(serialize = "ura")))] pub ura: f64, /// Curve fit interval + #[cfg_attr(feature = "serde", serde(rename(serialize = "fit_interval")))] pub fit_interval: u32, /// Status of ephemeris, 1 = valid, 0 = invalid + #[cfg_attr(feature = "serde", serde(rename(serialize = "valid")))] pub valid: u8, /// Satellite health status. /// GPS: ICD-GPS-200, chapter 20.3.3.3.1.4 /// Others: 0 = valid, non-zero = invalid + #[cfg_attr(feature = "serde", serde(rename(serialize = "health_bits")))] pub health_bits: u8, } -impl EphemerisCommonContentDepB { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( EphemerisCommonContentDepB{ - sid: GnssSignal::parse(_buf)?, - toe: GPSTimeSec::parse(_buf)?, - ura: _buf.read_f64::()?, - fit_interval: _buf.read_u32::()?, - valid: _buf.read_u8()?, - health_bits: _buf.read_u8()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(EphemerisCommonContentDepB::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(EphemerisCommonContentDepB::parse(buf)?); +impl WireFormat for EphemerisCommonContentDepB { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.toe) + + WireFormat::encoded_len(&self.ura) + + WireFormat::encoded_len(&self.fit_interval) + + WireFormat::encoded_len(&self.valid) + + WireFormat::encoded_len(&self.health_bits) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.toe, buf); + WireFormat::write(&self.ura, buf); + WireFormat::write(&self.fit_interval, buf); + WireFormat::write(&self.valid, buf); + WireFormat::write(&self.health_bits, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + EphemerisCommonContentDepB { + sid: WireFormat::parse_unchecked(buf), + toe: WireFormat::parse_unchecked(buf), + ura: WireFormat::parse_unchecked(buf), + fit_interval: WireFormat::parse_unchecked(buf), + valid: WireFormat::parse_unchecked(buf), + health_bits: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for EphemerisCommonContentDepB { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sid.append_to_sbp_buffer(buf); - self.toe.append_to_sbp_buffer(buf); - self.ura.append_to_sbp_buffer(buf); - self.fit_interval.append_to_sbp_buffer(buf); - self.valid.append_to_sbp_buffer(buf); - self.health_bits.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sid.sbp_size(); - size += self.toe.sbp_size(); - size += self.ura.sbp_size(); - size += self.fit_interval.sbp_size(); - size += self.valid.sbp_size(); - size += self.health_bits.sbp_size(); - size } } -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +/// GNSS capabilities masks +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct GnssCapb { /// GPS SV active mask + #[cfg_attr(feature = "serde", serde(rename(serialize = "gps_active")))] pub gps_active: u64, /// GPS L2C active mask + #[cfg_attr(feature = "serde", serde(rename(serialize = "gps_l2c")))] pub gps_l2c: u64, /// GPS L5 active mask + #[cfg_attr(feature = "serde", serde(rename(serialize = "gps_l5")))] pub gps_l5: u64, /// GLO active mask + #[cfg_attr(feature = "serde", serde(rename(serialize = "glo_active")))] pub glo_active: u32, /// GLO L2OF active mask + #[cfg_attr(feature = "serde", serde(rename(serialize = "glo_l2of")))] pub glo_l2of: u32, /// GLO L3 active mask + #[cfg_attr(feature = "serde", serde(rename(serialize = "glo_l3")))] pub glo_l3: u32, /// SBAS active mask (PRNs 120..158, AN 7/62.2.2-18/18 Table B-23, - /// https://www.caat.or.th/wp-content/uploads/2018/03/SL-2018.18.E-1.pdf) + /// ) + #[cfg_attr(feature = "serde", serde(rename(serialize = "sbas_active")))] pub sbas_active: u64, /// SBAS L5 active mask (PRNs 120..158, AN 7/62.2.2-18/18 Table B-23, - /// https://www.caat.or.th/wp-content/uploads/2018/03/SL-2018.18.E-1.pdf) + /// ) + #[cfg_attr(feature = "serde", serde(rename(serialize = "sbas_l5")))] pub sbas_l5: u64, /// BDS active mask + #[cfg_attr(feature = "serde", serde(rename(serialize = "bds_active")))] pub bds_active: u64, /// BDS D2NAV active mask + #[cfg_attr(feature = "serde", serde(rename(serialize = "bds_d2nav")))] pub bds_d2nav: u64, /// BDS B2 active mask + #[cfg_attr(feature = "serde", serde(rename(serialize = "bds_b2")))] pub bds_b2: u64, /// BDS B2A active mask + #[cfg_attr(feature = "serde", serde(rename(serialize = "bds_b2a")))] pub bds_b2a: u64, /// QZSS active mask + #[cfg_attr(feature = "serde", serde(rename(serialize = "qzss_active")))] pub qzss_active: u32, /// GAL active mask + #[cfg_attr(feature = "serde", serde(rename(serialize = "gal_active")))] pub gal_active: u64, /// GAL E5 active mask + #[cfg_attr(feature = "serde", serde(rename(serialize = "gal_e5")))] pub gal_e5: u64, } -impl GnssCapb { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( GnssCapb{ - gps_active: _buf.read_u64::()?, - gps_l2c: _buf.read_u64::()?, - gps_l5: _buf.read_u64::()?, - glo_active: _buf.read_u32::()?, - glo_l2of: _buf.read_u32::()?, - glo_l3: _buf.read_u32::()?, - sbas_active: _buf.read_u64::()?, - sbas_l5: _buf.read_u64::()?, - bds_active: _buf.read_u64::()?, - bds_d2nav: _buf.read_u64::()?, - bds_b2: _buf.read_u64::()?, - bds_b2a: _buf.read_u64::()?, - qzss_active: _buf.read_u32::()?, - gal_active: _buf.read_u64::()?, - gal_e5: _buf.read_u64::()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(GnssCapb::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(GnssCapb::parse(buf)?); +impl WireFormat for GnssCapb { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.gps_active) + + WireFormat::encoded_len(&self.gps_l2c) + + WireFormat::encoded_len(&self.gps_l5) + + WireFormat::encoded_len(&self.glo_active) + + WireFormat::encoded_len(&self.glo_l2of) + + WireFormat::encoded_len(&self.glo_l3) + + WireFormat::encoded_len(&self.sbas_active) + + WireFormat::encoded_len(&self.sbas_l5) + + WireFormat::encoded_len(&self.bds_active) + + WireFormat::encoded_len(&self.bds_d2nav) + + WireFormat::encoded_len(&self.bds_b2) + + WireFormat::encoded_len(&self.bds_b2a) + + WireFormat::encoded_len(&self.qzss_active) + + WireFormat::encoded_len(&self.gal_active) + + WireFormat::encoded_len(&self.gal_e5) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.gps_active, buf); + WireFormat::write(&self.gps_l2c, buf); + WireFormat::write(&self.gps_l5, buf); + WireFormat::write(&self.glo_active, buf); + WireFormat::write(&self.glo_l2of, buf); + WireFormat::write(&self.glo_l3, buf); + WireFormat::write(&self.sbas_active, buf); + WireFormat::write(&self.sbas_l5, buf); + WireFormat::write(&self.bds_active, buf); + WireFormat::write(&self.bds_d2nav, buf); + WireFormat::write(&self.bds_b2, buf); + WireFormat::write(&self.bds_b2a, buf); + WireFormat::write(&self.qzss_active, buf); + WireFormat::write(&self.gal_active, buf); + WireFormat::write(&self.gal_e5, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + GnssCapb { + gps_active: WireFormat::parse_unchecked(buf), + gps_l2c: WireFormat::parse_unchecked(buf), + gps_l5: WireFormat::parse_unchecked(buf), + glo_active: WireFormat::parse_unchecked(buf), + glo_l2of: WireFormat::parse_unchecked(buf), + glo_l3: WireFormat::parse_unchecked(buf), + sbas_active: WireFormat::parse_unchecked(buf), + sbas_l5: WireFormat::parse_unchecked(buf), + bds_active: WireFormat::parse_unchecked(buf), + bds_d2nav: WireFormat::parse_unchecked(buf), + bds_b2: WireFormat::parse_unchecked(buf), + bds_b2a: WireFormat::parse_unchecked(buf), + qzss_active: WireFormat::parse_unchecked(buf), + gal_active: WireFormat::parse_unchecked(buf), + gal_e5: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for GnssCapb { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.gps_active.append_to_sbp_buffer(buf); - self.gps_l2c.append_to_sbp_buffer(buf); - self.gps_l5.append_to_sbp_buffer(buf); - self.glo_active.append_to_sbp_buffer(buf); - self.glo_l2of.append_to_sbp_buffer(buf); - self.glo_l3.append_to_sbp_buffer(buf); - self.sbas_active.append_to_sbp_buffer(buf); - self.sbas_l5.append_to_sbp_buffer(buf); - self.bds_active.append_to_sbp_buffer(buf); - self.bds_d2nav.append_to_sbp_buffer(buf); - self.bds_b2.append_to_sbp_buffer(buf); - self.bds_b2a.append_to_sbp_buffer(buf); - self.qzss_active.append_to_sbp_buffer(buf); - self.gal_active.append_to_sbp_buffer(buf); - self.gal_e5.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.gps_active.sbp_size(); - size += self.gps_l2c.sbp_size(); - size += self.gps_l5.sbp_size(); - size += self.glo_active.sbp_size(); - size += self.glo_l2of.sbp_size(); - size += self.glo_l3.sbp_size(); - size += self.sbas_active.sbp_size(); - size += self.sbas_l5.sbp_size(); - size += self.bds_active.sbp_size(); - size += self.bds_d2nav.sbp_size(); - size += self.bds_b2.sbp_size(); - size += self.bds_b2a.sbp_size(); - size += self.qzss_active.sbp_size(); - size += self.gal_active.sbp_size(); - size += self.gal_e5.sbp_size(); - size } } @@ -667,113 +551,110 @@ impl crate::serialize::SbpSerialize for GnssCapb { /// Please see the GLO ICD 5.1 "Chapter 4.5 Non-immediate information and /// almanac" for details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgAlmanacGlo { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Values common for all almanac types + #[cfg_attr(feature = "serde", serde(rename(serialize = "common")))] pub common: AlmanacCommonContent, /// Longitude of the first ascending node of the orbit in PZ-90.02 /// coordinate system + #[cfg_attr(feature = "serde", serde(rename(serialize = "lambda_na")))] pub lambda_na: f64, /// Time of the first ascending node passage + #[cfg_attr(feature = "serde", serde(rename(serialize = "t_lambda_na")))] pub t_lambda_na: f64, /// Value of inclination at instant of t_lambda + #[cfg_attr(feature = "serde", serde(rename(serialize = "i")))] pub i: f64, /// Value of Draconian period at instant of t_lambda + #[cfg_attr(feature = "serde", serde(rename(serialize = "t")))] pub t: f64, /// Rate of change of the Draconian period + #[cfg_attr(feature = "serde", serde(rename(serialize = "t_dot")))] pub t_dot: f64, /// Eccentricity at instant of t_lambda + #[cfg_attr(feature = "serde", serde(rename(serialize = "epsilon")))] pub epsilon: f64, /// Argument of perigee at instant of t_lambda + #[cfg_attr(feature = "serde", serde(rename(serialize = "omega")))] pub omega: f64, } -impl MsgAlmanacGlo { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgAlmanacGlo{ - sender_id: None, - common: AlmanacCommonContent::parse(_buf)?, - lambda_na: _buf.read_f64::()?, - t_lambda_na: _buf.read_f64::()?, - i: _buf.read_f64::()?, - t: _buf.read_f64::()?, - t_dot: _buf.read_f64::()?, - epsilon: _buf.read_f64::()?, - omega: _buf.read_f64::()?, - } ) - } +impl ConcreteMessage for MsgAlmanacGlo { + const MESSAGE_TYPE: u16 = 115; + const MESSAGE_NAME: &'static str = "MSG_ALMANAC_GLO"; } -impl super::SBPMessage for MsgAlmanacGlo { - fn get_message_name(&self) -> &'static str { - "MSG_ALMANAC_GLO" - } - fn get_message_type(&self) -> u16 { - 115 +impl SbpMessage for MsgAlmanacGlo { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgAlmanacGlo { - const MESSAGE_TYPE: u16 = 115; - const MESSAGE_NAME: &'static str = "MSG_ALMANAC_GLO"; -} -impl TryFrom for MsgAlmanacGlo { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgAlmanacGlo { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgAlmanacGlo(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgAlmanacGlo(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgAlmanacGlo { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.common.append_to_sbp_buffer(buf); - self.lambda_na.append_to_sbp_buffer(buf); - self.t_lambda_na.append_to_sbp_buffer(buf); - self.i.append_to_sbp_buffer(buf); - self.t.append_to_sbp_buffer(buf); - self.t_dot.append_to_sbp_buffer(buf); - self.epsilon.append_to_sbp_buffer(buf); - self.omega.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.common.sbp_size(); - size += self.lambda_na.sbp_size(); - size += self.t_lambda_na.sbp_size(); - size += self.i.sbp_size(); - size += self.t.sbp_size(); - size += self.t_dot.sbp_size(); - size += self.epsilon.sbp_size(); - size += self.omega.sbp_size(); - size +impl WireFormat for MsgAlmanacGlo { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.common) + + WireFormat::encoded_len(&self.lambda_na) + + WireFormat::encoded_len(&self.t_lambda_na) + + WireFormat::encoded_len(&self.i) + + WireFormat::encoded_len(&self.t) + + WireFormat::encoded_len(&self.t_dot) + + WireFormat::encoded_len(&self.epsilon) + + WireFormat::encoded_len(&self.omega) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.common, buf); + WireFormat::write(&self.lambda_na, buf); + WireFormat::write(&self.t_lambda_na, buf); + WireFormat::write(&self.i, buf); + WireFormat::write(&self.t, buf); + WireFormat::write(&self.t_dot, buf); + WireFormat::write(&self.epsilon, buf); + WireFormat::write(&self.omega, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgAlmanacGlo { + sender_id: None, + common: WireFormat::parse_unchecked(buf), + lambda_na: WireFormat::parse_unchecked(buf), + t_lambda_na: WireFormat::parse_unchecked(buf), + i: WireFormat::parse_unchecked(buf), + t: WireFormat::parse_unchecked(buf), + t_dot: WireFormat::parse_unchecked(buf), + epsilon: WireFormat::parse_unchecked(buf), + omega: WireFormat::parse_unchecked(buf), + } } } @@ -784,113 +665,110 @@ impl crate::serialize::SbpSerialize for MsgAlmanacGlo { /// Please see the GLO ICD 5.1 "Chapter 4.5 Non-immediate information and /// almanac" for details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgAlmanacGloDep { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Values common for all almanac types + #[cfg_attr(feature = "serde", serde(rename(serialize = "common")))] pub common: AlmanacCommonContentDep, /// Longitude of the first ascending node of the orbit in PZ-90.02 /// coordinate system + #[cfg_attr(feature = "serde", serde(rename(serialize = "lambda_na")))] pub lambda_na: f64, /// Time of the first ascending node passage + #[cfg_attr(feature = "serde", serde(rename(serialize = "t_lambda_na")))] pub t_lambda_na: f64, /// Value of inclination at instant of t_lambda + #[cfg_attr(feature = "serde", serde(rename(serialize = "i")))] pub i: f64, /// Value of Draconian period at instant of t_lambda + #[cfg_attr(feature = "serde", serde(rename(serialize = "t")))] pub t: f64, /// Rate of change of the Draconian period + #[cfg_attr(feature = "serde", serde(rename(serialize = "t_dot")))] pub t_dot: f64, /// Eccentricity at instant of t_lambda + #[cfg_attr(feature = "serde", serde(rename(serialize = "epsilon")))] pub epsilon: f64, /// Argument of perigee at instant of t_lambda + #[cfg_attr(feature = "serde", serde(rename(serialize = "omega")))] pub omega: f64, } -impl MsgAlmanacGloDep { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgAlmanacGloDep{ - sender_id: None, - common: AlmanacCommonContentDep::parse(_buf)?, - lambda_na: _buf.read_f64::()?, - t_lambda_na: _buf.read_f64::()?, - i: _buf.read_f64::()?, - t: _buf.read_f64::()?, - t_dot: _buf.read_f64::()?, - epsilon: _buf.read_f64::()?, - omega: _buf.read_f64::()?, - } ) - } +impl ConcreteMessage for MsgAlmanacGloDep { + const MESSAGE_TYPE: u16 = 113; + const MESSAGE_NAME: &'static str = "MSG_ALMANAC_GLO_DEP"; } -impl super::SBPMessage for MsgAlmanacGloDep { - fn get_message_name(&self) -> &'static str { - "MSG_ALMANAC_GLO_DEP" - } - fn get_message_type(&self) -> u16 { - 113 +impl SbpMessage for MsgAlmanacGloDep { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgAlmanacGloDep { - const MESSAGE_TYPE: u16 = 113; - const MESSAGE_NAME: &'static str = "MSG_ALMANAC_GLO_DEP"; } -impl TryFrom for MsgAlmanacGloDep { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgAlmanacGloDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgAlmanacGloDep(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgAlmanacGloDep(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgAlmanacGloDep { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.common.append_to_sbp_buffer(buf); - self.lambda_na.append_to_sbp_buffer(buf); - self.t_lambda_na.append_to_sbp_buffer(buf); - self.i.append_to_sbp_buffer(buf); - self.t.append_to_sbp_buffer(buf); - self.t_dot.append_to_sbp_buffer(buf); - self.epsilon.append_to_sbp_buffer(buf); - self.omega.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.common.sbp_size(); - size += self.lambda_na.sbp_size(); - size += self.t_lambda_na.sbp_size(); - size += self.i.sbp_size(); - size += self.t.sbp_size(); - size += self.t_dot.sbp_size(); - size += self.epsilon.sbp_size(); - size += self.omega.sbp_size(); - size +impl WireFormat for MsgAlmanacGloDep { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.common) + + WireFormat::encoded_len(&self.lambda_na) + + WireFormat::encoded_len(&self.t_lambda_na) + + WireFormat::encoded_len(&self.i) + + WireFormat::encoded_len(&self.t) + + WireFormat::encoded_len(&self.t_dot) + + WireFormat::encoded_len(&self.epsilon) + + WireFormat::encoded_len(&self.omega) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.common, buf); + WireFormat::write(&self.lambda_na, buf); + WireFormat::write(&self.t_lambda_na, buf); + WireFormat::write(&self.i, buf); + WireFormat::write(&self.t, buf); + WireFormat::write(&self.t_dot, buf); + WireFormat::write(&self.epsilon, buf); + WireFormat::write(&self.omega, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgAlmanacGloDep { + sender_id: None, + common: WireFormat::parse_unchecked(buf), + lambda_na: WireFormat::parse_unchecked(buf), + t_lambda_na: WireFormat::parse_unchecked(buf), + i: WireFormat::parse_unchecked(buf), + t: WireFormat::parse_unchecked(buf), + t_dot: WireFormat::parse_unchecked(buf), + epsilon: WireFormat::parse_unchecked(buf), + omega: WireFormat::parse_unchecked(buf), + } } } @@ -901,122 +779,123 @@ impl crate::serialize::SbpSerialize for MsgAlmanacGloDep { /// Please see the Navstar GPS Space Segment/Navigation user interfaces (ICD- /// GPS-200, Chapter 20.3.3.5.1.2 Almanac Data) for more details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgAlmanacGPS { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgAlmanacGps { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Values common for all almanac types + #[cfg_attr(feature = "serde", serde(rename(serialize = "common")))] pub common: AlmanacCommonContent, /// Mean anomaly at reference time + #[cfg_attr(feature = "serde", serde(rename(serialize = "m0")))] pub m0: f64, /// Eccentricity of satellite orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "ecc")))] pub ecc: f64, /// Square root of the semi-major axis of orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "sqrta")))] pub sqrta: f64, /// Longitude of ascending node of orbit plane at weekly epoch + #[cfg_attr(feature = "serde", serde(rename(serialize = "omega0")))] pub omega0: f64, /// Rate of right ascension + #[cfg_attr(feature = "serde", serde(rename(serialize = "omegadot")))] pub omegadot: f64, /// Argument of perigee + #[cfg_attr(feature = "serde", serde(rename(serialize = "w")))] pub w: f64, /// Inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc")))] pub inc: f64, /// Polynomial clock correction coefficient (clock bias) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af0")))] pub af0: f64, /// Polynomial clock correction coefficient (clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af1")))] pub af1: f64, } -impl MsgAlmanacGPS { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgAlmanacGPS{ - sender_id: None, - common: AlmanacCommonContent::parse(_buf)?, - m0: _buf.read_f64::()?, - ecc: _buf.read_f64::()?, - sqrta: _buf.read_f64::()?, - omega0: _buf.read_f64::()?, - omegadot: _buf.read_f64::()?, - w: _buf.read_f64::()?, - inc: _buf.read_f64::()?, - af0: _buf.read_f64::()?, - af1: _buf.read_f64::()?, - } ) - } +impl ConcreteMessage for MsgAlmanacGps { + const MESSAGE_TYPE: u16 = 114; + const MESSAGE_NAME: &'static str = "MSG_ALMANAC_GPS"; } -impl super::SBPMessage for MsgAlmanacGPS { - fn get_message_name(&self) -> &'static str { - "MSG_ALMANAC_GPS" - } - fn get_message_type(&self) -> u16 { - 114 +impl SbpMessage for MsgAlmanacGps { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgAlmanacGPS { - const MESSAGE_TYPE: u16 = 114; - const MESSAGE_NAME: &'static str = "MSG_ALMANAC_GPS"; } -impl TryFrom for MsgAlmanacGPS { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgAlmanacGps { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgAlmanacGPS(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgAlmanacGps(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgAlmanacGPS { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.common.append_to_sbp_buffer(buf); - self.m0.append_to_sbp_buffer(buf); - self.ecc.append_to_sbp_buffer(buf); - self.sqrta.append_to_sbp_buffer(buf); - self.omega0.append_to_sbp_buffer(buf); - self.omegadot.append_to_sbp_buffer(buf); - self.w.append_to_sbp_buffer(buf); - self.inc.append_to_sbp_buffer(buf); - self.af0.append_to_sbp_buffer(buf); - self.af1.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.common.sbp_size(); - size += self.m0.sbp_size(); - size += self.ecc.sbp_size(); - size += self.sqrta.sbp_size(); - size += self.omega0.sbp_size(); - size += self.omegadot.sbp_size(); - size += self.w.sbp_size(); - size += self.inc.sbp_size(); - size += self.af0.sbp_size(); - size += self.af1.sbp_size(); - size +impl WireFormat for MsgAlmanacGps { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.common) + + WireFormat::encoded_len(&self.m0) + + WireFormat::encoded_len(&self.ecc) + + WireFormat::encoded_len(&self.sqrta) + + WireFormat::encoded_len(&self.omega0) + + WireFormat::encoded_len(&self.omegadot) + + WireFormat::encoded_len(&self.w) + + WireFormat::encoded_len(&self.inc) + + WireFormat::encoded_len(&self.af0) + + WireFormat::encoded_len(&self.af1) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.common, buf); + WireFormat::write(&self.m0, buf); + WireFormat::write(&self.ecc, buf); + WireFormat::write(&self.sqrta, buf); + WireFormat::write(&self.omega0, buf); + WireFormat::write(&self.omegadot, buf); + WireFormat::write(&self.w, buf); + WireFormat::write(&self.inc, buf); + WireFormat::write(&self.af0, buf); + WireFormat::write(&self.af1, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgAlmanacGps { + sender_id: None, + common: WireFormat::parse_unchecked(buf), + m0: WireFormat::parse_unchecked(buf), + ecc: WireFormat::parse_unchecked(buf), + sqrta: WireFormat::parse_unchecked(buf), + omega0: WireFormat::parse_unchecked(buf), + omegadot: WireFormat::parse_unchecked(buf), + w: WireFormat::parse_unchecked(buf), + inc: WireFormat::parse_unchecked(buf), + af0: WireFormat::parse_unchecked(buf), + af1: WireFormat::parse_unchecked(buf), + } } } @@ -1027,122 +906,123 @@ impl crate::serialize::SbpSerialize for MsgAlmanacGPS { /// Please see the Navstar GPS Space Segment/Navigation user interfaces (ICD- /// GPS-200, Chapter 20.3.3.5.1.2 Almanac Data) for more details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgAlmanacGPSDep { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgAlmanacGpsDep { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Values common for all almanac types + #[cfg_attr(feature = "serde", serde(rename(serialize = "common")))] pub common: AlmanacCommonContentDep, /// Mean anomaly at reference time + #[cfg_attr(feature = "serde", serde(rename(serialize = "m0")))] pub m0: f64, /// Eccentricity of satellite orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "ecc")))] pub ecc: f64, /// Square root of the semi-major axis of orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "sqrta")))] pub sqrta: f64, /// Longitude of ascending node of orbit plane at weekly epoch + #[cfg_attr(feature = "serde", serde(rename(serialize = "omega0")))] pub omega0: f64, /// Rate of right ascension + #[cfg_attr(feature = "serde", serde(rename(serialize = "omegadot")))] pub omegadot: f64, /// Argument of perigee + #[cfg_attr(feature = "serde", serde(rename(serialize = "w")))] pub w: f64, /// Inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc")))] pub inc: f64, /// Polynomial clock correction coefficient (clock bias) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af0")))] pub af0: f64, /// Polynomial clock correction coefficient (clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af1")))] pub af1: f64, } -impl MsgAlmanacGPSDep { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgAlmanacGPSDep{ - sender_id: None, - common: AlmanacCommonContentDep::parse(_buf)?, - m0: _buf.read_f64::()?, - ecc: _buf.read_f64::()?, - sqrta: _buf.read_f64::()?, - omega0: _buf.read_f64::()?, - omegadot: _buf.read_f64::()?, - w: _buf.read_f64::()?, - inc: _buf.read_f64::()?, - af0: _buf.read_f64::()?, - af1: _buf.read_f64::()?, - } ) - } +impl ConcreteMessage for MsgAlmanacGpsDep { + const MESSAGE_TYPE: u16 = 112; + const MESSAGE_NAME: &'static str = "MSG_ALMANAC_GPS_DEP"; } -impl super::SBPMessage for MsgAlmanacGPSDep { - fn get_message_name(&self) -> &'static str { - "MSG_ALMANAC_GPS_DEP" - } - fn get_message_type(&self) -> u16 { - 112 +impl SbpMessage for MsgAlmanacGpsDep { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgAlmanacGPSDep { - const MESSAGE_TYPE: u16 = 112; - const MESSAGE_NAME: &'static str = "MSG_ALMANAC_GPS_DEP"; } -impl TryFrom for MsgAlmanacGPSDep { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgAlmanacGpsDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgAlmanacGPSDep(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgAlmanacGpsDep(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgAlmanacGPSDep { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.common.append_to_sbp_buffer(buf); - self.m0.append_to_sbp_buffer(buf); - self.ecc.append_to_sbp_buffer(buf); - self.sqrta.append_to_sbp_buffer(buf); - self.omega0.append_to_sbp_buffer(buf); - self.omegadot.append_to_sbp_buffer(buf); - self.w.append_to_sbp_buffer(buf); - self.inc.append_to_sbp_buffer(buf); - self.af0.append_to_sbp_buffer(buf); - self.af1.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.common.sbp_size(); - size += self.m0.sbp_size(); - size += self.ecc.sbp_size(); - size += self.sqrta.sbp_size(); - size += self.omega0.sbp_size(); - size += self.omegadot.sbp_size(); - size += self.w.sbp_size(); - size += self.inc.sbp_size(); - size += self.af0.sbp_size(); - size += self.af1.sbp_size(); - size +impl WireFormat for MsgAlmanacGpsDep { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.common) + + WireFormat::encoded_len(&self.m0) + + WireFormat::encoded_len(&self.ecc) + + WireFormat::encoded_len(&self.sqrta) + + WireFormat::encoded_len(&self.omega0) + + WireFormat::encoded_len(&self.omegadot) + + WireFormat::encoded_len(&self.w) + + WireFormat::encoded_len(&self.inc) + + WireFormat::encoded_len(&self.af0) + + WireFormat::encoded_len(&self.af1) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.common, buf); + WireFormat::write(&self.m0, buf); + WireFormat::write(&self.ecc, buf); + WireFormat::write(&self.sqrta, buf); + WireFormat::write(&self.omega0, buf); + WireFormat::write(&self.omegadot, buf); + WireFormat::write(&self.w, buf); + WireFormat::write(&self.inc, buf); + WireFormat::write(&self.af0, buf); + WireFormat::write(&self.af1, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgAlmanacGpsDep { + sender_id: None, + common: WireFormat::parse_unchecked(buf), + m0: WireFormat::parse_unchecked(buf), + ecc: WireFormat::parse_unchecked(buf), + sqrta: WireFormat::parse_unchecked(buf), + omega0: WireFormat::parse_unchecked(buf), + omegadot: WireFormat::parse_unchecked(buf), + w: WireFormat::parse_unchecked(buf), + inc: WireFormat::parse_unchecked(buf), + af0: WireFormat::parse_unchecked(buf), + af1: WireFormat::parse_unchecked(buf), + } } } @@ -1154,87 +1034,74 @@ impl crate::serialize::SbpSerialize for MsgAlmanacGPSDep { /// accuracy surveyed location of the base station. Any error here will result /// in an error in the pseudo-absolute position output. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgBasePosECEF { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgBasePosEcef { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// ECEF X coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "x")))] pub x: f64, /// ECEF Y coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "y")))] pub y: f64, /// ECEF Z coordinate + #[cfg_attr(feature = "serde", serde(rename(serialize = "z")))] pub z: f64, } -impl MsgBasePosECEF { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgBasePosECEF{ - sender_id: None, - x: _buf.read_f64::()?, - y: _buf.read_f64::()?, - z: _buf.read_f64::()?, - } ) - } +impl ConcreteMessage for MsgBasePosEcef { + const MESSAGE_TYPE: u16 = 72; + const MESSAGE_NAME: &'static str = "MSG_BASE_POS_ECEF"; } -impl super::SBPMessage for MsgBasePosECEF { - fn get_message_name(&self) -> &'static str { - "MSG_BASE_POS_ECEF" - } - fn get_message_type(&self) -> u16 { - 72 +impl SbpMessage for MsgBasePosEcef { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgBasePosECEF { - const MESSAGE_TYPE: u16 = 72; - const MESSAGE_NAME: &'static str = "MSG_BASE_POS_ECEF"; -} -impl TryFrom for MsgBasePosECEF { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgBasePosEcef { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgBasePosECEF(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgBasePosEcef(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgBasePosECEF { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.x.append_to_sbp_buffer(buf); - self.y.append_to_sbp_buffer(buf); - self.z.append_to_sbp_buffer(buf); +impl WireFormat for MsgBasePosEcef { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.x) + + WireFormat::encoded_len(&self.y) + + WireFormat::encoded_len(&self.z) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.x.sbp_size(); - size += self.y.sbp_size(); - size += self.z.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.x, buf); + WireFormat::write(&self.y, buf); + WireFormat::write(&self.z, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgBasePosEcef { + sender_id: None, + x: WireFormat::parse_unchecked(buf), + y: WireFormat::parse_unchecked(buf), + z: WireFormat::parse_unchecked(buf), + } } } @@ -1245,87 +1112,74 @@ impl crate::serialize::SbpSerialize for MsgBasePosECEF { /// required to be a high-accuracy surveyed location of the base station. Any /// error here will result in an error in the pseudo-absolute position output. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgBasePosLLH { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgBasePosLlh { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "lat")))] pub lat: f64, /// Longitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "lon")))] pub lon: f64, /// Height + #[cfg_attr(feature = "serde", serde(rename(serialize = "height")))] pub height: f64, } -impl MsgBasePosLLH { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgBasePosLLH{ - sender_id: None, - lat: _buf.read_f64::()?, - lon: _buf.read_f64::()?, - height: _buf.read_f64::()?, - } ) - } +impl ConcreteMessage for MsgBasePosLlh { + const MESSAGE_TYPE: u16 = 68; + const MESSAGE_NAME: &'static str = "MSG_BASE_POS_LLH"; } -impl super::SBPMessage for MsgBasePosLLH { - fn get_message_name(&self) -> &'static str { - "MSG_BASE_POS_LLH" - } - fn get_message_type(&self) -> u16 { - 68 +impl SbpMessage for MsgBasePosLlh { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgBasePosLLH { - const MESSAGE_TYPE: u16 = 68; - const MESSAGE_NAME: &'static str = "MSG_BASE_POS_LLH"; } -impl TryFrom for MsgBasePosLLH { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgBasePosLlh { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgBasePosLLH(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgBasePosLlh(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgBasePosLLH { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.lat.append_to_sbp_buffer(buf); - self.lon.append_to_sbp_buffer(buf); - self.height.append_to_sbp_buffer(buf); +impl WireFormat for MsgBasePosLlh { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.lat) + + WireFormat::encoded_len(&self.lon) + + WireFormat::encoded_len(&self.height) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.lat.sbp_size(); - size += self.lon.sbp_size(); - size += self.height.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.lat, buf); + WireFormat::write(&self.lon, buf); + WireFormat::write(&self.height, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgBasePosLlh { + sender_id: None, + lat: WireFormat::parse_unchecked(buf), + lon: WireFormat::parse_unchecked(buf), + height: WireFormat::parse_unchecked(buf), + } } } @@ -1336,200 +1190,229 @@ impl crate::serialize::SbpSerialize for MsgBasePosLLH { /// Please see the BeiDou Navigation Satellite System SIS-ICD Version 2.1, /// Table 5-9 for more details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgEphemerisBds { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Values common for all ephemeris types + #[cfg_attr(feature = "serde", serde(rename(serialize = "common")))] pub common: EphemerisCommonContent, /// Group delay differential for B1 + #[cfg_attr(feature = "serde", serde(rename(serialize = "tgd1")))] pub tgd1: f32, /// Group delay differential for B2 + #[cfg_attr(feature = "serde", serde(rename(serialize = "tgd2")))] pub tgd2: f32, /// Amplitude of the sine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rs")))] pub c_rs: f32, /// Amplitude of the cosine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rc")))] pub c_rc: f32, /// Amplitude of the cosine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_uc")))] pub c_uc: f32, /// Amplitude of the sine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_us")))] pub c_us: f32, /// Amplitude of the cosine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_ic")))] pub c_ic: f32, /// Amplitude of the sine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_is")))] pub c_is: f32, /// Mean motion difference + #[cfg_attr(feature = "serde", serde(rename(serialize = "dn")))] pub dn: f64, /// Mean anomaly at reference time + #[cfg_attr(feature = "serde", serde(rename(serialize = "m0")))] pub m0: f64, /// Eccentricity of satellite orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "ecc")))] pub ecc: f64, /// Square root of the semi-major axis of orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "sqrta")))] pub sqrta: f64, /// Longitude of ascending node of orbit plane at weekly epoch + #[cfg_attr(feature = "serde", serde(rename(serialize = "omega0")))] pub omega0: f64, /// Rate of right ascension + #[cfg_attr(feature = "serde", serde(rename(serialize = "omegadot")))] pub omegadot: f64, /// Argument of perigee + #[cfg_attr(feature = "serde", serde(rename(serialize = "w")))] pub w: f64, /// Inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc")))] pub inc: f64, /// Inclination first derivative + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc_dot")))] pub inc_dot: f64, /// Polynomial clock correction coefficient (clock bias) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af0")))] pub af0: f64, /// Polynomial clock correction coefficient (clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af1")))] pub af1: f32, /// Polynomial clock correction coefficient (rate of clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af2")))] pub af2: f32, /// Clock reference - pub toc: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "toc")))] + pub toc: GpsTimeSec, /// Issue of ephemeris data /// Calculated from the navigation data parameter t_oe per RTCM/CSNO /// recommendation: IODE = mod (t_oe / 720, 240) + #[cfg_attr(feature = "serde", serde(rename(serialize = "iode")))] pub iode: u8, /// Issue of clock data /// Calculated from the navigation data parameter t_oe per RTCM/CSNO /// recommendation: IODE = mod (t_oc / 720, 240) + #[cfg_attr(feature = "serde", serde(rename(serialize = "iodc")))] pub iodc: u16, } -impl MsgEphemerisBds { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgEphemerisBds{ - sender_id: None, - common: EphemerisCommonContent::parse(_buf)?, - tgd1: _buf.read_f32::()?, - tgd2: _buf.read_f32::()?, - c_rs: _buf.read_f32::()?, - c_rc: _buf.read_f32::()?, - c_uc: _buf.read_f32::()?, - c_us: _buf.read_f32::()?, - c_ic: _buf.read_f32::()?, - c_is: _buf.read_f32::()?, - dn: _buf.read_f64::()?, - m0: _buf.read_f64::()?, - ecc: _buf.read_f64::()?, - sqrta: _buf.read_f64::()?, - omega0: _buf.read_f64::()?, - omegadot: _buf.read_f64::()?, - w: _buf.read_f64::()?, - inc: _buf.read_f64::()?, - inc_dot: _buf.read_f64::()?, - af0: _buf.read_f64::()?, - af1: _buf.read_f32::()?, - af2: _buf.read_f32::()?, - toc: GPSTimeSec::parse(_buf)?, - iode: _buf.read_u8()?, - iodc: _buf.read_u16::()?, - } ) - } -} -impl super::SBPMessage for MsgEphemerisBds { - fn get_message_name(&self) -> &'static str { - "MSG_EPHEMERIS_BDS" - } - - fn get_message_type(&self) -> u16 { - 137 - } - - fn get_sender_id(&self) -> Option { +impl ConcreteMessage for MsgEphemerisBds { + const MESSAGE_TYPE: u16 = 137; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_BDS"; +} + +impl SbpMessage for MsgEphemerisBds { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME + } + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgEphemerisBds { - const MESSAGE_TYPE: u16 = 137; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_BDS"; } -impl TryFrom for MsgEphemerisBds { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgEphemerisBds { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgEphemerisBds(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgEphemerisBds(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgEphemerisBds { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.common.append_to_sbp_buffer(buf); - self.tgd1.append_to_sbp_buffer(buf); - self.tgd2.append_to_sbp_buffer(buf); - self.c_rs.append_to_sbp_buffer(buf); - self.c_rc.append_to_sbp_buffer(buf); - self.c_uc.append_to_sbp_buffer(buf); - self.c_us.append_to_sbp_buffer(buf); - self.c_ic.append_to_sbp_buffer(buf); - self.c_is.append_to_sbp_buffer(buf); - self.dn.append_to_sbp_buffer(buf); - self.m0.append_to_sbp_buffer(buf); - self.ecc.append_to_sbp_buffer(buf); - self.sqrta.append_to_sbp_buffer(buf); - self.omega0.append_to_sbp_buffer(buf); - self.omegadot.append_to_sbp_buffer(buf); - self.w.append_to_sbp_buffer(buf); - self.inc.append_to_sbp_buffer(buf); - self.inc_dot.append_to_sbp_buffer(buf); - self.af0.append_to_sbp_buffer(buf); - self.af1.append_to_sbp_buffer(buf); - self.af2.append_to_sbp_buffer(buf); - self.toc.append_to_sbp_buffer(buf); - self.iode.append_to_sbp_buffer(buf); - self.iodc.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.common.sbp_size(); - size += self.tgd1.sbp_size(); - size += self.tgd2.sbp_size(); - size += self.c_rs.sbp_size(); - size += self.c_rc.sbp_size(); - size += self.c_uc.sbp_size(); - size += self.c_us.sbp_size(); - size += self.c_ic.sbp_size(); - size += self.c_is.sbp_size(); - size += self.dn.sbp_size(); - size += self.m0.sbp_size(); - size += self.ecc.sbp_size(); - size += self.sqrta.sbp_size(); - size += self.omega0.sbp_size(); - size += self.omegadot.sbp_size(); - size += self.w.sbp_size(); - size += self.inc.sbp_size(); - size += self.inc_dot.sbp_size(); - size += self.af0.sbp_size(); - size += self.af1.sbp_size(); - size += self.af2.sbp_size(); - size += self.toc.sbp_size(); - size += self.iode.sbp_size(); - size += self.iodc.sbp_size(); - size +impl WireFormat for MsgEphemerisBds { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.common) + + WireFormat::encoded_len(&self.tgd1) + + WireFormat::encoded_len(&self.tgd2) + + WireFormat::encoded_len(&self.c_rs) + + WireFormat::encoded_len(&self.c_rc) + + WireFormat::encoded_len(&self.c_uc) + + WireFormat::encoded_len(&self.c_us) + + WireFormat::encoded_len(&self.c_ic) + + WireFormat::encoded_len(&self.c_is) + + WireFormat::encoded_len(&self.dn) + + WireFormat::encoded_len(&self.m0) + + WireFormat::encoded_len(&self.ecc) + + WireFormat::encoded_len(&self.sqrta) + + WireFormat::encoded_len(&self.omega0) + + WireFormat::encoded_len(&self.omegadot) + + WireFormat::encoded_len(&self.w) + + WireFormat::encoded_len(&self.inc) + + WireFormat::encoded_len(&self.inc_dot) + + WireFormat::encoded_len(&self.af0) + + WireFormat::encoded_len(&self.af1) + + WireFormat::encoded_len(&self.af2) + + WireFormat::encoded_len(&self.toc) + + WireFormat::encoded_len(&self.iode) + + WireFormat::encoded_len(&self.iodc) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.common, buf); + WireFormat::write(&self.tgd1, buf); + WireFormat::write(&self.tgd2, buf); + WireFormat::write(&self.c_rs, buf); + WireFormat::write(&self.c_rc, buf); + WireFormat::write(&self.c_uc, buf); + WireFormat::write(&self.c_us, buf); + WireFormat::write(&self.c_ic, buf); + WireFormat::write(&self.c_is, buf); + WireFormat::write(&self.dn, buf); + WireFormat::write(&self.m0, buf); + WireFormat::write(&self.ecc, buf); + WireFormat::write(&self.sqrta, buf); + WireFormat::write(&self.omega0, buf); + WireFormat::write(&self.omegadot, buf); + WireFormat::write(&self.w, buf); + WireFormat::write(&self.inc, buf); + WireFormat::write(&self.inc_dot, buf); + WireFormat::write(&self.af0, buf); + WireFormat::write(&self.af1, buf); + WireFormat::write(&self.af2, buf); + WireFormat::write(&self.toc, buf); + WireFormat::write(&self.iode, buf); + WireFormat::write(&self.iodc, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgEphemerisBds { + sender_id: None, + common: WireFormat::parse_unchecked(buf), + tgd1: WireFormat::parse_unchecked(buf), + tgd2: WireFormat::parse_unchecked(buf), + c_rs: WireFormat::parse_unchecked(buf), + c_rc: WireFormat::parse_unchecked(buf), + c_uc: WireFormat::parse_unchecked(buf), + c_us: WireFormat::parse_unchecked(buf), + c_ic: WireFormat::parse_unchecked(buf), + c_is: WireFormat::parse_unchecked(buf), + dn: WireFormat::parse_unchecked(buf), + m0: WireFormat::parse_unchecked(buf), + ecc: WireFormat::parse_unchecked(buf), + sqrta: WireFormat::parse_unchecked(buf), + omega0: WireFormat::parse_unchecked(buf), + omegadot: WireFormat::parse_unchecked(buf), + w: WireFormat::parse_unchecked(buf), + inc: WireFormat::parse_unchecked(buf), + inc_dot: WireFormat::parse_unchecked(buf), + af0: WireFormat::parse_unchecked(buf), + af1: WireFormat::parse_unchecked(buf), + af2: WireFormat::parse_unchecked(buf), + toc: WireFormat::parse_unchecked(buf), + iode: WireFormat::parse_unchecked(buf), + iodc: WireFormat::parse_unchecked(buf), + } } } @@ -1537,206 +1420,239 @@ impl crate::serialize::SbpSerialize for MsgEphemerisBds { /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgEphemerisDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Group delay differential between L1 and L2 + #[cfg_attr(feature = "serde", serde(rename(serialize = "tgd")))] pub tgd: f64, /// Amplitude of the sine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rs")))] pub c_rs: f64, /// Amplitude of the cosine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rc")))] pub c_rc: f64, /// Amplitude of the cosine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_uc")))] pub c_uc: f64, /// Amplitude of the sine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_us")))] pub c_us: f64, /// Amplitude of the cosine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_ic")))] pub c_ic: f64, /// Amplitude of the sine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_is")))] pub c_is: f64, /// Mean motion difference + #[cfg_attr(feature = "serde", serde(rename(serialize = "dn")))] pub dn: f64, /// Mean anomaly at reference time + #[cfg_attr(feature = "serde", serde(rename(serialize = "m0")))] pub m0: f64, /// Eccentricity of satellite orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "ecc")))] pub ecc: f64, /// Square root of the semi-major axis of orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "sqrta")))] pub sqrta: f64, /// Longitude of ascending node of orbit plane at weekly epoch + #[cfg_attr(feature = "serde", serde(rename(serialize = "omega0")))] pub omega0: f64, /// Rate of right ascension + #[cfg_attr(feature = "serde", serde(rename(serialize = "omegadot")))] pub omegadot: f64, /// Argument of perigee + #[cfg_attr(feature = "serde", serde(rename(serialize = "w")))] pub w: f64, /// Inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc")))] pub inc: f64, /// Inclination first derivative + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc_dot")))] pub inc_dot: f64, /// Polynomial clock correction coefficient (clock bias) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af0")))] pub af0: f64, /// Polynomial clock correction coefficient (clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af1")))] pub af1: f64, /// Polynomial clock correction coefficient (rate of clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af2")))] pub af2: f64, /// Time of week + #[cfg_attr(feature = "serde", serde(rename(serialize = "toe_tow")))] pub toe_tow: f64, /// Week number + #[cfg_attr(feature = "serde", serde(rename(serialize = "toe_wn")))] pub toe_wn: u16, /// Clock reference time of week + #[cfg_attr(feature = "serde", serde(rename(serialize = "toc_tow")))] pub toc_tow: f64, /// Clock reference week number + #[cfg_attr(feature = "serde", serde(rename(serialize = "toc_wn")))] pub toc_wn: u16, /// Is valid? + #[cfg_attr(feature = "serde", serde(rename(serialize = "valid")))] pub valid: u8, /// Satellite is healthy? + #[cfg_attr(feature = "serde", serde(rename(serialize = "healthy")))] pub healthy: u8, /// PRN being tracked + #[cfg_attr(feature = "serde", serde(rename(serialize = "prn")))] pub prn: u8, } -impl MsgEphemerisDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgEphemerisDepA{ - sender_id: None, - tgd: _buf.read_f64::()?, - c_rs: _buf.read_f64::()?, - c_rc: _buf.read_f64::()?, - c_uc: _buf.read_f64::()?, - c_us: _buf.read_f64::()?, - c_ic: _buf.read_f64::()?, - c_is: _buf.read_f64::()?, - dn: _buf.read_f64::()?, - m0: _buf.read_f64::()?, - ecc: _buf.read_f64::()?, - sqrta: _buf.read_f64::()?, - omega0: _buf.read_f64::()?, - omegadot: _buf.read_f64::()?, - w: _buf.read_f64::()?, - inc: _buf.read_f64::()?, - inc_dot: _buf.read_f64::()?, - af0: _buf.read_f64::()?, - af1: _buf.read_f64::()?, - af2: _buf.read_f64::()?, - toe_tow: _buf.read_f64::()?, - toe_wn: _buf.read_u16::()?, - toc_tow: _buf.read_f64::()?, - toc_wn: _buf.read_u16::()?, - valid: _buf.read_u8()?, - healthy: _buf.read_u8()?, - prn: _buf.read_u8()?, - } ) - } -} -impl super::SBPMessage for MsgEphemerisDepA { - fn get_message_name(&self) -> &'static str { - "MSG_EPHEMERIS_DEP_A" - } - - fn get_message_type(&self) -> u16 { - 26 - } - - fn get_sender_id(&self) -> Option { +impl ConcreteMessage for MsgEphemerisDepA { + const MESSAGE_TYPE: u16 = 26; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_DEP_A"; +} + +impl SbpMessage for MsgEphemerisDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME + } + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgEphemerisDepA { - const MESSAGE_TYPE: u16 = 26; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_DEP_A"; } -impl TryFrom for MsgEphemerisDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgEphemerisDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgEphemerisDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgEphemerisDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgEphemerisDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tgd.append_to_sbp_buffer(buf); - self.c_rs.append_to_sbp_buffer(buf); - self.c_rc.append_to_sbp_buffer(buf); - self.c_uc.append_to_sbp_buffer(buf); - self.c_us.append_to_sbp_buffer(buf); - self.c_ic.append_to_sbp_buffer(buf); - self.c_is.append_to_sbp_buffer(buf); - self.dn.append_to_sbp_buffer(buf); - self.m0.append_to_sbp_buffer(buf); - self.ecc.append_to_sbp_buffer(buf); - self.sqrta.append_to_sbp_buffer(buf); - self.omega0.append_to_sbp_buffer(buf); - self.omegadot.append_to_sbp_buffer(buf); - self.w.append_to_sbp_buffer(buf); - self.inc.append_to_sbp_buffer(buf); - self.inc_dot.append_to_sbp_buffer(buf); - self.af0.append_to_sbp_buffer(buf); - self.af1.append_to_sbp_buffer(buf); - self.af2.append_to_sbp_buffer(buf); - self.toe_tow.append_to_sbp_buffer(buf); - self.toe_wn.append_to_sbp_buffer(buf); - self.toc_tow.append_to_sbp_buffer(buf); - self.toc_wn.append_to_sbp_buffer(buf); - self.valid.append_to_sbp_buffer(buf); - self.healthy.append_to_sbp_buffer(buf); - self.prn.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tgd.sbp_size(); - size += self.c_rs.sbp_size(); - size += self.c_rc.sbp_size(); - size += self.c_uc.sbp_size(); - size += self.c_us.sbp_size(); - size += self.c_ic.sbp_size(); - size += self.c_is.sbp_size(); - size += self.dn.sbp_size(); - size += self.m0.sbp_size(); - size += self.ecc.sbp_size(); - size += self.sqrta.sbp_size(); - size += self.omega0.sbp_size(); - size += self.omegadot.sbp_size(); - size += self.w.sbp_size(); - size += self.inc.sbp_size(); - size += self.inc_dot.sbp_size(); - size += self.af0.sbp_size(); - size += self.af1.sbp_size(); - size += self.af2.sbp_size(); - size += self.toe_tow.sbp_size(); - size += self.toe_wn.sbp_size(); - size += self.toc_tow.sbp_size(); - size += self.toc_wn.sbp_size(); - size += self.valid.sbp_size(); - size += self.healthy.sbp_size(); - size += self.prn.sbp_size(); - size +impl WireFormat for MsgEphemerisDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tgd) + + WireFormat::encoded_len(&self.c_rs) + + WireFormat::encoded_len(&self.c_rc) + + WireFormat::encoded_len(&self.c_uc) + + WireFormat::encoded_len(&self.c_us) + + WireFormat::encoded_len(&self.c_ic) + + WireFormat::encoded_len(&self.c_is) + + WireFormat::encoded_len(&self.dn) + + WireFormat::encoded_len(&self.m0) + + WireFormat::encoded_len(&self.ecc) + + WireFormat::encoded_len(&self.sqrta) + + WireFormat::encoded_len(&self.omega0) + + WireFormat::encoded_len(&self.omegadot) + + WireFormat::encoded_len(&self.w) + + WireFormat::encoded_len(&self.inc) + + WireFormat::encoded_len(&self.inc_dot) + + WireFormat::encoded_len(&self.af0) + + WireFormat::encoded_len(&self.af1) + + WireFormat::encoded_len(&self.af2) + + WireFormat::encoded_len(&self.toe_tow) + + WireFormat::encoded_len(&self.toe_wn) + + WireFormat::encoded_len(&self.toc_tow) + + WireFormat::encoded_len(&self.toc_wn) + + WireFormat::encoded_len(&self.valid) + + WireFormat::encoded_len(&self.healthy) + + WireFormat::encoded_len(&self.prn) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tgd, buf); + WireFormat::write(&self.c_rs, buf); + WireFormat::write(&self.c_rc, buf); + WireFormat::write(&self.c_uc, buf); + WireFormat::write(&self.c_us, buf); + WireFormat::write(&self.c_ic, buf); + WireFormat::write(&self.c_is, buf); + WireFormat::write(&self.dn, buf); + WireFormat::write(&self.m0, buf); + WireFormat::write(&self.ecc, buf); + WireFormat::write(&self.sqrta, buf); + WireFormat::write(&self.omega0, buf); + WireFormat::write(&self.omegadot, buf); + WireFormat::write(&self.w, buf); + WireFormat::write(&self.inc, buf); + WireFormat::write(&self.inc_dot, buf); + WireFormat::write(&self.af0, buf); + WireFormat::write(&self.af1, buf); + WireFormat::write(&self.af2, buf); + WireFormat::write(&self.toe_tow, buf); + WireFormat::write(&self.toe_wn, buf); + WireFormat::write(&self.toc_tow, buf); + WireFormat::write(&self.toc_wn, buf); + WireFormat::write(&self.valid, buf); + WireFormat::write(&self.healthy, buf); + WireFormat::write(&self.prn, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgEphemerisDepA { + sender_id: None, + tgd: WireFormat::parse_unchecked(buf), + c_rs: WireFormat::parse_unchecked(buf), + c_rc: WireFormat::parse_unchecked(buf), + c_uc: WireFormat::parse_unchecked(buf), + c_us: WireFormat::parse_unchecked(buf), + c_ic: WireFormat::parse_unchecked(buf), + c_is: WireFormat::parse_unchecked(buf), + dn: WireFormat::parse_unchecked(buf), + m0: WireFormat::parse_unchecked(buf), + ecc: WireFormat::parse_unchecked(buf), + sqrta: WireFormat::parse_unchecked(buf), + omega0: WireFormat::parse_unchecked(buf), + omegadot: WireFormat::parse_unchecked(buf), + w: WireFormat::parse_unchecked(buf), + inc: WireFormat::parse_unchecked(buf), + inc_dot: WireFormat::parse_unchecked(buf), + af0: WireFormat::parse_unchecked(buf), + af1: WireFormat::parse_unchecked(buf), + af2: WireFormat::parse_unchecked(buf), + toe_tow: WireFormat::parse_unchecked(buf), + toe_wn: WireFormat::parse_unchecked(buf), + toc_tow: WireFormat::parse_unchecked(buf), + toc_wn: WireFormat::parse_unchecked(buf), + valid: WireFormat::parse_unchecked(buf), + healthy: WireFormat::parse_unchecked(buf), + prn: WireFormat::parse_unchecked(buf), + } } } @@ -1744,211 +1660,246 @@ impl crate::serialize::SbpSerialize for MsgEphemerisDepA { /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgEphemerisDepB { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Group delay differential between L1 and L2 + #[cfg_attr(feature = "serde", serde(rename(serialize = "tgd")))] pub tgd: f64, /// Amplitude of the sine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rs")))] pub c_rs: f64, /// Amplitude of the cosine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rc")))] pub c_rc: f64, /// Amplitude of the cosine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_uc")))] pub c_uc: f64, /// Amplitude of the sine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_us")))] pub c_us: f64, /// Amplitude of the cosine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_ic")))] pub c_ic: f64, /// Amplitude of the sine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_is")))] pub c_is: f64, /// Mean motion difference + #[cfg_attr(feature = "serde", serde(rename(serialize = "dn")))] pub dn: f64, /// Mean anomaly at reference time + #[cfg_attr(feature = "serde", serde(rename(serialize = "m0")))] pub m0: f64, /// Eccentricity of satellite orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "ecc")))] pub ecc: f64, /// Square root of the semi-major axis of orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "sqrta")))] pub sqrta: f64, /// Longitude of ascending node of orbit plane at weekly epoch + #[cfg_attr(feature = "serde", serde(rename(serialize = "omega0")))] pub omega0: f64, /// Rate of right ascension + #[cfg_attr(feature = "serde", serde(rename(serialize = "omegadot")))] pub omegadot: f64, /// Argument of perigee + #[cfg_attr(feature = "serde", serde(rename(serialize = "w")))] pub w: f64, /// Inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc")))] pub inc: f64, /// Inclination first derivative + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc_dot")))] pub inc_dot: f64, /// Polynomial clock correction coefficient (clock bias) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af0")))] pub af0: f64, /// Polynomial clock correction coefficient (clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af1")))] pub af1: f64, /// Polynomial clock correction coefficient (rate of clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af2")))] pub af2: f64, /// Time of week + #[cfg_attr(feature = "serde", serde(rename(serialize = "toe_tow")))] pub toe_tow: f64, /// Week number + #[cfg_attr(feature = "serde", serde(rename(serialize = "toe_wn")))] pub toe_wn: u16, /// Clock reference time of week + #[cfg_attr(feature = "serde", serde(rename(serialize = "toc_tow")))] pub toc_tow: f64, /// Clock reference week number + #[cfg_attr(feature = "serde", serde(rename(serialize = "toc_wn")))] pub toc_wn: u16, /// Is valid? + #[cfg_attr(feature = "serde", serde(rename(serialize = "valid")))] pub valid: u8, /// Satellite is healthy? + #[cfg_attr(feature = "serde", serde(rename(serialize = "healthy")))] pub healthy: u8, /// PRN being tracked + #[cfg_attr(feature = "serde", serde(rename(serialize = "prn")))] pub prn: u8, /// Issue of ephemeris data + #[cfg_attr(feature = "serde", serde(rename(serialize = "iode")))] pub iode: u8, } -impl MsgEphemerisDepB { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgEphemerisDepB{ - sender_id: None, - tgd: _buf.read_f64::()?, - c_rs: _buf.read_f64::()?, - c_rc: _buf.read_f64::()?, - c_uc: _buf.read_f64::()?, - c_us: _buf.read_f64::()?, - c_ic: _buf.read_f64::()?, - c_is: _buf.read_f64::()?, - dn: _buf.read_f64::()?, - m0: _buf.read_f64::()?, - ecc: _buf.read_f64::()?, - sqrta: _buf.read_f64::()?, - omega0: _buf.read_f64::()?, - omegadot: _buf.read_f64::()?, - w: _buf.read_f64::()?, - inc: _buf.read_f64::()?, - inc_dot: _buf.read_f64::()?, - af0: _buf.read_f64::()?, - af1: _buf.read_f64::()?, - af2: _buf.read_f64::()?, - toe_tow: _buf.read_f64::()?, - toe_wn: _buf.read_u16::()?, - toc_tow: _buf.read_f64::()?, - toc_wn: _buf.read_u16::()?, - valid: _buf.read_u8()?, - healthy: _buf.read_u8()?, - prn: _buf.read_u8()?, - iode: _buf.read_u8()?, - } ) - } -} -impl super::SBPMessage for MsgEphemerisDepB { - fn get_message_name(&self) -> &'static str { - "MSG_EPHEMERIS_DEP_B" - } - - fn get_message_type(&self) -> u16 { - 70 - } - - fn get_sender_id(&self) -> Option { +impl ConcreteMessage for MsgEphemerisDepB { + const MESSAGE_TYPE: u16 = 70; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_DEP_B"; +} + +impl SbpMessage for MsgEphemerisDepB { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME + } + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgEphemerisDepB { - const MESSAGE_TYPE: u16 = 70; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_DEP_B"; -} -impl TryFrom for MsgEphemerisDepB { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgEphemerisDepB { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgEphemerisDepB(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgEphemerisDepB(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgEphemerisDepB { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tgd.append_to_sbp_buffer(buf); - self.c_rs.append_to_sbp_buffer(buf); - self.c_rc.append_to_sbp_buffer(buf); - self.c_uc.append_to_sbp_buffer(buf); - self.c_us.append_to_sbp_buffer(buf); - self.c_ic.append_to_sbp_buffer(buf); - self.c_is.append_to_sbp_buffer(buf); - self.dn.append_to_sbp_buffer(buf); - self.m0.append_to_sbp_buffer(buf); - self.ecc.append_to_sbp_buffer(buf); - self.sqrta.append_to_sbp_buffer(buf); - self.omega0.append_to_sbp_buffer(buf); - self.omegadot.append_to_sbp_buffer(buf); - self.w.append_to_sbp_buffer(buf); - self.inc.append_to_sbp_buffer(buf); - self.inc_dot.append_to_sbp_buffer(buf); - self.af0.append_to_sbp_buffer(buf); - self.af1.append_to_sbp_buffer(buf); - self.af2.append_to_sbp_buffer(buf); - self.toe_tow.append_to_sbp_buffer(buf); - self.toe_wn.append_to_sbp_buffer(buf); - self.toc_tow.append_to_sbp_buffer(buf); - self.toc_wn.append_to_sbp_buffer(buf); - self.valid.append_to_sbp_buffer(buf); - self.healthy.append_to_sbp_buffer(buf); - self.prn.append_to_sbp_buffer(buf); - self.iode.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tgd.sbp_size(); - size += self.c_rs.sbp_size(); - size += self.c_rc.sbp_size(); - size += self.c_uc.sbp_size(); - size += self.c_us.sbp_size(); - size += self.c_ic.sbp_size(); - size += self.c_is.sbp_size(); - size += self.dn.sbp_size(); - size += self.m0.sbp_size(); - size += self.ecc.sbp_size(); - size += self.sqrta.sbp_size(); - size += self.omega0.sbp_size(); - size += self.omegadot.sbp_size(); - size += self.w.sbp_size(); - size += self.inc.sbp_size(); - size += self.inc_dot.sbp_size(); - size += self.af0.sbp_size(); - size += self.af1.sbp_size(); - size += self.af2.sbp_size(); - size += self.toe_tow.sbp_size(); - size += self.toe_wn.sbp_size(); - size += self.toc_tow.sbp_size(); - size += self.toc_wn.sbp_size(); - size += self.valid.sbp_size(); - size += self.healthy.sbp_size(); - size += self.prn.sbp_size(); - size += self.iode.sbp_size(); - size +impl WireFormat for MsgEphemerisDepB { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tgd) + + WireFormat::encoded_len(&self.c_rs) + + WireFormat::encoded_len(&self.c_rc) + + WireFormat::encoded_len(&self.c_uc) + + WireFormat::encoded_len(&self.c_us) + + WireFormat::encoded_len(&self.c_ic) + + WireFormat::encoded_len(&self.c_is) + + WireFormat::encoded_len(&self.dn) + + WireFormat::encoded_len(&self.m0) + + WireFormat::encoded_len(&self.ecc) + + WireFormat::encoded_len(&self.sqrta) + + WireFormat::encoded_len(&self.omega0) + + WireFormat::encoded_len(&self.omegadot) + + WireFormat::encoded_len(&self.w) + + WireFormat::encoded_len(&self.inc) + + WireFormat::encoded_len(&self.inc_dot) + + WireFormat::encoded_len(&self.af0) + + WireFormat::encoded_len(&self.af1) + + WireFormat::encoded_len(&self.af2) + + WireFormat::encoded_len(&self.toe_tow) + + WireFormat::encoded_len(&self.toe_wn) + + WireFormat::encoded_len(&self.toc_tow) + + WireFormat::encoded_len(&self.toc_wn) + + WireFormat::encoded_len(&self.valid) + + WireFormat::encoded_len(&self.healthy) + + WireFormat::encoded_len(&self.prn) + + WireFormat::encoded_len(&self.iode) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tgd, buf); + WireFormat::write(&self.c_rs, buf); + WireFormat::write(&self.c_rc, buf); + WireFormat::write(&self.c_uc, buf); + WireFormat::write(&self.c_us, buf); + WireFormat::write(&self.c_ic, buf); + WireFormat::write(&self.c_is, buf); + WireFormat::write(&self.dn, buf); + WireFormat::write(&self.m0, buf); + WireFormat::write(&self.ecc, buf); + WireFormat::write(&self.sqrta, buf); + WireFormat::write(&self.omega0, buf); + WireFormat::write(&self.omegadot, buf); + WireFormat::write(&self.w, buf); + WireFormat::write(&self.inc, buf); + WireFormat::write(&self.inc_dot, buf); + WireFormat::write(&self.af0, buf); + WireFormat::write(&self.af1, buf); + WireFormat::write(&self.af2, buf); + WireFormat::write(&self.toe_tow, buf); + WireFormat::write(&self.toe_wn, buf); + WireFormat::write(&self.toc_tow, buf); + WireFormat::write(&self.toc_wn, buf); + WireFormat::write(&self.valid, buf); + WireFormat::write(&self.healthy, buf); + WireFormat::write(&self.prn, buf); + WireFormat::write(&self.iode, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgEphemerisDepB { + sender_id: None, + tgd: WireFormat::parse_unchecked(buf), + c_rs: WireFormat::parse_unchecked(buf), + c_rc: WireFormat::parse_unchecked(buf), + c_uc: WireFormat::parse_unchecked(buf), + c_us: WireFormat::parse_unchecked(buf), + c_ic: WireFormat::parse_unchecked(buf), + c_is: WireFormat::parse_unchecked(buf), + dn: WireFormat::parse_unchecked(buf), + m0: WireFormat::parse_unchecked(buf), + ecc: WireFormat::parse_unchecked(buf), + sqrta: WireFormat::parse_unchecked(buf), + omega0: WireFormat::parse_unchecked(buf), + omegadot: WireFormat::parse_unchecked(buf), + w: WireFormat::parse_unchecked(buf), + inc: WireFormat::parse_unchecked(buf), + inc_dot: WireFormat::parse_unchecked(buf), + af0: WireFormat::parse_unchecked(buf), + af1: WireFormat::parse_unchecked(buf), + af2: WireFormat::parse_unchecked(buf), + toe_tow: WireFormat::parse_unchecked(buf), + toe_wn: WireFormat::parse_unchecked(buf), + toc_tow: WireFormat::parse_unchecked(buf), + toc_wn: WireFormat::parse_unchecked(buf), + valid: WireFormat::parse_unchecked(buf), + healthy: WireFormat::parse_unchecked(buf), + prn: WireFormat::parse_unchecked(buf), + iode: WireFormat::parse_unchecked(buf), + } } } @@ -1959,221 +1910,260 @@ impl crate::serialize::SbpSerialize for MsgEphemerisDepB { /// Please see the Navstar GPS Space Segment/Navigation user interfaces (ICD- /// GPS-200, Table 20-III) for more details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgEphemerisDepC { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Group delay differential between L1 and L2 + #[cfg_attr(feature = "serde", serde(rename(serialize = "tgd")))] pub tgd: f64, /// Amplitude of the sine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rs")))] pub c_rs: f64, /// Amplitude of the cosine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rc")))] pub c_rc: f64, /// Amplitude of the cosine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_uc")))] pub c_uc: f64, /// Amplitude of the sine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_us")))] pub c_us: f64, /// Amplitude of the cosine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_ic")))] pub c_ic: f64, /// Amplitude of the sine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_is")))] pub c_is: f64, /// Mean motion difference + #[cfg_attr(feature = "serde", serde(rename(serialize = "dn")))] pub dn: f64, /// Mean anomaly at reference time + #[cfg_attr(feature = "serde", serde(rename(serialize = "m0")))] pub m0: f64, /// Eccentricity of satellite orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "ecc")))] pub ecc: f64, /// Square root of the semi-major axis of orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "sqrta")))] pub sqrta: f64, /// Longitude of ascending node of orbit plane at weekly epoch + #[cfg_attr(feature = "serde", serde(rename(serialize = "omega0")))] pub omega0: f64, /// Rate of right ascension + #[cfg_attr(feature = "serde", serde(rename(serialize = "omegadot")))] pub omegadot: f64, /// Argument of perigee + #[cfg_attr(feature = "serde", serde(rename(serialize = "w")))] pub w: f64, /// Inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc")))] pub inc: f64, /// Inclination first derivative + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc_dot")))] pub inc_dot: f64, /// Polynomial clock correction coefficient (clock bias) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af0")))] pub af0: f64, /// Polynomial clock correction coefficient (clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af1")))] pub af1: f64, /// Polynomial clock correction coefficient (rate of clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af2")))] pub af2: f64, /// Time of week + #[cfg_attr(feature = "serde", serde(rename(serialize = "toe_tow")))] pub toe_tow: f64, /// Week number + #[cfg_attr(feature = "serde", serde(rename(serialize = "toe_wn")))] pub toe_wn: u16, /// Clock reference time of week + #[cfg_attr(feature = "serde", serde(rename(serialize = "toc_tow")))] pub toc_tow: f64, /// Clock reference week number + #[cfg_attr(feature = "serde", serde(rename(serialize = "toc_wn")))] pub toc_wn: u16, /// Is valid? + #[cfg_attr(feature = "serde", serde(rename(serialize = "valid")))] pub valid: u8, /// Satellite is healthy? + #[cfg_attr(feature = "serde", serde(rename(serialize = "healthy")))] pub healthy: u8, /// GNSS signal identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignalDep, /// Issue of ephemeris data + #[cfg_attr(feature = "serde", serde(rename(serialize = "iode")))] pub iode: u8, /// Issue of clock data + #[cfg_attr(feature = "serde", serde(rename(serialize = "iodc")))] pub iodc: u16, /// Reserved field + #[cfg_attr(feature = "serde", serde(rename(serialize = "reserved")))] pub reserved: u32, } -impl MsgEphemerisDepC { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgEphemerisDepC{ - sender_id: None, - tgd: _buf.read_f64::()?, - c_rs: _buf.read_f64::()?, - c_rc: _buf.read_f64::()?, - c_uc: _buf.read_f64::()?, - c_us: _buf.read_f64::()?, - c_ic: _buf.read_f64::()?, - c_is: _buf.read_f64::()?, - dn: _buf.read_f64::()?, - m0: _buf.read_f64::()?, - ecc: _buf.read_f64::()?, - sqrta: _buf.read_f64::()?, - omega0: _buf.read_f64::()?, - omegadot: _buf.read_f64::()?, - w: _buf.read_f64::()?, - inc: _buf.read_f64::()?, - inc_dot: _buf.read_f64::()?, - af0: _buf.read_f64::()?, - af1: _buf.read_f64::()?, - af2: _buf.read_f64::()?, - toe_tow: _buf.read_f64::()?, - toe_wn: _buf.read_u16::()?, - toc_tow: _buf.read_f64::()?, - toc_wn: _buf.read_u16::()?, - valid: _buf.read_u8()?, - healthy: _buf.read_u8()?, - sid: GnssSignalDep::parse(_buf)?, - iode: _buf.read_u8()?, - iodc: _buf.read_u16::()?, - reserved: _buf.read_u32::()?, - } ) - } -} -impl super::SBPMessage for MsgEphemerisDepC { - fn get_message_name(&self) -> &'static str { - "MSG_EPHEMERIS_DEP_C" - } - - fn get_message_type(&self) -> u16 { - 71 - } - - fn get_sender_id(&self) -> Option { +impl ConcreteMessage for MsgEphemerisDepC { + const MESSAGE_TYPE: u16 = 71; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_DEP_C"; +} + +impl SbpMessage for MsgEphemerisDepC { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME + } + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgEphemerisDepC { - const MESSAGE_TYPE: u16 = 71; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_DEP_C"; } -impl TryFrom for MsgEphemerisDepC { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgEphemerisDepC { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgEphemerisDepC(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgEphemerisDepC(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgEphemerisDepC { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tgd.append_to_sbp_buffer(buf); - self.c_rs.append_to_sbp_buffer(buf); - self.c_rc.append_to_sbp_buffer(buf); - self.c_uc.append_to_sbp_buffer(buf); - self.c_us.append_to_sbp_buffer(buf); - self.c_ic.append_to_sbp_buffer(buf); - self.c_is.append_to_sbp_buffer(buf); - self.dn.append_to_sbp_buffer(buf); - self.m0.append_to_sbp_buffer(buf); - self.ecc.append_to_sbp_buffer(buf); - self.sqrta.append_to_sbp_buffer(buf); - self.omega0.append_to_sbp_buffer(buf); - self.omegadot.append_to_sbp_buffer(buf); - self.w.append_to_sbp_buffer(buf); - self.inc.append_to_sbp_buffer(buf); - self.inc_dot.append_to_sbp_buffer(buf); - self.af0.append_to_sbp_buffer(buf); - self.af1.append_to_sbp_buffer(buf); - self.af2.append_to_sbp_buffer(buf); - self.toe_tow.append_to_sbp_buffer(buf); - self.toe_wn.append_to_sbp_buffer(buf); - self.toc_tow.append_to_sbp_buffer(buf); - self.toc_wn.append_to_sbp_buffer(buf); - self.valid.append_to_sbp_buffer(buf); - self.healthy.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - self.iode.append_to_sbp_buffer(buf); - self.iodc.append_to_sbp_buffer(buf); - self.reserved.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tgd.sbp_size(); - size += self.c_rs.sbp_size(); - size += self.c_rc.sbp_size(); - size += self.c_uc.sbp_size(); - size += self.c_us.sbp_size(); - size += self.c_ic.sbp_size(); - size += self.c_is.sbp_size(); - size += self.dn.sbp_size(); - size += self.m0.sbp_size(); - size += self.ecc.sbp_size(); - size += self.sqrta.sbp_size(); - size += self.omega0.sbp_size(); - size += self.omegadot.sbp_size(); - size += self.w.sbp_size(); - size += self.inc.sbp_size(); - size += self.inc_dot.sbp_size(); - size += self.af0.sbp_size(); - size += self.af1.sbp_size(); - size += self.af2.sbp_size(); - size += self.toe_tow.sbp_size(); - size += self.toe_wn.sbp_size(); - size += self.toc_tow.sbp_size(); - size += self.toc_wn.sbp_size(); - size += self.valid.sbp_size(); - size += self.healthy.sbp_size(); - size += self.sid.sbp_size(); - size += self.iode.sbp_size(); - size += self.iodc.sbp_size(); - size += self.reserved.sbp_size(); - size +impl WireFormat for MsgEphemerisDepC { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tgd) + + WireFormat::encoded_len(&self.c_rs) + + WireFormat::encoded_len(&self.c_rc) + + WireFormat::encoded_len(&self.c_uc) + + WireFormat::encoded_len(&self.c_us) + + WireFormat::encoded_len(&self.c_ic) + + WireFormat::encoded_len(&self.c_is) + + WireFormat::encoded_len(&self.dn) + + WireFormat::encoded_len(&self.m0) + + WireFormat::encoded_len(&self.ecc) + + WireFormat::encoded_len(&self.sqrta) + + WireFormat::encoded_len(&self.omega0) + + WireFormat::encoded_len(&self.omegadot) + + WireFormat::encoded_len(&self.w) + + WireFormat::encoded_len(&self.inc) + + WireFormat::encoded_len(&self.inc_dot) + + WireFormat::encoded_len(&self.af0) + + WireFormat::encoded_len(&self.af1) + + WireFormat::encoded_len(&self.af2) + + WireFormat::encoded_len(&self.toe_tow) + + WireFormat::encoded_len(&self.toe_wn) + + WireFormat::encoded_len(&self.toc_tow) + + WireFormat::encoded_len(&self.toc_wn) + + WireFormat::encoded_len(&self.valid) + + WireFormat::encoded_len(&self.healthy) + + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.iode) + + WireFormat::encoded_len(&self.iodc) + + WireFormat::encoded_len(&self.reserved) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tgd, buf); + WireFormat::write(&self.c_rs, buf); + WireFormat::write(&self.c_rc, buf); + WireFormat::write(&self.c_uc, buf); + WireFormat::write(&self.c_us, buf); + WireFormat::write(&self.c_ic, buf); + WireFormat::write(&self.c_is, buf); + WireFormat::write(&self.dn, buf); + WireFormat::write(&self.m0, buf); + WireFormat::write(&self.ecc, buf); + WireFormat::write(&self.sqrta, buf); + WireFormat::write(&self.omega0, buf); + WireFormat::write(&self.omegadot, buf); + WireFormat::write(&self.w, buf); + WireFormat::write(&self.inc, buf); + WireFormat::write(&self.inc_dot, buf); + WireFormat::write(&self.af0, buf); + WireFormat::write(&self.af1, buf); + WireFormat::write(&self.af2, buf); + WireFormat::write(&self.toe_tow, buf); + WireFormat::write(&self.toe_wn, buf); + WireFormat::write(&self.toc_tow, buf); + WireFormat::write(&self.toc_wn, buf); + WireFormat::write(&self.valid, buf); + WireFormat::write(&self.healthy, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.iode, buf); + WireFormat::write(&self.iodc, buf); + WireFormat::write(&self.reserved, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgEphemerisDepC { + sender_id: None, + tgd: WireFormat::parse_unchecked(buf), + c_rs: WireFormat::parse_unchecked(buf), + c_rc: WireFormat::parse_unchecked(buf), + c_uc: WireFormat::parse_unchecked(buf), + c_us: WireFormat::parse_unchecked(buf), + c_ic: WireFormat::parse_unchecked(buf), + c_is: WireFormat::parse_unchecked(buf), + dn: WireFormat::parse_unchecked(buf), + m0: WireFormat::parse_unchecked(buf), + ecc: WireFormat::parse_unchecked(buf), + sqrta: WireFormat::parse_unchecked(buf), + omega0: WireFormat::parse_unchecked(buf), + omegadot: WireFormat::parse_unchecked(buf), + w: WireFormat::parse_unchecked(buf), + inc: WireFormat::parse_unchecked(buf), + inc_dot: WireFormat::parse_unchecked(buf), + af0: WireFormat::parse_unchecked(buf), + af1: WireFormat::parse_unchecked(buf), + af2: WireFormat::parse_unchecked(buf), + toe_tow: WireFormat::parse_unchecked(buf), + toe_wn: WireFormat::parse_unchecked(buf), + toc_tow: WireFormat::parse_unchecked(buf), + toc_wn: WireFormat::parse_unchecked(buf), + valid: WireFormat::parse_unchecked(buf), + healthy: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + iode: WireFormat::parse_unchecked(buf), + iodc: WireFormat::parse_unchecked(buf), + reserved: WireFormat::parse_unchecked(buf), + } } } @@ -2184,221 +2174,260 @@ impl crate::serialize::SbpSerialize for MsgEphemerisDepC { /// Please see the Navstar GPS Space Segment/Navigation user interfaces (ICD- /// GPS-200, Table 20-III) for more details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgEphemerisDepD { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Group delay differential between L1 and L2 + #[cfg_attr(feature = "serde", serde(rename(serialize = "tgd")))] pub tgd: f64, /// Amplitude of the sine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rs")))] pub c_rs: f64, /// Amplitude of the cosine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rc")))] pub c_rc: f64, /// Amplitude of the cosine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_uc")))] pub c_uc: f64, /// Amplitude of the sine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_us")))] pub c_us: f64, /// Amplitude of the cosine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_ic")))] pub c_ic: f64, /// Amplitude of the sine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_is")))] pub c_is: f64, /// Mean motion difference + #[cfg_attr(feature = "serde", serde(rename(serialize = "dn")))] pub dn: f64, /// Mean anomaly at reference time + #[cfg_attr(feature = "serde", serde(rename(serialize = "m0")))] pub m0: f64, /// Eccentricity of satellite orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "ecc")))] pub ecc: f64, /// Square root of the semi-major axis of orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "sqrta")))] pub sqrta: f64, /// Longitude of ascending node of orbit plane at weekly epoch + #[cfg_attr(feature = "serde", serde(rename(serialize = "omega0")))] pub omega0: f64, /// Rate of right ascension + #[cfg_attr(feature = "serde", serde(rename(serialize = "omegadot")))] pub omegadot: f64, /// Argument of perigee + #[cfg_attr(feature = "serde", serde(rename(serialize = "w")))] pub w: f64, /// Inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc")))] pub inc: f64, /// Inclination first derivative + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc_dot")))] pub inc_dot: f64, /// Polynomial clock correction coefficient (clock bias) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af0")))] pub af0: f64, /// Polynomial clock correction coefficient (clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af1")))] pub af1: f64, /// Polynomial clock correction coefficient (rate of clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af2")))] pub af2: f64, /// Time of week + #[cfg_attr(feature = "serde", serde(rename(serialize = "toe_tow")))] pub toe_tow: f64, /// Week number + #[cfg_attr(feature = "serde", serde(rename(serialize = "toe_wn")))] pub toe_wn: u16, /// Clock reference time of week + #[cfg_attr(feature = "serde", serde(rename(serialize = "toc_tow")))] pub toc_tow: f64, /// Clock reference week number + #[cfg_attr(feature = "serde", serde(rename(serialize = "toc_wn")))] pub toc_wn: u16, /// Is valid? + #[cfg_attr(feature = "serde", serde(rename(serialize = "valid")))] pub valid: u8, /// Satellite is healthy? + #[cfg_attr(feature = "serde", serde(rename(serialize = "healthy")))] pub healthy: u8, /// GNSS signal identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignalDep, /// Issue of ephemeris data + #[cfg_attr(feature = "serde", serde(rename(serialize = "iode")))] pub iode: u8, /// Issue of clock data + #[cfg_attr(feature = "serde", serde(rename(serialize = "iodc")))] pub iodc: u16, /// Reserved field + #[cfg_attr(feature = "serde", serde(rename(serialize = "reserved")))] pub reserved: u32, } -impl MsgEphemerisDepD { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgEphemerisDepD{ - sender_id: None, - tgd: _buf.read_f64::()?, - c_rs: _buf.read_f64::()?, - c_rc: _buf.read_f64::()?, - c_uc: _buf.read_f64::()?, - c_us: _buf.read_f64::()?, - c_ic: _buf.read_f64::()?, - c_is: _buf.read_f64::()?, - dn: _buf.read_f64::()?, - m0: _buf.read_f64::()?, - ecc: _buf.read_f64::()?, - sqrta: _buf.read_f64::()?, - omega0: _buf.read_f64::()?, - omegadot: _buf.read_f64::()?, - w: _buf.read_f64::()?, - inc: _buf.read_f64::()?, - inc_dot: _buf.read_f64::()?, - af0: _buf.read_f64::()?, - af1: _buf.read_f64::()?, - af2: _buf.read_f64::()?, - toe_tow: _buf.read_f64::()?, - toe_wn: _buf.read_u16::()?, - toc_tow: _buf.read_f64::()?, - toc_wn: _buf.read_u16::()?, - valid: _buf.read_u8()?, - healthy: _buf.read_u8()?, - sid: GnssSignalDep::parse(_buf)?, - iode: _buf.read_u8()?, - iodc: _buf.read_u16::()?, - reserved: _buf.read_u32::()?, - } ) - } -} -impl super::SBPMessage for MsgEphemerisDepD { - fn get_message_name(&self) -> &'static str { - "MSG_EPHEMERIS_DEP_D" - } - - fn get_message_type(&self) -> u16 { - 128 - } - - fn get_sender_id(&self) -> Option { +impl ConcreteMessage for MsgEphemerisDepD { + const MESSAGE_TYPE: u16 = 128; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_DEP_D"; +} + +impl SbpMessage for MsgEphemerisDepD { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME + } + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } +} - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) +impl TryFrom for MsgEphemerisDepD { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisDepD(m) => Ok(m), + _ => Err(TryFromSbpError), + } } +} - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgEphemerisDepD { - const MESSAGE_TYPE: u16 = 128; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_DEP_D"; -} -impl TryFrom for MsgEphemerisDepD { - type Error = super::TryFromSBPError; - - fn try_from(msg: super::SBP) -> Result { - match msg { - super::SBP::MsgEphemerisDepD(m) => Ok(m), - _ => Err(super::TryFromSBPError), - } - } -} - -impl crate::serialize::SbpSerialize for MsgEphemerisDepD { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tgd.append_to_sbp_buffer(buf); - self.c_rs.append_to_sbp_buffer(buf); - self.c_rc.append_to_sbp_buffer(buf); - self.c_uc.append_to_sbp_buffer(buf); - self.c_us.append_to_sbp_buffer(buf); - self.c_ic.append_to_sbp_buffer(buf); - self.c_is.append_to_sbp_buffer(buf); - self.dn.append_to_sbp_buffer(buf); - self.m0.append_to_sbp_buffer(buf); - self.ecc.append_to_sbp_buffer(buf); - self.sqrta.append_to_sbp_buffer(buf); - self.omega0.append_to_sbp_buffer(buf); - self.omegadot.append_to_sbp_buffer(buf); - self.w.append_to_sbp_buffer(buf); - self.inc.append_to_sbp_buffer(buf); - self.inc_dot.append_to_sbp_buffer(buf); - self.af0.append_to_sbp_buffer(buf); - self.af1.append_to_sbp_buffer(buf); - self.af2.append_to_sbp_buffer(buf); - self.toe_tow.append_to_sbp_buffer(buf); - self.toe_wn.append_to_sbp_buffer(buf); - self.toc_tow.append_to_sbp_buffer(buf); - self.toc_wn.append_to_sbp_buffer(buf); - self.valid.append_to_sbp_buffer(buf); - self.healthy.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - self.iode.append_to_sbp_buffer(buf); - self.iodc.append_to_sbp_buffer(buf); - self.reserved.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tgd.sbp_size(); - size += self.c_rs.sbp_size(); - size += self.c_rc.sbp_size(); - size += self.c_uc.sbp_size(); - size += self.c_us.sbp_size(); - size += self.c_ic.sbp_size(); - size += self.c_is.sbp_size(); - size += self.dn.sbp_size(); - size += self.m0.sbp_size(); - size += self.ecc.sbp_size(); - size += self.sqrta.sbp_size(); - size += self.omega0.sbp_size(); - size += self.omegadot.sbp_size(); - size += self.w.sbp_size(); - size += self.inc.sbp_size(); - size += self.inc_dot.sbp_size(); - size += self.af0.sbp_size(); - size += self.af1.sbp_size(); - size += self.af2.sbp_size(); - size += self.toe_tow.sbp_size(); - size += self.toe_wn.sbp_size(); - size += self.toc_tow.sbp_size(); - size += self.toc_wn.sbp_size(); - size += self.valid.sbp_size(); - size += self.healthy.sbp_size(); - size += self.sid.sbp_size(); - size += self.iode.sbp_size(); - size += self.iodc.sbp_size(); - size += self.reserved.sbp_size(); - size +impl WireFormat for MsgEphemerisDepD { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tgd) + + WireFormat::encoded_len(&self.c_rs) + + WireFormat::encoded_len(&self.c_rc) + + WireFormat::encoded_len(&self.c_uc) + + WireFormat::encoded_len(&self.c_us) + + WireFormat::encoded_len(&self.c_ic) + + WireFormat::encoded_len(&self.c_is) + + WireFormat::encoded_len(&self.dn) + + WireFormat::encoded_len(&self.m0) + + WireFormat::encoded_len(&self.ecc) + + WireFormat::encoded_len(&self.sqrta) + + WireFormat::encoded_len(&self.omega0) + + WireFormat::encoded_len(&self.omegadot) + + WireFormat::encoded_len(&self.w) + + WireFormat::encoded_len(&self.inc) + + WireFormat::encoded_len(&self.inc_dot) + + WireFormat::encoded_len(&self.af0) + + WireFormat::encoded_len(&self.af1) + + WireFormat::encoded_len(&self.af2) + + WireFormat::encoded_len(&self.toe_tow) + + WireFormat::encoded_len(&self.toe_wn) + + WireFormat::encoded_len(&self.toc_tow) + + WireFormat::encoded_len(&self.toc_wn) + + WireFormat::encoded_len(&self.valid) + + WireFormat::encoded_len(&self.healthy) + + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.iode) + + WireFormat::encoded_len(&self.iodc) + + WireFormat::encoded_len(&self.reserved) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tgd, buf); + WireFormat::write(&self.c_rs, buf); + WireFormat::write(&self.c_rc, buf); + WireFormat::write(&self.c_uc, buf); + WireFormat::write(&self.c_us, buf); + WireFormat::write(&self.c_ic, buf); + WireFormat::write(&self.c_is, buf); + WireFormat::write(&self.dn, buf); + WireFormat::write(&self.m0, buf); + WireFormat::write(&self.ecc, buf); + WireFormat::write(&self.sqrta, buf); + WireFormat::write(&self.omega0, buf); + WireFormat::write(&self.omegadot, buf); + WireFormat::write(&self.w, buf); + WireFormat::write(&self.inc, buf); + WireFormat::write(&self.inc_dot, buf); + WireFormat::write(&self.af0, buf); + WireFormat::write(&self.af1, buf); + WireFormat::write(&self.af2, buf); + WireFormat::write(&self.toe_tow, buf); + WireFormat::write(&self.toe_wn, buf); + WireFormat::write(&self.toc_tow, buf); + WireFormat::write(&self.toc_wn, buf); + WireFormat::write(&self.valid, buf); + WireFormat::write(&self.healthy, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.iode, buf); + WireFormat::write(&self.iodc, buf); + WireFormat::write(&self.reserved, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgEphemerisDepD { + sender_id: None, + tgd: WireFormat::parse_unchecked(buf), + c_rs: WireFormat::parse_unchecked(buf), + c_rc: WireFormat::parse_unchecked(buf), + c_uc: WireFormat::parse_unchecked(buf), + c_us: WireFormat::parse_unchecked(buf), + c_ic: WireFormat::parse_unchecked(buf), + c_is: WireFormat::parse_unchecked(buf), + dn: WireFormat::parse_unchecked(buf), + m0: WireFormat::parse_unchecked(buf), + ecc: WireFormat::parse_unchecked(buf), + sqrta: WireFormat::parse_unchecked(buf), + omega0: WireFormat::parse_unchecked(buf), + omegadot: WireFormat::parse_unchecked(buf), + w: WireFormat::parse_unchecked(buf), + inc: WireFormat::parse_unchecked(buf), + inc_dot: WireFormat::parse_unchecked(buf), + af0: WireFormat::parse_unchecked(buf), + af1: WireFormat::parse_unchecked(buf), + af2: WireFormat::parse_unchecked(buf), + toe_tow: WireFormat::parse_unchecked(buf), + toe_wn: WireFormat::parse_unchecked(buf), + toc_tow: WireFormat::parse_unchecked(buf), + toc_wn: WireFormat::parse_unchecked(buf), + valid: WireFormat::parse_unchecked(buf), + healthy: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + iode: WireFormat::parse_unchecked(buf), + iodc: WireFormat::parse_unchecked(buf), + reserved: WireFormat::parse_unchecked(buf), + } } } @@ -2409,201 +2438,232 @@ impl crate::serialize::SbpSerialize for MsgEphemerisDepD { /// Please see the Signal In Space ICD OS SIS ICD, Issue 1.3, December 2016 /// for more details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgEphemerisGal { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Values common for all ephemeris types + #[cfg_attr(feature = "serde", serde(rename(serialize = "common")))] pub common: EphemerisCommonContent, /// E1-E5a Broadcast Group Delay + #[cfg_attr(feature = "serde", serde(rename(serialize = "bgd_e1e5a")))] pub bgd_e1e5a: f32, /// E1-E5b Broadcast Group Delay + #[cfg_attr(feature = "serde", serde(rename(serialize = "bgd_e1e5b")))] pub bgd_e1e5b: f32, /// Amplitude of the sine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rs")))] pub c_rs: f32, /// Amplitude of the cosine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rc")))] pub c_rc: f32, /// Amplitude of the cosine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_uc")))] pub c_uc: f32, /// Amplitude of the sine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_us")))] pub c_us: f32, /// Amplitude of the cosine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_ic")))] pub c_ic: f32, /// Amplitude of the sine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_is")))] pub c_is: f32, /// Mean motion difference + #[cfg_attr(feature = "serde", serde(rename(serialize = "dn")))] pub dn: f64, /// Mean anomaly at reference time + #[cfg_attr(feature = "serde", serde(rename(serialize = "m0")))] pub m0: f64, /// Eccentricity of satellite orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "ecc")))] pub ecc: f64, /// Square root of the semi-major axis of orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "sqrta")))] pub sqrta: f64, /// Longitude of ascending node of orbit plane at weekly epoch + #[cfg_attr(feature = "serde", serde(rename(serialize = "omega0")))] pub omega0: f64, /// Rate of right ascension + #[cfg_attr(feature = "serde", serde(rename(serialize = "omegadot")))] pub omegadot: f64, /// Argument of perigee + #[cfg_attr(feature = "serde", serde(rename(serialize = "w")))] pub w: f64, /// Inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc")))] pub inc: f64, /// Inclination first derivative + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc_dot")))] pub inc_dot: f64, /// Polynomial clock correction coefficient (clock bias) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af0")))] pub af0: f64, /// Polynomial clock correction coefficient (clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af1")))] pub af1: f64, /// Polynomial clock correction coefficient (rate of clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af2")))] pub af2: f32, /// Clock reference - pub toc: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "toc")))] + pub toc: GpsTimeSec, /// Issue of data (IODnav) + #[cfg_attr(feature = "serde", serde(rename(serialize = "iode")))] pub iode: u16, /// Issue of data (IODnav). Always equal to iode + #[cfg_attr(feature = "serde", serde(rename(serialize = "iodc")))] pub iodc: u16, /// 0=I/NAV, 1=F/NAV + #[cfg_attr(feature = "serde", serde(rename(serialize = "source")))] pub source: u8, } -impl MsgEphemerisGal { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgEphemerisGal{ - sender_id: None, - common: EphemerisCommonContent::parse(_buf)?, - bgd_e1e5a: _buf.read_f32::()?, - bgd_e1e5b: _buf.read_f32::()?, - c_rs: _buf.read_f32::()?, - c_rc: _buf.read_f32::()?, - c_uc: _buf.read_f32::()?, - c_us: _buf.read_f32::()?, - c_ic: _buf.read_f32::()?, - c_is: _buf.read_f32::()?, - dn: _buf.read_f64::()?, - m0: _buf.read_f64::()?, - ecc: _buf.read_f64::()?, - sqrta: _buf.read_f64::()?, - omega0: _buf.read_f64::()?, - omegadot: _buf.read_f64::()?, - w: _buf.read_f64::()?, - inc: _buf.read_f64::()?, - inc_dot: _buf.read_f64::()?, - af0: _buf.read_f64::()?, - af1: _buf.read_f64::()?, - af2: _buf.read_f32::()?, - toc: GPSTimeSec::parse(_buf)?, - iode: _buf.read_u16::()?, - iodc: _buf.read_u16::()?, - source: _buf.read_u8()?, - } ) - } -} -impl super::SBPMessage for MsgEphemerisGal { - fn get_message_name(&self) -> &'static str { - "MSG_EPHEMERIS_GAL" - } - - fn get_message_type(&self) -> u16 { - 141 - } - - fn get_sender_id(&self) -> Option { +impl ConcreteMessage for MsgEphemerisGal { + const MESSAGE_TYPE: u16 = 141; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GAL"; +} + +impl SbpMessage for MsgEphemerisGal { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME + } + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgEphemerisGal { - const MESSAGE_TYPE: u16 = 141; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GAL"; } -impl TryFrom for MsgEphemerisGal { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgEphemerisGal { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgEphemerisGal(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgEphemerisGal(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgEphemerisGal { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.common.append_to_sbp_buffer(buf); - self.bgd_e1e5a.append_to_sbp_buffer(buf); - self.bgd_e1e5b.append_to_sbp_buffer(buf); - self.c_rs.append_to_sbp_buffer(buf); - self.c_rc.append_to_sbp_buffer(buf); - self.c_uc.append_to_sbp_buffer(buf); - self.c_us.append_to_sbp_buffer(buf); - self.c_ic.append_to_sbp_buffer(buf); - self.c_is.append_to_sbp_buffer(buf); - self.dn.append_to_sbp_buffer(buf); - self.m0.append_to_sbp_buffer(buf); - self.ecc.append_to_sbp_buffer(buf); - self.sqrta.append_to_sbp_buffer(buf); - self.omega0.append_to_sbp_buffer(buf); - self.omegadot.append_to_sbp_buffer(buf); - self.w.append_to_sbp_buffer(buf); - self.inc.append_to_sbp_buffer(buf); - self.inc_dot.append_to_sbp_buffer(buf); - self.af0.append_to_sbp_buffer(buf); - self.af1.append_to_sbp_buffer(buf); - self.af2.append_to_sbp_buffer(buf); - self.toc.append_to_sbp_buffer(buf); - self.iode.append_to_sbp_buffer(buf); - self.iodc.append_to_sbp_buffer(buf); - self.source.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.common.sbp_size(); - size += self.bgd_e1e5a.sbp_size(); - size += self.bgd_e1e5b.sbp_size(); - size += self.c_rs.sbp_size(); - size += self.c_rc.sbp_size(); - size += self.c_uc.sbp_size(); - size += self.c_us.sbp_size(); - size += self.c_ic.sbp_size(); - size += self.c_is.sbp_size(); - size += self.dn.sbp_size(); - size += self.m0.sbp_size(); - size += self.ecc.sbp_size(); - size += self.sqrta.sbp_size(); - size += self.omega0.sbp_size(); - size += self.omegadot.sbp_size(); - size += self.w.sbp_size(); - size += self.inc.sbp_size(); - size += self.inc_dot.sbp_size(); - size += self.af0.sbp_size(); - size += self.af1.sbp_size(); - size += self.af2.sbp_size(); - size += self.toc.sbp_size(); - size += self.iode.sbp_size(); - size += self.iodc.sbp_size(); - size += self.source.sbp_size(); - size +impl WireFormat for MsgEphemerisGal { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.common) + + WireFormat::encoded_len(&self.bgd_e1e5a) + + WireFormat::encoded_len(&self.bgd_e1e5b) + + WireFormat::encoded_len(&self.c_rs) + + WireFormat::encoded_len(&self.c_rc) + + WireFormat::encoded_len(&self.c_uc) + + WireFormat::encoded_len(&self.c_us) + + WireFormat::encoded_len(&self.c_ic) + + WireFormat::encoded_len(&self.c_is) + + WireFormat::encoded_len(&self.dn) + + WireFormat::encoded_len(&self.m0) + + WireFormat::encoded_len(&self.ecc) + + WireFormat::encoded_len(&self.sqrta) + + WireFormat::encoded_len(&self.omega0) + + WireFormat::encoded_len(&self.omegadot) + + WireFormat::encoded_len(&self.w) + + WireFormat::encoded_len(&self.inc) + + WireFormat::encoded_len(&self.inc_dot) + + WireFormat::encoded_len(&self.af0) + + WireFormat::encoded_len(&self.af1) + + WireFormat::encoded_len(&self.af2) + + WireFormat::encoded_len(&self.toc) + + WireFormat::encoded_len(&self.iode) + + WireFormat::encoded_len(&self.iodc) + + WireFormat::encoded_len(&self.source) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.common, buf); + WireFormat::write(&self.bgd_e1e5a, buf); + WireFormat::write(&self.bgd_e1e5b, buf); + WireFormat::write(&self.c_rs, buf); + WireFormat::write(&self.c_rc, buf); + WireFormat::write(&self.c_uc, buf); + WireFormat::write(&self.c_us, buf); + WireFormat::write(&self.c_ic, buf); + WireFormat::write(&self.c_is, buf); + WireFormat::write(&self.dn, buf); + WireFormat::write(&self.m0, buf); + WireFormat::write(&self.ecc, buf); + WireFormat::write(&self.sqrta, buf); + WireFormat::write(&self.omega0, buf); + WireFormat::write(&self.omegadot, buf); + WireFormat::write(&self.w, buf); + WireFormat::write(&self.inc, buf); + WireFormat::write(&self.inc_dot, buf); + WireFormat::write(&self.af0, buf); + WireFormat::write(&self.af1, buf); + WireFormat::write(&self.af2, buf); + WireFormat::write(&self.toc, buf); + WireFormat::write(&self.iode, buf); + WireFormat::write(&self.iodc, buf); + WireFormat::write(&self.source, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgEphemerisGal { + sender_id: None, + common: WireFormat::parse_unchecked(buf), + bgd_e1e5a: WireFormat::parse_unchecked(buf), + bgd_e1e5b: WireFormat::parse_unchecked(buf), + c_rs: WireFormat::parse_unchecked(buf), + c_rc: WireFormat::parse_unchecked(buf), + c_uc: WireFormat::parse_unchecked(buf), + c_us: WireFormat::parse_unchecked(buf), + c_ic: WireFormat::parse_unchecked(buf), + c_is: WireFormat::parse_unchecked(buf), + dn: WireFormat::parse_unchecked(buf), + m0: WireFormat::parse_unchecked(buf), + ecc: WireFormat::parse_unchecked(buf), + sqrta: WireFormat::parse_unchecked(buf), + omega0: WireFormat::parse_unchecked(buf), + omegadot: WireFormat::parse_unchecked(buf), + w: WireFormat::parse_unchecked(buf), + inc: WireFormat::parse_unchecked(buf), + inc_dot: WireFormat::parse_unchecked(buf), + af0: WireFormat::parse_unchecked(buf), + af1: WireFormat::parse_unchecked(buf), + af2: WireFormat::parse_unchecked(buf), + toc: WireFormat::parse_unchecked(buf), + iode: WireFormat::parse_unchecked(buf), + iodc: WireFormat::parse_unchecked(buf), + source: WireFormat::parse_unchecked(buf), + } } } @@ -2612,196 +2672,225 @@ impl crate::serialize::SbpSerialize for MsgEphemerisGal { /// This observation message has been deprecated in favor of an ephemeris /// message with explicit source of NAV data. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgEphemerisGalDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Values common for all ephemeris types + #[cfg_attr(feature = "serde", serde(rename(serialize = "common")))] pub common: EphemerisCommonContent, /// E1-E5a Broadcast Group Delay + #[cfg_attr(feature = "serde", serde(rename(serialize = "bgd_e1e5a")))] pub bgd_e1e5a: f32, /// E1-E5b Broadcast Group Delay + #[cfg_attr(feature = "serde", serde(rename(serialize = "bgd_e1e5b")))] pub bgd_e1e5b: f32, /// Amplitude of the sine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rs")))] pub c_rs: f32, /// Amplitude of the cosine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rc")))] pub c_rc: f32, /// Amplitude of the cosine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_uc")))] pub c_uc: f32, /// Amplitude of the sine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_us")))] pub c_us: f32, /// Amplitude of the cosine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_ic")))] pub c_ic: f32, /// Amplitude of the sine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_is")))] pub c_is: f32, /// Mean motion difference + #[cfg_attr(feature = "serde", serde(rename(serialize = "dn")))] pub dn: f64, /// Mean anomaly at reference time + #[cfg_attr(feature = "serde", serde(rename(serialize = "m0")))] pub m0: f64, /// Eccentricity of satellite orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "ecc")))] pub ecc: f64, /// Square root of the semi-major axis of orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "sqrta")))] pub sqrta: f64, /// Longitude of ascending node of orbit plane at weekly epoch + #[cfg_attr(feature = "serde", serde(rename(serialize = "omega0")))] pub omega0: f64, /// Rate of right ascension + #[cfg_attr(feature = "serde", serde(rename(serialize = "omegadot")))] pub omegadot: f64, /// Argument of perigee + #[cfg_attr(feature = "serde", serde(rename(serialize = "w")))] pub w: f64, /// Inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc")))] pub inc: f64, /// Inclination first derivative + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc_dot")))] pub inc_dot: f64, /// Polynomial clock correction coefficient (clock bias) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af0")))] pub af0: f64, /// Polynomial clock correction coefficient (clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af1")))] pub af1: f64, /// Polynomial clock correction coefficient (rate of clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af2")))] pub af2: f32, /// Clock reference - pub toc: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "toc")))] + pub toc: GpsTimeSec, /// Issue of data (IODnav) + #[cfg_attr(feature = "serde", serde(rename(serialize = "iode")))] pub iode: u16, /// Issue of data (IODnav). Always equal to iode + #[cfg_attr(feature = "serde", serde(rename(serialize = "iodc")))] pub iodc: u16, } -impl MsgEphemerisGalDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgEphemerisGalDepA{ - sender_id: None, - common: EphemerisCommonContent::parse(_buf)?, - bgd_e1e5a: _buf.read_f32::()?, - bgd_e1e5b: _buf.read_f32::()?, - c_rs: _buf.read_f32::()?, - c_rc: _buf.read_f32::()?, - c_uc: _buf.read_f32::()?, - c_us: _buf.read_f32::()?, - c_ic: _buf.read_f32::()?, - c_is: _buf.read_f32::()?, - dn: _buf.read_f64::()?, - m0: _buf.read_f64::()?, - ecc: _buf.read_f64::()?, - sqrta: _buf.read_f64::()?, - omega0: _buf.read_f64::()?, - omegadot: _buf.read_f64::()?, - w: _buf.read_f64::()?, - inc: _buf.read_f64::()?, - inc_dot: _buf.read_f64::()?, - af0: _buf.read_f64::()?, - af1: _buf.read_f64::()?, - af2: _buf.read_f32::()?, - toc: GPSTimeSec::parse(_buf)?, - iode: _buf.read_u16::()?, - iodc: _buf.read_u16::()?, - } ) - } -} -impl super::SBPMessage for MsgEphemerisGalDepA { - fn get_message_name(&self) -> &'static str { - "MSG_EPHEMERIS_GAL_DEP_A" - } - - fn get_message_type(&self) -> u16 { - 149 - } - - fn get_sender_id(&self) -> Option { +impl ConcreteMessage for MsgEphemerisGalDepA { + const MESSAGE_TYPE: u16 = 149; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GAL_DEP_A"; +} + +impl SbpMessage for MsgEphemerisGalDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME + } + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgEphemerisGalDepA { - const MESSAGE_TYPE: u16 = 149; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GAL_DEP_A"; -} -impl TryFrom for MsgEphemerisGalDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgEphemerisGalDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgEphemerisGalDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgEphemerisGalDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgEphemerisGalDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.common.append_to_sbp_buffer(buf); - self.bgd_e1e5a.append_to_sbp_buffer(buf); - self.bgd_e1e5b.append_to_sbp_buffer(buf); - self.c_rs.append_to_sbp_buffer(buf); - self.c_rc.append_to_sbp_buffer(buf); - self.c_uc.append_to_sbp_buffer(buf); - self.c_us.append_to_sbp_buffer(buf); - self.c_ic.append_to_sbp_buffer(buf); - self.c_is.append_to_sbp_buffer(buf); - self.dn.append_to_sbp_buffer(buf); - self.m0.append_to_sbp_buffer(buf); - self.ecc.append_to_sbp_buffer(buf); - self.sqrta.append_to_sbp_buffer(buf); - self.omega0.append_to_sbp_buffer(buf); - self.omegadot.append_to_sbp_buffer(buf); - self.w.append_to_sbp_buffer(buf); - self.inc.append_to_sbp_buffer(buf); - self.inc_dot.append_to_sbp_buffer(buf); - self.af0.append_to_sbp_buffer(buf); - self.af1.append_to_sbp_buffer(buf); - self.af2.append_to_sbp_buffer(buf); - self.toc.append_to_sbp_buffer(buf); - self.iode.append_to_sbp_buffer(buf); - self.iodc.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.common.sbp_size(); - size += self.bgd_e1e5a.sbp_size(); - size += self.bgd_e1e5b.sbp_size(); - size += self.c_rs.sbp_size(); - size += self.c_rc.sbp_size(); - size += self.c_uc.sbp_size(); - size += self.c_us.sbp_size(); - size += self.c_ic.sbp_size(); - size += self.c_is.sbp_size(); - size += self.dn.sbp_size(); - size += self.m0.sbp_size(); - size += self.ecc.sbp_size(); - size += self.sqrta.sbp_size(); - size += self.omega0.sbp_size(); - size += self.omegadot.sbp_size(); - size += self.w.sbp_size(); - size += self.inc.sbp_size(); - size += self.inc_dot.sbp_size(); - size += self.af0.sbp_size(); - size += self.af1.sbp_size(); - size += self.af2.sbp_size(); - size += self.toc.sbp_size(); - size += self.iode.sbp_size(); - size += self.iodc.sbp_size(); - size +impl WireFormat for MsgEphemerisGalDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.common) + + WireFormat::encoded_len(&self.bgd_e1e5a) + + WireFormat::encoded_len(&self.bgd_e1e5b) + + WireFormat::encoded_len(&self.c_rs) + + WireFormat::encoded_len(&self.c_rc) + + WireFormat::encoded_len(&self.c_uc) + + WireFormat::encoded_len(&self.c_us) + + WireFormat::encoded_len(&self.c_ic) + + WireFormat::encoded_len(&self.c_is) + + WireFormat::encoded_len(&self.dn) + + WireFormat::encoded_len(&self.m0) + + WireFormat::encoded_len(&self.ecc) + + WireFormat::encoded_len(&self.sqrta) + + WireFormat::encoded_len(&self.omega0) + + WireFormat::encoded_len(&self.omegadot) + + WireFormat::encoded_len(&self.w) + + WireFormat::encoded_len(&self.inc) + + WireFormat::encoded_len(&self.inc_dot) + + WireFormat::encoded_len(&self.af0) + + WireFormat::encoded_len(&self.af1) + + WireFormat::encoded_len(&self.af2) + + WireFormat::encoded_len(&self.toc) + + WireFormat::encoded_len(&self.iode) + + WireFormat::encoded_len(&self.iodc) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.common, buf); + WireFormat::write(&self.bgd_e1e5a, buf); + WireFormat::write(&self.bgd_e1e5b, buf); + WireFormat::write(&self.c_rs, buf); + WireFormat::write(&self.c_rc, buf); + WireFormat::write(&self.c_uc, buf); + WireFormat::write(&self.c_us, buf); + WireFormat::write(&self.c_ic, buf); + WireFormat::write(&self.c_is, buf); + WireFormat::write(&self.dn, buf); + WireFormat::write(&self.m0, buf); + WireFormat::write(&self.ecc, buf); + WireFormat::write(&self.sqrta, buf); + WireFormat::write(&self.omega0, buf); + WireFormat::write(&self.omegadot, buf); + WireFormat::write(&self.w, buf); + WireFormat::write(&self.inc, buf); + WireFormat::write(&self.inc_dot, buf); + WireFormat::write(&self.af0, buf); + WireFormat::write(&self.af1, buf); + WireFormat::write(&self.af2, buf); + WireFormat::write(&self.toc, buf); + WireFormat::write(&self.iode, buf); + WireFormat::write(&self.iodc, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgEphemerisGalDepA { + sender_id: None, + common: WireFormat::parse_unchecked(buf), + bgd_e1e5a: WireFormat::parse_unchecked(buf), + bgd_e1e5b: WireFormat::parse_unchecked(buf), + c_rs: WireFormat::parse_unchecked(buf), + c_rc: WireFormat::parse_unchecked(buf), + c_uc: WireFormat::parse_unchecked(buf), + c_us: WireFormat::parse_unchecked(buf), + c_ic: WireFormat::parse_unchecked(buf), + c_is: WireFormat::parse_unchecked(buf), + dn: WireFormat::parse_unchecked(buf), + m0: WireFormat::parse_unchecked(buf), + ecc: WireFormat::parse_unchecked(buf), + sqrta: WireFormat::parse_unchecked(buf), + omega0: WireFormat::parse_unchecked(buf), + omegadot: WireFormat::parse_unchecked(buf), + w: WireFormat::parse_unchecked(buf), + inc: WireFormat::parse_unchecked(buf), + inc_dot: WireFormat::parse_unchecked(buf), + af0: WireFormat::parse_unchecked(buf), + af1: WireFormat::parse_unchecked(buf), + af2: WireFormat::parse_unchecked(buf), + toc: WireFormat::parse_unchecked(buf), + iode: WireFormat::parse_unchecked(buf), + iodc: WireFormat::parse_unchecked(buf), + } } } @@ -2812,117 +2901,116 @@ impl crate::serialize::SbpSerialize for MsgEphemerisGalDepA { /// Please see the GLO ICD 5.1 "Table 4.5 Characteristics of words of /// immediate information (ephemeris parameters)" for more details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgEphemerisGlo { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Values common for all ephemeris types + #[cfg_attr(feature = "serde", serde(rename(serialize = "common")))] pub common: EphemerisCommonContent, /// Relative deviation of predicted carrier frequency from nominal + #[cfg_attr(feature = "serde", serde(rename(serialize = "gamma")))] pub gamma: f32, /// Correction to the SV time + #[cfg_attr(feature = "serde", serde(rename(serialize = "tau")))] pub tau: f32, /// Equipment delay between L1 and L2 + #[cfg_attr(feature = "serde", serde(rename(serialize = "d_tau")))] pub d_tau: f32, /// Position of the SV at tb in PZ-90.02 coordinates system - pub pos: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "pos")))] + pub pos: [f64; 3], /// Velocity vector of the SV at tb in PZ-90.02 coordinates system - pub vel: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "vel")))] + pub vel: [f64; 3], /// Acceleration vector of the SV at tb in PZ-90.02 coordinates sys - pub acc: Vec, - /// Frequency slot. FCN+8 (that is [1..14]). 0 or 0xFF for invalid + #[cfg_attr(feature = "serde", serde(rename(serialize = "acc")))] + pub acc: [f32; 3], + /// Frequency slot. FCN+8 (that is \[1..14\]). 0 or 0xFF for invalid + #[cfg_attr(feature = "serde", serde(rename(serialize = "fcn")))] pub fcn: u8, /// Issue of data. Equal to the 7 bits of the immediate data word t_b + #[cfg_attr(feature = "serde", serde(rename(serialize = "iod")))] pub iod: u8, } -impl MsgEphemerisGlo { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgEphemerisGlo{ - sender_id: None, - common: EphemerisCommonContent::parse(_buf)?, - gamma: _buf.read_f32::()?, - tau: _buf.read_f32::()?, - d_tau: _buf.read_f32::()?, - pos: crate::parser::read_double_array_limit(_buf, 3)?, - vel: crate::parser::read_double_array_limit(_buf, 3)?, - acc: crate::parser::read_float_array_limit(_buf, 3)?, - fcn: _buf.read_u8()?, - iod: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgEphemerisGlo { + const MESSAGE_TYPE: u16 = 139; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO"; } -impl super::SBPMessage for MsgEphemerisGlo { - fn get_message_name(&self) -> &'static str { - "MSG_EPHEMERIS_GLO" - } - fn get_message_type(&self) -> u16 { - 139 +impl SbpMessage for MsgEphemerisGlo { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgEphemerisGlo { - const MESSAGE_TYPE: u16 = 139; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO"; } -impl TryFrom for MsgEphemerisGlo { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgEphemerisGlo { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgEphemerisGlo(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgEphemerisGlo(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgEphemerisGlo { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.common.append_to_sbp_buffer(buf); - self.gamma.append_to_sbp_buffer(buf); - self.tau.append_to_sbp_buffer(buf); - self.d_tau.append_to_sbp_buffer(buf); - self.pos.append_to_sbp_buffer(buf); - self.vel.append_to_sbp_buffer(buf); - self.acc.append_to_sbp_buffer(buf); - self.fcn.append_to_sbp_buffer(buf); - self.iod.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.common.sbp_size(); - size += self.gamma.sbp_size(); - size += self.tau.sbp_size(); - size += self.d_tau.sbp_size(); - size += self.pos.sbp_size(); - size += self.vel.sbp_size(); - size += self.acc.sbp_size(); - size += self.fcn.sbp_size(); - size += self.iod.sbp_size(); - size +impl WireFormat for MsgEphemerisGlo { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN + + <[f32; 3] as WireFormat>::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.common) + + WireFormat::encoded_len(&self.gamma) + + WireFormat::encoded_len(&self.tau) + + WireFormat::encoded_len(&self.d_tau) + + WireFormat::encoded_len(&self.pos) + + WireFormat::encoded_len(&self.vel) + + WireFormat::encoded_len(&self.acc) + + WireFormat::encoded_len(&self.fcn) + + WireFormat::encoded_len(&self.iod) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.common, buf); + WireFormat::write(&self.gamma, buf); + WireFormat::write(&self.tau, buf); + WireFormat::write(&self.d_tau, buf); + WireFormat::write(&self.pos, buf); + WireFormat::write(&self.vel, buf); + WireFormat::write(&self.acc, buf); + WireFormat::write(&self.fcn, buf); + WireFormat::write(&self.iod, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgEphemerisGlo { + sender_id: None, + common: WireFormat::parse_unchecked(buf), + gamma: WireFormat::parse_unchecked(buf), + tau: WireFormat::parse_unchecked(buf), + d_tau: WireFormat::parse_unchecked(buf), + pos: WireFormat::parse_unchecked(buf), + vel: WireFormat::parse_unchecked(buf), + acc: WireFormat::parse_unchecked(buf), + fcn: WireFormat::parse_unchecked(buf), + iod: WireFormat::parse_unchecked(buf), + } } } @@ -2933,102 +3021,95 @@ impl crate::serialize::SbpSerialize for MsgEphemerisGlo { /// Please see the GLO ICD 5.1 "Table 4.5 Characteristics of words of /// immediate information (ephemeris parameters)" for more details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgEphemerisGloDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Values common for all ephemeris types + #[cfg_attr(feature = "serde", serde(rename(serialize = "common")))] pub common: EphemerisCommonContentDepA, /// Relative deviation of predicted carrier frequency from nominal + #[cfg_attr(feature = "serde", serde(rename(serialize = "gamma")))] pub gamma: f64, /// Correction to the SV time + #[cfg_attr(feature = "serde", serde(rename(serialize = "tau")))] pub tau: f64, /// Position of the SV at tb in PZ-90.02 coordinates system - pub pos: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "pos")))] + pub pos: [f64; 3], /// Velocity vector of the SV at tb in PZ-90.02 coordinates system - pub vel: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "vel")))] + pub vel: [f64; 3], /// Acceleration vector of the SV at tb in PZ-90.02 coordinates sys - pub acc: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "acc")))] + pub acc: [f64; 3], } -impl MsgEphemerisGloDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgEphemerisGloDepA{ - sender_id: None, - common: EphemerisCommonContentDepA::parse(_buf)?, - gamma: _buf.read_f64::()?, - tau: _buf.read_f64::()?, - pos: crate::parser::read_double_array_limit(_buf, 3)?, - vel: crate::parser::read_double_array_limit(_buf, 3)?, - acc: crate::parser::read_double_array_limit(_buf, 3)?, - } ) - } +impl ConcreteMessage for MsgEphemerisGloDepA { + const MESSAGE_TYPE: u16 = 131; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO_DEP_A"; } -impl super::SBPMessage for MsgEphemerisGloDepA { - fn get_message_name(&self) -> &'static str { - "MSG_EPHEMERIS_GLO_DEP_A" - } - fn get_message_type(&self) -> u16 { - 131 +impl SbpMessage for MsgEphemerisGloDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgEphemerisGloDepA { - const MESSAGE_TYPE: u16 = 131; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO_DEP_A"; -} -impl TryFrom for MsgEphemerisGloDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgEphemerisGloDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgEphemerisGloDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgEphemerisGloDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgEphemerisGloDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.common.append_to_sbp_buffer(buf); - self.gamma.append_to_sbp_buffer(buf); - self.tau.append_to_sbp_buffer(buf); - self.pos.append_to_sbp_buffer(buf); - self.vel.append_to_sbp_buffer(buf); - self.acc.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.common.sbp_size(); - size += self.gamma.sbp_size(); - size += self.tau.sbp_size(); - size += self.pos.sbp_size(); - size += self.vel.sbp_size(); - size += self.acc.sbp_size(); - size +impl WireFormat for MsgEphemerisGloDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.common) + + WireFormat::encoded_len(&self.gamma) + + WireFormat::encoded_len(&self.tau) + + WireFormat::encoded_len(&self.pos) + + WireFormat::encoded_len(&self.vel) + + WireFormat::encoded_len(&self.acc) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.common, buf); + WireFormat::write(&self.gamma, buf); + WireFormat::write(&self.tau, buf); + WireFormat::write(&self.pos, buf); + WireFormat::write(&self.vel, buf); + WireFormat::write(&self.acc, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgEphemerisGloDepA { + sender_id: None, + common: WireFormat::parse_unchecked(buf), + gamma: WireFormat::parse_unchecked(buf), + tau: WireFormat::parse_unchecked(buf), + pos: WireFormat::parse_unchecked(buf), + vel: WireFormat::parse_unchecked(buf), + acc: WireFormat::parse_unchecked(buf), + } } } @@ -3039,102 +3120,95 @@ impl crate::serialize::SbpSerialize for MsgEphemerisGloDepA { /// Please see the GLO ICD 5.1 "Table 4.5 Characteristics of words of /// immediate information (ephemeris parameters)" for more details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgEphemerisGloDepB { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Values common for all ephemeris types + #[cfg_attr(feature = "serde", serde(rename(serialize = "common")))] pub common: EphemerisCommonContentDepB, /// Relative deviation of predicted carrier frequency from nominal + #[cfg_attr(feature = "serde", serde(rename(serialize = "gamma")))] pub gamma: f64, /// Correction to the SV time + #[cfg_attr(feature = "serde", serde(rename(serialize = "tau")))] pub tau: f64, /// Position of the SV at tb in PZ-90.02 coordinates system - pub pos: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "pos")))] + pub pos: [f64; 3], /// Velocity vector of the SV at tb in PZ-90.02 coordinates system - pub vel: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "vel")))] + pub vel: [f64; 3], /// Acceleration vector of the SV at tb in PZ-90.02 coordinates sys - pub acc: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "acc")))] + pub acc: [f64; 3], } -impl MsgEphemerisGloDepB { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgEphemerisGloDepB{ - sender_id: None, - common: EphemerisCommonContentDepB::parse(_buf)?, - gamma: _buf.read_f64::()?, - tau: _buf.read_f64::()?, - pos: crate::parser::read_double_array_limit(_buf, 3)?, - vel: crate::parser::read_double_array_limit(_buf, 3)?, - acc: crate::parser::read_double_array_limit(_buf, 3)?, - } ) - } +impl ConcreteMessage for MsgEphemerisGloDepB { + const MESSAGE_TYPE: u16 = 133; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO_DEP_B"; } -impl super::SBPMessage for MsgEphemerisGloDepB { - fn get_message_name(&self) -> &'static str { - "MSG_EPHEMERIS_GLO_DEP_B" - } - fn get_message_type(&self) -> u16 { - 133 +impl SbpMessage for MsgEphemerisGloDepB { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgEphemerisGloDepB { - const MESSAGE_TYPE: u16 = 133; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO_DEP_B"; } -impl TryFrom for MsgEphemerisGloDepB { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgEphemerisGloDepB { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgEphemerisGloDepB(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgEphemerisGloDepB(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgEphemerisGloDepB { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.common.append_to_sbp_buffer(buf); - self.gamma.append_to_sbp_buffer(buf); - self.tau.append_to_sbp_buffer(buf); - self.pos.append_to_sbp_buffer(buf); - self.vel.append_to_sbp_buffer(buf); - self.acc.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.common.sbp_size(); - size += self.gamma.sbp_size(); - size += self.tau.sbp_size(); - size += self.pos.sbp_size(); - size += self.vel.sbp_size(); - size += self.acc.sbp_size(); - size +impl WireFormat for MsgEphemerisGloDepB { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.common) + + WireFormat::encoded_len(&self.gamma) + + WireFormat::encoded_len(&self.tau) + + WireFormat::encoded_len(&self.pos) + + WireFormat::encoded_len(&self.vel) + + WireFormat::encoded_len(&self.acc) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.common, buf); + WireFormat::write(&self.gamma, buf); + WireFormat::write(&self.tau, buf); + WireFormat::write(&self.pos, buf); + WireFormat::write(&self.vel, buf); + WireFormat::write(&self.acc, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgEphemerisGloDepB { + sender_id: None, + common: WireFormat::parse_unchecked(buf), + gamma: WireFormat::parse_unchecked(buf), + tau: WireFormat::parse_unchecked(buf), + pos: WireFormat::parse_unchecked(buf), + vel: WireFormat::parse_unchecked(buf), + acc: WireFormat::parse_unchecked(buf), + } } } @@ -3145,112 +3219,109 @@ impl crate::serialize::SbpSerialize for MsgEphemerisGloDepB { /// Please see the GLO ICD 5.1 "Table 4.5 Characteristics of words of /// immediate information (ephemeris parameters)" for more details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgEphemerisGloDepC { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Values common for all ephemeris types + #[cfg_attr(feature = "serde", serde(rename(serialize = "common")))] pub common: EphemerisCommonContentDepB, /// Relative deviation of predicted carrier frequency from nominal + #[cfg_attr(feature = "serde", serde(rename(serialize = "gamma")))] pub gamma: f64, /// Correction to the SV time + #[cfg_attr(feature = "serde", serde(rename(serialize = "tau")))] pub tau: f64, /// Equipment delay between L1 and L2 + #[cfg_attr(feature = "serde", serde(rename(serialize = "d_tau")))] pub d_tau: f64, /// Position of the SV at tb in PZ-90.02 coordinates system - pub pos: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "pos")))] + pub pos: [f64; 3], /// Velocity vector of the SV at tb in PZ-90.02 coordinates system - pub vel: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "vel")))] + pub vel: [f64; 3], /// Acceleration vector of the SV at tb in PZ-90.02 coordinates sys - pub acc: Vec, - /// Frequency slot. FCN+8 (that is [1..14]). 0 or 0xFF for invalid + #[cfg_attr(feature = "serde", serde(rename(serialize = "acc")))] + pub acc: [f64; 3], + /// Frequency slot. FCN+8 (that is \[1..14\]). 0 or 0xFF for invalid + #[cfg_attr(feature = "serde", serde(rename(serialize = "fcn")))] pub fcn: u8, } -impl MsgEphemerisGloDepC { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgEphemerisGloDepC{ - sender_id: None, - common: EphemerisCommonContentDepB::parse(_buf)?, - gamma: _buf.read_f64::()?, - tau: _buf.read_f64::()?, - d_tau: _buf.read_f64::()?, - pos: crate::parser::read_double_array_limit(_buf, 3)?, - vel: crate::parser::read_double_array_limit(_buf, 3)?, - acc: crate::parser::read_double_array_limit(_buf, 3)?, - fcn: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgEphemerisGloDepC { + const MESSAGE_TYPE: u16 = 135; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO_DEP_C"; } -impl super::SBPMessage for MsgEphemerisGloDepC { - fn get_message_name(&self) -> &'static str { - "MSG_EPHEMERIS_GLO_DEP_C" - } - fn get_message_type(&self) -> u16 { - 135 +impl SbpMessage for MsgEphemerisGloDepC { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgEphemerisGloDepC { - const MESSAGE_TYPE: u16 = 135; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO_DEP_C"; } -impl TryFrom for MsgEphemerisGloDepC { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgEphemerisGloDepC { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgEphemerisGloDepC(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgEphemerisGloDepC(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgEphemerisGloDepC { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.common.append_to_sbp_buffer(buf); - self.gamma.append_to_sbp_buffer(buf); - self.tau.append_to_sbp_buffer(buf); - self.d_tau.append_to_sbp_buffer(buf); - self.pos.append_to_sbp_buffer(buf); - self.vel.append_to_sbp_buffer(buf); - self.acc.append_to_sbp_buffer(buf); - self.fcn.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.common.sbp_size(); - size += self.gamma.sbp_size(); - size += self.tau.sbp_size(); - size += self.d_tau.sbp_size(); - size += self.pos.sbp_size(); - size += self.vel.sbp_size(); - size += self.acc.sbp_size(); - size += self.fcn.sbp_size(); - size +impl WireFormat for MsgEphemerisGloDepC { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.common) + + WireFormat::encoded_len(&self.gamma) + + WireFormat::encoded_len(&self.tau) + + WireFormat::encoded_len(&self.d_tau) + + WireFormat::encoded_len(&self.pos) + + WireFormat::encoded_len(&self.vel) + + WireFormat::encoded_len(&self.acc) + + WireFormat::encoded_len(&self.fcn) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.common, buf); + WireFormat::write(&self.gamma, buf); + WireFormat::write(&self.tau, buf); + WireFormat::write(&self.d_tau, buf); + WireFormat::write(&self.pos, buf); + WireFormat::write(&self.vel, buf); + WireFormat::write(&self.acc, buf); + WireFormat::write(&self.fcn, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgEphemerisGloDepC { + sender_id: None, + common: WireFormat::parse_unchecked(buf), + gamma: WireFormat::parse_unchecked(buf), + tau: WireFormat::parse_unchecked(buf), + d_tau: WireFormat::parse_unchecked(buf), + pos: WireFormat::parse_unchecked(buf), + vel: WireFormat::parse_unchecked(buf), + acc: WireFormat::parse_unchecked(buf), + fcn: WireFormat::parse_unchecked(buf), + } } } @@ -3259,117 +3330,116 @@ impl crate::serialize::SbpSerialize for MsgEphemerisGloDepC { /// This observation message has been deprecated in favor of ephemeris message /// using floats for size reduction. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgEphemerisGloDepD { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Values common for all ephemeris types + #[cfg_attr(feature = "serde", serde(rename(serialize = "common")))] pub common: EphemerisCommonContentDepB, /// Relative deviation of predicted carrier frequency from nominal + #[cfg_attr(feature = "serde", serde(rename(serialize = "gamma")))] pub gamma: f64, /// Correction to the SV time + #[cfg_attr(feature = "serde", serde(rename(serialize = "tau")))] pub tau: f64, /// Equipment delay between L1 and L2 + #[cfg_attr(feature = "serde", serde(rename(serialize = "d_tau")))] pub d_tau: f64, /// Position of the SV at tb in PZ-90.02 coordinates system - pub pos: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "pos")))] + pub pos: [f64; 3], /// Velocity vector of the SV at tb in PZ-90.02 coordinates system - pub vel: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "vel")))] + pub vel: [f64; 3], /// Acceleration vector of the SV at tb in PZ-90.02 coordinates sys - pub acc: Vec, - /// Frequency slot. FCN+8 (that is [1..14]). 0 or 0xFF for invalid + #[cfg_attr(feature = "serde", serde(rename(serialize = "acc")))] + pub acc: [f64; 3], + /// Frequency slot. FCN+8 (that is \[1..14\]). 0 or 0xFF for invalid + #[cfg_attr(feature = "serde", serde(rename(serialize = "fcn")))] pub fcn: u8, /// Issue of data. Equal to the 7 bits of the immediate data word t_b + #[cfg_attr(feature = "serde", serde(rename(serialize = "iod")))] pub iod: u8, } -impl MsgEphemerisGloDepD { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgEphemerisGloDepD{ - sender_id: None, - common: EphemerisCommonContentDepB::parse(_buf)?, - gamma: _buf.read_f64::()?, - tau: _buf.read_f64::()?, - d_tau: _buf.read_f64::()?, - pos: crate::parser::read_double_array_limit(_buf, 3)?, - vel: crate::parser::read_double_array_limit(_buf, 3)?, - acc: crate::parser::read_double_array_limit(_buf, 3)?, - fcn: _buf.read_u8()?, - iod: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgEphemerisGloDepD { + const MESSAGE_TYPE: u16 = 136; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO_DEP_D"; } -impl super::SBPMessage for MsgEphemerisGloDepD { - fn get_message_name(&self) -> &'static str { - "MSG_EPHEMERIS_GLO_DEP_D" - } - fn get_message_type(&self) -> u16 { - 136 +impl SbpMessage for MsgEphemerisGloDepD { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgEphemerisGloDepD { - const MESSAGE_TYPE: u16 = 136; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO_DEP_D"; } -impl TryFrom for MsgEphemerisGloDepD { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgEphemerisGloDepD { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgEphemerisGloDepD(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgEphemerisGloDepD(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgEphemerisGloDepD { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.common.append_to_sbp_buffer(buf); - self.gamma.append_to_sbp_buffer(buf); - self.tau.append_to_sbp_buffer(buf); - self.d_tau.append_to_sbp_buffer(buf); - self.pos.append_to_sbp_buffer(buf); - self.vel.append_to_sbp_buffer(buf); - self.acc.append_to_sbp_buffer(buf); - self.fcn.append_to_sbp_buffer(buf); - self.iod.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.common.sbp_size(); - size += self.gamma.sbp_size(); - size += self.tau.sbp_size(); - size += self.d_tau.sbp_size(); - size += self.pos.sbp_size(); - size += self.vel.sbp_size(); - size += self.acc.sbp_size(); - size += self.fcn.sbp_size(); - size += self.iod.sbp_size(); - size +impl WireFormat for MsgEphemerisGloDepD { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.common) + + WireFormat::encoded_len(&self.gamma) + + WireFormat::encoded_len(&self.tau) + + WireFormat::encoded_len(&self.d_tau) + + WireFormat::encoded_len(&self.pos) + + WireFormat::encoded_len(&self.vel) + + WireFormat::encoded_len(&self.acc) + + WireFormat::encoded_len(&self.fcn) + + WireFormat::encoded_len(&self.iod) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.common, buf); + WireFormat::write(&self.gamma, buf); + WireFormat::write(&self.tau, buf); + WireFormat::write(&self.d_tau, buf); + WireFormat::write(&self.pos, buf); + WireFormat::write(&self.vel, buf); + WireFormat::write(&self.acc, buf); + WireFormat::write(&self.fcn, buf); + WireFormat::write(&self.iod, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgEphemerisGloDepD { + sender_id: None, + common: WireFormat::parse_unchecked(buf), + gamma: WireFormat::parse_unchecked(buf), + tau: WireFormat::parse_unchecked(buf), + d_tau: WireFormat::parse_unchecked(buf), + pos: WireFormat::parse_unchecked(buf), + vel: WireFormat::parse_unchecked(buf), + acc: WireFormat::parse_unchecked(buf), + fcn: WireFormat::parse_unchecked(buf), + iod: WireFormat::parse_unchecked(buf), + } } } @@ -3380,191 +3450,218 @@ impl crate::serialize::SbpSerialize for MsgEphemerisGloDepD { /// Please see the Navstar GPS Space Segment/Navigation user interfaces (ICD- /// GPS-200, Table 20-III) for more details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgEphemerisGPS { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgEphemerisGps { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Values common for all ephemeris types + #[cfg_attr(feature = "serde", serde(rename(serialize = "common")))] pub common: EphemerisCommonContent, /// Group delay differential between L1 and L2 + #[cfg_attr(feature = "serde", serde(rename(serialize = "tgd")))] pub tgd: f32, /// Amplitude of the sine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rs")))] pub c_rs: f32, /// Amplitude of the cosine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rc")))] pub c_rc: f32, /// Amplitude of the cosine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_uc")))] pub c_uc: f32, /// Amplitude of the sine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_us")))] pub c_us: f32, /// Amplitude of the cosine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_ic")))] pub c_ic: f32, /// Amplitude of the sine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_is")))] pub c_is: f32, /// Mean motion difference + #[cfg_attr(feature = "serde", serde(rename(serialize = "dn")))] pub dn: f64, /// Mean anomaly at reference time + #[cfg_attr(feature = "serde", serde(rename(serialize = "m0")))] pub m0: f64, /// Eccentricity of satellite orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "ecc")))] pub ecc: f64, /// Square root of the semi-major axis of orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "sqrta")))] pub sqrta: f64, /// Longitude of ascending node of orbit plane at weekly epoch + #[cfg_attr(feature = "serde", serde(rename(serialize = "omega0")))] pub omega0: f64, /// Rate of right ascension + #[cfg_attr(feature = "serde", serde(rename(serialize = "omegadot")))] pub omegadot: f64, /// Argument of perigee + #[cfg_attr(feature = "serde", serde(rename(serialize = "w")))] pub w: f64, /// Inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc")))] pub inc: f64, /// Inclination first derivative + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc_dot")))] pub inc_dot: f64, /// Polynomial clock correction coefficient (clock bias) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af0")))] pub af0: f32, /// Polynomial clock correction coefficient (clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af1")))] pub af1: f32, /// Polynomial clock correction coefficient (rate of clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af2")))] pub af2: f32, /// Clock reference - pub toc: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "toc")))] + pub toc: GpsTimeSec, /// Issue of ephemeris data + #[cfg_attr(feature = "serde", serde(rename(serialize = "iode")))] pub iode: u8, /// Issue of clock data + #[cfg_attr(feature = "serde", serde(rename(serialize = "iodc")))] pub iodc: u16, } -impl MsgEphemerisGPS { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgEphemerisGPS{ - sender_id: None, - common: EphemerisCommonContent::parse(_buf)?, - tgd: _buf.read_f32::()?, - c_rs: _buf.read_f32::()?, - c_rc: _buf.read_f32::()?, - c_uc: _buf.read_f32::()?, - c_us: _buf.read_f32::()?, - c_ic: _buf.read_f32::()?, - c_is: _buf.read_f32::()?, - dn: _buf.read_f64::()?, - m0: _buf.read_f64::()?, - ecc: _buf.read_f64::()?, - sqrta: _buf.read_f64::()?, - omega0: _buf.read_f64::()?, - omegadot: _buf.read_f64::()?, - w: _buf.read_f64::()?, - inc: _buf.read_f64::()?, - inc_dot: _buf.read_f64::()?, - af0: _buf.read_f32::()?, - af1: _buf.read_f32::()?, - af2: _buf.read_f32::()?, - toc: GPSTimeSec::parse(_buf)?, - iode: _buf.read_u8()?, - iodc: _buf.read_u16::()?, - } ) - } -} -impl super::SBPMessage for MsgEphemerisGPS { - fn get_message_name(&self) -> &'static str { - "MSG_EPHEMERIS_GPS" - } - - fn get_message_type(&self) -> u16 { - 138 - } - - fn get_sender_id(&self) -> Option { +impl ConcreteMessage for MsgEphemerisGps { + const MESSAGE_TYPE: u16 = 138; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GPS"; +} + +impl SbpMessage for MsgEphemerisGps { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME + } + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgEphemerisGPS { - const MESSAGE_TYPE: u16 = 138; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GPS"; -} -impl TryFrom for MsgEphemerisGPS { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgEphemerisGps { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgEphemerisGPS(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgEphemerisGps(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgEphemerisGPS { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.common.append_to_sbp_buffer(buf); - self.tgd.append_to_sbp_buffer(buf); - self.c_rs.append_to_sbp_buffer(buf); - self.c_rc.append_to_sbp_buffer(buf); - self.c_uc.append_to_sbp_buffer(buf); - self.c_us.append_to_sbp_buffer(buf); - self.c_ic.append_to_sbp_buffer(buf); - self.c_is.append_to_sbp_buffer(buf); - self.dn.append_to_sbp_buffer(buf); - self.m0.append_to_sbp_buffer(buf); - self.ecc.append_to_sbp_buffer(buf); - self.sqrta.append_to_sbp_buffer(buf); - self.omega0.append_to_sbp_buffer(buf); - self.omegadot.append_to_sbp_buffer(buf); - self.w.append_to_sbp_buffer(buf); - self.inc.append_to_sbp_buffer(buf); - self.inc_dot.append_to_sbp_buffer(buf); - self.af0.append_to_sbp_buffer(buf); - self.af1.append_to_sbp_buffer(buf); - self.af2.append_to_sbp_buffer(buf); - self.toc.append_to_sbp_buffer(buf); - self.iode.append_to_sbp_buffer(buf); - self.iodc.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.common.sbp_size(); - size += self.tgd.sbp_size(); - size += self.c_rs.sbp_size(); - size += self.c_rc.sbp_size(); - size += self.c_uc.sbp_size(); - size += self.c_us.sbp_size(); - size += self.c_ic.sbp_size(); - size += self.c_is.sbp_size(); - size += self.dn.sbp_size(); - size += self.m0.sbp_size(); - size += self.ecc.sbp_size(); - size += self.sqrta.sbp_size(); - size += self.omega0.sbp_size(); - size += self.omegadot.sbp_size(); - size += self.w.sbp_size(); - size += self.inc.sbp_size(); - size += self.inc_dot.sbp_size(); - size += self.af0.sbp_size(); - size += self.af1.sbp_size(); - size += self.af2.sbp_size(); - size += self.toc.sbp_size(); - size += self.iode.sbp_size(); - size += self.iodc.sbp_size(); - size +impl WireFormat for MsgEphemerisGps { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.common) + + WireFormat::encoded_len(&self.tgd) + + WireFormat::encoded_len(&self.c_rs) + + WireFormat::encoded_len(&self.c_rc) + + WireFormat::encoded_len(&self.c_uc) + + WireFormat::encoded_len(&self.c_us) + + WireFormat::encoded_len(&self.c_ic) + + WireFormat::encoded_len(&self.c_is) + + WireFormat::encoded_len(&self.dn) + + WireFormat::encoded_len(&self.m0) + + WireFormat::encoded_len(&self.ecc) + + WireFormat::encoded_len(&self.sqrta) + + WireFormat::encoded_len(&self.omega0) + + WireFormat::encoded_len(&self.omegadot) + + WireFormat::encoded_len(&self.w) + + WireFormat::encoded_len(&self.inc) + + WireFormat::encoded_len(&self.inc_dot) + + WireFormat::encoded_len(&self.af0) + + WireFormat::encoded_len(&self.af1) + + WireFormat::encoded_len(&self.af2) + + WireFormat::encoded_len(&self.toc) + + WireFormat::encoded_len(&self.iode) + + WireFormat::encoded_len(&self.iodc) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.common, buf); + WireFormat::write(&self.tgd, buf); + WireFormat::write(&self.c_rs, buf); + WireFormat::write(&self.c_rc, buf); + WireFormat::write(&self.c_uc, buf); + WireFormat::write(&self.c_us, buf); + WireFormat::write(&self.c_ic, buf); + WireFormat::write(&self.c_is, buf); + WireFormat::write(&self.dn, buf); + WireFormat::write(&self.m0, buf); + WireFormat::write(&self.ecc, buf); + WireFormat::write(&self.sqrta, buf); + WireFormat::write(&self.omega0, buf); + WireFormat::write(&self.omegadot, buf); + WireFormat::write(&self.w, buf); + WireFormat::write(&self.inc, buf); + WireFormat::write(&self.inc_dot, buf); + WireFormat::write(&self.af0, buf); + WireFormat::write(&self.af1, buf); + WireFormat::write(&self.af2, buf); + WireFormat::write(&self.toc, buf); + WireFormat::write(&self.iode, buf); + WireFormat::write(&self.iodc, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgEphemerisGps { + sender_id: None, + common: WireFormat::parse_unchecked(buf), + tgd: WireFormat::parse_unchecked(buf), + c_rs: WireFormat::parse_unchecked(buf), + c_rc: WireFormat::parse_unchecked(buf), + c_uc: WireFormat::parse_unchecked(buf), + c_us: WireFormat::parse_unchecked(buf), + c_ic: WireFormat::parse_unchecked(buf), + c_is: WireFormat::parse_unchecked(buf), + dn: WireFormat::parse_unchecked(buf), + m0: WireFormat::parse_unchecked(buf), + ecc: WireFormat::parse_unchecked(buf), + sqrta: WireFormat::parse_unchecked(buf), + omega0: WireFormat::parse_unchecked(buf), + omegadot: WireFormat::parse_unchecked(buf), + w: WireFormat::parse_unchecked(buf), + inc: WireFormat::parse_unchecked(buf), + inc_dot: WireFormat::parse_unchecked(buf), + af0: WireFormat::parse_unchecked(buf), + af1: WireFormat::parse_unchecked(buf), + af2: WireFormat::parse_unchecked(buf), + toc: WireFormat::parse_unchecked(buf), + iode: WireFormat::parse_unchecked(buf), + iodc: WireFormat::parse_unchecked(buf), + } } } @@ -3575,191 +3672,218 @@ impl crate::serialize::SbpSerialize for MsgEphemerisGPS { /// Please see the Navstar GPS Space Segment/Navigation user interfaces (ICD- /// GPS-200, Table 20-III) for more details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgEphemerisGPSDepE { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgEphemerisGpsDepE { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Values common for all ephemeris types + #[cfg_attr(feature = "serde", serde(rename(serialize = "common")))] pub common: EphemerisCommonContentDepA, /// Group delay differential between L1 and L2 + #[cfg_attr(feature = "serde", serde(rename(serialize = "tgd")))] pub tgd: f64, /// Amplitude of the sine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rs")))] pub c_rs: f64, /// Amplitude of the cosine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rc")))] pub c_rc: f64, /// Amplitude of the cosine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_uc")))] pub c_uc: f64, /// Amplitude of the sine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_us")))] pub c_us: f64, /// Amplitude of the cosine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_ic")))] pub c_ic: f64, /// Amplitude of the sine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_is")))] pub c_is: f64, /// Mean motion difference + #[cfg_attr(feature = "serde", serde(rename(serialize = "dn")))] pub dn: f64, /// Mean anomaly at reference time + #[cfg_attr(feature = "serde", serde(rename(serialize = "m0")))] pub m0: f64, /// Eccentricity of satellite orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "ecc")))] pub ecc: f64, /// Square root of the semi-major axis of orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "sqrta")))] pub sqrta: f64, /// Longitude of ascending node of orbit plane at weekly epoch + #[cfg_attr(feature = "serde", serde(rename(serialize = "omega0")))] pub omega0: f64, /// Rate of right ascension + #[cfg_attr(feature = "serde", serde(rename(serialize = "omegadot")))] pub omegadot: f64, /// Argument of perigee + #[cfg_attr(feature = "serde", serde(rename(serialize = "w")))] pub w: f64, /// Inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc")))] pub inc: f64, /// Inclination first derivative + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc_dot")))] pub inc_dot: f64, /// Polynomial clock correction coefficient (clock bias) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af0")))] pub af0: f64, /// Polynomial clock correction coefficient (clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af1")))] pub af1: f64, /// Polynomial clock correction coefficient (rate of clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af2")))] pub af2: f64, /// Clock reference - pub toc: GPSTimeDep, + #[cfg_attr(feature = "serde", serde(rename(serialize = "toc")))] + pub toc: GpsTimeDep, /// Issue of ephemeris data + #[cfg_attr(feature = "serde", serde(rename(serialize = "iode")))] pub iode: u8, /// Issue of clock data + #[cfg_attr(feature = "serde", serde(rename(serialize = "iodc")))] pub iodc: u16, } -impl MsgEphemerisGPSDepE { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgEphemerisGPSDepE{ - sender_id: None, - common: EphemerisCommonContentDepA::parse(_buf)?, - tgd: _buf.read_f64::()?, - c_rs: _buf.read_f64::()?, - c_rc: _buf.read_f64::()?, - c_uc: _buf.read_f64::()?, - c_us: _buf.read_f64::()?, - c_ic: _buf.read_f64::()?, - c_is: _buf.read_f64::()?, - dn: _buf.read_f64::()?, - m0: _buf.read_f64::()?, - ecc: _buf.read_f64::()?, - sqrta: _buf.read_f64::()?, - omega0: _buf.read_f64::()?, - omegadot: _buf.read_f64::()?, - w: _buf.read_f64::()?, - inc: _buf.read_f64::()?, - inc_dot: _buf.read_f64::()?, - af0: _buf.read_f64::()?, - af1: _buf.read_f64::()?, - af2: _buf.read_f64::()?, - toc: GPSTimeDep::parse(_buf)?, - iode: _buf.read_u8()?, - iodc: _buf.read_u16::()?, - } ) - } -} -impl super::SBPMessage for MsgEphemerisGPSDepE { - fn get_message_name(&self) -> &'static str { - "MSG_EPHEMERIS_GPS_DEP_E" - } - - fn get_message_type(&self) -> u16 { - 129 - } - - fn get_sender_id(&self) -> Option { +impl ConcreteMessage for MsgEphemerisGpsDepE { + const MESSAGE_TYPE: u16 = 129; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GPS_DEP_E"; +} + +impl SbpMessage for MsgEphemerisGpsDepE { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME + } + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgEphemerisGPSDepE { - const MESSAGE_TYPE: u16 = 129; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GPS_DEP_E"; } -impl TryFrom for MsgEphemerisGPSDepE { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgEphemerisGpsDepE { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgEphemerisGPSDepE(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgEphemerisGpsDepE(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgEphemerisGPSDepE { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.common.append_to_sbp_buffer(buf); - self.tgd.append_to_sbp_buffer(buf); - self.c_rs.append_to_sbp_buffer(buf); - self.c_rc.append_to_sbp_buffer(buf); - self.c_uc.append_to_sbp_buffer(buf); - self.c_us.append_to_sbp_buffer(buf); - self.c_ic.append_to_sbp_buffer(buf); - self.c_is.append_to_sbp_buffer(buf); - self.dn.append_to_sbp_buffer(buf); - self.m0.append_to_sbp_buffer(buf); - self.ecc.append_to_sbp_buffer(buf); - self.sqrta.append_to_sbp_buffer(buf); - self.omega0.append_to_sbp_buffer(buf); - self.omegadot.append_to_sbp_buffer(buf); - self.w.append_to_sbp_buffer(buf); - self.inc.append_to_sbp_buffer(buf); - self.inc_dot.append_to_sbp_buffer(buf); - self.af0.append_to_sbp_buffer(buf); - self.af1.append_to_sbp_buffer(buf); - self.af2.append_to_sbp_buffer(buf); - self.toc.append_to_sbp_buffer(buf); - self.iode.append_to_sbp_buffer(buf); - self.iodc.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.common.sbp_size(); - size += self.tgd.sbp_size(); - size += self.c_rs.sbp_size(); - size += self.c_rc.sbp_size(); - size += self.c_uc.sbp_size(); - size += self.c_us.sbp_size(); - size += self.c_ic.sbp_size(); - size += self.c_is.sbp_size(); - size += self.dn.sbp_size(); - size += self.m0.sbp_size(); - size += self.ecc.sbp_size(); - size += self.sqrta.sbp_size(); - size += self.omega0.sbp_size(); - size += self.omegadot.sbp_size(); - size += self.w.sbp_size(); - size += self.inc.sbp_size(); - size += self.inc_dot.sbp_size(); - size += self.af0.sbp_size(); - size += self.af1.sbp_size(); - size += self.af2.sbp_size(); - size += self.toc.sbp_size(); - size += self.iode.sbp_size(); - size += self.iodc.sbp_size(); - size +impl WireFormat for MsgEphemerisGpsDepE { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.common) + + WireFormat::encoded_len(&self.tgd) + + WireFormat::encoded_len(&self.c_rs) + + WireFormat::encoded_len(&self.c_rc) + + WireFormat::encoded_len(&self.c_uc) + + WireFormat::encoded_len(&self.c_us) + + WireFormat::encoded_len(&self.c_ic) + + WireFormat::encoded_len(&self.c_is) + + WireFormat::encoded_len(&self.dn) + + WireFormat::encoded_len(&self.m0) + + WireFormat::encoded_len(&self.ecc) + + WireFormat::encoded_len(&self.sqrta) + + WireFormat::encoded_len(&self.omega0) + + WireFormat::encoded_len(&self.omegadot) + + WireFormat::encoded_len(&self.w) + + WireFormat::encoded_len(&self.inc) + + WireFormat::encoded_len(&self.inc_dot) + + WireFormat::encoded_len(&self.af0) + + WireFormat::encoded_len(&self.af1) + + WireFormat::encoded_len(&self.af2) + + WireFormat::encoded_len(&self.toc) + + WireFormat::encoded_len(&self.iode) + + WireFormat::encoded_len(&self.iodc) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.common, buf); + WireFormat::write(&self.tgd, buf); + WireFormat::write(&self.c_rs, buf); + WireFormat::write(&self.c_rc, buf); + WireFormat::write(&self.c_uc, buf); + WireFormat::write(&self.c_us, buf); + WireFormat::write(&self.c_ic, buf); + WireFormat::write(&self.c_is, buf); + WireFormat::write(&self.dn, buf); + WireFormat::write(&self.m0, buf); + WireFormat::write(&self.ecc, buf); + WireFormat::write(&self.sqrta, buf); + WireFormat::write(&self.omega0, buf); + WireFormat::write(&self.omegadot, buf); + WireFormat::write(&self.w, buf); + WireFormat::write(&self.inc, buf); + WireFormat::write(&self.inc_dot, buf); + WireFormat::write(&self.af0, buf); + WireFormat::write(&self.af1, buf); + WireFormat::write(&self.af2, buf); + WireFormat::write(&self.toc, buf); + WireFormat::write(&self.iode, buf); + WireFormat::write(&self.iodc, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgEphemerisGpsDepE { + sender_id: None, + common: WireFormat::parse_unchecked(buf), + tgd: WireFormat::parse_unchecked(buf), + c_rs: WireFormat::parse_unchecked(buf), + c_rc: WireFormat::parse_unchecked(buf), + c_uc: WireFormat::parse_unchecked(buf), + c_us: WireFormat::parse_unchecked(buf), + c_ic: WireFormat::parse_unchecked(buf), + c_is: WireFormat::parse_unchecked(buf), + dn: WireFormat::parse_unchecked(buf), + m0: WireFormat::parse_unchecked(buf), + ecc: WireFormat::parse_unchecked(buf), + sqrta: WireFormat::parse_unchecked(buf), + omega0: WireFormat::parse_unchecked(buf), + omegadot: WireFormat::parse_unchecked(buf), + w: WireFormat::parse_unchecked(buf), + inc: WireFormat::parse_unchecked(buf), + inc_dot: WireFormat::parse_unchecked(buf), + af0: WireFormat::parse_unchecked(buf), + af1: WireFormat::parse_unchecked(buf), + af2: WireFormat::parse_unchecked(buf), + toc: WireFormat::parse_unchecked(buf), + iode: WireFormat::parse_unchecked(buf), + iodc: WireFormat::parse_unchecked(buf), + } } } @@ -3768,191 +3892,218 @@ impl crate::serialize::SbpSerialize for MsgEphemerisGPSDepE { /// This observation message has been deprecated in favor of ephemeris message /// using floats for size reduction. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgEphemerisGPSDepF { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgEphemerisGpsDepF { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Values common for all ephemeris types + #[cfg_attr(feature = "serde", serde(rename(serialize = "common")))] pub common: EphemerisCommonContentDepB, /// Group delay differential between L1 and L2 + #[cfg_attr(feature = "serde", serde(rename(serialize = "tgd")))] pub tgd: f64, /// Amplitude of the sine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rs")))] pub c_rs: f64, /// Amplitude of the cosine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rc")))] pub c_rc: f64, /// Amplitude of the cosine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_uc")))] pub c_uc: f64, /// Amplitude of the sine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_us")))] pub c_us: f64, /// Amplitude of the cosine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_ic")))] pub c_ic: f64, /// Amplitude of the sine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_is")))] pub c_is: f64, /// Mean motion difference + #[cfg_attr(feature = "serde", serde(rename(serialize = "dn")))] pub dn: f64, /// Mean anomaly at reference time + #[cfg_attr(feature = "serde", serde(rename(serialize = "m0")))] pub m0: f64, /// Eccentricity of satellite orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "ecc")))] pub ecc: f64, /// Square root of the semi-major axis of orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "sqrta")))] pub sqrta: f64, /// Longitude of ascending node of orbit plane at weekly epoch + #[cfg_attr(feature = "serde", serde(rename(serialize = "omega0")))] pub omega0: f64, /// Rate of right ascension + #[cfg_attr(feature = "serde", serde(rename(serialize = "omegadot")))] pub omegadot: f64, /// Argument of perigee + #[cfg_attr(feature = "serde", serde(rename(serialize = "w")))] pub w: f64, /// Inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc")))] pub inc: f64, /// Inclination first derivative + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc_dot")))] pub inc_dot: f64, /// Polynomial clock correction coefficient (clock bias) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af0")))] pub af0: f64, /// Polynomial clock correction coefficient (clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af1")))] pub af1: f64, /// Polynomial clock correction coefficient (rate of clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af2")))] pub af2: f64, /// Clock reference - pub toc: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "toc")))] + pub toc: GpsTimeSec, /// Issue of ephemeris data + #[cfg_attr(feature = "serde", serde(rename(serialize = "iode")))] pub iode: u8, /// Issue of clock data + #[cfg_attr(feature = "serde", serde(rename(serialize = "iodc")))] pub iodc: u16, } -impl MsgEphemerisGPSDepF { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgEphemerisGPSDepF{ - sender_id: None, - common: EphemerisCommonContentDepB::parse(_buf)?, - tgd: _buf.read_f64::()?, - c_rs: _buf.read_f64::()?, - c_rc: _buf.read_f64::()?, - c_uc: _buf.read_f64::()?, - c_us: _buf.read_f64::()?, - c_ic: _buf.read_f64::()?, - c_is: _buf.read_f64::()?, - dn: _buf.read_f64::()?, - m0: _buf.read_f64::()?, - ecc: _buf.read_f64::()?, - sqrta: _buf.read_f64::()?, - omega0: _buf.read_f64::()?, - omegadot: _buf.read_f64::()?, - w: _buf.read_f64::()?, - inc: _buf.read_f64::()?, - inc_dot: _buf.read_f64::()?, - af0: _buf.read_f64::()?, - af1: _buf.read_f64::()?, - af2: _buf.read_f64::()?, - toc: GPSTimeSec::parse(_buf)?, - iode: _buf.read_u8()?, - iodc: _buf.read_u16::()?, - } ) - } -} -impl super::SBPMessage for MsgEphemerisGPSDepF { - fn get_message_name(&self) -> &'static str { - "MSG_EPHEMERIS_GPS_DEP_F" - } - - fn get_message_type(&self) -> u16 { - 134 - } - - fn get_sender_id(&self) -> Option { +impl ConcreteMessage for MsgEphemerisGpsDepF { + const MESSAGE_TYPE: u16 = 134; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GPS_DEP_F"; +} + +impl SbpMessage for MsgEphemerisGpsDepF { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME + } + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgEphemerisGPSDepF { - const MESSAGE_TYPE: u16 = 134; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GPS_DEP_F"; } -impl TryFrom for MsgEphemerisGPSDepF { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgEphemerisGpsDepF { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgEphemerisGPSDepF(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgEphemerisGpsDepF(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgEphemerisGPSDepF { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.common.append_to_sbp_buffer(buf); - self.tgd.append_to_sbp_buffer(buf); - self.c_rs.append_to_sbp_buffer(buf); - self.c_rc.append_to_sbp_buffer(buf); - self.c_uc.append_to_sbp_buffer(buf); - self.c_us.append_to_sbp_buffer(buf); - self.c_ic.append_to_sbp_buffer(buf); - self.c_is.append_to_sbp_buffer(buf); - self.dn.append_to_sbp_buffer(buf); - self.m0.append_to_sbp_buffer(buf); - self.ecc.append_to_sbp_buffer(buf); - self.sqrta.append_to_sbp_buffer(buf); - self.omega0.append_to_sbp_buffer(buf); - self.omegadot.append_to_sbp_buffer(buf); - self.w.append_to_sbp_buffer(buf); - self.inc.append_to_sbp_buffer(buf); - self.inc_dot.append_to_sbp_buffer(buf); - self.af0.append_to_sbp_buffer(buf); - self.af1.append_to_sbp_buffer(buf); - self.af2.append_to_sbp_buffer(buf); - self.toc.append_to_sbp_buffer(buf); - self.iode.append_to_sbp_buffer(buf); - self.iodc.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.common.sbp_size(); - size += self.tgd.sbp_size(); - size += self.c_rs.sbp_size(); - size += self.c_rc.sbp_size(); - size += self.c_uc.sbp_size(); - size += self.c_us.sbp_size(); - size += self.c_ic.sbp_size(); - size += self.c_is.sbp_size(); - size += self.dn.sbp_size(); - size += self.m0.sbp_size(); - size += self.ecc.sbp_size(); - size += self.sqrta.sbp_size(); - size += self.omega0.sbp_size(); - size += self.omegadot.sbp_size(); - size += self.w.sbp_size(); - size += self.inc.sbp_size(); - size += self.inc_dot.sbp_size(); - size += self.af0.sbp_size(); - size += self.af1.sbp_size(); - size += self.af2.sbp_size(); - size += self.toc.sbp_size(); - size += self.iode.sbp_size(); - size += self.iodc.sbp_size(); - size +impl WireFormat for MsgEphemerisGpsDepF { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.common) + + WireFormat::encoded_len(&self.tgd) + + WireFormat::encoded_len(&self.c_rs) + + WireFormat::encoded_len(&self.c_rc) + + WireFormat::encoded_len(&self.c_uc) + + WireFormat::encoded_len(&self.c_us) + + WireFormat::encoded_len(&self.c_ic) + + WireFormat::encoded_len(&self.c_is) + + WireFormat::encoded_len(&self.dn) + + WireFormat::encoded_len(&self.m0) + + WireFormat::encoded_len(&self.ecc) + + WireFormat::encoded_len(&self.sqrta) + + WireFormat::encoded_len(&self.omega0) + + WireFormat::encoded_len(&self.omegadot) + + WireFormat::encoded_len(&self.w) + + WireFormat::encoded_len(&self.inc) + + WireFormat::encoded_len(&self.inc_dot) + + WireFormat::encoded_len(&self.af0) + + WireFormat::encoded_len(&self.af1) + + WireFormat::encoded_len(&self.af2) + + WireFormat::encoded_len(&self.toc) + + WireFormat::encoded_len(&self.iode) + + WireFormat::encoded_len(&self.iodc) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.common, buf); + WireFormat::write(&self.tgd, buf); + WireFormat::write(&self.c_rs, buf); + WireFormat::write(&self.c_rc, buf); + WireFormat::write(&self.c_uc, buf); + WireFormat::write(&self.c_us, buf); + WireFormat::write(&self.c_ic, buf); + WireFormat::write(&self.c_is, buf); + WireFormat::write(&self.dn, buf); + WireFormat::write(&self.m0, buf); + WireFormat::write(&self.ecc, buf); + WireFormat::write(&self.sqrta, buf); + WireFormat::write(&self.omega0, buf); + WireFormat::write(&self.omegadot, buf); + WireFormat::write(&self.w, buf); + WireFormat::write(&self.inc, buf); + WireFormat::write(&self.inc_dot, buf); + WireFormat::write(&self.af0, buf); + WireFormat::write(&self.af1, buf); + WireFormat::write(&self.af2, buf); + WireFormat::write(&self.toc, buf); + WireFormat::write(&self.iode, buf); + WireFormat::write(&self.iodc, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgEphemerisGpsDepF { + sender_id: None, + common: WireFormat::parse_unchecked(buf), + tgd: WireFormat::parse_unchecked(buf), + c_rs: WireFormat::parse_unchecked(buf), + c_rc: WireFormat::parse_unchecked(buf), + c_uc: WireFormat::parse_unchecked(buf), + c_us: WireFormat::parse_unchecked(buf), + c_ic: WireFormat::parse_unchecked(buf), + c_is: WireFormat::parse_unchecked(buf), + dn: WireFormat::parse_unchecked(buf), + m0: WireFormat::parse_unchecked(buf), + ecc: WireFormat::parse_unchecked(buf), + sqrta: WireFormat::parse_unchecked(buf), + omega0: WireFormat::parse_unchecked(buf), + omegadot: WireFormat::parse_unchecked(buf), + w: WireFormat::parse_unchecked(buf), + inc: WireFormat::parse_unchecked(buf), + inc_dot: WireFormat::parse_unchecked(buf), + af0: WireFormat::parse_unchecked(buf), + af1: WireFormat::parse_unchecked(buf), + af2: WireFormat::parse_unchecked(buf), + toc: WireFormat::parse_unchecked(buf), + iode: WireFormat::parse_unchecked(buf), + iodc: WireFormat::parse_unchecked(buf), + } } } @@ -3961,389 +4112,404 @@ impl crate::serialize::SbpSerialize for MsgEphemerisGPSDepF { /// The ephemeris message returns a set of satellite orbit parameters that is /// used to calculate QZSS satellite position, velocity, and clock offset. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgEphemerisQzss { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Values common for all ephemeris types + #[cfg_attr(feature = "serde", serde(rename(serialize = "common")))] pub common: EphemerisCommonContent, /// Group delay differential between L1 and L2 + #[cfg_attr(feature = "serde", serde(rename(serialize = "tgd")))] pub tgd: f32, /// Amplitude of the sine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rs")))] pub c_rs: f32, /// Amplitude of the cosine harmonic correction term to the orbit radius + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_rc")))] pub c_rc: f32, /// Amplitude of the cosine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_uc")))] pub c_uc: f32, /// Amplitude of the sine harmonic correction term to the argument of /// latitude + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_us")))] pub c_us: f32, /// Amplitude of the cosine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_ic")))] pub c_ic: f32, /// Amplitude of the sine harmonic correction term to the angle of /// inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "c_is")))] pub c_is: f32, /// Mean motion difference + #[cfg_attr(feature = "serde", serde(rename(serialize = "dn")))] pub dn: f64, /// Mean anomaly at reference time + #[cfg_attr(feature = "serde", serde(rename(serialize = "m0")))] pub m0: f64, /// Eccentricity of satellite orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "ecc")))] pub ecc: f64, /// Square root of the semi-major axis of orbit + #[cfg_attr(feature = "serde", serde(rename(serialize = "sqrta")))] pub sqrta: f64, /// Longitude of ascending node of orbit plane at weekly epoch + #[cfg_attr(feature = "serde", serde(rename(serialize = "omega0")))] pub omega0: f64, /// Rate of right ascension + #[cfg_attr(feature = "serde", serde(rename(serialize = "omegadot")))] pub omegadot: f64, /// Argument of perigee + #[cfg_attr(feature = "serde", serde(rename(serialize = "w")))] pub w: f64, /// Inclination + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc")))] pub inc: f64, /// Inclination first derivative + #[cfg_attr(feature = "serde", serde(rename(serialize = "inc_dot")))] pub inc_dot: f64, /// Polynomial clock correction coefficient (clock bias) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af0")))] pub af0: f32, /// Polynomial clock correction coefficient (clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af1")))] pub af1: f32, /// Polynomial clock correction coefficient (rate of clock drift) + #[cfg_attr(feature = "serde", serde(rename(serialize = "af2")))] pub af2: f32, /// Clock reference - pub toc: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "toc")))] + pub toc: GpsTimeSec, /// Issue of ephemeris data + #[cfg_attr(feature = "serde", serde(rename(serialize = "iode")))] pub iode: u8, /// Issue of clock data + #[cfg_attr(feature = "serde", serde(rename(serialize = "iodc")))] pub iodc: u16, } -impl MsgEphemerisQzss { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgEphemerisQzss{ - sender_id: None, - common: EphemerisCommonContent::parse(_buf)?, - tgd: _buf.read_f32::()?, - c_rs: _buf.read_f32::()?, - c_rc: _buf.read_f32::()?, - c_uc: _buf.read_f32::()?, - c_us: _buf.read_f32::()?, - c_ic: _buf.read_f32::()?, - c_is: _buf.read_f32::()?, - dn: _buf.read_f64::()?, - m0: _buf.read_f64::()?, - ecc: _buf.read_f64::()?, - sqrta: _buf.read_f64::()?, - omega0: _buf.read_f64::()?, - omegadot: _buf.read_f64::()?, - w: _buf.read_f64::()?, - inc: _buf.read_f64::()?, - inc_dot: _buf.read_f64::()?, - af0: _buf.read_f32::()?, - af1: _buf.read_f32::()?, - af2: _buf.read_f32::()?, - toc: GPSTimeSec::parse(_buf)?, - iode: _buf.read_u8()?, - iodc: _buf.read_u16::()?, - } ) - } -} -impl super::SBPMessage for MsgEphemerisQzss { - fn get_message_name(&self) -> &'static str { - "MSG_EPHEMERIS_QZSS" - } - - fn get_message_type(&self) -> u16 { - 142 - } - - fn get_sender_id(&self) -> Option { +impl ConcreteMessage for MsgEphemerisQzss { + const MESSAGE_TYPE: u16 = 142; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_QZSS"; +} + +impl SbpMessage for MsgEphemerisQzss { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME + } + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } +} - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) +impl TryFrom for MsgEphemerisQzss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisQzss(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -impl super::ConcreteMessage for MsgEphemerisQzss { - const MESSAGE_TYPE: u16 = 142; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_QZSS"; -} -impl TryFrom for MsgEphemerisQzss { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { - match msg { - super::SBP::MsgEphemerisQzss(m) => Ok(m), - _ => Err(super::TryFromSBPError), +impl WireFormat for MsgEphemerisQzss { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.common) + + WireFormat::encoded_len(&self.tgd) + + WireFormat::encoded_len(&self.c_rs) + + WireFormat::encoded_len(&self.c_rc) + + WireFormat::encoded_len(&self.c_uc) + + WireFormat::encoded_len(&self.c_us) + + WireFormat::encoded_len(&self.c_ic) + + WireFormat::encoded_len(&self.c_is) + + WireFormat::encoded_len(&self.dn) + + WireFormat::encoded_len(&self.m0) + + WireFormat::encoded_len(&self.ecc) + + WireFormat::encoded_len(&self.sqrta) + + WireFormat::encoded_len(&self.omega0) + + WireFormat::encoded_len(&self.omegadot) + + WireFormat::encoded_len(&self.w) + + WireFormat::encoded_len(&self.inc) + + WireFormat::encoded_len(&self.inc_dot) + + WireFormat::encoded_len(&self.af0) + + WireFormat::encoded_len(&self.af1) + + WireFormat::encoded_len(&self.af2) + + WireFormat::encoded_len(&self.toc) + + WireFormat::encoded_len(&self.iode) + + WireFormat::encoded_len(&self.iodc) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.common, buf); + WireFormat::write(&self.tgd, buf); + WireFormat::write(&self.c_rs, buf); + WireFormat::write(&self.c_rc, buf); + WireFormat::write(&self.c_uc, buf); + WireFormat::write(&self.c_us, buf); + WireFormat::write(&self.c_ic, buf); + WireFormat::write(&self.c_is, buf); + WireFormat::write(&self.dn, buf); + WireFormat::write(&self.m0, buf); + WireFormat::write(&self.ecc, buf); + WireFormat::write(&self.sqrta, buf); + WireFormat::write(&self.omega0, buf); + WireFormat::write(&self.omegadot, buf); + WireFormat::write(&self.w, buf); + WireFormat::write(&self.inc, buf); + WireFormat::write(&self.inc_dot, buf); + WireFormat::write(&self.af0, buf); + WireFormat::write(&self.af1, buf); + WireFormat::write(&self.af2, buf); + WireFormat::write(&self.toc, buf); + WireFormat::write(&self.iode, buf); + WireFormat::write(&self.iodc, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgEphemerisQzss { + sender_id: None, + common: WireFormat::parse_unchecked(buf), + tgd: WireFormat::parse_unchecked(buf), + c_rs: WireFormat::parse_unchecked(buf), + c_rc: WireFormat::parse_unchecked(buf), + c_uc: WireFormat::parse_unchecked(buf), + c_us: WireFormat::parse_unchecked(buf), + c_ic: WireFormat::parse_unchecked(buf), + c_is: WireFormat::parse_unchecked(buf), + dn: WireFormat::parse_unchecked(buf), + m0: WireFormat::parse_unchecked(buf), + ecc: WireFormat::parse_unchecked(buf), + sqrta: WireFormat::parse_unchecked(buf), + omega0: WireFormat::parse_unchecked(buf), + omegadot: WireFormat::parse_unchecked(buf), + w: WireFormat::parse_unchecked(buf), + inc: WireFormat::parse_unchecked(buf), + inc_dot: WireFormat::parse_unchecked(buf), + af0: WireFormat::parse_unchecked(buf), + af1: WireFormat::parse_unchecked(buf), + af2: WireFormat::parse_unchecked(buf), + toc: WireFormat::parse_unchecked(buf), + iode: WireFormat::parse_unchecked(buf), + iodc: WireFormat::parse_unchecked(buf), } } } -impl crate::serialize::SbpSerialize for MsgEphemerisQzss { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.common.append_to_sbp_buffer(buf); - self.tgd.append_to_sbp_buffer(buf); - self.c_rs.append_to_sbp_buffer(buf); - self.c_rc.append_to_sbp_buffer(buf); - self.c_uc.append_to_sbp_buffer(buf); - self.c_us.append_to_sbp_buffer(buf); - self.c_ic.append_to_sbp_buffer(buf); - self.c_is.append_to_sbp_buffer(buf); - self.dn.append_to_sbp_buffer(buf); - self.m0.append_to_sbp_buffer(buf); - self.ecc.append_to_sbp_buffer(buf); - self.sqrta.append_to_sbp_buffer(buf); - self.omega0.append_to_sbp_buffer(buf); - self.omegadot.append_to_sbp_buffer(buf); - self.w.append_to_sbp_buffer(buf); - self.inc.append_to_sbp_buffer(buf); - self.inc_dot.append_to_sbp_buffer(buf); - self.af0.append_to_sbp_buffer(buf); - self.af1.append_to_sbp_buffer(buf); - self.af2.append_to_sbp_buffer(buf); - self.toc.append_to_sbp_buffer(buf); - self.iode.append_to_sbp_buffer(buf); - self.iodc.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.common.sbp_size(); - size += self.tgd.sbp_size(); - size += self.c_rs.sbp_size(); - size += self.c_rc.sbp_size(); - size += self.c_uc.sbp_size(); - size += self.c_us.sbp_size(); - size += self.c_ic.sbp_size(); - size += self.c_is.sbp_size(); - size += self.dn.sbp_size(); - size += self.m0.sbp_size(); - size += self.ecc.sbp_size(); - size += self.sqrta.sbp_size(); - size += self.omega0.sbp_size(); - size += self.omegadot.sbp_size(); - size += self.w.sbp_size(); - size += self.inc.sbp_size(); - size += self.inc_dot.sbp_size(); - size += self.af0.sbp_size(); - size += self.af1.sbp_size(); - size += self.af2.sbp_size(); - size += self.toc.sbp_size(); - size += self.iode.sbp_size(); - size += self.iodc.sbp_size(); - size - } -} - -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +/// Satellite broadcast ephemeris for SBAS +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgEphemerisSbas { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Values common for all ephemeris types + #[cfg_attr(feature = "serde", serde(rename(serialize = "common")))] pub common: EphemerisCommonContent, /// Position of the GEO at time toe - pub pos: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "pos")))] + pub pos: [f64; 3], /// Velocity of the GEO at time toe - pub vel: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "vel")))] + pub vel: [f32; 3], /// Acceleration of the GEO at time toe - pub acc: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "acc")))] + pub acc: [f32; 3], /// Time offset of the GEO clock w.r.t. SBAS Network Time + #[cfg_attr(feature = "serde", serde(rename(serialize = "a_gf0")))] pub a_gf0: f32, /// Drift of the GEO clock w.r.t. SBAS Network Time + #[cfg_attr(feature = "serde", serde(rename(serialize = "a_gf1")))] pub a_gf1: f32, } -impl MsgEphemerisSbas { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgEphemerisSbas{ - sender_id: None, - common: EphemerisCommonContent::parse(_buf)?, - pos: crate::parser::read_double_array_limit(_buf, 3)?, - vel: crate::parser::read_float_array_limit(_buf, 3)?, - acc: crate::parser::read_float_array_limit(_buf, 3)?, - a_gf0: _buf.read_f32::()?, - a_gf1: _buf.read_f32::()?, - } ) - } +impl ConcreteMessage for MsgEphemerisSbas { + const MESSAGE_TYPE: u16 = 140; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_SBAS"; } -impl super::SBPMessage for MsgEphemerisSbas { - fn get_message_name(&self) -> &'static str { - "MSG_EPHEMERIS_SBAS" - } - fn get_message_type(&self) -> u16 { - 140 +impl SbpMessage for MsgEphemerisSbas { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgEphemerisSbas { - const MESSAGE_TYPE: u16 = 140; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_SBAS"; } -impl TryFrom for MsgEphemerisSbas { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgEphemerisSbas { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgEphemerisSbas(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgEphemerisSbas(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgEphemerisSbas { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.common.append_to_sbp_buffer(buf); - self.pos.append_to_sbp_buffer(buf); - self.vel.append_to_sbp_buffer(buf); - self.acc.append_to_sbp_buffer(buf); - self.a_gf0.append_to_sbp_buffer(buf); - self.a_gf1.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.common.sbp_size(); - size += self.pos.sbp_size(); - size += self.vel.sbp_size(); - size += self.acc.sbp_size(); - size += self.a_gf0.sbp_size(); - size += self.a_gf1.sbp_size(); - size +impl WireFormat for MsgEphemerisSbas { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN + + <[f32; 3] as WireFormat>::MIN_ENCODED_LEN + + <[f32; 3] as WireFormat>::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.common) + + WireFormat::encoded_len(&self.pos) + + WireFormat::encoded_len(&self.vel) + + WireFormat::encoded_len(&self.acc) + + WireFormat::encoded_len(&self.a_gf0) + + WireFormat::encoded_len(&self.a_gf1) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.common, buf); + WireFormat::write(&self.pos, buf); + WireFormat::write(&self.vel, buf); + WireFormat::write(&self.acc, buf); + WireFormat::write(&self.a_gf0, buf); + WireFormat::write(&self.a_gf1, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgEphemerisSbas { + sender_id: None, + common: WireFormat::parse_unchecked(buf), + pos: WireFormat::parse_unchecked(buf), + vel: WireFormat::parse_unchecked(buf), + acc: WireFormat::parse_unchecked(buf), + a_gf0: WireFormat::parse_unchecked(buf), + a_gf1: WireFormat::parse_unchecked(buf), + } } } -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +/// Satellite broadcast ephemeris for SBAS +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgEphemerisSbasDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Values common for all ephemeris types + #[cfg_attr(feature = "serde", serde(rename(serialize = "common")))] pub common: EphemerisCommonContentDepA, /// Position of the GEO at time toe - pub pos: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "pos")))] + pub pos: [f64; 3], /// Velocity of the GEO at time toe - pub vel: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "vel")))] + pub vel: [f64; 3], /// Acceleration of the GEO at time toe - pub acc: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "acc")))] + pub acc: [f64; 3], /// Time offset of the GEO clock w.r.t. SBAS Network Time + #[cfg_attr(feature = "serde", serde(rename(serialize = "a_gf0")))] pub a_gf0: f64, /// Drift of the GEO clock w.r.t. SBAS Network Time + #[cfg_attr(feature = "serde", serde(rename(serialize = "a_gf1")))] pub a_gf1: f64, } -impl MsgEphemerisSbasDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgEphemerisSbasDepA{ - sender_id: None, - common: EphemerisCommonContentDepA::parse(_buf)?, - pos: crate::parser::read_double_array_limit(_buf, 3)?, - vel: crate::parser::read_double_array_limit(_buf, 3)?, - acc: crate::parser::read_double_array_limit(_buf, 3)?, - a_gf0: _buf.read_f64::()?, - a_gf1: _buf.read_f64::()?, - } ) - } +impl ConcreteMessage for MsgEphemerisSbasDepA { + const MESSAGE_TYPE: u16 = 130; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_SBAS_DEP_A"; } -impl super::SBPMessage for MsgEphemerisSbasDepA { - fn get_message_name(&self) -> &'static str { - "MSG_EPHEMERIS_SBAS_DEP_A" - } - fn get_message_type(&self) -> u16 { - 130 +impl SbpMessage for MsgEphemerisSbasDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgEphemerisSbasDepA { - const MESSAGE_TYPE: u16 = 130; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_SBAS_DEP_A"; -} -impl TryFrom for MsgEphemerisSbasDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgEphemerisSbasDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgEphemerisSbasDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgEphemerisSbasDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgEphemerisSbasDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.common.append_to_sbp_buffer(buf); - self.pos.append_to_sbp_buffer(buf); - self.vel.append_to_sbp_buffer(buf); - self.acc.append_to_sbp_buffer(buf); - self.a_gf0.append_to_sbp_buffer(buf); - self.a_gf1.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.common.sbp_size(); - size += self.pos.sbp_size(); - size += self.vel.sbp_size(); - size += self.acc.sbp_size(); - size += self.a_gf0.sbp_size(); - size += self.a_gf1.sbp_size(); - size +impl WireFormat for MsgEphemerisSbasDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.common) + + WireFormat::encoded_len(&self.pos) + + WireFormat::encoded_len(&self.vel) + + WireFormat::encoded_len(&self.acc) + + WireFormat::encoded_len(&self.a_gf0) + + WireFormat::encoded_len(&self.a_gf1) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.common, buf); + WireFormat::write(&self.pos, buf); + WireFormat::write(&self.vel, buf); + WireFormat::write(&self.acc, buf); + WireFormat::write(&self.a_gf0, buf); + WireFormat::write(&self.a_gf1, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgEphemerisSbasDepA { + sender_id: None, + common: WireFormat::parse_unchecked(buf), + pos: WireFormat::parse_unchecked(buf), + vel: WireFormat::parse_unchecked(buf), + acc: WireFormat::parse_unchecked(buf), + a_gf0: WireFormat::parse_unchecked(buf), + a_gf1: WireFormat::parse_unchecked(buf), + } } } @@ -4352,102 +4518,95 @@ impl crate::serialize::SbpSerialize for MsgEphemerisSbasDepA { /// This observation message has been deprecated in favor of ephemeris message /// using floats for size reduction. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgEphemerisSbasDepB { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Values common for all ephemeris types + #[cfg_attr(feature = "serde", serde(rename(serialize = "common")))] pub common: EphemerisCommonContentDepB, /// Position of the GEO at time toe - pub pos: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "pos")))] + pub pos: [f64; 3], /// Velocity of the GEO at time toe - pub vel: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "vel")))] + pub vel: [f64; 3], /// Acceleration of the GEO at time toe - pub acc: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "acc")))] + pub acc: [f64; 3], /// Time offset of the GEO clock w.r.t. SBAS Network Time + #[cfg_attr(feature = "serde", serde(rename(serialize = "a_gf0")))] pub a_gf0: f64, /// Drift of the GEO clock w.r.t. SBAS Network Time + #[cfg_attr(feature = "serde", serde(rename(serialize = "a_gf1")))] pub a_gf1: f64, } -impl MsgEphemerisSbasDepB { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgEphemerisSbasDepB{ - sender_id: None, - common: EphemerisCommonContentDepB::parse(_buf)?, - pos: crate::parser::read_double_array_limit(_buf, 3)?, - vel: crate::parser::read_double_array_limit(_buf, 3)?, - acc: crate::parser::read_double_array_limit(_buf, 3)?, - a_gf0: _buf.read_f64::()?, - a_gf1: _buf.read_f64::()?, - } ) - } +impl ConcreteMessage for MsgEphemerisSbasDepB { + const MESSAGE_TYPE: u16 = 132; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_SBAS_DEP_B"; } -impl super::SBPMessage for MsgEphemerisSbasDepB { - fn get_message_name(&self) -> &'static str { - "MSG_EPHEMERIS_SBAS_DEP_B" - } - fn get_message_type(&self) -> u16 { - 132 +impl SbpMessage for MsgEphemerisSbasDepB { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } +} - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgEphemerisSbasDepB { - const MESSAGE_TYPE: u16 = 132; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_SBAS_DEP_B"; -} -impl TryFrom for MsgEphemerisSbasDepB { - type Error = super::TryFromSBPError; - - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgEphemerisSbasDepB { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgEphemerisSbasDepB(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgEphemerisSbasDepB(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgEphemerisSbasDepB { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.common.append_to_sbp_buffer(buf); - self.pos.append_to_sbp_buffer(buf); - self.vel.append_to_sbp_buffer(buf); - self.acc.append_to_sbp_buffer(buf); - self.a_gf0.append_to_sbp_buffer(buf); - self.a_gf1.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.common.sbp_size(); - size += self.pos.sbp_size(); - size += self.vel.sbp_size(); - size += self.acc.sbp_size(); - size += self.a_gf0.sbp_size(); - size += self.a_gf1.sbp_size(); - size +impl WireFormat for MsgEphemerisSbasDepB { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN + + <[f64; 3] as WireFormat>::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.common) + + WireFormat::encoded_len(&self.pos) + + WireFormat::encoded_len(&self.vel) + + WireFormat::encoded_len(&self.acc) + + WireFormat::encoded_len(&self.a_gf0) + + WireFormat::encoded_len(&self.a_gf1) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.common, buf); + WireFormat::write(&self.pos, buf); + WireFormat::write(&self.vel, buf); + WireFormat::write(&self.acc, buf); + WireFormat::write(&self.a_gf0, buf); + WireFormat::write(&self.a_gf1, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgEphemerisSbasDepB { + sender_id: None, + common: WireFormat::parse_unchecked(buf), + pos: WireFormat::parse_unchecked(buf), + vel: WireFormat::parse_unchecked(buf), + acc: WireFormat::parse_unchecked(buf), + a_gf0: WireFormat::parse_unchecked(buf), + a_gf1: WireFormat::parse_unchecked(buf), + } } } @@ -4457,176 +4616,152 @@ impl crate::serialize::SbpSerialize for MsgEphemerisSbasDepB { /// ambiguity resolution for baselines with mixed receiver types (e.g. /// receiver of different manufacturers). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgGloBiases { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GLONASS FDMA signals mask + #[cfg_attr(feature = "serde", serde(rename(serialize = "mask")))] pub mask: u8, /// GLONASS L1 C/A Code-Phase Bias + #[cfg_attr(feature = "serde", serde(rename(serialize = "l1ca_bias")))] pub l1ca_bias: i16, /// GLONASS L1 P Code-Phase Bias + #[cfg_attr(feature = "serde", serde(rename(serialize = "l1p_bias")))] pub l1p_bias: i16, /// GLONASS L2 C/A Code-Phase Bias + #[cfg_attr(feature = "serde", serde(rename(serialize = "l2ca_bias")))] pub l2ca_bias: i16, /// GLONASS L2 P Code-Phase Bias + #[cfg_attr(feature = "serde", serde(rename(serialize = "l2p_bias")))] pub l2p_bias: i16, } -impl MsgGloBiases { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgGloBiases{ - sender_id: None, - mask: _buf.read_u8()?, - l1ca_bias: _buf.read_i16::()?, - l1p_bias: _buf.read_i16::()?, - l2ca_bias: _buf.read_i16::()?, - l2p_bias: _buf.read_i16::()?, - } ) - } +impl ConcreteMessage for MsgGloBiases { + const MESSAGE_TYPE: u16 = 117; + const MESSAGE_NAME: &'static str = "MSG_GLO_BIASES"; } -impl super::SBPMessage for MsgGloBiases { - fn get_message_name(&self) -> &'static str { - "MSG_GLO_BIASES" - } - fn get_message_type(&self) -> u16 { - 117 +impl SbpMessage for MsgGloBiases { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgGloBiases { - const MESSAGE_TYPE: u16 = 117; - const MESSAGE_NAME: &'static str = "MSG_GLO_BIASES"; } -impl TryFrom for MsgGloBiases { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgGloBiases { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgGloBiases(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgGloBiases(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgGloBiases { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.mask.append_to_sbp_buffer(buf); - self.l1ca_bias.append_to_sbp_buffer(buf); - self.l1p_bias.append_to_sbp_buffer(buf); - self.l2ca_bias.append_to_sbp_buffer(buf); - self.l2p_bias.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.mask.sbp_size(); - size += self.l1ca_bias.sbp_size(); - size += self.l1p_bias.sbp_size(); - size += self.l2ca_bias.sbp_size(); - size += self.l2p_bias.sbp_size(); - size +impl WireFormat for MsgGloBiases { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.mask) + + WireFormat::encoded_len(&self.l1ca_bias) + + WireFormat::encoded_len(&self.l1p_bias) + + WireFormat::encoded_len(&self.l2ca_bias) + + WireFormat::encoded_len(&self.l2p_bias) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.mask, buf); + WireFormat::write(&self.l1ca_bias, buf); + WireFormat::write(&self.l1p_bias, buf); + WireFormat::write(&self.l2ca_bias, buf); + WireFormat::write(&self.l2p_bias, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgGloBiases { + sender_id: None, + mask: WireFormat::parse_unchecked(buf), + l1ca_bias: WireFormat::parse_unchecked(buf), + l1p_bias: WireFormat::parse_unchecked(buf), + l2ca_bias: WireFormat::parse_unchecked(buf), + l2p_bias: WireFormat::parse_unchecked(buf), + } } } -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +/// GNSS capabilities +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgGnssCapb { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Navigation Message Correction Table Validity Time - pub t_nmct: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "t_nmct")))] + pub t_nmct: GpsTimeSec, /// GNSS capabilities masks + #[cfg_attr(feature = "serde", serde(rename(serialize = "gc")))] pub gc: GnssCapb, } -impl MsgGnssCapb { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgGnssCapb{ - sender_id: None, - t_nmct: GPSTimeSec::parse(_buf)?, - gc: GnssCapb::parse(_buf)?, - } ) - } +impl ConcreteMessage for MsgGnssCapb { + const MESSAGE_TYPE: u16 = 150; + const MESSAGE_NAME: &'static str = "MSG_GNSS_CAPB"; } -impl super::SBPMessage for MsgGnssCapb { - fn get_message_name(&self) -> &'static str { - "MSG_GNSS_CAPB" - } - fn get_message_type(&self) -> u16 { - 150 +impl SbpMessage for MsgGnssCapb { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgGnssCapb { - const MESSAGE_TYPE: u16 = 150; - const MESSAGE_NAME: &'static str = "MSG_GNSS_CAPB"; } -impl TryFrom for MsgGnssCapb { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgGnssCapb { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgGnssCapb(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgGnssCapb(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgGnssCapb { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.t_nmct.append_to_sbp_buffer(buf); - self.gc.append_to_sbp_buffer(buf); +impl WireFormat for MsgGnssCapb { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.t_nmct) + WireFormat::encoded_len(&self.gc) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.t_nmct.sbp_size(); - size += self.gc.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.t_nmct, buf); + WireFormat::write(&self.gc, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgGnssCapb { + sender_id: None, + t_nmct: WireFormat::parse_unchecked(buf), + gc: WireFormat::parse_unchecked(buf), + } } } @@ -4634,100 +4769,93 @@ impl crate::serialize::SbpSerialize for MsgGnssCapb { /// /// Please see ICD-GPS-200 (30.3.3.3.1.1) for more details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgGroupDelay { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Data Predict Time of Week - pub t_op: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "t_op")))] + pub t_op: GpsTimeSec, /// GNSS signal identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, /// bit-field indicating validity of the values, LSB indicating tgd validity /// etc. 1 = value is valid, 0 = value is not valid. + #[cfg_attr(feature = "serde", serde(rename(serialize = "valid")))] pub valid: u8, + #[cfg_attr(feature = "serde", serde(rename(serialize = "tgd")))] pub tgd: i16, + #[cfg_attr(feature = "serde", serde(rename(serialize = "isc_l1ca")))] pub isc_l1ca: i16, + #[cfg_attr(feature = "serde", serde(rename(serialize = "isc_l2c")))] pub isc_l2c: i16, } -impl MsgGroupDelay { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgGroupDelay{ - sender_id: None, - t_op: GPSTimeSec::parse(_buf)?, - sid: GnssSignal::parse(_buf)?, - valid: _buf.read_u8()?, - tgd: _buf.read_i16::()?, - isc_l1ca: _buf.read_i16::()?, - isc_l2c: _buf.read_i16::()?, - } ) - } +impl ConcreteMessage for MsgGroupDelay { + const MESSAGE_TYPE: u16 = 148; + const MESSAGE_NAME: &'static str = "MSG_GROUP_DELAY"; } -impl super::SBPMessage for MsgGroupDelay { - fn get_message_name(&self) -> &'static str { - "MSG_GROUP_DELAY" - } - fn get_message_type(&self) -> u16 { - 148 +impl SbpMessage for MsgGroupDelay { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgGroupDelay { - const MESSAGE_TYPE: u16 = 148; - const MESSAGE_NAME: &'static str = "MSG_GROUP_DELAY"; -} -impl TryFrom for MsgGroupDelay { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgGroupDelay { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgGroupDelay(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgGroupDelay(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgGroupDelay { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.t_op.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - self.valid.append_to_sbp_buffer(buf); - self.tgd.append_to_sbp_buffer(buf); - self.isc_l1ca.append_to_sbp_buffer(buf); - self.isc_l2c.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.t_op.sbp_size(); - size += self.sid.sbp_size(); - size += self.valid.sbp_size(); - size += self.tgd.sbp_size(); - size += self.isc_l1ca.sbp_size(); - size += self.isc_l2c.sbp_size(); - size +impl WireFormat for MsgGroupDelay { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.t_op) + + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.valid) + + WireFormat::encoded_len(&self.tgd) + + WireFormat::encoded_len(&self.isc_l1ca) + + WireFormat::encoded_len(&self.isc_l2c) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.t_op, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.valid, buf); + WireFormat::write(&self.tgd, buf); + WireFormat::write(&self.isc_l1ca, buf); + WireFormat::write(&self.isc_l2c, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgGroupDelay { + sender_id: None, + t_op: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + valid: WireFormat::parse_unchecked(buf), + tgd: WireFormat::parse_unchecked(buf), + isc_l1ca: WireFormat::parse_unchecked(buf), + isc_l2c: WireFormat::parse_unchecked(buf), + } } } @@ -4735,100 +4863,93 @@ impl crate::serialize::SbpSerialize for MsgGroupDelay { /// /// Please see ICD-GPS-200 (30.3.3.3.1.1) for more details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgGroupDelayDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Data Predict Time of Week - pub t_op: GPSTimeDep, + #[cfg_attr(feature = "serde", serde(rename(serialize = "t_op")))] + pub t_op: GpsTimeDep, /// Satellite number + #[cfg_attr(feature = "serde", serde(rename(serialize = "prn")))] pub prn: u8, /// bit-field indicating validity of the values, LSB indicating tgd validity /// etc. 1 = value is valid, 0 = value is not valid. + #[cfg_attr(feature = "serde", serde(rename(serialize = "valid")))] pub valid: u8, + #[cfg_attr(feature = "serde", serde(rename(serialize = "tgd")))] pub tgd: i16, + #[cfg_attr(feature = "serde", serde(rename(serialize = "isc_l1ca")))] pub isc_l1ca: i16, + #[cfg_attr(feature = "serde", serde(rename(serialize = "isc_l2c")))] pub isc_l2c: i16, } -impl MsgGroupDelayDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgGroupDelayDepA{ - sender_id: None, - t_op: GPSTimeDep::parse(_buf)?, - prn: _buf.read_u8()?, - valid: _buf.read_u8()?, - tgd: _buf.read_i16::()?, - isc_l1ca: _buf.read_i16::()?, - isc_l2c: _buf.read_i16::()?, - } ) - } +impl ConcreteMessage for MsgGroupDelayDepA { + const MESSAGE_TYPE: u16 = 146; + const MESSAGE_NAME: &'static str = "MSG_GROUP_DELAY_DEP_A"; } -impl super::SBPMessage for MsgGroupDelayDepA { - fn get_message_name(&self) -> &'static str { - "MSG_GROUP_DELAY_DEP_A" - } - fn get_message_type(&self) -> u16 { - 146 +impl SbpMessage for MsgGroupDelayDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgGroupDelayDepA { - const MESSAGE_TYPE: u16 = 146; - const MESSAGE_NAME: &'static str = "MSG_GROUP_DELAY_DEP_A"; } -impl TryFrom for MsgGroupDelayDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgGroupDelayDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgGroupDelayDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgGroupDelayDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgGroupDelayDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.t_op.append_to_sbp_buffer(buf); - self.prn.append_to_sbp_buffer(buf); - self.valid.append_to_sbp_buffer(buf); - self.tgd.append_to_sbp_buffer(buf); - self.isc_l1ca.append_to_sbp_buffer(buf); - self.isc_l2c.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.t_op.sbp_size(); - size += self.prn.sbp_size(); - size += self.valid.sbp_size(); - size += self.tgd.sbp_size(); - size += self.isc_l1ca.sbp_size(); - size += self.isc_l2c.sbp_size(); - size +impl WireFormat for MsgGroupDelayDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.t_op) + + WireFormat::encoded_len(&self.prn) + + WireFormat::encoded_len(&self.valid) + + WireFormat::encoded_len(&self.tgd) + + WireFormat::encoded_len(&self.isc_l1ca) + + WireFormat::encoded_len(&self.isc_l2c) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.t_op, buf); + WireFormat::write(&self.prn, buf); + WireFormat::write(&self.valid, buf); + WireFormat::write(&self.tgd, buf); + WireFormat::write(&self.isc_l1ca, buf); + WireFormat::write(&self.isc_l2c, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgGroupDelayDepA { + sender_id: None, + t_op: WireFormat::parse_unchecked(buf), + prn: WireFormat::parse_unchecked(buf), + valid: WireFormat::parse_unchecked(buf), + tgd: WireFormat::parse_unchecked(buf), + isc_l1ca: WireFormat::parse_unchecked(buf), + isc_l2c: WireFormat::parse_unchecked(buf), + } } } @@ -4836,100 +4957,93 @@ impl crate::serialize::SbpSerialize for MsgGroupDelayDepA { /// /// Please see ICD-GPS-200 (30.3.3.3.1.1) for more details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgGroupDelayDepB { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Data Predict Time of Week - pub t_op: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "t_op")))] + pub t_op: GpsTimeSec, /// GNSS signal identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignalDep, /// bit-field indicating validity of the values, LSB indicating tgd validity /// etc. 1 = value is valid, 0 = value is not valid. + #[cfg_attr(feature = "serde", serde(rename(serialize = "valid")))] pub valid: u8, + #[cfg_attr(feature = "serde", serde(rename(serialize = "tgd")))] pub tgd: i16, + #[cfg_attr(feature = "serde", serde(rename(serialize = "isc_l1ca")))] pub isc_l1ca: i16, + #[cfg_attr(feature = "serde", serde(rename(serialize = "isc_l2c")))] pub isc_l2c: i16, } -impl MsgGroupDelayDepB { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgGroupDelayDepB{ - sender_id: None, - t_op: GPSTimeSec::parse(_buf)?, - sid: GnssSignalDep::parse(_buf)?, - valid: _buf.read_u8()?, - tgd: _buf.read_i16::()?, - isc_l1ca: _buf.read_i16::()?, - isc_l2c: _buf.read_i16::()?, - } ) - } +impl ConcreteMessage for MsgGroupDelayDepB { + const MESSAGE_TYPE: u16 = 147; + const MESSAGE_NAME: &'static str = "MSG_GROUP_DELAY_DEP_B"; } -impl super::SBPMessage for MsgGroupDelayDepB { - fn get_message_name(&self) -> &'static str { - "MSG_GROUP_DELAY_DEP_B" - } - fn get_message_type(&self) -> u16 { - 147 +impl SbpMessage for MsgGroupDelayDepB { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgGroupDelayDepB { - const MESSAGE_TYPE: u16 = 147; - const MESSAGE_NAME: &'static str = "MSG_GROUP_DELAY_DEP_B"; } -impl TryFrom for MsgGroupDelayDepB { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgGroupDelayDepB { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgGroupDelayDepB(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgGroupDelayDepB(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgGroupDelayDepB { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.t_op.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - self.valid.append_to_sbp_buffer(buf); - self.tgd.append_to_sbp_buffer(buf); - self.isc_l1ca.append_to_sbp_buffer(buf); - self.isc_l2c.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.t_op.sbp_size(); - size += self.sid.sbp_size(); - size += self.valid.sbp_size(); - size += self.tgd.sbp_size(); - size += self.isc_l1ca.sbp_size(); - size += self.isc_l2c.sbp_size(); - size +impl WireFormat for MsgGroupDelayDepB { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.t_op) + + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.valid) + + WireFormat::encoded_len(&self.tgd) + + WireFormat::encoded_len(&self.isc_l1ca) + + WireFormat::encoded_len(&self.isc_l2c) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.t_op, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.valid, buf); + WireFormat::write(&self.tgd, buf); + WireFormat::write(&self.isc_l1ca, buf); + WireFormat::write(&self.isc_l2c, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgGroupDelayDepB { + sender_id: None, + t_op: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + valid: WireFormat::parse_unchecked(buf), + tgd: WireFormat::parse_unchecked(buf), + isc_l1ca: WireFormat::parse_unchecked(buf), + isc_l2c: WireFormat::parse_unchecked(buf), + } } } @@ -4939,109 +5053,108 @@ impl crate::serialize::SbpSerialize for MsgGroupDelayDepB { /// utilize the ionospheric model for computation of the ionospheric delay. /// Please see ICD-GPS-200 (Chapter 20.3.3.5.1.7) for more details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgIono { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Navigation Message Correction Table Validity Time - pub t_nmct: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "t_nmct")))] + pub t_nmct: GpsTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "a0")))] pub a0: f64, + #[cfg_attr(feature = "serde", serde(rename(serialize = "a1")))] pub a1: f64, + #[cfg_attr(feature = "serde", serde(rename(serialize = "a2")))] pub a2: f64, + #[cfg_attr(feature = "serde", serde(rename(serialize = "a3")))] pub a3: f64, + #[cfg_attr(feature = "serde", serde(rename(serialize = "b0")))] pub b0: f64, + #[cfg_attr(feature = "serde", serde(rename(serialize = "b1")))] pub b1: f64, + #[cfg_attr(feature = "serde", serde(rename(serialize = "b2")))] pub b2: f64, + #[cfg_attr(feature = "serde", serde(rename(serialize = "b3")))] pub b3: f64, } -impl MsgIono { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgIono{ - sender_id: None, - t_nmct: GPSTimeSec::parse(_buf)?, - a0: _buf.read_f64::()?, - a1: _buf.read_f64::()?, - a2: _buf.read_f64::()?, - a3: _buf.read_f64::()?, - b0: _buf.read_f64::()?, - b1: _buf.read_f64::()?, - b2: _buf.read_f64::()?, - b3: _buf.read_f64::()?, - } ) - } +impl ConcreteMessage for MsgIono { + const MESSAGE_TYPE: u16 = 144; + const MESSAGE_NAME: &'static str = "MSG_IONO"; } -impl super::SBPMessage for MsgIono { - fn get_message_name(&self) -> &'static str { - "MSG_IONO" - } - fn get_message_type(&self) -> u16 { - 144 +impl SbpMessage for MsgIono { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgIono { - const MESSAGE_TYPE: u16 = 144; - const MESSAGE_NAME: &'static str = "MSG_IONO"; -} -impl TryFrom for MsgIono { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgIono { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgIono(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgIono(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgIono { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.t_nmct.append_to_sbp_buffer(buf); - self.a0.append_to_sbp_buffer(buf); - self.a1.append_to_sbp_buffer(buf); - self.a2.append_to_sbp_buffer(buf); - self.a3.append_to_sbp_buffer(buf); - self.b0.append_to_sbp_buffer(buf); - self.b1.append_to_sbp_buffer(buf); - self.b2.append_to_sbp_buffer(buf); - self.b3.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.t_nmct.sbp_size(); - size += self.a0.sbp_size(); - size += self.a1.sbp_size(); - size += self.a2.sbp_size(); - size += self.a3.sbp_size(); - size += self.b0.sbp_size(); - size += self.b1.sbp_size(); - size += self.b2.sbp_size(); - size += self.b3.sbp_size(); - size +impl WireFormat for MsgIono { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.t_nmct) + + WireFormat::encoded_len(&self.a0) + + WireFormat::encoded_len(&self.a1) + + WireFormat::encoded_len(&self.a2) + + WireFormat::encoded_len(&self.a3) + + WireFormat::encoded_len(&self.b0) + + WireFormat::encoded_len(&self.b1) + + WireFormat::encoded_len(&self.b2) + + WireFormat::encoded_len(&self.b3) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.t_nmct, buf); + WireFormat::write(&self.a0, buf); + WireFormat::write(&self.a1, buf); + WireFormat::write(&self.a2, buf); + WireFormat::write(&self.a3, buf); + WireFormat::write(&self.b0, buf); + WireFormat::write(&self.b1, buf); + WireFormat::write(&self.b2, buf); + WireFormat::write(&self.b3, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgIono { + sender_id: None, + t_nmct: WireFormat::parse_unchecked(buf), + a0: WireFormat::parse_unchecked(buf), + a1: WireFormat::parse_unchecked(buf), + a2: WireFormat::parse_unchecked(buf), + a3: WireFormat::parse_unchecked(buf), + b0: WireFormat::parse_unchecked(buf), + b1: WireFormat::parse_unchecked(buf), + b2: WireFormat::parse_unchecked(buf), + b3: WireFormat::parse_unchecked(buf), + } } } @@ -5054,98 +5167,79 @@ impl crate::serialize::SbpSerialize for MsgIono { /// cycles). The observations are be interoperable with 3rd party receivers /// and conform with typical RTCMv3 GNSS observations. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgObs { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Header of a GPS observation message + #[cfg_attr(feature = "serde", serde(rename(serialize = "header")))] pub header: ObservationHeader, /// Pseudorange and carrier phase observation for a satellite being tracked. + #[cfg_attr(feature = "serde", serde(rename(serialize = "obs")))] pub obs: Vec, } -impl MsgObs { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgObs{ - sender_id: None, - header: ObservationHeader::parse(_buf)?, - obs: PackedObsContent::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgObs { + const MESSAGE_TYPE: u16 = 74; + const MESSAGE_NAME: &'static str = "MSG_OBS"; } -impl super::SBPMessage for MsgObs { - fn get_message_name(&self) -> &'static str { - "MSG_OBS" - } - fn get_message_type(&self) -> u16 { - 74 +impl SbpMessage for MsgObs { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.header.t.tow as f64) / 1000.0; - let wn = match i16::try_from(self.header.t.wn) { + let wn: i16 = match self.header.t.wn.try_into() { Ok(wn) => wn, Err(e) => return Some(Err(e.into())), }; - let gps_time = match crate::time::GpsTime::new(wn, tow_s) { + let gps_time = match time::GpsTime::new(wn, tow_s) { Ok(gps_time) => gps_time, Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Base(gps_time.into()))) + Some(Ok(time::MessageTime::Base(gps_time.into()))) } } -impl super::ConcreteMessage for MsgObs { - const MESSAGE_TYPE: u16 = 74; - const MESSAGE_NAME: &'static str = "MSG_OBS"; -} -impl TryFrom for MsgObs { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgObs { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgObs(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgObs(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgObs { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.header.append_to_sbp_buffer(buf); - self.obs.append_to_sbp_buffer(buf); +impl WireFormat for MsgObs { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.header) + WireFormat::encoded_len(&self.obs) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.header.sbp_size(); - size += self.obs.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.header, buf); + WireFormat::write(&self.obs, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgObs { + sender_id: None, + header: WireFormat::parse_unchecked(buf), + obs: WireFormat::parse_unchecked(buf), + } } } @@ -5153,98 +5247,79 @@ impl crate::serialize::SbpSerialize for MsgObs { /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgObsDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Header of a GPS observation message + #[cfg_attr(feature = "serde", serde(rename(serialize = "header")))] pub header: ObservationHeaderDep, /// Pseudorange and carrier phase observation for a satellite being tracked. + #[cfg_attr(feature = "serde", serde(rename(serialize = "obs")))] pub obs: Vec, } -impl MsgObsDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgObsDepA{ - sender_id: None, - header: ObservationHeaderDep::parse(_buf)?, - obs: PackedObsContentDepA::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgObsDepA { + const MESSAGE_TYPE: u16 = 69; + const MESSAGE_NAME: &'static str = "MSG_OBS_DEP_A"; } -impl super::SBPMessage for MsgObsDepA { - fn get_message_name(&self) -> &'static str { - "MSG_OBS_DEP_A" - } - fn get_message_type(&self) -> u16 { - 69 +impl SbpMessage for MsgObsDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.header.t.tow as f64) / 1000.0; - let wn = match i16::try_from(self.header.t.wn) { + let wn: i16 = match self.header.t.wn.try_into() { Ok(wn) => wn, Err(e) => return Some(Err(e.into())), }; - let gps_time = match crate::time::GpsTime::new(wn, tow_s) { + let gps_time = match time::GpsTime::new(wn, tow_s) { Ok(gps_time) => gps_time, Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgObsDepA { - const MESSAGE_TYPE: u16 = 69; - const MESSAGE_NAME: &'static str = "MSG_OBS_DEP_A"; -} -impl TryFrom for MsgObsDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgObsDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgObsDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgObsDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgObsDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.header.append_to_sbp_buffer(buf); - self.obs.append_to_sbp_buffer(buf); +impl WireFormat for MsgObsDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.header) + WireFormat::encoded_len(&self.obs) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.header.sbp_size(); - size += self.obs.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.header, buf); + WireFormat::write(&self.obs, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgObsDepA { + sender_id: None, + header: WireFormat::parse_unchecked(buf), + obs: WireFormat::parse_unchecked(buf), + } } } @@ -5255,98 +5330,79 @@ impl crate::serialize::SbpSerialize for MsgObsDepA { /// referenced to a nominal pseudorange which are not interoperable with most /// 3rd party GNSS receivers or typical RTCMv3 observations. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgObsDepB { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Header of a GPS observation message + #[cfg_attr(feature = "serde", serde(rename(serialize = "header")))] pub header: ObservationHeaderDep, /// Pseudorange and carrier phase observation for a satellite being tracked. + #[cfg_attr(feature = "serde", serde(rename(serialize = "obs")))] pub obs: Vec, } -impl MsgObsDepB { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgObsDepB{ - sender_id: None, - header: ObservationHeaderDep::parse(_buf)?, - obs: PackedObsContentDepB::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgObsDepB { + const MESSAGE_TYPE: u16 = 67; + const MESSAGE_NAME: &'static str = "MSG_OBS_DEP_B"; } -impl super::SBPMessage for MsgObsDepB { - fn get_message_name(&self) -> &'static str { - "MSG_OBS_DEP_B" - } - fn get_message_type(&self) -> u16 { - 67 +impl SbpMessage for MsgObsDepB { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.header.t.tow as f64) / 1000.0; - let wn = match i16::try_from(self.header.t.wn) { + let wn: i16 = match self.header.t.wn.try_into() { Ok(wn) => wn, Err(e) => return Some(Err(e.into())), }; - let gps_time = match crate::time::GpsTime::new(wn, tow_s) { + let gps_time = match time::GpsTime::new(wn, tow_s) { Ok(gps_time) => gps_time, Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgObsDepB { - const MESSAGE_TYPE: u16 = 67; - const MESSAGE_NAME: &'static str = "MSG_OBS_DEP_B"; -} -impl TryFrom for MsgObsDepB { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgObsDepB { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgObsDepB(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgObsDepB(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgObsDepB { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.header.append_to_sbp_buffer(buf); - self.obs.append_to_sbp_buffer(buf); +impl WireFormat for MsgObsDepB { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.header) + WireFormat::encoded_len(&self.obs) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.header.sbp_size(); - size += self.obs.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.header, buf); + WireFormat::write(&self.obs, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgObsDepB { + sender_id: None, + header: WireFormat::parse_unchecked(buf), + obs: WireFormat::parse_unchecked(buf), + } } } @@ -5359,98 +5415,79 @@ impl crate::serialize::SbpSerialize for MsgObsDepB { /// cycles). The observations are interoperable with 3rd party receivers and /// conform with typical RTCMv3 GNSS observations. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgObsDepC { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Header of a GPS observation message + #[cfg_attr(feature = "serde", serde(rename(serialize = "header")))] pub header: ObservationHeaderDep, /// Pseudorange and carrier phase observation for a satellite being tracked. + #[cfg_attr(feature = "serde", serde(rename(serialize = "obs")))] pub obs: Vec, } -impl MsgObsDepC { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgObsDepC{ - sender_id: None, - header: ObservationHeaderDep::parse(_buf)?, - obs: PackedObsContentDepC::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgObsDepC { + const MESSAGE_TYPE: u16 = 73; + const MESSAGE_NAME: &'static str = "MSG_OBS_DEP_C"; } -impl super::SBPMessage for MsgObsDepC { - fn get_message_name(&self) -> &'static str { - "MSG_OBS_DEP_C" - } - fn get_message_type(&self) -> u16 { - 73 +impl SbpMessage for MsgObsDepC { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.header.t.tow as f64) / 1000.0; - let wn = match i16::try_from(self.header.t.wn) { + let wn: i16 = match self.header.t.wn.try_into() { Ok(wn) => wn, Err(e) => return Some(Err(e.into())), }; - let gps_time = match crate::time::GpsTime::new(wn, tow_s) { + let gps_time = match time::GpsTime::new(wn, tow_s) { Ok(gps_time) => gps_time, Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgObsDepC { - const MESSAGE_TYPE: u16 = 73; - const MESSAGE_NAME: &'static str = "MSG_OBS_DEP_C"; -} -impl TryFrom for MsgObsDepC { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgObsDepC { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgObsDepC(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgObsDepC(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgObsDepC { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.header.append_to_sbp_buffer(buf); - self.obs.append_to_sbp_buffer(buf); +impl WireFormat for MsgObsDepC { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.header) + WireFormat::encoded_len(&self.obs) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.header.sbp_size(); - size += self.obs.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.header, buf); + WireFormat::write(&self.obs, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgObsDepC { + sender_id: None, + header: WireFormat::parse_unchecked(buf), + obs: WireFormat::parse_unchecked(buf), + } } } @@ -5459,98 +5496,79 @@ impl crate::serialize::SbpSerialize for MsgObsDepC { /// The OSR message contains network corrections in an observation-like /// format. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgOsr { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Header of a GPS observation message + #[cfg_attr(feature = "serde", serde(rename(serialize = "header")))] pub header: ObservationHeader, /// Network correction for a satellite signal. + #[cfg_attr(feature = "serde", serde(rename(serialize = "obs")))] pub obs: Vec, } -impl MsgOsr { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgOsr{ - sender_id: None, - header: ObservationHeader::parse(_buf)?, - obs: PackedOsrContent::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgOsr { + const MESSAGE_TYPE: u16 = 1600; + const MESSAGE_NAME: &'static str = "MSG_OSR"; } -impl super::SBPMessage for MsgOsr { - fn get_message_name(&self) -> &'static str { - "MSG_OSR" - } - fn get_message_type(&self) -> u16 { - 1600 +impl SbpMessage for MsgOsr { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.header.t.tow as f64) / 1000.0; - let wn = match i16::try_from(self.header.t.wn) { + let wn: i16 = match self.header.t.wn.try_into() { Ok(wn) => wn, Err(e) => return Some(Err(e.into())), }; - let gps_time = match crate::time::GpsTime::new(wn, tow_s) { + let gps_time = match time::GpsTime::new(wn, tow_s) { Ok(gps_time) => gps_time, Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Base(gps_time.into()))) + Some(Ok(time::MessageTime::Base(gps_time.into()))) } } -impl super::ConcreteMessage for MsgOsr { - const MESSAGE_TYPE: u16 = 1600; - const MESSAGE_NAME: &'static str = "MSG_OSR"; -} -impl TryFrom for MsgOsr { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgOsr { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgOsr(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgOsr(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgOsr { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.header.append_to_sbp_buffer(buf); - self.obs.append_to_sbp_buffer(buf); +impl WireFormat for MsgOsr { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.header) + WireFormat::encoded_len(&self.obs) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.header.sbp_size(); - size += self.obs.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.header, buf); + WireFormat::write(&self.obs, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgOsr { + sender_id: None, + header: WireFormat::parse_unchecked(buf), + obs: WireFormat::parse_unchecked(buf), + } } } @@ -5559,77 +5577,60 @@ impl crate::serialize::SbpSerialize for MsgOsr { /// Azimuth and elevation angles of all the visible satellites that the device /// does have ephemeris or almanac for. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSvAzEl { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Azimuth and elevation per satellite + #[cfg_attr(feature = "serde", serde(rename(serialize = "azel")))] pub azel: Vec, } -impl MsgSvAzEl { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSvAzEl{ - sender_id: None, - azel: SvAzEl::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgSvAzEl { + const MESSAGE_TYPE: u16 = 151; + const MESSAGE_NAME: &'static str = "MSG_SV_AZ_EL"; } -impl super::SBPMessage for MsgSvAzEl { - fn get_message_name(&self) -> &'static str { - "MSG_SV_AZ_EL" - } - fn get_message_type(&self) -> u16 { - 151 +impl SbpMessage for MsgSvAzEl { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgSvAzEl { - const MESSAGE_TYPE: u16 = 151; - const MESSAGE_NAME: &'static str = "MSG_SV_AZ_EL"; } -impl TryFrom for MsgSvAzEl { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSvAzEl { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSvAzEl(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSvAzEl(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSvAzEl { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.azel.append_to_sbp_buffer(buf); +impl WireFormat for MsgSvAzEl { + const MIN_ENCODED_LEN: usize = as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.azel) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.azel.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.azel, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSvAzEl { + sender_id: None, + azel: WireFormat::parse_unchecked(buf), + } } } @@ -5637,82 +5638,66 @@ impl crate::serialize::SbpSerialize for MsgSvAzEl { /// /// Please see ICD-GPS-200 (Chapter 20.3.3.5.1.4) for more details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct MsgSvConfigurationGPSDep { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] +pub struct MsgSvConfigurationGpsDep { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Navigation Message Correction Table Validity Time - pub t_nmct: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "t_nmct")))] + pub t_nmct: GpsTimeSec, /// L2C capability mask, SV32 bit being MSB, SV1 bit being LSB + #[cfg_attr(feature = "serde", serde(rename(serialize = "l2c_mask")))] pub l2c_mask: u32, } -impl MsgSvConfigurationGPSDep { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSvConfigurationGPSDep{ - sender_id: None, - t_nmct: GPSTimeSec::parse(_buf)?, - l2c_mask: _buf.read_u32::()?, - } ) - } +impl ConcreteMessage for MsgSvConfigurationGpsDep { + const MESSAGE_TYPE: u16 = 145; + const MESSAGE_NAME: &'static str = "MSG_SV_CONFIGURATION_GPS_DEP"; } -impl super::SBPMessage for MsgSvConfigurationGPSDep { - fn get_message_name(&self) -> &'static str { - "MSG_SV_CONFIGURATION_GPS_DEP" - } - fn get_message_type(&self) -> u16 { - 145 +impl SbpMessage for MsgSvConfigurationGpsDep { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgSvConfigurationGPSDep { - const MESSAGE_TYPE: u16 = 145; - const MESSAGE_NAME: &'static str = "MSG_SV_CONFIGURATION_GPS_DEP"; -} -impl TryFrom for MsgSvConfigurationGPSDep { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSvConfigurationGpsDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSvConfigurationGPSDep(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSvConfigurationGpsDep(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSvConfigurationGPSDep { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.t_nmct.append_to_sbp_buffer(buf); - self.l2c_mask.append_to_sbp_buffer(buf); +impl WireFormat for MsgSvConfigurationGpsDep { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.t_nmct) + WireFormat::encoded_len(&self.l2c_mask) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.t_nmct.sbp_size(); - size += self.l2c_mask.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.t_nmct, buf); + WireFormat::write(&self.l2c_mask, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSvConfigurationGpsDep { + sender_id: None, + t_nmct: WireFormat::parse_unchecked(buf), + l2c_mask: WireFormat::parse_unchecked(buf), + } } } @@ -5720,57 +5705,33 @@ impl crate::serialize::SbpSerialize for MsgSvConfigurationGPSDep { /// /// Header of a GNSS observation message. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct ObservationHeader { /// GNSS time of this observation - pub t: GPSTime, + #[cfg_attr(feature = "serde", serde(rename(serialize = "t")))] + pub t: GpsTime, /// Total number of observations. First nibble is the size of the sequence /// (n), second nibble is the zero-indexed counter (ith packet of n) + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_obs")))] pub n_obs: u8, } -impl ObservationHeader { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( ObservationHeader{ - t: GPSTime::parse(_buf)?, - n_obs: _buf.read_u8()?, - } ) +impl WireFormat for ObservationHeader { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.t) + WireFormat::encoded_len(&self.n_obs) } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(ObservationHeader::parse(buf)?); - } - Ok(v) + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.t, buf); + WireFormat::write(&self.n_obs, buf); } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(ObservationHeader::parse(buf)?); + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + ObservationHeader { + t: WireFormat::parse_unchecked(buf), + n_obs: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for ObservationHeader { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.t.append_to_sbp_buffer(buf); - self.n_obs.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.t.sbp_size(); - size += self.n_obs.sbp_size(); - size } } @@ -5778,57 +5739,33 @@ impl crate::serialize::SbpSerialize for ObservationHeader { /// /// Header of a GPS observation message. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct ObservationHeaderDep { /// GPS time of this observation - pub t: GPSTimeDep, + #[cfg_attr(feature = "serde", serde(rename(serialize = "t")))] + pub t: GpsTimeDep, /// Total number of observations. First nibble is the size of the sequence /// (n), second nibble is the zero-indexed counter (ith packet of n) + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_obs")))] pub n_obs: u8, } -impl ObservationHeaderDep { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( ObservationHeaderDep{ - t: GPSTimeDep::parse(_buf)?, - n_obs: _buf.read_u8()?, - } ) +impl WireFormat for ObservationHeaderDep { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.t) + WireFormat::encoded_len(&self.n_obs) } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(ObservationHeaderDep::parse(buf)?); - } - Ok(v) + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.t, buf); + WireFormat::write(&self.n_obs, buf); } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(ObservationHeaderDep::parse(buf)?); + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + ObservationHeaderDep { + t: WireFormat::parse_unchecked(buf), + n_obs: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for ObservationHeaderDep { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.t.append_to_sbp_buffer(buf); - self.n_obs.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.t.sbp_size(); - size += self.n_obs.sbp_size(); - size } } @@ -5842,17 +5779,20 @@ impl crate::serialize::SbpSerialize for ObservationHeaderDep { /// or RTCM 3.3 MSM reference signal and no 1/4 cycle adjustments are /// currently performed. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct PackedObsContent { /// Pseudorange observation - pub P: u32, + #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] + pub p: u32, /// Carrier phase observation with typical sign convention. - pub L: CarrierPhase, + #[cfg_attr(feature = "serde", serde(rename(serialize = "L")))] + pub l: CarrierPhase, /// Doppler observation with typical sign convention. - pub D: Doppler, + #[cfg_attr(feature = "serde", serde(rename(serialize = "D")))] + pub d: Doppler, /// Carrier-to-Noise density. Zero implies invalid cn0. + #[cfg_attr(feature = "serde", serde(rename(serialize = "cn0")))] pub cn0: u8, /// Lock timer. This value gives an indication of the time for which a /// signal has maintained continuous phase lock. Whenever a signal has lost @@ -5860,70 +5800,54 @@ pub struct PackedObsContent { /// to DF402 from the RTCM 10403.2 Amendment 2 specification. Valid values /// range from 0 to 15 and the most significant nibble is reserved for /// future use. + #[cfg_attr(feature = "serde", serde(rename(serialize = "lock")))] pub lock: u8, /// Measurement status flags. A bit field of flags providing the status of /// this observation. If this field is 0 it means only the Cn0 estimate for /// the signal is valid. + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, /// GNSS signal identifier (16 bit) + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, } -impl PackedObsContent { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( PackedObsContent{ - P: _buf.read_u32::()?, - L: CarrierPhase::parse(_buf)?, - D: Doppler::parse(_buf)?, - cn0: _buf.read_u8()?, - lock: _buf.read_u8()?, - flags: _buf.read_u8()?, - sid: GnssSignal::parse(_buf)?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(PackedObsContent::parse(buf)?); +impl WireFormat for PackedObsContent { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.p) + + WireFormat::encoded_len(&self.l) + + WireFormat::encoded_len(&self.d) + + WireFormat::encoded_len(&self.cn0) + + WireFormat::encoded_len(&self.lock) + + WireFormat::encoded_len(&self.flags) + + WireFormat::encoded_len(&self.sid) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.p, buf); + WireFormat::write(&self.l, buf); + WireFormat::write(&self.d, buf); + WireFormat::write(&self.cn0, buf); + WireFormat::write(&self.lock, buf); + WireFormat::write(&self.flags, buf); + WireFormat::write(&self.sid, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + PackedObsContent { + p: WireFormat::parse_unchecked(buf), + l: WireFormat::parse_unchecked(buf), + d: WireFormat::parse_unchecked(buf), + cn0: WireFormat::parse_unchecked(buf), + lock: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(PackedObsContent::parse(buf)?); - } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for PackedObsContent { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.P.append_to_sbp_buffer(buf); - self.L.append_to_sbp_buffer(buf); - self.D.append_to_sbp_buffer(buf); - self.cn0.append_to_sbp_buffer(buf); - self.lock.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.P.sbp_size(); - size += self.L.sbp_size(); - size += self.D.sbp_size(); - size += self.cn0.sbp_size(); - size += self.lock.sbp_size(); - size += self.flags.sbp_size(); - size += self.sid.sbp_size(); - size } } @@ -5931,73 +5855,56 @@ impl crate::serialize::SbpSerialize for PackedObsContent { /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct PackedObsContentDepA { /// Pseudorange observation - pub P: u32, + #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] + pub p: u32, /// Carrier phase observation with opposite sign from typical convention - pub L: CarrierPhaseDepA, + #[cfg_attr(feature = "serde", serde(rename(serialize = "L")))] + pub l: CarrierPhaseDepA, /// Carrier-to-Noise density + #[cfg_attr(feature = "serde", serde(rename(serialize = "cn0")))] pub cn0: u8, /// Lock indicator. This value changes whenever a satellite signal has lost /// and regained lock, indicating that the carrier phase ambiguity may have /// changed. + #[cfg_attr(feature = "serde", serde(rename(serialize = "lock")))] pub lock: u16, /// PRN-1 identifier of the satellite signal + #[cfg_attr(feature = "serde", serde(rename(serialize = "prn")))] pub prn: u8, } -impl PackedObsContentDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( PackedObsContentDepA{ - P: _buf.read_u32::()?, - L: CarrierPhaseDepA::parse(_buf)?, - cn0: _buf.read_u8()?, - lock: _buf.read_u16::()?, - prn: _buf.read_u8()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(PackedObsContentDepA::parse(buf)?); +impl WireFormat for PackedObsContentDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.p) + + WireFormat::encoded_len(&self.l) + + WireFormat::encoded_len(&self.cn0) + + WireFormat::encoded_len(&self.lock) + + WireFormat::encoded_len(&self.prn) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.p, buf); + WireFormat::write(&self.l, buf); + WireFormat::write(&self.cn0, buf); + WireFormat::write(&self.lock, buf); + WireFormat::write(&self.prn, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + PackedObsContentDepA { + p: WireFormat::parse_unchecked(buf), + l: WireFormat::parse_unchecked(buf), + cn0: WireFormat::parse_unchecked(buf), + lock: WireFormat::parse_unchecked(buf), + prn: WireFormat::parse_unchecked(buf), } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(PackedObsContentDepA::parse(buf)?); - } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for PackedObsContentDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.P.append_to_sbp_buffer(buf); - self.L.append_to_sbp_buffer(buf); - self.cn0.append_to_sbp_buffer(buf); - self.lock.append_to_sbp_buffer(buf); - self.prn.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.P.sbp_size(); - size += self.L.sbp_size(); - size += self.cn0.sbp_size(); - size += self.lock.sbp_size(); - size += self.prn.sbp_size(); - size } } @@ -6006,73 +5913,56 @@ impl crate::serialize::SbpSerialize for PackedObsContentDepA { /// Pseudorange and carrier phase observation for a satellite being tracked. /// Pseudoranges are referenced to a nominal pseudorange. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct PackedObsContentDepB { /// Pseudorange observation - pub P: u32, + #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] + pub p: u32, /// Carrier phase observation with opposite sign from typical convention. - pub L: CarrierPhaseDepA, + #[cfg_attr(feature = "serde", serde(rename(serialize = "L")))] + pub l: CarrierPhaseDepA, /// Carrier-to-Noise density + #[cfg_attr(feature = "serde", serde(rename(serialize = "cn0")))] pub cn0: u8, /// Lock indicator. This value changes whenever a satellite signal has lost /// and regained lock, indicating that the carrier phase ambiguity may have /// changed. + #[cfg_attr(feature = "serde", serde(rename(serialize = "lock")))] pub lock: u16, /// GNSS signal identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignalDep, } -impl PackedObsContentDepB { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( PackedObsContentDepB{ - P: _buf.read_u32::()?, - L: CarrierPhaseDepA::parse(_buf)?, - cn0: _buf.read_u8()?, - lock: _buf.read_u16::()?, - sid: GnssSignalDep::parse(_buf)?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(PackedObsContentDepB::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(PackedObsContentDepB::parse(buf)?); +impl WireFormat for PackedObsContentDepB { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.p) + + WireFormat::encoded_len(&self.l) + + WireFormat::encoded_len(&self.cn0) + + WireFormat::encoded_len(&self.lock) + + WireFormat::encoded_len(&self.sid) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.p, buf); + WireFormat::write(&self.l, buf); + WireFormat::write(&self.cn0, buf); + WireFormat::write(&self.lock, buf); + WireFormat::write(&self.sid, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + PackedObsContentDepB { + p: WireFormat::parse_unchecked(buf), + l: WireFormat::parse_unchecked(buf), + cn0: WireFormat::parse_unchecked(buf), + lock: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for PackedObsContentDepB { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.P.append_to_sbp_buffer(buf); - self.L.append_to_sbp_buffer(buf); - self.cn0.append_to_sbp_buffer(buf); - self.lock.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.P.sbp_size(); - size += self.L.sbp_size(); - size += self.cn0.sbp_size(); - size += self.lock.sbp_size(); - size += self.sid.sbp_size(); - size } } @@ -6082,73 +5972,56 @@ impl crate::serialize::SbpSerialize for PackedObsContentDepB { /// The observations are be interoperable with 3rd party receivers and conform /// with typical RTCMv3 GNSS observations. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct PackedObsContentDepC { /// Pseudorange observation - pub P: u32, + #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] + pub p: u32, /// Carrier phase observation with typical sign convention. - pub L: CarrierPhase, + #[cfg_attr(feature = "serde", serde(rename(serialize = "L")))] + pub l: CarrierPhase, /// Carrier-to-Noise density + #[cfg_attr(feature = "serde", serde(rename(serialize = "cn0")))] pub cn0: u8, /// Lock indicator. This value changes whenever a satellite signal has lost /// and regained lock, indicating that the carrier phase ambiguity may have /// changed. + #[cfg_attr(feature = "serde", serde(rename(serialize = "lock")))] pub lock: u16, /// GNSS signal identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignalDep, } -impl PackedObsContentDepC { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( PackedObsContentDepC{ - P: _buf.read_u32::()?, - L: CarrierPhase::parse(_buf)?, - cn0: _buf.read_u8()?, - lock: _buf.read_u16::()?, - sid: GnssSignalDep::parse(_buf)?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(PackedObsContentDepC::parse(buf)?); +impl WireFormat for PackedObsContentDepC { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.p) + + WireFormat::encoded_len(&self.l) + + WireFormat::encoded_len(&self.cn0) + + WireFormat::encoded_len(&self.lock) + + WireFormat::encoded_len(&self.sid) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.p, buf); + WireFormat::write(&self.l, buf); + WireFormat::write(&self.cn0, buf); + WireFormat::write(&self.lock, buf); + WireFormat::write(&self.sid, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + PackedObsContentDepC { + p: WireFormat::parse_unchecked(buf), + l: WireFormat::parse_unchecked(buf), + cn0: WireFormat::parse_unchecked(buf), + lock: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(PackedObsContentDepC::parse(buf)?); - } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for PackedObsContentDepC { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.P.append_to_sbp_buffer(buf); - self.L.append_to_sbp_buffer(buf); - self.cn0.append_to_sbp_buffer(buf); - self.lock.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.P.sbp_size(); - size += self.L.sbp_size(); - size += self.cn0.sbp_size(); - size += self.lock.sbp_size(); - size += self.sid.sbp_size(); - size } } @@ -6156,91 +6029,80 @@ impl crate::serialize::SbpSerialize for PackedObsContentDepC { /// /// Pseudorange and carrier phase network corrections for a satellite signal. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct PackedOsrContent { /// Pseudorange observation - pub P: u32, + #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] + pub p: u32, /// Carrier phase observation with typical sign convention. - pub L: CarrierPhase, + #[cfg_attr(feature = "serde", serde(rename(serialize = "L")))] + pub l: CarrierPhase, /// Lock timer. This value gives an indication of the time for which a /// signal has maintained continuous phase lock. Whenever a signal has lost /// and regained lock, this value is reset to zero. It is encoded according /// to DF402 from the RTCM 10403.2 Amendment 2 specification. Valid values /// range from 0 to 15 and the most significant nibble is reserved for /// future use. + #[cfg_attr(feature = "serde", serde(rename(serialize = "lock")))] pub lock: u8, /// Correction flags. + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, /// GNSS signal identifier (16 bit) + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, /// Slant ionospheric correction standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "iono_std")))] pub iono_std: u16, /// Slant tropospheric correction standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "tropo_std")))] pub tropo_std: u16, /// Orbit/clock/bias correction projected on range standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "range_std")))] pub range_std: u16, } -impl PackedOsrContent { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( PackedOsrContent{ - P: _buf.read_u32::()?, - L: CarrierPhase::parse(_buf)?, - lock: _buf.read_u8()?, - flags: _buf.read_u8()?, - sid: GnssSignal::parse(_buf)?, - iono_std: _buf.read_u16::()?, - tropo_std: _buf.read_u16::()?, - range_std: _buf.read_u16::()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(PackedOsrContent::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(PackedOsrContent::parse(buf)?); +impl WireFormat for PackedOsrContent { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.p) + + WireFormat::encoded_len(&self.l) + + WireFormat::encoded_len(&self.lock) + + WireFormat::encoded_len(&self.flags) + + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.iono_std) + + WireFormat::encoded_len(&self.tropo_std) + + WireFormat::encoded_len(&self.range_std) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.p, buf); + WireFormat::write(&self.l, buf); + WireFormat::write(&self.lock, buf); + WireFormat::write(&self.flags, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.iono_std, buf); + WireFormat::write(&self.tropo_std, buf); + WireFormat::write(&self.range_std, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + PackedOsrContent { + p: WireFormat::parse_unchecked(buf), + l: WireFormat::parse_unchecked(buf), + lock: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + iono_std: WireFormat::parse_unchecked(buf), + tropo_std: WireFormat::parse_unchecked(buf), + range_std: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for PackedOsrContent { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.P.append_to_sbp_buffer(buf); - self.L.append_to_sbp_buffer(buf); - self.lock.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - self.iono_std.append_to_sbp_buffer(buf); - self.tropo_std.append_to_sbp_buffer(buf); - self.range_std.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.P.sbp_size(); - size += self.L.sbp_size(); - size += self.lock.sbp_size(); - size += self.flags.sbp_size(); - size += self.sid.sbp_size(); - size += self.iono_std.sbp_size(); - size += self.tropo_std.sbp_size(); - size += self.range_std.sbp_size(); - size } } @@ -6248,57 +6110,39 @@ impl crate::serialize::SbpSerialize for PackedOsrContent { /// /// Satellite azimuth and elevation. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct SvAzEl { /// GNSS signal identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, /// Azimuth angle (range 0..179) + #[cfg_attr(feature = "serde", serde(rename(serialize = "az")))] pub az: u8, /// Elevation angle (range -90..90) + #[cfg_attr(feature = "serde", serde(rename(serialize = "el")))] pub el: i8, } -impl SvAzEl { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( SvAzEl{ - sid: GnssSignal::parse(_buf)?, - az: _buf.read_u8()?, - el: _buf.read_i8()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(SvAzEl::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(SvAzEl::parse(buf)?); +impl WireFormat for SvAzEl { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.az) + + WireFormat::encoded_len(&self.el) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.az, buf); + WireFormat::write(&self.el, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + SvAzEl { + sid: WireFormat::parse_unchecked(buf), + az: WireFormat::parse_unchecked(buf), + el: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for SvAzEl { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sid.append_to_sbp_buffer(buf); - self.az.append_to_sbp_buffer(buf); - self.el.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sid.sbp_size(); - size += self.az.sbp_size(); - size += self.el.sbp_size(); - size } } diff --git a/rust/sbp/src/messages/orientation.rs b/rust/sbp/src/messages/orientation.rs index dfe7f122dc..2eda1a08d6 100644 --- a/rust/sbp/src/messages/orientation.rs +++ b/rust/sbp/src/messages/orientation.rs @@ -14,16 +14,7 @@ //****************************************************************************/ //! Orientation Messages -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; +use super::lib::*; /// Vehicle Body Frame instantaneous angular rates /// @@ -37,109 +28,97 @@ use crate::SbpString; /// down direction. This message will only be available in future INS versions /// of Swift Products and is not produced by Piksi Multi or Duro. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgAngularRate { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// angular rate about x axis + #[cfg_attr(feature = "serde", serde(rename(serialize = "x")))] pub x: i32, /// angular rate about y axis + #[cfg_attr(feature = "serde", serde(rename(serialize = "y")))] pub y: i32, /// angular rate about z axis + #[cfg_attr(feature = "serde", serde(rename(serialize = "z")))] pub z: i32, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgAngularRate { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgAngularRate{ - sender_id: None, - tow: _buf.read_u32::()?, - x: _buf.read_i32::()?, - y: _buf.read_i32::()?, - z: _buf.read_i32::()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgAngularRate { + const MESSAGE_TYPE: u16 = 546; + const MESSAGE_NAME: &'static str = "MSG_ANGULAR_RATE"; } -impl super::SBPMessage for MsgAngularRate { - fn get_message_name(&self) -> &'static str { - "MSG_ANGULAR_RATE" - } - fn get_message_type(&self) -> u16 { - 546 +impl SbpMessage for MsgAngularRate { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgAngularRate { - const MESSAGE_TYPE: u16 = 546; - const MESSAGE_NAME: &'static str = "MSG_ANGULAR_RATE"; -} -impl TryFrom for MsgAngularRate { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgAngularRate { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgAngularRate(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgAngularRate(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgAngularRate { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.x.append_to_sbp_buffer(buf); - self.y.append_to_sbp_buffer(buf); - self.z.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.x.sbp_size(); - size += self.y.sbp_size(); - size += self.z.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgAngularRate { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.x) + + WireFormat::encoded_len(&self.y) + + WireFormat::encoded_len(&self.z) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.x, buf); + WireFormat::write(&self.y, buf); + WireFormat::write(&self.z, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgAngularRate { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + x: WireFormat::parse_unchecked(buf), + y: WireFormat::parse_unchecked(buf), + z: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -151,104 +130,90 @@ impl crate::serialize::SbpSerialize for MsgAngularRate { /// intended that time-matched RTK mode is used when the base station is /// moving. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgBaselineHeading { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Heading + #[cfg_attr(feature = "serde", serde(rename(serialize = "heading")))] pub heading: u32, /// Number of satellites used in solution + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgBaselineHeading { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgBaselineHeading{ - sender_id: None, - tow: _buf.read_u32::()?, - heading: _buf.read_u32::()?, - n_sats: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgBaselineHeading { + const MESSAGE_TYPE: u16 = 527; + const MESSAGE_NAME: &'static str = "MSG_BASELINE_HEADING"; } -impl super::SBPMessage for MsgBaselineHeading { - fn get_message_name(&self) -> &'static str { - "MSG_BASELINE_HEADING" - } - fn get_message_type(&self) -> u16 { - 527 +impl SbpMessage for MsgBaselineHeading { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgBaselineHeading { - const MESSAGE_TYPE: u16 = 527; - const MESSAGE_NAME: &'static str = "MSG_BASELINE_HEADING"; -} -impl TryFrom for MsgBaselineHeading { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgBaselineHeading { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgBaselineHeading(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgBaselineHeading(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgBaselineHeading { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.heading.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.heading.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgBaselineHeading { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.heading) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.heading, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgBaselineHeading { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + heading: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -261,124 +226,118 @@ impl crate::serialize::SbpSerialize for MsgBaselineHeading { /// in future INS versions of Swift Products and is not produced by Piksi /// Multi or Duro. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgOrientEuler { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// rotation about the forward axis of the vehicle + #[cfg_attr(feature = "serde", serde(rename(serialize = "roll")))] pub roll: i32, /// rotation about the rightward axis of the vehicle + #[cfg_attr(feature = "serde", serde(rename(serialize = "pitch")))] pub pitch: i32, /// rotation about the downward axis of the vehicle + #[cfg_attr(feature = "serde", serde(rename(serialize = "yaw")))] pub yaw: i32, /// Estimated standard deviation of roll + #[cfg_attr(feature = "serde", serde(rename(serialize = "roll_accuracy")))] pub roll_accuracy: f32, /// Estimated standard deviation of pitch + #[cfg_attr(feature = "serde", serde(rename(serialize = "pitch_accuracy")))] pub pitch_accuracy: f32, /// Estimated standard deviation of yaw + #[cfg_attr(feature = "serde", serde(rename(serialize = "yaw_accuracy")))] pub yaw_accuracy: f32, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgOrientEuler { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgOrientEuler{ - sender_id: None, - tow: _buf.read_u32::()?, - roll: _buf.read_i32::()?, - pitch: _buf.read_i32::()?, - yaw: _buf.read_i32::()?, - roll_accuracy: _buf.read_f32::()?, - pitch_accuracy: _buf.read_f32::()?, - yaw_accuracy: _buf.read_f32::()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgOrientEuler { + const MESSAGE_TYPE: u16 = 545; + const MESSAGE_NAME: &'static str = "MSG_ORIENT_EULER"; } -impl super::SBPMessage for MsgOrientEuler { - fn get_message_name(&self) -> &'static str { - "MSG_ORIENT_EULER" - } - fn get_message_type(&self) -> u16 { - 545 +impl SbpMessage for MsgOrientEuler { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgOrientEuler { - const MESSAGE_TYPE: u16 = 545; - const MESSAGE_NAME: &'static str = "MSG_ORIENT_EULER"; -} -impl TryFrom for MsgOrientEuler { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgOrientEuler { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgOrientEuler(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgOrientEuler(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgOrientEuler { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.roll.append_to_sbp_buffer(buf); - self.pitch.append_to_sbp_buffer(buf); - self.yaw.append_to_sbp_buffer(buf); - self.roll_accuracy.append_to_sbp_buffer(buf); - self.pitch_accuracy.append_to_sbp_buffer(buf); - self.yaw_accuracy.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.roll.sbp_size(); - size += self.pitch.sbp_size(); - size += self.yaw.sbp_size(); - size += self.roll_accuracy.sbp_size(); - size += self.pitch_accuracy.sbp_size(); - size += self.yaw_accuracy.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgOrientEuler { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.roll) + + WireFormat::encoded_len(&self.pitch) + + WireFormat::encoded_len(&self.yaw) + + WireFormat::encoded_len(&self.roll_accuracy) + + WireFormat::encoded_len(&self.pitch_accuracy) + + WireFormat::encoded_len(&self.yaw_accuracy) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.roll, buf); + WireFormat::write(&self.pitch, buf); + WireFormat::write(&self.yaw, buf); + WireFormat::write(&self.roll_accuracy, buf); + WireFormat::write(&self.pitch_accuracy, buf); + WireFormat::write(&self.yaw_accuracy, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgOrientEuler { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + roll: WireFormat::parse_unchecked(buf), + pitch: WireFormat::parse_unchecked(buf), + yaw: WireFormat::parse_unchecked(buf), + roll_accuracy: WireFormat::parse_unchecked(buf), + pitch_accuracy: WireFormat::parse_unchecked(buf), + yaw_accuracy: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -391,133 +350,131 @@ impl crate::serialize::SbpSerialize for MsgOrientEuler { /// in future INS versions of Swift Products and is not produced by Piksi /// Multi or Duro. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgOrientQuat { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Real component + #[cfg_attr(feature = "serde", serde(rename(serialize = "w")))] pub w: i32, /// 1st imaginary component + #[cfg_attr(feature = "serde", serde(rename(serialize = "x")))] pub x: i32, /// 2nd imaginary component + #[cfg_attr(feature = "serde", serde(rename(serialize = "y")))] pub y: i32, /// 3rd imaginary component + #[cfg_attr(feature = "serde", serde(rename(serialize = "z")))] pub z: i32, /// Estimated standard deviation of w + #[cfg_attr(feature = "serde", serde(rename(serialize = "w_accuracy")))] pub w_accuracy: f32, /// Estimated standard deviation of x + #[cfg_attr(feature = "serde", serde(rename(serialize = "x_accuracy")))] pub x_accuracy: f32, /// Estimated standard deviation of y + #[cfg_attr(feature = "serde", serde(rename(serialize = "y_accuracy")))] pub y_accuracy: f32, /// Estimated standard deviation of z + #[cfg_attr(feature = "serde", serde(rename(serialize = "z_accuracy")))] pub z_accuracy: f32, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgOrientQuat { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgOrientQuat{ - sender_id: None, - tow: _buf.read_u32::()?, - w: _buf.read_i32::()?, - x: _buf.read_i32::()?, - y: _buf.read_i32::()?, - z: _buf.read_i32::()?, - w_accuracy: _buf.read_f32::()?, - x_accuracy: _buf.read_f32::()?, - y_accuracy: _buf.read_f32::()?, - z_accuracy: _buf.read_f32::()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgOrientQuat { + const MESSAGE_TYPE: u16 = 544; + const MESSAGE_NAME: &'static str = "MSG_ORIENT_QUAT"; } -impl super::SBPMessage for MsgOrientQuat { - fn get_message_name(&self) -> &'static str { - "MSG_ORIENT_QUAT" - } - fn get_message_type(&self) -> u16 { - 544 +impl SbpMessage for MsgOrientQuat { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgOrientQuat { - const MESSAGE_TYPE: u16 = 544; - const MESSAGE_NAME: &'static str = "MSG_ORIENT_QUAT"; -} -impl TryFrom for MsgOrientQuat { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgOrientQuat { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgOrientQuat(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgOrientQuat(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgOrientQuat { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.w.append_to_sbp_buffer(buf); - self.x.append_to_sbp_buffer(buf); - self.y.append_to_sbp_buffer(buf); - self.z.append_to_sbp_buffer(buf); - self.w_accuracy.append_to_sbp_buffer(buf); - self.x_accuracy.append_to_sbp_buffer(buf); - self.y_accuracy.append_to_sbp_buffer(buf); - self.z_accuracy.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.w.sbp_size(); - size += self.x.sbp_size(); - size += self.y.sbp_size(); - size += self.z.sbp_size(); - size += self.w_accuracy.sbp_size(); - size += self.x_accuracy.sbp_size(); - size += self.y_accuracy.sbp_size(); - size += self.z_accuracy.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgOrientQuat { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.w) + + WireFormat::encoded_len(&self.x) + + WireFormat::encoded_len(&self.y) + + WireFormat::encoded_len(&self.z) + + WireFormat::encoded_len(&self.w_accuracy) + + WireFormat::encoded_len(&self.x_accuracy) + + WireFormat::encoded_len(&self.y_accuracy) + + WireFormat::encoded_len(&self.z_accuracy) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.w, buf); + WireFormat::write(&self.x, buf); + WireFormat::write(&self.y, buf); + WireFormat::write(&self.z, buf); + WireFormat::write(&self.w_accuracy, buf); + WireFormat::write(&self.x_accuracy, buf); + WireFormat::write(&self.y_accuracy, buf); + WireFormat::write(&self.z_accuracy, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgOrientQuat { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + w: WireFormat::parse_unchecked(buf), + x: WireFormat::parse_unchecked(buf), + y: WireFormat::parse_unchecked(buf), + z: WireFormat::parse_unchecked(buf), + w_accuracy: WireFormat::parse_unchecked(buf), + x_accuracy: WireFormat::parse_unchecked(buf), + y_accuracy: WireFormat::parse_unchecked(buf), + z_accuracy: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } diff --git a/rust/sbp/src/messages/piksi.rs b/rust/sbp/src/messages/piksi.rs index f73a930de2..5dffdbab05 100644 --- a/rust/sbp/src/messages/piksi.rs +++ b/rust/sbp/src/messages/piksi.rs @@ -16,17 +16,9 @@ //! Piksi L1 receiver, including a variety of legacy messages that may no //! longer be used. -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - use super::gnss::*; -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; + +use super::lib::*; /// Receiver-to-base station latency /// @@ -35,63 +27,47 @@ use crate::SbpString; /// current GPS time calculated locally by the receiver to give a precise /// measurement of the end-to-end communication latency in the system. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct Latency { /// Average latency + #[cfg_attr(feature = "serde", serde(rename(serialize = "avg")))] pub avg: i32, /// Minimum latency + #[cfg_attr(feature = "serde", serde(rename(serialize = "lmin")))] pub lmin: i32, /// Maximum latency + #[cfg_attr(feature = "serde", serde(rename(serialize = "lmax")))] pub lmax: i32, /// Smoothed estimate of the current latency + #[cfg_attr(feature = "serde", serde(rename(serialize = "current")))] pub current: i32, } -impl Latency { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( Latency{ - avg: _buf.read_i32::()?, - lmin: _buf.read_i32::()?, - lmax: _buf.read_i32::()?, - current: _buf.read_i32::()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(Latency::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(Latency::parse(buf)?); +impl WireFormat for Latency { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.avg) + + WireFormat::encoded_len(&self.lmin) + + WireFormat::encoded_len(&self.lmax) + + WireFormat::encoded_len(&self.current) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.avg, buf); + WireFormat::write(&self.lmin, buf); + WireFormat::write(&self.lmax, buf); + WireFormat::write(&self.current, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + Latency { + avg: WireFormat::parse_unchecked(buf), + lmin: WireFormat::parse_unchecked(buf), + lmax: WireFormat::parse_unchecked(buf), + current: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for Latency { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.avg.append_to_sbp_buffer(buf); - self.lmin.append_to_sbp_buffer(buf); - self.lmax.append_to_sbp_buffer(buf); - self.current.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.avg.sbp_size(); - size += self.lmin.sbp_size(); - size += self.lmax.sbp_size(); - size += self.current.sbp_size(); - size } } @@ -100,71 +76,53 @@ impl crate::serialize::SbpSerialize for Latency { /// This is a legacy message for sending and loading a satellite alamanac onto /// the Piksi's flash memory from the host. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgAlmanac { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, } -impl MsgAlmanac { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgAlmanac{ - sender_id: None, - } ) - } +impl ConcreteMessage for MsgAlmanac { + const MESSAGE_TYPE: u16 = 105; + const MESSAGE_NAME: &'static str = "MSG_ALMANAC"; } -impl super::SBPMessage for MsgAlmanac { - fn get_message_name(&self) -> &'static str { - "MSG_ALMANAC" - } - fn get_message_type(&self) -> u16 { - 105 +impl SbpMessage for MsgAlmanac { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgAlmanac { - const MESSAGE_TYPE: u16 = 105; - const MESSAGE_NAME: &'static str = "MSG_ALMANAC"; -} -impl TryFrom for MsgAlmanac { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgAlmanac { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgAlmanac(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgAlmanac(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgAlmanac { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) {} - - fn sbp_size(&self) -> usize { +impl WireFormat for MsgAlmanac { + const MIN_ENCODED_LEN: usize = 0; + fn encoded_len(&self) -> usize { 0 } + fn write(&self, _buf: &mut bytes::BytesMut) {} + fn parse_unchecked(_buf: &mut bytes::BytesMut) -> Self { + MsgAlmanac { sender_id: None } + } } /// Cell modem information update message @@ -173,87 +131,74 @@ impl crate::serialize::SbpSerialize for MsgAlmanac { /// periodically to update the host on the status of the modem and its various /// parameters. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgCellModemStatus { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Received cell signal strength in dBm, zero translates to unknown + #[cfg_attr(feature = "serde", serde(rename(serialize = "signal_strength")))] pub signal_strength: i8, /// BER as reported by the modem, zero translates to unknown + #[cfg_attr(feature = "serde", serde(rename(serialize = "signal_error_rate")))] pub signal_error_rate: f32, /// Unspecified data TBD for this schema + #[cfg_attr(feature = "serde", serde(rename(serialize = "reserved")))] pub reserved: Vec, } -impl MsgCellModemStatus { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgCellModemStatus{ - sender_id: None, - signal_strength: _buf.read_i8()?, - signal_error_rate: _buf.read_f32::()?, - reserved: crate::parser::read_u8_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgCellModemStatus { + const MESSAGE_TYPE: u16 = 190; + const MESSAGE_NAME: &'static str = "MSG_CELL_MODEM_STATUS"; } -impl super::SBPMessage for MsgCellModemStatus { - fn get_message_name(&self) -> &'static str { - "MSG_CELL_MODEM_STATUS" - } - fn get_message_type(&self) -> u16 { - 190 +impl SbpMessage for MsgCellModemStatus { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgCellModemStatus { - const MESSAGE_TYPE: u16 = 190; - const MESSAGE_NAME: &'static str = "MSG_CELL_MODEM_STATUS"; } -impl TryFrom for MsgCellModemStatus { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgCellModemStatus { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgCellModemStatus(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgCellModemStatus(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgCellModemStatus { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.signal_strength.append_to_sbp_buffer(buf); - self.signal_error_rate.append_to_sbp_buffer(buf); - self.reserved.append_to_sbp_buffer(buf); +impl WireFormat for MsgCellModemStatus { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.signal_strength) + + WireFormat::encoded_len(&self.signal_error_rate) + + WireFormat::encoded_len(&self.reserved) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.signal_strength.sbp_size(); - size += self.signal_error_rate.sbp_size(); - size += self.reserved.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.signal_strength, buf); + WireFormat::write(&self.signal_error_rate, buf); + WireFormat::write(&self.reserved, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgCellModemStatus { + sender_id: None, + signal_strength: WireFormat::parse_unchecked(buf), + signal_error_rate: WireFormat::parse_unchecked(buf), + reserved: WireFormat::parse_unchecked(buf), + } } } @@ -263,82 +208,66 @@ impl crate::serialize::SbpSerialize for MsgCellModemStatus { /// MSG_COMMAND_REQ. The sequence number can be used to filter for filtering /// the correct command. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgCommandOutput { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Sequence number + #[cfg_attr(feature = "serde", serde(rename(serialize = "sequence")))] pub sequence: u32, /// Line of standard output or standard error - pub line: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "line")))] + pub line: SbpString, Unterminated>, } -impl MsgCommandOutput { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgCommandOutput{ - sender_id: None, - sequence: _buf.read_u32::()?, - line: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgCommandOutput { + const MESSAGE_TYPE: u16 = 188; + const MESSAGE_NAME: &'static str = "MSG_COMMAND_OUTPUT"; } -impl super::SBPMessage for MsgCommandOutput { - fn get_message_name(&self) -> &'static str { - "MSG_COMMAND_OUTPUT" - } - fn get_message_type(&self) -> u16 { - 188 +impl SbpMessage for MsgCommandOutput { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgCommandOutput { - const MESSAGE_TYPE: u16 = 188; - const MESSAGE_NAME: &'static str = "MSG_COMMAND_OUTPUT"; } -impl TryFrom for MsgCommandOutput { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgCommandOutput { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgCommandOutput(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgCommandOutput(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgCommandOutput { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sequence.append_to_sbp_buffer(buf); - self.line.append_to_sbp_buffer(buf); +impl WireFormat for MsgCommandOutput { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + , Unterminated> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sequence) + WireFormat::encoded_len(&self.line) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sequence.sbp_size(); - size += self.line.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sequence, buf); + WireFormat::write(&self.line, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgCommandOutput { + sender_id: None, + sequence: WireFormat::parse_unchecked(buf), + line: WireFormat::parse_unchecked(buf), + } } } @@ -348,82 +277,66 @@ impl crate::serialize::SbpSerialize for MsgCommandOutput { /// MSG_LOG messages, and the exit code will be returned with /// MSG_COMMAND_RESP. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgCommandReq { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Sequence number + #[cfg_attr(feature = "serde", serde(rename(serialize = "sequence")))] pub sequence: u32, /// Command line to execute - pub command: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "command")))] + pub command: SbpString, NullTerminated>, } -impl MsgCommandReq { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgCommandReq{ - sender_id: None, - sequence: _buf.read_u32::()?, - command: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgCommandReq { + const MESSAGE_TYPE: u16 = 184; + const MESSAGE_NAME: &'static str = "MSG_COMMAND_REQ"; } -impl super::SBPMessage for MsgCommandReq { - fn get_message_name(&self) -> &'static str { - "MSG_COMMAND_REQ" - } - fn get_message_type(&self) -> u16 { - 184 +impl SbpMessage for MsgCommandReq { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgCommandReq { - const MESSAGE_TYPE: u16 = 184; - const MESSAGE_NAME: &'static str = "MSG_COMMAND_REQ"; -} -impl TryFrom for MsgCommandReq { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgCommandReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgCommandReq(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgCommandReq(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgCommandReq { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sequence.append_to_sbp_buffer(buf); - self.command.append_to_sbp_buffer(buf); +impl WireFormat for MsgCommandReq { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + , NullTerminated> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sequence) + WireFormat::encoded_len(&self.command) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sequence.sbp_size(); - size += self.command.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sequence, buf); + WireFormat::write(&self.command, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgCommandReq { + sender_id: None, + sequence: WireFormat::parse_unchecked(buf), + command: WireFormat::parse_unchecked(buf), + } } } @@ -432,82 +345,66 @@ impl crate::serialize::SbpSerialize for MsgCommandReq { /// The response to MSG_COMMAND_REQ with the return code of the command. A /// return code of zero indicates success. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgCommandResp { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Sequence number + #[cfg_attr(feature = "serde", serde(rename(serialize = "sequence")))] pub sequence: u32, /// Exit code + #[cfg_attr(feature = "serde", serde(rename(serialize = "code")))] pub code: i32, } -impl MsgCommandResp { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgCommandResp{ - sender_id: None, - sequence: _buf.read_u32::()?, - code: _buf.read_i32::()?, - } ) - } +impl ConcreteMessage for MsgCommandResp { + const MESSAGE_TYPE: u16 = 185; + const MESSAGE_NAME: &'static str = "MSG_COMMAND_RESP"; } -impl super::SBPMessage for MsgCommandResp { - fn get_message_name(&self) -> &'static str { - "MSG_COMMAND_RESP" - } - fn get_message_type(&self) -> u16 { - 185 +impl SbpMessage for MsgCommandResp { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgCommandResp { - const MESSAGE_TYPE: u16 = 185; - const MESSAGE_NAME: &'static str = "MSG_COMMAND_RESP"; -} -impl TryFrom for MsgCommandResp { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgCommandResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgCommandResp(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgCommandResp(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgCommandResp { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sequence.append_to_sbp_buffer(buf); - self.code.append_to_sbp_buffer(buf); +impl WireFormat for MsgCommandResp { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sequence) + WireFormat::encoded_len(&self.code) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sequence.sbp_size(); - size += self.code.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sequence, buf); + WireFormat::write(&self.code, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgCommandResp { + sender_id: None, + sequence: WireFormat::parse_unchecked(buf), + code: WireFormat::parse_unchecked(buf), + } } } @@ -517,71 +414,53 @@ impl crate::serialize::SbpSerialize for MsgCommandResp { /// interference channel on the SwiftNAP. This message will be removed in a /// future release. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgCwResults { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, } -impl MsgCwResults { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgCwResults{ - sender_id: None, - } ) - } +impl ConcreteMessage for MsgCwResults { + const MESSAGE_TYPE: u16 = 192; + const MESSAGE_NAME: &'static str = "MSG_CW_RESULTS"; } -impl super::SBPMessage for MsgCwResults { - fn get_message_name(&self) -> &'static str { - "MSG_CW_RESULTS" - } - fn get_message_type(&self) -> u16 { - 192 +impl SbpMessage for MsgCwResults { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgCwResults { - const MESSAGE_TYPE: u16 = 192; - const MESSAGE_NAME: &'static str = "MSG_CW_RESULTS"; -} -impl TryFrom for MsgCwResults { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgCwResults { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgCwResults(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgCwResults(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgCwResults { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) {} - - fn sbp_size(&self) -> usize { +impl WireFormat for MsgCwResults { + const MIN_ENCODED_LEN: usize = 0; + fn encoded_len(&self) -> usize { 0 } + fn write(&self, _buf: &mut bytes::BytesMut) {} + fn parse_unchecked(_buf: &mut bytes::BytesMut) -> Self { + MsgCwResults { sender_id: None } + } } /// Legacy message for CW interference channel (host => Piksi) @@ -590,71 +469,53 @@ impl crate::serialize::SbpSerialize for MsgCwResults { /// interference channel on the SwiftNAP. This message will be removed in a /// future release. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgCwStart { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, } -impl MsgCwStart { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgCwStart{ - sender_id: None, - } ) - } +impl ConcreteMessage for MsgCwStart { + const MESSAGE_TYPE: u16 = 193; + const MESSAGE_NAME: &'static str = "MSG_CW_START"; } -impl super::SBPMessage for MsgCwStart { - fn get_message_name(&self) -> &'static str { - "MSG_CW_START" - } - fn get_message_type(&self) -> u16 { - 193 +impl SbpMessage for MsgCwStart { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgCwStart { - const MESSAGE_TYPE: u16 = 193; - const MESSAGE_NAME: &'static str = "MSG_CW_START"; } -impl TryFrom for MsgCwStart { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgCwStart { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgCwStart(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgCwStart(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgCwStart { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) {} - - fn sbp_size(&self) -> usize { +impl WireFormat for MsgCwStart { + const MIN_ENCODED_LEN: usize = 0; + fn encoded_len(&self) -> usize { 0 } + fn write(&self, _buf: &mut bytes::BytesMut) {} + fn parse_unchecked(_buf: &mut bytes::BytesMut) -> Self { + MsgCwStart { sender_id: None } + } } /// Device temperature and voltage levels @@ -663,97 +524,88 @@ impl crate::serialize::SbpSerialize for MsgCwStart { /// processor's monitoring system and the RF frontend die temperature if /// available. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgDeviceMonitor { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Device V_in + #[cfg_attr(feature = "serde", serde(rename(serialize = "dev_vin")))] pub dev_vin: i16, /// Processor V_int + #[cfg_attr(feature = "serde", serde(rename(serialize = "cpu_vint")))] pub cpu_vint: i16, /// Processor V_aux + #[cfg_attr(feature = "serde", serde(rename(serialize = "cpu_vaux")))] pub cpu_vaux: i16, /// Processor temperature + #[cfg_attr(feature = "serde", serde(rename(serialize = "cpu_temperature")))] pub cpu_temperature: i16, /// Frontend temperature (if available) + #[cfg_attr(feature = "serde", serde(rename(serialize = "fe_temperature")))] pub fe_temperature: i16, } -impl MsgDeviceMonitor { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgDeviceMonitor{ - sender_id: None, - dev_vin: _buf.read_i16::()?, - cpu_vint: _buf.read_i16::()?, - cpu_vaux: _buf.read_i16::()?, - cpu_temperature: _buf.read_i16::()?, - fe_temperature: _buf.read_i16::()?, - } ) - } +impl ConcreteMessage for MsgDeviceMonitor { + const MESSAGE_TYPE: u16 = 181; + const MESSAGE_NAME: &'static str = "MSG_DEVICE_MONITOR"; } -impl super::SBPMessage for MsgDeviceMonitor { - fn get_message_name(&self) -> &'static str { - "MSG_DEVICE_MONITOR" - } - fn get_message_type(&self) -> u16 { - 181 +impl SbpMessage for MsgDeviceMonitor { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgDeviceMonitor { - const MESSAGE_TYPE: u16 = 181; - const MESSAGE_NAME: &'static str = "MSG_DEVICE_MONITOR"; -} -impl TryFrom for MsgDeviceMonitor { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgDeviceMonitor { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgDeviceMonitor(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgDeviceMonitor(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgDeviceMonitor { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.dev_vin.append_to_sbp_buffer(buf); - self.cpu_vint.append_to_sbp_buffer(buf); - self.cpu_vaux.append_to_sbp_buffer(buf); - self.cpu_temperature.append_to_sbp_buffer(buf); - self.fe_temperature.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.dev_vin.sbp_size(); - size += self.cpu_vint.sbp_size(); - size += self.cpu_vaux.sbp_size(); - size += self.cpu_temperature.sbp_size(); - size += self.fe_temperature.sbp_size(); - size +impl WireFormat for MsgDeviceMonitor { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.dev_vin) + + WireFormat::encoded_len(&self.cpu_vint) + + WireFormat::encoded_len(&self.cpu_vaux) + + WireFormat::encoded_len(&self.cpu_temperature) + + WireFormat::encoded_len(&self.fe_temperature) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.dev_vin, buf); + WireFormat::write(&self.cpu_vint, buf); + WireFormat::write(&self.cpu_vaux, buf); + WireFormat::write(&self.cpu_temperature, buf); + WireFormat::write(&self.fe_temperature, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgDeviceMonitor { + sender_id: None, + dev_vin: WireFormat::parse_unchecked(buf), + cpu_vint: WireFormat::parse_unchecked(buf), + cpu_vaux: WireFormat::parse_unchecked(buf), + cpu_temperature: WireFormat::parse_unchecked(buf), + fe_temperature: WireFormat::parse_unchecked(buf), + } } } @@ -767,82 +619,66 @@ impl crate::serialize::SbpSerialize for MsgDeviceMonitor { /// that rf channel is not present in the hardware. A negative value implies /// an error for the particular gain stage as reported by the frontend. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgFrontEndGain { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// RF gain for each frontend channel - pub rf_gain: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "rf_gain")))] + pub rf_gain: [i8; 8], /// Intermediate frequency gain for each frontend channel - pub if_gain: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "if_gain")))] + pub if_gain: [i8; 8], } -impl MsgFrontEndGain { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgFrontEndGain{ - sender_id: None, - rf_gain: crate::parser::read_s8_array_limit(_buf, 8)?, - if_gain: crate::parser::read_s8_array_limit(_buf, 8)?, - } ) - } +impl ConcreteMessage for MsgFrontEndGain { + const MESSAGE_TYPE: u16 = 191; + const MESSAGE_NAME: &'static str = "MSG_FRONT_END_GAIN"; } -impl super::SBPMessage for MsgFrontEndGain { - fn get_message_name(&self) -> &'static str { - "MSG_FRONT_END_GAIN" - } - fn get_message_type(&self) -> u16 { - 191 +impl SbpMessage for MsgFrontEndGain { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgFrontEndGain { - const MESSAGE_TYPE: u16 = 191; - const MESSAGE_NAME: &'static str = "MSG_FRONT_END_GAIN"; -} -impl TryFrom for MsgFrontEndGain { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgFrontEndGain { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgFrontEndGain(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgFrontEndGain(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgFrontEndGain { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.rf_gain.append_to_sbp_buffer(buf); - self.if_gain.append_to_sbp_buffer(buf); +impl WireFormat for MsgFrontEndGain { + const MIN_ENCODED_LEN: usize = + <[i8; 8] as WireFormat>::MIN_ENCODED_LEN + <[i8; 8] as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.rf_gain) + WireFormat::encoded_len(&self.if_gain) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.rf_gain.sbp_size(); - size += self.if_gain.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.rf_gain, buf); + WireFormat::write(&self.if_gain, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgFrontEndGain { + sender_id: None, + rf_gain: WireFormat::parse_unchecked(buf), + if_gain: WireFormat::parse_unchecked(buf), + } } } @@ -852,77 +688,60 @@ impl crate::serialize::SbpSerialize for MsgFrontEndGain { /// process, which resolves unknown integer ambiguities from double- /// differenced carrier-phase measurements from satellite observations. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgIarState { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Number of integer ambiguity hypotheses remaining + #[cfg_attr(feature = "serde", serde(rename(serialize = "num_hyps")))] pub num_hyps: u32, } -impl MsgIarState { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgIarState{ - sender_id: None, - num_hyps: _buf.read_u32::()?, - } ) - } +impl ConcreteMessage for MsgIarState { + const MESSAGE_TYPE: u16 = 25; + const MESSAGE_NAME: &'static str = "MSG_IAR_STATE"; } -impl super::SBPMessage for MsgIarState { - fn get_message_name(&self) -> &'static str { - "MSG_IAR_STATE" - } - fn get_message_type(&self) -> u16 { - 25 +impl SbpMessage for MsgIarState { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgIarState { - const MESSAGE_TYPE: u16 = 25; - const MESSAGE_NAME: &'static str = "MSG_IAR_STATE"; } -impl TryFrom for MsgIarState { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgIarState { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgIarState(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgIarState(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgIarState { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.num_hyps.append_to_sbp_buffer(buf); +impl WireFormat for MsgIarState { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.num_hyps) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.num_hyps.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.num_hyps, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgIarState { + sender_id: None, + num_hyps: WireFormat::parse_unchecked(buf), + } } } @@ -930,71 +749,53 @@ impl crate::serialize::SbpSerialize for MsgIarState { /// /// Deprecated /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgInitBaseDep { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, } -impl MsgInitBaseDep { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgInitBaseDep{ - sender_id: None, - } ) - } +impl ConcreteMessage for MsgInitBaseDep { + const MESSAGE_TYPE: u16 = 35; + const MESSAGE_NAME: &'static str = "MSG_INIT_BASE_DEP"; } -impl super::SBPMessage for MsgInitBaseDep { - fn get_message_name(&self) -> &'static str { - "MSG_INIT_BASE_DEP" - } - fn get_message_type(&self) -> u16 { - 35 +impl SbpMessage for MsgInitBaseDep { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgInitBaseDep { - const MESSAGE_TYPE: u16 = 35; - const MESSAGE_NAME: &'static str = "MSG_INIT_BASE_DEP"; -} -impl TryFrom for MsgInitBaseDep { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgInitBaseDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgInitBaseDep(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgInitBaseDep(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgInitBaseDep { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) {} - - fn sbp_size(&self) -> usize { +impl WireFormat for MsgInitBaseDep { + const MIN_ENCODED_LEN: usize = 0; + fn encoded_len(&self) -> usize { 0 } + fn write(&self, _buf: &mut bytes::BytesMut) {} + fn parse_unchecked(_buf: &mut bytes::BytesMut) -> Self { + MsgInitBaseDep { sender_id: None } + } } /// Mask a satellite from use in Piksi subsystems @@ -1002,82 +803,66 @@ impl crate::serialize::SbpSerialize for MsgInitBaseDep { /// This message allows setting a mask to prevent a particular satellite from /// being used in various Piksi subsystems. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgMaskSatellite { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Mask of systems that should ignore this satellite. + #[cfg_attr(feature = "serde", serde(rename(serialize = "mask")))] pub mask: u8, /// GNSS signal for which the mask is applied + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, } -impl MsgMaskSatellite { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgMaskSatellite{ - sender_id: None, - mask: _buf.read_u8()?, - sid: GnssSignal::parse(_buf)?, - } ) - } +impl ConcreteMessage for MsgMaskSatellite { + const MESSAGE_TYPE: u16 = 43; + const MESSAGE_NAME: &'static str = "MSG_MASK_SATELLITE"; } -impl super::SBPMessage for MsgMaskSatellite { - fn get_message_name(&self) -> &'static str { - "MSG_MASK_SATELLITE" - } - fn get_message_type(&self) -> u16 { - 43 +impl SbpMessage for MsgMaskSatellite { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgMaskSatellite { - const MESSAGE_TYPE: u16 = 43; - const MESSAGE_NAME: &'static str = "MSG_MASK_SATELLITE"; -} -impl TryFrom for MsgMaskSatellite { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgMaskSatellite { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgMaskSatellite(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgMaskSatellite(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgMaskSatellite { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.mask.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); +impl WireFormat for MsgMaskSatellite { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.mask) + WireFormat::encoded_len(&self.sid) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.mask.sbp_size(); - size += self.sid.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.mask, buf); + WireFormat::write(&self.sid, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgMaskSatellite { + sender_id: None, + mask: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + } } } @@ -1085,82 +870,66 @@ impl crate::serialize::SbpSerialize for MsgMaskSatellite { /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgMaskSatelliteDep { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Mask of systems that should ignore this satellite. + #[cfg_attr(feature = "serde", serde(rename(serialize = "mask")))] pub mask: u8, /// GNSS signal for which the mask is applied + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignalDep, } -impl MsgMaskSatelliteDep { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgMaskSatelliteDep{ - sender_id: None, - mask: _buf.read_u8()?, - sid: GnssSignalDep::parse(_buf)?, - } ) - } +impl ConcreteMessage for MsgMaskSatelliteDep { + const MESSAGE_TYPE: u16 = 27; + const MESSAGE_NAME: &'static str = "MSG_MASK_SATELLITE_DEP"; } -impl super::SBPMessage for MsgMaskSatelliteDep { - fn get_message_name(&self) -> &'static str { - "MSG_MASK_SATELLITE_DEP" - } - fn get_message_type(&self) -> u16 { - 27 +impl SbpMessage for MsgMaskSatelliteDep { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgMaskSatelliteDep { - const MESSAGE_TYPE: u16 = 27; - const MESSAGE_NAME: &'static str = "MSG_MASK_SATELLITE_DEP"; } -impl TryFrom for MsgMaskSatelliteDep { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgMaskSatelliteDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgMaskSatelliteDep(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgMaskSatelliteDep(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgMaskSatelliteDep { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.mask.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); +impl WireFormat for MsgMaskSatelliteDep { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.mask) + WireFormat::encoded_len(&self.sid) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.mask.sbp_size(); - size += self.sid.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.mask, buf); + WireFormat::write(&self.sid, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgMaskSatelliteDep { + sender_id: None, + mask: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + } } } @@ -1168,77 +937,60 @@ impl crate::serialize::SbpSerialize for MsgMaskSatelliteDep { /// /// The bandwidth usage, a list of usage by interface. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgNetworkBandwidthUsage { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Usage measurement array + #[cfg_attr(feature = "serde", serde(rename(serialize = "interfaces")))] pub interfaces: Vec, } -impl MsgNetworkBandwidthUsage { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgNetworkBandwidthUsage{ - sender_id: None, - interfaces: NetworkUsage::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgNetworkBandwidthUsage { + const MESSAGE_TYPE: u16 = 189; + const MESSAGE_NAME: &'static str = "MSG_NETWORK_BANDWIDTH_USAGE"; } -impl super::SBPMessage for MsgNetworkBandwidthUsage { - fn get_message_name(&self) -> &'static str { - "MSG_NETWORK_BANDWIDTH_USAGE" - } - fn get_message_type(&self) -> u16 { - 189 +impl SbpMessage for MsgNetworkBandwidthUsage { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgNetworkBandwidthUsage { - const MESSAGE_TYPE: u16 = 189; - const MESSAGE_NAME: &'static str = "MSG_NETWORK_BANDWIDTH_USAGE"; -} -impl TryFrom for MsgNetworkBandwidthUsage { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgNetworkBandwidthUsage { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgNetworkBandwidthUsage(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgNetworkBandwidthUsage(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgNetworkBandwidthUsage { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.interfaces.append_to_sbp_buffer(buf); +impl WireFormat for MsgNetworkBandwidthUsage { + const MIN_ENCODED_LEN: usize = as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.interfaces) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.interfaces.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.interfaces, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgNetworkBandwidthUsage { + sender_id: None, + interfaces: WireFormat::parse_unchecked(buf), + } } } @@ -1247,71 +999,53 @@ impl crate::serialize::SbpSerialize for MsgNetworkBandwidthUsage { /// Request state of Piksi network interfaces. Output will be sent in /// MSG_NETWORK_STATE_RESP messages. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgNetworkStateReq { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, } -impl MsgNetworkStateReq { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgNetworkStateReq{ - sender_id: None, - } ) - } +impl ConcreteMessage for MsgNetworkStateReq { + const MESSAGE_TYPE: u16 = 186; + const MESSAGE_NAME: &'static str = "MSG_NETWORK_STATE_REQ"; } -impl super::SBPMessage for MsgNetworkStateReq { - fn get_message_name(&self) -> &'static str { - "MSG_NETWORK_STATE_REQ" - } - fn get_message_type(&self) -> u16 { - 186 +impl SbpMessage for MsgNetworkStateReq { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgNetworkStateReq { - const MESSAGE_TYPE: u16 = 186; - const MESSAGE_NAME: &'static str = "MSG_NETWORK_STATE_REQ"; -} -impl TryFrom for MsgNetworkStateReq { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgNetworkStateReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgNetworkStateReq(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgNetworkStateReq(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgNetworkStateReq { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) {} - - fn sbp_size(&self) -> usize { +impl WireFormat for MsgNetworkStateReq { + const MIN_ENCODED_LEN: usize = 0; + fn encoded_len(&self) -> usize { 0 } + fn write(&self, _buf: &mut bytes::BytesMut) {} + fn parse_unchecked(_buf: &mut bytes::BytesMut) -> Self { + MsgNetworkStateReq { sender_id: None } + } } /// State of network interface @@ -1319,112 +1053,109 @@ impl crate::serialize::SbpSerialize for MsgNetworkStateReq { /// The state of a network interface on the Piksi. Data is made to reflect /// output of ifaddrs struct returned by getifaddrs in c. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgNetworkStateResp { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// IPv4 address (all zero when unavailable) - pub ipv4_address: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "ipv4_address")))] + pub ipv4_address: [u8; 4], /// IPv4 netmask CIDR notation + #[cfg_attr(feature = "serde", serde(rename(serialize = "ipv4_mask_size")))] pub ipv4_mask_size: u8, /// IPv6 address (all zero when unavailable) - pub ipv6_address: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "ipv6_address")))] + pub ipv6_address: [u8; 16], /// IPv6 netmask CIDR notation + #[cfg_attr(feature = "serde", serde(rename(serialize = "ipv6_mask_size")))] pub ipv6_mask_size: u8, /// Number of Rx bytes + #[cfg_attr(feature = "serde", serde(rename(serialize = "rx_bytes")))] pub rx_bytes: u32, /// Number of Tx bytes + #[cfg_attr(feature = "serde", serde(rename(serialize = "tx_bytes")))] pub tx_bytes: u32, /// Interface Name - pub interface_name: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "interface_name")))] + pub interface_name: SbpString<[u8; 16], Unterminated>, /// Interface flags from SIOCGIFFLAGS + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u32, } -impl MsgNetworkStateResp { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgNetworkStateResp{ - sender_id: None, - ipv4_address: crate::parser::read_u8_array_limit(_buf, 4)?, - ipv4_mask_size: _buf.read_u8()?, - ipv6_address: crate::parser::read_u8_array_limit(_buf, 16)?, - ipv6_mask_size: _buf.read_u8()?, - rx_bytes: _buf.read_u32::()?, - tx_bytes: _buf.read_u32::()?, - interface_name: crate::parser::read_string_limit(_buf, 16)?, - flags: _buf.read_u32::()?, - } ) - } +impl ConcreteMessage for MsgNetworkStateResp { + const MESSAGE_TYPE: u16 = 187; + const MESSAGE_NAME: &'static str = "MSG_NETWORK_STATE_RESP"; } -impl super::SBPMessage for MsgNetworkStateResp { - fn get_message_name(&self) -> &'static str { - "MSG_NETWORK_STATE_RESP" - } - fn get_message_type(&self) -> u16 { - 187 +impl SbpMessage for MsgNetworkStateResp { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgNetworkStateResp { - const MESSAGE_TYPE: u16 = 187; - const MESSAGE_NAME: &'static str = "MSG_NETWORK_STATE_RESP"; } -impl TryFrom for MsgNetworkStateResp { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgNetworkStateResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgNetworkStateResp(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgNetworkStateResp(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgNetworkStateResp { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.ipv4_address.append_to_sbp_buffer(buf); - self.ipv4_mask_size.append_to_sbp_buffer(buf); - self.ipv6_address.append_to_sbp_buffer(buf); - self.ipv6_mask_size.append_to_sbp_buffer(buf); - self.rx_bytes.append_to_sbp_buffer(buf); - self.tx_bytes.append_to_sbp_buffer(buf); - self.interface_name.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.ipv4_address.sbp_size(); - size += self.ipv4_mask_size.sbp_size(); - size += self.ipv6_address.sbp_size(); - size += self.ipv6_mask_size.sbp_size(); - size += self.rx_bytes.sbp_size(); - size += self.tx_bytes.sbp_size(); - size += self.interface_name.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgNetworkStateResp { + const MIN_ENCODED_LEN: usize = <[u8; 4] as WireFormat>::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + <[u8; 16] as WireFormat>::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.ipv4_address) + + WireFormat::encoded_len(&self.ipv4_mask_size) + + WireFormat::encoded_len(&self.ipv6_address) + + WireFormat::encoded_len(&self.ipv6_mask_size) + + WireFormat::encoded_len(&self.rx_bytes) + + WireFormat::encoded_len(&self.tx_bytes) + + WireFormat::encoded_len(&self.interface_name) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.ipv4_address, buf); + WireFormat::write(&self.ipv4_mask_size, buf); + WireFormat::write(&self.ipv6_address, buf); + WireFormat::write(&self.ipv6_mask_size, buf); + WireFormat::write(&self.rx_bytes, buf); + WireFormat::write(&self.tx_bytes, buf); + WireFormat::write(&self.interface_name, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgNetworkStateResp { + sender_id: None, + ipv4_address: WireFormat::parse_unchecked(buf), + ipv4_mask_size: WireFormat::parse_unchecked(buf), + ipv6_address: WireFormat::parse_unchecked(buf), + ipv6_mask_size: WireFormat::parse_unchecked(buf), + rx_bytes: WireFormat::parse_unchecked(buf), + tx_bytes: WireFormat::parse_unchecked(buf), + interface_name: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -1432,77 +1163,60 @@ impl crate::serialize::SbpSerialize for MsgNetworkStateResp { /// /// This message from the host resets the Piksi back into the bootloader. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgReset { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Reset flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u32, } -impl MsgReset { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgReset{ - sender_id: None, - flags: _buf.read_u32::()?, - } ) - } +impl ConcreteMessage for MsgReset { + const MESSAGE_TYPE: u16 = 182; + const MESSAGE_NAME: &'static str = "MSG_RESET"; } -impl super::SBPMessage for MsgReset { - fn get_message_name(&self) -> &'static str { - "MSG_RESET" - } - fn get_message_type(&self) -> u16 { - 182 +impl SbpMessage for MsgReset { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgReset { - const MESSAGE_TYPE: u16 = 182; - const MESSAGE_NAME: &'static str = "MSG_RESET"; } -impl TryFrom for MsgReset { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgReset { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgReset(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgReset(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgReset { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.flags.append_to_sbp_buffer(buf); +impl WireFormat for MsgReset { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.flags) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.flags.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgReset { + sender_id: None, + flags: WireFormat::parse_unchecked(buf), + } } } @@ -1510,71 +1224,53 @@ impl crate::serialize::SbpSerialize for MsgReset { /// /// This message from the host resets the Piksi back into the bootloader. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgResetDep { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, } -impl MsgResetDep { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgResetDep{ - sender_id: None, - } ) - } +impl ConcreteMessage for MsgResetDep { + const MESSAGE_TYPE: u16 = 178; + const MESSAGE_NAME: &'static str = "MSG_RESET_DEP"; } -impl super::SBPMessage for MsgResetDep { - fn get_message_name(&self) -> &'static str { - "MSG_RESET_DEP" - } - fn get_message_type(&self) -> u16 { - 178 +impl SbpMessage for MsgResetDep { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgResetDep { - const MESSAGE_TYPE: u16 = 178; - const MESSAGE_NAME: &'static str = "MSG_RESET_DEP"; } -impl TryFrom for MsgResetDep { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgResetDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgResetDep(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgResetDep(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgResetDep { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) {} - - fn sbp_size(&self) -> usize { +impl WireFormat for MsgResetDep { + const MIN_ENCODED_LEN: usize = 0; + fn encoded_len(&self) -> usize { 0 } + fn write(&self, _buf: &mut bytes::BytesMut) {} + fn parse_unchecked(_buf: &mut bytes::BytesMut) -> Self { + MsgResetDep { sender_id: None } + } } /// Reset IAR filters (host => Piksi) @@ -1582,77 +1278,60 @@ impl crate::serialize::SbpSerialize for MsgResetDep { /// This message resets either the DGNSS Kalman filters or Integer Ambiguity /// Resolution (IAR) process. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgResetFilters { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Filter flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "filter")))] pub filter: u8, } -impl MsgResetFilters { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgResetFilters{ - sender_id: None, - filter: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgResetFilters { + const MESSAGE_TYPE: u16 = 34; + const MESSAGE_NAME: &'static str = "MSG_RESET_FILTERS"; } -impl super::SBPMessage for MsgResetFilters { - fn get_message_name(&self) -> &'static str { - "MSG_RESET_FILTERS" - } - fn get_message_type(&self) -> u16 { - 34 +impl SbpMessage for MsgResetFilters { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgResetFilters { - const MESSAGE_TYPE: u16 = 34; - const MESSAGE_NAME: &'static str = "MSG_RESET_FILTERS"; } -impl TryFrom for MsgResetFilters { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgResetFilters { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgResetFilters(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgResetFilters(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgResetFilters { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.filter.append_to_sbp_buffer(buf); +impl WireFormat for MsgResetFilters { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.filter) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.filter.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.filter, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgResetFilters { + sender_id: None, + filter: WireFormat::parse_unchecked(buf), + } } } @@ -1661,178 +1340,155 @@ impl crate::serialize::SbpSerialize for MsgResetFilters { /// This message sets up timing functionality using a coarse GPS time estimate /// sent by the host. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSetTime { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, } -impl MsgSetTime { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSetTime{ - sender_id: None, - } ) - } +impl ConcreteMessage for MsgSetTime { + const MESSAGE_TYPE: u16 = 104; + const MESSAGE_NAME: &'static str = "MSG_SET_TIME"; } -impl super::SBPMessage for MsgSetTime { - fn get_message_name(&self) -> &'static str { - "MSG_SET_TIME" - } - fn get_message_type(&self) -> u16 { - 104 +impl SbpMessage for MsgSetTime { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgSetTime { - const MESSAGE_TYPE: u16 = 104; - const MESSAGE_NAME: &'static str = "MSG_SET_TIME"; } -impl TryFrom for MsgSetTime { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSetTime { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSetTime(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSetTime(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSetTime { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) {} - - fn sbp_size(&self) -> usize { +impl WireFormat for MsgSetTime { + const MIN_ENCODED_LEN: usize = 0; + fn encoded_len(&self) -> usize { 0 } + fn write(&self, _buf: &mut bytes::BytesMut) {} + fn parse_unchecked(_buf: &mut bytes::BytesMut) -> Self { + MsgSetTime { sender_id: None } + } } /// Spectrum analyzer /// /// Spectrum analyzer packet. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSpecan { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Channel ID + #[cfg_attr(feature = "serde", serde(rename(serialize = "channel_tag")))] pub channel_tag: u16, /// Receiver time of this observation - pub t: GPSTime, + #[cfg_attr(feature = "serde", serde(rename(serialize = "t")))] + pub t: GpsTime, /// Reference frequency of this packet + #[cfg_attr(feature = "serde", serde(rename(serialize = "freq_ref")))] pub freq_ref: f32, /// Frequency step of points in this packet + #[cfg_attr(feature = "serde", serde(rename(serialize = "freq_step")))] pub freq_step: f32, /// Reference amplitude of this packet + #[cfg_attr(feature = "serde", serde(rename(serialize = "amplitude_ref")))] pub amplitude_ref: f32, /// Amplitude unit value of points in this packet + #[cfg_attr(feature = "serde", serde(rename(serialize = "amplitude_unit")))] pub amplitude_unit: f32, /// Amplitude values (in the above units) of points in this packet + #[cfg_attr(feature = "serde", serde(rename(serialize = "amplitude_value")))] pub amplitude_value: Vec, } -impl MsgSpecan { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSpecan{ - sender_id: None, - channel_tag: _buf.read_u16::()?, - t: GPSTime::parse(_buf)?, - freq_ref: _buf.read_f32::()?, - freq_step: _buf.read_f32::()?, - amplitude_ref: _buf.read_f32::()?, - amplitude_unit: _buf.read_f32::()?, - amplitude_value: crate::parser::read_u8_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgSpecan { + const MESSAGE_TYPE: u16 = 81; + const MESSAGE_NAME: &'static str = "MSG_SPECAN"; } -impl super::SBPMessage for MsgSpecan { - fn get_message_name(&self) -> &'static str { - "MSG_SPECAN" - } - fn get_message_type(&self) -> u16 { - 81 +impl SbpMessage for MsgSpecan { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgSpecan { - const MESSAGE_TYPE: u16 = 81; - const MESSAGE_NAME: &'static str = "MSG_SPECAN"; -} -impl TryFrom for MsgSpecan { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSpecan { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSpecan(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSpecan(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSpecan { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.channel_tag.append_to_sbp_buffer(buf); - self.t.append_to_sbp_buffer(buf); - self.freq_ref.append_to_sbp_buffer(buf); - self.freq_step.append_to_sbp_buffer(buf); - self.amplitude_ref.append_to_sbp_buffer(buf); - self.amplitude_unit.append_to_sbp_buffer(buf); - self.amplitude_value.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.channel_tag.sbp_size(); - size += self.t.sbp_size(); - size += self.freq_ref.sbp_size(); - size += self.freq_step.sbp_size(); - size += self.amplitude_ref.sbp_size(); - size += self.amplitude_unit.sbp_size(); - size += self.amplitude_value.sbp_size(); - size +impl WireFormat for MsgSpecan { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.channel_tag) + + WireFormat::encoded_len(&self.t) + + WireFormat::encoded_len(&self.freq_ref) + + WireFormat::encoded_len(&self.freq_step) + + WireFormat::encoded_len(&self.amplitude_ref) + + WireFormat::encoded_len(&self.amplitude_unit) + + WireFormat::encoded_len(&self.amplitude_value) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.channel_tag, buf); + WireFormat::write(&self.t, buf); + WireFormat::write(&self.freq_ref, buf); + WireFormat::write(&self.freq_step, buf); + WireFormat::write(&self.amplitude_ref, buf); + WireFormat::write(&self.amplitude_unit, buf); + WireFormat::write(&self.amplitude_value, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSpecan { + sender_id: None, + channel_tag: WireFormat::parse_unchecked(buf), + t: WireFormat::parse_unchecked(buf), + freq_ref: WireFormat::parse_unchecked(buf), + freq_step: WireFormat::parse_unchecked(buf), + amplitude_ref: WireFormat::parse_unchecked(buf), + amplitude_unit: WireFormat::parse_unchecked(buf), + amplitude_value: WireFormat::parse_unchecked(buf), + } } } @@ -1840,107 +1496,102 @@ impl crate::serialize::SbpSerialize for MsgSpecan { /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSpecanDep { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Channel ID + #[cfg_attr(feature = "serde", serde(rename(serialize = "channel_tag")))] pub channel_tag: u16, /// Receiver time of this observation - pub t: GPSTimeDep, + #[cfg_attr(feature = "serde", serde(rename(serialize = "t")))] + pub t: GpsTimeDep, /// Reference frequency of this packet + #[cfg_attr(feature = "serde", serde(rename(serialize = "freq_ref")))] pub freq_ref: f32, /// Frequency step of points in this packet + #[cfg_attr(feature = "serde", serde(rename(serialize = "freq_step")))] pub freq_step: f32, /// Reference amplitude of this packet + #[cfg_attr(feature = "serde", serde(rename(serialize = "amplitude_ref")))] pub amplitude_ref: f32, /// Amplitude unit value of points in this packet + #[cfg_attr(feature = "serde", serde(rename(serialize = "amplitude_unit")))] pub amplitude_unit: f32, /// Amplitude values (in the above units) of points in this packet + #[cfg_attr(feature = "serde", serde(rename(serialize = "amplitude_value")))] pub amplitude_value: Vec, } -impl MsgSpecanDep { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSpecanDep{ - sender_id: None, - channel_tag: _buf.read_u16::()?, - t: GPSTimeDep::parse(_buf)?, - freq_ref: _buf.read_f32::()?, - freq_step: _buf.read_f32::()?, - amplitude_ref: _buf.read_f32::()?, - amplitude_unit: _buf.read_f32::()?, - amplitude_value: crate::parser::read_u8_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgSpecanDep { + const MESSAGE_TYPE: u16 = 80; + const MESSAGE_NAME: &'static str = "MSG_SPECAN_DEP"; } -impl super::SBPMessage for MsgSpecanDep { - fn get_message_name(&self) -> &'static str { - "MSG_SPECAN_DEP" - } - fn get_message_type(&self) -> u16 { - 80 +impl SbpMessage for MsgSpecanDep { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgSpecanDep { - const MESSAGE_TYPE: u16 = 80; - const MESSAGE_NAME: &'static str = "MSG_SPECAN_DEP"; -} -impl TryFrom for MsgSpecanDep { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSpecanDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSpecanDep(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSpecanDep(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSpecanDep { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.channel_tag.append_to_sbp_buffer(buf); - self.t.append_to_sbp_buffer(buf); - self.freq_ref.append_to_sbp_buffer(buf); - self.freq_step.append_to_sbp_buffer(buf); - self.amplitude_ref.append_to_sbp_buffer(buf); - self.amplitude_unit.append_to_sbp_buffer(buf); - self.amplitude_value.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.channel_tag.sbp_size(); - size += self.t.sbp_size(); - size += self.freq_ref.sbp_size(); - size += self.freq_step.sbp_size(); - size += self.amplitude_ref.sbp_size(); - size += self.amplitude_unit.sbp_size(); - size += self.amplitude_value.sbp_size(); - size +impl WireFormat for MsgSpecanDep { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.channel_tag) + + WireFormat::encoded_len(&self.t) + + WireFormat::encoded_len(&self.freq_ref) + + WireFormat::encoded_len(&self.freq_step) + + WireFormat::encoded_len(&self.amplitude_ref) + + WireFormat::encoded_len(&self.amplitude_unit) + + WireFormat::encoded_len(&self.amplitude_value) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.channel_tag, buf); + WireFormat::write(&self.t, buf); + WireFormat::write(&self.freq_ref, buf); + WireFormat::write(&self.freq_step, buf); + WireFormat::write(&self.amplitude_ref, buf); + WireFormat::write(&self.amplitude_unit, buf); + WireFormat::write(&self.amplitude_value, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSpecanDep { + sender_id: None, + channel_tag: WireFormat::parse_unchecked(buf), + t: WireFormat::parse_unchecked(buf), + freq_ref: WireFormat::parse_unchecked(buf), + freq_step: WireFormat::parse_unchecked(buf), + amplitude_ref: WireFormat::parse_unchecked(buf), + amplitude_unit: WireFormat::parse_unchecked(buf), + amplitude_value: WireFormat::parse_unchecked(buf), + } } } @@ -1950,88 +1601,76 @@ impl crate::serialize::SbpSerialize for MsgSpecanDep { /// system (RTOS) thread usage statistics for the named thread. The reported /// percentage values must be normalized. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgThreadState { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Thread name (NULL terminated) - pub name: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "name")))] + pub name: SbpString<[u8; 20], NullTerminated>, /// Percentage cpu use for this thread. Values range from 0 - 1000 and needs /// to be renormalized to 100 + #[cfg_attr(feature = "serde", serde(rename(serialize = "cpu")))] pub cpu: u16, /// Free stack space for this thread + #[cfg_attr(feature = "serde", serde(rename(serialize = "stack_free")))] pub stack_free: u32, } -impl MsgThreadState { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgThreadState{ - sender_id: None, - name: crate::parser::read_string_limit(_buf, 20)?, - cpu: _buf.read_u16::()?, - stack_free: _buf.read_u32::()?, - } ) - } +impl ConcreteMessage for MsgThreadState { + const MESSAGE_TYPE: u16 = 23; + const MESSAGE_NAME: &'static str = "MSG_THREAD_STATE"; } -impl super::SBPMessage for MsgThreadState { - fn get_message_name(&self) -> &'static str { - "MSG_THREAD_STATE" - } - fn get_message_type(&self) -> u16 { - 23 +impl SbpMessage for MsgThreadState { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgThreadState { - const MESSAGE_TYPE: u16 = 23; - const MESSAGE_NAME: &'static str = "MSG_THREAD_STATE"; } -impl TryFrom for MsgThreadState { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgThreadState { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgThreadState(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgThreadState(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgThreadState { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.name.append_to_sbp_buffer(buf); - self.cpu.append_to_sbp_buffer(buf); - self.stack_free.append_to_sbp_buffer(buf); +impl WireFormat for MsgThreadState { + const MIN_ENCODED_LEN: usize = + as WireFormat>::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.name) + + WireFormat::encoded_len(&self.cpu) + + WireFormat::encoded_len(&self.stack_free) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.name.sbp_size(); - size += self.cpu.sbp_size(); - size += self.stack_free.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.name, buf); + WireFormat::write(&self.cpu, buf); + WireFormat::write(&self.stack_free, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgThreadState { + sender_id: None, + name: WireFormat::parse_unchecked(buf), + cpu: WireFormat::parse_unchecked(buf), + stack_free: WireFormat::parse_unchecked(buf), + } } } @@ -2046,97 +1685,88 @@ impl crate::serialize::SbpSerialize for MsgThreadState { /// timeliness of received base observations while the period indicates their /// likelihood of transmission. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgUartState { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// State of UART A + #[cfg_attr(feature = "serde", serde(rename(serialize = "uart_a")))] pub uart_a: UARTChannel, /// State of UART B + #[cfg_attr(feature = "serde", serde(rename(serialize = "uart_b")))] pub uart_b: UARTChannel, /// State of UART FTDI (USB logger) + #[cfg_attr(feature = "serde", serde(rename(serialize = "uart_ftdi")))] pub uart_ftdi: UARTChannel, /// UART communication latency + #[cfg_attr(feature = "serde", serde(rename(serialize = "latency")))] pub latency: Latency, /// Observation receipt period + #[cfg_attr(feature = "serde", serde(rename(serialize = "obs_period")))] pub obs_period: Period, } -impl MsgUartState { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgUartState{ - sender_id: None, - uart_a: UARTChannel::parse(_buf)?, - uart_b: UARTChannel::parse(_buf)?, - uart_ftdi: UARTChannel::parse(_buf)?, - latency: Latency::parse(_buf)?, - obs_period: Period::parse(_buf)?, - } ) - } +impl ConcreteMessage for MsgUartState { + const MESSAGE_TYPE: u16 = 29; + const MESSAGE_NAME: &'static str = "MSG_UART_STATE"; } -impl super::SBPMessage for MsgUartState { - fn get_message_name(&self) -> &'static str { - "MSG_UART_STATE" - } - fn get_message_type(&self) -> u16 { - 29 +impl SbpMessage for MsgUartState { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgUartState { - const MESSAGE_TYPE: u16 = 29; - const MESSAGE_NAME: &'static str = "MSG_UART_STATE"; -} -impl TryFrom for MsgUartState { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgUartState { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgUartState(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgUartState(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgUartState { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.uart_a.append_to_sbp_buffer(buf); - self.uart_b.append_to_sbp_buffer(buf); - self.uart_ftdi.append_to_sbp_buffer(buf); - self.latency.append_to_sbp_buffer(buf); - self.obs_period.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.uart_a.sbp_size(); - size += self.uart_b.sbp_size(); - size += self.uart_ftdi.sbp_size(); - size += self.latency.sbp_size(); - size += self.obs_period.sbp_size(); - size +impl WireFormat for MsgUartState { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.uart_a) + + WireFormat::encoded_len(&self.uart_b) + + WireFormat::encoded_len(&self.uart_ftdi) + + WireFormat::encoded_len(&self.latency) + + WireFormat::encoded_len(&self.obs_period) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.uart_a, buf); + WireFormat::write(&self.uart_b, buf); + WireFormat::write(&self.uart_ftdi, buf); + WireFormat::write(&self.latency, buf); + WireFormat::write(&self.obs_period, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgUartState { + sender_id: None, + uart_a: WireFormat::parse_unchecked(buf), + uart_b: WireFormat::parse_unchecked(buf), + uart_ftdi: WireFormat::parse_unchecked(buf), + latency: WireFormat::parse_unchecked(buf), + obs_period: WireFormat::parse_unchecked(buf), + } } } @@ -2144,92 +1774,81 @@ impl crate::serialize::SbpSerialize for MsgUartState { /// /// Deprecated /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgUartStateDepa { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// State of UART A + #[cfg_attr(feature = "serde", serde(rename(serialize = "uart_a")))] pub uart_a: UARTChannel, /// State of UART B + #[cfg_attr(feature = "serde", serde(rename(serialize = "uart_b")))] pub uart_b: UARTChannel, /// State of UART FTDI (USB logger) + #[cfg_attr(feature = "serde", serde(rename(serialize = "uart_ftdi")))] pub uart_ftdi: UARTChannel, /// UART communication latency + #[cfg_attr(feature = "serde", serde(rename(serialize = "latency")))] pub latency: Latency, } -impl MsgUartStateDepa { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgUartStateDepa{ - sender_id: None, - uart_a: UARTChannel::parse(_buf)?, - uart_b: UARTChannel::parse(_buf)?, - uart_ftdi: UARTChannel::parse(_buf)?, - latency: Latency::parse(_buf)?, - } ) - } +impl ConcreteMessage for MsgUartStateDepa { + const MESSAGE_TYPE: u16 = 24; + const MESSAGE_NAME: &'static str = "MSG_UART_STATE_DEPA"; } -impl super::SBPMessage for MsgUartStateDepa { - fn get_message_name(&self) -> &'static str { - "MSG_UART_STATE_DEPA" - } - fn get_message_type(&self) -> u16 { - 24 +impl SbpMessage for MsgUartStateDepa { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgUartStateDepa { - const MESSAGE_TYPE: u16 = 24; - const MESSAGE_NAME: &'static str = "MSG_UART_STATE_DEPA"; -} -impl TryFrom for MsgUartStateDepa { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgUartStateDepa { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgUartStateDepa(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgUartStateDepa(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgUartStateDepa { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.uart_a.append_to_sbp_buffer(buf); - self.uart_b.append_to_sbp_buffer(buf); - self.uart_ftdi.append_to_sbp_buffer(buf); - self.latency.append_to_sbp_buffer(buf); +impl WireFormat for MsgUartStateDepa { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.uart_a) + + WireFormat::encoded_len(&self.uart_b) + + WireFormat::encoded_len(&self.uart_ftdi) + + WireFormat::encoded_len(&self.latency) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.uart_a.sbp_size(); - size += self.uart_b.sbp_size(); - size += self.uart_ftdi.sbp_size(); - size += self.latency.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.uart_a, buf); + WireFormat::write(&self.uart_b, buf); + WireFormat::write(&self.uart_ftdi, buf); + WireFormat::write(&self.latency, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgUartStateDepa { + sender_id: None, + uart_a: WireFormat::parse_unchecked(buf), + uart_b: WireFormat::parse_unchecked(buf), + uart_ftdi: WireFormat::parse_unchecked(buf), + latency: WireFormat::parse_unchecked(buf), + } } } @@ -2241,68 +1860,54 @@ impl crate::serialize::SbpSerialize for MsgUartStateDepa { /// may vary, both a timestamp and period field is provided, though may not /// necessarily be populated with a value. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct NetworkUsage { /// Duration over which the measurement was collected + #[cfg_attr(feature = "serde", serde(rename(serialize = "duration")))] pub duration: u64, /// Number of bytes handled in total within period + #[cfg_attr(feature = "serde", serde(rename(serialize = "total_bytes")))] pub total_bytes: u64, /// Number of bytes transmitted within period + #[cfg_attr(feature = "serde", serde(rename(serialize = "rx_bytes")))] pub rx_bytes: u32, /// Number of bytes received within period + #[cfg_attr(feature = "serde", serde(rename(serialize = "tx_bytes")))] pub tx_bytes: u32, /// Interface Name - pub interface_name: SbpString, -} - -impl NetworkUsage { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( NetworkUsage{ - duration: _buf.read_u64::()?, - total_bytes: _buf.read_u64::()?, - rx_bytes: _buf.read_u32::()?, - tx_bytes: _buf.read_u32::()?, - interface_name: crate::parser::read_string_limit(_buf, 16)?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(NetworkUsage::parse(buf)?); + #[cfg_attr(feature = "serde", serde(rename(serialize = "interface_name")))] + pub interface_name: SbpString<[u8; 16], Unterminated>, +} + +impl WireFormat for NetworkUsage { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.duration) + + WireFormat::encoded_len(&self.total_bytes) + + WireFormat::encoded_len(&self.rx_bytes) + + WireFormat::encoded_len(&self.tx_bytes) + + WireFormat::encoded_len(&self.interface_name) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.duration, buf); + WireFormat::write(&self.total_bytes, buf); + WireFormat::write(&self.rx_bytes, buf); + WireFormat::write(&self.tx_bytes, buf); + WireFormat::write(&self.interface_name, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + NetworkUsage { + duration: WireFormat::parse_unchecked(buf), + total_bytes: WireFormat::parse_unchecked(buf), + rx_bytes: WireFormat::parse_unchecked(buf), + tx_bytes: WireFormat::parse_unchecked(buf), + interface_name: WireFormat::parse_unchecked(buf), } - Ok(v) - } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(NetworkUsage::parse(buf)?); - } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for NetworkUsage { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.duration.append_to_sbp_buffer(buf); - self.total_bytes.append_to_sbp_buffer(buf); - self.rx_bytes.append_to_sbp_buffer(buf); - self.tx_bytes.append_to_sbp_buffer(buf); - self.interface_name.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.duration.sbp_size(); - size += self.total_bytes.sbp_size(); - size += self.rx_bytes.sbp_size(); - size += self.tx_bytes.sbp_size(); - size += self.interface_name.sbp_size(); - size } } @@ -2315,63 +1920,47 @@ impl crate::serialize::SbpSerialize for NetworkUsage { /// increase the period. Long periods can cause momentary RTK solution /// outages. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct Period { /// Average period + #[cfg_attr(feature = "serde", serde(rename(serialize = "avg")))] pub avg: i32, /// Minimum period + #[cfg_attr(feature = "serde", serde(rename(serialize = "pmin")))] pub pmin: i32, /// Maximum period + #[cfg_attr(feature = "serde", serde(rename(serialize = "pmax")))] pub pmax: i32, /// Smoothed estimate of the current period + #[cfg_attr(feature = "serde", serde(rename(serialize = "current")))] pub current: i32, } -impl Period { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( Period{ - avg: _buf.read_i32::()?, - pmin: _buf.read_i32::()?, - pmax: _buf.read_i32::()?, - current: _buf.read_i32::()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(Period::parse(buf)?); +impl WireFormat for Period { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.avg) + + WireFormat::encoded_len(&self.pmin) + + WireFormat::encoded_len(&self.pmax) + + WireFormat::encoded_len(&self.current) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.avg, buf); + WireFormat::write(&self.pmin, buf); + WireFormat::write(&self.pmax, buf); + WireFormat::write(&self.current, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + Period { + avg: WireFormat::parse_unchecked(buf), + pmin: WireFormat::parse_unchecked(buf), + pmax: WireFormat::parse_unchecked(buf), + current: WireFormat::parse_unchecked(buf), } - Ok(v) - } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(Period::parse(buf)?); - } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for Period { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.avg.append_to_sbp_buffer(buf); - self.pmin.append_to_sbp_buffer(buf); - self.pmax.append_to_sbp_buffer(buf); - self.current.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.avg.sbp_size(); - size += self.pmin.sbp_size(); - size += self.pmax.sbp_size(); - size += self.current.sbp_size(); - size } } @@ -2380,72 +1969,60 @@ impl crate::serialize::SbpSerialize for Period { /// Throughput, utilization, and error counts on the RX/TX buffers of this /// UART channel. The reported percentage values must be normalized. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct UARTChannel { /// UART transmit throughput + #[cfg_attr(feature = "serde", serde(rename(serialize = "tx_throughput")))] pub tx_throughput: f32, /// UART receive throughput + #[cfg_attr(feature = "serde", serde(rename(serialize = "rx_throughput")))] pub rx_throughput: f32, /// UART CRC error count + #[cfg_attr(feature = "serde", serde(rename(serialize = "crc_error_count")))] pub crc_error_count: u16, /// UART IO error count + #[cfg_attr(feature = "serde", serde(rename(serialize = "io_error_count")))] pub io_error_count: u16, /// UART transmit buffer percentage utilization (ranges from 0 to 255) + #[cfg_attr(feature = "serde", serde(rename(serialize = "tx_buffer_level")))] pub tx_buffer_level: u8, /// UART receive buffer percentage utilization (ranges from 0 to 255) + #[cfg_attr(feature = "serde", serde(rename(serialize = "rx_buffer_level")))] pub rx_buffer_level: u8, } -impl UARTChannel { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( UARTChannel{ - tx_throughput: _buf.read_f32::()?, - rx_throughput: _buf.read_f32::()?, - crc_error_count: _buf.read_u16::()?, - io_error_count: _buf.read_u16::()?, - tx_buffer_level: _buf.read_u8()?, - rx_buffer_level: _buf.read_u8()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(UARTChannel::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(UARTChannel::parse(buf)?); +impl WireFormat for UARTChannel { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tx_throughput) + + WireFormat::encoded_len(&self.rx_throughput) + + WireFormat::encoded_len(&self.crc_error_count) + + WireFormat::encoded_len(&self.io_error_count) + + WireFormat::encoded_len(&self.tx_buffer_level) + + WireFormat::encoded_len(&self.rx_buffer_level) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tx_throughput, buf); + WireFormat::write(&self.rx_throughput, buf); + WireFormat::write(&self.crc_error_count, buf); + WireFormat::write(&self.io_error_count, buf); + WireFormat::write(&self.tx_buffer_level, buf); + WireFormat::write(&self.rx_buffer_level, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + UARTChannel { + tx_throughput: WireFormat::parse_unchecked(buf), + rx_throughput: WireFormat::parse_unchecked(buf), + crc_error_count: WireFormat::parse_unchecked(buf), + io_error_count: WireFormat::parse_unchecked(buf), + tx_buffer_level: WireFormat::parse_unchecked(buf), + rx_buffer_level: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for UARTChannel { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tx_throughput.append_to_sbp_buffer(buf); - self.rx_throughput.append_to_sbp_buffer(buf); - self.crc_error_count.append_to_sbp_buffer(buf); - self.io_error_count.append_to_sbp_buffer(buf); - self.tx_buffer_level.append_to_sbp_buffer(buf); - self.rx_buffer_level.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tx_throughput.sbp_size(); - size += self.rx_throughput.sbp_size(); - size += self.crc_error_count.sbp_size(); - size += self.io_error_count.sbp_size(); - size += self.tx_buffer_level.sbp_size(); - size += self.rx_buffer_level.sbp_size(); - size } } diff --git a/rust/sbp/src/messages/sbas.rs b/rust/sbp/src/messages/sbas.rs index 058033051a..39ba6ed1f6 100644 --- a/rust/sbp/src/messages/sbas.rs +++ b/rust/sbp/src/messages/sbas.rs @@ -14,120 +14,98 @@ //****************************************************************************/ //! SBAS data -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - use super::gnss::*; -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; + +use super::lib::*; /// Raw SBAS data /// /// This message is sent once per second per SBAS satellite. ME checks the /// parity of the data block and sends only blocks that pass the check. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSbasRaw { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GNSS signal identifier. + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, /// GPS time-of-week at the start of the data block. + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// SBAS message type (0-63) + #[cfg_attr(feature = "serde", serde(rename(serialize = "message_type")))] pub message_type: u8, /// Raw SBAS data field of 212 bits (last byte padded with zeros). - pub data: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "data")))] + pub data: [u8; 27], } -impl MsgSbasRaw { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSbasRaw{ - sender_id: None, - sid: GnssSignal::parse(_buf)?, - tow: _buf.read_u32::()?, - message_type: _buf.read_u8()?, - data: crate::parser::read_u8_array_limit(_buf, 27)?, - } ) - } +impl ConcreteMessage for MsgSbasRaw { + const MESSAGE_TYPE: u16 = 30583; + const MESSAGE_NAME: &'static str = "MSG_SBAS_RAW"; } -impl super::SBPMessage for MsgSbasRaw { - fn get_message_name(&self) -> &'static str { - "MSG_SBAS_RAW" - } - fn get_message_type(&self) -> u16 { - 30583 +impl SbpMessage for MsgSbasRaw { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgSbasRaw { - const MESSAGE_TYPE: u16 = 30583; - const MESSAGE_NAME: &'static str = "MSG_SBAS_RAW"; -} -impl TryFrom for MsgSbasRaw { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSbasRaw { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSbasRaw(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSbasRaw(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSbasRaw { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sid.append_to_sbp_buffer(buf); - self.tow.append_to_sbp_buffer(buf); - self.message_type.append_to_sbp_buffer(buf); - self.data.append_to_sbp_buffer(buf); +impl WireFormat for MsgSbasRaw { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + <[u8; 27] as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.message_type) + + WireFormat::encoded_len(&self.data) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sid.sbp_size(); - size += self.tow.sbp_size(); - size += self.message_type.sbp_size(); - size += self.data.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.message_type, buf); + WireFormat::write(&self.data, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSbasRaw { + sender_id: None, + sid: WireFormat::parse_unchecked(buf), + tow: WireFormat::parse_unchecked(buf), + message_type: WireFormat::parse_unchecked(buf), + data: WireFormat::parse_unchecked(buf), + } } } diff --git a/rust/sbp/src/messages/settings.rs b/rust/sbp/src/messages/settings.rs index 9a693aeb9f..e32ba7fe46 100644 --- a/rust/sbp/src/messages/settings.rs +++ b/rust/sbp/src/messages/settings.rs @@ -39,86 +39,59 @@ //! saving settings in the piksi_tools repository on github as a helpful //! reference and example. -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; +use super::lib::*; /// Finished reading settings (host <= device) /// /// The settings message for indicating end of the settings values. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSettingsReadByIndexDone { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, } -impl MsgSettingsReadByIndexDone { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSettingsReadByIndexDone{ - sender_id: None, - } ) - } +impl ConcreteMessage for MsgSettingsReadByIndexDone { + const MESSAGE_TYPE: u16 = 166; + const MESSAGE_NAME: &'static str = "MSG_SETTINGS_READ_BY_INDEX_DONE"; } -impl super::SBPMessage for MsgSettingsReadByIndexDone { - fn get_message_name(&self) -> &'static str { - "MSG_SETTINGS_READ_BY_INDEX_DONE" - } - fn get_message_type(&self) -> u16 { - 166 +impl SbpMessage for MsgSettingsReadByIndexDone { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgSettingsReadByIndexDone { - const MESSAGE_TYPE: u16 = 166; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_READ_BY_INDEX_DONE"; } -impl TryFrom for MsgSettingsReadByIndexDone { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSettingsReadByIndexDone { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSettingsReadByIndexDone(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSettingsReadByIndexDone(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSettingsReadByIndexDone { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) {} - - fn sbp_size(&self) -> usize { +impl WireFormat for MsgSettingsReadByIndexDone { + const MIN_ENCODED_LEN: usize = 0; + fn encoded_len(&self) -> usize { 0 } + fn write(&self, _buf: &mut bytes::BytesMut) {} + fn parse_unchecked(_buf: &mut bytes::BytesMut) -> Self { + MsgSettingsReadByIndexDone { sender_id: None } + } } /// Read setting by direct index (host => device) @@ -126,78 +99,61 @@ impl crate::serialize::SbpSerialize for MsgSettingsReadByIndexDone { /// The settings message for iterating through the settings values. A device /// will respond to this message with a "MSG_SETTINGS_READ_BY_INDEX_RESP". /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSettingsReadByIndexReq { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// An index into the device settings, with values ranging from 0 to /// length(settings). + #[cfg_attr(feature = "serde", serde(rename(serialize = "index")))] pub index: u16, } -impl MsgSettingsReadByIndexReq { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSettingsReadByIndexReq{ - sender_id: None, - index: _buf.read_u16::()?, - } ) - } +impl ConcreteMessage for MsgSettingsReadByIndexReq { + const MESSAGE_TYPE: u16 = 162; + const MESSAGE_NAME: &'static str = "MSG_SETTINGS_READ_BY_INDEX_REQ"; } -impl super::SBPMessage for MsgSettingsReadByIndexReq { - fn get_message_name(&self) -> &'static str { - "MSG_SETTINGS_READ_BY_INDEX_REQ" - } - fn get_message_type(&self) -> u16 { - 162 +impl SbpMessage for MsgSettingsReadByIndexReq { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgSettingsReadByIndexReq { - const MESSAGE_TYPE: u16 = 162; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_READ_BY_INDEX_REQ"; } -impl TryFrom for MsgSettingsReadByIndexReq { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSettingsReadByIndexReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSettingsReadByIndexReq(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSettingsReadByIndexReq(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSettingsReadByIndexReq { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.index.append_to_sbp_buffer(buf); +impl WireFormat for MsgSettingsReadByIndexReq { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.index) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.index.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.index, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSettingsReadByIndexReq { + sender_id: None, + index: WireFormat::parse_unchecked(buf), + } } } @@ -214,84 +170,68 @@ impl crate::serialize::SbpSerialize for MsgSettingsReadByIndexReq { /// example string that could be sent from the device is /// "simulator\0enabled\0True\0enum:True,False\0". /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSettingsReadByIndexResp { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// An index into the device settings, with values ranging from 0 to /// length(settings) + #[cfg_attr(feature = "serde", serde(rename(serialize = "index")))] pub index: u16, /// A NULL-terminated and delimited string with contents /// "SECTION_SETTING\0SETTING\0VALUE\0FORMAT_TYPE\0" - pub setting: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] + pub setting: SbpString, Multipart>, } -impl MsgSettingsReadByIndexResp { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSettingsReadByIndexResp{ - sender_id: None, - index: _buf.read_u16::()?, - setting: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgSettingsReadByIndexResp { + const MESSAGE_TYPE: u16 = 167; + const MESSAGE_NAME: &'static str = "MSG_SETTINGS_READ_BY_INDEX_RESP"; } -impl super::SBPMessage for MsgSettingsReadByIndexResp { - fn get_message_name(&self) -> &'static str { - "MSG_SETTINGS_READ_BY_INDEX_RESP" - } - fn get_message_type(&self) -> u16 { - 167 +impl SbpMessage for MsgSettingsReadByIndexResp { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgSettingsReadByIndexResp { - const MESSAGE_TYPE: u16 = 167; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_READ_BY_INDEX_RESP"; } -impl TryFrom for MsgSettingsReadByIndexResp { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSettingsReadByIndexResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSettingsReadByIndexResp(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSettingsReadByIndexResp(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSettingsReadByIndexResp { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.index.append_to_sbp_buffer(buf); - self.setting.append_to_sbp_buffer(buf); +impl WireFormat for MsgSettingsReadByIndexResp { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + , Multipart> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.index) + WireFormat::encoded_len(&self.setting) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.index.sbp_size(); - size += self.setting.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.index, buf); + WireFormat::write(&self.setting, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSettingsReadByIndexResp { + sender_id: None, + index: WireFormat::parse_unchecked(buf), + setting: WireFormat::parse_unchecked(buf), + } } } @@ -306,78 +246,61 @@ impl crate::serialize::SbpSerialize for MsgSettingsReadByIndexResp { /// device should respond with a MSG_SETTINGS_READ_RESP message (msg_id /// 0x00A5). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSettingsReadReq { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// A NULL-terminated and NULL-delimited string with contents /// "SECTION_SETTING\0SETTING\0" - pub setting: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] + pub setting: SbpString, Multipart>, } -impl MsgSettingsReadReq { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSettingsReadReq{ - sender_id: None, - setting: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgSettingsReadReq { + const MESSAGE_TYPE: u16 = 164; + const MESSAGE_NAME: &'static str = "MSG_SETTINGS_READ_REQ"; } -impl super::SBPMessage for MsgSettingsReadReq { - fn get_message_name(&self) -> &'static str { - "MSG_SETTINGS_READ_REQ" - } - fn get_message_type(&self) -> u16 { - 164 +impl SbpMessage for MsgSettingsReadReq { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgSettingsReadReq { - const MESSAGE_TYPE: u16 = 164; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_READ_REQ"; -} -impl TryFrom for MsgSettingsReadReq { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSettingsReadReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSettingsReadReq(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSettingsReadReq(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSettingsReadReq { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.setting.append_to_sbp_buffer(buf); +impl WireFormat for MsgSettingsReadReq { + const MIN_ENCODED_LEN: usize = , Multipart> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.setting) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.setting.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.setting, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSettingsReadReq { + sender_id: None, + setting: WireFormat::parse_unchecked(buf), + } } } @@ -390,78 +313,61 @@ impl crate::serialize::SbpSerialize for MsgSettingsReadReq { /// the NULL character and where quotation marks are omitted. An example /// string that could be sent from device is "solution\0soln_freq\010\0". /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSettingsReadResp { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// A NULL-terminated and NULL-delimited string with contents /// "SECTION_SETTING\0SETTING\0VALUE\0" - pub setting: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] + pub setting: SbpString, Multipart>, } -impl MsgSettingsReadResp { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSettingsReadResp{ - sender_id: None, - setting: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgSettingsReadResp { + const MESSAGE_TYPE: u16 = 165; + const MESSAGE_NAME: &'static str = "MSG_SETTINGS_READ_RESP"; } -impl super::SBPMessage for MsgSettingsReadResp { - fn get_message_name(&self) -> &'static str { - "MSG_SETTINGS_READ_RESP" - } - fn get_message_type(&self) -> u16 { - 165 +impl SbpMessage for MsgSettingsReadResp { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgSettingsReadResp { - const MESSAGE_TYPE: u16 = 165; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_READ_RESP"; -} -impl TryFrom for MsgSettingsReadResp { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSettingsReadResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSettingsReadResp(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSettingsReadResp(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSettingsReadResp { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.setting.append_to_sbp_buffer(buf); +impl WireFormat for MsgSettingsReadResp { + const MIN_ENCODED_LEN: usize = , Multipart> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.setting) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.setting.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.setting, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSettingsReadResp { + sender_id: None, + setting: WireFormat::parse_unchecked(buf), + } } } @@ -471,78 +377,61 @@ impl crate::serialize::SbpSerialize for MsgSettingsReadResp { /// settings daemon. The host should reply with MSG_SETTINGS_WRITE for this /// setting to set the initial value. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSettingsRegister { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// A NULL-terminated and delimited string with contents /// "SECTION_SETTING\0SETTING\0VALUE". - pub setting: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] + pub setting: SbpString, Multipart>, } -impl MsgSettingsRegister { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSettingsRegister{ - sender_id: None, - setting: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgSettingsRegister { + const MESSAGE_TYPE: u16 = 174; + const MESSAGE_NAME: &'static str = "MSG_SETTINGS_REGISTER"; } -impl super::SBPMessage for MsgSettingsRegister { - fn get_message_name(&self) -> &'static str { - "MSG_SETTINGS_REGISTER" - } - fn get_message_type(&self) -> u16 { - 174 +impl SbpMessage for MsgSettingsRegister { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgSettingsRegister { - const MESSAGE_TYPE: u16 = 174; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_REGISTER"; } -impl TryFrom for MsgSettingsRegister { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSettingsRegister { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSettingsRegister(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSettingsRegister(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSettingsRegister { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.setting.append_to_sbp_buffer(buf); +impl WireFormat for MsgSettingsRegister { + const MIN_ENCODED_LEN: usize = , Multipart> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.setting) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.setting.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.setting, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSettingsRegister { + sender_id: None, + setting: WireFormat::parse_unchecked(buf), + } } } @@ -553,84 +442,68 @@ impl crate::serialize::SbpSerialize for MsgSettingsRegister { /// was already registered or is available in the permanent setting storage /// and had a different value. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSettingsRegisterResp { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Register status + #[cfg_attr(feature = "serde", serde(rename(serialize = "status")))] pub status: u8, /// A NULL-terminated and delimited string with contents /// "SECTION_SETTING\0SETTING\0VALUE". The meaning of value is defined /// according to the status field. - pub setting: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] + pub setting: SbpString, Multipart>, } -impl MsgSettingsRegisterResp { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSettingsRegisterResp{ - sender_id: None, - status: _buf.read_u8()?, - setting: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgSettingsRegisterResp { + const MESSAGE_TYPE: u16 = 431; + const MESSAGE_NAME: &'static str = "MSG_SETTINGS_REGISTER_RESP"; } -impl super::SBPMessage for MsgSettingsRegisterResp { - fn get_message_name(&self) -> &'static str { - "MSG_SETTINGS_REGISTER_RESP" - } - fn get_message_type(&self) -> u16 { - 431 +impl SbpMessage for MsgSettingsRegisterResp { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgSettingsRegisterResp { - const MESSAGE_TYPE: u16 = 431; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_REGISTER_RESP"; } -impl TryFrom for MsgSettingsRegisterResp { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSettingsRegisterResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSettingsRegisterResp(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSettingsRegisterResp(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSettingsRegisterResp { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.status.append_to_sbp_buffer(buf); - self.setting.append_to_sbp_buffer(buf); +impl WireFormat for MsgSettingsRegisterResp { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + , Multipart> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.status) + WireFormat::encoded_len(&self.setting) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.status.sbp_size(); - size += self.setting.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.status, buf); + WireFormat::write(&self.setting, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSettingsRegisterResp { + sender_id: None, + status: WireFormat::parse_unchecked(buf), + setting: WireFormat::parse_unchecked(buf), + } } } @@ -639,71 +512,53 @@ impl crate::serialize::SbpSerialize for MsgSettingsRegisterResp { /// The save settings message persists the device's current settings /// configuration to its onboard flash memory file system. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSettingsSave { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, } -impl MsgSettingsSave { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSettingsSave{ - sender_id: None, - } ) - } +impl ConcreteMessage for MsgSettingsSave { + const MESSAGE_TYPE: u16 = 161; + const MESSAGE_NAME: &'static str = "MSG_SETTINGS_SAVE"; } -impl super::SBPMessage for MsgSettingsSave { - fn get_message_name(&self) -> &'static str { - "MSG_SETTINGS_SAVE" - } - fn get_message_type(&self) -> u16 { - 161 +impl SbpMessage for MsgSettingsSave { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgSettingsSave { - const MESSAGE_TYPE: u16 = 161; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_SAVE"; } -impl TryFrom for MsgSettingsSave { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSettingsSave { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSettingsSave(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSettingsSave(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSettingsSave { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) {} - - fn sbp_size(&self) -> usize { +impl WireFormat for MsgSettingsSave { + const MIN_ENCODED_LEN: usize = 0; + fn encoded_len(&self) -> usize { 0 } + fn write(&self, _buf: &mut bytes::BytesMut) {} + fn parse_unchecked(_buf: &mut bytes::BytesMut) -> Self { + MsgSettingsSave { sender_id: None } + } } /// Write device configuration settings (host => device) @@ -716,78 +571,61 @@ impl crate::serialize::SbpSerialize for MsgSettingsSave { /// example string that could be sent to a device is /// "solution\0soln_freq\010\0". /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSettingsWrite { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// A NULL-terminated and NULL-delimited string with contents /// "SECTION_SETTING\0SETTING\0VALUE\0" - pub setting: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] + pub setting: SbpString, Multipart>, } -impl MsgSettingsWrite { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSettingsWrite{ - sender_id: None, - setting: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgSettingsWrite { + const MESSAGE_TYPE: u16 = 160; + const MESSAGE_NAME: &'static str = "MSG_SETTINGS_WRITE"; } -impl super::SBPMessage for MsgSettingsWrite { - fn get_message_name(&self) -> &'static str { - "MSG_SETTINGS_WRITE" - } - fn get_message_type(&self) -> u16 { - 160 +impl SbpMessage for MsgSettingsWrite { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgSettingsWrite { - const MESSAGE_TYPE: u16 = 160; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_WRITE"; } -impl TryFrom for MsgSettingsWrite { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSettingsWrite { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSettingsWrite(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSettingsWrite(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSettingsWrite { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.setting.append_to_sbp_buffer(buf); +impl WireFormat for MsgSettingsWrite { + const MIN_ENCODED_LEN: usize = , Multipart> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.setting) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.setting.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.setting, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSettingsWrite { + sender_id: None, + setting: WireFormat::parse_unchecked(buf), + } } } @@ -801,82 +639,66 @@ impl crate::serialize::SbpSerialize for MsgSettingsWrite { /// An example string that could be sent from device is /// "solution\0soln_freq\010\0". /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSettingsWriteResp { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Write status + #[cfg_attr(feature = "serde", serde(rename(serialize = "status")))] pub status: u8, /// A NULL-terminated and delimited string with contents /// "SECTION_SETTING\0SETTING\0VALUE\0" - pub setting: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] + pub setting: SbpString, Multipart>, } -impl MsgSettingsWriteResp { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSettingsWriteResp{ - sender_id: None, - status: _buf.read_u8()?, - setting: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgSettingsWriteResp { + const MESSAGE_TYPE: u16 = 175; + const MESSAGE_NAME: &'static str = "MSG_SETTINGS_WRITE_RESP"; } -impl super::SBPMessage for MsgSettingsWriteResp { - fn get_message_name(&self) -> &'static str { - "MSG_SETTINGS_WRITE_RESP" - } - fn get_message_type(&self) -> u16 { - 175 +impl SbpMessage for MsgSettingsWriteResp { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgSettingsWriteResp { - const MESSAGE_TYPE: u16 = 175; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_WRITE_RESP"; -} -impl TryFrom for MsgSettingsWriteResp { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSettingsWriteResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSettingsWriteResp(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSettingsWriteResp(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSettingsWriteResp { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.status.append_to_sbp_buffer(buf); - self.setting.append_to_sbp_buffer(buf); +impl WireFormat for MsgSettingsWriteResp { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + , Multipart> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.status) + WireFormat::encoded_len(&self.setting) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.status.sbp_size(); - size += self.setting.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.status, buf); + WireFormat::write(&self.setting, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSettingsWriteResp { + sender_id: None, + status: WireFormat::parse_unchecked(buf), + setting: WireFormat::parse_unchecked(buf), + } } } diff --git a/rust/sbp/src/messages/solution_meta.rs b/rust/sbp/src/messages/solution_meta.rs index 8497fe6a2a..80ad337e86 100644 --- a/rust/sbp/src/messages/solution_meta.rs +++ b/rust/sbp/src/messages/solution_meta.rs @@ -15,67 +15,33 @@ //! Standardized Metadata messages for Fuzed Solution from Swift Navigation //! devices. -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; +use super::lib::*; /// Instruments the physical type of GNSS sensor input to the fuzed solution /// /// Metadata around the GNSS sensors involved in the fuzed solution. -/// Accessible through sol_in[N].flags in a MSG_SOLN_META. +/// Accessible through sol_in\[N\].flags in a MSG_SOLN_META. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct GNSSInputType { +pub struct GnssInputType { /// flags that store all relevant info specific to this sensor type. + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl GNSSInputType { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( GNSSInputType{ - flags: _buf.read_u8()?, - } ) +impl WireFormat for GnssInputType { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.flags) } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(GNSSInputType::parse(buf)?); - } - Ok(v) + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.flags, buf); } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(GNSSInputType::parse(buf)?); + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + GnssInputType { + flags: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for GNSSInputType { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.flags.sbp_size(); - size } } @@ -83,50 +49,28 @@ impl crate::serialize::SbpSerialize for GNSSInputType { /// /// Metadata around the IMU sensors involved in the fuzed solution. Accessible -/// through sol_in[N].flags in a MSG_SOLN_META. +/// through sol_in\[N\].flags in a MSG_SOLN_META. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] -pub struct IMUInputType { +pub struct ImuInputType { /// Instrument time, grade, and architecture for a sensor. + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl IMUInputType { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( IMUInputType{ - flags: _buf.read_u8()?, - } ) +impl WireFormat for ImuInputType { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.flags) } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(IMUInputType::parse(buf)?); - } - Ok(v) + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.flags, buf); } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(IMUInputType::parse(buf)?); + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + ImuInputType { + flags: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for IMUInputType { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.flags.sbp_size(); - size } } @@ -142,127 +86,119 @@ impl crate::serialize::SbpSerialize for IMUInputType { /// complete in the Fusion Engine, when output solution is the last received /// valid GNSS solution and its tow is not a TOM. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSolnMeta { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS time of week rounded to the nearest millisecond + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// Position Dilution of Precision as per last available DOPS from PVT /// engine (0xFFFF indicates invalid) + #[cfg_attr(feature = "serde", serde(rename(serialize = "pdop")))] pub pdop: u16, /// Horizontal Dilution of Precision as per last available DOPS from PVT /// engine (0xFFFF indicates invalid) + #[cfg_attr(feature = "serde", serde(rename(serialize = "hdop")))] pub hdop: u16, /// Vertical Dilution of Precision as per last available DOPS from PVT /// engine (0xFFFF indicates invalid) + #[cfg_attr(feature = "serde", serde(rename(serialize = "vdop")))] pub vdop: u16, /// Age of corrections as per last available AGE_CORRECTIONS from PVT engine /// (0xFFFF indicates invalid) + #[cfg_attr(feature = "serde", serde(rename(serialize = "age_corrections")))] pub age_corrections: u16, /// Age and Time Status of the last received valid GNSS solution. + #[cfg_attr(feature = "serde", serde(rename(serialize = "age_gnss")))] pub age_gnss: u32, /// Array of Metadata describing the sensors potentially involved in the /// solution. Each element in the array represents a single sensor type and /// consists of flags containing (meta)data pertaining to that specific /// single sensor. Refer to each (XX)InputType descriptor in the present /// doc. + #[cfg_attr(feature = "serde", serde(rename(serialize = "sol_in")))] pub sol_in: Vec, } -impl MsgSolnMeta { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSolnMeta{ - sender_id: None, - tow: _buf.read_u32::()?, - pdop: _buf.read_u16::()?, - hdop: _buf.read_u16::()?, - vdop: _buf.read_u16::()?, - age_corrections: _buf.read_u16::()?, - age_gnss: _buf.read_u32::()?, - sol_in: SolutionInputType::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgSolnMeta { + const MESSAGE_TYPE: u16 = 65294; + const MESSAGE_NAME: &'static str = "MSG_SOLN_META"; } -impl super::SBPMessage for MsgSolnMeta { - fn get_message_name(&self) -> &'static str { - "MSG_SOLN_META" - } - fn get_message_type(&self) -> u16 { - 65294 +impl SbpMessage for MsgSolnMeta { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgSolnMeta { - const MESSAGE_TYPE: u16 = 65294; - const MESSAGE_NAME: &'static str = "MSG_SOLN_META"; -} -impl TryFrom for MsgSolnMeta { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSolnMeta { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSolnMeta(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSolnMeta(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSolnMeta { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.pdop.append_to_sbp_buffer(buf); - self.hdop.append_to_sbp_buffer(buf); - self.vdop.append_to_sbp_buffer(buf); - self.age_corrections.append_to_sbp_buffer(buf); - self.age_gnss.append_to_sbp_buffer(buf); - self.sol_in.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.pdop.sbp_size(); - size += self.hdop.sbp_size(); - size += self.vdop.sbp_size(); - size += self.age_corrections.sbp_size(); - size += self.age_gnss.sbp_size(); - size += self.sol_in.sbp_size(); - size +impl WireFormat for MsgSolnMeta { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.pdop) + + WireFormat::encoded_len(&self.hdop) + + WireFormat::encoded_len(&self.vdop) + + WireFormat::encoded_len(&self.age_corrections) + + WireFormat::encoded_len(&self.age_gnss) + + WireFormat::encoded_len(&self.sol_in) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.pdop, buf); + WireFormat::write(&self.hdop, buf); + WireFormat::write(&self.vdop, buf); + WireFormat::write(&self.age_corrections, buf); + WireFormat::write(&self.age_gnss, buf); + WireFormat::write(&self.sol_in, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSolnMeta { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + pdop: WireFormat::parse_unchecked(buf), + hdop: WireFormat::parse_unchecked(buf), + vdop: WireFormat::parse_unchecked(buf), + age_corrections: WireFormat::parse_unchecked(buf), + age_gnss: WireFormat::parse_unchecked(buf), + sol_in: WireFormat::parse_unchecked(buf), + } } } @@ -274,125 +210,124 @@ impl crate::serialize::SbpSerialize for MsgSolnMeta { /// in computing the Fuzed Solution. It focuses primarily, but not only, on /// GNSS metadata. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSolnMetaDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Position Dilution of Precision as per last available DOPS from PVT /// engine (0xFFFF indicates invalid) + #[cfg_attr(feature = "serde", serde(rename(serialize = "pdop")))] pub pdop: u16, /// Horizontal Dilution of Precision as per last available DOPS from PVT /// engine (0xFFFF indicates invalid) + #[cfg_attr(feature = "serde", serde(rename(serialize = "hdop")))] pub hdop: u16, /// Vertical Dilution of Precision as per last available DOPS from PVT /// engine (0xFFFF indicates invalid) + #[cfg_attr(feature = "serde", serde(rename(serialize = "vdop")))] pub vdop: u16, /// Number of satellites as per last available solution from PVT engine + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_sats")))] pub n_sats: u8, /// Age of corrections as per last available AGE_CORRECTIONS from PVT engine /// (0xFFFF indicates invalid) + #[cfg_attr(feature = "serde", serde(rename(serialize = "age_corrections")))] pub age_corrections: u16, /// State of alignment and the status and receipt of the alignment inputs + #[cfg_attr(feature = "serde", serde(rename(serialize = "alignment_status")))] pub alignment_status: u8, /// Tow of last-used GNSS position measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "last_used_gnss_pos_tow")))] pub last_used_gnss_pos_tow: u32, /// Tow of last-used GNSS velocity measurement + #[cfg_attr(feature = "serde", serde(rename(serialize = "last_used_gnss_vel_tow")))] pub last_used_gnss_vel_tow: u32, /// Array of Metadata describing the sensors potentially involved in the /// solution. Each element in the array represents a single sensor type and /// consists of flags containing (meta)data pertaining to that specific /// single sensor. Refer to each (XX)InputType descriptor in the present /// doc. + #[cfg_attr(feature = "serde", serde(rename(serialize = "sol_in")))] pub sol_in: Vec, } -impl MsgSolnMetaDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSolnMetaDepA{ - sender_id: None, - pdop: _buf.read_u16::()?, - hdop: _buf.read_u16::()?, - vdop: _buf.read_u16::()?, - n_sats: _buf.read_u8()?, - age_corrections: _buf.read_u16::()?, - alignment_status: _buf.read_u8()?, - last_used_gnss_pos_tow: _buf.read_u32::()?, - last_used_gnss_vel_tow: _buf.read_u32::()?, - sol_in: SolutionInputType::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgSolnMetaDepA { + const MESSAGE_TYPE: u16 = 65295; + const MESSAGE_NAME: &'static str = "MSG_SOLN_META_DEP_A"; } -impl super::SBPMessage for MsgSolnMetaDepA { - fn get_message_name(&self) -> &'static str { - "MSG_SOLN_META_DEP_A" - } - fn get_message_type(&self) -> u16 { - 65295 +impl SbpMessage for MsgSolnMetaDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgSolnMetaDepA { - const MESSAGE_TYPE: u16 = 65295; - const MESSAGE_NAME: &'static str = "MSG_SOLN_META_DEP_A"; -} -impl TryFrom for MsgSolnMetaDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSolnMetaDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSolnMetaDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSolnMetaDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSolnMetaDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.pdop.append_to_sbp_buffer(buf); - self.hdop.append_to_sbp_buffer(buf); - self.vdop.append_to_sbp_buffer(buf); - self.n_sats.append_to_sbp_buffer(buf); - self.age_corrections.append_to_sbp_buffer(buf); - self.alignment_status.append_to_sbp_buffer(buf); - self.last_used_gnss_pos_tow.append_to_sbp_buffer(buf); - self.last_used_gnss_vel_tow.append_to_sbp_buffer(buf); - self.sol_in.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.pdop.sbp_size(); - size += self.hdop.sbp_size(); - size += self.vdop.sbp_size(); - size += self.n_sats.sbp_size(); - size += self.age_corrections.sbp_size(); - size += self.alignment_status.sbp_size(); - size += self.last_used_gnss_pos_tow.sbp_size(); - size += self.last_used_gnss_vel_tow.sbp_size(); - size += self.sol_in.sbp_size(); - size +impl WireFormat for MsgSolnMetaDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.pdop) + + WireFormat::encoded_len(&self.hdop) + + WireFormat::encoded_len(&self.vdop) + + WireFormat::encoded_len(&self.n_sats) + + WireFormat::encoded_len(&self.age_corrections) + + WireFormat::encoded_len(&self.alignment_status) + + WireFormat::encoded_len(&self.last_used_gnss_pos_tow) + + WireFormat::encoded_len(&self.last_used_gnss_vel_tow) + + WireFormat::encoded_len(&self.sol_in) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.pdop, buf); + WireFormat::write(&self.hdop, buf); + WireFormat::write(&self.vdop, buf); + WireFormat::write(&self.n_sats, buf); + WireFormat::write(&self.age_corrections, buf); + WireFormat::write(&self.alignment_status, buf); + WireFormat::write(&self.last_used_gnss_pos_tow, buf); + WireFormat::write(&self.last_used_gnss_vel_tow, buf); + WireFormat::write(&self.sol_in, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSolnMetaDepA { + sender_id: None, + pdop: WireFormat::parse_unchecked(buf), + hdop: WireFormat::parse_unchecked(buf), + vdop: WireFormat::parse_unchecked(buf), + n_sats: WireFormat::parse_unchecked(buf), + age_corrections: WireFormat::parse_unchecked(buf), + alignment_status: WireFormat::parse_unchecked(buf), + last_used_gnss_pos_tow: WireFormat::parse_unchecked(buf), + last_used_gnss_vel_tow: WireFormat::parse_unchecked(buf), + sol_in: WireFormat::parse_unchecked(buf), + } } } @@ -400,50 +335,28 @@ impl crate::serialize::SbpSerialize for MsgSolnMetaDepA { /// /// Metadata around the Odometry sensors involved in the fuzed solution. -/// Accessible through sol_in[N].flags in a MSG_SOLN_META. +/// Accessible through sol_in\[N\].flags in a MSG_SOLN_META. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct OdoInputType { /// Instrument ODO rate, grade, and quality. + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl OdoInputType { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( OdoInputType{ - flags: _buf.read_u8()?, - } ) +impl WireFormat for OdoInputType { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.flags) } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(OdoInputType::parse(buf)?); - } - Ok(v) + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.flags, buf); } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(OdoInputType::parse(buf)?); + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + OdoInputType { + flags: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for OdoInputType { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.flags.sbp_size(); - size } } @@ -457,55 +370,31 @@ impl crate::serialize::SbpSerialize for OdoInputType { /// flags, for each sensor type, is described in the relevant structures in /// this section. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct SolutionInputType { /// The type of sensor + #[cfg_attr(feature = "serde", serde(rename(serialize = "sensor_type")))] pub sensor_type: u8, /// Refer to each InputType description + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl SolutionInputType { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( SolutionInputType{ - sensor_type: _buf.read_u8()?, - flags: _buf.read_u8()?, - } ) +impl WireFormat for SolutionInputType { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sensor_type) + WireFormat::encoded_len(&self.flags) } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(SolutionInputType::parse(buf)?); - } - Ok(v) + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sensor_type, buf); + WireFormat::write(&self.flags, buf); } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(SolutionInputType::parse(buf)?); + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + SolutionInputType { + sensor_type: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for SolutionInputType { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sensor_type.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sensor_type.sbp_size(); - size += self.flags.sbp_size(); - size } } diff --git a/rust/sbp/src/messages/ssr.rs b/rust/sbp/src/messages/ssr.rs index 8fe8fcb018..2842571f5f 100644 --- a/rust/sbp/src/messages/ssr.rs +++ b/rust/sbp/src/messages/ssr.rs @@ -14,74 +14,42 @@ //****************************************************************************/ //! Precise State Space Representation (SSR) corrections format -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - use super::gnss::*; -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; + +use super::lib::*; /// SSR code biases corrections for a particular satellite /// /// Code biases are to be added to pseudorange. The corrections conform with /// RTCMv3 MT 1059 / 1065. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct CodeBiasesContent { /// Signal encoded following RTCM specifications (DF380, DF381, DF382 and /// DF467). + #[cfg_attr(feature = "serde", serde(rename(serialize = "code")))] pub code: u8, /// Code bias value + #[cfg_attr(feature = "serde", serde(rename(serialize = "value")))] pub value: i16, } -impl CodeBiasesContent { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( CodeBiasesContent{ - code: _buf.read_u8()?, - value: _buf.read_i16::()?, - } ) +impl WireFormat for CodeBiasesContent { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.code) + WireFormat::encoded_len(&self.value) } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(CodeBiasesContent::parse(buf)?); - } - Ok(v) + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.code, buf); + WireFormat::write(&self.value, buf); } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(CodeBiasesContent::parse(buf)?); + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + CodeBiasesContent { + code: WireFormat::parse_unchecked(buf), + value: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for CodeBiasesContent { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.code.append_to_sbp_buffer(buf); - self.value.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.code.sbp_size(); - size += self.value.sbp_size(); - size } } @@ -90,78 +58,63 @@ impl crate::serialize::SbpSerialize for CodeBiasesContent { /// Defines the grid for MSG_SSR_GRIDDED_CORRECTION messages. Also includes an /// RLE encoded validity list. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct GridDefinitionHeaderDepA { /// region_size (deg) = 10 / region_size_inverse 0 is an invalid value. + #[cfg_attr(feature = "serde", serde(rename(serialize = "region_size_inverse")))] pub region_size_inverse: u8, /// grid height (deg) = grid width (deg) = area_width / region_size 0 is an /// invalid value. + #[cfg_attr(feature = "serde", serde(rename(serialize = "area_width")))] pub area_width: u16, /// North-West corner latitude (deg) = region_size * lat_nw_corner_enc - 90 + #[cfg_attr(feature = "serde", serde(rename(serialize = "lat_nw_corner_enc")))] pub lat_nw_corner_enc: u16, /// North-West corner longitude (deg) = region_size * lon_nw_corner_enc - /// 180 + #[cfg_attr(feature = "serde", serde(rename(serialize = "lon_nw_corner_enc")))] pub lon_nw_corner_enc: u16, /// Number of messages in the dataset + #[cfg_attr(feature = "serde", serde(rename(serialize = "num_msgs")))] pub num_msgs: u8, /// Position of this message in the dataset + #[cfg_attr(feature = "serde", serde(rename(serialize = "seq_num")))] pub seq_num: u8, } -impl GridDefinitionHeaderDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( GridDefinitionHeaderDepA{ - region_size_inverse: _buf.read_u8()?, - area_width: _buf.read_u16::()?, - lat_nw_corner_enc: _buf.read_u16::()?, - lon_nw_corner_enc: _buf.read_u16::()?, - num_msgs: _buf.read_u8()?, - seq_num: _buf.read_u8()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(GridDefinitionHeaderDepA::parse(buf)?); +impl WireFormat for GridDefinitionHeaderDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.region_size_inverse) + + WireFormat::encoded_len(&self.area_width) + + WireFormat::encoded_len(&self.lat_nw_corner_enc) + + WireFormat::encoded_len(&self.lon_nw_corner_enc) + + WireFormat::encoded_len(&self.num_msgs) + + WireFormat::encoded_len(&self.seq_num) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.region_size_inverse, buf); + WireFormat::write(&self.area_width, buf); + WireFormat::write(&self.lat_nw_corner_enc, buf); + WireFormat::write(&self.lon_nw_corner_enc, buf); + WireFormat::write(&self.num_msgs, buf); + WireFormat::write(&self.seq_num, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + GridDefinitionHeaderDepA { + region_size_inverse: WireFormat::parse_unchecked(buf), + area_width: WireFormat::parse_unchecked(buf), + lat_nw_corner_enc: WireFormat::parse_unchecked(buf), + lon_nw_corner_enc: WireFormat::parse_unchecked(buf), + num_msgs: WireFormat::parse_unchecked(buf), + seq_num: WireFormat::parse_unchecked(buf), } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(GridDefinitionHeaderDepA::parse(buf)?); - } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for GridDefinitionHeaderDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.region_size_inverse.append_to_sbp_buffer(buf); - self.area_width.append_to_sbp_buffer(buf); - self.lat_nw_corner_enc.append_to_sbp_buffer(buf); - self.lon_nw_corner_enc.append_to_sbp_buffer(buf); - self.num_msgs.append_to_sbp_buffer(buf); - self.seq_num.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.region_size_inverse.sbp_size(); - size += self.area_width.sbp_size(); - size += self.lat_nw_corner_enc.sbp_size(); - size += self.lon_nw_corner_enc.sbp_size(); - size += self.num_msgs.sbp_size(); - size += self.seq_num.sbp_size(); - size } } @@ -170,88 +123,80 @@ impl crate::serialize::SbpSerialize for GridDefinitionHeaderDepA { /// The LPP message contains nested variable length arrays which are not /// supported in SBP, so each grid point will be identified by the index. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct GriddedCorrectionHeader { /// Unique identifier of the tile set this tile belongs to. + #[cfg_attr(feature = "serde", serde(rename(serialize = "tile_set_id")))] pub tile_set_id: u16, /// Unique identifier of this tile in the tile set. + #[cfg_attr(feature = "serde", serde(rename(serialize = "tile_id")))] pub tile_id: u16, /// GNSS reference time of the correction - pub time: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "time")))] + pub time: GpsTimeSec, /// Number of messages in the dataset + #[cfg_attr(feature = "serde", serde(rename(serialize = "num_msgs")))] pub num_msgs: u16, /// Position of this message in the dataset + #[cfg_attr(feature = "serde", serde(rename(serialize = "seq_num")))] pub seq_num: u16, /// Update interval between consecutive corrections. Encoded following RTCM /// DF391 specification. + #[cfg_attr(feature = "serde", serde(rename(serialize = "update_interval")))] pub update_interval: u8, /// IOD of the SSR atmospheric correction + #[cfg_attr(feature = "serde", serde(rename(serialize = "iod_atmo")))] pub iod_atmo: u8, /// Quality of the troposphere data. Encoded following RTCM DF389 /// specification in units of m. + #[cfg_attr( + feature = "serde", + serde(rename(serialize = "tropo_quality_indicator")) + )] pub tropo_quality_indicator: u8, } -impl GriddedCorrectionHeader { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( GriddedCorrectionHeader{ - tile_set_id: _buf.read_u16::()?, - tile_id: _buf.read_u16::()?, - time: GPSTimeSec::parse(_buf)?, - num_msgs: _buf.read_u16::()?, - seq_num: _buf.read_u16::()?, - update_interval: _buf.read_u8()?, - iod_atmo: _buf.read_u8()?, - tropo_quality_indicator: _buf.read_u8()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(GriddedCorrectionHeader::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(GriddedCorrectionHeader::parse(buf)?); +impl WireFormat for GriddedCorrectionHeader { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tile_set_id) + + WireFormat::encoded_len(&self.tile_id) + + WireFormat::encoded_len(&self.time) + + WireFormat::encoded_len(&self.num_msgs) + + WireFormat::encoded_len(&self.seq_num) + + WireFormat::encoded_len(&self.update_interval) + + WireFormat::encoded_len(&self.iod_atmo) + + WireFormat::encoded_len(&self.tropo_quality_indicator) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tile_set_id, buf); + WireFormat::write(&self.tile_id, buf); + WireFormat::write(&self.time, buf); + WireFormat::write(&self.num_msgs, buf); + WireFormat::write(&self.seq_num, buf); + WireFormat::write(&self.update_interval, buf); + WireFormat::write(&self.iod_atmo, buf); + WireFormat::write(&self.tropo_quality_indicator, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + GriddedCorrectionHeader { + tile_set_id: WireFormat::parse_unchecked(buf), + tile_id: WireFormat::parse_unchecked(buf), + time: WireFormat::parse_unchecked(buf), + num_msgs: WireFormat::parse_unchecked(buf), + seq_num: WireFormat::parse_unchecked(buf), + update_interval: WireFormat::parse_unchecked(buf), + iod_atmo: WireFormat::parse_unchecked(buf), + tropo_quality_indicator: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for GriddedCorrectionHeader { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tile_set_id.append_to_sbp_buffer(buf); - self.tile_id.append_to_sbp_buffer(buf); - self.time.append_to_sbp_buffer(buf); - self.num_msgs.append_to_sbp_buffer(buf); - self.seq_num.append_to_sbp_buffer(buf); - self.update_interval.append_to_sbp_buffer(buf); - self.iod_atmo.append_to_sbp_buffer(buf); - self.tropo_quality_indicator.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tile_set_id.sbp_size(); - size += self.tile_id.sbp_size(); - size += self.time.sbp_size(); - size += self.num_msgs.sbp_size(); - size += self.seq_num.sbp_size(); - size += self.update_interval.sbp_size(); - size += self.iod_atmo.sbp_size(); - size += self.tropo_quality_indicator.sbp_size(); - size } } @@ -260,78 +205,66 @@ impl crate::serialize::SbpSerialize for GriddedCorrectionHeader { /// The 3GPP message contains nested variable length arrays which are not /// supported in SBP, so each grid point will be identified by the index. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct GriddedCorrectionHeaderDepA { /// GNSS reference time of the correction - pub time: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "time")))] + pub time: GpsTimeSec, /// Number of messages in the dataset + #[cfg_attr(feature = "serde", serde(rename(serialize = "num_msgs")))] pub num_msgs: u16, /// Position of this message in the dataset + #[cfg_attr(feature = "serde", serde(rename(serialize = "seq_num")))] pub seq_num: u16, /// Update interval between consecutive corrections. Encoded following RTCM /// DF391 specification. + #[cfg_attr(feature = "serde", serde(rename(serialize = "update_interval")))] pub update_interval: u8, /// IOD of the SSR atmospheric correction + #[cfg_attr(feature = "serde", serde(rename(serialize = "iod_atmo")))] pub iod_atmo: u8, /// Quality of the troposphere data. Encoded following RTCM DF389 /// specification in units of m. + #[cfg_attr( + feature = "serde", + serde(rename(serialize = "tropo_quality_indicator")) + )] pub tropo_quality_indicator: u8, } -impl GriddedCorrectionHeaderDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( GriddedCorrectionHeaderDepA{ - time: GPSTimeSec::parse(_buf)?, - num_msgs: _buf.read_u16::()?, - seq_num: _buf.read_u16::()?, - update_interval: _buf.read_u8()?, - iod_atmo: _buf.read_u8()?, - tropo_quality_indicator: _buf.read_u8()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(GriddedCorrectionHeaderDepA::parse(buf)?); +impl WireFormat for GriddedCorrectionHeaderDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.time) + + WireFormat::encoded_len(&self.num_msgs) + + WireFormat::encoded_len(&self.seq_num) + + WireFormat::encoded_len(&self.update_interval) + + WireFormat::encoded_len(&self.iod_atmo) + + WireFormat::encoded_len(&self.tropo_quality_indicator) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.time, buf); + WireFormat::write(&self.num_msgs, buf); + WireFormat::write(&self.seq_num, buf); + WireFormat::write(&self.update_interval, buf); + WireFormat::write(&self.iod_atmo, buf); + WireFormat::write(&self.tropo_quality_indicator, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + GriddedCorrectionHeaderDepA { + time: WireFormat::parse_unchecked(buf), + num_msgs: WireFormat::parse_unchecked(buf), + seq_num: WireFormat::parse_unchecked(buf), + update_interval: WireFormat::parse_unchecked(buf), + iod_atmo: WireFormat::parse_unchecked(buf), + tropo_quality_indicator: WireFormat::parse_unchecked(buf), } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(GriddedCorrectionHeaderDepA::parse(buf)?); - } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for GriddedCorrectionHeaderDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.time.append_to_sbp_buffer(buf); - self.num_msgs.append_to_sbp_buffer(buf); - self.seq_num.append_to_sbp_buffer(buf); - self.update_interval.append_to_sbp_buffer(buf); - self.iod_atmo.append_to_sbp_buffer(buf); - self.tropo_quality_indicator.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.time.sbp_size(); - size += self.num_msgs.sbp_size(); - size += self.seq_num.sbp_size(); - size += self.update_interval.sbp_size(); - size += self.iod_atmo.sbp_size(); - size += self.tropo_quality_indicator.sbp_size(); - size } } @@ -341,99 +274,90 @@ impl crate::serialize::SbpSerialize for GriddedCorrectionHeaderDepA { /// corresponding signal to get corrected pseudorange. It is an equivalent to /// the 1059 / 1065 RTCM message types. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSsrCodeBiases { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GNSS reference time of the correction - pub time: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "time")))] + pub time: GpsTimeSec, /// GNSS signal identifier (16 bit) + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, /// Update interval between consecutive corrections. Encoded following RTCM /// DF391 specification. + #[cfg_attr(feature = "serde", serde(rename(serialize = "update_interval")))] pub update_interval: u8, /// IOD of the SSR correction. A change of Issue Of Data SSR is used to /// indicate a change in the SSR generating configuration + #[cfg_attr(feature = "serde", serde(rename(serialize = "iod_ssr")))] pub iod_ssr: u8, /// Code biases for the different satellite signals + #[cfg_attr(feature = "serde", serde(rename(serialize = "biases")))] pub biases: Vec, } -impl MsgSsrCodeBiases { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSsrCodeBiases{ - sender_id: None, - time: GPSTimeSec::parse(_buf)?, - sid: GnssSignal::parse(_buf)?, - update_interval: _buf.read_u8()?, - iod_ssr: _buf.read_u8()?, - biases: CodeBiasesContent::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgSsrCodeBiases { + const MESSAGE_TYPE: u16 = 1505; + const MESSAGE_NAME: &'static str = "MSG_SSR_CODE_BIASES"; } -impl super::SBPMessage for MsgSsrCodeBiases { - fn get_message_name(&self) -> &'static str { - "MSG_SSR_CODE_BIASES" - } - fn get_message_type(&self) -> u16 { - 1505 +impl SbpMessage for MsgSsrCodeBiases { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgSsrCodeBiases { - const MESSAGE_TYPE: u16 = 1505; - const MESSAGE_NAME: &'static str = "MSG_SSR_CODE_BIASES"; -} -impl TryFrom for MsgSsrCodeBiases { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSsrCodeBiases { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSsrCodeBiases(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSsrCodeBiases(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSsrCodeBiases { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.time.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - self.update_interval.append_to_sbp_buffer(buf); - self.iod_ssr.append_to_sbp_buffer(buf); - self.biases.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.time.sbp_size(); - size += self.sid.sbp_size(); - size += self.update_interval.sbp_size(); - size += self.iod_ssr.sbp_size(); - size += self.biases.sbp_size(); - size +impl WireFormat for MsgSsrCodeBiases { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.time) + + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.update_interval) + + WireFormat::encoded_len(&self.iod_ssr) + + WireFormat::encoded_len(&self.biases) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.time, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.update_interval, buf); + WireFormat::write(&self.iod_ssr, buf); + WireFormat::write(&self.biases, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSsrCodeBiases { + sender_id: None, + time: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + update_interval: WireFormat::parse_unchecked(buf), + iod_ssr: WireFormat::parse_unchecked(buf), + biases: WireFormat::parse_unchecked(buf), + } } } @@ -443,352 +367,306 @@ impl crate::serialize::SbpSerialize for MsgSsrCodeBiases { /// /// It is typically equivalent to the QZSS CLAS Sub Type 9 messages. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSsrGriddedCorrection { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Header of a gridded correction message + #[cfg_attr(feature = "serde", serde(rename(serialize = "header")))] pub header: GriddedCorrectionHeader, /// Index of the grid point. + #[cfg_attr(feature = "serde", serde(rename(serialize = "index")))] pub index: u16, /// Wet and hydrostatic vertical delays (mean, stddev). + #[cfg_attr(feature = "serde", serde(rename(serialize = "tropo_delay_correction")))] pub tropo_delay_correction: TroposphericDelayCorrection, /// STEC residuals for each satellite (mean, stddev). + #[cfg_attr(feature = "serde", serde(rename(serialize = "stec_residuals")))] pub stec_residuals: Vec, } -impl MsgSsrGriddedCorrection { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSsrGriddedCorrection{ - sender_id: None, - header: GriddedCorrectionHeader::parse(_buf)?, - index: _buf.read_u16::()?, - tropo_delay_correction: TroposphericDelayCorrection::parse(_buf)?, - stec_residuals: STECResidual::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgSsrGriddedCorrection { + const MESSAGE_TYPE: u16 = 1532; + const MESSAGE_NAME: &'static str = "MSG_SSR_GRIDDED_CORRECTION"; } -impl super::SBPMessage for MsgSsrGriddedCorrection { - fn get_message_name(&self) -> &'static str { - "MSG_SSR_GRIDDED_CORRECTION" - } - fn get_message_type(&self) -> u16 { - 1532 +impl SbpMessage for MsgSsrGriddedCorrection { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgSsrGriddedCorrection { - const MESSAGE_TYPE: u16 = 1532; - const MESSAGE_NAME: &'static str = "MSG_SSR_GRIDDED_CORRECTION"; } -impl TryFrom for MsgSsrGriddedCorrection { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSsrGriddedCorrection { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSsrGriddedCorrection(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSsrGriddedCorrection(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSsrGriddedCorrection { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.header.append_to_sbp_buffer(buf); - self.index.append_to_sbp_buffer(buf); - self.tropo_delay_correction.append_to_sbp_buffer(buf); - self.stec_residuals.append_to_sbp_buffer(buf); +impl WireFormat for MsgSsrGriddedCorrection { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.header) + + WireFormat::encoded_len(&self.index) + + WireFormat::encoded_len(&self.tropo_delay_correction) + + WireFormat::encoded_len(&self.stec_residuals) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.header.sbp_size(); - size += self.index.sbp_size(); - size += self.tropo_delay_correction.sbp_size(); - size += self.stec_residuals.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.header, buf); + WireFormat::write(&self.index, buf); + WireFormat::write(&self.tropo_delay_correction, buf); + WireFormat::write(&self.stec_residuals, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSsrGriddedCorrection { + sender_id: None, + header: WireFormat::parse_unchecked(buf), + index: WireFormat::parse_unchecked(buf), + tropo_delay_correction: WireFormat::parse_unchecked(buf), + stec_residuals: WireFormat::parse_unchecked(buf), + } } } -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +/// Deprecated +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSsrGriddedCorrectionDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Header of a Gridded Correction message + #[cfg_attr(feature = "serde", serde(rename(serialize = "header")))] pub header: GriddedCorrectionHeaderDepA, /// Index of the grid point + #[cfg_attr(feature = "serde", serde(rename(serialize = "index")))] pub index: u16, /// Wet and hydrostatic vertical delays (mean, stddev) + #[cfg_attr(feature = "serde", serde(rename(serialize = "tropo_delay_correction")))] pub tropo_delay_correction: TroposphericDelayCorrection, /// STEC residuals for each satellite (mean, stddev) + #[cfg_attr(feature = "serde", serde(rename(serialize = "stec_residuals")))] pub stec_residuals: Vec, } -impl MsgSsrGriddedCorrectionDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSsrGriddedCorrectionDepA{ - sender_id: None, - header: GriddedCorrectionHeaderDepA::parse(_buf)?, - index: _buf.read_u16::()?, - tropo_delay_correction: TroposphericDelayCorrection::parse(_buf)?, - stec_residuals: STECResidual::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgSsrGriddedCorrectionDepA { + const MESSAGE_TYPE: u16 = 1530; + const MESSAGE_NAME: &'static str = "MSG_SSR_GRIDDED_CORRECTION_DEP_A"; } -impl super::SBPMessage for MsgSsrGriddedCorrectionDepA { - fn get_message_name(&self) -> &'static str { - "MSG_SSR_GRIDDED_CORRECTION_DEP_A" - } - fn get_message_type(&self) -> u16 { - 1530 +impl SbpMessage for MsgSsrGriddedCorrectionDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgSsrGriddedCorrectionDepA { - const MESSAGE_TYPE: u16 = 1530; - const MESSAGE_NAME: &'static str = "MSG_SSR_GRIDDED_CORRECTION_DEP_A"; } -impl TryFrom for MsgSsrGriddedCorrectionDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSsrGriddedCorrectionDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSsrGriddedCorrectionDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSsrGriddedCorrectionDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSsrGriddedCorrectionDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.header.append_to_sbp_buffer(buf); - self.index.append_to_sbp_buffer(buf); - self.tropo_delay_correction.append_to_sbp_buffer(buf); - self.stec_residuals.append_to_sbp_buffer(buf); +impl WireFormat for MsgSsrGriddedCorrectionDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.header) + + WireFormat::encoded_len(&self.index) + + WireFormat::encoded_len(&self.tropo_delay_correction) + + WireFormat::encoded_len(&self.stec_residuals) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.header.sbp_size(); - size += self.index.sbp_size(); - size += self.tropo_delay_correction.sbp_size(); - size += self.stec_residuals.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.header, buf); + WireFormat::write(&self.index, buf); + WireFormat::write(&self.tropo_delay_correction, buf); + WireFormat::write(&self.stec_residuals, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSsrGriddedCorrectionDepA { + sender_id: None, + header: WireFormat::parse_unchecked(buf), + index: WireFormat::parse_unchecked(buf), + tropo_delay_correction: WireFormat::parse_unchecked(buf), + stec_residuals: WireFormat::parse_unchecked(buf), + } } } -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +/// Deprecated +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSsrGriddedCorrectionNoStdDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Header of a Gridded Correction message + #[cfg_attr(feature = "serde", serde(rename(serialize = "header")))] pub header: GriddedCorrectionHeaderDepA, /// Index of the grid point + #[cfg_attr(feature = "serde", serde(rename(serialize = "index")))] pub index: u16, /// Wet and hydrostatic vertical delays + #[cfg_attr(feature = "serde", serde(rename(serialize = "tropo_delay_correction")))] pub tropo_delay_correction: TroposphericDelayCorrectionNoStd, /// STEC residuals for each satellite + #[cfg_attr(feature = "serde", serde(rename(serialize = "stec_residuals")))] pub stec_residuals: Vec, } -impl MsgSsrGriddedCorrectionNoStdDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSsrGriddedCorrectionNoStdDepA{ - sender_id: None, - header: GriddedCorrectionHeaderDepA::parse(_buf)?, - index: _buf.read_u16::()?, - tropo_delay_correction: TroposphericDelayCorrectionNoStd::parse(_buf)?, - stec_residuals: STECResidualNoStd::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgSsrGriddedCorrectionNoStdDepA { + const MESSAGE_TYPE: u16 = 1520; + const MESSAGE_NAME: &'static str = "MSG_SSR_GRIDDED_CORRECTION_NO_STD_DEP_A"; } -impl super::SBPMessage for MsgSsrGriddedCorrectionNoStdDepA { - fn get_message_name(&self) -> &'static str { - "MSG_SSR_GRIDDED_CORRECTION_NO_STD_DEP_A" - } - fn get_message_type(&self) -> u16 { - 1520 +impl SbpMessage for MsgSsrGriddedCorrectionNoStdDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgSsrGriddedCorrectionNoStdDepA { - const MESSAGE_TYPE: u16 = 1520; - const MESSAGE_NAME: &'static str = "MSG_SSR_GRIDDED_CORRECTION_NO_STD_DEP_A"; } -impl TryFrom for MsgSsrGriddedCorrectionNoStdDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSsrGriddedCorrectionNoStdDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSsrGriddedCorrectionNoStdDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSsrGriddedCorrectionNoStdDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSsrGriddedCorrectionNoStdDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.header.append_to_sbp_buffer(buf); - self.index.append_to_sbp_buffer(buf); - self.tropo_delay_correction.append_to_sbp_buffer(buf); - self.stec_residuals.append_to_sbp_buffer(buf); +impl WireFormat for MsgSsrGriddedCorrectionNoStdDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.header) + + WireFormat::encoded_len(&self.index) + + WireFormat::encoded_len(&self.tropo_delay_correction) + + WireFormat::encoded_len(&self.stec_residuals) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.header.sbp_size(); - size += self.index.sbp_size(); - size += self.tropo_delay_correction.sbp_size(); - size += self.stec_residuals.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.header, buf); + WireFormat::write(&self.index, buf); + WireFormat::write(&self.tropo_delay_correction, buf); + WireFormat::write(&self.stec_residuals, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSsrGriddedCorrectionNoStdDepA { + sender_id: None, + header: WireFormat::parse_unchecked(buf), + index: WireFormat::parse_unchecked(buf), + tropo_delay_correction: WireFormat::parse_unchecked(buf), + stec_residuals: WireFormat::parse_unchecked(buf), + } } } -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +/// Deprecated +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSsrGridDefinitionDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Header of a Gridded Correction message + #[cfg_attr(feature = "serde", serde(rename(serialize = "header")))] pub header: GridDefinitionHeaderDepA, /// Run Length Encode list of quadrants that contain valid data. The spec /// describes the encoding scheme in detail, but essentially the index of /// the quadrants that contain transitions between valid and invalid (and /// vice versa) are encoded as u8 integers. + #[cfg_attr(feature = "serde", serde(rename(serialize = "rle_list")))] pub rle_list: Vec, } -impl MsgSsrGridDefinitionDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSsrGridDefinitionDepA{ - sender_id: None, - header: GridDefinitionHeaderDepA::parse(_buf)?, - rle_list: crate::parser::read_u8_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgSsrGridDefinitionDepA { + const MESSAGE_TYPE: u16 = 1525; + const MESSAGE_NAME: &'static str = "MSG_SSR_GRID_DEFINITION_DEP_A"; } -impl super::SBPMessage for MsgSsrGridDefinitionDepA { - fn get_message_name(&self) -> &'static str { - "MSG_SSR_GRID_DEFINITION_DEP_A" - } - fn get_message_type(&self) -> u16 { - 1525 +impl SbpMessage for MsgSsrGridDefinitionDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgSsrGridDefinitionDepA { - const MESSAGE_TYPE: u16 = 1525; - const MESSAGE_NAME: &'static str = "MSG_SSR_GRID_DEFINITION_DEP_A"; } -impl TryFrom for MsgSsrGridDefinitionDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSsrGridDefinitionDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSsrGridDefinitionDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSsrGridDefinitionDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSsrGridDefinitionDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.header.append_to_sbp_buffer(buf); - self.rle_list.append_to_sbp_buffer(buf); +impl WireFormat for MsgSsrGridDefinitionDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.header) + WireFormat::encoded_len(&self.rle_list) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.header.sbp_size(); - size += self.rle_list.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.header, buf); + WireFormat::write(&self.rle_list, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSsrGridDefinitionDepA { + sender_id: None, + header: WireFormat::parse_unchecked(buf), + rle_list: WireFormat::parse_unchecked(buf), + } } } @@ -798,285 +676,304 @@ impl crate::serialize::SbpSerialize for MsgSsrGridDefinitionDepA { /// correction to broadcast ephemeris and is an equivalent to the 1060 /1066 /// RTCM message types. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSsrOrbitClock { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GNSS reference time of the correction - pub time: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "time")))] + pub time: GpsTimeSec, /// GNSS signal identifier (16 bit) + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, /// Update interval between consecutive corrections. Encoded following RTCM /// DF391 specification. + #[cfg_attr(feature = "serde", serde(rename(serialize = "update_interval")))] pub update_interval: u8, /// IOD of the SSR correction. A change of Issue Of Data SSR is used to /// indicate a change in the SSR generating configuration + #[cfg_attr(feature = "serde", serde(rename(serialize = "iod_ssr")))] pub iod_ssr: u8, /// Issue of broadcast ephemeris data or IODCRC (Beidou) + #[cfg_attr(feature = "serde", serde(rename(serialize = "iod")))] pub iod: u32, /// Orbit radial delta correction + #[cfg_attr(feature = "serde", serde(rename(serialize = "radial")))] pub radial: i32, /// Orbit along delta correction + #[cfg_attr(feature = "serde", serde(rename(serialize = "along")))] pub along: i32, /// Orbit along delta correction + #[cfg_attr(feature = "serde", serde(rename(serialize = "cross")))] pub cross: i32, /// Velocity of orbit radial delta correction + #[cfg_attr(feature = "serde", serde(rename(serialize = "dot_radial")))] pub dot_radial: i32, /// Velocity of orbit along delta correction + #[cfg_attr(feature = "serde", serde(rename(serialize = "dot_along")))] pub dot_along: i32, /// Velocity of orbit cross delta correction + #[cfg_attr(feature = "serde", serde(rename(serialize = "dot_cross")))] pub dot_cross: i32, /// C0 polynomial coefficient for correction of broadcast satellite clock + #[cfg_attr(feature = "serde", serde(rename(serialize = "c0")))] pub c0: i32, /// C1 polynomial coefficient for correction of broadcast satellite clock + #[cfg_attr(feature = "serde", serde(rename(serialize = "c1")))] pub c1: i32, /// C2 polynomial coefficient for correction of broadcast satellite clock + #[cfg_attr(feature = "serde", serde(rename(serialize = "c2")))] pub c2: i32, } -impl MsgSsrOrbitClock { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSsrOrbitClock{ - sender_id: None, - time: GPSTimeSec::parse(_buf)?, - sid: GnssSignal::parse(_buf)?, - update_interval: _buf.read_u8()?, - iod_ssr: _buf.read_u8()?, - iod: _buf.read_u32::()?, - radial: _buf.read_i32::()?, - along: _buf.read_i32::()?, - cross: _buf.read_i32::()?, - dot_radial: _buf.read_i32::()?, - dot_along: _buf.read_i32::()?, - dot_cross: _buf.read_i32::()?, - c0: _buf.read_i32::()?, - c1: _buf.read_i32::()?, - c2: _buf.read_i32::()?, - } ) - } +impl ConcreteMessage for MsgSsrOrbitClock { + const MESSAGE_TYPE: u16 = 1501; + const MESSAGE_NAME: &'static str = "MSG_SSR_ORBIT_CLOCK"; } -impl super::SBPMessage for MsgSsrOrbitClock { - fn get_message_name(&self) -> &'static str { - "MSG_SSR_ORBIT_CLOCK" - } - fn get_message_type(&self) -> u16 { - 1501 +impl SbpMessage for MsgSsrOrbitClock { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } +} - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) +impl TryFrom for MsgSsrOrbitClock { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSsrOrbitClock(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -impl super::ConcreteMessage for MsgSsrOrbitClock { - const MESSAGE_TYPE: u16 = 1501; - const MESSAGE_NAME: &'static str = "MSG_SSR_ORBIT_CLOCK"; -} -impl TryFrom for MsgSsrOrbitClock { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { - match msg { - super::SBP::MsgSsrOrbitClock(m) => Ok(m), - _ => Err(super::TryFromSBPError), +impl WireFormat for MsgSsrOrbitClock { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.time) + + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.update_interval) + + WireFormat::encoded_len(&self.iod_ssr) + + WireFormat::encoded_len(&self.iod) + + WireFormat::encoded_len(&self.radial) + + WireFormat::encoded_len(&self.along) + + WireFormat::encoded_len(&self.cross) + + WireFormat::encoded_len(&self.dot_radial) + + WireFormat::encoded_len(&self.dot_along) + + WireFormat::encoded_len(&self.dot_cross) + + WireFormat::encoded_len(&self.c0) + + WireFormat::encoded_len(&self.c1) + + WireFormat::encoded_len(&self.c2) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.time, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.update_interval, buf); + WireFormat::write(&self.iod_ssr, buf); + WireFormat::write(&self.iod, buf); + WireFormat::write(&self.radial, buf); + WireFormat::write(&self.along, buf); + WireFormat::write(&self.cross, buf); + WireFormat::write(&self.dot_radial, buf); + WireFormat::write(&self.dot_along, buf); + WireFormat::write(&self.dot_cross, buf); + WireFormat::write(&self.c0, buf); + WireFormat::write(&self.c1, buf); + WireFormat::write(&self.c2, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSsrOrbitClock { + sender_id: None, + time: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + update_interval: WireFormat::parse_unchecked(buf), + iod_ssr: WireFormat::parse_unchecked(buf), + iod: WireFormat::parse_unchecked(buf), + radial: WireFormat::parse_unchecked(buf), + along: WireFormat::parse_unchecked(buf), + cross: WireFormat::parse_unchecked(buf), + dot_radial: WireFormat::parse_unchecked(buf), + dot_along: WireFormat::parse_unchecked(buf), + dot_cross: WireFormat::parse_unchecked(buf), + c0: WireFormat::parse_unchecked(buf), + c1: WireFormat::parse_unchecked(buf), + c2: WireFormat::parse_unchecked(buf), } } } -impl crate::serialize::SbpSerialize for MsgSsrOrbitClock { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.time.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - self.update_interval.append_to_sbp_buffer(buf); - self.iod_ssr.append_to_sbp_buffer(buf); - self.iod.append_to_sbp_buffer(buf); - self.radial.append_to_sbp_buffer(buf); - self.along.append_to_sbp_buffer(buf); - self.cross.append_to_sbp_buffer(buf); - self.dot_radial.append_to_sbp_buffer(buf); - self.dot_along.append_to_sbp_buffer(buf); - self.dot_cross.append_to_sbp_buffer(buf); - self.c0.append_to_sbp_buffer(buf); - self.c1.append_to_sbp_buffer(buf); - self.c2.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.time.sbp_size(); - size += self.sid.sbp_size(); - size += self.update_interval.sbp_size(); - size += self.iod_ssr.sbp_size(); - size += self.iod.sbp_size(); - size += self.radial.sbp_size(); - size += self.along.sbp_size(); - size += self.cross.sbp_size(); - size += self.dot_radial.sbp_size(); - size += self.dot_along.sbp_size(); - size += self.dot_cross.sbp_size(); - size += self.c0.sbp_size(); - size += self.c1.sbp_size(); - size += self.c2.sbp_size(); - size - } -} - -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +/// Deprecated +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSsrOrbitClockDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GNSS reference time of the correction - pub time: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "time")))] + pub time: GpsTimeSec, /// GNSS signal identifier (16 bit) + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, /// Update interval between consecutive corrections. Encoded following RTCM /// DF391 specification. + #[cfg_attr(feature = "serde", serde(rename(serialize = "update_interval")))] pub update_interval: u8, /// IOD of the SSR correction. A change of Issue Of Data SSR is used to /// indicate a change in the SSR generating configuration + #[cfg_attr(feature = "serde", serde(rename(serialize = "iod_ssr")))] pub iod_ssr: u8, /// Issue of broadcast ephemeris data + #[cfg_attr(feature = "serde", serde(rename(serialize = "iod")))] pub iod: u8, /// Orbit radial delta correction + #[cfg_attr(feature = "serde", serde(rename(serialize = "radial")))] pub radial: i32, /// Orbit along delta correction + #[cfg_attr(feature = "serde", serde(rename(serialize = "along")))] pub along: i32, /// Orbit along delta correction + #[cfg_attr(feature = "serde", serde(rename(serialize = "cross")))] pub cross: i32, /// Velocity of orbit radial delta correction + #[cfg_attr(feature = "serde", serde(rename(serialize = "dot_radial")))] pub dot_radial: i32, /// Velocity of orbit along delta correction + #[cfg_attr(feature = "serde", serde(rename(serialize = "dot_along")))] pub dot_along: i32, /// Velocity of orbit cross delta correction + #[cfg_attr(feature = "serde", serde(rename(serialize = "dot_cross")))] pub dot_cross: i32, /// C0 polynomial coefficient for correction of broadcast satellite clock + #[cfg_attr(feature = "serde", serde(rename(serialize = "c0")))] pub c0: i32, /// C1 polynomial coefficient for correction of broadcast satellite clock + #[cfg_attr(feature = "serde", serde(rename(serialize = "c1")))] pub c1: i32, /// C2 polynomial coefficient for correction of broadcast satellite clock + #[cfg_attr(feature = "serde", serde(rename(serialize = "c2")))] pub c2: i32, } -impl MsgSsrOrbitClockDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSsrOrbitClockDepA{ - sender_id: None, - time: GPSTimeSec::parse(_buf)?, - sid: GnssSignal::parse(_buf)?, - update_interval: _buf.read_u8()?, - iod_ssr: _buf.read_u8()?, - iod: _buf.read_u8()?, - radial: _buf.read_i32::()?, - along: _buf.read_i32::()?, - cross: _buf.read_i32::()?, - dot_radial: _buf.read_i32::()?, - dot_along: _buf.read_i32::()?, - dot_cross: _buf.read_i32::()?, - c0: _buf.read_i32::()?, - c1: _buf.read_i32::()?, - c2: _buf.read_i32::()?, - } ) - } +impl ConcreteMessage for MsgSsrOrbitClockDepA { + const MESSAGE_TYPE: u16 = 1500; + const MESSAGE_NAME: &'static str = "MSG_SSR_ORBIT_CLOCK_DEP_A"; } -impl super::SBPMessage for MsgSsrOrbitClockDepA { - fn get_message_name(&self) -> &'static str { - "MSG_SSR_ORBIT_CLOCK_DEP_A" - } - fn get_message_type(&self) -> u16 { - 1500 +impl SbpMessage for MsgSsrOrbitClockDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgSsrOrbitClockDepA { - const MESSAGE_TYPE: u16 = 1500; - const MESSAGE_NAME: &'static str = "MSG_SSR_ORBIT_CLOCK_DEP_A"; } -impl TryFrom for MsgSsrOrbitClockDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSsrOrbitClockDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSsrOrbitClockDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSsrOrbitClockDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSsrOrbitClockDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.time.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - self.update_interval.append_to_sbp_buffer(buf); - self.iod_ssr.append_to_sbp_buffer(buf); - self.iod.append_to_sbp_buffer(buf); - self.radial.append_to_sbp_buffer(buf); - self.along.append_to_sbp_buffer(buf); - self.cross.append_to_sbp_buffer(buf); - self.dot_radial.append_to_sbp_buffer(buf); - self.dot_along.append_to_sbp_buffer(buf); - self.dot_cross.append_to_sbp_buffer(buf); - self.c0.append_to_sbp_buffer(buf); - self.c1.append_to_sbp_buffer(buf); - self.c2.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.time.sbp_size(); - size += self.sid.sbp_size(); - size += self.update_interval.sbp_size(); - size += self.iod_ssr.sbp_size(); - size += self.iod.sbp_size(); - size += self.radial.sbp_size(); - size += self.along.sbp_size(); - size += self.cross.sbp_size(); - size += self.dot_radial.sbp_size(); - size += self.dot_along.sbp_size(); - size += self.dot_cross.sbp_size(); - size += self.c0.sbp_size(); - size += self.c1.sbp_size(); - size += self.c2.sbp_size(); - size +impl WireFormat for MsgSsrOrbitClockDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.time) + + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.update_interval) + + WireFormat::encoded_len(&self.iod_ssr) + + WireFormat::encoded_len(&self.iod) + + WireFormat::encoded_len(&self.radial) + + WireFormat::encoded_len(&self.along) + + WireFormat::encoded_len(&self.cross) + + WireFormat::encoded_len(&self.dot_radial) + + WireFormat::encoded_len(&self.dot_along) + + WireFormat::encoded_len(&self.dot_cross) + + WireFormat::encoded_len(&self.c0) + + WireFormat::encoded_len(&self.c1) + + WireFormat::encoded_len(&self.c2) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.time, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.update_interval, buf); + WireFormat::write(&self.iod_ssr, buf); + WireFormat::write(&self.iod, buf); + WireFormat::write(&self.radial, buf); + WireFormat::write(&self.along, buf); + WireFormat::write(&self.cross, buf); + WireFormat::write(&self.dot_radial, buf); + WireFormat::write(&self.dot_along, buf); + WireFormat::write(&self.dot_cross, buf); + WireFormat::write(&self.c0, buf); + WireFormat::write(&self.c1, buf); + WireFormat::write(&self.c2, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSsrOrbitClockDepA { + sender_id: None, + time: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + update_interval: WireFormat::parse_unchecked(buf), + iod_ssr: WireFormat::parse_unchecked(buf), + iod: WireFormat::parse_unchecked(buf), + radial: WireFormat::parse_unchecked(buf), + along: WireFormat::parse_unchecked(buf), + cross: WireFormat::parse_unchecked(buf), + dot_radial: WireFormat::parse_unchecked(buf), + dot_along: WireFormat::parse_unchecked(buf), + dot_cross: WireFormat::parse_unchecked(buf), + c0: WireFormat::parse_unchecked(buf), + c1: WireFormat::parse_unchecked(buf), + c2: WireFormat::parse_unchecked(buf), + } } } @@ -1088,193 +985,176 @@ impl crate::serialize::SbpSerialize for MsgSsrOrbitClockDepA { /// the phase wind-up correction. It is typically an equivalent to the 1265 /// RTCM message types. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSsrPhaseBiases { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GNSS reference time of the correction - pub time: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "time")))] + pub time: GpsTimeSec, /// GNSS signal identifier (16 bit) + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, /// Update interval between consecutive corrections. Encoded following RTCM /// DF391 specification. + #[cfg_attr(feature = "serde", serde(rename(serialize = "update_interval")))] pub update_interval: u8, /// IOD of the SSR correction. A change of Issue Of Data SSR is used to /// indicate a change in the SSR generating configuration + #[cfg_attr(feature = "serde", serde(rename(serialize = "iod_ssr")))] pub iod_ssr: u8, /// Indicator for the dispersive phase biases property. + #[cfg_attr(feature = "serde", serde(rename(serialize = "dispersive_bias")))] pub dispersive_bias: u8, /// Consistency indicator for Melbourne-Wubbena linear combinations + #[cfg_attr(feature = "serde", serde(rename(serialize = "mw_consistency")))] pub mw_consistency: u8, /// Satellite yaw angle + #[cfg_attr(feature = "serde", serde(rename(serialize = "yaw")))] pub yaw: u16, /// Satellite yaw angle rate + #[cfg_attr(feature = "serde", serde(rename(serialize = "yaw_rate")))] pub yaw_rate: i8, /// Phase biases corrections for a satellite being tracked. + #[cfg_attr(feature = "serde", serde(rename(serialize = "biases")))] pub biases: Vec, } -impl MsgSsrPhaseBiases { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSsrPhaseBiases{ - sender_id: None, - time: GPSTimeSec::parse(_buf)?, - sid: GnssSignal::parse(_buf)?, - update_interval: _buf.read_u8()?, - iod_ssr: _buf.read_u8()?, - dispersive_bias: _buf.read_u8()?, - mw_consistency: _buf.read_u8()?, - yaw: _buf.read_u16::()?, - yaw_rate: _buf.read_i8()?, - biases: PhaseBiasesContent::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgSsrPhaseBiases { + const MESSAGE_TYPE: u16 = 1510; + const MESSAGE_NAME: &'static str = "MSG_SSR_PHASE_BIASES"; } -impl super::SBPMessage for MsgSsrPhaseBiases { - fn get_message_name(&self) -> &'static str { - "MSG_SSR_PHASE_BIASES" - } - fn get_message_type(&self) -> u16 { - 1510 +impl SbpMessage for MsgSsrPhaseBiases { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgSsrPhaseBiases { - const MESSAGE_TYPE: u16 = 1510; - const MESSAGE_NAME: &'static str = "MSG_SSR_PHASE_BIASES"; -} -impl TryFrom for MsgSsrPhaseBiases { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSsrPhaseBiases { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSsrPhaseBiases(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSsrPhaseBiases(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSsrPhaseBiases { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.time.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - self.update_interval.append_to_sbp_buffer(buf); - self.iod_ssr.append_to_sbp_buffer(buf); - self.dispersive_bias.append_to_sbp_buffer(buf); - self.mw_consistency.append_to_sbp_buffer(buf); - self.yaw.append_to_sbp_buffer(buf); - self.yaw_rate.append_to_sbp_buffer(buf); - self.biases.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.time.sbp_size(); - size += self.sid.sbp_size(); - size += self.update_interval.sbp_size(); - size += self.iod_ssr.sbp_size(); - size += self.dispersive_bias.sbp_size(); - size += self.mw_consistency.sbp_size(); - size += self.yaw.sbp_size(); - size += self.yaw_rate.sbp_size(); - size += self.biases.sbp_size(); - size +impl WireFormat for MsgSsrPhaseBiases { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.time) + + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.update_interval) + + WireFormat::encoded_len(&self.iod_ssr) + + WireFormat::encoded_len(&self.dispersive_bias) + + WireFormat::encoded_len(&self.mw_consistency) + + WireFormat::encoded_len(&self.yaw) + + WireFormat::encoded_len(&self.yaw_rate) + + WireFormat::encoded_len(&self.biases) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.time, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.update_interval, buf); + WireFormat::write(&self.iod_ssr, buf); + WireFormat::write(&self.dispersive_bias, buf); + WireFormat::write(&self.mw_consistency, buf); + WireFormat::write(&self.yaw, buf); + WireFormat::write(&self.yaw_rate, buf); + WireFormat::write(&self.biases, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSsrPhaseBiases { + sender_id: None, + time: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + update_interval: WireFormat::parse_unchecked(buf), + iod_ssr: WireFormat::parse_unchecked(buf), + dispersive_bias: WireFormat::parse_unchecked(buf), + mw_consistency: WireFormat::parse_unchecked(buf), + yaw: WireFormat::parse_unchecked(buf), + yaw_rate: WireFormat::parse_unchecked(buf), + biases: WireFormat::parse_unchecked(buf), + } } } -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +/// Satellite antenna phase center corrections +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSsrSatelliteApc { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Satellite antenna phase center corrections + #[cfg_attr(feature = "serde", serde(rename(serialize = "apc")))] pub apc: Vec, } -impl MsgSsrSatelliteApc { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSsrSatelliteApc{ - sender_id: None, - apc: SatelliteAPC::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgSsrSatelliteApc { + const MESSAGE_TYPE: u16 = 1540; + const MESSAGE_NAME: &'static str = "MSG_SSR_SATELLITE_APC"; } -impl super::SBPMessage for MsgSsrSatelliteApc { - fn get_message_name(&self) -> &'static str { - "MSG_SSR_SATELLITE_APC" - } - fn get_message_type(&self) -> u16 { - 1540 +impl SbpMessage for MsgSsrSatelliteApc { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgSsrSatelliteApc { - const MESSAGE_TYPE: u16 = 1540; - const MESSAGE_NAME: &'static str = "MSG_SSR_SATELLITE_APC"; } -impl TryFrom for MsgSsrSatelliteApc { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSsrSatelliteApc { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSsrSatelliteApc(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSsrSatelliteApc(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSsrSatelliteApc { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.apc.append_to_sbp_buffer(buf); +impl WireFormat for MsgSsrSatelliteApc { + const MIN_ENCODED_LEN: usize = as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.apc) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.apc.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.apc, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSsrSatelliteApc { + sender_id: None, + apc: WireFormat::parse_unchecked(buf), + } } } @@ -1287,161 +1167,130 @@ impl crate::serialize::SbpSerialize for MsgSsrSatelliteApc { /// /// It is typically equivalent to the QZSS CLAS Sub Type 8 messages. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSsrStecCorrection { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Header of a STEC polynomial coefficient message. + #[cfg_attr(feature = "serde", serde(rename(serialize = "header")))] pub header: STECHeader, /// Array of STEC polynomial coefficients for each space vehicle. + #[cfg_attr(feature = "serde", serde(rename(serialize = "stec_sat_list")))] pub stec_sat_list: Vec, } -impl MsgSsrStecCorrection { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSsrStecCorrection{ - sender_id: None, - header: STECHeader::parse(_buf)?, - stec_sat_list: STECSatElement::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgSsrStecCorrection { + const MESSAGE_TYPE: u16 = 1531; + const MESSAGE_NAME: &'static str = "MSG_SSR_STEC_CORRECTION"; } -impl super::SBPMessage for MsgSsrStecCorrection { - fn get_message_name(&self) -> &'static str { - "MSG_SSR_STEC_CORRECTION" - } - fn get_message_type(&self) -> u16 { - 1531 +impl SbpMessage for MsgSsrStecCorrection { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgSsrStecCorrection { - const MESSAGE_TYPE: u16 = 1531; - const MESSAGE_NAME: &'static str = "MSG_SSR_STEC_CORRECTION"; -} -impl TryFrom for MsgSsrStecCorrection { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSsrStecCorrection { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSsrStecCorrection(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSsrStecCorrection(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSsrStecCorrection { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.header.append_to_sbp_buffer(buf); - self.stec_sat_list.append_to_sbp_buffer(buf); +impl WireFormat for MsgSsrStecCorrection { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.header) + WireFormat::encoded_len(&self.stec_sat_list) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.header.sbp_size(); - size += self.stec_sat_list.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.header, buf); + WireFormat::write(&self.stec_sat_list, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSsrStecCorrection { + sender_id: None, + header: WireFormat::parse_unchecked(buf), + stec_sat_list: WireFormat::parse_unchecked(buf), + } } } -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +/// Deprecated +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSsrStecCorrectionDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Header of a STEC message + #[cfg_attr(feature = "serde", serde(rename(serialize = "header")))] pub header: STECHeaderDepA, /// Array of STEC information for each space vehicle + #[cfg_attr(feature = "serde", serde(rename(serialize = "stec_sat_list")))] pub stec_sat_list: Vec, } -impl MsgSsrStecCorrectionDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSsrStecCorrectionDepA{ - sender_id: None, - header: STECHeaderDepA::parse(_buf)?, - stec_sat_list: STECSatElement::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgSsrStecCorrectionDepA { + const MESSAGE_TYPE: u16 = 1515; + const MESSAGE_NAME: &'static str = "MSG_SSR_STEC_CORRECTION_DEP_A"; } -impl super::SBPMessage for MsgSsrStecCorrectionDepA { - fn get_message_name(&self) -> &'static str { - "MSG_SSR_STEC_CORRECTION_DEP_A" - } - fn get_message_type(&self) -> u16 { - 1515 +impl SbpMessage for MsgSsrStecCorrectionDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgSsrStecCorrectionDepA { - const MESSAGE_TYPE: u16 = 1515; - const MESSAGE_NAME: &'static str = "MSG_SSR_STEC_CORRECTION_DEP_A"; } -impl TryFrom for MsgSsrStecCorrectionDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSsrStecCorrectionDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSsrStecCorrectionDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSsrStecCorrectionDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSsrStecCorrectionDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.header.append_to_sbp_buffer(buf); - self.stec_sat_list.append_to_sbp_buffer(buf); +impl WireFormat for MsgSsrStecCorrectionDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.header) + WireFormat::encoded_len(&self.stec_sat_list) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.header.sbp_size(); - size += self.stec_sat_list.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.header, buf); + WireFormat::write(&self.stec_sat_list, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSsrStecCorrectionDepA { + sender_id: None, + header: WireFormat::parse_unchecked(buf), + stec_sat_list: WireFormat::parse_unchecked(buf), + } } } @@ -1456,50 +1305,58 @@ impl crate::serialize::SbpSerialize for MsgSsrStecCorrectionDepA { /// element GNSS-SSR-CorrectionPoints. SBP only supports gridded arrays of /// correction points, not lists of points. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgSsrTileDefinition { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Unique identifier of the tile set this tile belongs to. + #[cfg_attr(feature = "serde", serde(rename(serialize = "tile_set_id")))] pub tile_set_id: u16, /// Unique identifier of this tile in the tile set. /// See GNSS-SSR-ArrayOfCorrectionPoints field correctionPointSetID. + #[cfg_attr(feature = "serde", serde(rename(serialize = "tile_id")))] pub tile_id: u16, /// North-West corner correction point latitude. /// - /// The relation between the latitude X in the range [-90, 90] and the coded + /// The relation between the latitude X in the range \[-90, 90\] and the coded /// number N is: /// /// N = floor((X / 90) * 2^14) /// /// See GNSS-SSR-ArrayOfCorrectionPoints field referencePointLatitude. + #[cfg_attr(feature = "serde", serde(rename(serialize = "corner_nw_lat")))] pub corner_nw_lat: i16, /// North-West corner correction point longitude. /// - /// The relation between the longitude X in the range [-180, 180] and the + /// The relation between the longitude X in the range \[-180, 180\] and the /// coded number N is: /// /// N = floor((X / 180) * 2^15) /// /// See GNSS-SSR-ArrayOfCorrectionPoints field referencePointLongitude. + #[cfg_attr(feature = "serde", serde(rename(serialize = "corner_nw_lon")))] pub corner_nw_lon: i16, /// Spacing of the correction points in the latitude direction. /// /// See GNSS-SSR-ArrayOfCorrectionPoints field stepOfLatitude. + #[cfg_attr(feature = "serde", serde(rename(serialize = "spacing_lat")))] pub spacing_lat: u16, /// Spacing of the correction points in the longitude direction. /// /// See GNSS-SSR-ArrayOfCorrectionPoints field stepOfLongitude. + #[cfg_attr(feature = "serde", serde(rename(serialize = "spacing_lon")))] pub spacing_lon: u16, /// Number of steps in the latitude direction. /// /// See GNSS-SSR-ArrayOfCorrectionPoints field numberOfStepsLatitude. + #[cfg_attr(feature = "serde", serde(rename(serialize = "rows")))] pub rows: u16, /// Number of steps in the longitude direction. /// /// See GNSS-SSR-ArrayOfCorrectionPoints field numberOfStepsLongitude. + #[cfg_attr(feature = "serde", serde(rename(serialize = "cols")))] pub cols: u16, /// Specifies the availability of correction data at the correction points /// in the array. @@ -1516,94 +1373,85 @@ pub struct MsgSsrTileDefinition { /// /// See GNSS-SSR-ArrayOfCorrectionPoints field bitmaskOfGrids but note the /// definition of the bits is inverted. + #[cfg_attr(feature = "serde", serde(rename(serialize = "bitmask")))] pub bitmask: u64, } -impl MsgSsrTileDefinition { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgSsrTileDefinition{ - sender_id: None, - tile_set_id: _buf.read_u16::()?, - tile_id: _buf.read_u16::()?, - corner_nw_lat: _buf.read_i16::()?, - corner_nw_lon: _buf.read_i16::()?, - spacing_lat: _buf.read_u16::()?, - spacing_lon: _buf.read_u16::()?, - rows: _buf.read_u16::()?, - cols: _buf.read_u16::()?, - bitmask: _buf.read_u64::()?, - } ) - } +impl ConcreteMessage for MsgSsrTileDefinition { + const MESSAGE_TYPE: u16 = 1526; + const MESSAGE_NAME: &'static str = "MSG_SSR_TILE_DEFINITION"; } -impl super::SBPMessage for MsgSsrTileDefinition { - fn get_message_name(&self) -> &'static str { - "MSG_SSR_TILE_DEFINITION" - } - fn get_message_type(&self) -> u16 { - 1526 +impl SbpMessage for MsgSsrTileDefinition { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgSsrTileDefinition { - const MESSAGE_TYPE: u16 = 1526; - const MESSAGE_NAME: &'static str = "MSG_SSR_TILE_DEFINITION"; } -impl TryFrom for MsgSsrTileDefinition { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgSsrTileDefinition { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgSsrTileDefinition(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgSsrTileDefinition(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgSsrTileDefinition { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tile_set_id.append_to_sbp_buffer(buf); - self.tile_id.append_to_sbp_buffer(buf); - self.corner_nw_lat.append_to_sbp_buffer(buf); - self.corner_nw_lon.append_to_sbp_buffer(buf); - self.spacing_lat.append_to_sbp_buffer(buf); - self.spacing_lon.append_to_sbp_buffer(buf); - self.rows.append_to_sbp_buffer(buf); - self.cols.append_to_sbp_buffer(buf); - self.bitmask.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tile_set_id.sbp_size(); - size += self.tile_id.sbp_size(); - size += self.corner_nw_lat.sbp_size(); - size += self.corner_nw_lon.sbp_size(); - size += self.spacing_lat.sbp_size(); - size += self.spacing_lon.sbp_size(); - size += self.rows.sbp_size(); - size += self.cols.sbp_size(); - size += self.bitmask.sbp_size(); - size +impl WireFormat for MsgSsrTileDefinition { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tile_set_id) + + WireFormat::encoded_len(&self.tile_id) + + WireFormat::encoded_len(&self.corner_nw_lat) + + WireFormat::encoded_len(&self.corner_nw_lon) + + WireFormat::encoded_len(&self.spacing_lat) + + WireFormat::encoded_len(&self.spacing_lon) + + WireFormat::encoded_len(&self.rows) + + WireFormat::encoded_len(&self.cols) + + WireFormat::encoded_len(&self.bitmask) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tile_set_id, buf); + WireFormat::write(&self.tile_id, buf); + WireFormat::write(&self.corner_nw_lat, buf); + WireFormat::write(&self.corner_nw_lon, buf); + WireFormat::write(&self.spacing_lat, buf); + WireFormat::write(&self.spacing_lon, buf); + WireFormat::write(&self.rows, buf); + WireFormat::write(&self.cols, buf); + WireFormat::write(&self.bitmask, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgSsrTileDefinition { + sender_id: None, + tile_set_id: WireFormat::parse_unchecked(buf), + tile_id: WireFormat::parse_unchecked(buf), + corner_nw_lat: WireFormat::parse_unchecked(buf), + corner_nw_lon: WireFormat::parse_unchecked(buf), + spacing_lat: WireFormat::parse_unchecked(buf), + spacing_lon: WireFormat::parse_unchecked(buf), + rows: WireFormat::parse_unchecked(buf), + cols: WireFormat::parse_unchecked(buf), + bitmask: WireFormat::parse_unchecked(buf), + } } } @@ -1611,73 +1459,59 @@ impl crate::serialize::SbpSerialize for MsgSsrTileDefinition { /// /// Phase biases are to be added to carrier phase measurements. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct PhaseBiasesContent { /// Signal encoded following RTCM specifications (DF380, DF381, DF382 and /// DF467) + #[cfg_attr(feature = "serde", serde(rename(serialize = "code")))] pub code: u8, /// Indicator for integer property + #[cfg_attr(feature = "serde", serde(rename(serialize = "integer_indicator")))] pub integer_indicator: u8, /// Indicator for two groups of Wide-Lane(s) integer property + #[cfg_attr( + feature = "serde", + serde(rename(serialize = "widelane_integer_indicator")) + )] pub widelane_integer_indicator: u8, /// Signal phase discontinuity counter. Increased for every discontinuity in /// phase. + #[cfg_attr(feature = "serde", serde(rename(serialize = "discontinuity_counter")))] pub discontinuity_counter: u8, /// Phase bias for specified signal + #[cfg_attr(feature = "serde", serde(rename(serialize = "bias")))] pub bias: i32, } -impl PhaseBiasesContent { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( PhaseBiasesContent{ - code: _buf.read_u8()?, - integer_indicator: _buf.read_u8()?, - widelane_integer_indicator: _buf.read_u8()?, - discontinuity_counter: _buf.read_u8()?, - bias: _buf.read_i32::()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(PhaseBiasesContent::parse(buf)?); +impl WireFormat for PhaseBiasesContent { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.code) + + WireFormat::encoded_len(&self.integer_indicator) + + WireFormat::encoded_len(&self.widelane_integer_indicator) + + WireFormat::encoded_len(&self.discontinuity_counter) + + WireFormat::encoded_len(&self.bias) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.code, buf); + WireFormat::write(&self.integer_indicator, buf); + WireFormat::write(&self.widelane_integer_indicator, buf); + WireFormat::write(&self.discontinuity_counter, buf); + WireFormat::write(&self.bias, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + PhaseBiasesContent { + code: WireFormat::parse_unchecked(buf), + integer_indicator: WireFormat::parse_unchecked(buf), + widelane_integer_indicator: WireFormat::parse_unchecked(buf), + discontinuity_counter: WireFormat::parse_unchecked(buf), + bias: WireFormat::parse_unchecked(buf), } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(PhaseBiasesContent::parse(buf)?); - } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for PhaseBiasesContent { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.code.append_to_sbp_buffer(buf); - self.integer_indicator.append_to_sbp_buffer(buf); - self.widelane_integer_indicator.append_to_sbp_buffer(buf); - self.discontinuity_counter.append_to_sbp_buffer(buf); - self.bias.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.code.sbp_size(); - size += self.integer_indicator.sbp_size(); - size += self.widelane_integer_indicator.sbp_size(); - size += self.discontinuity_counter.sbp_size(); - size += self.bias.sbp_size(); - size } } @@ -1687,79 +1521,69 @@ impl crate::serialize::SbpSerialize for PhaseBiasesContent { /// since SBP message a limited to 255 bytes. The header is used to tie /// multiple SBP messages into a sequence. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct STECHeader { /// Unique identifier of the tile set this tile belongs to. + #[cfg_attr(feature = "serde", serde(rename(serialize = "tile_set_id")))] pub tile_set_id: u16, /// Unique identifier of this tile in the tile set. + #[cfg_attr(feature = "serde", serde(rename(serialize = "tile_id")))] pub tile_id: u16, /// GNSS reference time of the correction - pub time: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "time")))] + pub time: GpsTimeSec, /// Number of messages in the dataset + #[cfg_attr(feature = "serde", serde(rename(serialize = "num_msgs")))] pub num_msgs: u8, /// Position of this message in the dataset + #[cfg_attr(feature = "serde", serde(rename(serialize = "seq_num")))] pub seq_num: u8, /// Update interval between consecutive corrections. Encoded following RTCM /// DF391 specification. + #[cfg_attr(feature = "serde", serde(rename(serialize = "update_interval")))] pub update_interval: u8, /// IOD of the SSR atmospheric correction + #[cfg_attr(feature = "serde", serde(rename(serialize = "iod_atmo")))] pub iod_atmo: u8, } -impl STECHeader { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( STECHeader{ - tile_set_id: _buf.read_u16::()?, - tile_id: _buf.read_u16::()?, - time: GPSTimeSec::parse(_buf)?, - num_msgs: _buf.read_u8()?, - seq_num: _buf.read_u8()?, - update_interval: _buf.read_u8()?, - iod_atmo: _buf.read_u8()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(STECHeader::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(STECHeader::parse(buf)?); +impl WireFormat for STECHeader { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tile_set_id) + + WireFormat::encoded_len(&self.tile_id) + + WireFormat::encoded_len(&self.time) + + WireFormat::encoded_len(&self.num_msgs) + + WireFormat::encoded_len(&self.seq_num) + + WireFormat::encoded_len(&self.update_interval) + + WireFormat::encoded_len(&self.iod_atmo) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tile_set_id, buf); + WireFormat::write(&self.tile_id, buf); + WireFormat::write(&self.time, buf); + WireFormat::write(&self.num_msgs, buf); + WireFormat::write(&self.seq_num, buf); + WireFormat::write(&self.update_interval, buf); + WireFormat::write(&self.iod_atmo, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + STECHeader { + tile_set_id: WireFormat::parse_unchecked(buf), + tile_id: WireFormat::parse_unchecked(buf), + time: WireFormat::parse_unchecked(buf), + num_msgs: WireFormat::parse_unchecked(buf), + seq_num: WireFormat::parse_unchecked(buf), + update_interval: WireFormat::parse_unchecked(buf), + iod_atmo: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for STECHeader { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tile_set_id.append_to_sbp_buffer(buf); - self.tile_id.append_to_sbp_buffer(buf); - self.time.append_to_sbp_buffer(buf); - self.num_msgs.append_to_sbp_buffer(buf); - self.seq_num.append_to_sbp_buffer(buf); - self.update_interval.append_to_sbp_buffer(buf); - self.iod_atmo.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tile_set_id.sbp_size(); - size += self.tile_id.sbp_size(); - size += self.time.sbp_size(); - size += self.num_msgs.sbp_size(); - size += self.seq_num.sbp_size(); - size += self.update_interval.sbp_size(); - size += self.iod_atmo.sbp_size(); - size } } @@ -1769,72 +1593,55 @@ impl crate::serialize::SbpSerialize for STECHeader { /// since SBP message a limited to 255 bytes. The header is used to tie /// multiple SBP messages into a sequence. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct STECHeaderDepA { /// GNSS reference time of the correction - pub time: GPSTimeSec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "time")))] + pub time: GpsTimeSec, /// Number of messages in the dataset + #[cfg_attr(feature = "serde", serde(rename(serialize = "num_msgs")))] pub num_msgs: u8, /// Position of this message in the dataset + #[cfg_attr(feature = "serde", serde(rename(serialize = "seq_num")))] pub seq_num: u8, /// Update interval between consecutive corrections. Encoded following RTCM /// DF391 specification. + #[cfg_attr(feature = "serde", serde(rename(serialize = "update_interval")))] pub update_interval: u8, /// IOD of the SSR atmospheric correction + #[cfg_attr(feature = "serde", serde(rename(serialize = "iod_atmo")))] pub iod_atmo: u8, } -impl STECHeaderDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( STECHeaderDepA{ - time: GPSTimeSec::parse(_buf)?, - num_msgs: _buf.read_u8()?, - seq_num: _buf.read_u8()?, - update_interval: _buf.read_u8()?, - iod_atmo: _buf.read_u8()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(STECHeaderDepA::parse(buf)?); +impl WireFormat for STECHeaderDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.time) + + WireFormat::encoded_len(&self.num_msgs) + + WireFormat::encoded_len(&self.seq_num) + + WireFormat::encoded_len(&self.update_interval) + + WireFormat::encoded_len(&self.iod_atmo) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.time, buf); + WireFormat::write(&self.num_msgs, buf); + WireFormat::write(&self.seq_num, buf); + WireFormat::write(&self.update_interval, buf); + WireFormat::write(&self.iod_atmo, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + STECHeaderDepA { + time: WireFormat::parse_unchecked(buf), + num_msgs: WireFormat::parse_unchecked(buf), + seq_num: WireFormat::parse_unchecked(buf), + update_interval: WireFormat::parse_unchecked(buf), + iod_atmo: WireFormat::parse_unchecked(buf), } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(STECHeaderDepA::parse(buf)?); - } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for STECHeaderDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.time.append_to_sbp_buffer(buf); - self.num_msgs.append_to_sbp_buffer(buf); - self.seq_num.append_to_sbp_buffer(buf); - self.update_interval.append_to_sbp_buffer(buf); - self.iod_atmo.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.time.sbp_size(); - size += self.num_msgs.sbp_size(); - size += self.seq_num.sbp_size(); - size += self.update_interval.sbp_size(); - size += self.iod_atmo.sbp_size(); - size } } @@ -1843,58 +1650,40 @@ impl crate::serialize::SbpSerialize for STECHeaderDepA { /// STEC residual (mean and standard deviation) for the given satellite at the /// grid point. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct STECResidual { /// space vehicle identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sv_id")))] pub sv_id: SvId, /// STEC residual + #[cfg_attr(feature = "serde", serde(rename(serialize = "residual")))] pub residual: i16, /// stddev + #[cfg_attr(feature = "serde", serde(rename(serialize = "stddev")))] pub stddev: u8, } -impl STECResidual { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( STECResidual{ - sv_id: SvId::parse(_buf)?, - residual: _buf.read_i16::()?, - stddev: _buf.read_u8()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(STECResidual::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(STECResidual::parse(buf)?); +impl WireFormat for STECResidual { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sv_id) + + WireFormat::encoded_len(&self.residual) + + WireFormat::encoded_len(&self.stddev) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sv_id, buf); + WireFormat::write(&self.residual, buf); + WireFormat::write(&self.stddev, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + STECResidual { + sv_id: WireFormat::parse_unchecked(buf), + residual: WireFormat::parse_unchecked(buf), + stddev: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for STECResidual { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sv_id.append_to_sbp_buffer(buf); - self.residual.append_to_sbp_buffer(buf); - self.stddev.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sv_id.sbp_size(); - size += self.residual.sbp_size(); - size += self.stddev.sbp_size(); - size } } @@ -1902,56 +1691,32 @@ impl crate::serialize::SbpSerialize for STECResidual { /// /// STEC residual for the given satellite at the grid point. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct STECResidualNoStd { /// space vehicle identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sv_id")))] pub sv_id: SvId, /// STEC residual + #[cfg_attr(feature = "serde", serde(rename(serialize = "residual")))] pub residual: i16, } -impl STECResidualNoStd { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( STECResidualNoStd{ - sv_id: SvId::parse(_buf)?, - residual: _buf.read_i16::()?, - } ) +impl WireFormat for STECResidualNoStd { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sv_id) + WireFormat::encoded_len(&self.residual) } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(STECResidualNoStd::parse(buf)?); - } - Ok(v) + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sv_id, buf); + WireFormat::write(&self.residual, buf); } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(STECResidualNoStd::parse(buf)?); + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + STECResidualNoStd { + sv_id: WireFormat::parse_unchecked(buf), + residual: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for STECResidualNoStd { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sv_id.append_to_sbp_buffer(buf); - self.residual.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sv_id.sbp_size(); - size += self.residual.sbp_size(); - size } } @@ -1959,62 +1724,41 @@ impl crate::serialize::SbpSerialize for STECResidualNoStd { /// /// STEC polynomial for the given satellite. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct STECSatElement { /// Unique space vehicle identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sv_id")))] pub sv_id: SvId, /// Quality of the STEC data. Encoded following RTCM DF389 specification but /// in units of TECU instead of m. + #[cfg_attr(feature = "serde", serde(rename(serialize = "stec_quality_indicator")))] pub stec_quality_indicator: u8, /// Coefficients of the STEC polynomial in the order of C00, C01, C10, C11 - pub stec_coeff: Vec, -} - -impl STECSatElement { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( STECSatElement{ - sv_id: SvId::parse(_buf)?, - stec_quality_indicator: _buf.read_u8()?, - stec_coeff: crate::parser::read_s16_array_limit(_buf, 4)?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(STECSatElement::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(STECSatElement::parse(buf)?); + #[cfg_attr(feature = "serde", serde(rename(serialize = "stec_coeff")))] + pub stec_coeff: [i16; 4], +} + +impl WireFormat for STECSatElement { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + <[i16; 4] as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sv_id) + + WireFormat::encoded_len(&self.stec_quality_indicator) + + WireFormat::encoded_len(&self.stec_coeff) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sv_id, buf); + WireFormat::write(&self.stec_quality_indicator, buf); + WireFormat::write(&self.stec_coeff, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + STECSatElement { + sv_id: WireFormat::parse_unchecked(buf), + stec_quality_indicator: WireFormat::parse_unchecked(buf), + stec_coeff: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for STECSatElement { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sv_id.append_to_sbp_buffer(buf); - self.stec_quality_indicator.append_to_sbp_buffer(buf); - self.stec_coeff.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sv_id.sbp_size(); - size += self.stec_quality_indicator.sbp_size(); - size += self.stec_coeff.sbp_size(); - size } } @@ -2023,71 +1767,57 @@ impl crate::serialize::SbpSerialize for STECSatElement { /// Contains phase center offset and elevation variation corrections for one /// signal on a satellite. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct SatelliteAPC { /// GNSS signal identifier (16 bit) + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, /// Additional satellite information + #[cfg_attr(feature = "serde", serde(rename(serialize = "sat_info")))] pub sat_info: u8, /// Satellite Code, as defined by IGS. Typically the space vehicle number. + #[cfg_attr(feature = "serde", serde(rename(serialize = "svn")))] pub svn: u16, /// Mean phase center offset, X Y and Z axes. See IGS ANTEX file format /// description for coordinate system definition. - pub pco: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "pco")))] + pub pco: [i16; 3], /// Elevation dependent phase center variations. First element is 0 degrees /// separation from the Z axis, subsequent elements represent elevation /// variations in 1 degree increments. - pub pcv: Vec, -} - -impl SatelliteAPC { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( SatelliteAPC{ - sid: GnssSignal::parse(_buf)?, - sat_info: _buf.read_u8()?, - svn: _buf.read_u16::()?, - pco: crate::parser::read_s16_array_limit(_buf, 3)?, - pcv: crate::parser::read_s8_array_limit(_buf, 21)?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(SatelliteAPC::parse(buf)?); + #[cfg_attr(feature = "serde", serde(rename(serialize = "pcv")))] + pub pcv: [i8; 21], +} + +impl WireFormat for SatelliteAPC { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + <[i16; 3] as WireFormat>::MIN_ENCODED_LEN + + <[i8; 21] as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.sat_info) + + WireFormat::encoded_len(&self.svn) + + WireFormat::encoded_len(&self.pco) + + WireFormat::encoded_len(&self.pcv) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.sat_info, buf); + WireFormat::write(&self.svn, buf); + WireFormat::write(&self.pco, buf); + WireFormat::write(&self.pcv, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + SatelliteAPC { + sid: WireFormat::parse_unchecked(buf), + sat_info: WireFormat::parse_unchecked(buf), + svn: WireFormat::parse_unchecked(buf), + pco: WireFormat::parse_unchecked(buf), + pcv: WireFormat::parse_unchecked(buf), } - Ok(v) - } - - pub fn parse_array_limit(buf: &mut &[u8], n: usize) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(SatelliteAPC::parse(buf)?); - } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for SatelliteAPC { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sid.append_to_sbp_buffer(buf); - self.sat_info.append_to_sbp_buffer(buf); - self.svn.append_to_sbp_buffer(buf); - self.pco.append_to_sbp_buffer(buf); - self.pcv.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sid.sbp_size(); - size += self.sat_info.sbp_size(); - size += self.svn.sbp_size(); - size += self.pco.sbp_size(); - size += self.pcv.sbp_size(); - size } } @@ -2096,61 +1826,40 @@ impl crate::serialize::SbpSerialize for SatelliteAPC { /// Troposphere vertical delays (mean and standard deviation) at the grid /// point. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct TroposphericDelayCorrection { /// Hydrostatic vertical delay + #[cfg_attr(feature = "serde", serde(rename(serialize = "hydro")))] pub hydro: i16, /// Wet vertical delay + #[cfg_attr(feature = "serde", serde(rename(serialize = "wet")))] pub wet: i8, /// stddev + #[cfg_attr(feature = "serde", serde(rename(serialize = "stddev")))] pub stddev: u8, } -impl TroposphericDelayCorrection { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( TroposphericDelayCorrection{ - hydro: _buf.read_i16::()?, - wet: _buf.read_i8()?, - stddev: _buf.read_u8()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(TroposphericDelayCorrection::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(TroposphericDelayCorrection::parse(buf)?); +impl WireFormat for TroposphericDelayCorrection { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.hydro) + + WireFormat::encoded_len(&self.wet) + + WireFormat::encoded_len(&self.stddev) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.hydro, buf); + WireFormat::write(&self.wet, buf); + WireFormat::write(&self.stddev, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + TroposphericDelayCorrection { + hydro: WireFormat::parse_unchecked(buf), + wet: WireFormat::parse_unchecked(buf), + stddev: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for TroposphericDelayCorrection { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.hydro.append_to_sbp_buffer(buf); - self.wet.append_to_sbp_buffer(buf); - self.stddev.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.hydro.sbp_size(); - size += self.wet.sbp_size(); - size += self.stddev.sbp_size(); - size } } @@ -2158,57 +1867,31 @@ impl crate::serialize::SbpSerialize for TroposphericDelayCorrection { /// /// Troposphere vertical delays at the grid point. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct TroposphericDelayCorrectionNoStd { /// Hydrostatic vertical delay + #[cfg_attr(feature = "serde", serde(rename(serialize = "hydro")))] pub hydro: i16, /// Wet vertical delay + #[cfg_attr(feature = "serde", serde(rename(serialize = "wet")))] pub wet: i8, } -impl TroposphericDelayCorrectionNoStd { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( TroposphericDelayCorrectionNoStd{ - hydro: _buf.read_i16::()?, - wet: _buf.read_i8()?, - } ) - } - pub fn parse_array( - buf: &mut &[u8], - ) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(TroposphericDelayCorrectionNoStd::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(TroposphericDelayCorrectionNoStd::parse(buf)?); - } - Ok(v) +impl WireFormat for TroposphericDelayCorrectionNoStd { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.hydro) + WireFormat::encoded_len(&self.wet) } -} - -impl crate::serialize::SbpSerialize for TroposphericDelayCorrectionNoStd { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.hydro.append_to_sbp_buffer(buf); - self.wet.append_to_sbp_buffer(buf); + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.hydro, buf); + WireFormat::write(&self.wet, buf); } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.hydro.sbp_size(); - size += self.wet.sbp_size(); - size + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + TroposphericDelayCorrectionNoStd { + hydro: WireFormat::parse_unchecked(buf), + wet: WireFormat::parse_unchecked(buf), + } } } diff --git a/rust/sbp/src/messages/system.rs b/rust/sbp/src/messages/system.rs index 7ed3c13904..1cc487c5c2 100644 --- a/rust/sbp/src/messages/system.rs +++ b/rust/sbp/src/messages/system.rs @@ -14,16 +14,7 @@ //****************************************************************************/ //! Standardized system messages from Swift Navigation devices. -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; +use super::lib::*; /// Experimental telemetry message /// @@ -31,83 +22,67 @@ use crate::SbpString; /// from a device. It is not produced or available on general Swift Products. /// It is intended to be a low rate message for status purposes. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgCsacTelemetry { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Index representing the type of telemetry in use. It is implementation /// defined. + #[cfg_attr(feature = "serde", serde(rename(serialize = "id")))] pub id: u8, /// Comma separated list of values as defined by the index - pub telemetry: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "telemetry")))] + pub telemetry: SbpString, Unterminated>, } -impl MsgCsacTelemetry { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgCsacTelemetry{ - sender_id: None, - id: _buf.read_u8()?, - telemetry: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgCsacTelemetry { + const MESSAGE_TYPE: u16 = 65284; + const MESSAGE_NAME: &'static str = "MSG_CSAC_TELEMETRY"; } -impl super::SBPMessage for MsgCsacTelemetry { - fn get_message_name(&self) -> &'static str { - "MSG_CSAC_TELEMETRY" - } - fn get_message_type(&self) -> u16 { - 65284 +impl SbpMessage for MsgCsacTelemetry { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgCsacTelemetry { - const MESSAGE_TYPE: u16 = 65284; - const MESSAGE_NAME: &'static str = "MSG_CSAC_TELEMETRY"; -} -impl TryFrom for MsgCsacTelemetry { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgCsacTelemetry { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgCsacTelemetry(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgCsacTelemetry(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgCsacTelemetry { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.id.append_to_sbp_buffer(buf); - self.telemetry.append_to_sbp_buffer(buf); +impl WireFormat for MsgCsacTelemetry { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + , Unterminated> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.id) + WireFormat::encoded_len(&self.telemetry) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.id.sbp_size(); - size += self.telemetry.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.id, buf); + WireFormat::write(&self.telemetry, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgCsacTelemetry { + sender_id: None, + id: WireFormat::parse_unchecked(buf), + telemetry: WireFormat::parse_unchecked(buf), + } } } @@ -117,83 +92,67 @@ impl crate::serialize::SbpSerialize for MsgCsacTelemetry { /// produced by MSG_CSAC_TELEMETRY. It should be provided by a device at a /// lower rate than the MSG_CSAC_TELEMETRY. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgCsacTelemetryLabels { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Index representing the type of telemetry in use. It is implementation /// defined. + #[cfg_attr(feature = "serde", serde(rename(serialize = "id")))] pub id: u8, /// Comma separated list of telemetry field values - pub telemetry_labels: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "telemetry_labels")))] + pub telemetry_labels: SbpString, Unterminated>, } -impl MsgCsacTelemetryLabels { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgCsacTelemetryLabels{ - sender_id: None, - id: _buf.read_u8()?, - telemetry_labels: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgCsacTelemetryLabels { + const MESSAGE_TYPE: u16 = 65285; + const MESSAGE_NAME: &'static str = "MSG_CSAC_TELEMETRY_LABELS"; } -impl super::SBPMessage for MsgCsacTelemetryLabels { - fn get_message_name(&self) -> &'static str { - "MSG_CSAC_TELEMETRY_LABELS" - } - fn get_message_type(&self) -> u16 { - 65285 +impl SbpMessage for MsgCsacTelemetryLabels { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgCsacTelemetryLabels { - const MESSAGE_TYPE: u16 = 65285; - const MESSAGE_NAME: &'static str = "MSG_CSAC_TELEMETRY_LABELS"; } -impl TryFrom for MsgCsacTelemetryLabels { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgCsacTelemetryLabels { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgCsacTelemetryLabels(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgCsacTelemetryLabels(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgCsacTelemetryLabels { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.id.append_to_sbp_buffer(buf); - self.telemetry_labels.append_to_sbp_buffer(buf); +impl WireFormat for MsgCsacTelemetryLabels { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + , Unterminated> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.id) + WireFormat::encoded_len(&self.telemetry_labels) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.id.sbp_size(); - size += self.telemetry_labels.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.id, buf); + WireFormat::write(&self.telemetry_labels, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgCsacTelemetryLabels { + sender_id: None, + id: WireFormat::parse_unchecked(buf), + telemetry_labels: WireFormat::parse_unchecked(buf), + } } } @@ -203,92 +162,81 @@ impl crate::serialize::SbpSerialize for MsgCsacTelemetryLabels { /// corrections. It is expected to be sent with each receipt of a complete /// corrections packet. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgDgnssStatus { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, /// Latency of observation receipt + #[cfg_attr(feature = "serde", serde(rename(serialize = "latency")))] pub latency: u16, /// Number of signals from base station + #[cfg_attr(feature = "serde", serde(rename(serialize = "num_signals")))] pub num_signals: u8, /// Corrections source string - pub source: SbpString, + #[cfg_attr(feature = "serde", serde(rename(serialize = "source")))] + pub source: SbpString, Unterminated>, } -impl MsgDgnssStatus { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgDgnssStatus{ - sender_id: None, - flags: _buf.read_u8()?, - latency: _buf.read_u16::()?, - num_signals: _buf.read_u8()?, - source: crate::parser::read_string(_buf)?, - } ) - } +impl ConcreteMessage for MsgDgnssStatus { + const MESSAGE_TYPE: u16 = 65282; + const MESSAGE_NAME: &'static str = "MSG_DGNSS_STATUS"; } -impl super::SBPMessage for MsgDgnssStatus { - fn get_message_name(&self) -> &'static str { - "MSG_DGNSS_STATUS" - } - fn get_message_type(&self) -> u16 { - 65282 +impl SbpMessage for MsgDgnssStatus { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgDgnssStatus { - const MESSAGE_TYPE: u16 = 65282; - const MESSAGE_NAME: &'static str = "MSG_DGNSS_STATUS"; } -impl TryFrom for MsgDgnssStatus { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgDgnssStatus { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgDgnssStatus(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgDgnssStatus(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgDgnssStatus { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.flags.append_to_sbp_buffer(buf); - self.latency.append_to_sbp_buffer(buf); - self.num_signals.append_to_sbp_buffer(buf); - self.source.append_to_sbp_buffer(buf); +impl WireFormat for MsgDgnssStatus { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + , Unterminated> as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.flags) + + WireFormat::encoded_len(&self.latency) + + WireFormat::encoded_len(&self.num_signals) + + WireFormat::encoded_len(&self.source) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.flags.sbp_size(); - size += self.latency.sbp_size(); - size += self.num_signals.sbp_size(); - size += self.source.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.flags, buf); + WireFormat::write(&self.latency, buf); + WireFormat::write(&self.num_signals, buf); + WireFormat::write(&self.source, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgDgnssStatus { + sender_id: None, + flags: WireFormat::parse_unchecked(buf), + latency: WireFormat::parse_unchecked(buf), + num_signals: WireFormat::parse_unchecked(buf), + source: WireFormat::parse_unchecked(buf), + } } } @@ -298,92 +246,81 @@ impl crate::serialize::SbpSerialize for MsgDgnssStatus { /// translate messages tagged with a local timestamp (e.g. IMU or wheeltick /// messages) to GNSS time for the sender producing this message. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgGnssTimeOffset { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Weeks portion of the time offset + #[cfg_attr(feature = "serde", serde(rename(serialize = "weeks")))] pub weeks: i16, /// Milliseconds portion of the time offset + #[cfg_attr(feature = "serde", serde(rename(serialize = "milliseconds")))] pub milliseconds: i32, /// Microseconds portion of the time offset + #[cfg_attr(feature = "serde", serde(rename(serialize = "microseconds")))] pub microseconds: i16, /// Status flags (reserved) + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgGnssTimeOffset { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgGnssTimeOffset{ - sender_id: None, - weeks: _buf.read_i16::()?, - milliseconds: _buf.read_i32::()?, - microseconds: _buf.read_i16::()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgGnssTimeOffset { + const MESSAGE_TYPE: u16 = 65287; + const MESSAGE_NAME: &'static str = "MSG_GNSS_TIME_OFFSET"; } -impl super::SBPMessage for MsgGnssTimeOffset { - fn get_message_name(&self) -> &'static str { - "MSG_GNSS_TIME_OFFSET" - } - fn get_message_type(&self) -> u16 { - 65287 +impl SbpMessage for MsgGnssTimeOffset { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgGnssTimeOffset { - const MESSAGE_TYPE: u16 = 65287; - const MESSAGE_NAME: &'static str = "MSG_GNSS_TIME_OFFSET"; -} -impl TryFrom for MsgGnssTimeOffset { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgGnssTimeOffset { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgGnssTimeOffset(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgGnssTimeOffset(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgGnssTimeOffset { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.weeks.append_to_sbp_buffer(buf); - self.milliseconds.append_to_sbp_buffer(buf); - self.microseconds.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); +impl WireFormat for MsgGnssTimeOffset { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.weeks) + + WireFormat::encoded_len(&self.milliseconds) + + WireFormat::encoded_len(&self.microseconds) + + WireFormat::encoded_len(&self.flags) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.weeks.sbp_size(); - size += self.milliseconds.sbp_size(); - size += self.microseconds.sbp_size(); - size += self.flags.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.weeks, buf); + WireFormat::write(&self.milliseconds, buf); + WireFormat::write(&self.microseconds, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgGnssTimeOffset { + sender_id: None, + weeks: WireFormat::parse_unchecked(buf), + milliseconds: WireFormat::parse_unchecked(buf), + microseconds: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -393,93 +330,82 @@ impl crate::serialize::SbpSerialize for MsgGnssTimeOffset { /// also lists the atomic contents (i.e. types of messages included) of the /// Solution Group. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgGroupMeta { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Id of the Msgs Group, 0 is Unknown, 1 is Bestpos, 2 is Gnss + #[cfg_attr(feature = "serde", serde(rename(serialize = "group_id")))] pub group_id: u8, /// Status flags (reserved) + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, /// Size of list group_msgs + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_group_msgs")))] pub n_group_msgs: u8, /// An in-order list of message types included in the Solution Group, /// including GROUP_META itself + #[cfg_attr(feature = "serde", serde(rename(serialize = "group_msgs")))] pub group_msgs: Vec, } -impl MsgGroupMeta { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgGroupMeta{ - sender_id: None, - group_id: _buf.read_u8()?, - flags: _buf.read_u8()?, - n_group_msgs: _buf.read_u8()?, - group_msgs: crate::parser::read_u16_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgGroupMeta { + const MESSAGE_TYPE: u16 = 65290; + const MESSAGE_NAME: &'static str = "MSG_GROUP_META"; } -impl super::SBPMessage for MsgGroupMeta { - fn get_message_name(&self) -> &'static str { - "MSG_GROUP_META" - } - fn get_message_type(&self) -> u16 { - 65290 +impl SbpMessage for MsgGroupMeta { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgGroupMeta { - const MESSAGE_TYPE: u16 = 65290; - const MESSAGE_NAME: &'static str = "MSG_GROUP_META"; -} -impl TryFrom for MsgGroupMeta { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgGroupMeta { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgGroupMeta(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgGroupMeta(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgGroupMeta { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.group_id.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - self.n_group_msgs.append_to_sbp_buffer(buf); - self.group_msgs.append_to_sbp_buffer(buf); +impl WireFormat for MsgGroupMeta { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.group_id) + + WireFormat::encoded_len(&self.flags) + + WireFormat::encoded_len(&self.n_group_msgs) + + WireFormat::encoded_len(&self.group_msgs) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.group_id.sbp_size(); - size += self.flags.sbp_size(); - size += self.n_group_msgs.sbp_size(); - size += self.group_msgs.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.group_id, buf); + WireFormat::write(&self.flags, buf); + WireFormat::write(&self.n_group_msgs, buf); + WireFormat::write(&self.group_msgs, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgGroupMeta { + sender_id: None, + group_id: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + n_group_msgs: WireFormat::parse_unchecked(buf), + group_msgs: WireFormat::parse_unchecked(buf), + } } } @@ -495,77 +421,60 @@ impl crate::serialize::SbpSerialize for MsgGroupMeta { /// the system. To determine the source of the error, the remaining error /// flags should be inspected. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgHeartbeat { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u32, } -impl MsgHeartbeat { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgHeartbeat{ - sender_id: None, - flags: _buf.read_u32::()?, - } ) - } +impl ConcreteMessage for MsgHeartbeat { + const MESSAGE_TYPE: u16 = 65535; + const MESSAGE_NAME: &'static str = "MSG_HEARTBEAT"; } -impl super::SBPMessage for MsgHeartbeat { - fn get_message_name(&self) -> &'static str { - "MSG_HEARTBEAT" - } - fn get_message_type(&self) -> u16 { - 65535 +impl SbpMessage for MsgHeartbeat { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgHeartbeat { - const MESSAGE_TYPE: u16 = 65535; - const MESSAGE_NAME: &'static str = "MSG_HEARTBEAT"; } -impl TryFrom for MsgHeartbeat { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgHeartbeat { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgHeartbeat(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgHeartbeat(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgHeartbeat { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.flags.append_to_sbp_buffer(buf); +impl WireFormat for MsgHeartbeat { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.flags) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.flags.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgHeartbeat { + sender_id: None, + flags: WireFormat::parse_unchecked(buf), + } } } @@ -574,77 +483,60 @@ impl crate::serialize::SbpSerialize for MsgHeartbeat { /// The INS status message describes the state of the operation and /// initialization of the inertial navigation system. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgInsStatus { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u32, } -impl MsgInsStatus { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgInsStatus{ - sender_id: None, - flags: _buf.read_u32::()?, - } ) - } +impl ConcreteMessage for MsgInsStatus { + const MESSAGE_TYPE: u16 = 65283; + const MESSAGE_NAME: &'static str = "MSG_INS_STATUS"; } -impl super::SBPMessage for MsgInsStatus { - fn get_message_name(&self) -> &'static str { - "MSG_INS_STATUS" - } - fn get_message_type(&self) -> u16 { - 65283 +impl SbpMessage for MsgInsStatus { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgInsStatus { - const MESSAGE_TYPE: u16 = 65283; - const MESSAGE_NAME: &'static str = "MSG_INS_STATUS"; } -impl TryFrom for MsgInsStatus { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgInsStatus { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgInsStatus(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgInsStatus(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgInsStatus { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.flags.append_to_sbp_buffer(buf); +impl WireFormat for MsgInsStatus { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.flags) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.flags.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgInsStatus { + sender_id: None, + flags: WireFormat::parse_unchecked(buf), + } } } @@ -654,119 +546,111 @@ impl crate::serialize::SbpSerialize for MsgInsStatus { /// rejected INS updates. This message is expected to be extended in the /// future as new types of measurements are being added. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgInsUpdates { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// GPS Time of Week + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// GNSS position update status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "gnsspos")))] pub gnsspos: u8, /// GNSS velocity update status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "gnssvel")))] pub gnssvel: u8, /// Wheelticks update status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "wheelticks")))] pub wheelticks: u8, /// Wheelticks update status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "speed")))] pub speed: u8, /// NHC update status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "nhc")))] pub nhc: u8, /// Zero velocity update status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "zerovel")))] pub zerovel: u8, } -impl MsgInsUpdates { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgInsUpdates{ - sender_id: None, - tow: _buf.read_u32::()?, - gnsspos: _buf.read_u8()?, - gnssvel: _buf.read_u8()?, - wheelticks: _buf.read_u8()?, - speed: _buf.read_u8()?, - nhc: _buf.read_u8()?, - zerovel: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgInsUpdates { + const MESSAGE_TYPE: u16 = 65286; + const MESSAGE_NAME: &'static str = "MSG_INS_UPDATES"; } -impl super::SBPMessage for MsgInsUpdates { - fn get_message_name(&self) -> &'static str { - "MSG_INS_UPDATES" - } - fn get_message_type(&self) -> u16 { - 65286 +impl SbpMessage for MsgInsUpdates { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgInsUpdates { - const MESSAGE_TYPE: u16 = 65286; - const MESSAGE_NAME: &'static str = "MSG_INS_UPDATES"; -} -impl TryFrom for MsgInsUpdates { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgInsUpdates { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgInsUpdates(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgInsUpdates(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgInsUpdates { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.gnsspos.append_to_sbp_buffer(buf); - self.gnssvel.append_to_sbp_buffer(buf); - self.wheelticks.append_to_sbp_buffer(buf); - self.speed.append_to_sbp_buffer(buf); - self.nhc.append_to_sbp_buffer(buf); - self.zerovel.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.gnsspos.sbp_size(); - size += self.gnssvel.sbp_size(); - size += self.wheelticks.sbp_size(); - size += self.speed.sbp_size(); - size += self.nhc.sbp_size(); - size += self.zerovel.sbp_size(); - size +impl WireFormat for MsgInsUpdates { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.gnsspos) + + WireFormat::encoded_len(&self.gnssvel) + + WireFormat::encoded_len(&self.wheelticks) + + WireFormat::encoded_len(&self.speed) + + WireFormat::encoded_len(&self.nhc) + + WireFormat::encoded_len(&self.zerovel) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.gnsspos, buf); + WireFormat::write(&self.gnssvel, buf); + WireFormat::write(&self.wheelticks, buf); + WireFormat::write(&self.speed, buf); + WireFormat::write(&self.nhc, buf); + WireFormat::write(&self.zerovel, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgInsUpdates { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + gnsspos: WireFormat::parse_unchecked(buf), + gnssvel: WireFormat::parse_unchecked(buf), + wheelticks: WireFormat::parse_unchecked(buf), + speed: WireFormat::parse_unchecked(buf), + nhc: WireFormat::parse_unchecked(buf), + zerovel: WireFormat::parse_unchecked(buf), + } } } @@ -785,82 +669,66 @@ impl crate::serialize::SbpSerialize for MsgInsUpdates { /// timestamping. The sender ID for each of these MSG_PPS_TIME messages /// should match the sender ID of the respective sensor data. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgPpsTime { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Local time in microseconds + #[cfg_attr(feature = "serde", serde(rename(serialize = "time")))] pub time: u64, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgPpsTime { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgPpsTime{ - sender_id: None, - time: _buf.read_u64::()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgPpsTime { + const MESSAGE_TYPE: u16 = 65288; + const MESSAGE_NAME: &'static str = "MSG_PPS_TIME"; } -impl super::SBPMessage for MsgPpsTime { - fn get_message_name(&self) -> &'static str { - "MSG_PPS_TIME" - } - fn get_message_type(&self) -> u16 { - 65288 +impl SbpMessage for MsgPpsTime { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgPpsTime { - const MESSAGE_TYPE: u16 = 65288; - const MESSAGE_NAME: &'static str = "MSG_PPS_TIME"; -} -impl TryFrom for MsgPpsTime { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgPpsTime { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgPpsTime(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgPpsTime(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgPpsTime { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.time.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); +impl WireFormat for MsgPpsTime { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.time) + WireFormat::encoded_len(&self.flags) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.time.sbp_size(); - size += self.flags.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.time, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgPpsTime { + sender_id: None, + time: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -870,87 +738,74 @@ impl crate::serialize::SbpSerialize for MsgPpsTime { /// the host or other attached devices that the system has started and is now /// ready to respond to commands or configuration requests. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgStartup { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Cause of startup + #[cfg_attr(feature = "serde", serde(rename(serialize = "cause")))] pub cause: u8, /// Startup type + #[cfg_attr(feature = "serde", serde(rename(serialize = "startup_type")))] pub startup_type: u8, /// Reserved + #[cfg_attr(feature = "serde", serde(rename(serialize = "reserved")))] pub reserved: u16, } -impl MsgStartup { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgStartup{ - sender_id: None, - cause: _buf.read_u8()?, - startup_type: _buf.read_u8()?, - reserved: _buf.read_u16::()?, - } ) - } +impl ConcreteMessage for MsgStartup { + const MESSAGE_TYPE: u16 = 65280; + const MESSAGE_NAME: &'static str = "MSG_STARTUP"; } -impl super::SBPMessage for MsgStartup { - fn get_message_name(&self) -> &'static str { - "MSG_STARTUP" - } - fn get_message_type(&self) -> u16 { - 65280 +impl SbpMessage for MsgStartup { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgStartup { - const MESSAGE_TYPE: u16 = 65280; - const MESSAGE_NAME: &'static str = "MSG_STARTUP"; -} -impl TryFrom for MsgStartup { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgStartup { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgStartup(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgStartup(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgStartup { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.cause.append_to_sbp_buffer(buf); - self.startup_type.append_to_sbp_buffer(buf); - self.reserved.append_to_sbp_buffer(buf); +impl WireFormat for MsgStartup { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.cause) + + WireFormat::encoded_len(&self.startup_type) + + WireFormat::encoded_len(&self.reserved) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.cause.sbp_size(); - size += self.startup_type.sbp_size(); - size += self.reserved.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.cause, buf); + WireFormat::write(&self.startup_type, buf); + WireFormat::write(&self.reserved, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgStartup { + sender_id: None, + cause: WireFormat::parse_unchecked(buf), + startup_type: WireFormat::parse_unchecked(buf), + reserved: WireFormat::parse_unchecked(buf), + } } } @@ -965,97 +820,88 @@ impl crate::serialize::SbpSerialize for MsgStartup { /// but if the generic status code is initializing, it should be ignored. /// Refer to product documentation for details. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgStatusReport { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Identity of reporting system + #[cfg_attr(feature = "serde", serde(rename(serialize = "reporting_system")))] pub reporting_system: u16, /// SBP protocol version + #[cfg_attr(feature = "serde", serde(rename(serialize = "sbp_version")))] pub sbp_version: u16, /// Increments on each status report sent + #[cfg_attr(feature = "serde", serde(rename(serialize = "sequence")))] pub sequence: u32, /// Number of seconds since system start-up + #[cfg_attr(feature = "serde", serde(rename(serialize = "uptime")))] pub uptime: u32, /// Reported status of individual subsystems + #[cfg_attr(feature = "serde", serde(rename(serialize = "status")))] pub status: Vec, } -impl MsgStatusReport { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgStatusReport{ - sender_id: None, - reporting_system: _buf.read_u16::()?, - sbp_version: _buf.read_u16::()?, - sequence: _buf.read_u32::()?, - uptime: _buf.read_u32::()?, - status: SubSystemReport::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgStatusReport { + const MESSAGE_TYPE: u16 = 65534; + const MESSAGE_NAME: &'static str = "MSG_STATUS_REPORT"; } -impl super::SBPMessage for MsgStatusReport { - fn get_message_name(&self) -> &'static str { - "MSG_STATUS_REPORT" - } - fn get_message_type(&self) -> u16 { - 65534 +impl SbpMessage for MsgStatusReport { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgStatusReport { - const MESSAGE_TYPE: u16 = 65534; - const MESSAGE_NAME: &'static str = "MSG_STATUS_REPORT"; -} -impl TryFrom for MsgStatusReport { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgStatusReport { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgStatusReport(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgStatusReport(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgStatusReport { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.reporting_system.append_to_sbp_buffer(buf); - self.sbp_version.append_to_sbp_buffer(buf); - self.sequence.append_to_sbp_buffer(buf); - self.uptime.append_to_sbp_buffer(buf); - self.status.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.reporting_system.sbp_size(); - size += self.sbp_version.sbp_size(); - size += self.sequence.sbp_size(); - size += self.uptime.sbp_size(); - size += self.status.sbp_size(); - size +impl WireFormat for MsgStatusReport { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.reporting_system) + + WireFormat::encoded_len(&self.sbp_version) + + WireFormat::encoded_len(&self.sequence) + + WireFormat::encoded_len(&self.uptime) + + WireFormat::encoded_len(&self.status) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.reporting_system, buf); + WireFormat::write(&self.sbp_version, buf); + WireFormat::write(&self.sequence, buf); + WireFormat::write(&self.uptime, buf); + WireFormat::write(&self.status, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgStatusReport { + sender_id: None, + reporting_system: WireFormat::parse_unchecked(buf), + sbp_version: WireFormat::parse_unchecked(buf), + sequence: WireFormat::parse_unchecked(buf), + uptime: WireFormat::parse_unchecked(buf), + status: WireFormat::parse_unchecked(buf), + } } } @@ -1064,60 +910,39 @@ impl crate::serialize::SbpSerialize for MsgStatusReport { /// Report the general and specific state of a sub-system. If the generic /// state is reported as initializing, the specific state should be ignored. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct SubSystemReport { /// Identity of reporting subsystem + #[cfg_attr(feature = "serde", serde(rename(serialize = "component")))] pub component: u16, /// Generic form status report + #[cfg_attr(feature = "serde", serde(rename(serialize = "generic")))] pub generic: u8, /// Subsystem specific status code + #[cfg_attr(feature = "serde", serde(rename(serialize = "specific")))] pub specific: u8, } -impl SubSystemReport { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( SubSystemReport{ - component: _buf.read_u16::()?, - generic: _buf.read_u8()?, - specific: _buf.read_u8()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(SubSystemReport::parse(buf)?); +impl WireFormat for SubSystemReport { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.component) + + WireFormat::encoded_len(&self.generic) + + WireFormat::encoded_len(&self.specific) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.component, buf); + WireFormat::write(&self.generic, buf); + WireFormat::write(&self.specific, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + SubSystemReport { + component: WireFormat::parse_unchecked(buf), + generic: WireFormat::parse_unchecked(buf), + specific: WireFormat::parse_unchecked(buf), } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(SubSystemReport::parse(buf)?); - } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for SubSystemReport { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.component.append_to_sbp_buffer(buf); - self.generic.append_to_sbp_buffer(buf); - self.specific.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.component.sbp_size(); - size += self.generic.sbp_size(); - size += self.specific.sbp_size(); - size } } diff --git a/rust/sbp/src/messages/tracking.rs b/rust/sbp/src/messages/tracking.rs index 5bb125e9bd..e26c772b92 100644 --- a/rust/sbp/src/messages/tracking.rs +++ b/rust/sbp/src/messages/tracking.rs @@ -14,17 +14,9 @@ //****************************************************************************/ //! Satellite code and carrier-phase tracking messages from the device. -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - use super::gnss::*; -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; + +use super::lib::*; /// Measurement Engine signal tracking channel states /// @@ -32,77 +24,60 @@ use crate::SbpString; /// states. It reports status and carrier-to-noise density measurements for /// all tracked satellites. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgMeasurementState { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// ME signal tracking channel state + #[cfg_attr(feature = "serde", serde(rename(serialize = "states")))] pub states: Vec, } -impl MsgMeasurementState { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgMeasurementState{ - sender_id: None, - states: MeasurementState::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgMeasurementState { + const MESSAGE_TYPE: u16 = 97; + const MESSAGE_NAME: &'static str = "MSG_MEASUREMENT_STATE"; } -impl super::SBPMessage for MsgMeasurementState { - fn get_message_name(&self) -> &'static str { - "MSG_MEASUREMENT_STATE" - } - fn get_message_type(&self) -> u16 { - 97 +impl SbpMessage for MsgMeasurementState { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgMeasurementState { - const MESSAGE_TYPE: u16 = 97; - const MESSAGE_NAME: &'static str = "MSG_MEASUREMENT_STATE"; } -impl TryFrom for MsgMeasurementState { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgMeasurementState { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgMeasurementState(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgMeasurementState(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgMeasurementState { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.states.append_to_sbp_buffer(buf); +impl WireFormat for MsgMeasurementState { + const MIN_ENCODED_LEN: usize = as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.states) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.states.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.states, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgMeasurementState { + sender_id: None, + states: WireFormat::parse_unchecked(buf), + } } } @@ -111,87 +86,74 @@ impl crate::serialize::SbpSerialize for MsgMeasurementState { /// When enabled, a tracking channel can output the correlations at each /// update interval. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgTrackingIq { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Tracking channel of origin + #[cfg_attr(feature = "serde", serde(rename(serialize = "channel")))] pub channel: u8, /// GNSS signal identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, /// Early, Prompt and Late correlations - pub corrs: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "corrs")))] + pub corrs: [TrackingChannelCorrelation; 3], } -impl MsgTrackingIq { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgTrackingIq{ - sender_id: None, - channel: _buf.read_u8()?, - sid: GnssSignal::parse(_buf)?, - corrs: TrackingChannelCorrelation::parse_array_limit(_buf, 3)?, - } ) - } +impl ConcreteMessage for MsgTrackingIq { + const MESSAGE_TYPE: u16 = 45; + const MESSAGE_NAME: &'static str = "MSG_TRACKING_IQ"; } -impl super::SBPMessage for MsgTrackingIq { - fn get_message_name(&self) -> &'static str { - "MSG_TRACKING_IQ" - } - fn get_message_type(&self) -> u16 { - 45 +impl SbpMessage for MsgTrackingIq { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgTrackingIq { - const MESSAGE_TYPE: u16 = 45; - const MESSAGE_NAME: &'static str = "MSG_TRACKING_IQ"; } -impl TryFrom for MsgTrackingIq { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgTrackingIq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgTrackingIq(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgTrackingIq(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgTrackingIq { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.channel.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - self.corrs.append_to_sbp_buffer(buf); +impl WireFormat for MsgTrackingIq { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + <[TrackingChannelCorrelation; 3] as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.channel) + + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.corrs) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.channel.sbp_size(); - size += self.sid.sbp_size(); - size += self.corrs.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.channel, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.corrs, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgTrackingIq { + sender_id: None, + channel: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + corrs: WireFormat::parse_unchecked(buf), + } } } @@ -199,87 +161,74 @@ impl crate::serialize::SbpSerialize for MsgTrackingIq { /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgTrackingIqDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Tracking channel of origin + #[cfg_attr(feature = "serde", serde(rename(serialize = "channel")))] pub channel: u8, /// GNSS signal identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignalDep, /// Early, Prompt and Late correlations - pub corrs: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "corrs")))] + pub corrs: [TrackingChannelCorrelationDep; 3], } -impl MsgTrackingIqDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgTrackingIqDepA{ - sender_id: None, - channel: _buf.read_u8()?, - sid: GnssSignalDep::parse(_buf)?, - corrs: TrackingChannelCorrelationDep::parse_array_limit(_buf, 3)?, - } ) - } +impl ConcreteMessage for MsgTrackingIqDepA { + const MESSAGE_TYPE: u16 = 28; + const MESSAGE_NAME: &'static str = "MSG_TRACKING_IQ_DEP_A"; } -impl super::SBPMessage for MsgTrackingIqDepA { - fn get_message_name(&self) -> &'static str { - "MSG_TRACKING_IQ_DEP_A" - } - fn get_message_type(&self) -> u16 { - 28 +impl SbpMessage for MsgTrackingIqDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgTrackingIqDepA { - const MESSAGE_TYPE: u16 = 28; - const MESSAGE_NAME: &'static str = "MSG_TRACKING_IQ_DEP_A"; } -impl TryFrom for MsgTrackingIqDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgTrackingIqDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgTrackingIqDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgTrackingIqDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgTrackingIqDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.channel.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - self.corrs.append_to_sbp_buffer(buf); +impl WireFormat for MsgTrackingIqDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + <[TrackingChannelCorrelationDep; 3] as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.channel) + + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.corrs) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.channel.sbp_size(); - size += self.sid.sbp_size(); - size += self.corrs.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.channel, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.corrs, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgTrackingIqDepA { + sender_id: None, + channel: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + corrs: WireFormat::parse_unchecked(buf), + } } } @@ -288,87 +237,74 @@ impl crate::serialize::SbpSerialize for MsgTrackingIqDepA { /// When enabled, a tracking channel can output the correlations at each /// update interval. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgTrackingIqDepB { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Tracking channel of origin + #[cfg_attr(feature = "serde", serde(rename(serialize = "channel")))] pub channel: u8, /// GNSS signal identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, /// Early, Prompt and Late correlations - pub corrs: Vec, + #[cfg_attr(feature = "serde", serde(rename(serialize = "corrs")))] + pub corrs: [TrackingChannelCorrelationDep; 3], } -impl MsgTrackingIqDepB { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgTrackingIqDepB{ - sender_id: None, - channel: _buf.read_u8()?, - sid: GnssSignal::parse(_buf)?, - corrs: TrackingChannelCorrelationDep::parse_array_limit(_buf, 3)?, - } ) - } +impl ConcreteMessage for MsgTrackingIqDepB { + const MESSAGE_TYPE: u16 = 44; + const MESSAGE_NAME: &'static str = "MSG_TRACKING_IQ_DEP_B"; } -impl super::SBPMessage for MsgTrackingIqDepB { - fn get_message_name(&self) -> &'static str { - "MSG_TRACKING_IQ_DEP_B" - } - fn get_message_type(&self) -> u16 { - 44 +impl SbpMessage for MsgTrackingIqDepB { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgTrackingIqDepB { - const MESSAGE_TYPE: u16 = 44; - const MESSAGE_NAME: &'static str = "MSG_TRACKING_IQ_DEP_B"; -} -impl TryFrom for MsgTrackingIqDepB { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgTrackingIqDepB { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgTrackingIqDepB(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgTrackingIqDepB(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgTrackingIqDepB { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.channel.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - self.corrs.append_to_sbp_buffer(buf); +impl WireFormat for MsgTrackingIqDepB { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + <[TrackingChannelCorrelationDep; 3] as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.channel) + + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.corrs) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.channel.sbp_size(); - size += self.sid.sbp_size(); - size += self.corrs.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.channel, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.corrs, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgTrackingIqDepB { + sender_id: None, + channel: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + corrs: WireFormat::parse_unchecked(buf), + } } } @@ -378,77 +314,60 @@ impl crate::serialize::SbpSerialize for MsgTrackingIqDepB { /// states. It reports status and carrier-to-noise density measurements for /// all tracked satellites. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgTrackingState { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Signal tracking channel state + #[cfg_attr(feature = "serde", serde(rename(serialize = "states")))] pub states: Vec, } -impl MsgTrackingState { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgTrackingState{ - sender_id: None, - states: TrackingChannelState::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgTrackingState { + const MESSAGE_TYPE: u16 = 65; + const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE"; } -impl super::SBPMessage for MsgTrackingState { - fn get_message_name(&self) -> &'static str { - "MSG_TRACKING_STATE" - } - fn get_message_type(&self) -> u16 { - 65 +impl SbpMessage for MsgTrackingState { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgTrackingState { - const MESSAGE_TYPE: u16 = 65; - const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE"; -} -impl TryFrom for MsgTrackingState { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgTrackingState { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgTrackingState(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgTrackingState(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgTrackingState { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.states.append_to_sbp_buffer(buf); +impl WireFormat for MsgTrackingState { + const MIN_ENCODED_LEN: usize = as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.states) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.states.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.states, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgTrackingState { + sender_id: None, + states: WireFormat::parse_unchecked(buf), + } } } @@ -456,77 +375,60 @@ impl crate::serialize::SbpSerialize for MsgTrackingState { /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgTrackingStateDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Satellite tracking channel state + #[cfg_attr(feature = "serde", serde(rename(serialize = "states")))] pub states: Vec, } -impl MsgTrackingStateDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgTrackingStateDepA{ - sender_id: None, - states: TrackingChannelStateDepA::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgTrackingStateDepA { + const MESSAGE_TYPE: u16 = 22; + const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE_DEP_A"; } -impl super::SBPMessage for MsgTrackingStateDepA { - fn get_message_name(&self) -> &'static str { - "MSG_TRACKING_STATE_DEP_A" - } - fn get_message_type(&self) -> u16 { - 22 +impl SbpMessage for MsgTrackingStateDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgTrackingStateDepA { - const MESSAGE_TYPE: u16 = 22; - const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE_DEP_A"; } -impl TryFrom for MsgTrackingStateDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgTrackingStateDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgTrackingStateDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgTrackingStateDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgTrackingStateDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.states.append_to_sbp_buffer(buf); +impl WireFormat for MsgTrackingStateDepA { + const MIN_ENCODED_LEN: usize = as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.states) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.states.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.states, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgTrackingStateDepA { + sender_id: None, + states: WireFormat::parse_unchecked(buf), + } } } @@ -534,77 +436,60 @@ impl crate::serialize::SbpSerialize for MsgTrackingStateDepA { /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgTrackingStateDepB { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Signal tracking channel state + #[cfg_attr(feature = "serde", serde(rename(serialize = "states")))] pub states: Vec, } -impl MsgTrackingStateDepB { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgTrackingStateDepB{ - sender_id: None, - states: TrackingChannelStateDepB::parse_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgTrackingStateDepB { + const MESSAGE_TYPE: u16 = 19; + const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE_DEP_B"; } -impl super::SBPMessage for MsgTrackingStateDepB { - fn get_message_name(&self) -> &'static str { - "MSG_TRACKING_STATE_DEP_B" - } - fn get_message_type(&self) -> u16 { - 19 +impl SbpMessage for MsgTrackingStateDepB { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgTrackingStateDepB { - const MESSAGE_TYPE: u16 = 19; - const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE_DEP_B"; } -impl TryFrom for MsgTrackingStateDepB { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgTrackingStateDepB { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgTrackingStateDepB(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgTrackingStateDepB(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgTrackingStateDepB { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.states.append_to_sbp_buffer(buf); +impl WireFormat for MsgTrackingStateDepB { + const MIN_ENCODED_LEN: usize = as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.states) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.states.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.states, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgTrackingStateDepB { + sender_id: None, + states: WireFormat::parse_unchecked(buf), + } } } @@ -612,183 +497,206 @@ impl crate::serialize::SbpSerialize for MsgTrackingStateDepB { /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgTrackingStateDetailedDep { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Receiver clock time. + #[cfg_attr(feature = "serde", serde(rename(serialize = "recv_time")))] pub recv_time: u64, /// Time of transmission of signal from satellite. TOW only valid when TOW /// status is decoded or propagated. WN only valid when week number valid /// flag is set. - pub tot: GPSTimeDep, + #[cfg_attr(feature = "serde", serde(rename(serialize = "tot")))] + pub tot: GpsTimeDep, /// Pseudorange observation. Valid only when pseudorange valid flag is set. - pub P: u32, + #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] + pub p: u32, /// Pseudorange observation standard deviation. Valid only when pseudorange /// valid flag is set. - pub P_std: u16, + #[cfg_attr(feature = "serde", serde(rename(serialize = "P_std")))] + pub p_std: u16, /// Carrier phase observation with typical sign convention. Valid only when /// PLL pessimistic lock is achieved. - pub L: CarrierPhase, + #[cfg_attr(feature = "serde", serde(rename(serialize = "L")))] + pub l: CarrierPhase, /// Carrier-to-Noise density + #[cfg_attr(feature = "serde", serde(rename(serialize = "cn0")))] pub cn0: u8, /// Lock time. It is encoded according to DF402 from the RTCM 10403.2 /// Amendment 2 specification. Valid values range from 0 to 15. + #[cfg_attr(feature = "serde", serde(rename(serialize = "lock")))] pub lock: u16, /// GNSS signal identifier. + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignalDep, /// Carrier Doppler frequency. + #[cfg_attr(feature = "serde", serde(rename(serialize = "doppler")))] pub doppler: i32, /// Carrier Doppler frequency standard deviation. + #[cfg_attr(feature = "serde", serde(rename(serialize = "doppler_std")))] pub doppler_std: u16, /// Number of seconds of continuous tracking. Specifies how much time signal /// is in continuous track. + #[cfg_attr(feature = "serde", serde(rename(serialize = "uptime")))] pub uptime: u32, /// TCXO clock offset. Valid only when valid clock valid flag is set. + #[cfg_attr(feature = "serde", serde(rename(serialize = "clock_offset")))] pub clock_offset: i16, /// TCXO clock drift. Valid only when valid clock valid flag is set. + #[cfg_attr(feature = "serde", serde(rename(serialize = "clock_drift")))] pub clock_drift: i16, /// Early-Prompt (EP) and Prompt-Late (PL) correlators spacing. + #[cfg_attr(feature = "serde", serde(rename(serialize = "corr_spacing")))] pub corr_spacing: u16, /// Acceleration. Valid only when acceleration valid flag is set. + #[cfg_attr(feature = "serde", serde(rename(serialize = "acceleration")))] pub acceleration: i8, /// Synchronization status flags. + #[cfg_attr(feature = "serde", serde(rename(serialize = "sync_flags")))] pub sync_flags: u8, /// TOW status flags. + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow_flags")))] pub tow_flags: u8, /// Tracking loop status flags. + #[cfg_attr(feature = "serde", serde(rename(serialize = "track_flags")))] pub track_flags: u8, /// Navigation data status flags. + #[cfg_attr(feature = "serde", serde(rename(serialize = "nav_flags")))] pub nav_flags: u8, /// Parameters sets flags. + #[cfg_attr(feature = "serde", serde(rename(serialize = "pset_flags")))] pub pset_flags: u8, /// Miscellaneous flags. + #[cfg_attr(feature = "serde", serde(rename(serialize = "misc_flags")))] pub misc_flags: u8, } -impl MsgTrackingStateDetailedDep { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgTrackingStateDetailedDep{ - sender_id: None, - recv_time: _buf.read_u64::()?, - tot: GPSTimeDep::parse(_buf)?, - P: _buf.read_u32::()?, - P_std: _buf.read_u16::()?, - L: CarrierPhase::parse(_buf)?, - cn0: _buf.read_u8()?, - lock: _buf.read_u16::()?, - sid: GnssSignalDep::parse(_buf)?, - doppler: _buf.read_i32::()?, - doppler_std: _buf.read_u16::()?, - uptime: _buf.read_u32::()?, - clock_offset: _buf.read_i16::()?, - clock_drift: _buf.read_i16::()?, - corr_spacing: _buf.read_u16::()?, - acceleration: _buf.read_i8()?, - sync_flags: _buf.read_u8()?, - tow_flags: _buf.read_u8()?, - track_flags: _buf.read_u8()?, - nav_flags: _buf.read_u8()?, - pset_flags: _buf.read_u8()?, - misc_flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgTrackingStateDetailedDep { + const MESSAGE_TYPE: u16 = 17; + const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE_DETAILED_DEP"; } -impl super::SBPMessage for MsgTrackingStateDetailedDep { - fn get_message_name(&self) -> &'static str { - "MSG_TRACKING_STATE_DETAILED_DEP" - } - fn get_message_type(&self) -> u16 { - 17 +impl SbpMessage for MsgTrackingStateDetailedDep { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgTrackingStateDetailedDep { - const MESSAGE_TYPE: u16 = 17; - const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE_DETAILED_DEP"; -} -impl TryFrom for MsgTrackingStateDetailedDep { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgTrackingStateDetailedDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgTrackingStateDetailedDep(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgTrackingStateDetailedDep(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgTrackingStateDetailedDep { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.recv_time.append_to_sbp_buffer(buf); - self.tot.append_to_sbp_buffer(buf); - self.P.append_to_sbp_buffer(buf); - self.P_std.append_to_sbp_buffer(buf); - self.L.append_to_sbp_buffer(buf); - self.cn0.append_to_sbp_buffer(buf); - self.lock.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - self.doppler.append_to_sbp_buffer(buf); - self.doppler_std.append_to_sbp_buffer(buf); - self.uptime.append_to_sbp_buffer(buf); - self.clock_offset.append_to_sbp_buffer(buf); - self.clock_drift.append_to_sbp_buffer(buf); - self.corr_spacing.append_to_sbp_buffer(buf); - self.acceleration.append_to_sbp_buffer(buf); - self.sync_flags.append_to_sbp_buffer(buf); - self.tow_flags.append_to_sbp_buffer(buf); - self.track_flags.append_to_sbp_buffer(buf); - self.nav_flags.append_to_sbp_buffer(buf); - self.pset_flags.append_to_sbp_buffer(buf); - self.misc_flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.recv_time.sbp_size(); - size += self.tot.sbp_size(); - size += self.P.sbp_size(); - size += self.P_std.sbp_size(); - size += self.L.sbp_size(); - size += self.cn0.sbp_size(); - size += self.lock.sbp_size(); - size += self.sid.sbp_size(); - size += self.doppler.sbp_size(); - size += self.doppler_std.sbp_size(); - size += self.uptime.sbp_size(); - size += self.clock_offset.sbp_size(); - size += self.clock_drift.sbp_size(); - size += self.corr_spacing.sbp_size(); - size += self.acceleration.sbp_size(); - size += self.sync_flags.sbp_size(); - size += self.tow_flags.sbp_size(); - size += self.track_flags.sbp_size(); - size += self.nav_flags.sbp_size(); - size += self.pset_flags.sbp_size(); - size += self.misc_flags.sbp_size(); - size +impl WireFormat for MsgTrackingStateDetailedDep { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.recv_time) + + WireFormat::encoded_len(&self.tot) + + WireFormat::encoded_len(&self.p) + + WireFormat::encoded_len(&self.p_std) + + WireFormat::encoded_len(&self.l) + + WireFormat::encoded_len(&self.cn0) + + WireFormat::encoded_len(&self.lock) + + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.doppler) + + WireFormat::encoded_len(&self.doppler_std) + + WireFormat::encoded_len(&self.uptime) + + WireFormat::encoded_len(&self.clock_offset) + + WireFormat::encoded_len(&self.clock_drift) + + WireFormat::encoded_len(&self.corr_spacing) + + WireFormat::encoded_len(&self.acceleration) + + WireFormat::encoded_len(&self.sync_flags) + + WireFormat::encoded_len(&self.tow_flags) + + WireFormat::encoded_len(&self.track_flags) + + WireFormat::encoded_len(&self.nav_flags) + + WireFormat::encoded_len(&self.pset_flags) + + WireFormat::encoded_len(&self.misc_flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.recv_time, buf); + WireFormat::write(&self.tot, buf); + WireFormat::write(&self.p, buf); + WireFormat::write(&self.p_std, buf); + WireFormat::write(&self.l, buf); + WireFormat::write(&self.cn0, buf); + WireFormat::write(&self.lock, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.doppler, buf); + WireFormat::write(&self.doppler_std, buf); + WireFormat::write(&self.uptime, buf); + WireFormat::write(&self.clock_offset, buf); + WireFormat::write(&self.clock_drift, buf); + WireFormat::write(&self.corr_spacing, buf); + WireFormat::write(&self.acceleration, buf); + WireFormat::write(&self.sync_flags, buf); + WireFormat::write(&self.tow_flags, buf); + WireFormat::write(&self.track_flags, buf); + WireFormat::write(&self.nav_flags, buf); + WireFormat::write(&self.pset_flags, buf); + WireFormat::write(&self.misc_flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgTrackingStateDetailedDep { + sender_id: None, + recv_time: WireFormat::parse_unchecked(buf), + tot: WireFormat::parse_unchecked(buf), + p: WireFormat::parse_unchecked(buf), + p_std: WireFormat::parse_unchecked(buf), + l: WireFormat::parse_unchecked(buf), + cn0: WireFormat::parse_unchecked(buf), + lock: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + doppler: WireFormat::parse_unchecked(buf), + doppler_std: WireFormat::parse_unchecked(buf), + uptime: WireFormat::parse_unchecked(buf), + clock_offset: WireFormat::parse_unchecked(buf), + clock_drift: WireFormat::parse_unchecked(buf), + corr_spacing: WireFormat::parse_unchecked(buf), + acceleration: WireFormat::parse_unchecked(buf), + sync_flags: WireFormat::parse_unchecked(buf), + tow_flags: WireFormat::parse_unchecked(buf), + track_flags: WireFormat::parse_unchecked(buf), + nav_flags: WireFormat::parse_unchecked(buf), + pset_flags: WireFormat::parse_unchecked(buf), + misc_flags: WireFormat::parse_unchecked(buf), + } } } @@ -797,183 +705,206 @@ impl crate::serialize::SbpSerialize for MsgTrackingStateDetailedDep { /// The tracking message returns a set tracking channel parameters for a /// single tracking channel useful for debugging issues. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgTrackingStateDetailedDepA { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Receiver clock time. + #[cfg_attr(feature = "serde", serde(rename(serialize = "recv_time")))] pub recv_time: u64, /// Time of transmission of signal from satellite. TOW only valid when TOW /// status is decoded or propagated. WN only valid when week number valid /// flag is set. - pub tot: GPSTime, + #[cfg_attr(feature = "serde", serde(rename(serialize = "tot")))] + pub tot: GpsTime, /// Pseudorange observation. Valid only when pseudorange valid flag is set. - pub P: u32, + #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] + pub p: u32, /// Pseudorange observation standard deviation. Valid only when pseudorange /// valid flag is set. - pub P_std: u16, + #[cfg_attr(feature = "serde", serde(rename(serialize = "P_std")))] + pub p_std: u16, /// Carrier phase observation with typical sign convention. Valid only when /// PLL pessimistic lock is achieved. - pub L: CarrierPhase, + #[cfg_attr(feature = "serde", serde(rename(serialize = "L")))] + pub l: CarrierPhase, /// Carrier-to-Noise density + #[cfg_attr(feature = "serde", serde(rename(serialize = "cn0")))] pub cn0: u8, /// Lock time. It is encoded according to DF402 from the RTCM 10403.2 /// Amendment 2 specification. Valid values range from 0 to 15. + #[cfg_attr(feature = "serde", serde(rename(serialize = "lock")))] pub lock: u16, /// GNSS signal identifier. + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, /// Carrier Doppler frequency. + #[cfg_attr(feature = "serde", serde(rename(serialize = "doppler")))] pub doppler: i32, /// Carrier Doppler frequency standard deviation. + #[cfg_attr(feature = "serde", serde(rename(serialize = "doppler_std")))] pub doppler_std: u16, /// Number of seconds of continuous tracking. Specifies how much time signal /// is in continuous track. + #[cfg_attr(feature = "serde", serde(rename(serialize = "uptime")))] pub uptime: u32, /// TCXO clock offset. Valid only when valid clock valid flag is set. + #[cfg_attr(feature = "serde", serde(rename(serialize = "clock_offset")))] pub clock_offset: i16, /// TCXO clock drift. Valid only when valid clock valid flag is set. + #[cfg_attr(feature = "serde", serde(rename(serialize = "clock_drift")))] pub clock_drift: i16, /// Early-Prompt (EP) and Prompt-Late (PL) correlators spacing. + #[cfg_attr(feature = "serde", serde(rename(serialize = "corr_spacing")))] pub corr_spacing: u16, /// Acceleration. Valid only when acceleration valid flag is set. + #[cfg_attr(feature = "serde", serde(rename(serialize = "acceleration")))] pub acceleration: i8, /// Synchronization status flags. + #[cfg_attr(feature = "serde", serde(rename(serialize = "sync_flags")))] pub sync_flags: u8, /// TOW status flags. + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow_flags")))] pub tow_flags: u8, /// Tracking loop status flags. + #[cfg_attr(feature = "serde", serde(rename(serialize = "track_flags")))] pub track_flags: u8, /// Navigation data status flags. + #[cfg_attr(feature = "serde", serde(rename(serialize = "nav_flags")))] pub nav_flags: u8, /// Parameters sets flags. + #[cfg_attr(feature = "serde", serde(rename(serialize = "pset_flags")))] pub pset_flags: u8, /// Miscellaneous flags. + #[cfg_attr(feature = "serde", serde(rename(serialize = "misc_flags")))] pub misc_flags: u8, } -impl MsgTrackingStateDetailedDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgTrackingStateDetailedDepA{ - sender_id: None, - recv_time: _buf.read_u64::()?, - tot: GPSTime::parse(_buf)?, - P: _buf.read_u32::()?, - P_std: _buf.read_u16::()?, - L: CarrierPhase::parse(_buf)?, - cn0: _buf.read_u8()?, - lock: _buf.read_u16::()?, - sid: GnssSignal::parse(_buf)?, - doppler: _buf.read_i32::()?, - doppler_std: _buf.read_u16::()?, - uptime: _buf.read_u32::()?, - clock_offset: _buf.read_i16::()?, - clock_drift: _buf.read_i16::()?, - corr_spacing: _buf.read_u16::()?, - acceleration: _buf.read_i8()?, - sync_flags: _buf.read_u8()?, - tow_flags: _buf.read_u8()?, - track_flags: _buf.read_u8()?, - nav_flags: _buf.read_u8()?, - pset_flags: _buf.read_u8()?, - misc_flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgTrackingStateDetailedDepA { + const MESSAGE_TYPE: u16 = 33; + const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE_DETAILED_DEP_A"; } -impl super::SBPMessage for MsgTrackingStateDetailedDepA { - fn get_message_name(&self) -> &'static str { - "MSG_TRACKING_STATE_DETAILED_DEP_A" - } - fn get_message_type(&self) -> u16 { - 33 +impl SbpMessage for MsgTrackingStateDetailedDepA { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } } -impl super::ConcreteMessage for MsgTrackingStateDetailedDepA { - const MESSAGE_TYPE: u16 = 33; - const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE_DETAILED_DEP_A"; -} -impl TryFrom for MsgTrackingStateDetailedDepA { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgTrackingStateDetailedDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgTrackingStateDetailedDepA(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgTrackingStateDetailedDepA(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgTrackingStateDetailedDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.recv_time.append_to_sbp_buffer(buf); - self.tot.append_to_sbp_buffer(buf); - self.P.append_to_sbp_buffer(buf); - self.P_std.append_to_sbp_buffer(buf); - self.L.append_to_sbp_buffer(buf); - self.cn0.append_to_sbp_buffer(buf); - self.lock.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - self.doppler.append_to_sbp_buffer(buf); - self.doppler_std.append_to_sbp_buffer(buf); - self.uptime.append_to_sbp_buffer(buf); - self.clock_offset.append_to_sbp_buffer(buf); - self.clock_drift.append_to_sbp_buffer(buf); - self.corr_spacing.append_to_sbp_buffer(buf); - self.acceleration.append_to_sbp_buffer(buf); - self.sync_flags.append_to_sbp_buffer(buf); - self.tow_flags.append_to_sbp_buffer(buf); - self.track_flags.append_to_sbp_buffer(buf); - self.nav_flags.append_to_sbp_buffer(buf); - self.pset_flags.append_to_sbp_buffer(buf); - self.misc_flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.recv_time.sbp_size(); - size += self.tot.sbp_size(); - size += self.P.sbp_size(); - size += self.P_std.sbp_size(); - size += self.L.sbp_size(); - size += self.cn0.sbp_size(); - size += self.lock.sbp_size(); - size += self.sid.sbp_size(); - size += self.doppler.sbp_size(); - size += self.doppler_std.sbp_size(); - size += self.uptime.sbp_size(); - size += self.clock_offset.sbp_size(); - size += self.clock_drift.sbp_size(); - size += self.corr_spacing.sbp_size(); - size += self.acceleration.sbp_size(); - size += self.sync_flags.sbp_size(); - size += self.tow_flags.sbp_size(); - size += self.track_flags.sbp_size(); - size += self.nav_flags.sbp_size(); - size += self.pset_flags.sbp_size(); - size += self.misc_flags.sbp_size(); - size +impl WireFormat for MsgTrackingStateDetailedDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.recv_time) + + WireFormat::encoded_len(&self.tot) + + WireFormat::encoded_len(&self.p) + + WireFormat::encoded_len(&self.p_std) + + WireFormat::encoded_len(&self.l) + + WireFormat::encoded_len(&self.cn0) + + WireFormat::encoded_len(&self.lock) + + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.doppler) + + WireFormat::encoded_len(&self.doppler_std) + + WireFormat::encoded_len(&self.uptime) + + WireFormat::encoded_len(&self.clock_offset) + + WireFormat::encoded_len(&self.clock_drift) + + WireFormat::encoded_len(&self.corr_spacing) + + WireFormat::encoded_len(&self.acceleration) + + WireFormat::encoded_len(&self.sync_flags) + + WireFormat::encoded_len(&self.tow_flags) + + WireFormat::encoded_len(&self.track_flags) + + WireFormat::encoded_len(&self.nav_flags) + + WireFormat::encoded_len(&self.pset_flags) + + WireFormat::encoded_len(&self.misc_flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.recv_time, buf); + WireFormat::write(&self.tot, buf); + WireFormat::write(&self.p, buf); + WireFormat::write(&self.p_std, buf); + WireFormat::write(&self.l, buf); + WireFormat::write(&self.cn0, buf); + WireFormat::write(&self.lock, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.doppler, buf); + WireFormat::write(&self.doppler_std, buf); + WireFormat::write(&self.uptime, buf); + WireFormat::write(&self.clock_offset, buf); + WireFormat::write(&self.clock_drift, buf); + WireFormat::write(&self.corr_spacing, buf); + WireFormat::write(&self.acceleration, buf); + WireFormat::write(&self.sync_flags, buf); + WireFormat::write(&self.tow_flags, buf); + WireFormat::write(&self.track_flags, buf); + WireFormat::write(&self.nav_flags, buf); + WireFormat::write(&self.pset_flags, buf); + WireFormat::write(&self.misc_flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgTrackingStateDetailedDepA { + sender_id: None, + recv_time: WireFormat::parse_unchecked(buf), + tot: WireFormat::parse_unchecked(buf), + p: WireFormat::parse_unchecked(buf), + p_std: WireFormat::parse_unchecked(buf), + l: WireFormat::parse_unchecked(buf), + cn0: WireFormat::parse_unchecked(buf), + lock: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + doppler: WireFormat::parse_unchecked(buf), + doppler_std: WireFormat::parse_unchecked(buf), + uptime: WireFormat::parse_unchecked(buf), + clock_offset: WireFormat::parse_unchecked(buf), + clock_drift: WireFormat::parse_unchecked(buf), + corr_spacing: WireFormat::parse_unchecked(buf), + acceleration: WireFormat::parse_unchecked(buf), + sync_flags: WireFormat::parse_unchecked(buf), + tow_flags: WireFormat::parse_unchecked(buf), + track_flags: WireFormat::parse_unchecked(buf), + nav_flags: WireFormat::parse_unchecked(buf), + pset_flags: WireFormat::parse_unchecked(buf), + misc_flags: WireFormat::parse_unchecked(buf), + } } } @@ -981,60 +912,36 @@ impl crate::serialize::SbpSerialize for MsgTrackingStateDetailedDepA { /// /// Measurement Engine tracking channel state for a specific satellite signal /// and measured signal power. The mesid field for Glonass can either carry -/// the FCN as 100 + FCN where FCN is in [-7, +6] or the Slot ID (from 1 to +/// the FCN as 100 + FCN where FCN is in \[-7, +6\] or the Slot ID (from 1 to /// 28). /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MeasurementState { /// Measurement Engine GNSS signal being tracked (carries either Glonass FCN /// or SLOT) + #[cfg_attr(feature = "serde", serde(rename(serialize = "mesid")))] pub mesid: GnssSignal, /// Carrier-to-Noise density. Zero implies invalid cn0. + #[cfg_attr(feature = "serde", serde(rename(serialize = "cn0")))] pub cn0: u8, } -impl MeasurementState { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MeasurementState{ - mesid: GnssSignal::parse(_buf)?, - cn0: _buf.read_u8()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(MeasurementState::parse(buf)?); - } - Ok(v) +impl WireFormat for MeasurementState { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.mesid) + WireFormat::encoded_len(&self.cn0) } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(MeasurementState::parse(buf)?); - } - Ok(v) + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.mesid, buf); + WireFormat::write(&self.cn0, buf); } -} - -impl crate::serialize::SbpSerialize for MeasurementState { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.mesid.append_to_sbp_buffer(buf); - self.cn0.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.mesid.sbp_size(); - size += self.cn0.sbp_size(); - size + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MeasurementState { + mesid: WireFormat::parse_unchecked(buf), + cn0: WireFormat::parse_unchecked(buf), + } } } @@ -1042,56 +949,32 @@ impl crate::serialize::SbpSerialize for MeasurementState { /// /// Structure containing in-phase and quadrature correlation components. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct TrackingChannelCorrelation { /// In-phase correlation - pub I: i16, + #[cfg_attr(feature = "serde", serde(rename(serialize = "I")))] + pub i: i16, /// Quadrature correlation - pub Q: i16, + #[cfg_attr(feature = "serde", serde(rename(serialize = "Q")))] + pub q: i16, } -impl TrackingChannelCorrelation { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( TrackingChannelCorrelation{ - I: _buf.read_i16::()?, - Q: _buf.read_i16::()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(TrackingChannelCorrelation::parse(buf)?); - } - Ok(v) +impl WireFormat for TrackingChannelCorrelation { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.i) + WireFormat::encoded_len(&self.q) } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(TrackingChannelCorrelation::parse(buf)?); - } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for TrackingChannelCorrelation { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.I.append_to_sbp_buffer(buf); - self.Q.append_to_sbp_buffer(buf); + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.i, buf); + WireFormat::write(&self.q, buf); } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.I.sbp_size(); - size += self.Q.sbp_size(); - size + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + TrackingChannelCorrelation { + i: WireFormat::parse_unchecked(buf), + q: WireFormat::parse_unchecked(buf), + } } } @@ -1099,58 +982,32 @@ impl crate::serialize::SbpSerialize for TrackingChannelCorrelation { /// /// Structure containing in-phase and quadrature correlation components. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct TrackingChannelCorrelationDep { /// In-phase correlation - pub I: i32, + #[cfg_attr(feature = "serde", serde(rename(serialize = "I")))] + pub i: i32, /// Quadrature correlation - pub Q: i32, + #[cfg_attr(feature = "serde", serde(rename(serialize = "Q")))] + pub q: i32, } -impl TrackingChannelCorrelationDep { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( TrackingChannelCorrelationDep{ - I: _buf.read_i32::()?, - Q: _buf.read_i32::()?, - } ) - } - pub fn parse_array( - buf: &mut &[u8], - ) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(TrackingChannelCorrelationDep::parse(buf)?); - } - Ok(v) +impl WireFormat for TrackingChannelCorrelationDep { + const MIN_ENCODED_LEN: usize = + ::MIN_ENCODED_LEN + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.i) + WireFormat::encoded_len(&self.q) } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(TrackingChannelCorrelationDep::parse(buf)?); - } - Ok(v) + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.i, buf); + WireFormat::write(&self.q, buf); } -} - -impl crate::serialize::SbpSerialize for TrackingChannelCorrelationDep { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.I.append_to_sbp_buffer(buf); - self.Q.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.I.sbp_size(); - size += self.Q.sbp_size(); - size + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + TrackingChannelCorrelationDep { + i: WireFormat::parse_unchecked(buf), + q: WireFormat::parse_unchecked(buf), + } } } @@ -1159,61 +1016,40 @@ impl crate::serialize::SbpSerialize for TrackingChannelCorrelationDep { /// Tracking channel state for a specific satellite signal and measured signal /// power. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct TrackingChannelState { /// GNSS signal being tracked + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignal, /// Frequency channel number (GLONASS only) + #[cfg_attr(feature = "serde", serde(rename(serialize = "fcn")))] pub fcn: u8, /// Carrier-to-Noise density. Zero implies invalid cn0. + #[cfg_attr(feature = "serde", serde(rename(serialize = "cn0")))] pub cn0: u8, } -impl TrackingChannelState { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( TrackingChannelState{ - sid: GnssSignal::parse(_buf)?, - fcn: _buf.read_u8()?, - cn0: _buf.read_u8()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(TrackingChannelState::parse(buf)?); +impl WireFormat for TrackingChannelState { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.fcn) + + WireFormat::encoded_len(&self.cn0) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.fcn, buf); + WireFormat::write(&self.cn0, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + TrackingChannelState { + sid: WireFormat::parse_unchecked(buf), + fcn: WireFormat::parse_unchecked(buf), + cn0: WireFormat::parse_unchecked(buf), } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(TrackingChannelState::parse(buf)?); - } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for TrackingChannelState { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.sid.append_to_sbp_buffer(buf); - self.fcn.append_to_sbp_buffer(buf); - self.cn0.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.sid.sbp_size(); - size += self.fcn.sbp_size(); - size += self.cn0.sbp_size(); - size } } @@ -1221,61 +1057,40 @@ impl crate::serialize::SbpSerialize for TrackingChannelState { /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct TrackingChannelStateDepA { /// Status of tracking channel + #[cfg_attr(feature = "serde", serde(rename(serialize = "state")))] pub state: u8, /// PRN-1 being tracked + #[cfg_attr(feature = "serde", serde(rename(serialize = "prn")))] pub prn: u8, /// Carrier-to-noise density + #[cfg_attr(feature = "serde", serde(rename(serialize = "cn0")))] pub cn0: f32, } -impl TrackingChannelStateDepA { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( TrackingChannelStateDepA{ - state: _buf.read_u8()?, - prn: _buf.read_u8()?, - cn0: _buf.read_f32::()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(TrackingChannelStateDepA::parse(buf)?); - } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(TrackingChannelStateDepA::parse(buf)?); +impl WireFormat for TrackingChannelStateDepA { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.state) + + WireFormat::encoded_len(&self.prn) + + WireFormat::encoded_len(&self.cn0) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.state, buf); + WireFormat::write(&self.prn, buf); + WireFormat::write(&self.cn0, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + TrackingChannelStateDepA { + state: WireFormat::parse_unchecked(buf), + prn: WireFormat::parse_unchecked(buf), + cn0: WireFormat::parse_unchecked(buf), } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for TrackingChannelStateDepA { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.state.append_to_sbp_buffer(buf); - self.prn.append_to_sbp_buffer(buf); - self.cn0.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.state.sbp_size(); - size += self.prn.sbp_size(); - size += self.cn0.sbp_size(); - size } } @@ -1283,60 +1098,39 @@ impl crate::serialize::SbpSerialize for TrackingChannelStateDepA { /// /// Deprecated. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct TrackingChannelStateDepB { /// Status of tracking channel + #[cfg_attr(feature = "serde", serde(rename(serialize = "state")))] pub state: u8, /// GNSS signal being tracked + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] pub sid: GnssSignalDep, /// Carrier-to-noise density + #[cfg_attr(feature = "serde", serde(rename(serialize = "cn0")))] pub cn0: f32, } -impl TrackingChannelStateDepB { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( TrackingChannelStateDepB{ - state: _buf.read_u8()?, - sid: GnssSignalDep::parse(_buf)?, - cn0: _buf.read_f32::()?, - } ) - } - pub fn parse_array(buf: &mut &[u8]) -> Result, crate::Error> { - let mut v = Vec::new(); - while buf.len() > 0 { - v.push(TrackingChannelStateDepB::parse(buf)?); +impl WireFormat for TrackingChannelStateDepB { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.state) + + WireFormat::encoded_len(&self.sid) + + WireFormat::encoded_len(&self.cn0) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.state, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.cn0, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + TrackingChannelStateDepB { + state: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + cn0: WireFormat::parse_unchecked(buf), } - Ok(v) - } - - pub fn parse_array_limit( - buf: &mut &[u8], - n: usize, - ) -> Result, crate::Error> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(TrackingChannelStateDepB::parse(buf)?); - } - Ok(v) - } -} - -impl crate::serialize::SbpSerialize for TrackingChannelStateDepB { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.state.append_to_sbp_buffer(buf); - self.sid.append_to_sbp_buffer(buf); - self.cn0.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.state.sbp_size(); - size += self.sid.sbp_size(); - size += self.cn0.sbp_size(); - size } } diff --git a/rust/sbp/src/messages/unknown.rs b/rust/sbp/src/messages/unknown.rs index bad65bfa53..33b65955cb 100644 --- a/rust/sbp/src/messages/unknown.rs +++ b/rust/sbp/src/messages/unknown.rs @@ -1,50 +1,53 @@ -use crate::{messages::SBPMessage, serialize::SbpSerialize}; +//! Unknown messages. -#[cfg(feature = "sbp_serde")] -use serde::{Deserialize, Serialize}; +use bytes::BytesMut; -#[cfg_attr(feature = "sbp_serde", derive(Serialize, Deserialize))] +use crate::{wire_format::WireFormat, SbpMessage}; + +/// The message returned by the parser when the message type does not correspond to a known message. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Debug, Clone)] pub struct Unknown { + /// The message id of the message. pub msg_id: u16, - pub sender_id: u16, + /// The message sender_id. + pub sender_id: Option, + /// Raw payload of the message. pub payload: Vec, } -impl SbpSerialize for Unknown { - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - buf.extend(&self.payload); - } - - fn sbp_size(&self) -> usize { - self.payload.len() - } -} - -impl SBPMessage for Unknown { - fn get_message_name(&self) -> &'static str { +impl SbpMessage for Unknown { + fn message_name(&self) -> &'static str { "UNKNOWN" } - fn get_message_type(&self) -> u16 { + fn message_type(&self) -> u16 { self.msg_id } - fn get_sender_id(&self) -> Option { - Some(self.sender_id) + fn sender_id(&self) -> Option { + self.sender_id } fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = new_id; + self.sender_id = Some(new_id); + } +} + +impl WireFormat for Unknown { + fn encoded_len(&self) -> usize { + self.payload.encoded_len() } - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) + fn write(&self, buf: &mut BytesMut) { + self.payload.write(buf) } - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) + fn parse_unchecked(buf: &mut BytesMut) -> Self { + Unknown { + msg_id: 0, + sender_id: None, + payload: WireFormat::parse_unchecked(buf), + } } } diff --git a/rust/sbp/src/messages/user.rs b/rust/sbp/src/messages/user.rs index 96439c156c..a4cc79fe96 100644 --- a/rust/sbp/src/messages/user.rs +++ b/rust/sbp/src/messages/user.rs @@ -14,92 +14,66 @@ //****************************************************************************/ //! Messages reserved for use by the user. -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; +use super::lib::*; /// User data /// /// This message can contain any application specific user data up to a /// maximum length of 255 bytes per message. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgUserData { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// User data payload + #[cfg_attr(feature = "serde", serde(rename(serialize = "contents")))] pub contents: Vec, } -impl MsgUserData { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgUserData{ - sender_id: None, - contents: crate::parser::read_u8_array(_buf)?, - } ) - } +impl ConcreteMessage for MsgUserData { + const MESSAGE_TYPE: u16 = 2048; + const MESSAGE_NAME: &'static str = "MSG_USER_DATA"; } -impl super::SBPMessage for MsgUserData { - fn get_message_name(&self) -> &'static str { - "MSG_USER_DATA" - } - fn get_message_type(&self) -> u16 { - 2048 +impl SbpMessage for MsgUserData { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } -} -impl super::ConcreteMessage for MsgUserData { - const MESSAGE_TYPE: u16 = 2048; - const MESSAGE_NAME: &'static str = "MSG_USER_DATA"; } -impl TryFrom for MsgUserData { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgUserData { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgUserData(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgUserData(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgUserData { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.contents.append_to_sbp_buffer(buf); +impl WireFormat for MsgUserData { + const MIN_ENCODED_LEN: usize = as WireFormat>::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.contents) } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.contents.sbp_size(); - size + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.contents, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgUserData { + sender_id: None, + contents: WireFormat::parse_unchecked(buf), + } } } diff --git a/rust/sbp/src/messages/vehicle.rs b/rust/sbp/src/messages/vehicle.rs index 788667b242..a48f4434cf 100644 --- a/rust/sbp/src/messages/vehicle.rs +++ b/rust/sbp/src/messages/vehicle.rs @@ -14,16 +14,7 @@ //****************************************************************************/ //! Messages from a vehicle. -#[allow(unused_imports)] -use std::convert::TryFrom; - -#[allow(unused_imports)] -use byteorder::{LittleEndian, ReadBytesExt}; - -#[allow(unused_imports)] -use crate::serialize::SbpSerialize; -#[allow(unused_imports)] -use crate::SbpString; +use super::lib::*; /// Vehicle forward (x-axis) velocity /// @@ -37,101 +28,85 @@ use crate::SbpString; /// available to synchronise odometry measurements with GNSS. Processor time /// shall roll over to zero after one week. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgOdometry { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Time field representing either milliseconds in the GPS Week or local CPU /// time from the producing system in milliseconds. See the tow_source flag /// for the exact source of this timestamp. + #[cfg_attr(feature = "serde", serde(rename(serialize = "tow")))] pub tow: u32, /// The signed forward component of vehicle velocity. + #[cfg_attr(feature = "serde", serde(rename(serialize = "velocity")))] pub velocity: i32, /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, } -impl MsgOdometry { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgOdometry{ - sender_id: None, - tow: _buf.read_u32::()?, - velocity: _buf.read_i32::()?, - flags: _buf.read_u8()?, - } ) - } +impl ConcreteMessage for MsgOdometry { + const MESSAGE_TYPE: u16 = 2307; + const MESSAGE_NAME: &'static str = "MSG_ODOMETRY"; } -impl super::SBPMessage for MsgOdometry { - fn get_message_name(&self) -> &'static str { - "MSG_ODOMETRY" - } - fn get_message_type(&self) -> u16 { - 2307 +impl SbpMessage for MsgOdometry { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { let tow_s = (self.tow as f64) / 1000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgOdometry { - const MESSAGE_TYPE: u16 = 2307; - const MESSAGE_NAME: &'static str = "MSG_ODOMETRY"; -} -impl TryFrom for MsgOdometry { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgOdometry { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgOdometry(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgOdometry(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgOdometry { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.tow.append_to_sbp_buffer(buf); - self.velocity.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.tow.sbp_size(); - size += self.velocity.sbp_size(); - size += self.flags.sbp_size(); - size +impl WireFormat for MsgOdometry { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.tow) + + WireFormat::encoded_len(&self.velocity) + + WireFormat::encoded_len(&self.flags) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.velocity, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgOdometry { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + velocity: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } @@ -149,112 +124,98 @@ impl crate::serialize::SbpSerialize for MsgOdometry { /// when a PVT fix becomes available to synchronise wheeltick measurements /// with GNSS. Local CPU time shall roll over to zero after one week. /// -#[cfg_attr(feature = "sbp_serde", derive(serde::Serialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -#[allow(non_snake_case)] pub struct MsgWheeltick { - #[cfg_attr(feature = "sbp_serde", serde(skip_serializing))] + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] pub sender_id: Option, /// Time field representing either microseconds since the last PPS, /// microseconds in the GPS Week or local CPU time from the producing system /// in microseconds. See the synch_type field for the exact meaning of this /// timestamp. + #[cfg_attr(feature = "serde", serde(rename(serialize = "time")))] pub time: u64, /// Field indicating the type of timestamp contained in the time field. + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] pub flags: u8, /// ID of the sensor producing this message + #[cfg_attr(feature = "serde", serde(rename(serialize = "source")))] pub source: u8, /// Free-running counter of the accumulated distance for this sensor. The /// counter should be incrementing if travelling into one direction and /// decrementing when travelling in the opposite direction. + #[cfg_attr(feature = "serde", serde(rename(serialize = "ticks")))] pub ticks: i32, } -impl MsgWheeltick { - #[rustfmt::skip] - pub fn parse(_buf: &mut &[u8]) -> Result { - Ok( MsgWheeltick{ - sender_id: None, - time: _buf.read_u64::()?, - flags: _buf.read_u8()?, - source: _buf.read_u8()?, - ticks: _buf.read_i32::()?, - } ) - } +impl ConcreteMessage for MsgWheeltick { + const MESSAGE_TYPE: u16 = 2308; + const MESSAGE_NAME: &'static str = "MSG_WHEELTICK"; } -impl super::SBPMessage for MsgWheeltick { - fn get_message_name(&self) -> &'static str { - "MSG_WHEELTICK" - } - fn get_message_type(&self) -> u16 { - 2308 +impl SbpMessage for MsgWheeltick { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - - fn get_sender_id(&self) -> Option { + fn message_type(&self) -> u16 { + ::MESSAGE_TYPE + } + fn sender_id(&self) -> Option { self.sender_id } - fn set_sender_id(&mut self, new_id: u16) { self.sender_id = Some(new_id); } - - fn to_frame(&self) -> std::result::Result, crate::FramerError> { - let mut frame = Vec::new(); - self.write_frame(&mut frame)?; - Ok(frame) - } - - fn write_frame(&self, frame: &mut Vec) -> std::result::Result<(), crate::FramerError> { - crate::write_frame(self, frame) - } - #[cfg(feature = "swiftnav")] - fn gps_time( - &self, - ) -> Option> { + fn gps_time(&self) -> Option> { // only consider wheelticks with synchronization type value "microsec in GPS week" if self.flags != 1 { return None; } let tow_s = (self.time as f64) / 1000000.0; - let gps_time = match crate::time::GpsTime::new(0, tow_s) { + let gps_time = match time::GpsTime::new(0, tow_s) { Ok(gps_time) => gps_time.tow(), Err(e) => return Some(Err(e.into())), }; - Some(Ok(crate::time::MessageTime::Rover(gps_time.into()))) + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -impl super::ConcreteMessage for MsgWheeltick { - const MESSAGE_TYPE: u16 = 2308; - const MESSAGE_NAME: &'static str = "MSG_WHEELTICK"; -} -impl TryFrom for MsgWheeltick { - type Error = super::TryFromSBPError; - fn try_from(msg: super::SBP) -> Result { +impl TryFrom for MsgWheeltick { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { match msg { - super::SBP::MsgWheeltick(m) => Ok(m), - _ => Err(super::TryFromSBPError), + Sbp::MsgWheeltick(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -impl crate::serialize::SbpSerialize for MsgWheeltick { - #[allow(unused_variables)] - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - self.time.append_to_sbp_buffer(buf); - self.flags.append_to_sbp_buffer(buf); - self.source.append_to_sbp_buffer(buf); - self.ticks.append_to_sbp_buffer(buf); - } - - fn sbp_size(&self) -> usize { - let mut size = 0; - size += self.time.sbp_size(); - size += self.flags.sbp_size(); - size += self.source.sbp_size(); - size += self.ticks.sbp_size(); - size +impl WireFormat for MsgWheeltick { + const MIN_ENCODED_LEN: usize = ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN + + ::MIN_ENCODED_LEN; + fn encoded_len(&self) -> usize { + WireFormat::encoded_len(&self.time) + + WireFormat::encoded_len(&self.flags) + + WireFormat::encoded_len(&self.source) + + WireFormat::encoded_len(&self.ticks) + } + fn write(&self, buf: &mut bytes::BytesMut) { + WireFormat::write(&self.time, buf); + WireFormat::write(&self.flags, buf); + WireFormat::write(&self.source, buf); + WireFormat::write(&self.ticks, buf); + } + fn parse_unchecked(buf: &mut bytes::BytesMut) -> Self { + MsgWheeltick { + sender_id: None, + time: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + source: WireFormat::parse_unchecked(buf), + ticks: WireFormat::parse_unchecked(buf), + } } } diff --git a/rust/sbp/src/parser.rs b/rust/sbp/src/parser.rs deleted file mode 100644 index e073e3b832..0000000000 --- a/rust/sbp/src/parser.rs +++ /dev/null @@ -1,360 +0,0 @@ -//! Simple parsing functionality for extracting SBP -//! messages from binary streams - -use byteorder::{LittleEndian, ReadBytesExt}; -use nom::Err as NomErr; - -use crate::{messages::SBP, Error, Result, SbpString}; - -pub fn read_string(buf: &mut &[u8]) -> Result { - let amount = buf.len(); - let (head, tail) = buf.split_at(amount); - *buf = tail; - Ok(SbpString(head.to_vec())) -} - -pub fn read_string_limit(buf: &mut &[u8], n: usize) -> Result { - let n = std::cmp::min(n, buf.len()); - let (mut head, tail) = buf.split_at(n); - read_string(&mut head).map(|sbp_string| { - *buf = tail; - sbp_string - }) -} - -pub fn read_u16_array(buf: &mut &[u8]) -> Result> { - // buf is in fact an array of u16, so at least 2 u8 elem, unless buf is empty - let iter = buf.chunks_exact(2); - // collect() guarantees that it will return Err if at least one Err is found while iterating - // over the Vec https://doc.rust-lang.org/std/iter/trait.FromIterator.html#method.from_iter-14 - // map_err necessary to convert the generic read_u16's Error into our Error enum type - // LittleEndian means chunks are read from right-to-left - let v = iter - .map(|mut x| x.read_u16::().map_err(|e| e.into())) - .collect(); - v -} - -pub fn read_u8_array(buf: &mut &[u8]) -> Result> { - Ok(buf.to_vec()) -} - -pub fn read_u8_array_limit(buf: &mut &[u8], n: usize) -> Result> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(buf.read_u8()?); - } - Ok(v) -} - -pub fn read_s8_array_limit(buf: &mut &[u8], n: usize) -> Result> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(buf.read_i8()?); - } - Ok(v) -} - -pub fn read_s16_array_limit(buf: &mut &[u8], n: usize) -> Result> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(buf.read_i16::()?); - } - Ok(v) -} - -pub fn read_u16_array_limit(buf: &mut &[u8], n: usize) -> Result> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(buf.read_u16::()?); - } - Ok(v) -} - -pub fn read_float_array_limit(buf: &mut &[u8], n: usize) -> Result> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(buf.read_f32::()?); - } - Ok(v) -} - -pub fn read_double_array_limit(buf: &mut &[u8], n: usize) -> Result> { - let mut v = Vec::new(); - for _ in 0..n { - v.push(buf.read_f64::()?); - } - Ok(v) -} - -#[derive(Debug)] -pub enum ParseResult { - Ok((usize, SBP)), - Err((usize, Error)), - Incomplete, -} - -pub fn parse_sbp<'a>(input: &'a [u8]) -> ParseResult { - let (new_input, mut frame) = match frame::parse(input) { - Ok(res) => res, - Err(e) => match e { - NomErr::Incomplete(_) => return ParseResult::Incomplete, - NomErr::Error((_, kind)) | NomErr::Failure((_, kind)) => { - return ParseResult::Err((1, Error::ParseError { kind })) - } - }, - }; - - let bytes_read = input.len() - new_input.len(); - - if !frame::check_crc(&frame) { - return ParseResult::Err(( - bytes_read, - Error::CrcError { - msg_type: frame.1, - sender_id: frame.2, - crc: frame.4, - }, - )); - } - - let msg = match SBP::parse(frame.1, frame.2, &mut frame.3) { - Ok(msg) => msg, - Err(err) => return ParseResult::Err((bytes_read, err)), - }; - - ParseResult::Ok((bytes_read, msg)) -} - -pub mod frame { - use nom::{bytes, error::ErrorKind, number, sequence::tuple, IResult}; - - pub type Frame<'a> = (&'a [u8], u16, u16, &'a [u8], u16); - - pub type Error<'a> = (&'a [u8], ErrorKind); - - pub fn parse(i: &[u8]) -> IResult<&[u8], Frame, Error> { - tuple(( - parse_preamble, - parse_msg_type, - parse_sender_id, - parse_payload, - parse_crc, - ))(i) - } - - pub fn check_crc((_preamble, msg_type, sender_id, payload, crc_in): &Frame) -> bool { - let mut crc = crc16::State::::new(); - - crc.update(&msg_type.to_le_bytes()); - crc.update(&sender_id.to_le_bytes()); - crc.update(&[payload.len() as u8]); - crc.update(payload); - - crc.get() == *crc_in - } - - fn parse_preamble(i: &[u8]) -> IResult<&[u8], &[u8], Error> { - bytes::streaming::is_a("\x55")(i) - } - - fn parse_msg_type(i: &[u8]) -> IResult<&[u8], u16, Error> { - number::streaming::le_u16(i) - } - - fn parse_sender_id(i: &[u8]) -> IResult<&[u8], u16, Error> { - number::streaming::le_u16(i) - } - - fn parse_payload(i: &[u8]) -> IResult<&[u8], &[u8], Error> { - let (i, length) = number::streaming::le_u8(i)?; - bytes::streaming::take(length)(i) - } - - fn parse_crc(i: &[u8]) -> IResult<&[u8], u16, Error> { - number::streaming::le_u16(i) - } -} - -#[cfg(test)] -mod tests { - use std::io::Cursor; - - use crate::serialize::SbpSerialize; - - use super::*; - - #[test] - fn test_parse_sbp() { - let packet = [ - 0x55u8, 0x0b, 0x02, 0xd3, 0x88, 0x14, 0x28, 0xf4, 0x7a, 0x13, 0x96, 0x62, 0xee, 0xff, - 0xbe, 0x40, 0x14, 0x00, 0xf6, 0xa3, 0x09, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xdb, 0xbf, - ]; - let baseline_ecef_expectation = crate::messages::navigation::MsgBaselineECEF { - sender_id: Some(0x88d3), - accuracy: 0, - flags: 0, - n_sats: 14, - tow: 326825000, - x: -1154410, - y: 1327294, - z: 631798, - }; - - let (consumed, msg) = match parse_sbp(&packet[..]) { - ParseResult::Ok((consumed, SBP::MsgBaselineECEF(msg))) => (consumed, msg), - err => panic!("unexpected parse result: {:?}", err), - }; - - assert_eq!(packet.len(), consumed); - - assert_eq!(msg.sender_id, baseline_ecef_expectation.sender_id); - assert_eq!(msg.accuracy, baseline_ecef_expectation.accuracy); - assert_eq!(msg.flags, baseline_ecef_expectation.flags); - assert_eq!(msg.n_sats, baseline_ecef_expectation.n_sats); - assert_eq!(msg.tow, baseline_ecef_expectation.tow); - assert_eq!(msg.x, baseline_ecef_expectation.x); - assert_eq!(msg.y, baseline_ecef_expectation.y); - assert_eq!(msg.z, baseline_ecef_expectation.z); - } - - /// Test parsing when we don't have enough data for a frame message - #[test] - fn test_parse_sbp_eof() { - let packet = [ - 0x55u8, 0x0b, 0x02, 0xd3, 0x88, 0x14, 0x28, 0xf4, 0x7a, 0x13, 0x96, 0x62, 0xee, 0xff, - 0xbe, 0x40, 0x14, 0x00, 0xf6, 0xa3, 0x09, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xdb, 0xbf, - ]; - - let res = parse_sbp(&packet[..packet.len() - 1]); - - assert!(matches!(res, ParseResult::Incomplete)); - - let res = parse_sbp(&packet[..]); - - assert!(matches!( - res, - ParseResult::Ok((28, SBP::MsgBaselineECEF(_))) - )); - } - - #[test] - fn test_parse_sbp_crc_error() { - let packet = vec![ - // Start with a mostly valid message, with a single byte error - 0x55, 0x0c, // This byte should be 0x0b, changed to intentionally cause a CRC error - 0x02, 0xd3, 0x88, 0x14, 0x28, 0xf4, 0x7a, 0x13, 0x96, 0x62, 0xee, 0xff, 0xbe, 0x40, - 0x14, 0x00, 0xf6, 0xa3, 0x09, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xdb, 0xbf, 0xde, 0xad, - 0xbe, 0xef, // Include another valid message to properly parse - 0x55, 0x0b, 0x02, 0xd3, 0x88, 0x14, 0x28, 0xf4, 0x7a, 0x13, 0x96, 0x62, 0xee, 0xff, - 0xbe, 0x40, 0x14, 0x00, 0xf6, 0xa3, 0x09, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xdb, 0xbf, - 0xde, 0xad, 0xbe, 0xef, - ]; - - let reader = Cursor::new(packet); - let mut msgs = crate::iter_messages(reader); - - let res = msgs.next().unwrap().unwrap_err(); - assert!(matches!(res, Error::CrcError { .. })); - - let res = msgs.next().unwrap(); - assert!(res.is_ok()); - } - - #[test] - fn test_parser_iter() { - let mut payload = vec![ - 0x55u8, 0x0b, 0x02, 0xd3, 0x88, 0x14, 0x28, 0xf4, 0x7a, 0x13, 0x96, 0x62, 0xee, 0xff, - 0xbe, 0x40, 0x14, 0x00, 0xf6, 0xa3, 0x09, 0x00, 0x00, 0x00, 0x0e, 0x00, 0xdb, 0xbf, - ]; - payload.append(&mut payload.clone()); - - let input = Cursor::new(payload); - - let mut count = 0; - - for msg in crate::iter_messages(input) { - assert!(msg.is_ok()); - count += 1; - } - - assert_eq!(count, 2); - } - - #[test] - fn test_invalid_utf8() { - let packet = vec![ - 0x55, 0xa7, 0x0, 0x0, 0x10, 0x48, 0x8, 0x0, 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x69, 0x6f, - 0x6e, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xb6, 0xe8, 0xab, - ]; - - let reader = Cursor::new(packet); - let mut msgs = crate::iter_messages(reader); - - let sbp_result = msgs.next().unwrap(); - - assert!(sbp_result.is_ok()); - - let sbp_message = sbp_result.unwrap(); - - assert_eq!(sbp_message.sbp_size(), 72); - } - #[test] - fn test_read_string_invalid_utf8() { - // (9 * 8) - 2 = 70 - let buf = vec![ - 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0xb6, - ]; - - let mut slice = &buf[..]; - - let sbp_string = read_string(&mut slice).unwrap(); - - let string: String = sbp_string.clone().into(); - let vec: Vec = sbp_string.into(); - - // The last 0xb6 get's transformed into 3 UTF-8 bytes (� aka U+FFFD REPLACEMENT CHARACTER) - assert_eq!(string.len(), 69 + 3); - assert_eq!(vec.len(), 70); - } - - #[test] - fn test_read_string() { - let v = b"hi, imma string"; - let mut slice = &v[..]; - - let string: String = read_string(&mut slice).unwrap().into(); - assert_eq!(string, "hi, imma string".to_string()); - - let string: String = read_string(&mut slice).unwrap().into(); - assert_eq!(string, "".to_string()); - - let v = b"hi, imma string"; - let mut slice = &v[..]; - - let string: String = read_string_limit(&mut slice, 8).unwrap().into(); - assert_eq!(string, "hi, imma".to_string()); - - let string: String = read_string_limit(&mut slice, 8).unwrap().into(); - assert_eq!(string, " string".to_string()); - } - - #[test] - fn test_read_u16_array() { - // A basic unit test for read_u16_array, LittleEndian convention assumed everywhere - let mock_data: [u8; 4] = [0b00000001, 0b00010000, 0b00000010, 0b00000001]; - let mut expected_vec = Vec::with_capacity(2); - // 0b00010000+0b00000001 - expected_vec.push(4097); - expected_vec.push(258); - let returned_vec = read_u16_array(&mut &mock_data[..]).unwrap(); - assert_eq!(expected_vec, returned_vec); - } -} diff --git a/rust/sbp/src/sbp_tools.rs b/rust/sbp/src/sbp_iter_ext.rs similarity index 66% rename from rust/sbp/src/sbp_tools.rs rename to rust/sbp/src/sbp_iter_ext.rs index 8e2afd40fe..46dfe38796 100644 --- a/rust/sbp/src/sbp_tools.rs +++ b/rust/sbp/src/sbp_iter_ext.rs @@ -1,46 +1,58 @@ +//! Extra adaptors for iterators of [Sbp] messages. + #[cfg(feature = "swiftnav")] use swiftnav::time::GpsTime; #[cfg(feature = "swiftnav")] use crate::{ - messages::SBPMessage, + messages::SbpMessage, time::{GpsTimeError, MessageTime, RoverTime}, }; -use crate::messages::SBP; +use crate::{DeserializeError, Sbp}; -pub trait SBPTools: Iterator { - fn ignore_errors(self) -> HandleErrorsIter ControlFlow> +/// An [Iterator] blanket implementation that provides extra adaptors for iterators of [Sbp] messages. +pub trait SbpIterExt: Iterator { + /// Lift an `Iterator>` into an `Iterator` by ignoring all the errors. + /// The iterator will terminate if an io error is encountered. + fn ignore_errors<'a>(self) -> HandleErrorsIter<'a, Self, DeserializeError> where - Self: Iterator> + Sized, + Self: Iterator> + Sized, { - HandleErrorsIter::new(self, |_| ControlFlow::Continue) + HandleErrorsIter::new(self, |e| match e { + DeserializeError::IoError(_) => ControlFlow::Break, + _ => ControlFlow::Continue, + }) } - fn log_errors( - self, - level: log::Level, - ) -> HandleErrorsIter ControlFlow>> + /// Lift an `Iterator>` into an `Iterator` by logging all the errors. + /// The iterator will terminate if an io error is encountered. + fn log_errors<'a>(self, level: log::Level) -> HandleErrorsIter<'a, Self, DeserializeError> where - Self: Iterator> + Sized, + Self: Iterator> + Sized, { - HandleErrorsIter::new( - self, - Box::new(move |e| { - log::log!(level, "{}", e); - ControlFlow::Continue - }), - ) + HandleErrorsIter::new(self, move |e| { + log::log!(level, "{}", e); + match e { + DeserializeError::IoError(_) => ControlFlow::Break, + _ => ControlFlow::Continue, + } + }) } - fn handle_errors(self, on_err: F) -> HandleErrorsIter + /// Lift an `Iterator>` into an `Iterator` with a custom error handler. + /// You can use (ControlFlow)[self::ControlFlow] to determine if the iterator should continue or break on error. + fn handle_errors<'a, E, F>(self, on_err: F) -> HandleErrorsIter<'a, Self, E> where - Self: Iterator> + Sized, - F: FnMut(&crate::Error) -> ControlFlow, + Self: Iterator> + Sized, + F: FnMut(&E) -> ControlFlow + 'a, { HandleErrorsIter::new(self, on_err) } + /// Return an iterable that also includes [GpsTime]s. This method calls [SbpMessage::gps_time] on each message. + /// If the message has a complete GpsTime it is returned. If the message only has a TOW, this itertor will use the + /// last week number it has seen, or return `None` if it hasn't seen any. #[cfg(feature = "swiftnav")] fn with_rover_time(self) -> RoverTimeIter where @@ -50,47 +62,51 @@ pub trait SBPTools: Iterator { } } -impl SBPTools for I where I: Iterator + Sized {} +impl SbpIterExt for I where I: Iterator + Sized {} // A less general https://doc.rust-lang.org/std/ops/enum.ControlFlow.html // could be replaced by that once it's stable +/// Used to tell [HandleErrorsIter] whether it should exit early or go on as usual. pub enum ControlFlow { Continue, Break, } -pub struct HandleErrorsIter +/// See [SbpIterExt::handle_errors] for more information. +pub struct HandleErrorsIter<'a, I, E> where I: Iterator, { messages: I, - on_err: F, - err: crate::Result<()>, + on_err: Box ControlFlow + 'a>, + err: Result<(), E>, } -impl HandleErrorsIter +impl<'a, I, E> HandleErrorsIter<'a, I, E> where - I: Iterator>, + I: Iterator>, { - fn new(messages: I, on_err: F) -> HandleErrorsIter { + fn new(messages: I, on_err: F) -> HandleErrorsIter<'a, I, E> + where + F: FnMut(&E) -> ControlFlow + 'a, + { Self { messages, - on_err, + on_err: Box::new(on_err), err: Ok(()), } } - pub fn check_error(&mut self) -> crate::Result<()> { + pub fn take_err(&mut self) -> Result<(), E> { std::mem::replace(&mut self.err, Ok(())) } } -impl Iterator for HandleErrorsIter +impl<'a, I, E> Iterator for HandleErrorsIter<'a, I, E> where - I: Iterator>, - F: FnMut(&crate::Error) -> ControlFlow, + I: Iterator>, { - type Item = SBP; + type Item = Sbp; fn next(&mut self) -> Option { match self.messages.next()? { @@ -107,6 +123,7 @@ where } } +/// See [SbpIterExt::with_rover_time] for more information. #[cfg(feature = "swiftnav")] pub struct RoverTimeIter { messages: I, @@ -152,9 +169,9 @@ where #[cfg(feature = "swiftnav")] impl Iterator for RoverTimeIter where - I: Iterator, + I: Iterator, { - type Item = (SBP, Option>); + type Item = (Sbp, Option>); fn next(&mut self) -> Option { let msg = self.messages.next()?; @@ -255,15 +272,15 @@ mod tests { msg_count += 1; } assert!(matches!( - messages.check_error(), - Err(crate::Error::CrcError { .. }) + messages.take_err(), + Err(DeserializeError::CrcError { .. }) )); assert_eq!(msg_count, 2); while let Some(_) = messages.next() { msg_count += 1; } - assert!(messages.check_error().is_ok()); + assert!(messages.take_err().is_ok()); assert_eq!(msg_count, 3); assert_eq!(messages.count(), 0); diff --git a/rust/sbp/src/sbp_string.rs b/rust/sbp/src/sbp_string.rs new file mode 100644 index 0000000000..5267b50884 --- /dev/null +++ b/rust/sbp/src/sbp_string.rs @@ -0,0 +1,229 @@ +use std::fmt; +use std::marker::PhantomData; + +use bytes::BytesMut; + +use crate::wire_format::WireFormat; + +/// Fixed or variable length string and its encoding. +#[derive(Debug, Clone)] +pub struct SbpString { + data: T, + encoding: PhantomData, +} + +impl SbpString +where + T: AsRef<[u8]>, +{ + /// Creates a new SbpString. + pub fn new(data: T) -> Self { + Self { + data, + encoding: PhantomData, + } + } + + /// Returns a byte slice of this SbpString's contents. + pub fn as_bytes(&self) -> &[u8] { + self.data.as_ref() + } + + /// Returns a byte vector of this SbpString's contents. + pub fn to_vec(&self) -> Vec { + self.data.as_ref().to_vec() + } +} + +impl From for SbpString, E> { + fn from(s: String) -> Self { + SbpString::new(s.into_bytes()) + } +} + +impl From> for SbpString, E> { + fn from(v: Vec) -> Self { + SbpString::new(v) + } +} + +impl fmt::Display for SbpString +where + T: AsRef<[u8]>, +{ + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", String::from_utf8_lossy(self.as_bytes())) + } +} + +#[cfg(feature = "serde")] +impl serde::Serialize for SbpString +where + T: AsRef<[u8]>, +{ + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + let s = String::from_utf8_lossy(self.as_bytes()); + serializer.serialize_str(&s) + } +} + +impl WireFormat for SbpString<[u8; LEN], E> { + const MIN_ENCODED_LEN: usize = LEN; + + fn encoded_len(&self) -> usize { + LEN + } + + fn write(&self, buf: &mut BytesMut) { + self.data.write(buf) + } + + fn parse_unchecked(buf: &mut BytesMut) -> Self { + let data: [u8; LEN] = WireFormat::parse_unchecked(buf); + SbpString::new(data) + } +} + +macro_rules! forward_payload_vec { + ($encoding:ty, $min_len:expr) => { + impl WireFormat for SbpString, $encoding> { + const MIN_ENCODED_LEN: usize = $min_len; + + fn encoded_len(&self) -> usize { + self.data.encoded_len() + } + + fn write(&self, buf: &mut BytesMut) { + self.data.write(buf) + } + + fn parse_unchecked(buf: &mut BytesMut) -> Self { + let data: Vec = WireFormat::parse_unchecked(buf); + SbpString::new(data) + } + } + }; +} + +/// Handles encoding and decoding of unterminated strings. +/// +/// In SBP an unterminated string is a sequence of characters without a NULL +/// terminator to indicate the end of the string. Unterminated strings can only +/// appear at the end of an SBP payload, their length is indicated by the +/// remaining length of payload when processing incoming data. +/// +/// For example, the string "text" would be represented on the wire as +/// +/// text +#[derive(Debug, Clone, Copy)] +pub struct Unterminated; + +forward_payload_vec!(Unterminated, 0); + +/// Handles encoding and decoding of NULL terminated strings. +/// +/// In SBP a NULL terminated string has the same definition as string in the C +/// language. On the wire it is a sequence of characters with a NULL character to +/// indicate the end of the string. +/// +/// For example the string "text" would be represented on the wire as +/// +/// text\0 +#[derive(Debug, Clone, Copy)] +pub struct NullTerminated; + +forward_payload_vec!(NullTerminated, 1); + +/// Handles encoding and decoding of multipart strings. +/// +/// In SBP a multipart string is not a single C string but a collection of +/// smaller strings (or sections) each separated by a NULL character. +/// +/// For example, a multipart string might contain 3 sections - "one", "two", and +/// "three". On the wire this string would be encoded as +/// +/// one\0two\0three\0 +/// +/// for a total of 14 bytes. +/// +/// A multipart string might contain no sections in which case on the wire it +/// would consist of just a single NULL character. +#[derive(Debug, Clone, Copy)] +pub struct Multipart; + +forward_payload_vec!(Multipart, 0); + +/// Handles encoding and decoding of double NULL terminated strings. +/// +/// In SBP double NULL terminated strings are rather similar to multipart strings +/// except they have an extra NULL terminator at the end of a sequence. A double +/// NULL terminated string is not a single C style string, rather it is a +/// collection of substrings (or sections) each separated on the wire with a NULL +/// terminator with the end of sequence being marked by an extra NULL terminator. +/// +/// For example, a double NULL terminated string might contain 3 sections - +/// "one", "two", and "three". On the wire this string would be encoded as +/// +/// one\0two\0three\0\0 +/// +/// for a total of 15 bytes. +/// +/// A double NULL terminated string might contain no sections in which case on +/// the wire it would consists of just two NULL terminators with no printable +/// text. +#[derive(Debug, Clone, Copy)] +pub struct DoubleNullTerminated; + +forward_payload_vec!(DoubleNullTerminated, 2); + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_parse_sbp_string_vec() { + let mut buf = BytesMut::from(&b"hi, imma string"[..]); + + let actual: SbpString> = WireFormat::parse_unchecked(&mut buf); + assert_eq!(actual.to_string(), "hi, imma string".to_string()); + assert!(buf.is_empty()); + + let actual: SbpString> = WireFormat::parse_unchecked(&mut buf); + assert_eq!(actual.to_string(), "".to_string()); + } + + #[test] + fn test_parse_sbp_string_array() { + let mut buf = BytesMut::from(&b"hi, imma string"[..]); + + let actual: SbpString<[u8; 8]> = WireFormat::parse_unchecked(&mut buf); + assert_eq!(actual.to_string(), "hi, imma".to_string()); + assert_eq!(buf.len(), 7); + + let actual: SbpString<[u8; 7]> = WireFormat::parse_unchecked(&mut buf); + assert_eq!(actual.to_string(), " string".to_string()); + assert!(buf.is_empty()); + } + + #[test] + fn test_parse_sbp_string_invalid_utf8() { + // (9 * 8) - 2 = 70 + let mut buf = BytesMut::from( + &[ + 0x73, 0x6f, 0x6c, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xb6, + ][..], + ); + + let sbp_string: SbpString> = WireFormat::parse_unchecked(&mut buf); + // The last 0xb6 get's transformed into 3 UTF-8 bytes (� aka U+FFFD REPLACEMENT CHARACTER) + assert_eq!(sbp_string.to_string().len(), 69 + 3); + assert_eq!(sbp_string.to_vec().len(), 70); + } +} diff --git a/rust/sbp/src/ser.rs b/rust/sbp/src/ser.rs new file mode 100644 index 0000000000..7607f1276d --- /dev/null +++ b/rust/sbp/src/ser.rs @@ -0,0 +1,214 @@ +use std::borrow::Borrow; +use std::io; + +use bytes::BytesMut; +use dencode::{Encoder, FramedWrite, IterSinkExt}; + +use crate::wire_format::WireFormat; +use crate::{Sbp, SbpMessage}; +use crate::{CRC_LEN, HEADER_LEN, MAX_PAYLOAD_LEN, PREAMBLE}; + +/// Serialize the given message into the IO stream. +/// +/// # Example +/// +/// ``` +/// use sbp::messages::logging::MsgLog; +/// +/// fn main() -> Result<(), Box> { +/// let text = String::from("hello"); +/// let msg = MsgLog { +/// sender_id: Some(1), +/// level: 1, +/// text: text.clone().into(), +/// }; +/// let mut writer = Vec::new(); +/// sbp::to_writer(&mut writer, &msg)?; +/// assert_eq!( +/// &writer[sbp::HEADER_LEN + 1..writer.len() - sbp::CRC_LEN], +/// text.as_bytes() +/// ); +/// Ok(()) +/// } +/// ``` +pub fn to_writer(mut writer: W, msg: &M) -> Result<(), Error> +where + W: io::Write, + M: SbpMessage, +{ + let mut buf = BytesMut::with_capacity(msg.encoded_len() + HEADER_LEN + CRC_LEN); + to_buffer(&mut buf, msg)?; + writer.write_all(&buf)?; + Ok(()) +} + +/// Serialize the given message as a byte vector. +/// +/// # Example +/// +/// ``` +/// use sbp::messages::logging::MsgLog; +/// +/// fn main() -> Result<(), Box> { +/// let text = String::from("hello"); +/// let msg = MsgLog { +/// sender_id: Some(1), +/// level: 1, +/// text: text.clone().into(), +/// }; +/// let bytes = sbp::to_vec(&msg)?; +/// assert_eq!( +/// &bytes[sbp::HEADER_LEN + 1..bytes.len() - sbp::CRC_LEN], +/// text.as_bytes() +/// ); +/// Ok(()) +/// } +/// ``` +pub fn to_vec(msg: &M) -> Result, Error> { + let mut buf = BytesMut::with_capacity(msg.encoded_len() + HEADER_LEN + CRC_LEN); + to_buffer(&mut buf, msg)?; + Ok(buf.to_vec()) +} + +pub fn to_buffer(buf: &mut BytesMut, msg: &M) -> Result<(), WriteFrameError> { + let sender_id = msg.sender_id().ok_or(WriteFrameError::NoSenderId)?; + let payload_len = msg.encoded_len(); + if payload_len > MAX_PAYLOAD_LEN { + return Err(WriteFrameError::TooLarge); + } + + let old_buf = buf.split(); + + PREAMBLE.write(buf); + msg.message_type().write(buf); + sender_id.write(buf); + (payload_len as u8).write(buf); + msg.write(buf); + let crc = crc16::State::::calculate(&buf[1..]); + crc.write(buf); + + buf.unsplit(old_buf); + + Ok(()) +} + +/// All errors that can occur while writing messages. +#[derive(Debug)] +pub enum Error { + WriteFrameError(WriteFrameError), + IoError(io::Error), +} + +impl std::fmt::Display for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Error::WriteFrameError(e) => e.fmt(f), + Error::IoError(e) => e.fmt(f), + } + } +} + +impl std::error::Error for Error {} + +impl From for Error { + fn from(e: WriteFrameError) -> Self { + Error::WriteFrameError(e) + } +} + +impl From for Error { + fn from(e: io::Error) -> Self { + Error::IoError(e) + } +} + +#[derive(Debug, Clone)] +pub enum WriteFrameError { + TooLarge, + NoSenderId, +} + +impl std::fmt::Display for WriteFrameError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + WriteFrameError::TooLarge => write!(f, "message is too large to fit into a frame"), + WriteFrameError::NoSenderId => write!(f, "no sender id present in the message"), + } + } +} + +impl std::error::Error for WriteFrameError {} + +/// Writes [Sbp] messages into a writer. +#[derive(Debug)] +pub struct SbpEncoder(FramedWrite); + +impl SbpEncoder { + /// Creates a new SbpEncoder. + pub fn new(writer: W) -> SbpEncoder { + Self(FramedWrite::new(writer, SbpEncoderInner)) + } + + /// Send a message to the underlying writer. If sending multiple messages at once + /// consider using [SbpEncoder::send_all] which buffers the writing. + pub fn send(&mut self, message: &Sbp) -> Result<(), Error> { + self.0.send(message) + } + + /// Sends an iterator of messages to the underlying writer. + pub fn send_all(&mut self, messages: I) -> Result<(), Error> + where + I: IntoIterator, + { + self.0.send_all(messages.into_iter().map(Result::Ok)) + } +} + +#[derive(Debug)] +struct SbpEncoderInner; + +impl Encoder for SbpEncoderInner +where + T: Borrow, +{ + type Error = Error; + + fn encode(&mut self, msg: T, dst: &mut BytesMut) -> Result<(), Self::Error> { + if let Err(err) = to_buffer(dst, msg.borrow()) { + log::error!("error serializing message: {}", err); + } + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_to_vec() { + let msg = crate::messages::system::MsgStartup { + sender_id: Some(250), + cause: 1, + startup_type: 45, + reserved: 0, + }; + let frame = to_vec(&msg).unwrap(); + let expected_frame = b"\x55\x00\xFF\xFA\x00\x04\x01\x2D\x00\x00\xBC\x73"; + assert_eq!(frame, expected_frame); + } + + #[test] + fn test_to_writer() { + let msg = crate::messages::system::MsgStartup { + sender_id: Some(250), + cause: 1, + startup_type: 45, + reserved: 0, + }; + let mut writer = Vec::new(); + to_writer(&mut writer, &msg).unwrap(); + let expected_frame = b"\x55\x00\xFF\xFA\x00\x04\x01\x2D\x00\x00\xBC\x73"; + assert_eq!(writer, expected_frame); + } +} diff --git a/rust/sbp/src/serialize.rs b/rust/sbp/src/serialize.rs deleted file mode 100644 index a4e7a769d9..0000000000 --- a/rust/sbp/src/serialize.rs +++ /dev/null @@ -1,132 +0,0 @@ -use crate::SbpString; - -pub trait SbpSerialize { - fn append_to_sbp_buffer(&self, buf: &mut Vec); - fn sbp_size(&self) -> usize; -} - -impl SbpSerialize for u8 { - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - buf.extend(&self.to_le_bytes()) - } - - fn sbp_size(&self) -> usize { - 1 - } -} - -impl SbpSerialize for u16 { - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - buf.extend(&self.to_le_bytes()) - } - - fn sbp_size(&self) -> usize { - 2 - } -} - -impl SbpSerialize for u32 { - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - buf.extend(&self.to_le_bytes()) - } - - fn sbp_size(&self) -> usize { - 4 - } -} - -impl SbpSerialize for u64 { - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - buf.extend(&self.to_le_bytes()) - } - - fn sbp_size(&self) -> usize { - 8 - } -} - -impl SbpSerialize for i8 { - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - buf.extend(&self.to_le_bytes()) - } - - fn sbp_size(&self) -> usize { - 1 - } -} - -impl SbpSerialize for i16 { - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - buf.extend(&self.to_le_bytes()) - } - - fn sbp_size(&self) -> usize { - 2 - } -} - -impl SbpSerialize for i32 { - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - buf.extend(&self.to_le_bytes()) - } - - fn sbp_size(&self) -> usize { - 4 - } -} - -impl SbpSerialize for i64 { - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - buf.extend(&self.to_le_bytes()); - } - - fn sbp_size(&self) -> usize { - 8 - } -} - -impl SbpSerialize for f32 { - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - buf.extend(&self.to_le_bytes()); - } - - fn sbp_size(&self) -> usize { - 4 - } -} - -impl SbpSerialize for f64 { - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - buf.extend(&self.to_le_bytes()); - } - - fn sbp_size(&self) -> usize { - 8 - } -} - -impl SbpSerialize for SbpString { - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - buf.extend(self.as_bytes()); - } - - fn sbp_size(&self) -> usize { - self.0.len() - } -} - -impl SbpSerialize for Vec { - fn append_to_sbp_buffer(&self, buf: &mut Vec) { - for item in self.into_iter() { - item.append_to_sbp_buffer(buf); - } - } - - fn sbp_size(&self) -> usize { - let mut total = 0; - for item in self.iter() { - total += item.sbp_size(); - } - total - } -} diff --git a/rust/sbp/src/swiftnav_conversions.rs b/rust/sbp/src/swiftnav_conversions.rs new file mode 100644 index 0000000000..7c0ed7dd29 --- /dev/null +++ b/rust/sbp/src/swiftnav_conversions.rs @@ -0,0 +1,219 @@ +//! Conversions from messages to types in `swiftnav`. + +use std::{ + convert::{TryFrom, TryInto}, + fmt, num, +}; + +use crate::messages; + +#[derive(Debug, Clone)] +pub enum GpsTimeError { + InvalidGpsTime(swiftnav::time::InvalidGpsTime), + TryFromIntError(num::TryFromIntError), +} + +impl fmt::Display for GpsTimeError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + GpsTimeError::InvalidGpsTime(e) => e.fmt(f), + GpsTimeError::TryFromIntError(e) => e.fmt(f), + } + } +} + +impl std::error::Error for GpsTimeError {} + +impl From for GpsTimeError { + fn from(e: swiftnav::time::InvalidGpsTime) -> Self { + GpsTimeError::InvalidGpsTime(e) + } +} + +impl From for GpsTimeError { + fn from(e: num::TryFromIntError) -> Self { + GpsTimeError::TryFromIntError(e) + } +} + +impl From for GpsTimeError { + fn from(_: std::convert::Infallible) -> Self { + unreachable!() + } +} + +impl TryFrom for swiftnav::time::GpsTime { + type Error = swiftnav::time::InvalidGpsTime; + + fn try_from( + msg: messages::gnss::GpsTime, + ) -> Result { + let tow = (msg.tow as f64) * 1e-3 + (msg.ns_residual as f64) * 1e-9; + swiftnav::time::GpsTime::new(msg.wn as i16, tow) + } +} + +impl TryFrom for swiftnav::time::GpsTime { + type Error = swiftnav::time::InvalidGpsTime; + + fn try_from( + msg: messages::gnss::GpsTimeSec, + ) -> Result { + swiftnav::time::GpsTime::new(msg.wn as i16, msg.tow as f64) + } +} + +impl TryFrom for swiftnav::signal::GnssSignal { + type Error = swiftnav::signal::InvalidGnssSignal; + + fn try_from( + value: messages::gnss::GnssSignal, + ) -> Result { + swiftnav::signal::GnssSignal::new(value.sat as u16, value.code.try_into()?) + } +} + +impl TryFrom for swiftnav::ephemeris::Ephemeris { + type Error = EphemerisDecodeError; + + fn try_from( + eph: messages::observation::MsgEphemerisGps, + ) -> Result { + Ok(swiftnav::ephemeris::Ephemeris::new( + eph.common.sid.try_into()?, + eph.common.toe.try_into()?, + eph.common.ura, + eph.common.fit_interval, + eph.common.valid, + eph.common.health_bits, + 0, + swiftnav::ephemeris::EphemerisTerms::new_kepler( + swiftnav::signal::Constellation::Gps, + [eph.tgd, 0.], + eph.c_rc as f64, + eph.c_rs as f64, + eph.c_uc as f64, + eph.c_us as f64, + eph.c_ic as f64, + eph.c_is as f64, + eph.dn, + eph.m0, + eph.ecc, + eph.sqrta, + eph.omega0, + eph.omegadot, + eph.w, + eph.inc, + eph.inc_dot, + eph.af0 as f64, + eph.af1 as f64, + eph.af2 as f64, + eph.toc.try_into()?, + eph.iodc, + eph.iode as u16, + ), + )) + } +} + +impl TryFrom for swiftnav::ephemeris::Ephemeris { + type Error = EphemerisDecodeError; + + fn try_from( + eph: messages::observation::MsgEphemerisGal, + ) -> Result { + Ok(swiftnav::ephemeris::Ephemeris::new( + eph.common.sid.try_into()?, + eph.common.toe.try_into()?, + eph.common.ura, + eph.common.fit_interval, + eph.common.valid, + eph.common.health_bits, + eph.source, + swiftnav::ephemeris::EphemerisTerms::new_kepler( + swiftnav::signal::Constellation::Gal, + [eph.bgd_e1e5a, eph.bgd_e1e5b], + eph.c_rc as f64, + eph.c_rs as f64, + eph.c_uc as f64, + eph.c_us as f64, + eph.c_ic as f64, + eph.c_is as f64, + eph.dn, + eph.m0, + eph.ecc, + eph.sqrta, + eph.omega0, + eph.omegadot, + eph.w, + eph.inc, + eph.inc_dot, + eph.af0 as f64, + eph.af1 as f64, + eph.af2 as f64, + eph.toc.try_into()?, + eph.iodc, + eph.iode as u16, + ), + )) + } +} + +#[derive(Debug, Copy, Clone, PartialOrd, PartialEq)] +pub enum EphemerisDecodeError { + InvalidTime(swiftnav::time::InvalidGpsTime), + InvalidSignal(swiftnav::signal::InvalidGnssSignal), +} + +impl fmt::Display for EphemerisDecodeError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + EphemerisDecodeError::InvalidTime(e) => e.fmt(f), + EphemerisDecodeError::InvalidSignal(e) => e.fmt(f), + } + } +} + +impl std::error::Error for EphemerisDecodeError {} + +impl From for EphemerisDecodeError { + fn from(e: swiftnav::time::InvalidGpsTime) -> Self { + EphemerisDecodeError::InvalidTime(e) + } +} + +impl From for EphemerisDecodeError { + fn from(e: swiftnav::signal::InvalidGnssSignal) -> Self { + EphemerisDecodeError::InvalidSignal(e) + } +} + +impl TryFrom for swiftnav::navmeas::NavigationMeasurement { + type Error = swiftnav::signal::InvalidGnssSignal; + + fn try_from( + observation: messages::observation::PackedObsContent, + ) -> Result { + let mut measurement = swiftnav::navmeas::NavigationMeasurement::new(); + + measurement.set_lock_time(swiftnav::navmeas::decode_lock_time(observation.lock)); + measurement.set_sid(observation.sid.try_into()?); + // A CN0 of 0 is considered invalid + if observation.cn0 != 0 { + measurement.set_cn0(observation.cn0 as f64 / 4.); + } + if observation.flags & 0x01 != 0 { + measurement.set_pseudorange(observation.p as f64 / 5e1); + } + if observation.flags & 0x08 != 0 { + measurement + .set_measured_doppler(observation.d.i as f64 + (observation.d.f as f64) / 256.); + } + if observation.flags & 0x80 != 0 { + measurement + .set_flags(measurement.flags() | swiftnav::navmeas::NAV_MEAS_FLAG_RAIM_EXCLUSION); + } + + Ok(measurement) + } +} diff --git a/rust/sbp/src/time.rs b/rust/sbp/src/time.rs index 260706a28f..c87f8b5a08 100644 --- a/rust/sbp/src/time.rs +++ b/rust/sbp/src/time.rs @@ -1,14 +1,22 @@ +//! Types representing GPS times embedded in messsages. + pub use swiftnav::time::GpsTime; pub use crate::swiftnav_conversions::GpsTimeError; +/// The time returned by [SbpMessage::gps_time](crate::SbpMessage::gps_time). #[derive(Debug, Clone, Copy)] pub enum MessageTime { + /// Time received via a message from a rover. Rover(RoverTime), + + /// Time received via a message from a base station. Base(BaseTime), } impl MessageTime { + /* */ + /// If the `MessageTime` is from a rover return it. Otherwise return None. pub fn to_rover(self) -> Option { if let Self::Rover(v) = self { Some(v) @@ -17,6 +25,7 @@ impl MessageTime { } } + /// If the `MessageTime` is from a base station return it. Otherwise return None. pub fn to_base(self) -> Option { if let Self::Base(v) = self { Some(v) @@ -38,13 +47,18 @@ impl From for MessageTime { } } +/// Time received via a message from a rover, like +/// [MsgAngularRate](crate::messages::orientation::MsgAngularRate) #[derive(Debug, Clone, Copy)] pub enum RoverTime { + /// The [GpsTime] of the message. GpsTime(GpsTime), + /// The message had no week number. Tow(f64), } impl RoverTime { + /// Get the time of week. pub fn tow(&self) -> f64 { match self { RoverTime::GpsTime(time) => time.tow(), @@ -52,6 +66,7 @@ impl RoverTime { } } + /// Get the week number if the message included it. Otherwise return None. pub fn wn(&self) -> Option { match self { RoverTime::GpsTime(time) => Some(time.wn()), @@ -72,6 +87,8 @@ impl From for RoverTime { } } +/// Time received via a message from a base station, like +/// [MsgObs](crate::messages::observation::MsgObs). #[derive(Debug, Clone, Copy, PartialEq, PartialOrd)] pub struct BaseTime(GpsTime); diff --git a/rust/sbp/src/wire_format.rs b/rust/sbp/src/wire_format.rs new file mode 100644 index 0000000000..a12f770f6a --- /dev/null +++ b/rust/sbp/src/wire_format.rs @@ -0,0 +1,210 @@ +//! Functionality for parsing/writing SBP message payloads with in memory buffers + +use std::{ + self, + mem::{self, MaybeUninit}, + ptr, +}; + +use bytes::{Buf, BufMut, BytesMut}; + +pub trait WireFormat: Sized { + /// Minimum number of bytes this type will take in the frame. + const MIN_ENCODED_LEN: usize = mem::size_of::(); + + /// The actual number of bytes the type will take in the frame. + fn encoded_len(&self) -> usize { + Self::MIN_ENCODED_LEN + } + + /// Write the type to a buffer. + fn write(&self, buf: &mut BytesMut); + + /// Read the type out of a buffer, without checking any invariants. + fn parse_unchecked(buf: &mut BytesMut) -> Self; + + /// Read the type out of a buffer. + fn parse(buf: &mut BytesMut) -> Result { + if buf.remaining() >= Self::MIN_ENCODED_LEN { + Ok(Self::parse_unchecked(buf)) + } else { + Err(PayloadParseError {}) + } + } +} + +impl WireFormat for Vec +where + T: WireFormat, +{ + // A variable length array with no elements takes 0 bytes + const MIN_ENCODED_LEN: usize = 0; + + fn encoded_len(&self) -> usize { + self.iter().map(WireFormat::encoded_len).sum() + } + + fn write(&self, buf: &mut BytesMut) { + for item in self.iter() { + item.write(buf); + } + } + + fn parse_unchecked(buf: &mut BytesMut) -> Self { + let mut v = Vec::new(); + while buf.remaining() >= T::MIN_ENCODED_LEN { + v.push(T::parse_unchecked(buf)); + } + v + } +} + +impl WireFormat for [T; LEN] +where + T: WireFormat, +{ + const MIN_ENCODED_LEN: usize = T::MIN_ENCODED_LEN * LEN; + + fn write(&self, buf: &mut BytesMut) { + for item in self { + item.write(buf); + } + } + + fn parse_unchecked(buf: &mut BytesMut) -> Self { + // Safety: MaybeUninit`s do not require initialization so we can call assume_init() + // https://doc.rust-lang.org/stable/std/mem/union.MaybeUninit.html#initializing-an-array-element-by-element + let mut a: [MaybeUninit; LEN] = unsafe { MaybeUninit::uninit().assume_init() }; + for el in &mut a[..] { + unsafe { + ptr::write(el.as_mut_ptr(), T::parse_unchecked(buf)); + } + } + // Safety: Everything is initialized + unsafe { ptr::read(&a as *const _ as *const Self) } + } +} + +impl WireFormat for u8 { + fn write(&self, buf: &mut BytesMut) { + buf.put_u8(*self) + } + fn parse_unchecked(buf: &mut BytesMut) -> Self { + buf.get_u8() + } +} + +impl WireFormat for u16 { + fn write(&self, buf: &mut BytesMut) { + buf.put_u16_le(*self) + } + fn parse_unchecked(buf: &mut BytesMut) -> Self { + buf.get_u16_le() + } +} + +impl WireFormat for u32 { + fn write(&self, buf: &mut BytesMut) { + buf.put_u32_le(*self) + } + fn parse_unchecked(buf: &mut BytesMut) -> Self { + buf.get_u32_le() + } +} + +impl WireFormat for u64 { + fn write(&self, buf: &mut BytesMut) { + buf.put_u64_le(*self) + } + fn parse_unchecked(buf: &mut BytesMut) -> Self { + buf.get_u64_le() + } +} + +impl WireFormat for i8 { + fn write(&self, buf: &mut BytesMut) { + buf.put_i8(*self) + } + fn parse_unchecked(buf: &mut BytesMut) -> Self { + buf.get_i8() + } +} + +impl WireFormat for i16 { + fn write(&self, buf: &mut BytesMut) { + buf.put_i16_le(*self) + } + fn parse_unchecked(buf: &mut BytesMut) -> Self { + buf.get_i16_le() + } +} + +impl WireFormat for i32 { + fn write(&self, buf: &mut BytesMut) { + buf.put_i32_le(*self) + } + fn parse_unchecked(buf: &mut BytesMut) -> Self { + buf.get_i32_le() + } +} + +impl WireFormat for i64 { + fn write(&self, buf: &mut BytesMut) { + buf.put_i64_le(*self) + } + fn parse_unchecked(buf: &mut BytesMut) -> Self { + buf.get_i64_le() + } +} + +impl WireFormat for f32 { + fn write(&self, buf: &mut BytesMut) { + buf.put_f32_le(*self) + } + fn parse_unchecked(buf: &mut BytesMut) -> Self { + buf.get_f32_le() + } +} + +impl WireFormat for f64 { + fn write(&self, buf: &mut BytesMut) { + buf.put_f64_le(*self) + } + fn parse_unchecked(buf: &mut BytesMut) -> Self { + buf.get_f64_le() + } +} + +#[derive(Debug, Clone)] +pub struct PayloadParseError {} + +impl std::fmt::Display for PayloadParseError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "error parsing payload") + } +} + +impl std::error::Error for PayloadParseError {} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_parse_u16_vec() { + let mut buf = BytesMut::from(&[0b00000001, 0b00010000, 0b00000010, 0b00000001][..]); + let expected = vec![4097, 258]; + let actual: Vec = WireFormat::parse_unchecked(&mut buf); + assert_eq!(expected, actual); + assert!(buf.is_empty()); + } + + #[test] + fn test_parse_u16_array() { + let mut buf = BytesMut::from(&[0b00000001, 0b00010000, 0b00000010, 0b00000001][..]); + let expected = [4097, 258]; + let actual: [u16; 2] = WireFormat::parse_unchecked(&mut buf); + assert_eq!(expected, actual); + assert!(buf.is_empty()); + } +} diff --git a/rust/sbp/tests/auto_check_sbp_acquisition_MsgAcqResultDepA.rs b/rust/sbp/tests/integration/auto_check_sbp_acquisition_msg_acq_result_dep_a.rs similarity index 86% rename from rust/sbp/tests/auto_check_sbp_acquisition_MsgAcqResultDepA.rs rename to rust/sbp/tests/integration/auto_check_sbp_acquisition_msg_acq_result_dep_a.rs index b3cd18d948..b2b090c39d 100644 --- a/rust/sbp/tests/auto_check_sbp_acquisition_MsgAcqResultDepA.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_acquisition_msg_acq_result_dep_a.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/acquisition/test_MsgAcqResultDepA.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_acquisition_MsgAcqResultDepA() { +fn test_auto_check_sbp_acquisition_msg_acq_result_dep_a() { { let mut payload = Cursor::new(vec![ 85, 21, 0, 195, 4, 13, 0, 0, 104, 65, 0, 192, 53, 68, 198, 199, 0, 70, 8, 2, 68, @@ -35,14 +28,14 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgAcqResultDepA(msg) => { + sbp::messages::Sbp::MsgAcqResultDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x15, "Incorrect message type, expected 0x15, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -71,7 +64,7 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepA() { } _ => panic!("Invalid message type! Expected a MsgAcqResultDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -87,14 +80,14 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgAcqResultDepA(msg) => { + sbp::messages::Sbp::MsgAcqResultDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x15, "Incorrect message type, expected 0x15, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -123,7 +116,7 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepA() { } _ => panic!("Invalid message type! Expected a MsgAcqResultDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -139,14 +132,14 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgAcqResultDepA(msg) => { + sbp::messages::Sbp::MsgAcqResultDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x15, "Incorrect message type, expected 0x15, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -175,7 +168,7 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepA() { } _ => panic!("Invalid message type! Expected a MsgAcqResultDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -192,14 +185,14 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgAcqResultDepA(msg) => { + sbp::messages::Sbp::MsgAcqResultDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x15, "Incorrect message type, expected 0x15, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -228,7 +221,7 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepA() { } _ => panic!("Invalid message type! Expected a MsgAcqResultDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -244,14 +237,14 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgAcqResultDepA(msg) => { + sbp::messages::Sbp::MsgAcqResultDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x15, "Incorrect message type, expected 0x15, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -280,7 +273,7 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepA() { } _ => panic!("Invalid message type! Expected a MsgAcqResultDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -296,14 +289,14 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgAcqResultDepA(msg) => { + sbp::messages::Sbp::MsgAcqResultDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x15, "Incorrect message type, expected 0x15, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -332,7 +325,7 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepA() { } _ => panic!("Invalid message type! Expected a MsgAcqResultDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_acquisition_MsgAcqResultDepB.rs b/rust/sbp/tests/integration/auto_check_sbp_acquisition_msg_acq_result_dep_b.rs similarity index 88% rename from rust/sbp/tests/auto_check_sbp_acquisition_MsgAcqResultDepB.rs rename to rust/sbp/tests/integration/auto_check_sbp_acquisition_msg_acq_result_dep_b.rs index cc973c7aae..55edae71ba 100644 --- a/rust/sbp/tests/auto_check_sbp_acquisition_MsgAcqResultDepB.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_acquisition_msg_acq_result_dep_b.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/acquisition/test_MsgAcqResultDepB.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_acquisition_MsgAcqResultDepB() { +fn test_auto_check_sbp_acquisition_msg_acq_result_dep_b() { { let mut payload = Cursor::new(vec![ 85, 20, 0, 246, 215, 16, 137, 167, 18, 66, 0, 0, 161, 67, 240, 24, 156, 69, 9, 0, 0, 0, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepB() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgAcqResultDepB(msg) => { + sbp::messages::Sbp::MsgAcqResultDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x14, "Incorrect message type, expected 0x14, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -82,7 +75,7 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepB() { } _ => panic!("Invalid message type! Expected a MsgAcqResultDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -99,14 +92,14 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepB() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgAcqResultDepB(msg) => { + sbp::messages::Sbp::MsgAcqResultDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x14, "Incorrect message type, expected 0x14, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -145,7 +138,7 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepB() { } _ => panic!("Invalid message type! Expected a MsgAcqResultDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -162,14 +155,14 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepB() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgAcqResultDepB(msg) => { + sbp::messages::Sbp::MsgAcqResultDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x14, "Incorrect message type, expected 0x14, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -208,7 +201,7 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepB() { } _ => panic!("Invalid message type! Expected a MsgAcqResultDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -225,14 +218,14 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepB() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgAcqResultDepB(msg) => { + sbp::messages::Sbp::MsgAcqResultDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x14, "Incorrect message type, expected 0x14, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -271,7 +264,7 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepB() { } _ => panic!("Invalid message type! Expected a MsgAcqResultDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -288,14 +281,14 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepB() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgAcqResultDepB(msg) => { + sbp::messages::Sbp::MsgAcqResultDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x14, "Incorrect message type, expected 0x14, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -334,7 +327,7 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepB() { } _ => panic!("Invalid message type! Expected a MsgAcqResultDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_acquisition_MsgAcqResultDepC.rs b/rust/sbp/tests/integration/auto_check_sbp_acquisition_msg_acq_result_dep_c.rs similarity index 88% rename from rust/sbp/tests/auto_check_sbp_acquisition_MsgAcqResultDepC.rs rename to rust/sbp/tests/integration/auto_check_sbp_acquisition_msg_acq_result_dep_c.rs index f13934ab65..4315425c84 100644 --- a/rust/sbp/tests/auto_check_sbp_acquisition_MsgAcqResultDepC.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_acquisition_msg_acq_result_dep_c.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/acquisition/test_MsgAcqResultDepC.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_acquisition_MsgAcqResultDepC() { +fn test_auto_check_sbp_acquisition_msg_acq_result_dep_c() { { let mut payload = Cursor::new(vec![ 85, 31, 0, 40, 12, 16, 72, 9, 34, 66, 155, 152, 228, 67, 28, 34, 221, 68, 10, 0, 0, 0, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepC() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgAcqResultDepC(msg) => { + sbp::messages::Sbp::MsgAcqResultDepC(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x1f, "Incorrect message type, expected 0x1f, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xc28, "incorrect sender id, expected 0xc28, is {}", @@ -82,7 +75,7 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepC() { } _ => panic!("Invalid message type! Expected a MsgAcqResultDepC"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -99,14 +92,14 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepC() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgAcqResultDepC(msg) => { + sbp::messages::Sbp::MsgAcqResultDepC(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x1f, "Incorrect message type, expected 0x1f, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xc28, "incorrect sender id, expected 0xc28, is {}", @@ -145,7 +138,7 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepC() { } _ => panic!("Invalid message type! Expected a MsgAcqResultDepC"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -162,14 +155,14 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepC() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgAcqResultDepC(msg) => { + sbp::messages::Sbp::MsgAcqResultDepC(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x1f, "Incorrect message type, expected 0x1f, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xc28, "incorrect sender id, expected 0xc28, is {}", @@ -208,7 +201,7 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepC() { } _ => panic!("Invalid message type! Expected a MsgAcqResultDepC"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -225,14 +218,14 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepC() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgAcqResultDepC(msg) => { + sbp::messages::Sbp::MsgAcqResultDepC(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x1f, "Incorrect message type, expected 0x1f, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xc28, "incorrect sender id, expected 0xc28, is {}", @@ -271,7 +264,7 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepC() { } _ => panic!("Invalid message type! Expected a MsgAcqResultDepC"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -288,14 +281,14 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepC() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgAcqResultDepC(msg) => { + sbp::messages::Sbp::MsgAcqResultDepC(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x1f, "Incorrect message type, expected 0x1f, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xc28, "incorrect sender id, expected 0xc28, is {}", @@ -334,7 +327,7 @@ fn test_auto_check_sbp_acquisition_MsgAcqResultDepC() { } _ => panic!("Invalid message type! Expected a MsgAcqResultDepC"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_bootload_MsgBootloaderHandshakeResp.rs b/rust/sbp/tests/integration/auto_check_sbp_bootload_msg_bootloader_handshake_resp.rs similarity index 82% rename from rust/sbp/tests/auto_check_sbp_bootload_MsgBootloaderHandshakeResp.rs rename to rust/sbp/tests/integration/auto_check_sbp_bootload_msg_bootloader_handshake_resp.rs index c62c21bd75..1c656a568b 100644 --- a/rust/sbp/tests/auto_check_sbp_bootload_MsgBootloaderHandshakeResp.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_bootload_msg_bootloader_handshake_resp.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/bootload/test_MsgBootloaderHandshakeResp.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_bootload_MsgBootloaderHandshakeResp() { +fn test_auto_check_sbp_bootload_msg_bootloader_handshake_resp() { { let mut payload = Cursor::new(vec![ 85, 180, 0, 0, 0, 9, 0, 0, 0, 0, 118, 49, 46, 50, 10, 201, 1, @@ -35,14 +28,14 @@ fn test_auto_check_sbp_bootload_MsgBootloaderHandshakeResp() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBootloaderHandshakeResp(msg) => { + sbp::messages::Sbp::MsgBootloaderHandshakeResp(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0xb4, "Incorrect message type, expected 0xb4, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x0, "incorrect sender id, expected 0x0, is {}", @@ -54,7 +47,7 @@ fn test_auto_check_sbp_bootload_MsgBootloaderHandshakeResp() { msg.flags ); assert_eq!( - Into::::into(msg.version.clone()), + msg.version.to_string(), "v1.2 " .to_string(), @@ -67,7 +60,7 @@ fn test_auto_check_sbp_bootload_MsgBootloaderHandshakeResp() { } _ => panic!("Invalid message type! Expected a MsgBootloaderHandshakeResp"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -81,14 +74,14 @@ fn test_auto_check_sbp_bootload_MsgBootloaderHandshakeResp() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBootloaderHandshakeDepA(msg) => { + sbp::messages::Sbp::MsgBootloaderHandshakeDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0xb0, "Incorrect message type, expected 0xb0, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -117,7 +110,7 @@ fn test_auto_check_sbp_bootload_MsgBootloaderHandshakeResp() { } _ => panic!("Invalid message type! Expected a MsgBootloaderHandshakeDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_ext_events_MsgExtEvent.rs b/rust/sbp/tests/integration/auto_check_sbp_ext_events_msg_ext_event.rs similarity index 84% rename from rust/sbp/tests/auto_check_sbp_ext_events_MsgExtEvent.rs rename to rust/sbp/tests/integration/auto_check_sbp_ext_events_msg_ext_event.rs index cee4428089..b29b315b38 100644 --- a/rust/sbp/tests/auto_check_sbp_ext_events_MsgExtEvent.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_ext_events_msg_ext_event.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/ext_events/test_MsgExtEvent.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_ext_events_MsgExtEvent() { +fn test_auto_check_sbp_ext_events_msg_ext_event() { { let mut payload = Cursor::new(vec![ 85, 1, 1, 245, 6, 12, 48, 7, 199, 216, 49, 15, 202, 65, 15, 0, 3, 0, 62, 204, @@ -35,14 +28,14 @@ fn test_auto_check_sbp_ext_events_MsgExtEvent() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgExtEvent(msg) => { + sbp::messages::Sbp::MsgExtEvent(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x101, "Incorrect message type, expected 0x101, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x6f5, "incorrect sender id, expected 0x6f5, is {}", @@ -76,7 +69,7 @@ fn test_auto_check_sbp_ext_events_MsgExtEvent() { } _ => panic!("Invalid message type! Expected a MsgExtEvent"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_file_io_MsgFileioWriteResp.rs b/rust/sbp/tests/integration/auto_check_sbp_file_io_msg_fileio_write_resp.rs similarity index 78% rename from rust/sbp/tests/auto_check_sbp_file_io_MsgFileioWriteResp.rs rename to rust/sbp/tests/integration/auto_check_sbp_file_io_msg_fileio_write_resp.rs index 02431e4a69..b5e72602e7 100644 --- a/rust/sbp/tests/auto_check_sbp_file_io_MsgFileioWriteResp.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_file_io_msg_fileio_write_resp.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/file_io/test_MsgFileioWriteResp.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_file_io_MsgFileioWriteResp() { +fn test_auto_check_sbp_file_io_msg_fileio_write_resp() { { let mut payload = Cursor::new(vec![85, 171, 0, 66, 0, 4, 202, 0, 0, 0, 243, 243]); @@ -33,14 +26,14 @@ fn test_auto_check_sbp_file_io_MsgFileioWriteResp() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgFileioWriteResp(msg) => { + sbp::messages::Sbp::MsgFileioWriteResp(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0xab, "Incorrect message type, expected 0xab, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x42, "incorrect sender id, expected 0x42, is {}", @@ -54,7 +47,7 @@ fn test_auto_check_sbp_file_io_MsgFileioWriteResp() { } _ => panic!("Invalid message type! Expected a MsgFileioWriteResp"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_imu_MsgImuAux.rs b/rust/sbp/tests/integration/auto_check_sbp_imu_msg_imu_aux.rs similarity index 82% rename from rust/sbp/tests/auto_check_sbp_imu_MsgImuAux.rs rename to rust/sbp/tests/integration/auto_check_sbp_imu_msg_imu_aux.rs index 7f5be48e49..b38e35d345 100644 --- a/rust/sbp/tests/auto_check_sbp_imu_MsgImuAux.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_imu_msg_imu_aux.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/imu/test_MsgImuAux.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_imu_MsgImuAux() { +fn test_auto_check_sbp_imu_msg_imu_aux() { { let mut payload = Cursor::new(vec![85, 1, 9, 52, 18, 4, 1, 244, 10, 66, 200, 252]); @@ -33,14 +26,14 @@ fn test_auto_check_sbp_imu_MsgImuAux() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgImuAux(msg) => { + sbp::messages::Sbp::MsgImuAux(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x901, "Incorrect message type, expected 0x901, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x1234, "incorrect sender id, expected 0x1234, is {}", @@ -64,7 +57,7 @@ fn test_auto_check_sbp_imu_MsgImuAux() { } _ => panic!("Invalid message type! Expected a MsgImuAux"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_imu_MsgImuRaw.rs b/rust/sbp/tests/integration/auto_check_sbp_imu_msg_imu_raw.rs similarity index 87% rename from rust/sbp/tests/auto_check_sbp_imu_MsgImuRaw.rs rename to rust/sbp/tests/integration/auto_check_sbp_imu_msg_imu_raw.rs index e89ca9e39e..a91acd20ac 100644 --- a/rust/sbp/tests/auto_check_sbp_imu_MsgImuRaw.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_imu_msg_imu_raw.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/imu/test_MsgImuRaw.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_imu_MsgImuRaw() { +fn test_auto_check_sbp_imu_msg_imu_raw() { { let mut payload = Cursor::new(vec![ 85, 0, 9, 52, 18, 17, 26, 1, 0, 192, 206, 96, 0, 223, 255, 44, 16, 60, 0, 208, 254, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_imu_MsgImuRaw() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgImuRaw(msg) => { + sbp::messages::Sbp::MsgImuRaw(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x900, "Incorrect message type, expected 0x900, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x1234, "incorrect sender id, expected 0x1234, is {}", @@ -92,7 +85,7 @@ fn test_auto_check_sbp_imu_MsgImuRaw() { } _ => panic!("Invalid message type! Expected a MsgImuRaw"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_logging_MsgFwd.rs b/rust/sbp/tests/integration/auto_check_sbp_logging_msg_fwd.rs similarity index 92% rename from rust/sbp/tests/auto_check_sbp_logging_MsgFwd.rs rename to rust/sbp/tests/integration/auto_check_sbp_logging_msg_fwd.rs index ad86d4b377..97f576cd9b 100644 --- a/rust/sbp/tests/auto_check_sbp_logging_MsgFwd.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_logging_msg_fwd.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/logging/test_MsgFwd.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_logging_MsgFwd() { +fn test_auto_check_sbp_logging_msg_fwd() { { let mut payload = Cursor::new(vec![ 85, 2, 4, 66, 0, 18, 0, 0, 86, 81, 68, 47, 81, 103, 65, 69, 65, 65, 65, 65, 65, 69, 97, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_logging_MsgFwd() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgFwd(msg) => { + sbp::messages::Sbp::MsgFwd(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x402, "Incorrect message type, expected 0x402, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x42, "incorrect sender id, expected 0x42, is {}", @@ -142,7 +135,7 @@ fn test_auto_check_sbp_logging_MsgFwd() { } _ => panic!("Invalid message type! Expected a MsgFwd"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_logging_MsgLog.rs b/rust/sbp/tests/integration/auto_check_sbp_logging_msg_log.rs similarity index 81% rename from rust/sbp/tests/auto_check_sbp_logging_MsgLog.rs rename to rust/sbp/tests/integration/auto_check_sbp_logging_msg_log.rs index 481aacf761..33f6bc09a4 100644 --- a/rust/sbp/tests/auto_check_sbp_logging_MsgLog.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_logging_msg_log.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/logging/test_MsgLog.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_logging_MsgLog() { +fn test_auto_check_sbp_logging_msg_log() { { let mut payload = Cursor::new(vec![ 85, 1, 4, 10, 9, 44, 6, 70, 105, 108, 116, 101, 114, 101, 100, 32, 97, 108, 108, 32, @@ -37,14 +30,14 @@ fn test_auto_check_sbp_logging_MsgLog() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgLog(msg) => { + sbp::messages::Sbp::MsgLog(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x0401, "Incorrect message type, expected 0x0401, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x90a, "incorrect sender id, expected 0x90a, is {}", @@ -56,7 +49,7 @@ fn test_auto_check_sbp_logging_MsgLog() { msg.level ); assert_eq!( - Into::::into(msg.text.clone()), + msg.text.to_string(), "Filtered all obs from 2314 at tow 83.539019".to_string(), "incorrect value for msg.text, expected string '{}', is '{}'", "Filtered all obs from 2314 at tow 83.539019".to_string(), @@ -65,7 +58,7 @@ fn test_auto_check_sbp_logging_MsgLog() { } _ => panic!("Invalid message type! Expected a MsgLog"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_logging_MsgPrintDep.rs b/rust/sbp/tests/integration/auto_check_sbp_logging_msg_print_dep.rs similarity index 81% rename from rust/sbp/tests/auto_check_sbp_logging_MsgPrintDep.rs rename to rust/sbp/tests/integration/auto_check_sbp_logging_msg_print_dep.rs index 290d18d4d5..e8719f2320 100644 --- a/rust/sbp/tests/auto_check_sbp_logging_MsgPrintDep.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_logging_msg_print_dep.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/logging/test_MsgPrintDep.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_logging_MsgPrintDep() { +fn test_auto_check_sbp_logging_msg_print_dep() { { let mut payload = Cursor::new(vec![ 85, 16, 0, 34, 34, 43, 73, 78, 70, 79, 58, 32, 97, 99, 113, 58, 32, 80, 82, 78, 32, 49, @@ -37,21 +30,21 @@ fn test_auto_check_sbp_logging_MsgPrintDep() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPrintDep(msg) => { + sbp::messages::Sbp::MsgPrintDep(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x10, "Incorrect message type, expected 0x10, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x2222, "incorrect sender id, expected 0x2222, is {}", sender_id ); assert_eq!( - Into::::into(msg.text.clone()), + msg.text.to_string(), "INFO: acq: PRN 15 found @ -2497 Hz, 20 SNR " .to_string(), @@ -64,7 +57,7 @@ fn test_auto_check_sbp_logging_MsgPrintDep() { } _ => panic!("Invalid message type! Expected a MsgPrintDep"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -82,21 +75,21 @@ fn test_auto_check_sbp_logging_MsgPrintDep() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPrintDep(msg) => { + sbp::messages::Sbp::MsgPrintDep(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x10, "Incorrect message type, expected 0x10, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x2222, "incorrect sender id, expected 0x2222, is {}", sender_id ); assert_eq!( - Into::::into(msg.text.clone()), + msg.text.to_string(), "INFO: acq: PRN 31 found @ 4245 Hz, 21 SNR " .to_string(), @@ -109,7 +102,7 @@ fn test_auto_check_sbp_logging_MsgPrintDep() { } _ => panic!("Invalid message type! Expected a MsgPrintDep"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -127,21 +120,21 @@ fn test_auto_check_sbp_logging_MsgPrintDep() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPrintDep(msg) => { + sbp::messages::Sbp::MsgPrintDep(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x10, "Incorrect message type, expected 0x10, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x2222, "incorrect sender id, expected 0x2222, is {}", sender_id ); assert_eq!( - Into::::into(msg.text.clone()), + msg.text.to_string(), "INFO: Disabling channel 0 (PRN 11) " .to_string(), @@ -154,7 +147,7 @@ fn test_auto_check_sbp_logging_MsgPrintDep() { } _ => panic!("Invalid message type! Expected a MsgPrintDep"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -172,21 +165,21 @@ fn test_auto_check_sbp_logging_MsgPrintDep() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPrintDep(msg) => { + sbp::messages::Sbp::MsgPrintDep(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x10, "Incorrect message type, expected 0x10, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x2222, "incorrect sender id, expected 0x2222, is {}", sender_id ); assert_eq!( - Into::::into(msg.text.clone()), + msg.text.to_string(), "INFO: acq: PRN 2 found @ 3996 Hz, 20 SNR " .to_string(), @@ -199,7 +192,7 @@ fn test_auto_check_sbp_logging_MsgPrintDep() { } _ => panic!("Invalid message type! Expected a MsgPrintDep"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -217,21 +210,21 @@ fn test_auto_check_sbp_logging_MsgPrintDep() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPrintDep(msg) => { + sbp::messages::Sbp::MsgPrintDep(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x10, "Incorrect message type, expected 0x10, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x2222, "incorrect sender id, expected 0x2222, is {}", sender_id ); assert_eq!( - Into::::into(msg.text.clone()), + msg.text.to_string(), "INFO: acq: PRN 4 found @ -7492 Hz, 20 SNR " .to_string(), @@ -244,7 +237,7 @@ fn test_auto_check_sbp_logging_MsgPrintDep() { } _ => panic!("Invalid message type! Expected a MsgPrintDep"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -262,21 +255,21 @@ fn test_auto_check_sbp_logging_MsgPrintDep() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPrintDep(msg) => { + sbp::messages::Sbp::MsgPrintDep(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x10, "Incorrect message type, expected 0x10, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x2222, "incorrect sender id, expected 0x2222, is {}", sender_id ); assert_eq!( - Into::::into(msg.text.clone()), + msg.text.to_string(), "INFO: Disabling channel 1 (PRN 15) " .to_string(), @@ -289,7 +282,7 @@ fn test_auto_check_sbp_logging_MsgPrintDep() { } _ => panic!("Invalid message type! Expected a MsgPrintDep"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgAgeCorrections.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_age_corrections.rs similarity index 80% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgAgeCorrections.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_age_corrections.rs index 5e90345075..2a7070f734 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgAgeCorrections.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_age_corrections.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgAgeCorrections.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgAgeCorrections() { +fn test_auto_check_sbp_navigation_msg_age_corrections() { { let mut payload = Cursor::new(vec![85, 16, 2, 66, 0, 6, 100, 0, 0, 0, 30, 0, 233, 202]); @@ -33,14 +26,14 @@ fn test_auto_check_sbp_navigation_MsgAgeCorrections() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgAgeCorrections(msg) => { + sbp::messages::Sbp::MsgAgeCorrections(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x210, "Incorrect message type, expected 0x210, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x42, "incorrect sender id, expected 0x42, is {}", @@ -59,7 +52,7 @@ fn test_auto_check_sbp_navigation_MsgAgeCorrections() { } _ => panic!("Invalid message type! Expected a MsgAgeCorrections"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgBaselineECEF.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_baseline_ecef.rs similarity index 88% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgBaselineECEF.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_baseline_ecef.rs index e507bf5913..34744d5394 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgBaselineECEF.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_baseline_ecef.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgBaselineECEF.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgBaselineECEF() { +fn test_auto_check_sbp_navigation_msg_baseline_ecef() { { let mut payload = Cursor::new(vec![ 85, 11, 2, 211, 136, 20, 40, 244, 122, 19, 150, 98, 238, 255, 190, 64, 20, 0, 246, 163, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEF() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineECEF(msg) => { + sbp::messages::Sbp::MsgBaselineEcef(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20b, "Incorrect message type, expected 0x20b, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -87,7 +80,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEF() { } _ => panic!("Invalid message type! Expected a MsgBaselineECEF"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -104,14 +97,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEF() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineECEF(msg) => { + sbp::messages::Sbp::MsgBaselineEcef(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20b, "Incorrect message type, expected 0x20b, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -155,7 +148,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEF() { } _ => panic!("Invalid message type! Expected a MsgBaselineECEF"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -172,14 +165,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEF() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineECEF(msg) => { + sbp::messages::Sbp::MsgBaselineEcef(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20b, "Incorrect message type, expected 0x20b, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -223,7 +216,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEF() { } _ => panic!("Invalid message type! Expected a MsgBaselineECEF"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -240,14 +233,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEF() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineECEF(msg) => { + sbp::messages::Sbp::MsgBaselineEcef(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20b, "Incorrect message type, expected 0x20b, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -291,7 +284,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEF() { } _ => panic!("Invalid message type! Expected a MsgBaselineECEF"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -308,14 +301,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEF() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineECEF(msg) => { + sbp::messages::Sbp::MsgBaselineEcef(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20b, "Incorrect message type, expected 0x20b, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -359,7 +352,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEF() { } _ => panic!("Invalid message type! Expected a MsgBaselineECEF"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgBaselineECEFDepA.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_baseline_ecef_dep_a.rs similarity index 89% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgBaselineECEFDepA.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_baseline_ecef_dep_a.rs index ed9dda8dd9..75f7a33dd8 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgBaselineECEFDepA.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_baseline_ecef_dep_a.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgBaselineECEFDepA.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { +fn test_auto_check_sbp_navigation_msg_baseline_ecef_dep_a() { { let mut payload = Cursor::new(vec![ 85, 2, 2, 246, 215, 20, 20, 46, 39, 0, 21, 48, 255, 255, 52, 117, 255, 255, 216, 211, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + sbp::messages::Sbp::MsgBaselineEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x202, "Incorrect message type, expected 0x202, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -87,7 +80,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -104,14 +97,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + sbp::messages::Sbp::MsgBaselineEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x202, "Incorrect message type, expected 0x202, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -155,7 +148,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -172,14 +165,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + sbp::messages::Sbp::MsgBaselineEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x202, "Incorrect message type, expected 0x202, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -223,7 +216,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -240,14 +233,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + sbp::messages::Sbp::MsgBaselineEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x202, "Incorrect message type, expected 0x202, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -291,7 +284,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -308,14 +301,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + sbp::messages::Sbp::MsgBaselineEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x202, "Incorrect message type, expected 0x202, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -359,7 +352,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -376,14 +369,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + sbp::messages::Sbp::MsgBaselineEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x202, "Incorrect message type, expected 0x202, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -427,7 +420,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -444,14 +437,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + sbp::messages::Sbp::MsgBaselineEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x202, "Incorrect message type, expected 0x202, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -495,7 +488,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -512,14 +505,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + sbp::messages::Sbp::MsgBaselineEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x202, "Incorrect message type, expected 0x202, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -563,7 +556,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -580,14 +573,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + sbp::messages::Sbp::MsgBaselineEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x202, "Incorrect message type, expected 0x202, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -631,7 +624,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -648,14 +641,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + sbp::messages::Sbp::MsgBaselineEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x202, "Incorrect message type, expected 0x202, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -699,7 +692,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -716,14 +709,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineECEFDepA(msg) => { + sbp::messages::Sbp::MsgBaselineEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x202, "Incorrect message type, expected 0x202, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -767,7 +760,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgBaselineNED.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_baseline_ned.rs similarity index 89% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgBaselineNED.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_baseline_ned.rs index b4c34c55fb..72c2f6fd1b 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgBaselineNED.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_baseline_ned.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgBaselineNED.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgBaselineNED() { +fn test_auto_check_sbp_navigation_msg_baseline_ned() { { let mut payload = Cursor::new(vec![ 85, 12, 2, 211, 136, 22, 40, 244, 122, 19, 201, 115, 12, 0, 179, 88, 230, 255, 153, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineNED() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineNED(msg) => { + sbp::messages::Sbp::MsgBaselineNed(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20c, "Incorrect message type, expected 0x20c, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -92,7 +85,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineNED() { } _ => panic!("Invalid message type! Expected a MsgBaselineNED"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -109,14 +102,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineNED() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineNED(msg) => { + sbp::messages::Sbp::MsgBaselineNed(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20c, "Incorrect message type, expected 0x20c, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -165,7 +158,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineNED() { } _ => panic!("Invalid message type! Expected a MsgBaselineNED"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -182,14 +175,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineNED() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineNED(msg) => { + sbp::messages::Sbp::MsgBaselineNed(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20c, "Incorrect message type, expected 0x20c, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -238,7 +231,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineNED() { } _ => panic!("Invalid message type! Expected a MsgBaselineNED"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -255,14 +248,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineNED() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineNED(msg) => { + sbp::messages::Sbp::MsgBaselineNed(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20c, "Incorrect message type, expected 0x20c, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -311,7 +304,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineNED() { } _ => panic!("Invalid message type! Expected a MsgBaselineNED"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -328,14 +321,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineNED() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineNED(msg) => { + sbp::messages::Sbp::MsgBaselineNed(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20c, "Incorrect message type, expected 0x20c, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -384,7 +377,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineNED() { } _ => panic!("Invalid message type! Expected a MsgBaselineNED"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgBaselineNEDDepA.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_baseline_ned_dep_a.rs similarity index 89% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgBaselineNEDDepA.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_baseline_ned_dep_a.rs index a594dcb291..8d4b7271a6 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgBaselineNEDDepA.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_baseline_ned_dep_a.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgBaselineNEDDepA.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { +fn test_auto_check_sbp_navigation_msg_baseline_ned_dep_a() { { let mut payload = Cursor::new(vec![ 85, 3, 2, 246, 215, 22, 20, 46, 39, 0, 243, 134, 254, 255, 234, 153, 255, 255, 0, 0, 0, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + sbp::messages::Sbp::MsgBaselineNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x203, "Incorrect message type, expected 0x203, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -88,7 +81,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -105,14 +98,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + sbp::messages::Sbp::MsgBaselineNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x203, "Incorrect message type, expected 0x203, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -157,7 +150,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -174,14 +167,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + sbp::messages::Sbp::MsgBaselineNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x203, "Incorrect message type, expected 0x203, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -226,7 +219,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -243,14 +236,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + sbp::messages::Sbp::MsgBaselineNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x203, "Incorrect message type, expected 0x203, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -295,7 +288,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -312,14 +305,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + sbp::messages::Sbp::MsgBaselineNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x203, "Incorrect message type, expected 0x203, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -364,7 +357,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -381,14 +374,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + sbp::messages::Sbp::MsgBaselineNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x203, "Incorrect message type, expected 0x203, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -437,7 +430,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -454,14 +447,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + sbp::messages::Sbp::MsgBaselineNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x203, "Incorrect message type, expected 0x203, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -510,7 +503,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -527,14 +520,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + sbp::messages::Sbp::MsgBaselineNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x203, "Incorrect message type, expected 0x203, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -583,7 +576,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -600,14 +593,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + sbp::messages::Sbp::MsgBaselineNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x203, "Incorrect message type, expected 0x203, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -656,7 +649,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -673,14 +666,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + sbp::messages::Sbp::MsgBaselineNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x203, "Incorrect message type, expected 0x203, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -729,7 +722,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -746,14 +739,14 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBaselineNEDDepA(msg) => { + sbp::messages::Sbp::MsgBaselineNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x203, "Incorrect message type, expected 0x203, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -802,7 +795,7 @@ fn test_auto_check_sbp_navigation_MsgBaselineNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgBaselineNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgDops.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_dops.rs similarity index 86% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgDops.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_dops.rs index f68f8e02b7..52a43c72b9 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgDops.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_dops.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgDops.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgDops() { +fn test_auto_check_sbp_navigation_msg_dops() { { let mut payload = Cursor::new(vec![ 85, 8, 2, 66, 0, 15, 100, 0, 0, 0, 2, 0, 6, 0, 5, 0, 5, 0, 5, 0, 0, 244, 4, @@ -35,14 +28,14 @@ fn test_auto_check_sbp_navigation_MsgDops() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgDops(msg) => { + sbp::messages::Sbp::MsgDops(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x208, "Incorrect message type, expected 0x208, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x42, "incorrect sender id, expected 0x42, is {}", @@ -86,7 +79,7 @@ fn test_auto_check_sbp_navigation_MsgDops() { } _ => panic!("Invalid message type! Expected a MsgDops"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgDopsDepA.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_dops_dep_a.rs similarity index 88% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgDopsDepA.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_dops_dep_a.rs index ce2ee1c9b0..64b1a6e3c8 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgDopsDepA.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_dops_dep_a.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgDopsDepA.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgDopsDepA() { +fn test_auto_check_sbp_navigation_msg_dops_dep_a() { { let mut payload = Cursor::new(vec![ 85, 6, 2, 246, 215, 14, 8, 48, 39, 0, 180, 0, 190, 0, 170, 0, 160, 0, 150, 0, 121, 170, @@ -35,14 +28,14 @@ fn test_auto_check_sbp_navigation_MsgDopsDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgDopsDepA(msg) => { + sbp::messages::Sbp::MsgDopsDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x206, "Incorrect message type, expected 0x206, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -81,7 +74,7 @@ fn test_auto_check_sbp_navigation_MsgDopsDepA() { } _ => panic!("Invalid message type! Expected a MsgDopsDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -97,14 +90,14 @@ fn test_auto_check_sbp_navigation_MsgDopsDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgDopsDepA(msg) => { + sbp::messages::Sbp::MsgDopsDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x206, "Incorrect message type, expected 0x206, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -143,7 +136,7 @@ fn test_auto_check_sbp_navigation_MsgDopsDepA() { } _ => panic!("Invalid message type! Expected a MsgDopsDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -159,14 +152,14 @@ fn test_auto_check_sbp_navigation_MsgDopsDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgDopsDepA(msg) => { + sbp::messages::Sbp::MsgDopsDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x206, "Incorrect message type, expected 0x206, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -205,7 +198,7 @@ fn test_auto_check_sbp_navigation_MsgDopsDepA() { } _ => panic!("Invalid message type! Expected a MsgDopsDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -221,14 +214,14 @@ fn test_auto_check_sbp_navigation_MsgDopsDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgDopsDepA(msg) => { + sbp::messages::Sbp::MsgDopsDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x206, "Incorrect message type, expected 0x206, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -267,7 +260,7 @@ fn test_auto_check_sbp_navigation_MsgDopsDepA() { } _ => panic!("Invalid message type! Expected a MsgDopsDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -283,14 +276,14 @@ fn test_auto_check_sbp_navigation_MsgDopsDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgDopsDepA(msg) => { + sbp::messages::Sbp::MsgDopsDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x206, "Incorrect message type, expected 0x206, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -329,7 +322,7 @@ fn test_auto_check_sbp_navigation_MsgDopsDepA() { } _ => panic!("Invalid message type! Expected a MsgDopsDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -345,14 +338,14 @@ fn test_auto_check_sbp_navigation_MsgDopsDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgDopsDepA(msg) => { + sbp::messages::Sbp::MsgDopsDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x206, "Incorrect message type, expected 0x206, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -391,7 +384,7 @@ fn test_auto_check_sbp_navigation_MsgDopsDepA() { } _ => panic!("Invalid message type! Expected a MsgDopsDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -407,14 +400,14 @@ fn test_auto_check_sbp_navigation_MsgDopsDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgDopsDepA(msg) => { + sbp::messages::Sbp::MsgDopsDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x206, "Incorrect message type, expected 0x206, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -453,7 +446,7 @@ fn test_auto_check_sbp_navigation_MsgDopsDepA() { } _ => panic!("Invalid message type! Expected a MsgDopsDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -469,14 +462,14 @@ fn test_auto_check_sbp_navigation_MsgDopsDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgDopsDepA(msg) => { + sbp::messages::Sbp::MsgDopsDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x206, "Incorrect message type, expected 0x206, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -515,7 +508,7 @@ fn test_auto_check_sbp_navigation_MsgDopsDepA() { } _ => panic!("Invalid message type! Expected a MsgDopsDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -531,14 +524,14 @@ fn test_auto_check_sbp_navigation_MsgDopsDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgDopsDepA(msg) => { + sbp::messages::Sbp::MsgDopsDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x206, "Incorrect message type, expected 0x206, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -577,7 +570,7 @@ fn test_auto_check_sbp_navigation_MsgDopsDepA() { } _ => panic!("Invalid message type! Expected a MsgDopsDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgGPSTime.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_gps_time.rs similarity index 86% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgGPSTime.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_gps_time.rs index 287bdb68b0..23f1f114dd 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgGPSTime.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_gps_time.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgGPSTime.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgGPSTime() { +fn test_auto_check_sbp_navigation_msg_gps_time() { { let mut payload = Cursor::new(vec![ 85, 2, 1, 211, 136, 11, 128, 7, 40, 244, 122, 19, 244, 139, 2, 0, 0, 34, 152, @@ -35,14 +28,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTime() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTime(msg) => { + sbp::messages::Sbp::MsgGpsTime(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x102, "Incorrect message type, expected 0x102, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -71,7 +64,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTime() { } _ => panic!("Invalid message type! Expected a MsgGPSTime"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -87,14 +80,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTime() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTime(msg) => { + sbp::messages::Sbp::MsgGpsTime(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x102, "Incorrect message type, expected 0x102, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -123,7 +116,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTime() { } _ => panic!("Invalid message type! Expected a MsgGPSTime"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -139,14 +132,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTime() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTime(msg) => { + sbp::messages::Sbp::MsgGpsTime(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x102, "Incorrect message type, expected 0x102, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -175,7 +168,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTime() { } _ => panic!("Invalid message type! Expected a MsgGPSTime"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -191,14 +184,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTime() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTime(msg) => { + sbp::messages::Sbp::MsgGpsTime(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x102, "Incorrect message type, expected 0x102, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -227,7 +220,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTime() { } _ => panic!("Invalid message type! Expected a MsgGPSTime"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -243,14 +236,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTime() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTime(msg) => { + sbp::messages::Sbp::MsgGpsTime(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x102, "Incorrect message type, expected 0x102, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -279,7 +272,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTime() { } _ => panic!("Invalid message type! Expected a MsgGPSTime"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgGPSTimeDepA.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_gps_time_dep_a.rs similarity index 86% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgGPSTimeDepA.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_gps_time_dep_a.rs index f615c91377..91ac7a29f1 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgGPSTimeDepA.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_gps_time_dep_a.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgGPSTimeDepA.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { +fn test_auto_check_sbp_navigation_msg_gps_time_dep_a() { { let mut payload = Cursor::new(vec![ 85, 0, 1, 246, 215, 11, 251, 6, 120, 46, 39, 0, 0, 0, 0, 0, 0, 133, 36, @@ -35,14 +28,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + sbp::messages::Sbp::MsgGpsTimeDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x100, "Incorrect message type, expected 0x100, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -71,7 +64,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { } _ => panic!("Invalid message type! Expected a MsgGPSTimeDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -87,14 +80,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + sbp::messages::Sbp::MsgGpsTimeDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x100, "Incorrect message type, expected 0x100, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -123,7 +116,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { } _ => panic!("Invalid message type! Expected a MsgGPSTimeDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -139,14 +132,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + sbp::messages::Sbp::MsgGpsTimeDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x100, "Incorrect message type, expected 0x100, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -175,7 +168,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { } _ => panic!("Invalid message type! Expected a MsgGPSTimeDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -191,14 +184,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + sbp::messages::Sbp::MsgGpsTimeDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x100, "Incorrect message type, expected 0x100, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -227,7 +220,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { } _ => panic!("Invalid message type! Expected a MsgGPSTimeDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -243,14 +236,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + sbp::messages::Sbp::MsgGpsTimeDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x100, "Incorrect message type, expected 0x100, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -279,7 +272,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { } _ => panic!("Invalid message type! Expected a MsgGPSTimeDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -295,14 +288,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + sbp::messages::Sbp::MsgGpsTimeDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x100, "Incorrect message type, expected 0x100, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -331,7 +324,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { } _ => panic!("Invalid message type! Expected a MsgGPSTimeDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -347,14 +340,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + sbp::messages::Sbp::MsgGpsTimeDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x100, "Incorrect message type, expected 0x100, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -383,7 +376,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { } _ => panic!("Invalid message type! Expected a MsgGPSTimeDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -399,14 +392,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + sbp::messages::Sbp::MsgGpsTimeDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x100, "Incorrect message type, expected 0x100, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -435,7 +428,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { } _ => panic!("Invalid message type! Expected a MsgGPSTimeDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -451,14 +444,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + sbp::messages::Sbp::MsgGpsTimeDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x100, "Incorrect message type, expected 0x100, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -487,7 +480,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { } _ => panic!("Invalid message type! Expected a MsgGPSTimeDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -503,14 +496,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + sbp::messages::Sbp::MsgGpsTimeDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x100, "Incorrect message type, expected 0x100, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -539,7 +532,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { } _ => panic!("Invalid message type! Expected a MsgGPSTimeDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -555,14 +548,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTimeDepA(msg) => { + sbp::messages::Sbp::MsgGpsTimeDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x100, "Incorrect message type, expected 0x100, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -591,7 +584,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeDepA() { } _ => panic!("Invalid message type! Expected a MsgGPSTimeDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgGPSTimeGNSS.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_gps_time_gnss.rs similarity index 85% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgGPSTimeGNSS.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_gps_time_gnss.rs index 8a16eb7802..89f7935a20 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgGPSTimeGNSS.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_gps_time_gnss.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgGPSTimeGNSS.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgGPSTimeGNSS() { +fn test_auto_check_sbp_navigation_msg_gps_time_gnss() { { let mut payload = Cursor::new(vec![ 85, 4, 1, 211, 136, 11, 128, 7, 40, 244, 122, 19, 244, 139, 2, 0, 0, 153, 88, @@ -35,14 +28,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeGNSS() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTimeGnss(msg) => { + sbp::messages::Sbp::MsgGpsTimeGnss(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x104, "Incorrect message type, expected 0x104, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -71,7 +64,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeGNSS() { } _ => panic!("Invalid message type! Expected a MsgGPSTimeGnss"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -87,14 +80,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeGNSS() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTimeGnss(msg) => { + sbp::messages::Sbp::MsgGpsTimeGnss(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x104, "Incorrect message type, expected 0x104, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -123,7 +116,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeGNSS() { } _ => panic!("Invalid message type! Expected a MsgGPSTimeGnss"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -139,14 +132,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeGNSS() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTimeGnss(msg) => { + sbp::messages::Sbp::MsgGpsTimeGnss(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x104, "Incorrect message type, expected 0x104, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -175,7 +168,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeGNSS() { } _ => panic!("Invalid message type! Expected a MsgGPSTimeGnss"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -191,14 +184,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeGNSS() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTimeGnss(msg) => { + sbp::messages::Sbp::MsgGpsTimeGnss(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x104, "Incorrect message type, expected 0x104, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -227,7 +220,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeGNSS() { } _ => panic!("Invalid message type! Expected a MsgGPSTimeGnss"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -243,14 +236,14 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeGNSS() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGPSTimeGnss(msg) => { + sbp::messages::Sbp::MsgGpsTimeGnss(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x104, "Incorrect message type, expected 0x104, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -279,7 +272,7 @@ fn test_auto_check_sbp_navigation_MsgGPSTimeGNSS() { } _ => panic!("Invalid message type! Expected a MsgGPSTimeGnss"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosECEF.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_ecef.rs similarity index 89% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgPosECEF.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_ecef.rs index fe121cf48e..03f2520b8d 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosECEF.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_ecef.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosECEF.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgPosECEF() { +fn test_auto_check_sbp_navigation_msg_pos_ecef() { { let mut payload = Cursor::new(vec![ 85, 9, 2, 211, 136, 32, 16, 248, 122, 19, 73, 29, 46, 132, 182, 122, 68, 193, 219, 192, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_navigation_MsgPosECEF() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosECEF(msg) => { + sbp::messages::Sbp::MsgPosEcef(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x209, "Incorrect message type, expected 0x209, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -87,7 +80,7 @@ fn test_auto_check_sbp_navigation_MsgPosECEF() { } _ => panic!("Invalid message type! Expected a MsgPosECEF"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -105,14 +98,14 @@ fn test_auto_check_sbp_navigation_MsgPosECEF() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosECEF(msg) => { + sbp::messages::Sbp::MsgPosEcef(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x209, "Incorrect message type, expected 0x209, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -156,7 +149,7 @@ fn test_auto_check_sbp_navigation_MsgPosECEF() { } _ => panic!("Invalid message type! Expected a MsgPosECEF"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -174,14 +167,14 @@ fn test_auto_check_sbp_navigation_MsgPosECEF() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosECEF(msg) => { + sbp::messages::Sbp::MsgPosEcef(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x209, "Incorrect message type, expected 0x209, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -225,7 +218,7 @@ fn test_auto_check_sbp_navigation_MsgPosECEF() { } _ => panic!("Invalid message type! Expected a MsgPosECEF"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -242,14 +235,14 @@ fn test_auto_check_sbp_navigation_MsgPosECEF() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosECEF(msg) => { + sbp::messages::Sbp::MsgPosEcef(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x209, "Incorrect message type, expected 0x209, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -293,7 +286,7 @@ fn test_auto_check_sbp_navigation_MsgPosECEF() { } _ => panic!("Invalid message type! Expected a MsgPosECEF"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosECEFCov.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_ecef_cov.rs similarity index 90% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgPosECEFCov.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_ecef_cov.rs index 1212f889ed..5245f913a3 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosECEFCov.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_ecef_cov.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosECEFCov.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgPosECEFCov() { +fn test_auto_check_sbp_navigation_msg_pos_ecef_cov() { { let mut payload = Cursor::new(vec![ 85, 20, 2, 66, 0, 54, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 64, 0, 0, 0, 0, 0, 0, 240, 63, @@ -37,14 +30,14 @@ fn test_auto_check_sbp_navigation_MsgPosECEFCov() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosECEFCov(msg) => { + sbp::messages::Sbp::MsgPosEcefCov(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x214, "Incorrect message type, expected 0x214, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x42, "incorrect sender id, expected 0x42, is {}", @@ -113,7 +106,7 @@ fn test_auto_check_sbp_navigation_MsgPosECEFCov() { } _ => panic!("Invalid message type! Expected a MsgPosECEFCov"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosECEFCovGNSS.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_ecef_cov_gnss.rs similarity index 90% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgPosECEFCovGNSS.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_ecef_cov_gnss.rs index d4dc36043d..a328277bf5 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosECEFCovGNSS.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_ecef_cov_gnss.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosECEFCovGNSS.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgPosECEFCovGNSS() { +fn test_auto_check_sbp_navigation_msg_pos_ecef_cov_gnss() { { let mut payload = Cursor::new(vec![ 85, 52, 2, 0, 16, 54, 24, 229, 233, 29, 52, 254, 158, 218, 42, 142, 68, 193, 69, 162, @@ -38,14 +31,14 @@ fn test_auto_check_sbp_navigation_MsgPosECEFCovGNSS() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosECEFCovGnss(msg) => { + sbp::messages::Sbp::MsgPosEcefCovGnss(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x234, "Incorrect message type, expected 0x234, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x1000, "incorrect sender id, expected 0x1000, is {}", @@ -114,7 +107,7 @@ fn test_auto_check_sbp_navigation_MsgPosECEFCovGNSS() { } _ => panic!("Invalid message type! Expected a MsgPosECEFCovGnss"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosECEFDepA.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_ecef_dep_a.rs similarity index 90% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgPosECEFDepA.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_ecef_dep_a.rs index 431c0419ac..07cfa4b7cb 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosECEFDepA.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_ecef_dep_a.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosECEFDepA.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { +fn test_auto_check_sbp_navigation_msg_pos_ecef_dep_a() { { let mut payload = Cursor::new(vec![ 85, 0, 2, 246, 215, 32, 20, 46, 39, 0, 195, 122, 175, 75, 33, 154, 68, 193, 164, 14, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosECEFDepA(msg) => { + sbp::messages::Sbp::MsgPosEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x200, "Incorrect message type, expected 0x200, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -87,7 +80,7 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgPosECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -104,14 +97,14 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosECEFDepA(msg) => { + sbp::messages::Sbp::MsgPosEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x200, "Incorrect message type, expected 0x200, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -155,7 +148,7 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgPosECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -172,14 +165,14 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosECEFDepA(msg) => { + sbp::messages::Sbp::MsgPosEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x200, "Incorrect message type, expected 0x200, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -223,7 +216,7 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgPosECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -240,14 +233,14 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosECEFDepA(msg) => { + sbp::messages::Sbp::MsgPosEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x200, "Incorrect message type, expected 0x200, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -291,7 +284,7 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgPosECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -308,14 +301,14 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosECEFDepA(msg) => { + sbp::messages::Sbp::MsgPosEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x200, "Incorrect message type, expected 0x200, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -359,7 +352,7 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgPosECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -376,14 +369,14 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosECEFDepA(msg) => { + sbp::messages::Sbp::MsgPosEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x200, "Incorrect message type, expected 0x200, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -427,7 +420,7 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgPosECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -444,14 +437,14 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosECEFDepA(msg) => { + sbp::messages::Sbp::MsgPosEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x200, "Incorrect message type, expected 0x200, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -495,7 +488,7 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgPosECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -512,14 +505,14 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosECEFDepA(msg) => { + sbp::messages::Sbp::MsgPosEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x200, "Incorrect message type, expected 0x200, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -563,7 +556,7 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgPosECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -580,14 +573,14 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosECEFDepA(msg) => { + sbp::messages::Sbp::MsgPosEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x200, "Incorrect message type, expected 0x200, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -631,7 +624,7 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgPosECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -648,14 +641,14 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosECEFDepA(msg) => { + sbp::messages::Sbp::MsgPosEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x200, "Incorrect message type, expected 0x200, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -699,7 +692,7 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgPosECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -716,14 +709,14 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosECEFDepA(msg) => { + sbp::messages::Sbp::MsgPosEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x200, "Incorrect message type, expected 0x200, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -767,7 +760,7 @@ fn test_auto_check_sbp_navigation_MsgPosECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgPosECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosECEFGNSS.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_ecefgnss.rs similarity index 87% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgPosECEFGNSS.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_ecefgnss.rs index ab88c243bf..f08f782137 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosECEFGNSS.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_ecefgnss.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosECEFGNSS.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgPosECEFGNSS() { +fn test_auto_check_sbp_navigation_msg_pos_ecefgnss() { { let mut payload = Cursor::new(vec![ 85, 41, 2, 0, 16, 32, 24, 229, 233, 29, 52, 254, 158, 218, 42, 142, 68, 193, 69, 162, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_navigation_MsgPosECEFGNSS() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosECEFGnss(msg) => { + sbp::messages::Sbp::MsgPosEcefGnss(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x229, "Incorrect message type, expected 0x229, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x1000, "incorrect sender id, expected 0x1000, is {}", @@ -87,7 +80,7 @@ fn test_auto_check_sbp_navigation_MsgPosECEFGNSS() { } _ => panic!("Invalid message type! Expected a MsgPosECEFGnss"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosLLH.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_llh.rs similarity index 90% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgPosLLH.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_llh.rs index 08ec409bed..8b9e228b8c 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosLLH.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_llh.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosLLH.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgPosLLH() { +fn test_auto_check_sbp_navigation_msg_pos_llh() { { let mut payload = Cursor::new(vec![ 85, 10, 2, 211, 136, 34, 40, 244, 122, 19, 201, 106, 155, 186, 42, 160, 66, 64, 168, @@ -37,14 +30,14 @@ fn test_auto_check_sbp_navigation_MsgPosLLH() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosLLH(msg) => { + sbp::messages::Sbp::MsgPosLlh(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20a, "Incorrect message type, expected 0x20a, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -93,7 +86,7 @@ fn test_auto_check_sbp_navigation_MsgPosLLH() { } _ => panic!("Invalid message type! Expected a MsgPosLLH"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -111,14 +104,14 @@ fn test_auto_check_sbp_navigation_MsgPosLLH() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosLLH(msg) => { + sbp::messages::Sbp::MsgPosLlh(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20a, "Incorrect message type, expected 0x20a, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -167,7 +160,7 @@ fn test_auto_check_sbp_navigation_MsgPosLLH() { } _ => panic!("Invalid message type! Expected a MsgPosLLH"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -185,14 +178,14 @@ fn test_auto_check_sbp_navigation_MsgPosLLH() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosLLH(msg) => { + sbp::messages::Sbp::MsgPosLlh(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20a, "Incorrect message type, expected 0x20a, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -241,7 +234,7 @@ fn test_auto_check_sbp_navigation_MsgPosLLH() { } _ => panic!("Invalid message type! Expected a MsgPosLLH"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -259,14 +252,14 @@ fn test_auto_check_sbp_navigation_MsgPosLLH() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosLLH(msg) => { + sbp::messages::Sbp::MsgPosLlh(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20a, "Incorrect message type, expected 0x20a, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -315,7 +308,7 @@ fn test_auto_check_sbp_navigation_MsgPosLLH() { } _ => panic!("Invalid message type! Expected a MsgPosLLH"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -333,14 +326,14 @@ fn test_auto_check_sbp_navigation_MsgPosLLH() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosLLH(msg) => { + sbp::messages::Sbp::MsgPosLlh(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20a, "Incorrect message type, expected 0x20a, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -389,7 +382,7 @@ fn test_auto_check_sbp_navigation_MsgPosLLH() { } _ => panic!("Invalid message type! Expected a MsgPosLLH"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosLLHCov.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_llh_cov.rs similarity index 90% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgPosLLHCov.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_llh_cov.rs index b631fdba18..c422e81e53 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosLLHCov.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_llh_cov.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosLLHCov.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgPosLLHCov() { +fn test_auto_check_sbp_navigation_msg_pos_llh_cov() { { let mut payload = Cursor::new(vec![ 85, 17, 2, 66, 0, 54, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 64, 0, @@ -37,14 +30,14 @@ fn test_auto_check_sbp_navigation_MsgPosLLHCov() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosLLHCov(msg) => { + sbp::messages::Sbp::MsgPosLlhCov(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x211, "Incorrect message type, expected 0x211, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x42, "incorrect sender id, expected 0x42, is {}", @@ -113,7 +106,7 @@ fn test_auto_check_sbp_navigation_MsgPosLLHCov() { } _ => panic!("Invalid message type! Expected a MsgPosLLHCov"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosLlhCovGnss.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_llh_cov_gnss.rs similarity index 90% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgPosLlhCovGnss.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_llh_cov_gnss.rs index a40c308337..dab559538e 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosLlhCovGnss.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_llh_cov_gnss.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosLlhCovGnss.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgPosLlhCovGnss() { +fn test_auto_check_sbp_navigation_msg_pos_llh_cov_gnss() { { let mut payload = Cursor::new(vec![ 85, 49, 2, 0, 16, 54, 24, 229, 233, 29, 73, 123, 28, 207, 101, 234, 66, 64, 100, 168, @@ -38,14 +31,14 @@ fn test_auto_check_sbp_navigation_MsgPosLlhCovGnss() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosLLHCovGnss(msg) => { + sbp::messages::Sbp::MsgPosLlhCovGnss(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x231, "Incorrect message type, expected 0x231, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x1000, "incorrect sender id, expected 0x1000, is {}", @@ -114,7 +107,7 @@ fn test_auto_check_sbp_navigation_MsgPosLlhCovGnss() { } _ => panic!("Invalid message type! Expected a MsgPosLLHCovGnss"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosLLHDepA.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_llh_dep_a.rs similarity index 90% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgPosLLHDepA.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_llh_dep_a.rs index 67b2d070a5..2d86720bc2 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosLLHDepA.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_llh_dep_a.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosLLHDepA.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { +fn test_auto_check_sbp_navigation_msg_pos_llh_dep_a() { { let mut payload = Cursor::new(vec![ 85, 1, 2, 246, 215, 34, 20, 46, 39, 0, 250, 29, 226, 186, 235, 182, 66, 64, 19, 203, @@ -37,14 +30,14 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosLLHDepA(msg) => { + sbp::messages::Sbp::MsgPosLlhDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x201, "Incorrect message type, expected 0x201, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -93,7 +86,7 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { } _ => panic!("Invalid message type! Expected a MsgPosLLHDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -110,14 +103,14 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosLLHDepA(msg) => { + sbp::messages::Sbp::MsgPosLlhDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x201, "Incorrect message type, expected 0x201, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -166,7 +159,7 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { } _ => panic!("Invalid message type! Expected a MsgPosLLHDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -184,14 +177,14 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosLLHDepA(msg) => { + sbp::messages::Sbp::MsgPosLlhDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x201, "Incorrect message type, expected 0x201, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -240,7 +233,7 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { } _ => panic!("Invalid message type! Expected a MsgPosLLHDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -258,14 +251,14 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosLLHDepA(msg) => { + sbp::messages::Sbp::MsgPosLlhDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x201, "Incorrect message type, expected 0x201, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -314,7 +307,7 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { } _ => panic!("Invalid message type! Expected a MsgPosLLHDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -332,14 +325,14 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosLLHDepA(msg) => { + sbp::messages::Sbp::MsgPosLlhDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x201, "Incorrect message type, expected 0x201, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -388,7 +381,7 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { } _ => panic!("Invalid message type! Expected a MsgPosLLHDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -405,14 +398,14 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosLLHDepA(msg) => { + sbp::messages::Sbp::MsgPosLlhDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x201, "Incorrect message type, expected 0x201, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -461,7 +454,7 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { } _ => panic!("Invalid message type! Expected a MsgPosLLHDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -479,14 +472,14 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosLLHDepA(msg) => { + sbp::messages::Sbp::MsgPosLlhDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x201, "Incorrect message type, expected 0x201, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -535,7 +528,7 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { } _ => panic!("Invalid message type! Expected a MsgPosLLHDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -553,14 +546,14 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosLLHDepA(msg) => { + sbp::messages::Sbp::MsgPosLlhDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x201, "Incorrect message type, expected 0x201, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -609,7 +602,7 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { } _ => panic!("Invalid message type! Expected a MsgPosLLHDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -626,14 +619,14 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosLLHDepA(msg) => { + sbp::messages::Sbp::MsgPosLlhDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x201, "Incorrect message type, expected 0x201, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -682,7 +675,7 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { } _ => panic!("Invalid message type! Expected a MsgPosLLHDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -700,14 +693,14 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosLLHDepA(msg) => { + sbp::messages::Sbp::MsgPosLlhDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x201, "Incorrect message type, expected 0x201, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -756,7 +749,7 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { } _ => panic!("Invalid message type! Expected a MsgPosLLHDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -774,14 +767,14 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosLLHDepA(msg) => { + sbp::messages::Sbp::MsgPosLlhDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x201, "Incorrect message type, expected 0x201, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -830,7 +823,7 @@ fn test_auto_check_sbp_navigation_MsgPosLLHDepA() { } _ => panic!("Invalid message type! Expected a MsgPosLLHDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosLlhGnss.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_llh_gnss.rs similarity index 88% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgPosLlhGnss.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_llh_gnss.rs index b0ed915bce..ca904447b4 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgPosLlhGnss.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_pos_llh_gnss.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgPosLlhGnss.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgPosLlhGnss() { +fn test_auto_check_sbp_navigation_msg_pos_llh_gnss() { { let mut payload = Cursor::new(vec![ 85, 42, 2, 0, 16, 34, 24, 229, 233, 29, 73, 123, 28, 207, 101, 234, 66, 64, 100, 168, @@ -37,14 +30,14 @@ fn test_auto_check_sbp_navigation_MsgPosLlhGnss() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgPosLLHGnss(msg) => { + sbp::messages::Sbp::MsgPosLlhGnss(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x22a, "Incorrect message type, expected 0x22a, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x1000, "incorrect sender id, expected 0x1000, is {}", @@ -93,7 +86,7 @@ fn test_auto_check_sbp_navigation_MsgPosLlhGnss() { } _ => panic!("Invalid message type! Expected a MsgPosLLHGnss"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgProtectionLevel.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_protection_level.rs similarity index 86% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgProtectionLevel.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_protection_level.rs index 9efd6ca976..a486e8229e 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgProtectionLevel.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_protection_level.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgProtectionLevel.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgProtectionLevel() { +fn test_auto_check_sbp_navigation_msg_protection_level() { { let mut payload = Cursor::new(vec![ 85, 22, 2, 0, 16, 33, 136, 227, 233, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_navigation_MsgProtectionLevel() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgProtectionLevelDepA(msg) => { + sbp::messages::Sbp::MsgProtectionLevelDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x216, "Incorrect message type, expected 0x216, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x1000, "incorrect sender id, expected 0x1000, is {}", @@ -87,7 +80,7 @@ fn test_auto_check_sbp_navigation_MsgProtectionLevel() { } _ => panic!("Invalid message type! Expected a MsgProtectionLevelDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgUTCTime.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_utc_time.rs similarity index 88% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgUTCTime.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_utc_time.rs index b7a61873ac..cdc3977206 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgUTCTime.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_utc_time.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgUTCTime.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgUTCTime() { +fn test_auto_check_sbp_navigation_msg_utc_time() { { let mut payload = Cursor::new(vec![ 85, 3, 1, 21, 3, 16, 1, 24, 229, 233, 29, 229, 7, 4, 9, 19, 24, 9, 0, 8, 175, 47, 199, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_navigation_MsgUTCTime() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgUtcTime(msg) => { + sbp::messages::Sbp::MsgUtcTime(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x103, "Incorrect message type, expected 0x103, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x315, "incorrect sender id, expected 0x315, is {}", @@ -97,7 +90,7 @@ fn test_auto_check_sbp_navigation_MsgUTCTime() { } _ => panic!("Invalid message type! Expected a MsgUtcTime"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgUTCTimeGNSS.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_utc_time_gnss.rs similarity index 87% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgUTCTimeGNSS.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_utc_time_gnss.rs index bf06c47377..7fd1de97ab 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgUTCTimeGNSS.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_utc_time_gnss.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgUTCTimeGNSS.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgUTCTimeGNSS() { +fn test_auto_check_sbp_navigation_msg_utc_time_gnss() { { let mut payload = Cursor::new(vec![ 85, 5, 1, 21, 3, 16, 1, 24, 229, 233, 29, 229, 7, 4, 9, 19, 24, 9, 0, 8, 175, 47, 177, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_navigation_MsgUTCTimeGNSS() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgUtcTimeGnss(msg) => { + sbp::messages::Sbp::MsgUtcTimeGnss(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x105, "Incorrect message type, expected 0x105, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x315, "incorrect sender id, expected 0x315, is {}", @@ -97,7 +90,7 @@ fn test_auto_check_sbp_navigation_MsgUTCTimeGNSS() { } _ => panic!("Invalid message type! Expected a MsgUtcTimeGnss"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelBody.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_body.rs similarity index 89% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgVelBody.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_body.rs index efbeda1a8c..db2a138d56 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelBody.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_body.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelBody.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgVelBody() { +fn test_auto_check_sbp_navigation_msg_vel_body() { { let mut payload = Cursor::new(vec![ 85, 19, 2, 66, 0, 42, 1, 0, 0, 0, 4, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_navigation_MsgVelBody() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelBody(msg) => { + sbp::messages::Sbp::MsgVelBody(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x213, "Incorrect message type, expected 0x213, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x42, "incorrect sender id, expected 0x42, is {}", @@ -100,7 +93,7 @@ fn test_auto_check_sbp_navigation_MsgVelBody() { } _ => panic!("Invalid message type! Expected a MsgVelBody"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelECEF.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ecef.rs similarity index 88% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgVelECEF.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ecef.rs index 893ffa3d79..b661134d02 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelECEF.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ecef.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelECEF.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgVelECEF() { +fn test_auto_check_sbp_navigation_msg_vel_ecef() { { let mut payload = Cursor::new(vec![ 85, 13, 2, 211, 136, 20, 40, 244, 122, 19, 248, 255, 255, 255, 251, 255, 255, 255, 10, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_navigation_MsgVelECEF() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelECEF(msg) => { + sbp::messages::Sbp::MsgVelEcef(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20d, "Incorrect message type, expected 0x20d, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -87,7 +80,7 @@ fn test_auto_check_sbp_navigation_MsgVelECEF() { } _ => panic!("Invalid message type! Expected a MsgVelECEF"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -104,14 +97,14 @@ fn test_auto_check_sbp_navigation_MsgVelECEF() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelECEF(msg) => { + sbp::messages::Sbp::MsgVelEcef(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20d, "Incorrect message type, expected 0x20d, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -155,7 +148,7 @@ fn test_auto_check_sbp_navigation_MsgVelECEF() { } _ => panic!("Invalid message type! Expected a MsgVelECEF"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -172,14 +165,14 @@ fn test_auto_check_sbp_navigation_MsgVelECEF() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelECEF(msg) => { + sbp::messages::Sbp::MsgVelEcef(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20d, "Incorrect message type, expected 0x20d, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -219,7 +212,7 @@ fn test_auto_check_sbp_navigation_MsgVelECEF() { } _ => panic!("Invalid message type! Expected a MsgVelECEF"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -236,14 +229,14 @@ fn test_auto_check_sbp_navigation_MsgVelECEF() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelECEF(msg) => { + sbp::messages::Sbp::MsgVelEcef(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20d, "Incorrect message type, expected 0x20d, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -287,7 +280,7 @@ fn test_auto_check_sbp_navigation_MsgVelECEF() { } _ => panic!("Invalid message type! Expected a MsgVelECEF"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -304,14 +297,14 @@ fn test_auto_check_sbp_navigation_MsgVelECEF() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelECEF(msg) => { + sbp::messages::Sbp::MsgVelEcef(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20d, "Incorrect message type, expected 0x20d, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -355,7 +348,7 @@ fn test_auto_check_sbp_navigation_MsgVelECEF() { } _ => panic!("Invalid message type! Expected a MsgVelECEF"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelECEFCov.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ecef_cov.rs similarity index 89% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgVelECEFCov.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ecef_cov.rs index bb29b5ce66..aac6901af3 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelECEFCov.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ecef_cov.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelECEFCov.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgVelECEFCov() { +fn test_auto_check_sbp_navigation_msg_vel_ecef_cov() { { let mut payload = Cursor::new(vec![ 85, 21, 2, 66, 0, 42, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 64, 0, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_navigation_MsgVelECEFCov() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelECEFCov(msg) => { + sbp::messages::Sbp::MsgVelEcefCov(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x215, "Incorrect message type, expected 0x215, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x42, "incorrect sender id, expected 0x42, is {}", @@ -100,7 +93,7 @@ fn test_auto_check_sbp_navigation_MsgVelECEFCov() { } _ => panic!("Invalid message type! Expected a MsgVelECEFCov"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelEcefCovGnss.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ecef_cov_gnss.rs similarity index 89% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgVelEcefCovGnss.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ecef_cov_gnss.rs index 5e0117f4e6..d6b48dd67c 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelEcefCovGnss.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ecef_cov_gnss.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelEcefCovGnss.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgVelEcefCovGnss() { +fn test_auto_check_sbp_navigation_msg_vel_ecef_cov_gnss() { { let mut payload = Cursor::new(vec![ 85, 53, 2, 0, 16, 42, 224, 229, 233, 29, 253, 255, 255, 255, 1, 0, 0, 0, 4, 0, 0, 0, @@ -37,14 +30,14 @@ fn test_auto_check_sbp_navigation_MsgVelEcefCovGnss() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelECEFCovGnss(msg) => { + sbp::messages::Sbp::MsgVelEcefCovGnss(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x235, "Incorrect message type, expected 0x235, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x1000, "incorrect sender id, expected 0x1000, is {}", @@ -105,7 +98,7 @@ fn test_auto_check_sbp_navigation_MsgVelEcefCovGnss() { } _ => panic!("Invalid message type! Expected a MsgVelECEFCovGnss"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelECEFDepA.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ecef_dep_a.rs similarity index 89% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgVelECEFDepA.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ecef_dep_a.rs index be56dfdee3..fcd9957369 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelECEFDepA.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ecef_dep_a.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelECEFDepA.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { +fn test_auto_check_sbp_navigation_msg_vel_ecef_dep_a() { { let mut payload = Cursor::new(vec![ 85, 4, 2, 246, 215, 20, 20, 46, 39, 0, 218, 11, 0, 0, 134, 245, 255, 255, 163, 252, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelECEFDepA(msg) => { + sbp::messages::Sbp::MsgVelEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x204, "Incorrect message type, expected 0x204, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -87,7 +80,7 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgVelECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -104,14 +97,14 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelECEFDepA(msg) => { + sbp::messages::Sbp::MsgVelEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x204, "Incorrect message type, expected 0x204, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -155,7 +148,7 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgVelECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -172,14 +165,14 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelECEFDepA(msg) => { + sbp::messages::Sbp::MsgVelEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x204, "Incorrect message type, expected 0x204, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -223,7 +216,7 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgVelECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -240,14 +233,14 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelECEFDepA(msg) => { + sbp::messages::Sbp::MsgVelEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x204, "Incorrect message type, expected 0x204, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -291,7 +284,7 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgVelECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -308,14 +301,14 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelECEFDepA(msg) => { + sbp::messages::Sbp::MsgVelEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x204, "Incorrect message type, expected 0x204, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -359,7 +352,7 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgVelECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -376,14 +369,14 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelECEFDepA(msg) => { + sbp::messages::Sbp::MsgVelEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x204, "Incorrect message type, expected 0x204, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -427,7 +420,7 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgVelECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -444,14 +437,14 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelECEFDepA(msg) => { + sbp::messages::Sbp::MsgVelEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x204, "Incorrect message type, expected 0x204, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -491,7 +484,7 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgVelECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -508,14 +501,14 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelECEFDepA(msg) => { + sbp::messages::Sbp::MsgVelEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x204, "Incorrect message type, expected 0x204, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -551,7 +544,7 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgVelECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -568,14 +561,14 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelECEFDepA(msg) => { + sbp::messages::Sbp::MsgVelEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x204, "Incorrect message type, expected 0x204, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -619,7 +612,7 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgVelECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -636,14 +629,14 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelECEFDepA(msg) => { + sbp::messages::Sbp::MsgVelEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x204, "Incorrect message type, expected 0x204, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -683,7 +676,7 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgVelECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -700,14 +693,14 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelECEFDepA(msg) => { + sbp::messages::Sbp::MsgVelEcefDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x204, "Incorrect message type, expected 0x204, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -751,7 +744,7 @@ fn test_auto_check_sbp_navigation_MsgVelECEFDepA() { } _ => panic!("Invalid message type! Expected a MsgVelECEFDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelEcefGnss.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ecef_gnss.rs similarity index 85% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgVelEcefGnss.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ecef_gnss.rs index a0bae173af..a540769560 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelEcefGnss.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ecef_gnss.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelEcefGnss.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgVelEcefGnss() { +fn test_auto_check_sbp_navigation_msg_vel_ecef_gnss() { { let mut payload = Cursor::new(vec![ 85, 45, 2, 0, 16, 20, 224, 229, 233, 29, 253, 255, 255, 255, 1, 0, 0, 0, 4, 0, 0, 0, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_navigation_MsgVelEcefGnss() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelECEFGnss(msg) => { + sbp::messages::Sbp::MsgVelEcefGnss(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x22d, "Incorrect message type, expected 0x22d, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x1000, "incorrect sender id, expected 0x1000, is {}", @@ -79,7 +72,7 @@ fn test_auto_check_sbp_navigation_MsgVelEcefGnss() { } _ => panic!("Invalid message type! Expected a MsgVelECEFGnss"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelNED.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ned.rs similarity index 89% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgVelNED.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ned.rs index 11d30b41a3..ac6f6e4af1 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelNED.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ned.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelNED.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgVelNED() { +fn test_auto_check_sbp_navigation_msg_vel_ned() { { let mut payload = Cursor::new(vec![ 85, 14, 2, 211, 136, 22, 40, 244, 122, 19, 3, 0, 0, 0, 252, 255, 255, 255, 243, 255, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_navigation_MsgVelNED() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelNED(msg) => { + sbp::messages::Sbp::MsgVelNed(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20e, "Incorrect message type, expected 0x20e, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -88,7 +81,7 @@ fn test_auto_check_sbp_navigation_MsgVelNED() { } _ => panic!("Invalid message type! Expected a MsgVelNED"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -105,14 +98,14 @@ fn test_auto_check_sbp_navigation_MsgVelNED() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelNED(msg) => { + sbp::messages::Sbp::MsgVelNed(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20e, "Incorrect message type, expected 0x20e, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -161,7 +154,7 @@ fn test_auto_check_sbp_navigation_MsgVelNED() { } _ => panic!("Invalid message type! Expected a MsgVelNED"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -178,14 +171,14 @@ fn test_auto_check_sbp_navigation_MsgVelNED() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelNED(msg) => { + sbp::messages::Sbp::MsgVelNed(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20e, "Incorrect message type, expected 0x20e, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -230,7 +223,7 @@ fn test_auto_check_sbp_navigation_MsgVelNED() { } _ => panic!("Invalid message type! Expected a MsgVelNED"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -247,14 +240,14 @@ fn test_auto_check_sbp_navigation_MsgVelNED() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelNED(msg) => { + sbp::messages::Sbp::MsgVelNed(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20e, "Incorrect message type, expected 0x20e, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -295,7 +288,7 @@ fn test_auto_check_sbp_navigation_MsgVelNED() { } _ => panic!("Invalid message type! Expected a MsgVelNED"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -312,14 +305,14 @@ fn test_auto_check_sbp_navigation_MsgVelNED() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelNED(msg) => { + sbp::messages::Sbp::MsgVelNed(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x20e, "Incorrect message type, expected 0x20e, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x88d3, "incorrect sender id, expected 0x88d3, is {}", @@ -360,7 +353,7 @@ fn test_auto_check_sbp_navigation_MsgVelNED() { } _ => panic!("Invalid message type! Expected a MsgVelNED"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelNedCovGnss.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ned_cov_gnss.rs similarity index 90% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgVelNedCovGnss.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ned_cov_gnss.rs index 9546366be3..9282667ff7 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelNedCovGnss.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ned_cov_gnss.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelNedCovGnss.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgVelNedCovGnss() { +fn test_auto_check_sbp_navigation_msg_vel_ned_cov_gnss() { { let mut payload = Cursor::new(vec![ 85, 50, 2, 0, 16, 42, 168, 230, 233, 29, 251, 255, 255, 255, 0, 0, 0, 0, 246, 255, 255, @@ -37,14 +30,14 @@ fn test_auto_check_sbp_navigation_MsgVelNedCovGnss() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelNEDCovGnss(msg) => { + sbp::messages::Sbp::MsgVelNedCovGnss(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x232, "Incorrect message type, expected 0x232, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x1000, "incorrect sender id, expected 0x1000, is {}", @@ -109,7 +102,7 @@ fn test_auto_check_sbp_navigation_MsgVelNedCovGnss() { } _ => panic!("Invalid message type! Expected a MsgVelNEDCovGnss"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelNEDDepA.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ned_dep_a.rs similarity index 89% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgVelNEDDepA.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ned_dep_a.rs index ec546f7e20..013d4024aa 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelNEDDepA.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ned_dep_a.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelNEDDepA.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { +fn test_auto_check_sbp_navigation_msg_vel_ned_dep_a() { { let mut payload = Cursor::new(vec![ 85, 5, 2, 246, 215, 22, 20, 46, 39, 0, 198, 251, 255, 255, 156, 15, 0, 0, 0, 0, 0, 0, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelNEDDepA(msg) => { + sbp::messages::Sbp::MsgVelNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x205, "Incorrect message type, expected 0x205, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -88,7 +81,7 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgVelNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -105,14 +98,14 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelNEDDepA(msg) => { + sbp::messages::Sbp::MsgVelNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x205, "Incorrect message type, expected 0x205, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -157,7 +150,7 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgVelNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -174,14 +167,14 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelNEDDepA(msg) => { + sbp::messages::Sbp::MsgVelNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x205, "Incorrect message type, expected 0x205, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -226,7 +219,7 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgVelNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -243,14 +236,14 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelNEDDepA(msg) => { + sbp::messages::Sbp::MsgVelNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x205, "Incorrect message type, expected 0x205, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -295,7 +288,7 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgVelNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -312,14 +305,14 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelNEDDepA(msg) => { + sbp::messages::Sbp::MsgVelNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x205, "Incorrect message type, expected 0x205, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -364,7 +357,7 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgVelNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -381,14 +374,14 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelNEDDepA(msg) => { + sbp::messages::Sbp::MsgVelNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x205, "Incorrect message type, expected 0x205, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -437,7 +430,7 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgVelNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -454,14 +447,14 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelNEDDepA(msg) => { + sbp::messages::Sbp::MsgVelNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x205, "Incorrect message type, expected 0x205, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -506,7 +499,7 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgVelNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -523,14 +516,14 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelNEDDepA(msg) => { + sbp::messages::Sbp::MsgVelNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x205, "Incorrect message type, expected 0x205, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -579,7 +572,7 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgVelNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -596,14 +589,14 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelNEDDepA(msg) => { + sbp::messages::Sbp::MsgVelNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x205, "Incorrect message type, expected 0x205, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -648,7 +641,7 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgVelNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -665,14 +658,14 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelNEDDepA(msg) => { + sbp::messages::Sbp::MsgVelNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x205, "Incorrect message type, expected 0x205, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -717,7 +710,7 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgVelNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -734,14 +727,14 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelNEDDepA(msg) => { + sbp::messages::Sbp::MsgVelNedDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x205, "Incorrect message type, expected 0x205, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -790,7 +783,7 @@ fn test_auto_check_sbp_navigation_MsgVelNEDDepA() { } _ => panic!("Invalid message type! Expected a MsgVelNEDDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelNedGnss.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ned_gnss.rs similarity index 87% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgVelNedGnss.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ned_gnss.rs index defc32bde0..04809cb6bd 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelNedGnss.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_ned_gnss.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelNedGnss.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgVelNedGnss() { +fn test_auto_check_sbp_navigation_msg_vel_ned_gnss() { { let mut payload = Cursor::new(vec![ 85, 46, 2, 0, 16, 22, 168, 230, 233, 29, 251, 255, 255, 255, 0, 0, 0, 0, 246, 255, 255, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_navigation_MsgVelNedGnss() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelNEDGnss(msg) => { + sbp::messages::Sbp::MsgVelNedGnss(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x22e, "Incorrect message type, expected 0x22e, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x1000, "incorrect sender id, expected 0x1000, is {}", @@ -88,7 +81,7 @@ fn test_auto_check_sbp_navigation_MsgVelNedGnss() { } _ => panic!("Invalid message type! Expected a MsgVelNEDGnss"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelNEDCOV.rs b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_nedcov.rs similarity index 89% rename from rust/sbp/tests/auto_check_sbp_navigation_MsgVelNEDCOV.rs rename to rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_nedcov.rs index ccdbd92e1d..715f1b2537 100644 --- a/rust/sbp/tests/auto_check_sbp_navigation_MsgVelNEDCOV.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_navigation_msg_vel_nedcov.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/navigation/test_MsgVelNEDCOV.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_navigation_MsgVelNEDCOV() { +fn test_auto_check_sbp_navigation_msg_vel_nedcov() { { let mut payload = Cursor::new(vec![ 85, 18, 2, 66, 0, 42, 100, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 128, 63, @@ -37,14 +30,14 @@ fn test_auto_check_sbp_navigation_MsgVelNEDCOV() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgVelNEDCov(msg) => { + sbp::messages::Sbp::MsgVelNedCov(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x212, "Incorrect message type, expected 0x212, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x42, "incorrect sender id, expected 0x42, is {}", @@ -101,7 +94,7 @@ fn test_auto_check_sbp_navigation_MsgVelNEDCOV() { } _ => panic!("Invalid message type! Expected a MsgVelNEDCov"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_observation_MsgBasePosEcef.rs b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_base_pos_ecef.rs similarity index 83% rename from rust/sbp/tests/auto_check_sbp_observation_MsgBasePosEcef.rs rename to rust/sbp/tests/integration/auto_check_sbp_observation_msg_base_pos_ecef.rs index 84adf7597d..bfb7b3aade 100644 --- a/rust/sbp/tests/auto_check_sbp_observation_MsgBasePosEcef.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_base_pos_ecef.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/observation/test_MsgBasePosEcef.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_observation_MsgBasePosEcef() { +fn test_auto_check_sbp_observation_msg_base_pos_ecef() { { let mut payload = Cursor::new(vec![ 85, 72, 0, 0, 0, 24, 228, 131, 158, 245, 87, 205, 68, 193, 66, 62, 232, 209, 32, 118, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_observation_MsgBasePosEcef() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgBasePosECEF(msg) => { + sbp::messages::Sbp::MsgBasePosEcef(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x48, "Incorrect message type, expected 0x48, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0, "incorrect sender id, expected 0, is {}", @@ -67,7 +60,7 @@ fn test_auto_check_sbp_observation_MsgBasePosEcef() { } _ => panic!("Invalid message type! Expected a MsgBasePosECEF"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_observation_MsgEphemerisBds.rs b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_ephemeris_bds.rs similarity index 95% rename from rust/sbp/tests/auto_check_sbp_observation_MsgEphemerisBds.rs rename to rust/sbp/tests/integration/auto_check_sbp_observation_msg_ephemeris_bds.rs index 7288853051..8e77819c86 100644 --- a/rust/sbp/tests/auto_check_sbp_observation_MsgEphemerisBds.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_ephemeris_bds.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/observation/test_MsgEphemerisBds.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_observation_MsgEphemerisBds() { +fn test_auto_check_sbp_observation_msg_ephemeris_bds() { { let mut payload = Cursor::new(vec![ 85, 137, 0, 128, 240, 147, 8, 12, 174, 179, 6, 0, 106, 8, 0, 0, 0, 64, 48, 42, 0, 0, 1, @@ -42,14 +35,14 @@ fn test_auto_check_sbp_observation_MsgEphemerisBds() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgEphemerisBds(msg) => { + sbp::messages::Sbp::MsgEphemerisBds(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x89, "Incorrect message type, expected 0x89, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xf080, "incorrect sender id, expected 0xf080, is {}", @@ -218,7 +211,7 @@ fn test_auto_check_sbp_observation_MsgEphemerisBds() { } _ => panic!("Invalid message type! Expected a MsgEphemerisBds"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_observation_msgEphemerisDepB.rs b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_ephemeris_dep_b.rs similarity index 96% rename from rust/sbp/tests/auto_check_sbp_observation_msgEphemerisDepB.rs rename to rust/sbp/tests/integration/auto_check_sbp_observation_msg_ephemeris_dep_b.rs index 9f121f000c..7636871efa 100644 --- a/rust/sbp/tests/auto_check_sbp_observation_msgEphemerisDepB.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_ephemeris_dep_b.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/observation/test_msgEphemerisDepB.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_observation_msgEphemerisDepB() { +fn test_auto_check_sbp_observation_msg_ephemeris_dep_b() { { let mut payload = Cursor::new(vec![ 85, 70, 0, 195, 4, 176, 0, 0, 0, 0, 0, 0, 60, 190, 0, 0, 0, 0, 0, 186, 82, 192, 0, 0, @@ -43,14 +36,14 @@ fn test_auto_check_sbp_observation_msgEphemerisDepB() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgEphemerisDepB(msg) => { + sbp::messages::Sbp::MsgEphemerisDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x46, "Incorrect message type, expected 0x46, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -194,7 +187,7 @@ fn test_auto_check_sbp_observation_msgEphemerisDepB() { } _ => panic!("Invalid message type! Expected a MsgEphemerisDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -218,14 +211,14 @@ fn test_auto_check_sbp_observation_msgEphemerisDepB() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgEphemerisDepB(msg) => { + sbp::messages::Sbp::MsgEphemerisDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x46, "Incorrect message type, expected 0x46, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -369,7 +362,7 @@ fn test_auto_check_sbp_observation_msgEphemerisDepB() { } _ => panic!("Invalid message type! Expected a MsgEphemerisDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -393,14 +386,14 @@ fn test_auto_check_sbp_observation_msgEphemerisDepB() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgEphemerisDepB(msg) => { + sbp::messages::Sbp::MsgEphemerisDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x46, "Incorrect message type, expected 0x46, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -544,7 +537,7 @@ fn test_auto_check_sbp_observation_msgEphemerisDepB() { } _ => panic!("Invalid message type! Expected a MsgEphemerisDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -568,14 +561,14 @@ fn test_auto_check_sbp_observation_msgEphemerisDepB() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgEphemerisDepB(msg) => { + sbp::messages::Sbp::MsgEphemerisDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x46, "Incorrect message type, expected 0x46, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -719,7 +712,7 @@ fn test_auto_check_sbp_observation_msgEphemerisDepB() { } _ => panic!("Invalid message type! Expected a MsgEphemerisDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -743,14 +736,14 @@ fn test_auto_check_sbp_observation_msgEphemerisDepB() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgEphemerisDepB(msg) => { + sbp::messages::Sbp::MsgEphemerisDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x46, "Incorrect message type, expected 0x46, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -894,7 +887,7 @@ fn test_auto_check_sbp_observation_msgEphemerisDepB() { } _ => panic!("Invalid message type! Expected a MsgEphemerisDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -918,14 +911,14 @@ fn test_auto_check_sbp_observation_msgEphemerisDepB() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgEphemerisDepB(msg) => { + sbp::messages::Sbp::MsgEphemerisDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x46, "Incorrect message type, expected 0x46, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -1069,7 +1062,7 @@ fn test_auto_check_sbp_observation_msgEphemerisDepB() { } _ => panic!("Invalid message type! Expected a MsgEphemerisDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_observation_MsgEphemerisGal.rs b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_ephemeris_gal.rs similarity index 95% rename from rust/sbp/tests/auto_check_sbp_observation_MsgEphemerisGal.rs rename to rust/sbp/tests/integration/auto_check_sbp_observation_msg_ephemeris_gal.rs index 53f7320a99..72c412d645 100644 --- a/rust/sbp/tests/auto_check_sbp_observation_MsgEphemerisGal.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_ephemeris_gal.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/observation/test_MsgEphemerisGal.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_observation_MsgEphemerisGal() { +fn test_auto_check_sbp_observation_msg_ephemeris_gal() { { let mut payload = Cursor::new(vec![ 85, 141, 0, 128, 240, 153, 27, 14, 32, 217, 6, 0, 106, 8, 20, 174, 71, 64, 64, 56, 0, @@ -42,14 +35,14 @@ fn test_auto_check_sbp_observation_MsgEphemerisGal() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgEphemerisGal(msg) => { + sbp::messages::Sbp::MsgEphemerisGal(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x8d, "Incorrect message type, expected 0x8d, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xf080, "incorrect sender id, expected 0xf080, is {}", @@ -223,7 +216,7 @@ fn test_auto_check_sbp_observation_MsgEphemerisGal() { } _ => panic!("Invalid message type! Expected a MsgEphemerisGal"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_observation_MsgEphemerisGLO.rs b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_ephemeris_glo.rs similarity index 93% rename from rust/sbp/tests/auto_check_sbp_observation_MsgEphemerisGLO.rs rename to rust/sbp/tests/integration/auto_check_sbp_observation_msg_ephemeris_glo.rs index 9e34495529..fb19b53944 100644 --- a/rust/sbp/tests/auto_check_sbp_observation_MsgEphemerisGLO.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_ephemeris_glo.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/observation/test_MsgEphemerisGLO.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_observation_MsgEphemerisGLO() { +fn test_auto_check_sbp_observation_msg_ephemeris_glo() { { let mut payload = Cursor::new(vec![ 85, 139, 0, 10, 9, 92, 4, 3, 70, 197, 6, 0, 106, 8, 0, 0, 160, 64, 96, 9, 0, 0, 1, 0, @@ -39,14 +32,14 @@ fn test_auto_check_sbp_observation_MsgEphemerisGLO() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgEphemerisGlo(msg) => { + sbp::messages::Sbp::MsgEphemerisGlo(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x8b, "Incorrect message type, expected 0x8b, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x90a, "incorrect sender id, expected 0x90a, is {}", @@ -165,7 +158,7 @@ fn test_auto_check_sbp_observation_MsgEphemerisGLO() { } _ => panic!("Invalid message type! Expected a MsgEphemerisGlo"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_observation_MsgEphemerisGPS.rs b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_ephemeris_gps.rs similarity index 95% rename from rust/sbp/tests/auto_check_sbp_observation_MsgEphemerisGPS.rs rename to rust/sbp/tests/integration/auto_check_sbp_observation_msg_ephemeris_gps.rs index 5269af4ac3..532dba67f0 100644 --- a/rust/sbp/tests/auto_check_sbp_observation_MsgEphemerisGPS.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_ephemeris_gps.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/observation/test_MsgEphemerisGPS.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_observation_MsgEphemerisGPS() { +fn test_auto_check_sbp_observation_msg_ephemeris_gps() { { let mut payload = Cursor::new(vec![ 85, 138, 0, 10, 9, 139, 22, 0, 176, 207, 6, 0, 106, 8, 0, 0, 0, 64, 64, 56, 0, 0, 1, 0, @@ -42,14 +35,14 @@ fn test_auto_check_sbp_observation_MsgEphemerisGPS() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgEphemerisGPS(msg) => { + sbp::messages::Sbp::MsgEphemerisGps(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x8a, "Incorrect message type, expected 0x8a, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x90a, "incorrect sender id, expected 0x90a, is {}", @@ -213,7 +206,7 @@ fn test_auto_check_sbp_observation_MsgEphemerisGPS() { } _ => panic!("Invalid message type! Expected a MsgEphemerisGPS"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_observation_msgEphemerisQzss.rs b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_ephemeris_qzss.rs similarity index 95% rename from rust/sbp/tests/auto_check_sbp_observation_msgEphemerisQzss.rs rename to rust/sbp/tests/integration/auto_check_sbp_observation_msg_ephemeris_qzss.rs index 2220406c0e..5d7e67cd08 100644 --- a/rust/sbp/tests/auto_check_sbp_observation_msgEphemerisQzss.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_ephemeris_qzss.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/observation/test_msgEphemerisQzss.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_observation_msgEphemerisQzss() { +fn test_auto_check_sbp_observation_msg_ephemeris_qzss() { { let mut payload = Cursor::new(vec![ 85, 142, 0, 128, 240, 139, 193, 31, 208, 221, 6, 0, 106, 8, 0, 0, 0, 64, 64, 56, 0, 0, @@ -42,14 +35,14 @@ fn test_auto_check_sbp_observation_msgEphemerisQzss() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgEphemerisQzss(msg) => { + sbp::messages::Sbp::MsgEphemerisQzss(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x8e, "Incorrect message type, expected 0x8e, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xf080, "incorrect sender id, expected 0xf080, is {}", @@ -213,7 +206,7 @@ fn test_auto_check_sbp_observation_msgEphemerisQzss() { } _ => panic!("Invalid message type! Expected a MsgEphemerisQzss"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_observation_MsgGloBiases.rs b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_glo_biases.rs similarity index 84% rename from rust/sbp/tests/auto_check_sbp_observation_MsgGloBiases.rs rename to rust/sbp/tests/integration/auto_check_sbp_observation_msg_glo_biases.rs index a22fae82e8..46f6a62e5e 100644 --- a/rust/sbp/tests/auto_check_sbp_observation_MsgGloBiases.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_glo_biases.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/observation/test_MsgGloBiases.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_observation_MsgGloBiases() { +fn test_auto_check_sbp_observation_msg_glo_biases() { { let mut payload = Cursor::new(vec![ 85, 117, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 211, @@ -35,14 +28,14 @@ fn test_auto_check_sbp_observation_MsgGloBiases() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGloBiases(msg) => { + sbp::messages::Sbp::MsgGloBiases(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x75, "Incorrect message type, expected 0x75, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0, "incorrect sender id, expected 0, is {}", @@ -76,7 +69,7 @@ fn test_auto_check_sbp_observation_MsgGloBiases() { } _ => panic!("Invalid message type! Expected a MsgGloBiases"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_observation_MsgObs.rs b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_obs.rs similarity index 69% rename from rust/sbp/tests/auto_check_sbp_observation_MsgObs.rs rename to rust/sbp/tests/integration/auto_check_sbp_observation_msg_obs.rs index 8cff9c7004..726b40402b 100644 --- a/rust/sbp/tests/auto_check_sbp_observation_MsgObs.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_obs.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/observation/test_MsgObs.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_observation_MsgObs() { +fn test_auto_check_sbp_observation_msg_obs() { { let mut payload = Cursor::new(vec![ 85, 74, 0, 129, 240, 249, 152, 202, 226, 25, 0, 0, 0, 0, 106, 8, 32, 49, 227, 254, 62, @@ -47,14 +40,14 @@ fn test_auto_check_sbp_observation_MsgObs() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgObs(msg) => { + sbp::messages::Sbp::MsgObs(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x4a, "Incorrect message type, expected 0x4a, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xf081, "incorrect sender id, expected 0xf081, is {}", @@ -81,29 +74,29 @@ fn test_auto_check_sbp_observation_MsgObs() { msg.header.t.wn ); assert_eq!( - msg.obs[0].D.f, 172, - "incorrect value for obs[0].D.f, expected 172, is {}", - msg.obs[0].D.f + msg.obs[0].d.f, 172, + "incorrect value for obs[0].d.f, expected 172, is {}", + msg.obs[0].d.f ); assert_eq!( - msg.obs[0].D.i, -1536, - "incorrect value for obs[0].D.i, expected -1536, is {}", - msg.obs[0].D.i + msg.obs[0].d.i, -1536, + "incorrect value for obs[0].d.i, expected -1536, is {}", + msg.obs[0].d.i ); assert_eq!( - msg.obs[0].L.f, 146, - "incorrect value for obs[0].L.f, expected 146, is {}", - msg.obs[0].L.f + msg.obs[0].l.f, 146, + "incorrect value for obs[0].l.f, expected 146, is {}", + msg.obs[0].l.f ); assert_eq!( - msg.obs[0].L.i, 111080057, - "incorrect value for obs[0].L.i, expected 111080057, is {}", - msg.obs[0].L.i + msg.obs[0].l.i, 111080057, + "incorrect value for obs[0].l.i, expected 111080057, is {}", + msg.obs[0].l.i ); assert_eq!( - msg.obs[0].P, 1056891697, - "incorrect value for obs[0].P, expected 1056891697, is {}", - msg.obs[0].P + msg.obs[0].p, 1056891697, + "incorrect value for obs[0].p, expected 1056891697, is {}", + msg.obs[0].p ); assert_eq!( msg.obs[0].cn0, 182, @@ -131,29 +124,29 @@ fn test_auto_check_sbp_observation_MsgObs() { msg.obs[0].sid.sat ); assert_eq!( - msg.obs[1].D.f, 172, - "incorrect value for obs[1].D.f, expected 172, is {}", - msg.obs[1].D.f + msg.obs[1].d.f, 172, + "incorrect value for obs[1].d.f, expected 172, is {}", + msg.obs[1].d.f ); assert_eq!( - msg.obs[1].D.i, -1197, - "incorrect value for obs[1].D.i, expected -1197, is {}", - msg.obs[1].D.i + msg.obs[1].d.i, -1197, + "incorrect value for obs[1].d.i, expected -1197, is {}", + msg.obs[1].d.i ); assert_eq!( - msg.obs[1].L.f, 59, - "incorrect value for obs[1].L.f, expected 59, is {}", - msg.obs[1].L.f + msg.obs[1].l.f, 59, + "incorrect value for obs[1].l.f, expected 59, is {}", + msg.obs[1].l.f ); assert_eq!( - msg.obs[1].L.i, 86555916, - "incorrect value for obs[1].L.i, expected 86555916, is {}", - msg.obs[1].L.i + msg.obs[1].l.i, 86555916, + "incorrect value for obs[1].l.i, expected 86555916, is {}", + msg.obs[1].l.i ); assert_eq!( - msg.obs[1].P, 1056891934, - "incorrect value for obs[1].P, expected 1056891934, is {}", - msg.obs[1].P + msg.obs[1].p, 1056891934, + "incorrect value for obs[1].p, expected 1056891934, is {}", + msg.obs[1].p ); assert_eq!( msg.obs[1].cn0, 178, @@ -181,29 +174,29 @@ fn test_auto_check_sbp_observation_MsgObs() { msg.obs[1].sid.sat ); assert_eq!( - msg.obs[2].D.f, 119, - "incorrect value for obs[2].D.f, expected 119, is {}", - msg.obs[2].D.f + msg.obs[2].d.f, 119, + "incorrect value for obs[2].d.f, expected 119, is {}", + msg.obs[2].d.f ); assert_eq!( - msg.obs[2].D.i, -3219, - "incorrect value for obs[2].D.i, expected -3219, is {}", - msg.obs[2].D.i + msg.obs[2].d.i, -3219, + "incorrect value for obs[2].d.i, expected -3219, is {}", + msg.obs[2].d.i ); assert_eq!( - msg.obs[2].L.f, 243, - "incorrect value for obs[2].L.f, expected 243, is {}", - msg.obs[2].L.f + msg.obs[2].l.f, 243, + "incorrect value for obs[2].l.f, expected 243, is {}", + msg.obs[2].l.f ); assert_eq!( - msg.obs[2].L.i, 127954794, - "incorrect value for obs[2].L.i, expected 127954794, is {}", - msg.obs[2].L.i + msg.obs[2].l.i, 127954794, + "incorrect value for obs[2].l.i, expected 127954794, is {}", + msg.obs[2].l.i ); assert_eq!( - msg.obs[2].P, 1217449431, - "incorrect value for obs[2].P, expected 1217449431, is {}", - msg.obs[2].P + msg.obs[2].p, 1217449431, + "incorrect value for obs[2].p, expected 1217449431, is {}", + msg.obs[2].p ); assert_eq!( msg.obs[2].cn0, 158, @@ -231,29 +224,29 @@ fn test_auto_check_sbp_observation_MsgObs() { msg.obs[2].sid.sat ); assert_eq!( - msg.obs[3].D.f, 27, - "incorrect value for obs[3].D.f, expected 27, is {}", - msg.obs[3].D.f + msg.obs[3].d.f, 27, + "incorrect value for obs[3].d.f, expected 27, is {}", + msg.obs[3].d.f ); assert_eq!( - msg.obs[3].D.i, -2508, - "incorrect value for obs[3].D.i, expected -2508, is {}", - msg.obs[3].D.i + msg.obs[3].d.i, -2508, + "incorrect value for obs[3].d.i, expected -2508, is {}", + msg.obs[3].d.i ); assert_eq!( - msg.obs[3].L.f, 12, - "incorrect value for obs[3].L.f, expected 12, is {}", - msg.obs[3].L.f + msg.obs[3].l.f, 12, + "incorrect value for obs[3].l.f, expected 12, is {}", + msg.obs[3].l.f ); assert_eq!( - msg.obs[3].L.i, 99705055, - "incorrect value for obs[3].L.i, expected 99705055, is {}", - msg.obs[3].L.i + msg.obs[3].l.i, 99705055, + "incorrect value for obs[3].l.i, expected 99705055, is {}", + msg.obs[3].l.i ); assert_eq!( - msg.obs[3].P, 1217449753, - "incorrect value for obs[3].P, expected 1217449753, is {}", - msg.obs[3].P + msg.obs[3].p, 1217449753, + "incorrect value for obs[3].p, expected 1217449753, is {}", + msg.obs[3].p ); assert_eq!( msg.obs[3].cn0, 125, @@ -281,29 +274,29 @@ fn test_auto_check_sbp_observation_MsgObs() { msg.obs[3].sid.sat ); assert_eq!( - msg.obs[4].D.f, 245, - "incorrect value for obs[4].D.f, expected 245, is {}", - msg.obs[4].D.f + msg.obs[4].d.f, 245, + "incorrect value for obs[4].d.f, expected 245, is {}", + msg.obs[4].d.f ); assert_eq!( - msg.obs[4].D.i, 2829, - "incorrect value for obs[4].D.i, expected 2829, is {}", - msg.obs[4].D.i + msg.obs[4].d.i, 2829, + "incorrect value for obs[4].d.i, expected 2829, is {}", + msg.obs[4].d.i ); assert_eq!( - msg.obs[4].L.f, 53, - "incorrect value for obs[4].L.f, expected 53, is {}", - msg.obs[4].L.f + msg.obs[4].l.f, 53, + "incorrect value for obs[4].l.f, expected 53, is {}", + msg.obs[4].l.f ); assert_eq!( - msg.obs[4].L.i, 132024982, - "incorrect value for obs[4].L.i, expected 132024982, is {}", - msg.obs[4].L.i + msg.obs[4].l.i, 132024982, + "incorrect value for obs[4].l.i, expected 132024982, is {}", + msg.obs[4].l.i ); assert_eq!( - msg.obs[4].P, 1256175650, - "incorrect value for obs[4].P, expected 1256175650, is {}", - msg.obs[4].P + msg.obs[4].p, 1256175650, + "incorrect value for obs[4].p, expected 1256175650, is {}", + msg.obs[4].p ); assert_eq!( msg.obs[4].cn0, 114, @@ -331,29 +324,29 @@ fn test_auto_check_sbp_observation_MsgObs() { msg.obs[4].sid.sat ); assert_eq!( - msg.obs[5].D.f, 246, - "incorrect value for obs[5].D.f, expected 246, is {}", - msg.obs[5].D.f + msg.obs[5].d.f, 246, + "incorrect value for obs[5].d.f, expected 246, is {}", + msg.obs[5].d.f ); assert_eq!( - msg.obs[5].D.i, -2433, - "incorrect value for obs[5].D.i, expected -2433, is {}", - msg.obs[5].D.i + msg.obs[5].d.i, -2433, + "incorrect value for obs[5].d.i, expected -2433, is {}", + msg.obs[5].d.i ); assert_eq!( - msg.obs[5].L.f, 70, - "incorrect value for obs[5].L.f, expected 70, is {}", - msg.obs[5].L.f + msg.obs[5].l.f, 70, + "incorrect value for obs[5].l.f, expected 70, is {}", + msg.obs[5].l.f ); assert_eq!( - msg.obs[5].L.i, 121711010, - "incorrect value for obs[5].L.i, expected 121711010, is {}", - msg.obs[5].L.i + msg.obs[5].l.i, 121711010, + "incorrect value for obs[5].l.i, expected 121711010, is {}", + msg.obs[5].l.i ); assert_eq!( - msg.obs[5].P, 1158041713, - "incorrect value for obs[5].P, expected 1158041713, is {}", - msg.obs[5].P + msg.obs[5].p, 1158041713, + "incorrect value for obs[5].p, expected 1158041713, is {}", + msg.obs[5].p ); assert_eq!( msg.obs[5].cn0, 189, @@ -381,29 +374,29 @@ fn test_auto_check_sbp_observation_MsgObs() { msg.obs[5].sid.sat ); assert_eq!( - msg.obs[6].D.f, 231, - "incorrect value for obs[6].D.f, expected 231, is {}", - msg.obs[6].D.f + msg.obs[6].d.f, 231, + "incorrect value for obs[6].d.f, expected 231, is {}", + msg.obs[6].d.f ); assert_eq!( - msg.obs[6].D.i, -1896, - "incorrect value for obs[6].D.i, expected -1896, is {}", - msg.obs[6].D.i + msg.obs[6].d.i, -1896, + "incorrect value for obs[6].d.i, expected -1896, is {}", + msg.obs[6].d.i ); assert_eq!( - msg.obs[6].L.f, 221, - "incorrect value for obs[6].L.f, expected 221, is {}", - msg.obs[6].L.f + msg.obs[6].l.f, 221, + "incorrect value for obs[6].l.f, expected 221, is {}", + msg.obs[6].l.f ); assert_eq!( - msg.obs[6].L.i, 94839765, - "incorrect value for obs[6].L.i, expected 94839765, is {}", - msg.obs[6].L.i + msg.obs[6].l.i, 94839765, + "incorrect value for obs[6].l.i, expected 94839765, is {}", + msg.obs[6].l.i ); assert_eq!( - msg.obs[6].P, 1158041847, - "incorrect value for obs[6].P, expected 1158041847, is {}", - msg.obs[6].P + msg.obs[6].p, 1158041847, + "incorrect value for obs[6].p, expected 1158041847, is {}", + msg.obs[6].p ); assert_eq!( msg.obs[6].cn0, 158, @@ -431,29 +424,29 @@ fn test_auto_check_sbp_observation_MsgObs() { msg.obs[6].sid.sat ); assert_eq!( - msg.obs[7].D.f, 67, - "incorrect value for obs[7].D.f, expected 67, is {}", - msg.obs[7].D.f + msg.obs[7].d.f, 67, + "incorrect value for obs[7].d.f, expected 67, is {}", + msg.obs[7].d.f ); assert_eq!( - msg.obs[7].D.i, -1997, - "incorrect value for obs[7].D.i, expected -1997, is {}", - msg.obs[7].D.i + msg.obs[7].d.i, -1997, + "incorrect value for obs[7].d.i, expected -1997, is {}", + msg.obs[7].d.i ); assert_eq!( - msg.obs[7].L.f, 114, - "incorrect value for obs[7].L.f, expected 114, is {}", - msg.obs[7].L.f + msg.obs[7].l.f, 114, + "incorrect value for obs[7].l.f, expected 114, is {}", + msg.obs[7].l.f ); assert_eq!( - msg.obs[7].L.i, 113998348, - "incorrect value for obs[7].L.i, expected 113998348, is {}", - msg.obs[7].L.i + msg.obs[7].l.i, 113998348, + "incorrect value for obs[7].l.i, expected 113998348, is {}", + msg.obs[7].l.i ); assert_eq!( - msg.obs[7].P, 1084658184, - "incorrect value for obs[7].P, expected 1084658184, is {}", - msg.obs[7].P + msg.obs[7].p, 1084658184, + "incorrect value for obs[7].p, expected 1084658184, is {}", + msg.obs[7].p ); assert_eq!( msg.obs[7].cn0, 93, @@ -481,29 +474,29 @@ fn test_auto_check_sbp_observation_MsgObs() { msg.obs[7].sid.sat ); assert_eq!( - msg.obs[8].D.f, 237, - "incorrect value for obs[8].D.f, expected 237, is {}", - msg.obs[8].D.f + msg.obs[8].d.f, 237, + "incorrect value for obs[8].d.f, expected 237, is {}", + msg.obs[8].d.f ); assert_eq!( - msg.obs[8].D.i, 3041, - "incorrect value for obs[8].D.i, expected 3041, is {}", - msg.obs[8].D.i + msg.obs[8].d.i, 3041, + "incorrect value for obs[8].d.i, expected 3041, is {}", + msg.obs[8].d.i ); assert_eq!( - msg.obs[8].L.f, 232, - "incorrect value for obs[8].L.f, expected 232, is {}", - msg.obs[8].L.f + msg.obs[8].l.f, 232, + "incorrect value for obs[8].l.f, expected 232, is {}", + msg.obs[8].l.f ); assert_eq!( - msg.obs[8].L.i, 133443545, - "incorrect value for obs[8].L.i, expected 133443545, is {}", - msg.obs[8].L.i + msg.obs[8].l.i, 133443545, + "incorrect value for obs[8].l.i, expected 133443545, is {}", + msg.obs[8].l.i ); assert_eq!( - msg.obs[8].P, 1269673181, - "incorrect value for obs[8].P, expected 1269673181, is {}", - msg.obs[8].P + msg.obs[8].p, 1269673181, + "incorrect value for obs[8].p, expected 1269673181, is {}", + msg.obs[8].p ); assert_eq!( msg.obs[8].cn0, 123, @@ -531,29 +524,29 @@ fn test_auto_check_sbp_observation_MsgObs() { msg.obs[8].sid.sat ); assert_eq!( - msg.obs[9].D.f, 62, - "incorrect value for obs[9].D.f, expected 62, is {}", - msg.obs[9].D.f + msg.obs[9].d.f, 62, + "incorrect value for obs[9].d.f, expected 62, is {}", + msg.obs[9].d.f ); assert_eq!( - msg.obs[9].D.i, 2374, - "incorrect value for obs[9].D.i, expected 2374, is {}", - msg.obs[9].D.i + msg.obs[9].d.i, 2374, + "incorrect value for obs[9].d.i, expected 2374, is {}", + msg.obs[9].d.i ); assert_eq!( - msg.obs[9].L.f, 40, - "incorrect value for obs[9].L.f, expected 40, is {}", - msg.obs[9].L.f + msg.obs[9].l.f, 40, + "incorrect value for obs[9].l.f, expected 40, is {}", + msg.obs[9].l.f ); assert_eq!( - msg.obs[9].L.i, 103982040, - "incorrect value for obs[9].L.i, expected 103982040, is {}", - msg.obs[9].L.i + msg.obs[9].l.i, 103982040, + "incorrect value for obs[9].l.i, expected 103982040, is {}", + msg.obs[9].l.i ); assert_eq!( - msg.obs[9].P, 1269673722, - "incorrect value for obs[9].P, expected 1269673722, is {}", - msg.obs[9].P + msg.obs[9].p, 1269673722, + "incorrect value for obs[9].p, expected 1269673722, is {}", + msg.obs[9].p ); assert_eq!( msg.obs[9].cn0, 120, @@ -581,29 +574,29 @@ fn test_auto_check_sbp_observation_MsgObs() { msg.obs[9].sid.sat ); assert_eq!( - msg.obs[10].D.f, 96, - "incorrect value for obs[10].D.f, expected 96, is {}", - msg.obs[10].D.f + msg.obs[10].d.f, 96, + "incorrect value for obs[10].d.f, expected 96, is {}", + msg.obs[10].d.f ); assert_eq!( - msg.obs[10].D.i, -3446, - "incorrect value for obs[10].D.i, expected -3446, is {}", - msg.obs[10].D.i + msg.obs[10].d.i, -3446, + "incorrect value for obs[10].d.i, expected -3446, is {}", + msg.obs[10].d.i ); assert_eq!( - msg.obs[10].L.f, 7, - "incorrect value for obs[10].L.f, expected 7, is {}", - msg.obs[10].L.f + msg.obs[10].l.f, 7, + "incorrect value for obs[10].l.f, expected 7, is {}", + msg.obs[10].l.f ); assert_eq!( - msg.obs[10].L.i, 118217315, - "incorrect value for obs[10].L.i, expected 118217315, is {}", - msg.obs[10].L.i + msg.obs[10].l.i, 118217315, + "incorrect value for obs[10].l.i, expected 118217315, is {}", + msg.obs[10].l.i ); assert_eq!( - msg.obs[10].P, 1107693703, - "incorrect value for obs[10].P, expected 1107693703, is {}", - msg.obs[10].P + msg.obs[10].p, 1107693703, + "incorrect value for obs[10].p, expected 1107693703, is {}", + msg.obs[10].p ); assert_eq!( msg.obs[10].cn0, 176, @@ -631,29 +624,29 @@ fn test_auto_check_sbp_observation_MsgObs() { msg.obs[10].sid.sat ); assert_eq!( - msg.obs[11].D.f, 96, - "incorrect value for obs[11].D.f, expected 96, is {}", - msg.obs[11].D.f + msg.obs[11].d.f, 96, + "incorrect value for obs[11].d.f, expected 96, is {}", + msg.obs[11].d.f ); assert_eq!( - msg.obs[11].D.i, -1003, - "incorrect value for obs[11].D.i, expected -1003, is {}", - msg.obs[11].D.i + msg.obs[11].d.i, -1003, + "incorrect value for obs[11].d.i, expected -1003, is {}", + msg.obs[11].d.i ); assert_eq!( - msg.obs[11].L.f, 203, - "incorrect value for obs[11].L.f, expected 203, is {}", - msg.obs[11].L.f + msg.obs[11].l.f, 203, + "incorrect value for obs[11].l.f, expected 203, is {}", + msg.obs[11].l.f ); assert_eq!( - msg.obs[11].L.i, 104224985, - "incorrect value for obs[11].L.i, expected 104224985, is {}", - msg.obs[11].L.i + msg.obs[11].l.i, 104224985, + "incorrect value for obs[11].l.i, expected 104224985, is {}", + msg.obs[11].l.i ); assert_eq!( - msg.obs[11].P, 973505172, - "incorrect value for obs[11].P, expected 973505172, is {}", - msg.obs[11].P + msg.obs[11].p, 973505172, + "incorrect value for obs[11].p, expected 973505172, is {}", + msg.obs[11].p ); assert_eq!( msg.obs[11].cn0, 170, @@ -681,29 +674,29 @@ fn test_auto_check_sbp_observation_MsgObs() { msg.obs[11].sid.sat ); assert_eq!( - msg.obs[12].D.f, 219, - "incorrect value for obs[12].D.f, expected 219, is {}", - msg.obs[12].D.f + msg.obs[12].d.f, 219, + "incorrect value for obs[12].d.f, expected 219, is {}", + msg.obs[12].d.f ); assert_eq!( - msg.obs[12].D.i, -3836, - "incorrect value for obs[12].D.i, expected -3836, is {}", - msg.obs[12].D.i + msg.obs[12].d.i, -3836, + "incorrect value for obs[12].d.i, expected -3836, is {}", + msg.obs[12].d.i ); assert_eq!( - msg.obs[12].L.f, 80, - "incorrect value for obs[12].L.f, expected 80, is {}", - msg.obs[12].L.f + msg.obs[12].l.f, 80, + "incorrect value for obs[12].l.f, expected 80, is {}", + msg.obs[12].l.f ); assert_eq!( - msg.obs[12].L.i, 114505343, - "incorrect value for obs[12].L.i, expected 114505343, is {}", - msg.obs[12].L.i + msg.obs[12].l.i, 114505343, + "incorrect value for obs[12].l.i, expected 114505343, is {}", + msg.obs[12].l.i ); assert_eq!( - msg.obs[12].P, 1069903034, - "incorrect value for obs[12].P, expected 1069903034, is {}", - msg.obs[12].P + msg.obs[12].p, 1069903034, + "incorrect value for obs[12].p, expected 1069903034, is {}", + msg.obs[12].p ); assert_eq!( msg.obs[12].cn0, 200, @@ -731,29 +724,29 @@ fn test_auto_check_sbp_observation_MsgObs() { msg.obs[12].sid.sat ); assert_eq!( - msg.obs[13].D.f, 182, - "incorrect value for obs[13].D.f, expected 182, is {}", - msg.obs[13].D.f + msg.obs[13].d.f, 182, + "incorrect value for obs[13].d.f, expected 182, is {}", + msg.obs[13].d.f ); assert_eq!( - msg.obs[13].D.i, -461, - "incorrect value for obs[13].D.i, expected -461, is {}", - msg.obs[13].D.i + msg.obs[13].d.i, -461, + "incorrect value for obs[13].d.i, expected -461, is {}", + msg.obs[13].d.i ); assert_eq!( - msg.obs[13].L.f, 105, - "incorrect value for obs[13].L.f, expected 105, is {}", - msg.obs[13].L.f + msg.obs[13].l.f, 105, + "incorrect value for obs[13].l.f, expected 105, is {}", + msg.obs[13].l.f ); assert_eq!( - msg.obs[13].L.i, 102157331, - "incorrect value for obs[13].L.i, expected 102157331, is {}", - msg.obs[13].L.i + msg.obs[13].l.i, 102157331, + "incorrect value for obs[13].l.i, expected 102157331, is {}", + msg.obs[13].l.i ); assert_eq!( - msg.obs[13].P, 956875687, - "incorrect value for obs[13].P, expected 956875687, is {}", - msg.obs[13].P + msg.obs[13].p, 956875687, + "incorrect value for obs[13].p, expected 956875687, is {}", + msg.obs[13].p ); assert_eq!( msg.obs[13].cn0, 152, @@ -783,7 +776,7 @@ fn test_auto_check_sbp_observation_MsgObs() { } _ => panic!("Invalid message type! Expected a MsgObs"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -799,14 +792,14 @@ fn test_auto_check_sbp_observation_MsgObs() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgObs(msg) => { + sbp::messages::Sbp::MsgObs(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x4a, "Incorrect message type, expected 0x4a, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xf081, "incorrect sender id, expected 0xf081, is {}", @@ -835,7 +828,7 @@ fn test_auto_check_sbp_observation_MsgObs() { } _ => panic!("Invalid message type! Expected a MsgObs"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_observation_msgObsDepA.rs b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_obs_dep_a.rs similarity index 71% rename from rust/sbp/tests/auto_check_sbp_observation_msgObsDepA.rs rename to rust/sbp/tests/integration/auto_check_sbp_observation_msg_obs_dep_a.rs index 3f8aafcea2..1acf12a35b 100644 --- a/rust/sbp/tests/auto_check_sbp_observation_msgObsDepA.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_obs_dep_a.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/observation/test_msgObsDepA.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_observation_msgObsDepA() { +fn test_auto_check_sbp_observation_msg_obs_dep_a() { { let mut payload = Cursor::new(vec![ 85, 69, 0, 195, 4, 98, 56, 158, 67, 24, 46, 7, 32, 56, 235, 249, 121, 244, 114, 255, @@ -40,14 +33,14 @@ fn test_auto_check_sbp_observation_msgObsDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgObsDepA(msg) => { + sbp::messages::Sbp::MsgObsDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x45, "Incorrect message type, expected 0x45, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -69,19 +62,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.header.t.wn ); assert_eq!( - msg.obs[0].L.f, 33, - "incorrect value for obs[0].L.f, expected 33, is {}", - msg.obs[0].L.f + msg.obs[0].l.f, 33, + "incorrect value for obs[0].l.f, expected 33, is {}", + msg.obs[0].l.f ); assert_eq!( - msg.obs[0].L.i, -36108, - "incorrect value for obs[0].L.i, expected -36108, is {}", - msg.obs[0].L.i + msg.obs[0].l.i, -36108, + "incorrect value for obs[0].l.i, expected -36108, is {}", + msg.obs[0].l.i ); assert_eq!( - msg.obs[0].P, 2046421816, - "incorrect value for obs[0].P, expected 2046421816, is {}", - msg.obs[0].P + msg.obs[0].p, 2046421816, + "incorrect value for obs[0].p, expected 2046421816, is {}", + msg.obs[0].p ); assert_eq!( msg.obs[0].cn0, 46, @@ -99,19 +92,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[0].prn ); assert_eq!( - msg.obs[1].L.f, 98, - "incorrect value for obs[1].L.f, expected 98, is {}", - msg.obs[1].L.f + msg.obs[1].l.f, 98, + "incorrect value for obs[1].l.f, expected 98, is {}", + msg.obs[1].l.f ); assert_eq!( - msg.obs[1].L.i, 203030, - "incorrect value for obs[1].L.i, expected 203030, is {}", - msg.obs[1].L.i + msg.obs[1].l.i, 203030, + "incorrect value for obs[1].l.i, expected 203030, is {}", + msg.obs[1].l.i ); assert_eq!( - msg.obs[1].P, 2085014510, - "incorrect value for obs[1].P, expected 2085014510, is {}", - msg.obs[1].P + msg.obs[1].p, 2085014510, + "incorrect value for obs[1].p, expected 2085014510, is {}", + msg.obs[1].p ); assert_eq!( msg.obs[1].cn0, 43, @@ -129,19 +122,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[1].prn ); assert_eq!( - msg.obs[2].L.f, 185, - "incorrect value for obs[2].L.f, expected 185, is {}", - msg.obs[2].L.f + msg.obs[2].l.f, 185, + "incorrect value for obs[2].l.f, expected 185, is {}", + msg.obs[2].l.f ); assert_eq!( - msg.obs[2].L.i, -178306, - "incorrect value for obs[2].L.i, expected -178306, is {}", - msg.obs[2].L.i + msg.obs[2].l.i, -178306, + "incorrect value for obs[2].l.i, expected -178306, is {}", + msg.obs[2].l.i ); assert_eq!( - msg.obs[2].P, 2110096816, - "incorrect value for obs[2].P, expected 2110096816, is {}", - msg.obs[2].P + msg.obs[2].p, 2110096816, + "incorrect value for obs[2].p, expected 2110096816, is {}", + msg.obs[2].p ); assert_eq!( msg.obs[2].cn0, 39, @@ -159,19 +152,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[2].prn ); assert_eq!( - msg.obs[3].L.f, 139, - "incorrect value for obs[3].L.f, expected 139, is {}", - msg.obs[3].L.f + msg.obs[3].l.f, 139, + "incorrect value for obs[3].l.f, expected 139, is {}", + msg.obs[3].l.f ); assert_eq!( - msg.obs[3].L.i, -137374, - "incorrect value for obs[3].L.i, expected -137374, is {}", - msg.obs[3].L.i + msg.obs[3].l.i, -137374, + "incorrect value for obs[3].l.i, expected -137374, is {}", + msg.obs[3].l.i ); assert_eq!( - msg.obs[3].P, 2208476476, - "incorrect value for obs[3].P, expected 2208476476, is {}", - msg.obs[3].P + msg.obs[3].p, 2208476476, + "incorrect value for obs[3].p, expected 2208476476, is {}", + msg.obs[3].p ); assert_eq!( msg.obs[3].cn0, 30, @@ -189,19 +182,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[3].prn ); assert_eq!( - msg.obs[4].L.f, 40, - "incorrect value for obs[4].L.f, expected 40, is {}", - msg.obs[4].L.f + msg.obs[4].l.f, 40, + "incorrect value for obs[4].l.f, expected 40, is {}", + msg.obs[4].l.f ); assert_eq!( - msg.obs[4].L.i, -167638, - "incorrect value for obs[4].L.i, expected -167638, is {}", - msg.obs[4].L.i + msg.obs[4].l.i, -167638, + "incorrect value for obs[4].l.i, expected -167638, is {}", + msg.obs[4].l.i ); assert_eq!( - msg.obs[4].P, 2298000000, - "incorrect value for obs[4].P, expected 2298000000, is {}", - msg.obs[4].P + msg.obs[4].p, 2298000000, + "incorrect value for obs[4].p, expected 2298000000, is {}", + msg.obs[4].p ); assert_eq!( msg.obs[4].cn0, 20, @@ -219,19 +212,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[4].prn ); assert_eq!( - msg.obs[5].L.f, 64, - "incorrect value for obs[5].L.f, expected 64, is {}", - msg.obs[5].L.f + msg.obs[5].l.f, 64, + "incorrect value for obs[5].l.f, expected 64, is {}", + msg.obs[5].l.f ); assert_eq!( - msg.obs[5].L.i, 209919, - "incorrect value for obs[5].L.i, expected 209919, is {}", - msg.obs[5].L.i + msg.obs[5].l.i, 209919, + "incorrect value for obs[5].l.i, expected 209919, is {}", + msg.obs[5].l.i ); assert_eq!( - msg.obs[5].P, 2266101494, - "incorrect value for obs[5].P, expected 2266101494, is {}", - msg.obs[5].P + msg.obs[5].p, 2266101494, + "incorrect value for obs[5].p, expected 2266101494, is {}", + msg.obs[5].p ); assert_eq!( msg.obs[5].cn0, 27, @@ -249,19 +242,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[5].prn ); assert_eq!( - msg.obs[6].L.f, 31, - "incorrect value for obs[6].L.f, expected 31, is {}", - msg.obs[6].L.f + msg.obs[6].l.f, 31, + "incorrect value for obs[6].l.f, expected 31, is {}", + msg.obs[6].l.f ); assert_eq!( - msg.obs[6].L.i, -53117, - "incorrect value for obs[6].L.i, expected -53117, is {}", - msg.obs[6].L.i + msg.obs[6].l.i, -53117, + "incorrect value for obs[6].l.i, expected -53117, is {}", + msg.obs[6].l.i ); assert_eq!( - msg.obs[6].P, 1987193298, - "incorrect value for obs[6].P, expected 1987193298, is {}", - msg.obs[6].P + msg.obs[6].p, 1987193298, + "incorrect value for obs[6].p, expected 1987193298, is {}", + msg.obs[6].p ); assert_eq!( msg.obs[6].cn0, 52, @@ -281,7 +274,7 @@ fn test_auto_check_sbp_observation_msgObsDepA() { } _ => panic!("Invalid message type! Expected a MsgObsDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -298,14 +291,14 @@ fn test_auto_check_sbp_observation_msgObsDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgObsDepA(msg) => { + sbp::messages::Sbp::MsgObsDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x45, "Incorrect message type, expected 0x45, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -327,19 +320,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.header.t.wn ); assert_eq!( - msg.obs[0].L.f, 147, - "incorrect value for obs[0].L.f, expected 147, is {}", - msg.obs[0].L.f + msg.obs[0].l.f, 147, + "incorrect value for obs[0].l.f, expected 147, is {}", + msg.obs[0].l.f ); assert_eq!( - msg.obs[0].L.i, 8294, - "incorrect value for obs[0].L.i, expected 8294, is {}", - msg.obs[0].L.i + msg.obs[0].l.i, 8294, + "incorrect value for obs[0].l.i, expected 8294, is {}", + msg.obs[0].l.i ); assert_eq!( - msg.obs[0].P, 1973695572, - "incorrect value for obs[0].P, expected 1973695572, is {}", - msg.obs[0].P + msg.obs[0].p, 1973695572, + "incorrect value for obs[0].p, expected 1973695572, is {}", + msg.obs[0].p ); assert_eq!( msg.obs[0].cn0, 62, @@ -359,7 +352,7 @@ fn test_auto_check_sbp_observation_msgObsDepA() { } _ => panic!("Invalid message type! Expected a MsgObsDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -380,14 +373,14 @@ fn test_auto_check_sbp_observation_msgObsDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgObsDepA(msg) => { + sbp::messages::Sbp::MsgObsDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x45, "Incorrect message type, expected 0x45, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -409,19 +402,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.header.t.wn ); assert_eq!( - msg.obs[0].L.f, 141, - "incorrect value for obs[0].L.f, expected 141, is {}", - msg.obs[0].L.f + msg.obs[0].l.f, 141, + "incorrect value for obs[0].l.f, expected 141, is {}", + msg.obs[0].l.f ); assert_eq!( - msg.obs[0].L.i, -36207, - "incorrect value for obs[0].L.i, expected -36207, is {}", - msg.obs[0].L.i + msg.obs[0].l.i, -36207, + "incorrect value for obs[0].l.i, expected -36207, is {}", + msg.obs[0].l.i ); assert_eq!( - msg.obs[0].P, 2046415136, - "incorrect value for obs[0].P, expected 2046415136, is {}", - msg.obs[0].P + msg.obs[0].p, 2046415136, + "incorrect value for obs[0].p, expected 2046415136, is {}", + msg.obs[0].p ); assert_eq!( msg.obs[0].cn0, 45, @@ -439,19 +432,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[0].prn ); assert_eq!( - msg.obs[1].L.f, 159, - "incorrect value for obs[1].L.f, expected 159, is {}", - msg.obs[1].L.f + msg.obs[1].l.f, 159, + "incorrect value for obs[1].l.f, expected 159, is {}", + msg.obs[1].l.f ); assert_eq!( - msg.obs[1].L.i, 203599, - "incorrect value for obs[1].L.i, expected 203599, is {}", - msg.obs[1].L.i + msg.obs[1].l.i, 203599, + "incorrect value for obs[1].l.i, expected 203599, is {}", + msg.obs[1].l.i ); assert_eq!( - msg.obs[1].P, 2084995249, - "incorrect value for obs[1].P, expected 2084995249, is {}", - msg.obs[1].P + msg.obs[1].p, 2084995249, + "incorrect value for obs[1].p, expected 2084995249, is {}", + msg.obs[1].p ); assert_eq!( msg.obs[1].cn0, 44, @@ -469,19 +462,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[1].prn ); assert_eq!( - msg.obs[2].L.f, 77, - "incorrect value for obs[2].L.f, expected 77, is {}", - msg.obs[2].L.f + msg.obs[2].l.f, 77, + "incorrect value for obs[2].l.f, expected 77, is {}", + msg.obs[2].l.f ); assert_eq!( - msg.obs[2].L.i, -178769, - "incorrect value for obs[2].L.i, expected -178769, is {}", - msg.obs[2].L.i + msg.obs[2].l.i, -178769, + "incorrect value for obs[2].l.i, expected -178769, is {}", + msg.obs[2].l.i ); assert_eq!( - msg.obs[2].P, 2110097211, - "incorrect value for obs[2].P, expected 2110097211, is {}", - msg.obs[2].P + msg.obs[2].p, 2110097211, + "incorrect value for obs[2].p, expected 2110097211, is {}", + msg.obs[2].p ); assert_eq!( msg.obs[2].cn0, 40, @@ -499,19 +492,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[2].prn ); assert_eq!( - msg.obs[3].L.f, 20, - "incorrect value for obs[3].L.f, expected 20, is {}", - msg.obs[3].L.f + msg.obs[3].l.f, 20, + "incorrect value for obs[3].l.f, expected 20, is {}", + msg.obs[3].l.f ); assert_eq!( - msg.obs[3].L.i, -137807, - "incorrect value for obs[3].L.i, expected -137807, is {}", - msg.obs[3].L.i + msg.obs[3].l.i, -137807, + "incorrect value for obs[3].l.i, expected -137807, is {}", + msg.obs[3].l.i ); assert_eq!( - msg.obs[3].P, 2208476371, - "incorrect value for obs[3].P, expected 2208476371, is {}", - msg.obs[3].P + msg.obs[3].p, 2208476371, + "incorrect value for obs[3].p, expected 2208476371, is {}", + msg.obs[3].p ); assert_eq!( msg.obs[3].cn0, 31, @@ -529,19 +522,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[3].prn ); assert_eq!( - msg.obs[4].L.f, 94, - "incorrect value for obs[4].L.f, expected 94, is {}", - msg.obs[4].L.f + msg.obs[4].l.f, 94, + "incorrect value for obs[4].l.f, expected 94, is {}", + msg.obs[4].l.f ); assert_eq!( - msg.obs[4].L.i, -168076, - "incorrect value for obs[4].L.i, expected -168076, is {}", - msg.obs[4].L.i + msg.obs[4].l.i, -168076, + "incorrect value for obs[4].l.i, expected -168076, is {}", + msg.obs[4].l.i ); assert_eq!( - msg.obs[4].P, 2298000000, - "incorrect value for obs[4].P, expected 2298000000, is {}", - msg.obs[4].P + msg.obs[4].p, 2298000000, + "incorrect value for obs[4].p, expected 2298000000, is {}", + msg.obs[4].p ); assert_eq!( msg.obs[4].cn0, 21, @@ -559,19 +552,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[4].prn ); assert_eq!( - msg.obs[5].L.f, 214, - "incorrect value for obs[5].L.f, expected 214, is {}", - msg.obs[5].L.f + msg.obs[5].l.f, 214, + "incorrect value for obs[5].l.f, expected 214, is {}", + msg.obs[5].l.f ); assert_eq!( - msg.obs[5].L.i, 210469, - "incorrect value for obs[5].L.i, expected 210469, is {}", - msg.obs[5].L.i + msg.obs[5].l.i, 210469, + "incorrect value for obs[5].l.i, expected 210469, is {}", + msg.obs[5].l.i ); assert_eq!( - msg.obs[5].P, 2266082742, - "incorrect value for obs[5].P, expected 2266082742, is {}", - msg.obs[5].P + msg.obs[5].p, 2266082742, + "incorrect value for obs[5].p, expected 2266082742, is {}", + msg.obs[5].p ); assert_eq!( msg.obs[5].cn0, 27, @@ -589,19 +582,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[5].prn ); assert_eq!( - msg.obs[6].L.f, 129, - "incorrect value for obs[6].L.f, expected 129, is {}", - msg.obs[6].L.f + msg.obs[6].l.f, 129, + "incorrect value for obs[6].l.f, expected 129, is {}", + msg.obs[6].l.f ); assert_eq!( - msg.obs[6].L.i, -53264, - "incorrect value for obs[6].L.i, expected -53264, is {}", - msg.obs[6].L.i + msg.obs[6].l.i, -53264, + "incorrect value for obs[6].l.i, expected -53264, is {}", + msg.obs[6].l.i ); assert_eq!( - msg.obs[6].P, 1987187803, - "incorrect value for obs[6].P, expected 1987187803, is {}", - msg.obs[6].P + msg.obs[6].p, 1987187803, + "incorrect value for obs[6].p, expected 1987187803, is {}", + msg.obs[6].p ); assert_eq!( msg.obs[6].cn0, 52, @@ -621,7 +614,7 @@ fn test_auto_check_sbp_observation_msgObsDepA() { } _ => panic!("Invalid message type! Expected a MsgObsDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -638,14 +631,14 @@ fn test_auto_check_sbp_observation_msgObsDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgObsDepA(msg) => { + sbp::messages::Sbp::MsgObsDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x45, "Incorrect message type, expected 0x45, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -667,19 +660,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.header.t.wn ); assert_eq!( - msg.obs[0].L.f, 222, - "incorrect value for obs[0].L.f, expected 222, is {}", - msg.obs[0].L.f + msg.obs[0].l.f, 222, + "incorrect value for obs[0].l.f, expected 222, is {}", + msg.obs[0].l.f ); assert_eq!( - msg.obs[0].L.i, 8312, - "incorrect value for obs[0].L.i, expected 8312, is {}", - msg.obs[0].L.i + msg.obs[0].l.i, 8312, + "incorrect value for obs[0].l.i, expected 8312, is {}", + msg.obs[0].l.i ); assert_eq!( - msg.obs[0].P, 1973687089, - "incorrect value for obs[0].P, expected 1973687089, is {}", - msg.obs[0].P + msg.obs[0].p, 1973687089, + "incorrect value for obs[0].p, expected 1973687089, is {}", + msg.obs[0].p ); assert_eq!( msg.obs[0].cn0, 63, @@ -699,7 +692,7 @@ fn test_auto_check_sbp_observation_msgObsDepA() { } _ => panic!("Invalid message type! Expected a MsgObsDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -719,14 +712,14 @@ fn test_auto_check_sbp_observation_msgObsDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgObsDepA(msg) => { + sbp::messages::Sbp::MsgObsDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x45, "Incorrect message type, expected 0x45, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -748,19 +741,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.header.t.wn ); assert_eq!( - msg.obs[0].L.f, 189, - "incorrect value for obs[0].L.f, expected 189, is {}", - msg.obs[0].L.f + msg.obs[0].l.f, 189, + "incorrect value for obs[0].l.f, expected 189, is {}", + msg.obs[0].l.f ); assert_eq!( - msg.obs[0].L.i, -27527, - "incorrect value for obs[0].L.i, expected -27527, is {}", - msg.obs[0].L.i + msg.obs[0].l.i, -27527, + "incorrect value for obs[0].l.i, expected -27527, is {}", + msg.obs[0].l.i ); assert_eq!( - msg.obs[0].P, 2044298327, - "incorrect value for obs[0].P, expected 2044298327, is {}", - msg.obs[0].P + msg.obs[0].p, 2044298327, + "incorrect value for obs[0].p, expected 2044298327, is {}", + msg.obs[0].p ); assert_eq!( msg.obs[0].cn0, 43, @@ -778,19 +771,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[0].prn ); assert_eq!( - msg.obs[1].L.f, 1, - "incorrect value for obs[1].L.f, expected 1, is {}", - msg.obs[1].L.f + msg.obs[1].l.f, 1, + "incorrect value for obs[1].l.f, expected 1, is {}", + msg.obs[1].l.f ); assert_eq!( - msg.obs[1].L.i, -123030, - "incorrect value for obs[1].L.i, expected -123030, is {}", - msg.obs[1].L.i + msg.obs[1].l.i, -123030, + "incorrect value for obs[1].l.i, expected -123030, is {}", + msg.obs[1].l.i ); assert_eq!( - msg.obs[1].P, 2110275716, - "incorrect value for obs[1].P, expected 2110275716, is {}", - msg.obs[1].P + msg.obs[1].p, 2110275716, + "incorrect value for obs[1].p, expected 2110275716, is {}", + msg.obs[1].p ); assert_eq!( msg.obs[1].cn0, 41, @@ -808,19 +801,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[1].prn ); assert_eq!( - msg.obs[2].L.f, 166, - "incorrect value for obs[2].L.f, expected 166, is {}", - msg.obs[2].L.f + msg.obs[2].l.f, 166, + "incorrect value for obs[2].l.f, expected 166, is {}", + msg.obs[2].l.f ); assert_eq!( - msg.obs[2].L.i, -113594, - "incorrect value for obs[2].L.i, expected -113594, is {}", - msg.obs[2].L.i + msg.obs[2].l.i, -113594, + "incorrect value for obs[2].l.i, expected -113594, is {}", + msg.obs[2].l.i ); assert_eq!( - msg.obs[2].P, 2298000000, - "incorrect value for obs[2].P, expected 2298000000, is {}", - msg.obs[2].P + msg.obs[2].p, 2298000000, + "incorrect value for obs[2].p, expected 2298000000, is {}", + msg.obs[2].p ); assert_eq!( msg.obs[2].cn0, 18, @@ -838,19 +831,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[2].prn ); assert_eq!( - msg.obs[3].L.f, 249, - "incorrect value for obs[3].L.f, expected 249, is {}", - msg.obs[3].L.f + msg.obs[3].l.f, 249, + "incorrect value for obs[3].l.f, expected 249, is {}", + msg.obs[3].l.f ); assert_eq!( - msg.obs[3].L.i, 137478, - "incorrect value for obs[3].L.i, expected 137478, is {}", - msg.obs[3].L.i + msg.obs[3].l.i, 137478, + "incorrect value for obs[3].l.i, expected 137478, is {}", + msg.obs[3].l.i ); assert_eq!( - msg.obs[3].P, 2259844888, - "incorrect value for obs[3].P, expected 2259844888, is {}", - msg.obs[3].P + msg.obs[3].p, 2259844888, + "incorrect value for obs[3].p, expected 2259844888, is {}", + msg.obs[3].p ); assert_eq!( msg.obs[3].cn0, 28, @@ -868,19 +861,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[3].prn ); assert_eq!( - msg.obs[4].L.f, 203, - "incorrect value for obs[4].L.f, expected 203, is {}", - msg.obs[4].L.f + msg.obs[4].l.f, 203, + "incorrect value for obs[4].l.f, expected 203, is {}", + msg.obs[4].l.f ); assert_eq!( - msg.obs[4].L.i, -36797, - "incorrect value for obs[4].L.i, expected -36797, is {}", - msg.obs[4].L.i + msg.obs[4].l.i, -36797, + "incorrect value for obs[4].l.i, expected -36797, is {}", + msg.obs[4].l.i ); assert_eq!( - msg.obs[4].P, 1985374378, - "incorrect value for obs[4].P, expected 1985374378, is {}", - msg.obs[4].P + msg.obs[4].p, 1985374378, + "incorrect value for obs[4].p, expected 1985374378, is {}", + msg.obs[4].p ); assert_eq!( msg.obs[4].cn0, 56, @@ -900,7 +893,7 @@ fn test_auto_check_sbp_observation_msgObsDepA() { } _ => panic!("Invalid message type! Expected a MsgObsDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -920,14 +913,14 @@ fn test_auto_check_sbp_observation_msgObsDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgObsDepA(msg) => { + sbp::messages::Sbp::MsgObsDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x45, "Incorrect message type, expected 0x45, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -949,19 +942,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.header.t.wn ); assert_eq!( - msg.obs[0].L.f, 1, - "incorrect value for obs[0].L.f, expected 1, is {}", - msg.obs[0].L.f + msg.obs[0].l.f, 1, + "incorrect value for obs[0].l.f, expected 1, is {}", + msg.obs[0].l.f ); assert_eq!( - msg.obs[0].L.i, -27634, - "incorrect value for obs[0].L.i, expected -27634, is {}", - msg.obs[0].L.i + msg.obs[0].l.i, -27634, + "incorrect value for obs[0].l.i, expected -27634, is {}", + msg.obs[0].l.i ); assert_eq!( - msg.obs[0].P, 2044291972, - "incorrect value for obs[0].P, expected 2044291972, is {}", - msg.obs[0].P + msg.obs[0].p, 2044291972, + "incorrect value for obs[0].p, expected 2044291972, is {}", + msg.obs[0].p ); assert_eq!( msg.obs[0].cn0, 44, @@ -979,19 +972,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[0].prn ); assert_eq!( - msg.obs[1].L.f, 153, - "incorrect value for obs[1].L.f, expected 153, is {}", - msg.obs[1].L.f + msg.obs[1].l.f, 153, + "incorrect value for obs[1].l.f, expected 153, is {}", + msg.obs[1].l.f ); assert_eq!( - msg.obs[1].L.i, -123500, - "incorrect value for obs[1].L.i, expected -123500, is {}", - msg.obs[1].L.i + msg.obs[1].l.i, -123500, + "incorrect value for obs[1].l.i, expected -123500, is {}", + msg.obs[1].l.i ); assert_eq!( - msg.obs[1].P, 2110276225, - "incorrect value for obs[1].P, expected 2110276225, is {}", - msg.obs[1].P + msg.obs[1].p, 2110276225, + "incorrect value for obs[1].p, expected 2110276225, is {}", + msg.obs[1].p ); assert_eq!( msg.obs[1].cn0, 41, @@ -1009,19 +1002,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[1].prn ); assert_eq!( - msg.obs[2].L.f, 222, - "incorrect value for obs[2].L.f, expected 222, is {}", - msg.obs[2].L.f + msg.obs[2].l.f, 222, + "incorrect value for obs[2].l.f, expected 222, is {}", + msg.obs[2].l.f ); assert_eq!( - msg.obs[2].L.i, -114033, - "incorrect value for obs[2].L.i, expected -114033, is {}", - msg.obs[2].L.i + msg.obs[2].l.i, -114033, + "incorrect value for obs[2].l.i, expected -114033, is {}", + msg.obs[2].l.i ); assert_eq!( - msg.obs[2].P, 2298000000, - "incorrect value for obs[2].P, expected 2298000000, is {}", - msg.obs[2].P + msg.obs[2].p, 2298000000, + "incorrect value for obs[2].p, expected 2298000000, is {}", + msg.obs[2].p ); assert_eq!( msg.obs[2].cn0, 18, @@ -1039,19 +1032,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[2].prn ); assert_eq!( - msg.obs[3].L.f, 237, - "incorrect value for obs[3].L.f, expected 237, is {}", - msg.obs[3].L.f + msg.obs[3].l.f, 237, + "incorrect value for obs[3].l.f, expected 237, is {}", + msg.obs[3].l.f ); assert_eq!( - msg.obs[3].L.i, 138026, - "incorrect value for obs[3].L.i, expected 138026, is {}", - msg.obs[3].L.i + msg.obs[3].l.i, 138026, + "incorrect value for obs[3].l.i, expected 138026, is {}", + msg.obs[3].l.i ); assert_eq!( - msg.obs[3].P, 2259826078, - "incorrect value for obs[3].P, expected 2259826078, is {}", - msg.obs[3].P + msg.obs[3].p, 2259826078, + "incorrect value for obs[3].p, expected 2259826078, is {}", + msg.obs[3].p ); assert_eq!( msg.obs[3].cn0, 30, @@ -1069,19 +1062,19 @@ fn test_auto_check_sbp_observation_msgObsDepA() { msg.obs[3].prn ); assert_eq!( - msg.obs[4].L.f, 45, - "incorrect value for obs[4].L.f, expected 45, is {}", - msg.obs[4].L.f + msg.obs[4].l.f, 45, + "incorrect value for obs[4].l.f, expected 45, is {}", + msg.obs[4].l.f ); assert_eq!( - msg.obs[4].L.i, -36952, - "incorrect value for obs[4].L.i, expected -36952, is {}", - msg.obs[4].L.i + msg.obs[4].l.i, -36952, + "incorrect value for obs[4].l.i, expected -36952, is {}", + msg.obs[4].l.i ); assert_eq!( - msg.obs[4].P, 1985368870, - "incorrect value for obs[4].P, expected 1985368870, is {}", - msg.obs[4].P + msg.obs[4].p, 1985368870, + "incorrect value for obs[4].p, expected 1985368870, is {}", + msg.obs[4].p ); assert_eq!( msg.obs[4].cn0, 56, @@ -1101,7 +1094,7 @@ fn test_auto_check_sbp_observation_msgObsDepA() { } _ => panic!("Invalid message type! Expected a MsgObsDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_observation_MsgObsDepB.rs b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_obs_dep_b.rs similarity index 76% rename from rust/sbp/tests/auto_check_sbp_observation_MsgObsDepB.rs rename to rust/sbp/tests/integration/auto_check_sbp_observation_msg_obs_dep_b.rs index 53302c5e3e..0c55583fb6 100644 --- a/rust/sbp/tests/auto_check_sbp_observation_MsgObsDepB.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_obs_dep_b.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/observation/test_MsgObsDepB.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_observation_MsgObsDepB() { +fn test_auto_check_sbp_observation_msg_obs_dep_b() { { let mut payload = Cursor::new(vec![ 85, 67, 0, 246, 215, 103, 120, 46, 39, 0, 251, 6, 32, 180, 175, 187, 133, 223, 53, 7, @@ -40,14 +33,14 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgObsDepB(msg) => { + sbp::messages::Sbp::MsgObsDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x43, "Incorrect message type, expected 0x43, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -69,19 +62,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.header.t.wn ); assert_eq!( - msg.obs[0].L.f, 27, - "incorrect value for obs[0].L.f, expected 27, is {}", - msg.obs[0].L.f + msg.obs[0].l.f, 27, + "incorrect value for obs[0].l.f, expected 27, is {}", + msg.obs[0].l.f ); assert_eq!( - msg.obs[0].L.i, 117913055, - "incorrect value for obs[0].L.i, expected 117913055, is {}", - msg.obs[0].L.i + msg.obs[0].l.i, 117913055, + "incorrect value for obs[0].l.i, expected 117913055, is {}", + msg.obs[0].l.i ); assert_eq!( - msg.obs[0].P, 2243669940, - "incorrect value for obs[0].P, expected 2243669940, is {}", - msg.obs[0].P + msg.obs[0].p, 2243669940, + "incorrect value for obs[0].p, expected 2243669940, is {}", + msg.obs[0].p ); assert_eq!( msg.obs[0].cn0, 157, @@ -109,19 +102,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.obs[0].sid.sat ); assert_eq!( - msg.obs[1].L.f, 175, - "incorrect value for obs[1].L.f, expected 175, is {}", - msg.obs[1].L.f + msg.obs[1].l.f, 175, + "incorrect value for obs[1].l.f, expected 175, is {}", + msg.obs[1].l.f ); assert_eq!( - msg.obs[1].L.i, 129899608, - "incorrect value for obs[1].L.i, expected 129899608, is {}", - msg.obs[1].L.i + msg.obs[1].l.i, 129899608, + "incorrect value for obs[1].l.i, expected 129899608, is {}", + msg.obs[1].l.i ); assert_eq!( - msg.obs[1].P, 2471857210, - "incorrect value for obs[1].P, expected 2471857210, is {}", - msg.obs[1].P + msg.obs[1].p, 2471857210, + "incorrect value for obs[1].p, expected 2471857210, is {}", + msg.obs[1].p ); assert_eq!( msg.obs[1].cn0, 144, @@ -149,19 +142,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.obs[1].sid.sat ); assert_eq!( - msg.obs[2].L.f, 135, - "incorrect value for obs[2].L.f, expected 135, is {}", - msg.obs[2].L.f + msg.obs[2].l.f, 135, + "incorrect value for obs[2].l.f, expected 135, is {}", + msg.obs[2].l.f ); assert_eq!( - msg.obs[2].L.i, 122531024, - "incorrect value for obs[2].L.i, expected 122531024, is {}", - msg.obs[2].L.i + msg.obs[2].l.i, 122531024, + "incorrect value for obs[2].l.i, expected 122531024, is {}", + msg.obs[2].l.i ); assert_eq!( - msg.obs[2].P, 2331544796, - "incorrect value for obs[2].P, expected 2331544796, is {}", - msg.obs[2].P + msg.obs[2].p, 2331544796, + "incorrect value for obs[2].p, expected 2331544796, is {}", + msg.obs[2].p ); assert_eq!( msg.obs[2].cn0, 151, @@ -189,19 +182,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.obs[2].sid.sat ); assert_eq!( - msg.obs[3].L.f, 242, - "incorrect value for obs[3].L.f, expected 242, is {}", - msg.obs[3].L.f + msg.obs[3].l.f, 242, + "incorrect value for obs[3].l.f, expected 242, is {}", + msg.obs[3].l.f ); assert_eq!( - msg.obs[3].L.i, 119280243, - "incorrect value for obs[3].L.i, expected 119280243, is {}", - msg.obs[3].L.i + msg.obs[3].l.i, 119280243, + "incorrect value for obs[3].l.i, expected 119280243, is {}", + msg.obs[3].l.i ); assert_eq!( - msg.obs[3].P, 2269692589, - "incorrect value for obs[3].P, expected 2269692589, is {}", - msg.obs[3].P + msg.obs[3].p, 2269692589, + "incorrect value for obs[3].p, expected 2269692589, is {}", + msg.obs[3].p ); assert_eq!( msg.obs[3].cn0, 156, @@ -229,19 +222,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.obs[3].sid.sat ); assert_eq!( - msg.obs[4].L.f, 120, - "incorrect value for obs[4].L.f, expected 120, is {}", - msg.obs[4].L.f + msg.obs[4].l.f, 120, + "incorrect value for obs[4].l.f, expected 120, is {}", + msg.obs[4].l.f ); assert_eq!( - msg.obs[4].L.i, 109691922, - "incorrect value for obs[4].L.i, expected 109691922, is {}", - msg.obs[4].L.i + msg.obs[4].l.i, 109691922, + "incorrect value for obs[4].l.i, expected 109691922, is {}", + msg.obs[4].l.i ); assert_eq!( - msg.obs[4].P, 2087293092, - "incorrect value for obs[4].P, expected 2087293092, is {}", - msg.obs[4].P + msg.obs[4].p, 2087293092, + "incorrect value for obs[4].p, expected 2087293092, is {}", + msg.obs[4].p ); assert_eq!( msg.obs[4].cn0, 168, @@ -269,19 +262,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.obs[4].sid.sat ); assert_eq!( - msg.obs[5].L.f, 87, - "incorrect value for obs[5].L.f, expected 87, is {}", - msg.obs[5].L.f + msg.obs[5].l.f, 87, + "incorrect value for obs[5].l.f, expected 87, is {}", + msg.obs[5].l.f ); assert_eq!( - msg.obs[5].L.i, 123340754, - "incorrect value for obs[5].L.i, expected 123340754, is {}", - msg.obs[5].L.i + msg.obs[5].l.i, 123340754, + "incorrect value for obs[5].l.i, expected 123340754, is {}", + msg.obs[5].l.i ); assert_eq!( - msg.obs[5].P, 2347034654, - "incorrect value for obs[5].P, expected 2347034654, is {}", - msg.obs[5].P + msg.obs[5].p, 2347034654, + "incorrect value for obs[5].p, expected 2347034654, is {}", + msg.obs[5].p ); assert_eq!( msg.obs[5].cn0, 150, @@ -311,7 +304,7 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { } _ => panic!("Invalid message type! Expected a MsgObsDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -329,14 +322,14 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgObsDepB(msg) => { + sbp::messages::Sbp::MsgObsDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x43, "Incorrect message type, expected 0x43, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -358,19 +351,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.header.t.wn ); assert_eq!( - msg.obs[0].L.f, 219, - "incorrect value for obs[0].L.f, expected 219, is {}", - msg.obs[0].L.f + msg.obs[0].l.f, 219, + "incorrect value for obs[0].l.f, expected 219, is {}", + msg.obs[0].l.f ); assert_eq!( - msg.obs[0].L.i, 120256389, - "incorrect value for obs[0].L.i, expected 120256389, is {}", - msg.obs[0].L.i + msg.obs[0].l.i, 120256389, + "incorrect value for obs[0].l.i, expected 120256389, is {}", + msg.obs[0].l.i ); assert_eq!( - msg.obs[0].P, 2288371524, - "incorrect value for obs[0].P, expected 2288371524, is {}", - msg.obs[0].P + msg.obs[0].p, 2288371524, + "incorrect value for obs[0].p, expected 2288371524, is {}", + msg.obs[0].p ); assert_eq!( msg.obs[0].cn0, 154, @@ -398,19 +391,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.obs[0].sid.sat ); assert_eq!( - msg.obs[1].L.f, 235, - "incorrect value for obs[1].L.f, expected 235, is {}", - msg.obs[1].L.f + msg.obs[1].l.f, 235, + "incorrect value for obs[1].l.f, expected 235, is {}", + msg.obs[1].l.f ); assert_eq!( - msg.obs[1].L.i, 117692256, - "incorrect value for obs[1].L.i, expected 117692256, is {}", - msg.obs[1].L.i + msg.obs[1].l.i, 117692256, + "incorrect value for obs[1].l.i, expected 117692256, is {}", + msg.obs[1].l.i ); assert_eq!( - msg.obs[1].P, 2239434459, - "incorrect value for obs[1].P, expected 2239434459, is {}", - msg.obs[1].P + msg.obs[1].p, 2239434459, + "incorrect value for obs[1].p, expected 2239434459, is {}", + msg.obs[1].p ); assert_eq!( msg.obs[1].cn0, 156, @@ -438,19 +431,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.obs[1].sid.sat ); assert_eq!( - msg.obs[2].L.f, 174, - "incorrect value for obs[2].L.f, expected 174, is {}", - msg.obs[2].L.f + msg.obs[2].l.f, 174, + "incorrect value for obs[2].l.f, expected 174, is {}", + msg.obs[2].l.f ); assert_eq!( - msg.obs[2].L.i, 107851013, - "incorrect value for obs[2].L.i, expected 107851013, is {}", - msg.obs[2].L.i + msg.obs[2].l.i, 107851013, + "incorrect value for obs[2].l.i, expected 107851013, is {}", + msg.obs[2].l.i ); assert_eq!( - msg.obs[2].P, 2052171351, - "incorrect value for obs[2].P, expected 2052171351, is {}", - msg.obs[2].P + msg.obs[2].p, 2052171351, + "incorrect value for obs[2].p, expected 2052171351, is {}", + msg.obs[2].p ); assert_eq!( msg.obs[2].cn0, 170, @@ -480,7 +473,7 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { } _ => panic!("Invalid message type! Expected a MsgObsDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -501,14 +494,14 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgObsDepB(msg) => { + sbp::messages::Sbp::MsgObsDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x43, "Incorrect message type, expected 0x43, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -530,19 +523,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.header.t.wn ); assert_eq!( - msg.obs[0].L.f, 94, - "incorrect value for obs[0].L.f, expected 94, is {}", - msg.obs[0].L.f + msg.obs[0].l.f, 94, + "incorrect value for obs[0].l.f, expected 94, is {}", + msg.obs[0].l.f ); assert_eq!( - msg.obs[0].L.i, 117912556, - "incorrect value for obs[0].L.i, expected 117912556, is {}", - msg.obs[0].L.i + msg.obs[0].l.i, 117912556, + "incorrect value for obs[0].l.i, expected 117912556, is {}", + msg.obs[0].l.i ); assert_eq!( - msg.obs[0].P, 2243658852, - "incorrect value for obs[0].P, expected 2243658852, is {}", - msg.obs[0].P + msg.obs[0].p, 2243658852, + "incorrect value for obs[0].p, expected 2243658852, is {}", + msg.obs[0].p ); assert_eq!( msg.obs[0].cn0, 156, @@ -570,19 +563,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.obs[0].sid.sat ); assert_eq!( - msg.obs[1].L.f, 40, - "incorrect value for obs[1].L.f, expected 40, is {}", - msg.obs[1].L.f + msg.obs[1].l.f, 40, + "incorrect value for obs[1].l.f, expected 40, is {}", + msg.obs[1].l.f ); assert_eq!( - msg.obs[1].L.i, 129900210, - "incorrect value for obs[1].L.i, expected 129900210, is {}", - msg.obs[1].L.i + msg.obs[1].l.i, 129900210, + "incorrect value for obs[1].l.i, expected 129900210, is {}", + msg.obs[1].l.i ); assert_eq!( - msg.obs[1].P, 2471868513, - "incorrect value for obs[1].P, expected 2471868513, is {}", - msg.obs[1].P + msg.obs[1].p, 2471868513, + "incorrect value for obs[1].p, expected 2471868513, is {}", + msg.obs[1].p ); assert_eq!( msg.obs[1].cn0, 140, @@ -610,19 +603,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.obs[1].sid.sat ); assert_eq!( - msg.obs[2].L.f, 2, - "incorrect value for obs[2].L.f, expected 2, is {}", - msg.obs[2].L.f + msg.obs[2].l.f, 2, + "incorrect value for obs[2].l.f, expected 2, is {}", + msg.obs[2].l.f ); assert_eq!( - msg.obs[2].L.i, 122530650, - "incorrect value for obs[2].L.i, expected 122530650, is {}", - msg.obs[2].L.i + msg.obs[2].l.i, 122530650, + "incorrect value for obs[2].l.i, expected 122530650, is {}", + msg.obs[2].l.i ); assert_eq!( - msg.obs[2].P, 2331537287, - "incorrect value for obs[2].P, expected 2331537287, is {}", - msg.obs[2].P + msg.obs[2].p, 2331537287, + "incorrect value for obs[2].p, expected 2331537287, is {}", + msg.obs[2].p ); assert_eq!( msg.obs[2].cn0, 150, @@ -650,19 +643,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.obs[2].sid.sat ); assert_eq!( - msg.obs[3].L.f, 241, - "incorrect value for obs[3].L.f, expected 241, is {}", - msg.obs[3].L.f + msg.obs[3].l.f, 241, + "incorrect value for obs[3].l.f, expected 241, is {}", + msg.obs[3].l.f ); assert_eq!( - msg.obs[3].L.i, 119280830, - "incorrect value for obs[3].L.i, expected 119280830, is {}", - msg.obs[3].L.i + msg.obs[3].l.i, 119280830, + "incorrect value for obs[3].l.i, expected 119280830, is {}", + msg.obs[3].l.i ); assert_eq!( - msg.obs[3].P, 2269703860, - "incorrect value for obs[3].P, expected 2269703860, is {}", - msg.obs[3].P + msg.obs[3].p, 2269703860, + "incorrect value for obs[3].p, expected 2269703860, is {}", + msg.obs[3].p ); assert_eq!( msg.obs[3].cn0, 155, @@ -690,19 +683,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.obs[3].sid.sat ); assert_eq!( - msg.obs[4].L.f, 153, - "incorrect value for obs[4].L.f, expected 153, is {}", - msg.obs[4].L.f + msg.obs[4].l.f, 153, + "incorrect value for obs[4].l.f, expected 153, is {}", + msg.obs[4].l.f ); assert_eq!( - msg.obs[4].L.i, 109691996, - "incorrect value for obs[4].L.i, expected 109691996, is {}", - msg.obs[4].L.i + msg.obs[4].l.i, 109691996, + "incorrect value for obs[4].l.i, expected 109691996, is {}", + msg.obs[4].l.i ); assert_eq!( - msg.obs[4].P, 2087295247, - "incorrect value for obs[4].P, expected 2087295247, is {}", - msg.obs[4].P + msg.obs[4].p, 2087295247, + "incorrect value for obs[4].p, expected 2087295247, is {}", + msg.obs[4].p ); assert_eq!( msg.obs[4].cn0, 168, @@ -730,19 +723,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.obs[4].sid.sat ); assert_eq!( - msg.obs[5].L.f, 41, - "incorrect value for obs[5].L.f, expected 41, is {}", - msg.obs[5].L.f + msg.obs[5].l.f, 41, + "incorrect value for obs[5].l.f, expected 41, is {}", + msg.obs[5].l.f ); assert_eq!( - msg.obs[5].L.i, 123340176, - "incorrect value for obs[5].L.i, expected 123340176, is {}", - msg.obs[5].L.i + msg.obs[5].l.i, 123340176, + "incorrect value for obs[5].l.i, expected 123340176, is {}", + msg.obs[5].l.i ); assert_eq!( - msg.obs[5].P, 2347022641, - "incorrect value for obs[5].P, expected 2347022641, is {}", - msg.obs[5].P + msg.obs[5].p, 2347022641, + "incorrect value for obs[5].p, expected 2347022641, is {}", + msg.obs[5].p ); assert_eq!( msg.obs[5].cn0, 150, @@ -772,7 +765,7 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { } _ => panic!("Invalid message type! Expected a MsgObsDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -790,14 +783,14 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgObsDepB(msg) => { + sbp::messages::Sbp::MsgObsDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x43, "Incorrect message type, expected 0x43, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -819,19 +812,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.header.t.wn ); assert_eq!( - msg.obs[0].L.f, 20, - "incorrect value for obs[0].L.f, expected 20, is {}", - msg.obs[0].L.f + msg.obs[0].l.f, 20, + "incorrect value for obs[0].l.f, expected 20, is {}", + msg.obs[0].l.f ); assert_eq!( - msg.obs[0].L.i, 120255759, - "incorrect value for obs[0].L.i, expected 120255759, is {}", - msg.obs[0].L.i + msg.obs[0].l.i, 120255759, + "incorrect value for obs[0].l.i, expected 120255759, is {}", + msg.obs[0].l.i ); assert_eq!( - msg.obs[0].P, 2288358634, - "incorrect value for obs[0].P, expected 2288358634, is {}", - msg.obs[0].P + msg.obs[0].p, 2288358634, + "incorrect value for obs[0].p, expected 2288358634, is {}", + msg.obs[0].p ); assert_eq!( msg.obs[0].cn0, 154, @@ -859,19 +852,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.obs[0].sid.sat ); assert_eq!( - msg.obs[1].L.f, 38, - "incorrect value for obs[1].L.f, expected 38, is {}", - msg.obs[1].L.f + msg.obs[1].l.f, 38, + "incorrect value for obs[1].l.f, expected 38, is {}", + msg.obs[1].l.f ); assert_eq!( - msg.obs[1].L.i, 117691920, - "incorrect value for obs[1].L.i, expected 117691920, is {}", - msg.obs[1].L.i + msg.obs[1].l.i, 117691920, + "incorrect value for obs[1].l.i, expected 117691920, is {}", + msg.obs[1].l.i ); assert_eq!( - msg.obs[1].P, 2239428560, - "incorrect value for obs[1].P, expected 2239428560, is {}", - msg.obs[1].P + msg.obs[1].p, 2239428560, + "incorrect value for obs[1].p, expected 2239428560, is {}", + msg.obs[1].p ); assert_eq!( msg.obs[1].cn0, 156, @@ -899,19 +892,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.obs[1].sid.sat ); assert_eq!( - msg.obs[2].L.f, 7, - "incorrect value for obs[2].L.f, expected 7, is {}", - msg.obs[2].L.f + msg.obs[2].l.f, 7, + "incorrect value for obs[2].l.f, expected 7, is {}", + msg.obs[2].l.f ); assert_eq!( - msg.obs[2].L.i, 107850774, - "incorrect value for obs[2].L.i, expected 107850774, is {}", - msg.obs[2].L.i + msg.obs[2].l.i, 107850774, + "incorrect value for obs[2].l.i, expected 107850774, is {}", + msg.obs[2].l.i ); assert_eq!( - msg.obs[2].P, 2052167183, - "incorrect value for obs[2].P, expected 2052167183, is {}", - msg.obs[2].P + msg.obs[2].p, 2052167183, + "incorrect value for obs[2].p, expected 2052167183, is {}", + msg.obs[2].p ); assert_eq!( msg.obs[2].cn0, 172, @@ -941,7 +934,7 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { } _ => panic!("Invalid message type! Expected a MsgObsDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -962,14 +955,14 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgObsDepB(msg) => { + sbp::messages::Sbp::MsgObsDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x43, "Incorrect message type, expected 0x43, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -991,19 +984,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.header.t.wn ); assert_eq!( - msg.obs[0].L.f, 165, - "incorrect value for obs[0].L.f, expected 165, is {}", - msg.obs[0].L.f + msg.obs[0].l.f, 165, + "incorrect value for obs[0].l.f, expected 165, is {}", + msg.obs[0].l.f ); assert_eq!( - msg.obs[0].L.i, 117912057, - "incorrect value for obs[0].L.i, expected 117912057, is {}", - msg.obs[0].L.i + msg.obs[0].l.i, 117912057, + "incorrect value for obs[0].l.i, expected 117912057, is {}", + msg.obs[0].l.i ); assert_eq!( - msg.obs[0].P, 2243649790, - "incorrect value for obs[0].P, expected 2243649790, is {}", - msg.obs[0].P + msg.obs[0].p, 2243649790, + "incorrect value for obs[0].p, expected 2243649790, is {}", + msg.obs[0].p ); assert_eq!( msg.obs[0].cn0, 156, @@ -1031,19 +1024,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.obs[0].sid.sat ); assert_eq!( - msg.obs[1].L.f, 106, - "incorrect value for obs[1].L.f, expected 106, is {}", - msg.obs[1].L.f + msg.obs[1].l.f, 106, + "incorrect value for obs[1].l.f, expected 106, is {}", + msg.obs[1].l.f ); assert_eq!( - msg.obs[1].L.i, 129900811, - "incorrect value for obs[1].L.i, expected 129900811, is {}", - msg.obs[1].L.i + msg.obs[1].l.i, 129900811, + "incorrect value for obs[1].l.i, expected 129900811, is {}", + msg.obs[1].l.i ); assert_eq!( - msg.obs[1].P, 2471880049, - "incorrect value for obs[1].P, expected 2471880049, is {}", - msg.obs[1].P + msg.obs[1].p, 2471880049, + "incorrect value for obs[1].p, expected 2471880049, is {}", + msg.obs[1].p ); assert_eq!( msg.obs[1].cn0, 143, @@ -1071,19 +1064,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.obs[1].sid.sat ); assert_eq!( - msg.obs[2].L.f, 159, - "incorrect value for obs[2].L.f, expected 159, is {}", - msg.obs[2].L.f + msg.obs[2].l.f, 159, + "incorrect value for obs[2].l.f, expected 159, is {}", + msg.obs[2].l.f ); assert_eq!( - msg.obs[2].L.i, 122530275, - "incorrect value for obs[2].L.i, expected 122530275, is {}", - msg.obs[2].L.i + msg.obs[2].l.i, 122530275, + "incorrect value for obs[2].l.i, expected 122530275, is {}", + msg.obs[2].l.i ); assert_eq!( - msg.obs[2].P, 2331530678, - "incorrect value for obs[2].P, expected 2331530678, is {}", - msg.obs[2].P + msg.obs[2].p, 2331530678, + "incorrect value for obs[2].p, expected 2331530678, is {}", + msg.obs[2].p ); assert_eq!( msg.obs[2].cn0, 150, @@ -1111,19 +1104,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.obs[2].sid.sat ); assert_eq!( - msg.obs[3].L.f, 7, - "incorrect value for obs[3].L.f, expected 7, is {}", - msg.obs[3].L.f + msg.obs[3].l.f, 7, + "incorrect value for obs[3].l.f, expected 7, is {}", + msg.obs[3].l.f ); assert_eq!( - msg.obs[3].L.i, 119281418, - "incorrect value for obs[3].L.i, expected 119281418, is {}", - msg.obs[3].L.i + msg.obs[3].l.i, 119281418, + "incorrect value for obs[3].l.i, expected 119281418, is {}", + msg.obs[3].l.i ); assert_eq!( - msg.obs[3].P, 2269714449, - "incorrect value for obs[3].P, expected 2269714449, is {}", - msg.obs[3].P + msg.obs[3].p, 2269714449, + "incorrect value for obs[3].p, expected 2269714449, is {}", + msg.obs[3].p ); assert_eq!( msg.obs[3].cn0, 156, @@ -1151,19 +1144,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.obs[3].sid.sat ); assert_eq!( - msg.obs[4].L.f, 186, - "incorrect value for obs[4].L.f, expected 186, is {}", - msg.obs[4].L.f + msg.obs[4].l.f, 186, + "incorrect value for obs[4].l.f, expected 186, is {}", + msg.obs[4].l.f ); assert_eq!( - msg.obs[4].L.i, 109692070, - "incorrect value for obs[4].L.i, expected 109692070, is {}", - msg.obs[4].L.i + msg.obs[4].l.i, 109692070, + "incorrect value for obs[4].l.i, expected 109692070, is {}", + msg.obs[4].l.i ); assert_eq!( - msg.obs[4].P, 2087295852, - "incorrect value for obs[4].P, expected 2087295852, is {}", - msg.obs[4].P + msg.obs[4].p, 2087295852, + "incorrect value for obs[4].p, expected 2087295852, is {}", + msg.obs[4].p ); assert_eq!( msg.obs[4].cn0, 170, @@ -1191,19 +1184,19 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { msg.obs[4].sid.sat ); assert_eq!( - msg.obs[5].L.f, 236, - "incorrect value for obs[5].L.f, expected 236, is {}", - msg.obs[5].L.f + msg.obs[5].l.f, 236, + "incorrect value for obs[5].l.f, expected 236, is {}", + msg.obs[5].l.f ); assert_eq!( - msg.obs[5].L.i, 123339597, - "incorrect value for obs[5].L.i, expected 123339597, is {}", - msg.obs[5].L.i + msg.obs[5].l.i, 123339597, + "incorrect value for obs[5].l.i, expected 123339597, is {}", + msg.obs[5].l.i ); assert_eq!( - msg.obs[5].P, 2347011798, - "incorrect value for obs[5].P, expected 2347011798, is {}", - msg.obs[5].P + msg.obs[5].p, 2347011798, + "incorrect value for obs[5].p, expected 2347011798, is {}", + msg.obs[5].p ); assert_eq!( msg.obs[5].cn0, 151, @@ -1233,7 +1226,7 @@ fn test_auto_check_sbp_observation_MsgObsDepB() { } _ => panic!("Invalid message type! Expected a MsgObsDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_observation_MsgObsDepC.rs b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_obs_dep_c.rs similarity index 77% rename from rust/sbp/tests/auto_check_sbp_observation_MsgObsDepC.rs rename to rust/sbp/tests/integration/auto_check_sbp_observation_msg_obs_dep_c.rs index 582d6eff70..f28bc5f2c8 100644 --- a/rust/sbp/tests/auto_check_sbp_observation_MsgObsDepC.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_obs_dep_c.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/observation/test_MsgObsDepC.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_observation_MsgObsDepC() { +fn test_auto_check_sbp_observation_msg_obs_dep_c() { { let mut payload = Cursor::new(vec![ 85, 73, 0, 70, 152, 87, 8, 95, 183, 24, 106, 7, 32, 126, 250, 73, 80, 113, 94, 247, @@ -39,14 +32,14 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgObsDepC(msg) => { + sbp::messages::Sbp::MsgObsDepC(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x49, "Incorrect message type, expected 0x49, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x9846, "incorrect sender id, expected 0x9846, is {}", @@ -68,19 +61,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.header.t.wn ); assert_eq!( - msg.obs[0].L.f, 231, - "incorrect value for obs[0].L.f, expected 231, is {}", - msg.obs[0].L.f + msg.obs[0].l.f, 231, + "incorrect value for obs[0].l.f, expected 231, is {}", + msg.obs[0].l.f ); assert_eq!( - msg.obs[0].L.i, -565647, - "incorrect value for obs[0].L.i, expected -565647, is {}", - msg.obs[0].L.i + msg.obs[0].l.i, -565647, + "incorrect value for obs[0].l.i, expected -565647, is {}", + msg.obs[0].l.i ); assert_eq!( - msg.obs[0].P, 1347025534, - "incorrect value for obs[0].P, expected 1347025534, is {}", - msg.obs[0].P + msg.obs[0].p, 1347025534, + "incorrect value for obs[0].p, expected 1347025534, is {}", + msg.obs[0].p ); assert_eq!( msg.obs[0].cn0, 163, @@ -108,19 +101,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.obs[0].sid.sat ); assert_eq!( - msg.obs[1].L.f, 196, - "incorrect value for obs[1].L.f, expected 196, is {}", - msg.obs[1].L.f + msg.obs[1].l.f, 196, + "incorrect value for obs[1].l.f, expected 196, is {}", + msg.obs[1].l.f ); assert_eq!( - msg.obs[1].L.i, -355503, - "incorrect value for obs[1].L.i, expected -355503, is {}", - msg.obs[1].L.i + msg.obs[1].l.i, -355503, + "incorrect value for obs[1].l.i, expected -355503, is {}", + msg.obs[1].l.i ); assert_eq!( - msg.obs[1].P, 1180752956, - "incorrect value for obs[1].P, expected 1180752956, is {}", - msg.obs[1].P + msg.obs[1].p, 1180752956, + "incorrect value for obs[1].p, expected 1180752956, is {}", + msg.obs[1].p ); assert_eq!( msg.obs[1].cn0, 208, @@ -148,19 +141,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.obs[1].sid.sat ); assert_eq!( - msg.obs[2].L.f, 110, - "incorrect value for obs[2].L.f, expected 110, is {}", - msg.obs[2].L.f + msg.obs[2].l.f, 110, + "incorrect value for obs[2].l.f, expected 110, is {}", + msg.obs[2].l.f ); assert_eq!( - msg.obs[2].L.i, -902116, - "incorrect value for obs[2].L.i, expected -902116, is {}", - msg.obs[2].L.i + msg.obs[2].l.i, -902116, + "incorrect value for obs[2].l.i, expected -902116, is {}", + msg.obs[2].l.i ); assert_eq!( - msg.obs[2].P, 1295924728, - "incorrect value for obs[2].P, expected 1295924728, is {}", - msg.obs[2].P + msg.obs[2].p, 1295924728, + "incorrect value for obs[2].p, expected 1295924728, is {}", + msg.obs[2].p ); assert_eq!( msg.obs[2].cn0, 171, @@ -188,19 +181,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.obs[2].sid.sat ); assert_eq!( - msg.obs[3].L.f, 41, - "incorrect value for obs[3].L.f, expected 41, is {}", - msg.obs[3].L.f + msg.obs[3].l.f, 41, + "incorrect value for obs[3].l.f, expected 41, is {}", + msg.obs[3].l.f ); assert_eq!( - msg.obs[3].L.i, 861612, - "incorrect value for obs[3].L.i, expected 861612, is {}", - msg.obs[3].L.i + msg.obs[3].l.i, 861612, + "incorrect value for obs[3].l.i, expected 861612, is {}", + msg.obs[3].l.i ); assert_eq!( - msg.obs[3].P, 1304319213, - "incorrect value for obs[3].P, expected 1304319213, is {}", - msg.obs[3].P + msg.obs[3].p, 1304319213, + "incorrect value for obs[3].p, expected 1304319213, is {}", + msg.obs[3].p ); assert_eq!( msg.obs[3].cn0, 170, @@ -228,19 +221,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.obs[3].sid.sat ); assert_eq!( - msg.obs[4].L.f, 19, - "incorrect value for obs[4].L.f, expected 19, is {}", - msg.obs[4].L.f + msg.obs[4].l.f, 19, + "incorrect value for obs[4].l.f, expected 19, is {}", + msg.obs[4].l.f ); assert_eq!( - msg.obs[4].L.i, 1424624, - "incorrect value for obs[4].L.i, expected 1424624, is {}", - msg.obs[4].L.i + msg.obs[4].l.i, 1424624, + "incorrect value for obs[4].l.i, expected 1424624, is {}", + msg.obs[4].l.i ); assert_eq!( - msg.obs[4].P, 1258902820, - "incorrect value for obs[4].P, expected 1258902820, is {}", - msg.obs[4].P + msg.obs[4].p, 1258902820, + "incorrect value for obs[4].p, expected 1258902820, is {}", + msg.obs[4].p ); assert_eq!( msg.obs[4].cn0, 182, @@ -270,7 +263,7 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { } _ => panic!("Invalid message type! Expected a MsgObsDepC"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -288,14 +281,14 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgObsDepC(msg) => { + sbp::messages::Sbp::MsgObsDepC(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x49, "Incorrect message type, expected 0x49, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x9846, "incorrect sender id, expected 0x9846, is {}", @@ -317,19 +310,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.header.t.wn ); assert_eq!( - msg.obs[0].L.f, 101, - "incorrect value for obs[0].L.f, expected 101, is {}", - msg.obs[0].L.f + msg.obs[0].l.f, 101, + "incorrect value for obs[0].l.f, expected 101, is {}", + msg.obs[0].l.f ); assert_eq!( - msg.obs[0].L.i, 1631930, - "incorrect value for obs[0].L.i, expected 1631930, is {}", - msg.obs[0].L.i + msg.obs[0].l.i, 1631930, + "incorrect value for obs[0].l.i, expected 1631930, is {}", + msg.obs[0].l.i ); assert_eq!( - msg.obs[0].P, 1296803396, - "incorrect value for obs[0].P, expected 1296803396, is {}", - msg.obs[0].P + msg.obs[0].p, 1296803396, + "incorrect value for obs[0].p, expected 1296803396, is {}", + msg.obs[0].p ); assert_eq!( msg.obs[0].cn0, 186, @@ -357,19 +350,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.obs[0].sid.sat ); assert_eq!( - msg.obs[1].L.f, 26, - "incorrect value for obs[1].L.f, expected 26, is {}", - msg.obs[1].L.f + msg.obs[1].l.f, 26, + "incorrect value for obs[1].l.f, expected 26, is {}", + msg.obs[1].l.f ); assert_eq!( - msg.obs[1].L.i, 368202, - "incorrect value for obs[1].L.i, expected 368202, is {}", - msg.obs[1].L.i + msg.obs[1].l.i, 368202, + "incorrect value for obs[1].l.i, expected 368202, is {}", + msg.obs[1].l.i ); assert_eq!( - msg.obs[1].P, 1167851351, - "incorrect value for obs[1].P, expected 1167851351, is {}", - msg.obs[1].P + msg.obs[1].p, 1167851351, + "incorrect value for obs[1].p, expected 1167851351, is {}", + msg.obs[1].p ); assert_eq!( msg.obs[1].cn0, 190, @@ -397,19 +390,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.obs[1].sid.sat ); assert_eq!( - msg.obs[2].L.f, 114, - "incorrect value for obs[2].L.f, expected 114, is {}", - msg.obs[2].L.f + msg.obs[2].l.f, 114, + "incorrect value for obs[2].l.f, expected 114, is {}", + msg.obs[2].l.f ); assert_eq!( - msg.obs[2].L.i, 202266, - "incorrect value for obs[2].L.i, expected 202266, is {}", - msg.obs[2].L.i + msg.obs[2].l.i, 202266, + "incorrect value for obs[2].l.i, expected 202266, is {}", + msg.obs[2].l.i ); assert_eq!( - msg.obs[2].P, 1149000000, - "incorrect value for obs[2].P, expected 1149000000, is {}", - msg.obs[2].P + msg.obs[2].p, 1149000000, + "incorrect value for obs[2].p, expected 1149000000, is {}", + msg.obs[2].p ); assert_eq!( msg.obs[2].cn0, 217, @@ -439,7 +432,7 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { } _ => panic!("Invalid message type! Expected a MsgObsDepC"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -459,14 +452,14 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgObsDepC(msg) => { + sbp::messages::Sbp::MsgObsDepC(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x49, "Incorrect message type, expected 0x49, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x0, "incorrect sender id, expected 0x0, is {}", @@ -488,19 +481,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.header.t.wn ); assert_eq!( - msg.obs[0].L.f, 30, - "incorrect value for obs[0].L.f, expected 30, is {}", - msg.obs[0].L.f + msg.obs[0].l.f, 30, + "incorrect value for obs[0].l.f, expected 30, is {}", + msg.obs[0].l.f ); assert_eq!( - msg.obs[0].L.i, -505847, - "incorrect value for obs[0].L.i, expected -505847, is {}", - msg.obs[0].L.i + msg.obs[0].l.i, -505847, + "incorrect value for obs[0].l.i, expected -505847, is {}", + msg.obs[0].l.i ); assert_eq!( - msg.obs[0].P, 1347025881, - "incorrect value for obs[0].P, expected 1347025881, is {}", - msg.obs[0].P + msg.obs[0].p, 1347025881, + "incorrect value for obs[0].p, expected 1347025881, is {}", + msg.obs[0].p ); assert_eq!( msg.obs[0].cn0, 168, @@ -528,19 +521,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.obs[0].sid.sat ); assert_eq!( - msg.obs[1].L.f, 115, - "incorrect value for obs[1].L.f, expected 115, is {}", - msg.obs[1].L.f + msg.obs[1].l.f, 115, + "incorrect value for obs[1].l.f, expected 115, is {}", + msg.obs[1].l.f ); assert_eq!( - msg.obs[1].L.i, -300090, - "incorrect value for obs[1].L.i, expected -300090, is {}", - msg.obs[1].L.i + msg.obs[1].l.i, -300090, + "incorrect value for obs[1].l.i, expected -300090, is {}", + msg.obs[1].l.i ); assert_eq!( - msg.obs[1].P, 1180753107, - "incorrect value for obs[1].P, expected 1180753107, is {}", - msg.obs[1].P + msg.obs[1].p, 1180753107, + "incorrect value for obs[1].p, expected 1180753107, is {}", + msg.obs[1].p ); assert_eq!( msg.obs[1].cn0, 195, @@ -568,19 +561,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.obs[1].sid.sat ); assert_eq!( - msg.obs[2].L.f, 130, - "incorrect value for obs[2].L.f, expected 130, is {}", - msg.obs[2].L.f + msg.obs[2].l.f, 130, + "incorrect value for obs[2].l.f, expected 130, is {}", + msg.obs[2].l.f ); assert_eq!( - msg.obs[2].L.i, -810712, - "incorrect value for obs[2].L.i, expected -810712, is {}", - msg.obs[2].L.i + msg.obs[2].l.i, -810712, + "incorrect value for obs[2].l.i, expected -810712, is {}", + msg.obs[2].l.i ); assert_eq!( - msg.obs[2].P, 1295924557, - "incorrect value for obs[2].P, expected 1295924557, is {}", - msg.obs[2].P + msg.obs[2].p, 1295924557, + "incorrect value for obs[2].p, expected 1295924557, is {}", + msg.obs[2].p ); assert_eq!( msg.obs[2].cn0, 176, @@ -608,19 +601,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.obs[2].sid.sat ); assert_eq!( - msg.obs[3].L.f, 116, - "incorrect value for obs[3].L.f, expected 116, is {}", - msg.obs[3].L.f + msg.obs[3].l.f, 116, + "incorrect value for obs[3].l.f, expected 116, is {}", + msg.obs[3].l.f ); assert_eq!( - msg.obs[3].L.i, 806232, - "incorrect value for obs[3].L.i, expected 806232, is {}", - msg.obs[3].L.i + msg.obs[3].l.i, 806232, + "incorrect value for obs[3].l.i, expected 806232, is {}", + msg.obs[3].l.i ); assert_eq!( - msg.obs[3].P, 1304319489, - "incorrect value for obs[3].P, expected 1304319489, is {}", - msg.obs[3].P + msg.obs[3].p, 1304319489, + "incorrect value for obs[3].p, expected 1304319489, is {}", + msg.obs[3].p ); assert_eq!( msg.obs[3].cn0, 199, @@ -648,19 +641,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.obs[3].sid.sat ); assert_eq!( - msg.obs[4].L.f, 120, - "incorrect value for obs[4].L.f, expected 120, is {}", - msg.obs[4].L.f + msg.obs[4].l.f, 120, + "incorrect value for obs[4].l.f, expected 120, is {}", + msg.obs[4].l.f ); assert_eq!( - msg.obs[4].L.i, 1346368, - "incorrect value for obs[4].L.i, expected 1346368, is {}", - msg.obs[4].L.i + msg.obs[4].l.i, 1346368, + "incorrect value for obs[4].l.i, expected 1346368, is {}", + msg.obs[4].l.i ); assert_eq!( - msg.obs[4].P, 1258902877, - "incorrect value for obs[4].P, expected 1258902877, is {}", - msg.obs[4].P + msg.obs[4].p, 1258902877, + "incorrect value for obs[4].p, expected 1258902877, is {}", + msg.obs[4].p ); assert_eq!( msg.obs[4].cn0, 177, @@ -690,7 +683,7 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { } _ => panic!("Invalid message type! Expected a MsgObsDepC"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -708,14 +701,14 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgObsDepC(msg) => { + sbp::messages::Sbp::MsgObsDepC(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x49, "Incorrect message type, expected 0x49, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x0, "incorrect sender id, expected 0x0, is {}", @@ -737,19 +730,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.header.t.wn ); assert_eq!( - msg.obs[0].L.f, 90, - "incorrect value for obs[0].L.f, expected 90, is {}", - msg.obs[0].L.f + msg.obs[0].l.f, 90, + "incorrect value for obs[0].l.f, expected 90, is {}", + msg.obs[0].l.f ); assert_eq!( - msg.obs[0].L.i, 1542284, - "incorrect value for obs[0].L.i, expected 1542284, is {}", - msg.obs[0].L.i + msg.obs[0].l.i, 1542284, + "incorrect value for obs[0].l.i, expected 1542284, is {}", + msg.obs[0].l.i ); assert_eq!( - msg.obs[0].P, 1296803654, - "incorrect value for obs[0].P, expected 1296803654, is {}", - msg.obs[0].P + msg.obs[0].p, 1296803654, + "incorrect value for obs[0].p, expected 1296803654, is {}", + msg.obs[0].p ); assert_eq!( msg.obs[0].cn0, 187, @@ -777,19 +770,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.obs[0].sid.sat ); assert_eq!( - msg.obs[1].L.f, 17, - "incorrect value for obs[1].L.f, expected 17, is {}", - msg.obs[1].L.f + msg.obs[1].l.f, 17, + "incorrect value for obs[1].l.f, expected 17, is {}", + msg.obs[1].l.f ); assert_eq!( - msg.obs[1].L.i, 372525, - "incorrect value for obs[1].L.i, expected 372525, is {}", - msg.obs[1].L.i + msg.obs[1].l.i, 372525, + "incorrect value for obs[1].l.i, expected 372525, is {}", + msg.obs[1].l.i ); assert_eq!( - msg.obs[1].P, 1167851496, - "incorrect value for obs[1].P, expected 1167851496, is {}", - msg.obs[1].P + msg.obs[1].p, 1167851496, + "incorrect value for obs[1].p, expected 1167851496, is {}", + msg.obs[1].p ); assert_eq!( msg.obs[1].cn0, 208, @@ -817,19 +810,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.obs[1].sid.sat ); assert_eq!( - msg.obs[2].L.f, 75, - "incorrect value for obs[2].L.f, expected 75, is {}", - msg.obs[2].L.f + msg.obs[2].l.f, 75, + "incorrect value for obs[2].l.f, expected 75, is {}", + msg.obs[2].l.f ); assert_eq!( - msg.obs[2].L.i, 221229, - "incorrect value for obs[2].L.i, expected 221229, is {}", - msg.obs[2].L.i + msg.obs[2].l.i, 221229, + "incorrect value for obs[2].l.i, expected 221229, is {}", + msg.obs[2].l.i ); assert_eq!( - msg.obs[2].P, 1149000000, - "incorrect value for obs[2].P, expected 1149000000, is {}", - msg.obs[2].P + msg.obs[2].p, 1149000000, + "incorrect value for obs[2].p, expected 1149000000, is {}", + msg.obs[2].p ); assert_eq!( msg.obs[2].cn0, 185, @@ -859,7 +852,7 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { } _ => panic!("Invalid message type! Expected a MsgObsDepC"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -879,14 +872,14 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgObsDepC(msg) => { + sbp::messages::Sbp::MsgObsDepC(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x49, "Incorrect message type, expected 0x49, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x9846, "incorrect sender id, expected 0x9846, is {}", @@ -908,19 +901,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.header.t.wn ); assert_eq!( - msg.obs[0].L.f, 57, - "incorrect value for obs[0].L.f, expected 57, is {}", - msg.obs[0].L.f + msg.obs[0].l.f, 57, + "incorrect value for obs[0].l.f, expected 57, is {}", + msg.obs[0].l.f ); assert_eq!( - msg.obs[0].L.i, -565930, - "incorrect value for obs[0].L.i, expected -565930, is {}", - msg.obs[0].L.i + msg.obs[0].l.i, -565930, + "incorrect value for obs[0].l.i, expected -565930, is {}", + msg.obs[0].l.i ); assert_eq!( - msg.obs[0].P, 1347029036, - "incorrect value for obs[0].P, expected 1347029036, is {}", - msg.obs[0].P + msg.obs[0].p, 1347029036, + "incorrect value for obs[0].p, expected 1347029036, is {}", + msg.obs[0].p ); assert_eq!( msg.obs[0].cn0, 158, @@ -948,19 +941,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.obs[0].sid.sat ); assert_eq!( - msg.obs[1].L.f, 221, - "incorrect value for obs[1].L.f, expected 221, is {}", - msg.obs[1].L.f + msg.obs[1].l.f, 221, + "incorrect value for obs[1].l.f, expected 221, is {}", + msg.obs[1].l.f ); assert_eq!( - msg.obs[1].L.i, -355684, - "incorrect value for obs[1].L.i, expected -355684, is {}", - msg.obs[1].L.i + msg.obs[1].l.i, -355684, + "incorrect value for obs[1].l.i, expected -355684, is {}", + msg.obs[1].l.i ); assert_eq!( - msg.obs[1].P, 1180755424, - "incorrect value for obs[1].P, expected 1180755424, is {}", - msg.obs[1].P + msg.obs[1].p, 1180755424, + "incorrect value for obs[1].p, expected 1180755424, is {}", + msg.obs[1].p ); assert_eq!( msg.obs[1].cn0, 200, @@ -988,19 +981,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.obs[1].sid.sat ); assert_eq!( - msg.obs[2].L.f, 39, - "incorrect value for obs[2].L.f, expected 39, is {}", - msg.obs[2].L.f + msg.obs[2].l.f, 39, + "incorrect value for obs[2].l.f, expected 39, is {}", + msg.obs[2].l.f ); assert_eq!( - msg.obs[2].L.i, -902563, - "incorrect value for obs[2].L.i, expected -902563, is {}", - msg.obs[2].L.i + msg.obs[2].l.i, -902563, + "incorrect value for obs[2].l.i, expected -902563, is {}", + msg.obs[2].l.i ); assert_eq!( - msg.obs[2].P, 1295929916, - "incorrect value for obs[2].P, expected 1295929916, is {}", - msg.obs[2].P + msg.obs[2].p, 1295929916, + "incorrect value for obs[2].p, expected 1295929916, is {}", + msg.obs[2].p ); assert_eq!( msg.obs[2].cn0, 164, @@ -1028,19 +1021,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.obs[2].sid.sat ); assert_eq!( - msg.obs[3].L.f, 202, - "incorrect value for obs[3].L.f, expected 202, is {}", - msg.obs[3].L.f + msg.obs[3].l.f, 202, + "incorrect value for obs[3].l.f, expected 202, is {}", + msg.obs[3].l.f ); assert_eq!( - msg.obs[3].L.i, 861998, - "incorrect value for obs[3].L.i, expected 861998, is {}", - msg.obs[3].L.i + msg.obs[3].l.i, 861998, + "incorrect value for obs[3].l.i, expected 861998, is {}", + msg.obs[3].l.i ); assert_eq!( - msg.obs[3].P, 1304316382, - "incorrect value for obs[3].P, expected 1304316382, is {}", - msg.obs[3].P + msg.obs[3].p, 1304316382, + "incorrect value for obs[3].p, expected 1304316382, is {}", + msg.obs[3].p ); assert_eq!( msg.obs[3].cn0, 181, @@ -1068,19 +1061,19 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { msg.obs[3].sid.sat ); assert_eq!( - msg.obs[4].L.f, 249, - "incorrect value for obs[4].L.f, expected 249, is {}", - msg.obs[4].L.f + msg.obs[4].l.f, 249, + "incorrect value for obs[4].l.f, expected 249, is {}", + msg.obs[4].l.f ); assert_eq!( - msg.obs[4].L.i, 1425266, - "incorrect value for obs[4].L.i, expected 1425266, is {}", - msg.obs[4].L.i + msg.obs[4].l.i, 1425266, + "incorrect value for obs[4].l.i, expected 1425266, is {}", + msg.obs[4].l.i ); assert_eq!( - msg.obs[4].P, 1258897557, - "incorrect value for obs[4].P, expected 1258897557, is {}", - msg.obs[4].P + msg.obs[4].p, 1258897557, + "incorrect value for obs[4].p, expected 1258897557, is {}", + msg.obs[4].p ); assert_eq!( msg.obs[4].cn0, 182, @@ -1110,7 +1103,7 @@ fn test_auto_check_sbp_observation_MsgObsDepC() { } _ => panic!("Invalid message type! Expected a MsgObsDepC"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_observation_MsgOsr.rs b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_osr.rs similarity index 80% rename from rust/sbp/tests/auto_check_sbp_observation_MsgOsr.rs rename to rust/sbp/tests/integration/auto_check_sbp_observation_msg_osr.rs index b9bcc5360b..dc01aceebd 100644 --- a/rust/sbp/tests/auto_check_sbp_observation_MsgOsr.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_osr.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/observation/test_MsgOsr.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_observation_MsgOsr() { +fn test_auto_check_sbp_observation_msg_osr() { { let mut payload = Cursor::new(vec![ 85, 64, 6, 0, 0, 239, 248, 225, 233, 29, 0, 0, 0, 0, 104, 8, 64, 75, 143, 241, 68, 230, @@ -45,14 +38,14 @@ fn test_auto_check_sbp_observation_MsgOsr() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgOsr(msg) => { + sbp::messages::Sbp::MsgOsr(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x640, "Incorrect message type, expected 0x640, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0, "incorrect sender id, expected 0, is {}", @@ -79,19 +72,19 @@ fn test_auto_check_sbp_observation_MsgOsr() { msg.header.t.wn ); assert_eq!( - msg.obs[0].L.f, 66, - "incorrect value for obs[0].L.f, expected 66, is {}", - msg.obs[0].L.f + msg.obs[0].l.f, 66, + "incorrect value for obs[0].l.f, expected 66, is {}", + msg.obs[0].l.f ); assert_eq!( - msg.obs[0].L.i, 121567974, - "incorrect value for obs[0].L.i, expected 121567974, is {}", - msg.obs[0].L.i + msg.obs[0].l.i, 121567974, + "incorrect value for obs[0].l.i, expected 121567974, is {}", + msg.obs[0].l.i ); assert_eq!( - msg.obs[0].P, 1156681547, - "incorrect value for obs[0].P, expected 1156681547, is {}", - msg.obs[0].P + msg.obs[0].p, 1156681547, + "incorrect value for obs[0].p, expected 1156681547, is {}", + msg.obs[0].p ); assert_eq!( msg.obs[0].flags, 3, @@ -129,19 +122,19 @@ fn test_auto_check_sbp_observation_MsgOsr() { msg.obs[0].tropo_std ); assert_eq!( - msg.obs[1].L.f, 75, - "incorrect value for obs[1].L.f, expected 75, is {}", - msg.obs[1].L.f + msg.obs[1].l.f, 75, + "incorrect value for obs[1].l.f, expected 75, is {}", + msg.obs[1].l.f ); assert_eq!( - msg.obs[1].L.i, 111817196, - "incorrect value for obs[1].L.i, expected 111817196, is {}", - msg.obs[1].L.i + msg.obs[1].l.i, 111817196, + "incorrect value for obs[1].l.i, expected 111817196, is {}", + msg.obs[1].l.i ); assert_eq!( - msg.obs[1].P, 1063905486, - "incorrect value for obs[1].P, expected 1063905486, is {}", - msg.obs[1].P + msg.obs[1].p, 1063905486, + "incorrect value for obs[1].p, expected 1063905486, is {}", + msg.obs[1].p ); assert_eq!( msg.obs[1].flags, 3, @@ -179,19 +172,19 @@ fn test_auto_check_sbp_observation_MsgOsr() { msg.obs[1].tropo_std ); assert_eq!( - msg.obs[2].L.f, 128, - "incorrect value for obs[2].L.f, expected 128, is {}", - msg.obs[2].L.f + msg.obs[2].l.f, 128, + "incorrect value for obs[2].l.f, expected 128, is {}", + msg.obs[2].l.f ); assert_eq!( - msg.obs[2].L.i, 110692129, - "incorrect value for obs[2].L.i, expected 110692129, is {}", - msg.obs[2].L.i + msg.obs[2].l.i, 110692129, + "incorrect value for obs[2].l.i, expected 110692129, is {}", + msg.obs[2].l.i ); assert_eq!( - msg.obs[2].P, 1053200685, - "incorrect value for obs[2].P, expected 1053200685, is {}", - msg.obs[2].P + msg.obs[2].p, 1053200685, + "incorrect value for obs[2].p, expected 1053200685, is {}", + msg.obs[2].p ); assert_eq!( msg.obs[2].flags, 3, @@ -229,19 +222,19 @@ fn test_auto_check_sbp_observation_MsgOsr() { msg.obs[2].tropo_std ); assert_eq!( - msg.obs[3].L.f, 127, - "incorrect value for obs[3].L.f, expected 127, is {}", - msg.obs[3].L.f + msg.obs[3].l.f, 127, + "incorrect value for obs[3].l.f, expected 127, is {}", + msg.obs[3].l.f ); assert_eq!( - msg.obs[3].L.i, 119549583, - "incorrect value for obs[3].L.i, expected 119549583, is {}", - msg.obs[3].L.i + msg.obs[3].l.i, 119549583, + "incorrect value for obs[3].l.i, expected 119549583, is {}", + msg.obs[3].l.i ); assert_eq!( - msg.obs[3].P, 1137476697, - "incorrect value for obs[3].P, expected 1137476697, is {}", - msg.obs[3].P + msg.obs[3].p, 1137476697, + "incorrect value for obs[3].p, expected 1137476697, is {}", + msg.obs[3].p ); assert_eq!( msg.obs[3].flags, 3, @@ -279,19 +272,19 @@ fn test_auto_check_sbp_observation_MsgOsr() { msg.obs[3].tropo_std ); assert_eq!( - msg.obs[4].L.f, 55, - "incorrect value for obs[4].L.f, expected 55, is {}", - msg.obs[4].L.f + msg.obs[4].l.f, 55, + "incorrect value for obs[4].l.f, expected 55, is {}", + msg.obs[4].l.f ); assert_eq!( - msg.obs[4].L.i, 106934294, - "incorrect value for obs[4].L.i, expected 106934294, is {}", - msg.obs[4].L.i + msg.obs[4].l.i, 106934294, + "incorrect value for obs[4].l.i, expected 106934294, is {}", + msg.obs[4].l.i ); assert_eq!( - msg.obs[4].P, 1017446132, - "incorrect value for obs[4].P, expected 1017446132, is {}", - msg.obs[4].P + msg.obs[4].p, 1017446132, + "incorrect value for obs[4].p, expected 1017446132, is {}", + msg.obs[4].p ); assert_eq!( msg.obs[4].flags, 3, @@ -329,19 +322,19 @@ fn test_auto_check_sbp_observation_MsgOsr() { msg.obs[4].tropo_std ); assert_eq!( - msg.obs[5].L.f, 108, - "incorrect value for obs[5].L.f, expected 108, is {}", - msg.obs[5].L.f + msg.obs[5].l.f, 108, + "incorrect value for obs[5].l.f, expected 108, is {}", + msg.obs[5].l.f ); assert_eq!( - msg.obs[5].L.i, 110024343, - "incorrect value for obs[5].L.i, expected 110024343, is {}", - msg.obs[5].L.i + msg.obs[5].l.i, 110024343, + "incorrect value for obs[5].l.i, expected 110024343, is {}", + msg.obs[5].l.i ); assert_eq!( - msg.obs[5].P, 1046846826, - "incorrect value for obs[5].P, expected 1046846826, is {}", - msg.obs[5].P + msg.obs[5].p, 1046846826, + "incorrect value for obs[5].p, expected 1046846826, is {}", + msg.obs[5].p ); assert_eq!( msg.obs[5].flags, 3, @@ -379,19 +372,19 @@ fn test_auto_check_sbp_observation_MsgOsr() { msg.obs[5].tropo_std ); assert_eq!( - msg.obs[6].L.f, 206, - "incorrect value for obs[6].L.f, expected 206, is {}", - msg.obs[6].L.f + msg.obs[6].l.f, 206, + "incorrect value for obs[6].l.f, expected 206, is {}", + msg.obs[6].l.f ); assert_eq!( - msg.obs[6].L.i, 111507381, - "incorrect value for obs[6].L.i, expected 111507381, is {}", - msg.obs[6].L.i + msg.obs[6].l.i, 111507381, + "incorrect value for obs[6].l.i, expected 111507381, is {}", + msg.obs[6].l.i ); assert_eq!( - msg.obs[6].P, 1060957521, - "incorrect value for obs[6].P, expected 1060957521, is {}", - msg.obs[6].P + msg.obs[6].p, 1060957521, + "incorrect value for obs[6].p, expected 1060957521, is {}", + msg.obs[6].p ); assert_eq!( msg.obs[6].flags, 3, @@ -429,19 +422,19 @@ fn test_auto_check_sbp_observation_MsgOsr() { msg.obs[6].tropo_std ); assert_eq!( - msg.obs[7].L.f, 200, - "incorrect value for obs[7].L.f, expected 200, is {}", - msg.obs[7].L.f + msg.obs[7].l.f, 200, + "incorrect value for obs[7].l.f, expected 200, is {}", + msg.obs[7].l.f ); assert_eq!( - msg.obs[7].L.i, 113614775, - "incorrect value for obs[7].L.i, expected 113614775, is {}", - msg.obs[7].L.i + msg.obs[7].l.i, 113614775, + "incorrect value for obs[7].l.i, expected 113614775, is {}", + msg.obs[7].l.i ); assert_eq!( - msg.obs[7].P, 1081009286, - "incorrect value for obs[7].P, expected 1081009286, is {}", - msg.obs[7].P + msg.obs[7].p, 1081009286, + "incorrect value for obs[7].p, expected 1081009286, is {}", + msg.obs[7].p ); assert_eq!( msg.obs[7].flags, 3, @@ -479,19 +472,19 @@ fn test_auto_check_sbp_observation_MsgOsr() { msg.obs[7].tropo_std ); assert_eq!( - msg.obs[8].L.f, 170, - "incorrect value for obs[8].L.f, expected 170, is {}", - msg.obs[8].L.f + msg.obs[8].l.f, 170, + "incorrect value for obs[8].l.f, expected 170, is {}", + msg.obs[8].l.f ); assert_eq!( - msg.obs[8].L.i, 94728270, - "incorrect value for obs[8].L.i, expected 94728270, is {}", - msg.obs[8].L.i + msg.obs[8].l.i, 94728270, + "incorrect value for obs[8].l.i, expected 94728270, is {}", + msg.obs[8].l.i ); assert_eq!( - msg.obs[8].P, 1156681781, - "incorrect value for obs[8].P, expected 1156681781, is {}", - msg.obs[8].P + msg.obs[8].p, 1156681781, + "incorrect value for obs[8].p, expected 1156681781, is {}", + msg.obs[8].p ); assert_eq!( msg.obs[8].flags, 3, @@ -529,19 +522,19 @@ fn test_auto_check_sbp_observation_MsgOsr() { msg.obs[8].tropo_std ); assert_eq!( - msg.obs[9].L.f, 129, - "incorrect value for obs[9].L.f, expected 129, is {}", - msg.obs[9].L.f + msg.obs[9].l.f, 129, + "incorrect value for obs[9].l.f, expected 129, is {}", + msg.obs[9].l.f ); assert_eq!( - msg.obs[9].L.i, 87130275, - "incorrect value for obs[9].L.i, expected 87130275, is {}", - msg.obs[9].L.i + msg.obs[9].l.i, 87130275, + "incorrect value for obs[9].l.i, expected 87130275, is {}", + msg.obs[9].l.i ); assert_eq!( - msg.obs[9].P, 1063905531, - "incorrect value for obs[9].P, expected 1063905531, is {}", - msg.obs[9].P + msg.obs[9].p, 1063905531, + "incorrect value for obs[9].p, expected 1063905531, is {}", + msg.obs[9].p ); assert_eq!( msg.obs[9].flags, 3, @@ -579,19 +572,19 @@ fn test_auto_check_sbp_observation_MsgOsr() { msg.obs[9].tropo_std ); assert_eq!( - msg.obs[10].L.f, 46, - "incorrect value for obs[10].L.f, expected 46, is {}", - msg.obs[10].L.f + msg.obs[10].l.f, 46, + "incorrect value for obs[10].l.f, expected 46, is {}", + msg.obs[10].l.f ); assert_eq!( - msg.obs[10].L.i, 86253605, - "incorrect value for obs[10].L.i, expected 86253605, is {}", - msg.obs[10].L.i + msg.obs[10].l.i, 86253605, + "incorrect value for obs[10].l.i, expected 86253605, is {}", + msg.obs[10].l.i ); assert_eq!( - msg.obs[10].P, 1053200752, - "incorrect value for obs[10].P, expected 1053200752, is {}", - msg.obs[10].P + msg.obs[10].p, 1053200752, + "incorrect value for obs[10].p, expected 1053200752, is {}", + msg.obs[10].p ); assert_eq!( msg.obs[10].flags, 3, @@ -629,19 +622,19 @@ fn test_auto_check_sbp_observation_MsgOsr() { msg.obs[10].tropo_std ); assert_eq!( - msg.obs[11].L.f, 95, - "incorrect value for obs[11].L.f, expected 95, is {}", - msg.obs[11].L.f + msg.obs[11].l.f, 95, + "incorrect value for obs[11].l.f, expected 95, is {}", + msg.obs[11].l.f ); assert_eq!( - msg.obs[11].L.i, 93155512, - "incorrect value for obs[11].L.i, expected 93155512, is {}", - msg.obs[11].L.i + msg.obs[11].l.i, 93155512, + "incorrect value for obs[11].l.i, expected 93155512, is {}", + msg.obs[11].l.i ); assert_eq!( - msg.obs[11].P, 1137476774, - "incorrect value for obs[11].P, expected 1137476774, is {}", - msg.obs[11].P + msg.obs[11].p, 1137476774, + "incorrect value for obs[11].p, expected 1137476774, is {}", + msg.obs[11].p ); assert_eq!( msg.obs[11].flags, 3, @@ -681,7 +674,7 @@ fn test_auto_check_sbp_observation_MsgOsr() { } _ => panic!("Invalid message type! Expected a MsgOsr"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_observation_MsgSvAzEl.rs b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_sv_az_el.rs similarity index 98% rename from rust/sbp/tests/auto_check_sbp_observation_MsgSvAzEl.rs rename to rust/sbp/tests/integration/auto_check_sbp_observation_msg_sv_az_el.rs index 6fb021572a..e9f0e0cb76 100644 --- a/rust/sbp/tests/auto_check_sbp_observation_MsgSvAzEl.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_observation_msg_sv_az_el.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/observation/test_MsgSvAzEl.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_observation_MsgSvAzEl() { +fn test_auto_check_sbp_observation_msg_sv_az_el() { { let mut payload = Cursor::new(vec![ 85, 151, 0, 207, 121, 132, 8, 0, 160, 12, 10, 0, 139, 66, 13, 0, 16, 1, 15, 0, 24, 25, @@ -41,14 +34,14 @@ fn test_auto_check_sbp_observation_MsgSvAzEl() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgSvAzEl(msg) => { + sbp::messages::Sbp::MsgSvAzEl(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x97, "Incorrect message type, expected 0x97, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x79CF, "incorrect sender id, expected 0x79CF, is {}", @@ -717,7 +710,7 @@ fn test_auto_check_sbp_observation_MsgSvAzEl() { } _ => panic!("Invalid message type! Expected a MsgSvAzEl"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_orientation_MsgAngularRate.rs b/rust/sbp/tests/integration/auto_check_sbp_orientation_msg_angular_rate.rs similarity index 82% rename from rust/sbp/tests/auto_check_sbp_orientation_MsgAngularRate.rs rename to rust/sbp/tests/integration/auto_check_sbp_orientation_msg_angular_rate.rs index 6e4f3d1ac5..be245a5c9b 100644 --- a/rust/sbp/tests/auto_check_sbp_orientation_MsgAngularRate.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_orientation_msg_angular_rate.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/orientation/test_MsgAngularRate.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_orientation_MsgAngularRate() { +fn test_auto_check_sbp_orientation_msg_angular_rate() { { let mut payload = Cursor::new(vec![ 85, 34, 2, 66, 0, 17, 2, 0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 2, 0, 0, 0, 0, 88, 70, @@ -35,14 +28,14 @@ fn test_auto_check_sbp_orientation_MsgAngularRate() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgAngularRate(msg) => { + sbp::messages::Sbp::MsgAngularRate(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x222, "Incorrect message type, expected 0x222, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x42, "incorrect sender id, expected 0x42, is {}", @@ -64,7 +57,7 @@ fn test_auto_check_sbp_orientation_MsgAngularRate() { } _ => panic!("Invalid message type! Expected a MsgAngularRate"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_orientation_MsgOrientEuler.rs b/rust/sbp/tests/integration/auto_check_sbp_orientation_msg_orient_euler.rs similarity index 87% rename from rust/sbp/tests/auto_check_sbp_orientation_MsgOrientEuler.rs rename to rust/sbp/tests/integration/auto_check_sbp_orientation_msg_orient_euler.rs index 7f9b95ec1b..e07c4b4ae9 100644 --- a/rust/sbp/tests/auto_check_sbp_orientation_MsgOrientEuler.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_orientation_msg_orient_euler.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/orientation/test_MsgOrientEuler.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_orientation_MsgOrientEuler() { +fn test_auto_check_sbp_orientation_msg_orient_euler() { { let mut payload = Cursor::new(vec![ 85, 33, 2, 66, 0, 29, 1, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 0, 0, 224, 64, 0, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_orientation_MsgOrientEuler() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgOrientEuler(msg) => { + sbp::messages::Sbp::MsgOrientEuler(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x221, "Incorrect message type, expected 0x221, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x42, "incorrect sender id, expected 0x42, is {}", @@ -92,7 +85,7 @@ fn test_auto_check_sbp_orientation_MsgOrientEuler() { } _ => panic!("Invalid message type! Expected a MsgOrientEuler"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_orientation_MsgOrientQuat.rs b/rust/sbp/tests/integration/auto_check_sbp_orientation_msg_orient_quat.rs similarity index 88% rename from rust/sbp/tests/auto_check_sbp_orientation_MsgOrientQuat.rs rename to rust/sbp/tests/integration/auto_check_sbp_orientation_msg_orient_quat.rs index 34fff28ce3..a3931bc23e 100644 --- a/rust/sbp/tests/auto_check_sbp_orientation_MsgOrientQuat.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_orientation_msg_orient_quat.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/orientation/test_MsgOrientQuat.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_orientation_MsgOrientQuat() { +fn test_auto_check_sbp_orientation_msg_orient_quat() { { let mut payload = Cursor::new(vec![ 85, 32, 2, 66, 0, 37, 0, 0, 0, 0, 3, 0, 0, 0, 7, 0, 0, 0, 8, 0, 0, 0, 4, 0, 0, 0, 0, 0, @@ -36,14 +29,14 @@ fn test_auto_check_sbp_orientation_MsgOrientQuat() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgOrientQuat(msg) => { + sbp::messages::Sbp::MsgOrientQuat(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x220, "Incorrect message type, expected 0x220, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x42, "incorrect sender id, expected 0x42, is {}", @@ -86,7 +79,7 @@ fn test_auto_check_sbp_orientation_MsgOrientQuat() { } _ => panic!("Invalid message type! Expected a MsgOrientQuat"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_piksi_MsgDeviceMonitor.rs b/rust/sbp/tests/integration/auto_check_sbp_piksi_msg_device_monitor.rs similarity index 87% rename from rust/sbp/tests/auto_check_sbp_piksi_MsgDeviceMonitor.rs rename to rust/sbp/tests/integration/auto_check_sbp_piksi_msg_device_monitor.rs index aadab2a661..d59a42f468 100644 --- a/rust/sbp/tests/auto_check_sbp_piksi_MsgDeviceMonitor.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_piksi_msg_device_monitor.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/piksi/test_MsgDeviceMonitor.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_piksi_MsgDeviceMonitor() { +fn test_auto_check_sbp_piksi_msg_device_monitor() { { let mut payload = Cursor::new(vec![ 85, 181, 0, 95, 66, 10, 241, 216, 219, 3, 253, 6, 21, 24, 168, 18, 207, 233, @@ -35,14 +28,14 @@ fn test_auto_check_sbp_piksi_MsgDeviceMonitor() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgDeviceMonitor(msg) => { + sbp::messages::Sbp::MsgDeviceMonitor(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0xb5, "Incorrect message type, expected 0xb5, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x425f, "incorrect sender id, expected 0x425f, is {}", @@ -76,7 +69,7 @@ fn test_auto_check_sbp_piksi_MsgDeviceMonitor() { } _ => panic!("Invalid message type! Expected a MsgDeviceMonitor"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -92,14 +85,14 @@ fn test_auto_check_sbp_piksi_MsgDeviceMonitor() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgDeviceMonitor(msg) => { + sbp::messages::Sbp::MsgDeviceMonitor(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0xb5, "Incorrect message type, expected 0xb5, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x425f, "incorrect sender id, expected 0x425f, is {}", @@ -133,7 +126,7 @@ fn test_auto_check_sbp_piksi_MsgDeviceMonitor() { } _ => panic!("Invalid message type! Expected a MsgDeviceMonitor"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -149,14 +142,14 @@ fn test_auto_check_sbp_piksi_MsgDeviceMonitor() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgDeviceMonitor(msg) => { + sbp::messages::Sbp::MsgDeviceMonitor(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0xb5, "Incorrect message type, expected 0xb5, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x425f, "incorrect sender id, expected 0x425f, is {}", @@ -190,7 +183,7 @@ fn test_auto_check_sbp_piksi_MsgDeviceMonitor() { } _ => panic!("Invalid message type! Expected a MsgDeviceMonitor"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -206,14 +199,14 @@ fn test_auto_check_sbp_piksi_MsgDeviceMonitor() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgDeviceMonitor(msg) => { + sbp::messages::Sbp::MsgDeviceMonitor(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0xb5, "Incorrect message type, expected 0xb5, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x425f, "incorrect sender id, expected 0x425f, is {}", @@ -247,7 +240,7 @@ fn test_auto_check_sbp_piksi_MsgDeviceMonitor() { } _ => panic!("Invalid message type! Expected a MsgDeviceMonitor"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -263,14 +256,14 @@ fn test_auto_check_sbp_piksi_MsgDeviceMonitor() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgDeviceMonitor(msg) => { + sbp::messages::Sbp::MsgDeviceMonitor(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0xb5, "Incorrect message type, expected 0xb5, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x425f, "incorrect sender id, expected 0x425f, is {}", @@ -304,7 +297,7 @@ fn test_auto_check_sbp_piksi_MsgDeviceMonitor() { } _ => panic!("Invalid message type! Expected a MsgDeviceMonitor"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_piksi_MsgIarState.rs b/rust/sbp/tests/integration/auto_check_sbp_piksi_msg_iar_state.rs similarity index 80% rename from rust/sbp/tests/auto_check_sbp_piksi_MsgIarState.rs rename to rust/sbp/tests/integration/auto_check_sbp_piksi_msg_iar_state.rs index 0bec97a7f0..a26bba3075 100644 --- a/rust/sbp/tests/auto_check_sbp_piksi_MsgIarState.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_piksi_msg_iar_state.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/piksi/test_MsgIarState.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_piksi_MsgIarState() { +fn test_auto_check_sbp_piksi_msg_iar_state() { { let mut payload = Cursor::new(vec![85, 25, 0, 246, 215, 4, 1, 0, 0, 0, 216, 140]); @@ -33,14 +26,14 @@ fn test_auto_check_sbp_piksi_MsgIarState() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgIarState(msg) => { + sbp::messages::Sbp::MsgIarState(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x19, "Incorrect message type, expected 0x19, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -54,7 +47,7 @@ fn test_auto_check_sbp_piksi_MsgIarState() { } _ => panic!("Invalid message type! Expected a MsgIarState"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -68,14 +61,14 @@ fn test_auto_check_sbp_piksi_MsgIarState() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgIarState(msg) => { + sbp::messages::Sbp::MsgIarState(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x19, "Incorrect message type, expected 0x19, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -89,7 +82,7 @@ fn test_auto_check_sbp_piksi_MsgIarState() { } _ => panic!("Invalid message type! Expected a MsgIarState"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -103,14 +96,14 @@ fn test_auto_check_sbp_piksi_MsgIarState() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgIarState(msg) => { + sbp::messages::Sbp::MsgIarState(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x19, "Incorrect message type, expected 0x19, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -124,7 +117,7 @@ fn test_auto_check_sbp_piksi_MsgIarState() { } _ => panic!("Invalid message type! Expected a MsgIarState"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -138,14 +131,14 @@ fn test_auto_check_sbp_piksi_MsgIarState() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgIarState(msg) => { + sbp::messages::Sbp::MsgIarState(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x19, "Incorrect message type, expected 0x19, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -159,7 +152,7 @@ fn test_auto_check_sbp_piksi_MsgIarState() { } _ => panic!("Invalid message type! Expected a MsgIarState"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -173,14 +166,14 @@ fn test_auto_check_sbp_piksi_MsgIarState() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgIarState(msg) => { + sbp::messages::Sbp::MsgIarState(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x19, "Incorrect message type, expected 0x19, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -194,7 +187,7 @@ fn test_auto_check_sbp_piksi_MsgIarState() { } _ => panic!("Invalid message type! Expected a MsgIarState"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -208,14 +201,14 @@ fn test_auto_check_sbp_piksi_MsgIarState() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgIarState(msg) => { + sbp::messages::Sbp::MsgIarState(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x19, "Incorrect message type, expected 0x19, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -229,7 +222,7 @@ fn test_auto_check_sbp_piksi_MsgIarState() { } _ => panic!("Invalid message type! Expected a MsgIarState"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -243,14 +236,14 @@ fn test_auto_check_sbp_piksi_MsgIarState() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgIarState(msg) => { + sbp::messages::Sbp::MsgIarState(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x19, "Incorrect message type, expected 0x19, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -264,7 +257,7 @@ fn test_auto_check_sbp_piksi_MsgIarState() { } _ => panic!("Invalid message type! Expected a MsgIarState"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_piksi_MsgNetworkBandwidthUsage.rs b/rust/sbp/tests/integration/auto_check_sbp_piksi_msg_network_bandwidth_usage.rs similarity index 79% rename from rust/sbp/tests/auto_check_sbp_piksi_MsgNetworkBandwidthUsage.rs rename to rust/sbp/tests/integration/auto_check_sbp_piksi_msg_network_bandwidth_usage.rs index e74f5e2b39..014367101a 100644 Binary files a/rust/sbp/tests/auto_check_sbp_piksi_MsgNetworkBandwidthUsage.rs and b/rust/sbp/tests/integration/auto_check_sbp_piksi_msg_network_bandwidth_usage.rs differ diff --git a/rust/sbp/tests/auto_check_sbp_piksi_MsgThreadState.rs b/rust/sbp/tests/integration/auto_check_sbp_piksi_msg_thread_state.rs similarity index 83% rename from rust/sbp/tests/auto_check_sbp_piksi_MsgThreadState.rs rename to rust/sbp/tests/integration/auto_check_sbp_piksi_msg_thread_state.rs index 95d155017a..812a3c6cef 100644 Binary files a/rust/sbp/tests/auto_check_sbp_piksi_MsgThreadState.rs and b/rust/sbp/tests/integration/auto_check_sbp_piksi_msg_thread_state.rs differ diff --git a/rust/sbp/tests/auto_check_sbp_piksi_MsgUartState.rs b/rust/sbp/tests/integration/auto_check_sbp_piksi_msg_uart_state.rs similarity index 94% rename from rust/sbp/tests/auto_check_sbp_piksi_MsgUartState.rs rename to rust/sbp/tests/integration/auto_check_sbp_piksi_msg_uart_state.rs index 99972c956f..9be936a0b5 100644 --- a/rust/sbp/tests/auto_check_sbp_piksi_MsgUartState.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_piksi_msg_uart_state.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/piksi/test_MsgUartState.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_piksi_MsgUartState() { +fn test_auto_check_sbp_piksi_msg_uart_state() { { let mut payload = Cursor::new(vec![ 85, 24, 0, 246, 215, 58, 26, 191, 93, 63, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 123, 50, 62, @@ -37,14 +30,14 @@ fn test_auto_check_sbp_piksi_MsgUartState() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgUartStateDepa(msg) => { + sbp::messages::Sbp::MsgUartStateDepa(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x18, "Incorrect message type, expected 0x18, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -139,7 +132,7 @@ fn test_auto_check_sbp_piksi_MsgUartState() { } _ => panic!("Invalid message type! Expected a MsgUartStateDepa"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -157,14 +150,14 @@ fn test_auto_check_sbp_piksi_MsgUartState() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgUartStateDepa(msg) => { + sbp::messages::Sbp::MsgUartStateDepa(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x18, "Incorrect message type, expected 0x18, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -259,7 +252,7 @@ fn test_auto_check_sbp_piksi_MsgUartState() { } _ => panic!("Invalid message type! Expected a MsgUartStateDepa"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_piksi_MsgUartStateDepA.rs b/rust/sbp/tests/integration/auto_check_sbp_piksi_msg_uart_state_dep_a.rs similarity index 95% rename from rust/sbp/tests/auto_check_sbp_piksi_MsgUartStateDepA.rs rename to rust/sbp/tests/integration/auto_check_sbp_piksi_msg_uart_state_dep_a.rs index 66480eff46..9d1efb42c6 100644 --- a/rust/sbp/tests/auto_check_sbp_piksi_MsgUartStateDepA.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_piksi_msg_uart_state_dep_a.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/piksi/test_MsgUartStateDepA.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_piksi_MsgUartStateDepA() { +fn test_auto_check_sbp_piksi_msg_uart_state_dep_a() { { let mut payload = Cursor::new(vec![ 85, 24, 0, 195, 4, 58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -37,14 +30,14 @@ fn test_auto_check_sbp_piksi_MsgUartStateDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgUartStateDepa(msg) => { + sbp::messages::Sbp::MsgUartStateDepa(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x18, "Incorrect message type, expected 0x18, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -139,7 +132,7 @@ fn test_auto_check_sbp_piksi_MsgUartStateDepA() { } _ => panic!("Invalid message type! Expected a MsgUartStateDepa"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -157,14 +150,14 @@ fn test_auto_check_sbp_piksi_MsgUartStateDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgUartStateDepa(msg) => { + sbp::messages::Sbp::MsgUartStateDepa(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x18, "Incorrect message type, expected 0x18, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -259,7 +252,7 @@ fn test_auto_check_sbp_piksi_MsgUartStateDepA() { } _ => panic!("Invalid message type! Expected a MsgUartStateDepa"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -277,14 +270,14 @@ fn test_auto_check_sbp_piksi_MsgUartStateDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgUartStateDepa(msg) => { + sbp::messages::Sbp::MsgUartStateDepa(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x18, "Incorrect message type, expected 0x18, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -379,7 +372,7 @@ fn test_auto_check_sbp_piksi_MsgUartStateDepA() { } _ => panic!("Invalid message type! Expected a MsgUartStateDepa"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -397,14 +390,14 @@ fn test_auto_check_sbp_piksi_MsgUartStateDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgUartStateDepa(msg) => { + sbp::messages::Sbp::MsgUartStateDepa(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x18, "Incorrect message type, expected 0x18, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -499,7 +492,7 @@ fn test_auto_check_sbp_piksi_MsgUartStateDepA() { } _ => panic!("Invalid message type! Expected a MsgUartStateDepa"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -517,14 +510,14 @@ fn test_auto_check_sbp_piksi_MsgUartStateDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgUartStateDepa(msg) => { + sbp::messages::Sbp::MsgUartStateDepa(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x18, "Incorrect message type, expected 0x18, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -619,7 +612,7 @@ fn test_auto_check_sbp_piksi_MsgUartStateDepA() { } _ => panic!("Invalid message type! Expected a MsgUartStateDepa"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -637,14 +630,14 @@ fn test_auto_check_sbp_piksi_MsgUartStateDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgUartStateDepa(msg) => { + sbp::messages::Sbp::MsgUartStateDepa(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x18, "Incorrect message type, expected 0x18, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -739,7 +732,7 @@ fn test_auto_check_sbp_piksi_MsgUartStateDepA() { } _ => panic!("Invalid message type! Expected a MsgUartStateDepa"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_sbas_MsgSbasRaw.rs b/rust/sbp/tests/integration/auto_check_sbp_sbas_msg_sbas_raw.rs similarity index 94% rename from rust/sbp/tests/auto_check_sbp_sbas_MsgSbasRaw.rs rename to rust/sbp/tests/integration/auto_check_sbp_sbas_msg_sbas_raw.rs index ec3f3daa56..b64222817f 100644 --- a/rust/sbp/tests/auto_check_sbp_sbas_MsgSbasRaw.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_sbas_msg_sbas_raw.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/sbas/test_MsgSbasRaw.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_sbas_MsgSbasRaw() { +fn test_auto_check_sbp_sbas_msg_sbas_raw() { { let mut payload = Cursor::new(vec![ 85, 119, 119, 28, 200, 34, 131, 2, 201, 228, 233, 29, 4, 23, 255, 0, 23, 255, 0, 23, @@ -37,14 +30,14 @@ fn test_auto_check_sbp_sbas_MsgSbasRaw() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgSbasRaw(msg) => { + sbp::messages::Sbp::MsgSbasRaw(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x7777, "Incorrect message type, expected 0x7777, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xc81c, "incorrect sender id, expected 0xc81c, is {}", @@ -208,7 +201,7 @@ fn test_auto_check_sbp_sbas_MsgSbasRaw() { } _ => panic!("Invalid message type! Expected a MsgSbasRaw"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_settings_MsgSettingsReadByIndexDone.rs b/rust/sbp/tests/integration/auto_check_sbp_settings_msg_settings_read_by_index_done.rs similarity index 76% rename from rust/sbp/tests/auto_check_sbp_settings_MsgSettingsReadByIndexDone.rs rename to rust/sbp/tests/integration/auto_check_sbp_settings_msg_settings_read_by_index_done.rs index 723b5219bf..edea1d0682 100644 --- a/rust/sbp/tests/auto_check_sbp_settings_MsgSettingsReadByIndexDone.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_settings_msg_settings_read_by_index_done.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/settings/test_MsgSettingsReadByIndexDone.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_settings_MsgSettingsReadByIndexDone() { +fn test_auto_check_sbp_settings_msg_settings_read_by_index_done() { { let mut payload = Cursor::new(vec![85, 166, 0, 246, 215, 0, 163, 58]); @@ -33,14 +26,14 @@ fn test_auto_check_sbp_settings_MsgSettingsReadByIndexDone() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgSettingsReadByIndexDone(msg) => { + sbp::messages::Sbp::MsgSettingsReadByIndexDone(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0xa6, "Incorrect message type, expected 0xa6, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -49,7 +42,7 @@ fn test_auto_check_sbp_settings_MsgSettingsReadByIndexDone() { } _ => panic!("Invalid message type! Expected a MsgSettingsReadByIndexDone"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_settings_MsgSettingsReadByIndexResp.rs b/rust/sbp/tests/integration/auto_check_sbp_settings_msg_settings_read_by_index_resp.rs similarity index 82% rename from rust/sbp/tests/auto_check_sbp_settings_MsgSettingsReadByIndexResp.rs rename to rust/sbp/tests/integration/auto_check_sbp_settings_msg_settings_read_by_index_resp.rs index 639290a36c..cd9e3c5c31 100644 Binary files a/rust/sbp/tests/auto_check_sbp_settings_MsgSettingsReadByIndexResp.rs and b/rust/sbp/tests/integration/auto_check_sbp_settings_msg_settings_read_by_index_resp.rs differ diff --git a/rust/sbp/tests/auto_check_sbp_system_MsgDgnssStatus.rs b/rust/sbp/tests/integration/auto_check_sbp_system_msg_dgnss_status.rs similarity index 82% rename from rust/sbp/tests/auto_check_sbp_system_MsgDgnssStatus.rs rename to rust/sbp/tests/integration/auto_check_sbp_system_msg_dgnss_status.rs index de67e74a0c..a3585bae81 100644 --- a/rust/sbp/tests/auto_check_sbp_system_MsgDgnssStatus.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_system_msg_dgnss_status.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/system/test_MsgDgnssStatus.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_system_MsgDgnssStatus() { +fn test_auto_check_sbp_system_msg_dgnss_status() { { let mut payload = Cursor::new(vec![ 85, 2, 255, 66, 0, 11, 0, 50, 0, 12, 83, 107, 121, 108, 97, 114, 107, 202, 1, @@ -35,14 +28,14 @@ fn test_auto_check_sbp_system_MsgDgnssStatus() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgDgnssStatus(msg) => { + sbp::messages::Sbp::MsgDgnssStatus(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0xff02, "Incorrect message type, expected 0xff02, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x42, "incorrect sender id, expected 0x42, is {}", @@ -64,7 +57,7 @@ fn test_auto_check_sbp_system_MsgDgnssStatus() { msg.num_signals ); assert_eq!( - Into::::into(msg.source.clone()), + msg.source.to_string(), "Skylark".to_string(), "incorrect value for msg.source, expected string '{}', is '{}'", "Skylark".to_string(), @@ -73,7 +66,7 @@ fn test_auto_check_sbp_system_MsgDgnssStatus() { } _ => panic!("Invalid message type! Expected a MsgDgnssStatus"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_system_MsgGroupMeta.rs b/rust/sbp/tests/integration/auto_check_sbp_system_msg_group_meta.rs similarity index 91% rename from rust/sbp/tests/auto_check_sbp_system_MsgGroupMeta.rs rename to rust/sbp/tests/integration/auto_check_sbp_system_msg_group_meta.rs index bd0a98f594..db48321cbc 100644 --- a/rust/sbp/tests/auto_check_sbp_system_MsgGroupMeta.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_system_msg_group_meta.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/system/test_MsgGroupMeta.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_system_MsgGroupMeta() { +fn test_auto_check_sbp_system_msg_group_meta() { { let mut payload = Cursor::new(vec![ 85, 10, 255, 238, 238, 9, 1, 2, 3, 10, 255, 10, 2, 2, 255, 2, 14, @@ -35,14 +28,14 @@ fn test_auto_check_sbp_system_MsgGroupMeta() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGroupMeta(msg) => { + sbp::messages::Sbp::MsgGroupMeta(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0xFF0A, "Incorrect message type, expected 0xFF0A, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xEEEE, "incorrect sender id, expected 0xEEEE, is {}", @@ -81,7 +74,7 @@ fn test_auto_check_sbp_system_MsgGroupMeta() { } _ => panic!("Invalid message type! Expected a MsgGroupMeta"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -98,14 +91,14 @@ fn test_auto_check_sbp_system_MsgGroupMeta() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgGroupMeta(msg) => { + sbp::messages::Sbp::MsgGroupMeta(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0xFF0A, "Incorrect message type, expected 0xFF0A, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x315, "incorrect sender id, expected 0x315, is {}", @@ -199,7 +192,7 @@ fn test_auto_check_sbp_system_MsgGroupMeta() { } _ => panic!("Invalid message type! Expected a MsgGroupMeta"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_system_MsgHeartbeat.rs b/rust/sbp/tests/integration/auto_check_sbp_system_msg_heartbeat.rs similarity index 79% rename from rust/sbp/tests/auto_check_sbp_system_MsgHeartbeat.rs rename to rust/sbp/tests/integration/auto_check_sbp_system_msg_heartbeat.rs index 00d9a60b52..da5eb95b8a 100644 --- a/rust/sbp/tests/auto_check_sbp_system_MsgHeartbeat.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_system_msg_heartbeat.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/system/test_MsgHeartbeat.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_system_MsgHeartbeat() { +fn test_auto_check_sbp_system_msg_heartbeat() { { let mut payload = Cursor::new(vec![85, 255, 255, 246, 215, 4, 0, 50, 0, 0, 249, 216]); @@ -33,14 +26,14 @@ fn test_auto_check_sbp_system_MsgHeartbeat() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgHeartbeat(msg) => { + sbp::messages::Sbp::MsgHeartbeat(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0xffff, "Incorrect message type, expected 0xffff, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -54,7 +47,7 @@ fn test_auto_check_sbp_system_MsgHeartbeat() { } _ => panic!("Invalid message type! Expected a MsgHeartbeat"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -68,14 +61,14 @@ fn test_auto_check_sbp_system_MsgHeartbeat() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgHeartbeat(msg) => { + sbp::messages::Sbp::MsgHeartbeat(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0xffff, "Incorrect message type, expected 0xffff, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -89,7 +82,7 @@ fn test_auto_check_sbp_system_MsgHeartbeat() { } _ => panic!("Invalid message type! Expected a MsgHeartbeat"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_system_MsgInsStatus.rs b/rust/sbp/tests/integration/auto_check_sbp_system_msg_ins_status.rs similarity index 79% rename from rust/sbp/tests/auto_check_sbp_system_MsgInsStatus.rs rename to rust/sbp/tests/integration/auto_check_sbp_system_msg_ins_status.rs index 3540470864..99a7baaf8e 100644 --- a/rust/sbp/tests/auto_check_sbp_system_MsgInsStatus.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_system_msg_ins_status.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/system/test_MsgInsStatus.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_system_MsgInsStatus() { +fn test_auto_check_sbp_system_msg_ins_status() { { let mut payload = Cursor::new(vec![85, 3, 255, 21, 3, 4, 9, 0, 0, 32, 36, 103]); @@ -33,14 +26,14 @@ fn test_auto_check_sbp_system_MsgInsStatus() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgInsStatus(msg) => { + sbp::messages::Sbp::MsgInsStatus(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0xff03, "Incorrect message type, expected 0xff03, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x315, "incorrect sender id, expected 0x315, is {}", @@ -54,7 +47,7 @@ fn test_auto_check_sbp_system_MsgInsStatus() { } _ => panic!("Invalid message type! Expected a MsgInsStatus"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_system_MsgInsUpdates.rs b/rust/sbp/tests/integration/auto_check_sbp_system_msg_ins_updates.rs similarity index 86% rename from rust/sbp/tests/auto_check_sbp_system_MsgInsUpdates.rs rename to rust/sbp/tests/integration/auto_check_sbp_system_msg_ins_updates.rs index 85d2e9f560..ad45d3af42 100644 --- a/rust/sbp/tests/auto_check_sbp_system_MsgInsUpdates.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_system_msg_ins_updates.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/system/test_MsgInsUpdates.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_system_MsgInsUpdates() { +fn test_auto_check_sbp_system_msg_ins_updates() { { let mut payload = Cursor::new(vec![ 85, 6, 255, 21, 3, 10, 84, 229, 17, 30, 0, 0, 0, 0, 0, 0, 81, 63, @@ -35,14 +28,14 @@ fn test_auto_check_sbp_system_MsgInsUpdates() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgInsUpdates(msg) => { + sbp::messages::Sbp::MsgInsUpdates(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0xff06, "Incorrect message type, expected 0xff06, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x315, "incorrect sender id, expected 0x315, is {}", @@ -86,7 +79,7 @@ fn test_auto_check_sbp_system_MsgInsUpdates() { } _ => panic!("Invalid message type! Expected a MsgInsUpdates"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_system_MsgStartup.rs b/rust/sbp/tests/integration/auto_check_sbp_system_msg_startup.rs similarity index 83% rename from rust/sbp/tests/auto_check_sbp_system_MsgStartup.rs rename to rust/sbp/tests/integration/auto_check_sbp_system_msg_startup.rs index d0c7f819dd..9fee89486c 100644 --- a/rust/sbp/tests/auto_check_sbp_system_MsgStartup.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_system_msg_startup.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/system/test_MsgStartup.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_system_MsgStartup() { +fn test_auto_check_sbp_system_msg_startup() { { let mut payload = Cursor::new(vec![85, 0, 255, 66, 0, 4, 0, 0, 0, 0, 70, 160]); @@ -33,14 +26,14 @@ fn test_auto_check_sbp_system_MsgStartup() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgStartup(msg) => { + sbp::messages::Sbp::MsgStartup(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0xff00, "Incorrect message type, expected 0xff00, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x42, "incorrect sender id, expected 0x42, is {}", @@ -64,7 +57,7 @@ fn test_auto_check_sbp_system_MsgStartup() { } _ => panic!("Invalid message type! Expected a MsgStartup"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -78,14 +71,14 @@ fn test_auto_check_sbp_system_MsgStartup() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgStartup(msg) => { + sbp::messages::Sbp::MsgStartup(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0xff00, "Incorrect message type, expected 0xff00, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -109,7 +102,7 @@ fn test_auto_check_sbp_system_MsgStartup() { } _ => panic!("Invalid message type! Expected a MsgStartup"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_tracking_MsgMeasurementState.rs b/rust/sbp/tests/integration/auto_check_sbp_tracking_msg_measurement_state.rs similarity index 99% rename from rust/sbp/tests/auto_check_sbp_tracking_MsgMeasurementState.rs rename to rust/sbp/tests/integration/auto_check_sbp_tracking_msg_measurement_state.rs index 571aa8593c..63b1b4deaf 100644 --- a/rust/sbp/tests/auto_check_sbp_tracking_MsgMeasurementState.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_tracking_msg_measurement_state.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/tracking/test_MsgMeasurementState.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_tracking_MsgMeasurementState() { +fn test_auto_check_sbp_tracking_msg_measurement_state() { { let mut payload = Cursor::new(vec![ 85, 97, 0, 207, 121, 237, 29, 0, 162, 0, 0, 0, 0, 0, 0, 27, 0, 201, 20, 0, 168, 32, 0, @@ -45,14 +38,14 @@ fn test_auto_check_sbp_tracking_MsgMeasurementState() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgMeasurementState(msg) => { + sbp::messages::Sbp::MsgMeasurementState(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x61, "Incorrect message type, expected 0x61, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x79CF, "incorrect sender id, expected 0x79CF, is {}", @@ -1246,7 +1239,7 @@ fn test_auto_check_sbp_tracking_MsgMeasurementState() { } _ => panic!("Invalid message type! Expected a MsgMeasurementState"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_tracking_MsgTrackingState.rs b/rust/sbp/tests/integration/auto_check_sbp_tracking_msg_tracking_state.rs similarity index 97% rename from rust/sbp/tests/auto_check_sbp_tracking_MsgTrackingState.rs rename to rust/sbp/tests/integration/auto_check_sbp_tracking_msg_tracking_state.rs index 468e99880d..8ae65e7501 100644 --- a/rust/sbp/tests/auto_check_sbp_tracking_MsgTrackingState.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_tracking_msg_tracking_state.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/tracking/test_MsgTrackingState.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_tracking_MsgTrackingState() { +fn test_auto_check_sbp_tracking_msg_tracking_state() { { let mut payload = Cursor::new(vec![ 85, 19, 0, 246, 215, 99, 1, 202, 0, 0, 0, 197, 253, 28, 66, 1, 203, 0, 0, 0, 231, 99, @@ -39,14 +32,14 @@ fn test_auto_check_sbp_tracking_MsgTrackingState() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgTrackingStateDepB(msg) => { + sbp::messages::Sbp::MsgTrackingStateDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x13, "Incorrect message type, expected 0x13, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -326,7 +319,7 @@ fn test_auto_check_sbp_tracking_MsgTrackingState() { } _ => panic!("Invalid message type! Expected a MsgTrackingStateDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -346,14 +339,14 @@ fn test_auto_check_sbp_tracking_MsgTrackingState() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgTrackingStateDepB(msg) => { + sbp::messages::Sbp::MsgTrackingStateDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x13, "Incorrect message type, expected 0x13, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -633,7 +626,7 @@ fn test_auto_check_sbp_tracking_MsgTrackingState() { } _ => panic!("Invalid message type! Expected a MsgTrackingStateDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -653,14 +646,14 @@ fn test_auto_check_sbp_tracking_MsgTrackingState() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgTrackingStateDepB(msg) => { + sbp::messages::Sbp::MsgTrackingStateDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x13, "Incorrect message type, expected 0x13, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -940,7 +933,7 @@ fn test_auto_check_sbp_tracking_MsgTrackingState() { } _ => panic!("Invalid message type! Expected a MsgTrackingStateDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -960,14 +953,14 @@ fn test_auto_check_sbp_tracking_MsgTrackingState() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgTrackingStateDepB(msg) => { + sbp::messages::Sbp::MsgTrackingStateDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x13, "Incorrect message type, expected 0x13, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -1247,7 +1240,7 @@ fn test_auto_check_sbp_tracking_MsgTrackingState() { } _ => panic!("Invalid message type! Expected a MsgTrackingStateDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -1267,14 +1260,14 @@ fn test_auto_check_sbp_tracking_MsgTrackingState() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgTrackingStateDepB(msg) => { + sbp::messages::Sbp::MsgTrackingStateDepB(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x13, "Incorrect message type, expected 0x13, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0xd7f6, "incorrect sender id, expected 0xd7f6, is {}", @@ -1554,7 +1547,7 @@ fn test_auto_check_sbp_tracking_MsgTrackingState() { } _ => panic!("Invalid message type! Expected a MsgTrackingStateDepB"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_tracking_MsgTrackingStateDetailedDep.rs b/rust/sbp/tests/integration/auto_check_sbp_tracking_msg_tracking_state_detailed_dep.rs similarity index 87% rename from rust/sbp/tests/auto_check_sbp_tracking_MsgTrackingStateDetailedDep.rs rename to rust/sbp/tests/integration/auto_check_sbp_tracking_msg_tracking_state_detailed_dep.rs index e467addc05..6ded2d763e 100644 --- a/rust/sbp/tests/auto_check_sbp_tracking_MsgTrackingStateDetailedDep.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_tracking_msg_tracking_state_detailed_dep.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/tracking/test_MsgTrackingStateDetailedDep.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_tracking_MsgTrackingStateDetailedDep() { +fn test_auto_check_sbp_tracking_msg_tracking_state_detailed_dep() { { let mut payload = Cursor::new(vec![ 85, 17, 0, 59, 103, 55, 163, 151, 112, 215, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -37,34 +30,34 @@ fn test_auto_check_sbp_tracking_MsgTrackingStateDetailedDep() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgTrackingStateDetailedDep(msg) => { + sbp::messages::Sbp::MsgTrackingStateDetailedDep(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x11, "Incorrect message type, expected 0x11, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x673b, "incorrect sender id, expected 0x673b, is {}", sender_id ); assert_eq!( - msg.L.f, 169, - "incorrect value for L.f, expected 169, is {}", - msg.L.f + msg.l.f, 169, + "incorrect value for l.f, expected 169, is {}", + msg.l.f ); assert_eq!( - msg.L.i, 1319, - "incorrect value for L.i, expected 1319, is {}", - msg.L.i + msg.l.i, 1319, + "incorrect value for l.i, expected 1319, is {}", + msg.l.i ); - assert_eq!(msg.P, 0, "incorrect value for P, expected 0, is {}", msg.P); + assert_eq!(msg.p, 0, "incorrect value for p, expected 0, is {}", msg.p); assert_eq!( - msg.P_std, 0, - "incorrect value for P_std, expected 0, is {}", - msg.P_std + msg.p_std, 0, + "incorrect value for p_std, expected 0, is {}", + msg.p_std ); assert_eq!( msg.acceleration, 108, @@ -174,7 +167,7 @@ fn test_auto_check_sbp_tracking_MsgTrackingStateDetailedDep() { } _ => panic!("Invalid message type! Expected a MsgTrackingStateDetailedDep"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -192,34 +185,34 @@ fn test_auto_check_sbp_tracking_MsgTrackingStateDetailedDep() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgTrackingStateDetailedDep(msg) => { + sbp::messages::Sbp::MsgTrackingStateDetailedDep(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x11, "Incorrect message type, expected 0x11, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x673b, "incorrect sender id, expected 0x673b, is {}", sender_id ); assert_eq!( - msg.L.f, 14, - "incorrect value for L.f, expected 14, is {}", - msg.L.f + msg.l.f, 14, + "incorrect value for l.f, expected 14, is {}", + msg.l.f ); assert_eq!( - msg.L.i, 1810, - "incorrect value for L.i, expected 1810, is {}", - msg.L.i + msg.l.i, 1810, + "incorrect value for l.i, expected 1810, is {}", + msg.l.i ); - assert_eq!(msg.P, 0, "incorrect value for P, expected 0, is {}", msg.P); + assert_eq!(msg.p, 0, "incorrect value for p, expected 0, is {}", msg.p); assert_eq!( - msg.P_std, 0, - "incorrect value for P_std, expected 0, is {}", - msg.P_std + msg.p_std, 0, + "incorrect value for p_std, expected 0, is {}", + msg.p_std ); assert_eq!( msg.acceleration, -32, @@ -329,7 +322,7 @@ fn test_auto_check_sbp_tracking_MsgTrackingStateDetailedDep() { } _ => panic!("Invalid message type! Expected a MsgTrackingStateDetailedDep"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -347,34 +340,34 @@ fn test_auto_check_sbp_tracking_MsgTrackingStateDetailedDep() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgTrackingStateDetailedDep(msg) => { + sbp::messages::Sbp::MsgTrackingStateDetailedDep(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x11, "Incorrect message type, expected 0x11, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x673b, "incorrect sender id, expected 0x673b, is {}", sender_id ); assert_eq!( - msg.L.f, 8, - "incorrect value for L.f, expected 8, is {}", - msg.L.f + msg.l.f, 8, + "incorrect value for l.f, expected 8, is {}", + msg.l.f ); assert_eq!( - msg.L.i, 2298, - "incorrect value for L.i, expected 2298, is {}", - msg.L.i + msg.l.i, 2298, + "incorrect value for l.i, expected 2298, is {}", + msg.l.i ); - assert_eq!(msg.P, 0, "incorrect value for P, expected 0, is {}", msg.P); + assert_eq!(msg.p, 0, "incorrect value for p, expected 0, is {}", msg.p); assert_eq!( - msg.P_std, 0, - "incorrect value for P_std, expected 0, is {}", - msg.P_std + msg.p_std, 0, + "incorrect value for p_std, expected 0, is {}", + msg.p_std ); assert_eq!( msg.acceleration, 27, @@ -484,7 +477,7 @@ fn test_auto_check_sbp_tracking_MsgTrackingStateDetailedDep() { } _ => panic!("Invalid message type! Expected a MsgTrackingStateDetailedDep"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -502,34 +495,34 @@ fn test_auto_check_sbp_tracking_MsgTrackingStateDetailedDep() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgTrackingStateDetailedDep(msg) => { + sbp::messages::Sbp::MsgTrackingStateDetailedDep(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x11, "Incorrect message type, expected 0x11, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x673b, "incorrect sender id, expected 0x673b, is {}", sender_id ); assert_eq!( - msg.L.f, 125, - "incorrect value for L.f, expected 125, is {}", - msg.L.f + msg.l.f, 125, + "incorrect value for l.f, expected 125, is {}", + msg.l.f ); assert_eq!( - msg.L.i, 2786, - "incorrect value for L.i, expected 2786, is {}", - msg.L.i + msg.l.i, 2786, + "incorrect value for l.i, expected 2786, is {}", + msg.l.i ); - assert_eq!(msg.P, 0, "incorrect value for P, expected 0, is {}", msg.P); + assert_eq!(msg.p, 0, "incorrect value for p, expected 0, is {}", msg.p); assert_eq!( - msg.P_std, 0, - "incorrect value for P_std, expected 0, is {}", - msg.P_std + msg.p_std, 0, + "incorrect value for p_std, expected 0, is {}", + msg.p_std ); assert_eq!( msg.acceleration, -36, @@ -639,7 +632,7 @@ fn test_auto_check_sbp_tracking_MsgTrackingStateDetailedDep() { } _ => panic!("Invalid message type! Expected a MsgTrackingStateDetailedDep"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -657,34 +650,34 @@ fn test_auto_check_sbp_tracking_MsgTrackingStateDetailedDep() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgTrackingStateDetailedDep(msg) => { + sbp::messages::Sbp::MsgTrackingStateDetailedDep(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x11, "Incorrect message type, expected 0x11, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x673b, "incorrect sender id, expected 0x673b, is {}", sender_id ); assert_eq!( - msg.L.f, 64, - "incorrect value for L.f, expected 64, is {}", - msg.L.f + msg.l.f, 64, + "incorrect value for l.f, expected 64, is {}", + msg.l.f ); assert_eq!( - msg.L.i, 3275, - "incorrect value for L.i, expected 3275, is {}", - msg.L.i + msg.l.i, 3275, + "incorrect value for l.i, expected 3275, is {}", + msg.l.i ); - assert_eq!(msg.P, 0, "incorrect value for P, expected 0, is {}", msg.P); + assert_eq!(msg.p, 0, "incorrect value for p, expected 0, is {}", msg.p); assert_eq!( - msg.P_std, 0, - "incorrect value for P_std, expected 0, is {}", - msg.P_std + msg.p_std, 0, + "incorrect value for p_std, expected 0, is {}", + msg.p_std ); assert_eq!( msg.acceleration, 2, @@ -794,7 +787,7 @@ fn test_auto_check_sbp_tracking_MsgTrackingStateDetailedDep() { } _ => panic!("Invalid message type! Expected a MsgTrackingStateDetailedDep"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_tracking_MsgtrackingStateDepA.rs b/rust/sbp/tests/integration/auto_check_sbp_tracking_msgtracking_state_dep_a.rs similarity index 96% rename from rust/sbp/tests/auto_check_sbp_tracking_MsgtrackingStateDepA.rs rename to rust/sbp/tests/integration/auto_check_sbp_tracking_msgtracking_state_dep_a.rs index 9a6a526385..7262305eab 100644 --- a/rust/sbp/tests/auto_check_sbp_tracking_MsgtrackingStateDepA.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_tracking_msgtracking_state_dep_a.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/tracking/test_MsgtrackingStateDepA.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_tracking_MsgtrackingStateDepA() { +fn test_auto_check_sbp_tracking_msgtracking_state_dep_a() { { let mut payload = Cursor::new(vec![ 85, 22, 0, 195, 4, 66, 1, 0, 204, 177, 51, 65, 1, 2, 198, 4, 39, 65, 1, 3, 219, 182, @@ -38,14 +31,14 @@ fn test_auto_check_sbp_tracking_MsgtrackingStateDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgTrackingStateDepA(msg) => { + sbp::messages::Sbp::MsgTrackingStateDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x16, "Incorrect message type, expected 0x16, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -219,7 +212,7 @@ fn test_auto_check_sbp_tracking_MsgtrackingStateDepA() { } _ => panic!("Invalid message type! Expected a MsgTrackingStateDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -238,14 +231,14 @@ fn test_auto_check_sbp_tracking_MsgtrackingStateDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgTrackingStateDepA(msg) => { + sbp::messages::Sbp::MsgTrackingStateDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x16, "Incorrect message type, expected 0x16, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -419,7 +412,7 @@ fn test_auto_check_sbp_tracking_MsgtrackingStateDepA() { } _ => panic!("Invalid message type! Expected a MsgTrackingStateDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -438,14 +431,14 @@ fn test_auto_check_sbp_tracking_MsgtrackingStateDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgTrackingStateDepA(msg) => { + sbp::messages::Sbp::MsgTrackingStateDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x16, "Incorrect message type, expected 0x16, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -619,7 +612,7 @@ fn test_auto_check_sbp_tracking_MsgtrackingStateDepA() { } _ => panic!("Invalid message type! Expected a MsgTrackingStateDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -638,14 +631,14 @@ fn test_auto_check_sbp_tracking_MsgtrackingStateDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgTrackingStateDepA(msg) => { + sbp::messages::Sbp::MsgTrackingStateDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x16, "Incorrect message type, expected 0x16, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -815,7 +808,7 @@ fn test_auto_check_sbp_tracking_MsgtrackingStateDepA() { } _ => panic!("Invalid message type! Expected a MsgTrackingStateDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -834,14 +827,14 @@ fn test_auto_check_sbp_tracking_MsgtrackingStateDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgTrackingStateDepA(msg) => { + sbp::messages::Sbp::MsgTrackingStateDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x16, "Incorrect message type, expected 0x16, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -1011,7 +1004,7 @@ fn test_auto_check_sbp_tracking_MsgtrackingStateDepA() { } _ => panic!("Invalid message type! Expected a MsgTrackingStateDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } { @@ -1030,14 +1023,14 @@ fn test_auto_check_sbp_tracking_MsgtrackingStateDepA() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgTrackingStateDepA(msg) => { + sbp::messages::Sbp::MsgTrackingStateDepA(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x16, "Incorrect message type, expected 0x16, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x4c3, "incorrect sender id, expected 0x4c3, is {}", @@ -1207,7 +1200,7 @@ fn test_auto_check_sbp_tracking_MsgtrackingStateDepA() { } _ => panic!("Invalid message type! Expected a MsgTrackingStateDepA"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/auto_check_sbp_vehicle_MsgOdometry.rs b/rust/sbp/tests/integration/auto_check_sbp_vehicle_msg_odometry.rs similarity index 82% rename from rust/sbp/tests/auto_check_sbp_vehicle_MsgOdometry.rs rename to rust/sbp/tests/integration/auto_check_sbp_vehicle_msg_odometry.rs index efb256883e..352e98b932 100644 --- a/rust/sbp/tests/auto_check_sbp_vehicle_MsgOdometry.rs +++ b/rust/sbp/tests/integration/auto_check_sbp_vehicle_msg_odometry.rs @@ -11,17 +11,10 @@ // This file was auto-generated from spec/tests/yaml/swiftnav/sbp/vehicle/test_MsgOdometry.yaml by generate.py. Do not modify by hand! -use sbp::iter_messages; -use sbp::messages::SBPMessage; - -mod common; -#[allow(unused_imports)] -use common::AlmostEq; - -use std::io::Cursor; +use crate::*; #[test] -fn test_auto_check_sbp_vehicle_MsgOdometry() { +fn test_auto_check_sbp_vehicle_msg_odometry() { { let mut payload = Cursor::new(vec![85, 3, 9, 66, 0, 9, 8, 0, 0, 0, 7, 0, 0, 0, 1, 52, 99]); @@ -33,14 +26,14 @@ fn test_auto_check_sbp_vehicle_MsgOdometry() { .expect("failed to parse message") }; match &sbp_msg { - sbp::messages::SBP::MsgOdometry(msg) => { + sbp::messages::Sbp::MsgOdometry(msg) => { assert_eq!( - msg.get_message_type(), + msg.message_type(), 0x903, "Incorrect message type, expected 0x903, is {}", - msg.get_message_type() + msg.message_type() ); - let sender_id = msg.get_sender_id().unwrap(); + let sender_id = msg.sender_id().unwrap(); assert_eq!( sender_id, 0x42, "incorrect sender id, expected 0x42, is {}", @@ -64,7 +57,7 @@ fn test_auto_check_sbp_vehicle_MsgOdometry() { } _ => panic!("Invalid message type! Expected a MsgOdometry"), }; - let frame = sbp_msg.to_frame().unwrap(); + let frame = sbp::to_vec(&sbp_msg).unwrap(); assert_eq!(frame, payload.into_inner()); } } diff --git a/rust/sbp/tests/integration/main.rs b/rust/sbp/tests/integration/main.rs new file mode 100644 index 0000000000..977dcf4369 --- /dev/null +++ b/rust/sbp/tests/integration/main.rs @@ -0,0 +1,119 @@ +// +// Copyright (C) 2019-2021 Swift Navigation Inc. +// Contact: https://support.swiftnav.com +// +// This source is subject to the license found in the file 'LICENSE' which must +// be be distributed together with this source. All other rights reserved. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +// This file was auto-generated. Do not modify by hand! +mod auto_check_sbp_acquisition_msg_acq_result_dep_a; +mod auto_check_sbp_acquisition_msg_acq_result_dep_b; +mod auto_check_sbp_acquisition_msg_acq_result_dep_c; +mod auto_check_sbp_bootload_msg_bootloader_handshake_resp; +mod auto_check_sbp_ext_events_msg_ext_event; +mod auto_check_sbp_file_io_msg_fileio_write_resp; +mod auto_check_sbp_imu_msg_imu_aux; +mod auto_check_sbp_imu_msg_imu_raw; +mod auto_check_sbp_logging_msg_fwd; +mod auto_check_sbp_logging_msg_log; +mod auto_check_sbp_logging_msg_print_dep; +mod auto_check_sbp_navigation_msg_age_corrections; +mod auto_check_sbp_navigation_msg_baseline_ecef; +mod auto_check_sbp_navigation_msg_baseline_ecef_dep_a; +mod auto_check_sbp_navigation_msg_baseline_ned; +mod auto_check_sbp_navigation_msg_baseline_ned_dep_a; +mod auto_check_sbp_navigation_msg_dops; +mod auto_check_sbp_navigation_msg_dops_dep_a; +mod auto_check_sbp_navigation_msg_gps_time; +mod auto_check_sbp_navigation_msg_gps_time_dep_a; +mod auto_check_sbp_navigation_msg_gps_time_gnss; +mod auto_check_sbp_navigation_msg_pos_ecef; +mod auto_check_sbp_navigation_msg_pos_ecef_cov; +mod auto_check_sbp_navigation_msg_pos_ecef_cov_gnss; +mod auto_check_sbp_navigation_msg_pos_ecef_dep_a; +mod auto_check_sbp_navigation_msg_pos_ecefgnss; +mod auto_check_sbp_navigation_msg_pos_llh; +mod auto_check_sbp_navigation_msg_pos_llh_cov; +mod auto_check_sbp_navigation_msg_pos_llh_cov_gnss; +mod auto_check_sbp_navigation_msg_pos_llh_dep_a; +mod auto_check_sbp_navigation_msg_pos_llh_gnss; +mod auto_check_sbp_navigation_msg_protection_level; +mod auto_check_sbp_navigation_msg_utc_time; +mod auto_check_sbp_navigation_msg_utc_time_gnss; +mod auto_check_sbp_navigation_msg_vel_body; +mod auto_check_sbp_navigation_msg_vel_ecef; +mod auto_check_sbp_navigation_msg_vel_ecef_cov; +mod auto_check_sbp_navigation_msg_vel_ecef_cov_gnss; +mod auto_check_sbp_navigation_msg_vel_ecef_dep_a; +mod auto_check_sbp_navigation_msg_vel_ecef_gnss; +mod auto_check_sbp_navigation_msg_vel_ned; +mod auto_check_sbp_navigation_msg_vel_ned_cov_gnss; +mod auto_check_sbp_navigation_msg_vel_ned_dep_a; +mod auto_check_sbp_navigation_msg_vel_ned_gnss; +mod auto_check_sbp_navigation_msg_vel_nedcov; +mod auto_check_sbp_observation_msg_base_pos_ecef; +mod auto_check_sbp_observation_msg_ephemeris_bds; +mod auto_check_sbp_observation_msg_ephemeris_dep_b; +mod auto_check_sbp_observation_msg_ephemeris_gal; +mod auto_check_sbp_observation_msg_ephemeris_glo; +mod auto_check_sbp_observation_msg_ephemeris_gps; +mod auto_check_sbp_observation_msg_ephemeris_qzss; +mod auto_check_sbp_observation_msg_glo_biases; +mod auto_check_sbp_observation_msg_obs; +mod auto_check_sbp_observation_msg_obs_dep_a; +mod auto_check_sbp_observation_msg_obs_dep_b; +mod auto_check_sbp_observation_msg_obs_dep_c; +mod auto_check_sbp_observation_msg_osr; +mod auto_check_sbp_observation_msg_sv_az_el; +mod auto_check_sbp_orientation_msg_angular_rate; +mod auto_check_sbp_orientation_msg_orient_euler; +mod auto_check_sbp_orientation_msg_orient_quat; +mod auto_check_sbp_piksi_msg_device_monitor; +mod auto_check_sbp_piksi_msg_iar_state; +mod auto_check_sbp_piksi_msg_network_bandwidth_usage; +mod auto_check_sbp_piksi_msg_thread_state; +mod auto_check_sbp_piksi_msg_uart_state; +mod auto_check_sbp_piksi_msg_uart_state_dep_a; +mod auto_check_sbp_sbas_msg_sbas_raw; +mod auto_check_sbp_settings_msg_settings_read_by_index_done; +mod auto_check_sbp_settings_msg_settings_read_by_index_resp; +mod auto_check_sbp_system_msg_dgnss_status; +mod auto_check_sbp_system_msg_group_meta; +mod auto_check_sbp_system_msg_heartbeat; +mod auto_check_sbp_system_msg_ins_status; +mod auto_check_sbp_system_msg_ins_updates; +mod auto_check_sbp_system_msg_startup; +mod auto_check_sbp_tracking_msg_measurement_state; +mod auto_check_sbp_tracking_msg_tracking_state; +mod auto_check_sbp_tracking_msg_tracking_state_detailed_dep; +mod auto_check_sbp_tracking_msgtracking_state_dep_a; +mod auto_check_sbp_vehicle_msg_odometry; + +pub use std::io::Cursor; + +pub use sbp::iter_messages; +pub use sbp::messages::SbpMessage; + +pub trait AlmostEq { + fn almost_eq(self, rhs: Self) -> bool; +} + +impl AlmostEq for f32 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f32 = 5.0; + ((self - rhs).abs() <= (std::f32::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f32::MIN) + } +} + +impl AlmostEq for f64 { + fn almost_eq(self, rhs: Self) -> bool { + const ULP: f64 = 5.0; + ((self - rhs).abs() <= (std::f64::EPSILON * (self + rhs).abs() * ULP)) + || ((self - rhs).abs() < std::f64::MIN) + } +} diff --git a/rust/sbp2json/src/bin/json2json.rs b/rust/sbp2json/src/bin/json2json.rs index 234a82330f..c3812beeaa 100644 --- a/rust/sbp2json/src/bin/json2json.rs +++ b/rust/sbp2json/src/bin/json2json.rs @@ -1,9 +1,9 @@ use std::io; -use sbp::codec::json::{CompactFormatter, HaskellishFloatFormatter}; +use sbp::json::{CompactFormatter, HaskellishFloatFormatter}; use structopt::StructOpt; -use converters::json2json; +use converters::{json2json, Result}; #[cfg(all(not(windows), not(target_env = "musl")))] #[global_allocator] @@ -34,7 +34,7 @@ struct Options { fatal_errors: bool, } -fn main() -> sbp::Result<()> { +fn main() -> Result<()> { let options = Options::from_args(); if options.debug { diff --git a/rust/sbp2json/src/bin/json2sbp.rs b/rust/sbp2json/src/bin/json2sbp.rs index 9c7cedf855..98c10143d3 100644 --- a/rust/sbp2json/src/bin/json2sbp.rs +++ b/rust/sbp2json/src/bin/json2sbp.rs @@ -2,7 +2,7 @@ use std::io; use structopt::StructOpt; -use converters::json2sbp; +use converters::{json2sbp, Result}; #[cfg(all(not(windows), not(target_env = "musl")))] #[global_allocator] @@ -29,7 +29,7 @@ struct Options { fatal_errors: bool, } -fn main() -> sbp::Result<()> { +fn main() -> Result<()> { let options = Options::from_args(); if options.debug { diff --git a/rust/sbp2json/src/bin/sbp2json.rs b/rust/sbp2json/src/bin/sbp2json.rs index 54f92178e4..dca5a1d725 100644 --- a/rust/sbp2json/src/bin/sbp2json.rs +++ b/rust/sbp2json/src/bin/sbp2json.rs @@ -1,9 +1,9 @@ use std::io; -use sbp::codec::json::{CompactFormatter, HaskellishFloatFormatter}; +use sbp::json::{CompactFormatter, HaskellishFloatFormatter}; use structopt::StructOpt; -use converters::sbp2json; +use converters::{sbp2json, Result}; #[cfg(all(not(windows), not(target_env = "musl")))] #[global_allocator] @@ -38,7 +38,7 @@ pub struct Options { fatal_errors: bool, } -fn main() -> sbp::Result<()> { +fn main() -> Result<()> { let options = Options::from_args(); if options.debug { diff --git a/rust/sbp2json/src/lib.rs b/rust/sbp2json/src/lib.rs index 5ada38689b..de4969e381 100644 --- a/rust/sbp2json/src/lib.rs +++ b/rust/sbp2json/src/lib.rs @@ -1,26 +1,27 @@ use std::io::{Read, Write}; -use dencode::{Decoder, Encoder, FramedRead, FramedWrite, IterSinkExt}; -use serde_json::ser::Formatter; - use sbp::{ - codec::{ - json::{Json2JsonDecoder, Json2JsonEncoder, JsonDecoder, JsonEncoder}, - sbp::{SbpDecoder, SbpEncoder}, - }, - Error, Result, + json::{Json2JsonEncoder, JsonEncoder}, + SbpEncoder, }; +use serde_json::ser::Formatter; + +pub type Result = std::result::Result>; pub fn json2sbp(input: R, output: W, buffered: bool, fatal_errors: bool) -> Result<()> where R: Read, W: Write, { - let source = FramedRead::new(input, JsonDecoder::new()); - let sink = SbpEncoder::framed(output); - - maybe_send_buffered(source, sink, buffered, fatal_errors)?; - + let source = maybe_fatal_errors(sbp::json::iter_messages(input), fatal_errors); + let mut sink = SbpEncoder::new(output); + if buffered { + sink.send_all(source)?; + } else { + for msg in source { + sink.send(&msg)?; + } + } Ok(()) } @@ -36,11 +37,15 @@ where W: Write, F: Formatter + Clone, { - let source = FramedRead::new(input, Json2JsonDecoder {}); - let sink = FramedWrite::new(output, Json2JsonEncoder::new(formatter)); - - maybe_send_buffered(source, sink, buffered, fatal_errors)?; - + let source = maybe_fatal_errors(sbp::json::iter_json2json_messages(input), fatal_errors); + let mut sink = Json2JsonEncoder::new(output, formatter); + if buffered { + sink.send_all(source)?; + } else { + for msg in source { + sink.send(msg)?; + } + } Ok(()) } @@ -56,39 +61,30 @@ where W: Write, F: Formatter + Clone, { - let source = FramedRead::new(input, SbpDecoder {}); - let sink = JsonEncoder::framed(output, formatter); - - maybe_send_buffered(source, sink, buffered, fatal_errors)?; - + let source = maybe_fatal_errors(sbp::iter_messages(input), fatal_errors); + let mut sink = JsonEncoder::new(output, formatter); + if buffered { + sink.send_all(source)?; + } else { + for msg in source { + sink.send(&msg)?; + } + } Ok(()) } -fn maybe_send_buffered( - mut source: FramedRead, - mut sink: FramedWrite, - buffered: bool, +fn maybe_fatal_errors<'a, M, I, E>( + messages: I, fatal_errors: bool, -) -> Result<()> +) -> Box + 'a> where - R: Read, - W: Write, - D: Decoder, - E: Encoder, + M: 'a, + I: Iterator> + 'a, + E: std::error::Error + 'a, { - if buffered { - sink.send_all(source)?; + if fatal_errors { + Box::new(messages.take_while(|m| m.is_ok()).map(|m| m.unwrap())) } else { - while let Some(msg) = source.next() { - match msg { - Ok(msg) => { - sink.send(msg)?; - } - Err(e) if fatal_errors => return Err(e), - Err(e) => eprintln!("error: {}", e), - } - } + Box::new(messages.filter_map(|m| m.ok())) } - - Ok(()) }