From 01e1a5da902686a2a531247a16d0e4c96c788371 Mon Sep 17 00:00:00 2001 From: Steve Meyer Date: Mon, 27 Dec 2021 13:52:37 -0800 Subject: [PATCH 01/13] rust: add bitfield types --- generator/sbpg/generator.py | 8 +- .../sbp2json_cargo.toml} | 0 .../{sbp-cargo.toml => rust/sbp_cargo.toml} | 0 .../resources/{ => rust}/sbp_messages_mod.rs | 67 +- .../{ => rust}/sbp_messages_template.rs | 100 +- .../test}/sbp_tests_main_template.rs | 0 .../{ => rust/test}/sbp_tests_template.rs | 0 generator/sbpg/targets/rust.py | 468 ++- generator/sbpg/targets/test_rust.py | 4 +- rust/sbp/src/messages/bootload.rs | 32 + rust/sbp/src/messages/ext_events.rs | 66 + rust/sbp/src/messages/flash.rs | 197 ++ rust/sbp/src/messages/gnss.rs | 139 + rust/sbp/src/messages/imu.rs | 191 ++ rust/sbp/src/messages/linux.rs | 111 + rust/sbp/src/messages/logging.rs | 63 + rust/sbp/src/messages/mod.rs | 25 + rust/sbp/src/messages/navigation.rs | 3035 ++++++++++++++++- rust/sbp/src/messages/ndb.rs | 216 ++ rust/sbp/src/messages/observation.rs | 368 ++ rust/sbp/src/messages/orientation.rs | 148 + rust/sbp/src/messages/piksi.rs | 488 +++ rust/sbp/src/messages/settings.rs | 116 + rust/sbp/src/messages/solution_meta.rs | 509 +++ rust/sbp/src/messages/ssr.rs | 123 + rust/sbp/src/messages/system.rs | 1041 ++++++ rust/sbp/src/messages/tracking.rs | 1387 ++++++++ rust/sbp/src/messages/vehicle.rs | 208 ++ 28 files changed, 8889 insertions(+), 221 deletions(-) rename generator/sbpg/targets/resources/{sbp2json-cargo.toml => rust/sbp2json_cargo.toml} (100%) rename generator/sbpg/targets/resources/{sbp-cargo.toml => rust/sbp_cargo.toml} (100%) rename generator/sbpg/targets/resources/{ => rust}/sbp_messages_mod.rs (77%) rename generator/sbpg/targets/resources/{ => rust}/sbp_messages_template.rs (53%) rename generator/sbpg/targets/resources/{ => rust/test}/sbp_tests_main_template.rs (100%) rename generator/sbpg/targets/resources/{ => rust/test}/sbp_tests_template.rs (100%) diff --git a/generator/sbpg/generator.py b/generator/sbpg/generator.py index 67092f0f70..b08013fef5 100755 --- a/generator/sbpg/generator.py +++ b/generator/sbpg/generator.py @@ -171,9 +171,6 @@ def main(): elif args.test_java: import sbpg.targets.test_java as test_java test_java.render_source(output_dir, parsed) - elif args.rust: - import sbpg.targets.rust as rs - rs.render_source(output_dir, parsed) elif args.test_rust: import sbpg.targets.test_rust as test_rs test_rs.render_source(output_dir, parsed) @@ -200,10 +197,9 @@ def main(): parsed = [yaml.parse_spec(spec) for _, spec in file_index_items] java.render_table(output_dir, parsed) elif args.rust: + import sbpg.targets.rust as rs parsed = [yaml.parse_spec(spec) for spec in file_index.values()] - rs.render_mod(output_dir, parsed) - rs.render_sbp_cargo_toml(output_dir, release) - rs.render_sbp2json_cargo_toml(output_dir, release) + rs.render_all(output_dir, parsed, release) elif args.test_c: test_c.render_check_suites(output_dir, all_specs) test_c.render_check_main(output_dir, all_specs) diff --git a/generator/sbpg/targets/resources/sbp2json-cargo.toml b/generator/sbpg/targets/resources/rust/sbp2json_cargo.toml similarity index 100% rename from generator/sbpg/targets/resources/sbp2json-cargo.toml rename to generator/sbpg/targets/resources/rust/sbp2json_cargo.toml diff --git a/generator/sbpg/targets/resources/sbp-cargo.toml b/generator/sbpg/targets/resources/rust/sbp_cargo.toml similarity index 100% rename from generator/sbpg/targets/resources/sbp-cargo.toml rename to generator/sbpg/targets/resources/rust/sbp_cargo.toml diff --git a/generator/sbpg/targets/resources/sbp_messages_mod.rs b/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs similarity index 77% rename from generator/sbpg/targets/resources/sbp_messages_mod.rs rename to generator/sbpg/targets/resources/rust/sbp_messages_mod.rs index 4acbbf2f9d..94a55debce 100644 --- a/generator/sbpg/targets/resources/sbp_messages_mod.rs +++ b/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs @@ -14,13 +14,11 @@ pub mod (((m))); ((*- endfor *)) pub mod unknown; -((*- for p in packages *)) -((*- for m in p.definitions *)) +((*- for m in msgs *)) ((*- if m.is_real_message *)) -use self::(((p.identifier|mod_name)))::(((m.identifier|camel_case))); +use self::(((m.mod_name)))::(((m.msg_name))); ((*- endif *)) ((*- endfor *)) -((*- endfor *)) use self::unknown::Unknown; mod lib { @@ -28,14 +26,41 @@ mod lib { pub use std::convert::{TryFrom, TryInto}; - pub use crate::wire_format::{WireFormat, PayloadParseError}; - pub use crate::sbp_string::{SbpString, Unterminated, NullTerminated, Multipart, DoubleNullTerminated}; + pub use crate::sbp_string::{ + DoubleNullTerminated, Multipart, NullTerminated, SbpString, Unterminated, + }; #[cfg(feature = "swiftnav")] pub use crate::time; + pub use crate::wire_format::{PayloadParseError, WireFormat}; pub use super::{ConcreteMessage, Sbp, SbpMessage, TryFromSbpError}; pub use bytes::{Buf, BufMut}; + + macro_rules! get_bit_range { + ($bitrange:expr, $source_ty:ty, $target_ty:ty, $msb:expr, $lsb:expr) => {{ + let bit_len = std::mem::size_of::<$source_ty>() * 8; + let result_bit_len = std::mem::size_of::<$target_ty>() * 8; + let result = + (($bitrange << (bit_len - $msb - 1)) >> (bit_len - $msb - 1 + $lsb)) as $target_ty; + result << (result_bit_len - ($msb - $lsb + 1)) >> (result_bit_len - ($msb - $lsb + 1)) + }}; + } + + macro_rules! set_bit_range { + ($bitrange:expr, $value: expr, $source_ty:ty, $target_ty:ty, $msb:expr, $lsb:expr) => { + let bit_len = std::mem::size_of::<$source_ty>() * 8; + let mask: $source_ty = !(0 as $source_ty) + << (bit_len - $msb - 1) + >> (bit_len - $msb - 1 + $lsb) + << ($lsb); + *$bitrange &= !mask; + *$bitrange |= ($value as $source_ty << $lsb) & mask; + }; + } + + pub(crate) use get_bit_range; + pub(crate) use set_bit_range; } use lib::*; @@ -87,7 +112,7 @@ impl std::error::Error for TryFromSbpError {} pub enum Sbp { ((*- for m in msgs *)) /// (((m.short_desc | commentify(indent=2) ))) - (((m.identifier|camel_case)))( (((m.identifier|camel_case))) ), + (((m.msg_name)))( (((m.msg_name))) ), ((*- endfor *)) /// Unknown message type Unknown( Unknown ), @@ -122,10 +147,10 @@ impl Sbp { pub fn from_frame(mut frame: crate::Frame) -> Result { match frame.msg_type { ((*- for m in msgs *)) - (((m.identifier|camel_case)))::MESSAGE_TYPE => { - let mut msg = (((m.identifier|camel_case)))::parse(&mut frame.payload)?; + (((m.msg_name)))::MESSAGE_TYPE => { + let mut msg = (((m.msg_name)))::parse(&mut frame.payload)?; msg.set_sender_id(frame.sender_id); - Ok(Sbp::(((m.identifier|camel_case)))(msg)) + Ok(Sbp::(((m.msg_name)))(msg)) }, ((*- endfor *)) _ => { @@ -141,7 +166,7 @@ impl SbpMessage for Sbp { fn message_name(&self) -> &'static str { match self { ((*- for m in msgs *)) - Sbp::(((m.identifier|camel_case)))(msg) => { + Sbp::(((m.msg_name)))(msg) => { msg.message_name() }, ((*- endfor *)) @@ -154,7 +179,7 @@ impl SbpMessage for Sbp { fn message_type(&self) -> u16 { match self { ((*- for m in msgs *)) - Sbp::(((m.identifier|camel_case)))(msg) => { + Sbp::(((m.msg_name)))(msg) => { msg.message_type() }, ((*- endfor *)) @@ -167,7 +192,7 @@ impl SbpMessage for Sbp { fn sender_id(&self) -> Option { match self { ((*- for m in msgs *)) - Sbp::(((m.identifier|camel_case)))(msg) => { + Sbp::(((m.msg_name)))(msg) => { msg.sender_id() }, ((*- endfor *)) @@ -180,7 +205,7 @@ impl 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.msg_name)))(msg) => { msg.set_sender_id(new_id) }, ((*- endfor *)) @@ -193,7 +218,7 @@ impl SbpMessage for Sbp { fn encoded_len(&self) -> usize { match self { ((*- for m in msgs *)) - Sbp::(((m.identifier|camel_case)))(msg) => { + Sbp::(((m.msg_name)))(msg) => { msg.encoded_len() }, ((*- endfor *)) @@ -207,7 +232,7 @@ impl SbpMessage for Sbp { fn gps_time(&self) -> Option> { match self { ((*- for m in msgs *)) - Sbp::(((m.identifier|camel_case)))(msg) => { + Sbp::(((m.msg_name)))(msg) => { msg.gps_time() }, ((*- endfor *)) @@ -228,7 +253,7 @@ impl WireFormat for Sbp { fn write(&self, buf: &mut B) { match self { ((*- for m in msgs *)) - Sbp::(((m.identifier|camel_case)))(msg) => { + Sbp::(((m.msg_name)))(msg) => { WireFormat::write(msg, buf) }, ((*- endfor *)) @@ -241,7 +266,7 @@ impl WireFormat for Sbp { fn len(&self) -> usize { match self { ((*- for m in msgs *)) - Sbp::(((m.identifier|camel_case)))(msg) => { + Sbp::(((m.msg_name)))(msg) => { WireFormat::len(msg) }, ((*- endfor *)) @@ -253,9 +278,9 @@ impl WireFormat 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) +impl From<(((m.msg_name)))> for Sbp { + fn from(msg: (((m.msg_name)))) -> Self { + Sbp::(((m.msg_name)))(msg) } } diff --git a/generator/sbpg/targets/resources/sbp_messages_template.rs b/generator/sbpg/targets/resources/rust/sbp_messages_template.rs similarity index 53% rename from generator/sbpg/targets/resources/sbp_messages_template.rs rename to generator/sbpg/targets/resources/rust/sbp_messages_template.rs index fe792bd91e..d69edccd1f 100644 --- a/generator/sbpg/targets/resources/sbp_messages_template.rs +++ b/generator/sbpg/targets/resources/rust/sbp_messages_template.rs @@ -22,6 +22,7 @@ use super::(((i)))::*; use super::lib::*; ((* for m in msgs *)) + ((*- if m.desc *)) /// (((m.short_desc))) /// @@ -32,7 +33,7 @@ use super::lib::*; ((*- endif *)) #[cfg_attr(feature = "serde", derive(serde::Serialize))] #[derive(Debug, Clone)] -pub struct (((m.identifier|camel_case))) { +pub struct (((m.msg_name))) { ((*- if m.is_real_message *)) /// The message sender_id #[cfg_attr(feature = "serde", serde(skip_serializing))] @@ -43,17 +44,54 @@ pub struct (((m.identifier|camel_case))) { /// (((f.desc | commentify(indent=2) ))) ((*- endif *)) #[cfg_attr(feature = "serde", serde(rename(serialize = "(((f.identifier)))")))] - pub (((f.identifier|snake_case))): (((f|type_map))), + pub (((f.field_name))): (((f.type))), ((*- endfor *)) } +((= create getters/setters for bitfields if appropriate =)) + +((* if m.has_bitfield *)) +impl (((m.msg_name))) { +((* for f in m.fields *)) +((* for b in f.bitfield *)) + +((* if b.vals|length > 0 *)) + pub fn (((b.field_name))) (&self) -> Option<(((b.type_name)))> { + match get_bit_range!( self.(((b.field))), (((f.type))), (((b.type))), (((b.msb))), (((b.lsb))) ) { + ((*- for v in b.vals *)) + (((v.value))) => Some( (((b.type_name))) :: (((v.name))) ), + ((*- endfor *)) + _ => None, + } + } + + pub fn set_(((b.field_name))) (&mut self, (((b.field_name))): (((b.type_name)))) { + set_bit_range!(&mut self.(((b.field))), (((b.field_name))), (((f.type))), (((b.type))), (((b.msb))), (((b.lsb))) ); + } +((* else *)) + pub fn (((b.field_name))) (&self) -> (((b.type))) { + get_bit_range!( self.(((b.field))), (((f.type))), (((b.type))), (((b.msb))), (((b.lsb))) ) + } + + pub fn set_(((b.field_name))) (&mut self, (((b.field_name))): (((b.type)))) { + set_bit_range!(&mut self.(((b.field))), (((b.field_name))), (((f.type))), (((b.type))), (((b.msb))), (((b.lsb))) ); + } +((* endif *)) + +((* endfor *)) +((* endfor *)) +} +((* endif *)) + +((= implement various traits for the message =)) + ((* if m.is_real_message *)) -impl ConcreteMessage for (((m.identifier|camel_case))) { +impl ConcreteMessage for (((m.msg_name))) { const MESSAGE_TYPE: u16 = (((m.sbp_id))); const MESSAGE_NAME: &'static str = "(((m.identifier)))"; } -impl SbpMessage for (((m.identifier|camel_case))) { +impl SbpMessage for (((m.msg_name))) { fn message_name(&self) -> &'static str { ::MESSAGE_NAME } @@ -69,54 +107,86 @@ impl SbpMessage for (((m.identifier|camel_case))) { fn encoded_len(&self) -> usize { WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } - (((m|gps_time(msgs)))) + (((m.gps_time_fn))) } -impl TryFrom for (((m.identifier|camel_case))) { +impl TryFrom for (((m.msg_name))) { type Error = TryFromSbpError; fn try_from(msg: Sbp) -> Result { match msg { - Sbp::(((m.identifier|camel_case)))(m) => Ok(m), + Sbp::(((m.msg_name)))(m) => Ok(m), _ => Err(TryFromSbpError), } } } ((* endif *)) -impl WireFormat for (((m.identifier|camel_case))) { +impl WireFormat for (((m.msg_name))) { const MIN_LEN: usize = ((*- if not m.fields *)) 0 ((*- else *)) - < (((m.fields[0]|type_map))) as WireFormat>::MIN_LEN + < (((m.fields[0].type))) as WireFormat>::MIN_LEN ((*- for f in m.fields[1:] *)) - + < (((f|type_map))) as WireFormat>::MIN_LEN + + < (((f.type))) as WireFormat>::MIN_LEN ((*- endfor *)) ((*- endif *)); fn len(&self) -> usize { ((*- if not m.fields *)) 0 ((*- else *)) - WireFormat::len( &self.(((m.fields[0].identifier|snake_case))) ) + WireFormat::len( &self.(((m.fields[0].field_name))) ) ((*- for f in m.fields[1:] *)) - + WireFormat::len( &self.(((f.identifier|snake_case))) ) + + WireFormat::len( &self.(((f.field_name))) ) ((*- endfor *)) ((*- endif *)) } fn write(&self, ((*- if not m.fields *)) _buf ((*- else *)) buf ((*- endif *)): &mut B) { ((*- for f in m.fields *)) - WireFormat::write( &self.(((f.identifier|snake_case))), buf); + WireFormat::write( &self.(((f.field_name))), buf); ((*- endfor *)) } fn parse_unchecked( ((*- if not m.fields *)) _buf ((*- else *)) buf ((*- endif *)): &mut B) -> Self { - (((m.identifier|camel_case))) { + (((m.msg_name))) { ((*- if m.is_real_message *)) sender_id: None, ((*- endif *)) ((*- for f in m.fields *)) - (((f.identifier|snake_case))): WireFormat::parse_unchecked(buf), + (((f.field_name))): WireFormat::parse_unchecked(buf), ((*- endfor *)) } } } + +((= create types for bitfields if appropriate =)) + +((* if m.has_bitfield *)) +((* for f in m.fields *)) +((* for b in f.bitfield *)) +((* if b.vals|length > 0 *)) +((*- if b.desc *)) +/// (((b.desc | commentify))) +((*- endif *)) +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum (((b.type_name))) { + ((* for v in b.vals *)) + /// (((v.desc | commentify(indent=2) ))) + (((v.name))) = (((v.value))), + ((* endfor *)) +} + +impl std::fmt::Display for (((b.type_name))) { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ((*- for v in b.vals *)) + (((b.type_name)))::(((v.name))) => f.write_str("(((v.desc)))"), + ((*- endfor *)) + } + } +} +((* endif *)) +((* endfor *)) +((* endfor *)) +((* endif *)) + ((* endfor *)) diff --git a/generator/sbpg/targets/resources/sbp_tests_main_template.rs b/generator/sbpg/targets/resources/rust/test/sbp_tests_main_template.rs similarity index 100% rename from generator/sbpg/targets/resources/sbp_tests_main_template.rs rename to generator/sbpg/targets/resources/rust/test/sbp_tests_main_template.rs diff --git a/generator/sbpg/targets/resources/sbp_tests_template.rs b/generator/sbpg/targets/resources/rust/test/sbp_tests_template.rs similarity index 100% rename from generator/sbpg/targets/resources/sbp_tests_template.rs rename to generator/sbpg/targets/resources/rust/test/sbp_tests_template.rs diff --git a/generator/sbpg/targets/rust.py b/generator/sbpg/targets/rust.py index 18b18a67ed..2a3ae0f940 100644 --- a/generator/sbpg/targets/rust.py +++ b/generator/sbpg/targets/rust.py @@ -19,11 +19,11 @@ from sbpg.targets.templating import JENV, ACRONYMS, LOWER_ACRONYMS, indented_wordwrap from sbpg import ReleaseVersion -SBP_CARGO_TEMPLATE = "sbp-cargo.toml" -SBP2JSON_CARGO_TEMPLATE = "sbp2json-cargo.toml" +SBP_CARGO_TEMPLATE = "rust/sbp_cargo.toml" +SBP2JSON_CARGO_TEMPLATE = "rust/sbp2json_cargo.toml" +MESSAGES_TEMPLATE_NAME = "rust/sbp_messages_template.rs" +MESSAGES_MOD_TEMPLATE_NAME = "rust/sbp_messages_mod.rs" -MESSAGES_TEMPLATE_NAME = "sbp_messages_template.rs" -MESSAGES_MOD_TEMPLATE_NAME = "sbp_messages_mod.rs" GPS_TIME = """ let tow_s = (self.tow as f64) / 1000.0; @@ -59,7 +59,7 @@ BASE_TIME_MSGS = ["MSG_OBS", "MSG_OSR", "MSG_SSR"] CUSTOM_GPS_TIME_MSGS = { - "MSG_IMU_RAW": """ + "MSG_IMU_RAW": """ const IMU_RAW_TIME_STATUS_MASK: u32 = (1 << 30) | (1 << 31); if self.tow & IMU_RAW_TIME_STATUS_MASK != 0 { return None; @@ -70,8 +70,7 @@ Err(e) => return Some(Err(e.into())), }; """.strip(), - - "MSG_WHEELTICK": """ + "MSG_WHEELTICK": """ // only consider wheelticks with synchronization type value "microsec in GPS week" if self.flags != 1 { return None; @@ -85,131 +84,135 @@ } import re + + def camel_case(s): - """ - Makes a classname. - """ - if '_' not in s: return lower_acronyms(s) - s = re.sub('([a-z])([A-Z])', r'\1_\2', s) - return ''.join(w.title() for w in s.split('_')) + """ + Makes a classname. + """ + if "_" not in s: + return lower_acronyms(s) + s = re.sub("([a-z])([A-Z])", r"\1_\2", s) + 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() + 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 + 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, - value: str, - indent: int=0, - prefix: str="/// "): - """ - Builds a comment. - """ - 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 + 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', - 'u32': 'u32', - 'u64': 'u64', - 's8': 'i8', - 's16': 'i16', - 's32': 'i32', - 's64': 'i64', - 'float': 'f32', - 'double': 'f64'} + groups = re.findall(r"(\[[^\]]+\])[^\(]", s) + for group in groups: + s = s.replace(group, "\\" + group[:-1] + "\]") + return s -def type_map(field): - if field.type_id in TYPE_MAP: - return TYPE_MAP[field.type_id] - if field.type_id == 'array': - t = field.options['fill'].value - 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: - return "SbpString, {}>".format(encoding) +@pass_environment +def commentify( + environment: Environment, value: str, indent: int = 0, prefix: str = "/// " +): + """ + Builds a comment. + """ + value = indented_wordwrap( + environment, value, indent=(" " * indent) + prefix, first=False, markdown=True + ) + value = wrap_urls(value) + value = escape_braces(value) + return value + + +JENV.filters["commentify"] = commentify + + +TYPE_MAP = { + "u8": "u8", + "u16": "u16", + "u32": "u32", + "u64": "u64", + "s8": "i8", + "s16": "i16", + "s32": "i32", + "s64": "i64", + "float": "f32", + "double": "f64", +} + - return lower_acronyms(field.type_id) +def type_map(field): + if field.type_id in TYPE_MAP: + return TYPE_MAP[field.type_id] + + if field.type_id == "array": + t = field.options["fill"].value + 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: + return "SbpString, {}>".format(encoding) -def mod_name(x): - return x.split('.', 2)[2] + return lower_acronyms(field.type_id) -def gps_time(msg, all_messages): - def time_aware_header(type_id): - for m in all_messages: - if m.identifier == type_id: - return any([f.identifier == "t" for f in m.fields]) - return False +def gps_time_fn(msg): def gen_body(): if msg.identifier in CUSTOM_GPS_TIME_MSGS: - return CUSTOM_GPS_TIME_MSGS[msg.identifier] - - header = False + return CUSTOM_GPS_TIME_MSGS[msg.identifier] tow = False wn = False - for f in msg.fields: - if f.identifier == "header" and time_aware_header(f.type_id): - header = True + if f.has_gps_time: + return GPS_TIME_HEADER elif f.identifier == "tow": assert f.units == "ms" tow = True elif f.identifier == "wn": wn = True - - if header: - return GPS_TIME_HEADER - elif tow and wn: + if tow and wn: return GPS_TIME elif tow: return GPS_TIME_ONLY_TOW @@ -220,12 +223,12 @@ def gen_ret(): name = "Base" if msg.identifier in BASE_TIME_MSGS else "Rover" return f"Some(Ok(time::MessageTime::{name}(gps_time.into())))" + if not msg.is_real_message: + return "" body = gen_body() if body is None: return "" - ret = gen_ret() - return f""" #[cfg(feature = "swiftnav")] fn gps_time(&self) -> Option> {{ @@ -235,65 +238,190 @@ def gen_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['gps_time'] = gps_time -JENV.filters['wrap_urls'] = wrap_urls -JENV.filters['snake_case'] = snake_case - -def render_source(output_dir, package_spec): - """ - Render and output to a directory given a package specification. - """ - _, name = package_spec.filepath - destination_filename = "%s/sbp/src/messages/%s.rs" % (output_dir, name) - py_template = JENV.get_template(MESSAGES_TEMPLATE_NAME) - includes = [x.rsplit('.', 1)[0] for x in package_spec.includes] - if 'types' in includes: - del includes[includes.index('types')] - with open(destination_filename, 'w') as f: - f.write(py_template.render(msgs=sorted(package_spec.definitions, key=lambda msg: msg.identifier), - pkg_name=name, - filepath="/".join(package_spec.filepath) + ".yaml", - description=package_spec.description, - timestamp=package_spec.creation_timestamp, - includes=includes)) - -def render_mod(output_dir, package_specs): - msgs = [] - mods = [] - for package_spec in package_specs: - if not package_spec.render_source: - continue - name = package_spec.identifier.split('.', 2)[2] - if name != 'types': - mods.append(name) - for m in package_spec.definitions: - if m.is_real_message: - msgs.append(m) - destination_filename = "%s/sbp/src/messages/mod.rs" % output_dir - py_template = JENV.get_template(MESSAGES_MOD_TEMPLATE_NAME) - with open(destination_filename, 'w') as f: - f.write(py_template.render(packages=package_specs, - mods=mods, - msgs=sorted(msgs, key=lambda msg: msg.sbp_id))) - - -def render_sbp_cargo_toml(output_dir, release: ReleaseVersion): - destination_filename = "%s/sbp/Cargo.toml" % output_dir - py_template = JENV.get_template(SBP_CARGO_TEMPLATE) - with open(destination_filename, 'w') as f: - f.write(py_template.render(release=release.full_version)) - - -def render_sbp2json_cargo_toml(output_dir, release: ReleaseVersion): - destination_filename = "%s/sbp2json/Cargo.toml" % output_dir - py_template = JENV.get_template(SBP2JSON_CARGO_TEMPLATE) - if '-alpha' not in release.full_version: - version = "%s-unreleased" % (release.full_version,) - else: - version = release.full_version - with open(destination_filename, 'w') as f: - f.write(py_template.render(release=version)) +def get_bitfield_basename(item, field, msg): + msg_name = camel_case(msg.identifier) + if item.get("desc", False): + basename = camel_case(item.get("desc", "").replace(" ", "_")) + else: + basename = camel_case(field.identifier) + basename = re.sub("[^A-Za-z0-9_]+", "", msg_name + basename) + return basename + + +def calc_item_size(item, field): + int_types = [8, 16, 32, 64] + length = int(item.get("len")) - 1 + for i in int_types: + if i >= length: + return f"u{i}" + + +def get_bitfield_values(item): + vals = [] + for val in item.get("vals", []): + name = val.get("desc", None) + name = re.sub(r"\([^)]*\)", "", name) + name = re.sub("[ \-]+", "_", name.strip()) + name = re.sub("[^A-Za-z0-9_]+", "", name) + name = camel_case(name) + if name.lower() == "reserved": + continue + if name[0].isnumeric(): + name = "_" + name + vals.append( + { + "name": name, + "value": int(val.get("value")), + "desc": val.get("desc", ""), + } + ) + return vals + + +def get_bitfield(field, msg): + items = [] + for item in field.options["fields"].value: + type_name = get_bitfield_basename(item, field, msg) + if type_name.endswith("Reserved"): + continue + vals = get_bitfield_values(item) + if len(vals) == 0: + type_name = field.type + if item.get("desc", False): + field_name = snake_case(item.get("desc", "").replace(" ", "_")) + field_name = re.sub("[^A-Za-z0-9_]+", "", field_name) + else: + field_name = snake_case(field.identifier) + field_name = re.sub("__", "_", field_name) + bitrange = item.get("range").split(":") + if len(bitrange) == 1: + msb = bitrange[0] + lsb = 0 + else: + msb = bitrange[1] + lsb = bitrange[0] + print(field_name, type_name, calc_item_size(item, field)) + items.append( + { + "desc": item.get("desc"), + "field": field.field_name, + "msb": msb, + "lsb": lsb, + "type_name": type_name, + "type": calc_item_size(item, field), + "field_name": field_name, + "vals": vals, + } + ) + return items + + +class FieldItem(object): + def __init__(self, msg, package_specs, field): + self.identifier = field.identifier + self.type_id = field.type_id + self.units = field.units + self.desc = field.desc + self.options = field.options + self.field_name = snake_case(self.identifier) + self.type = type_map(field) + self.has_gps_time = False + for pkg in package_specs: + for m in pkg.definitions: + if m.identifier == self.type_id and any( + f.identifier == "t" for f in m.fields + ): + self.has_gps_time = True + self.bitfield = [] + if self.options.get("fields", False): + self.bitfield = get_bitfield(self, msg) + + +class MsgItem(object): + def __init__(self, msg, package, package_specs): + self.msg_name = camel_case(msg.identifier) + self.mod_name = package.mod_name + self.identifier = msg.identifier + self.sbp_id = msg.sbp_id + self.desc = msg.desc + self.short_desc = msg.short_desc + self.is_real_message = msg.is_real_message + self.fields = [] + self.has_bitfield = False + for f in msg.fields: + field = FieldItem(msg, package_specs, f) + self.fields.append(field) + if len(field.bitfield) > 0: + self.has_bitfield = True + self.gps_time_fn = gps_time_fn(self) + + +class PackageItem(object): + def __init__(self, package, package_specs): + self.identifier = package.identifier + self.description = package.description + self.creation_timestamp = package.creation_timestamp + self.mod_name = package.identifier.split(".", 2)[2] + self.filepath = package.filepath + self.includes = [inc.rsplit(".", 1)[0] for inc in package.includes] + if "types" in self.includes: + del self.includes[self.includes.index("types")] + self.msgs = [] + for msg in sorted(package.definitions, key=lambda pkg: pkg.identifier): + msg = MsgItem(msg, self, package_specs) + self.msgs.append(msg) + + +def render_all(output_dir, package_specs, release: ReleaseVersion): + pkgs = [] + msgs = [] + for package_spec in package_specs: + if not package_spec.render_source: + continue + pkg = PackageItem(package_spec, package_specs) + if pkg.mod_name == "types" or pkg.mod_name == "base": + continue + pkgs.append(pkg) + for m in pkg.msgs: + if m.is_real_message: + msgs.append(m) + for pkg in pkgs: + render_file( + MESSAGES_TEMPLATE_NAME, + f"{output_dir}/sbp/src/messages/{pkg.mod_name}.rs", + { + "msgs": pkg.msgs, + "filepath": "/".join(pkg.filepath) + ".yaml", + "description": pkg.description, + "timestamp": pkg.creation_timestamp, + "includes": pkg.includes, + }, + ) + render_file( + MESSAGES_MOD_TEMPLATE_NAME, + f"{output_dir}/sbp/src/messages/mod.rs", + { + "mods": [pkg.mod_name for pkg in pkgs], + "msgs": sorted(msgs, key=lambda msg: msg.sbp_id), + }, + ) + render_file( + SBP_CARGO_TEMPLATE, + f"{output_dir}/sbp/Cargo.toml", + {"release": release.full_version}, + ) + if "-alpha" not in release.full_version: + version = f"{release.full_version}-unreleased" + else: + version = release.full_version + render_file( + SBP2JSON_CARGO_TEMPLATE, + f"{output_dir}/sbp2json/Cargo.toml", + {"release": version}, + ) + + +def render_file(template, destination_filename, args): + py_template = JENV.get_template(template) + with open(destination_filename, "w") as f: + f.write(py_template.render(**args)) diff --git a/generator/sbpg/targets/test_rust.py b/generator/sbpg/targets/test_rust.py index a16192d1ff..536a926322 100644 --- a/generator/sbpg/targets/test_rust.py +++ b/generator/sbpg/targets/test_rust.py @@ -19,8 +19,8 @@ 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" +TEST_TEMPLATE_NAME = "rust/test/sbp_tests_template.rs" +TEST_MAIN_TEMPLATE_NAME = "rust/test/sbp_tests_main_template.rs" def str_escape(value): return "\"{}\".to_string()".format(value) diff --git a/rust/sbp/src/messages/bootload.rs b/rust/sbp/src/messages/bootload.rs index 68e185808d..5b8a08318f 100644 --- a/rust/sbp/src/messages/bootload.rs +++ b/rust/sbp/src/messages/bootload.rs @@ -163,6 +163,38 @@ pub struct MsgBootloaderHandshakeResp { pub version: SbpString, Unterminated>, } +impl MsgBootloaderHandshakeResp { + pub fn sbp_major_protocol_version_number(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 15, 8) + } + + pub fn set_sbp_major_protocol_version_number(&mut self, sbp_major_protocol_version_number: u8) { + set_bit_range!( + &mut self.flags, + sbp_major_protocol_version_number, + u32, + u8, + 15, + 8 + ); + } + + pub fn sbp_minor_protocol_version_number(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 7, 0) + } + + pub fn set_sbp_minor_protocol_version_number(&mut self, sbp_minor_protocol_version_number: u8) { + set_bit_range!( + &mut self.flags, + sbp_minor_protocol_version_number, + u32, + u8, + 7, + 0 + ); + } +} + impl ConcreteMessage for MsgBootloaderHandshakeResp { const MESSAGE_TYPE: u16 = 180; const MESSAGE_NAME: &'static str = "MSG_BOOTLOADER_HANDSHAKE_RESP"; diff --git a/rust/sbp/src/messages/ext_events.rs b/rust/sbp/src/messages/ext_events.rs index 7d74c4a9d0..18a4f63634 100644 --- a/rust/sbp/src/messages/ext_events.rs +++ b/rust/sbp/src/messages/ext_events.rs @@ -46,6 +46,32 @@ pub struct MsgExtEvent { pub pin: u8, } +impl MsgExtEvent { + pub fn time_quality(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 1, 0) { + 0 => Some(MsgExtEventTimeQuality::UnknownDontHaveNavSolution), + 1 => Some(MsgExtEventTimeQuality::Good), + _ => None, + } + } + + pub fn set_time_quality(&mut self, time_quality: MsgExtEventTimeQuality) { + set_bit_range!(&mut self.flags, time_quality, u8, u8, 1, 0); + } + + pub fn new_level_of_pin(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 0, 0) { + 0 => Some(MsgExtEventNewLevelOfPin::Low), + 1 => Some(MsgExtEventNewLevelOfPin::High), + _ => None, + } + } + + pub fn set_new_level_of_pin(&mut self, new_level_of_pin: MsgExtEventNewLevelOfPin) { + set_bit_range!(&mut self.flags, new_level_of_pin, u8, u8, 0, 0); + } +} + impl ConcreteMessage for MsgExtEvent { const MESSAGE_TYPE: u16 = 257; const MESSAGE_NAME: &'static str = "MSG_EXT_EVENT"; @@ -124,3 +150,43 @@ impl WireFormat for MsgExtEvent { } } } + +/// Time quality +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgExtEventTimeQuality { + /// Unknown - don't have nav solution + UnknownDontHaveNavSolution = 0, + + /// Good (< 1 microsecond) + Good = 1, +} + +impl std::fmt::Display for MsgExtEventTimeQuality { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgExtEventTimeQuality::UnknownDontHaveNavSolution => { + f.write_str("Unknown - don't have nav solution") + } + MsgExtEventTimeQuality::Good => f.write_str("Good (< 1 microsecond)"), + } + } +} + +/// New level of pin +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgExtEventNewLevelOfPin { + /// Low (falling edge) + Low = 0, + + /// High (rising edge) + High = 1, +} + +impl std::fmt::Display for MsgExtEventNewLevelOfPin { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgExtEventNewLevelOfPin::Low => f.write_str("Low (falling edge)"), + MsgExtEventNewLevelOfPin::High => f.write_str("High (rising edge)"), + } + } +} diff --git a/rust/sbp/src/messages/flash.rs b/rust/sbp/src/messages/flash.rs index 9964942066..4cbdd8d1e4 100644 --- a/rust/sbp/src/messages/flash.rs +++ b/rust/sbp/src/messages/flash.rs @@ -37,6 +37,24 @@ pub struct MsgFlashDone { pub response: u8, } +impl MsgFlashDone { + pub fn response_code(&self) -> Option { + match get_bit_range!(self.response, u8, u8, 2, 0) { + 0 => Some(MsgFlashDoneResponseCode::FlashOk), + 1 => Some(MsgFlashDoneResponseCode::FlashInvalidFlash), + 2 => Some(MsgFlashDoneResponseCode::FlashInvalidLen), + 3 => Some(MsgFlashDoneResponseCode::FlashInvalidAddr), + 4 => Some(MsgFlashDoneResponseCode::FlashInvalidRange), + 5 => Some(MsgFlashDoneResponseCode::FlashInvalidSector), + _ => None, + } + } + + pub fn set_response_code(&mut self, response_code: MsgFlashDoneResponseCode) { + set_bit_range!(&mut self.response, response_code, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgFlashDone { const MESSAGE_TYPE: u16 = 224; const MESSAGE_NAME: &'static str = "MSG_FLASH_DONE"; @@ -86,6 +104,41 @@ impl WireFormat for MsgFlashDone { } } +/// Response code +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgFlashDoneResponseCode { + /// FLASH_OK + FlashOk = 0, + + /// FLASH_INVALID_FLASH + FlashInvalidFlash = 1, + + /// FLASH_INVALID_LEN + FlashInvalidLen = 2, + + /// FLASH_INVALID_ADDR + FlashInvalidAddr = 3, + + /// FLASH_INVALID_RANGE + FlashInvalidRange = 4, + + /// FLASH_INVALID_SECTOR + FlashInvalidSector = 5, +} + +impl std::fmt::Display for MsgFlashDoneResponseCode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgFlashDoneResponseCode::FlashOk => f.write_str("FLASH_OK"), + MsgFlashDoneResponseCode::FlashInvalidFlash => f.write_str("FLASH_INVALID_FLASH"), + MsgFlashDoneResponseCode::FlashInvalidLen => f.write_str("FLASH_INVALID_LEN"), + MsgFlashDoneResponseCode::FlashInvalidAddr => f.write_str("FLASH_INVALID_ADDR"), + MsgFlashDoneResponseCode::FlashInvalidRange => f.write_str("FLASH_INVALID_RANGE"), + MsgFlashDoneResponseCode::FlashInvalidSector => f.write_str("FLASH_INVALID_SECTOR"), + } + } +} + /// Erase sector of device flash memory (host => device) /// /// The flash erase message from the host erases a sector of either the STM or @@ -107,6 +160,23 @@ pub struct MsgFlashErase { pub sector_num: u32, } +impl MsgFlashErase { + pub fn flash_target_to_read(&self) -> Option { + match get_bit_range!(self.target, u8, u8, 0, 0) { + 0 => Some(MsgFlashEraseFlashTargetToRead::FlashStm), + 1 => Some(MsgFlashEraseFlashTargetToRead::FlashM25), + _ => None, + } + } + + pub fn set_flash_target_to_read( + &mut self, + flash_target_to_read: MsgFlashEraseFlashTargetToRead, + ) { + set_bit_range!(&mut self.target, flash_target_to_read, u8, u8, 0, 0); + } +} + impl ConcreteMessage for MsgFlashErase { const MESSAGE_TYPE: u16 = 226; const MESSAGE_NAME: &'static str = "MSG_FLASH_ERASE"; @@ -158,6 +228,25 @@ impl WireFormat for MsgFlashErase { } } +/// Flash target to read +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgFlashEraseFlashTargetToRead { + /// FLASH_STM + FlashStm = 0, + + /// FLASH_M25 + FlashM25 = 1, +} + +impl std::fmt::Display for MsgFlashEraseFlashTargetToRead { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgFlashEraseFlashTargetToRead::FlashStm => f.write_str("FLASH_STM"), + MsgFlashEraseFlashTargetToRead::FlashM25 => f.write_str("FLASH_M25"), + } + } +} + /// Program flash addresses /// /// The flash program message programs a set of addresses of either the STM or @@ -186,6 +275,23 @@ pub struct MsgFlashProgram { pub data: Vec, } +impl MsgFlashProgram { + pub fn flash_target_to_read(&self) -> Option { + match get_bit_range!(self.target, u8, u8, 0, 0) { + 0 => Some(MsgFlashProgramFlashTargetToRead::FlashStm), + 1 => Some(MsgFlashProgramFlashTargetToRead::FlashM25), + _ => None, + } + } + + pub fn set_flash_target_to_read( + &mut self, + flash_target_to_read: MsgFlashProgramFlashTargetToRead, + ) { + set_bit_range!(&mut self.target, flash_target_to_read, u8, u8, 0, 0); + } +} + impl ConcreteMessage for MsgFlashProgram { const MESSAGE_TYPE: u16 = 230; const MESSAGE_NAME: &'static str = "MSG_FLASH_PROGRAM"; @@ -247,6 +353,25 @@ impl WireFormat for MsgFlashProgram { } } +/// Flash target to read +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgFlashProgramFlashTargetToRead { + /// FLASH_STM + FlashStm = 0, + + /// FLASH_M25 + FlashM25 = 1, +} + +impl std::fmt::Display for MsgFlashProgramFlashTargetToRead { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgFlashProgramFlashTargetToRead::FlashStm => f.write_str("FLASH_STM"), + MsgFlashProgramFlashTargetToRead::FlashM25 => f.write_str("FLASH_M25"), + } + } +} + /// Read STM or M25 flash address request (host => device) /// /// The flash read message reads a set of addresses of either the STM or M25 @@ -273,6 +398,23 @@ pub struct MsgFlashReadReq { pub addr_len: u8, } +impl MsgFlashReadReq { + pub fn flash_target_to_read(&self) -> Option { + match get_bit_range!(self.target, u8, u8, 0, 0) { + 0 => Some(MsgFlashReadReqFlashTargetToRead::FlashStm), + 1 => Some(MsgFlashReadReqFlashTargetToRead::FlashM25), + _ => None, + } + } + + pub fn set_flash_target_to_read( + &mut self, + flash_target_to_read: MsgFlashReadReqFlashTargetToRead, + ) { + set_bit_range!(&mut self.target, flash_target_to_read, u8, u8, 0, 0); + } +} + impl ConcreteMessage for MsgFlashReadReq { const MESSAGE_TYPE: u16 = 231; const MESSAGE_NAME: &'static str = "MSG_FLASH_READ_REQ"; @@ -330,6 +472,25 @@ impl WireFormat for MsgFlashReadReq { } } +/// Flash target to read +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgFlashReadReqFlashTargetToRead { + /// FLASH_STM + FlashStm = 0, + + /// FLASH_M25 + FlashM25 = 1, +} + +impl std::fmt::Display for MsgFlashReadReqFlashTargetToRead { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgFlashReadReqFlashTargetToRead::FlashStm => f.write_str("FLASH_STM"), + MsgFlashReadReqFlashTargetToRead::FlashM25 => f.write_str("FLASH_M25"), + } + } +} + /// Read STM or M25 flash address response (host <= device) /// /// The flash read message reads a set of addresses of either the STM or M25 @@ -356,6 +517,23 @@ pub struct MsgFlashReadResp { pub addr_len: u8, } +impl MsgFlashReadResp { + pub fn flash_target_to_read(&self) -> Option { + match get_bit_range!(self.target, u8, u8, 0, 0) { + 0 => Some(MsgFlashReadRespFlashTargetToRead::FlashStm), + 1 => Some(MsgFlashReadRespFlashTargetToRead::FlashM25), + _ => None, + } + } + + pub fn set_flash_target_to_read( + &mut self, + flash_target_to_read: MsgFlashReadRespFlashTargetToRead, + ) { + set_bit_range!(&mut self.target, flash_target_to_read, u8, u8, 0, 0); + } +} + impl ConcreteMessage for MsgFlashReadResp { const MESSAGE_TYPE: u16 = 225; const MESSAGE_NAME: &'static str = "MSG_FLASH_READ_RESP"; @@ -413,6 +591,25 @@ impl WireFormat for MsgFlashReadResp { } } +/// Flash target to read +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgFlashReadRespFlashTargetToRead { + /// FLASH_STM + FlashStm = 0, + + /// FLASH_M25 + FlashM25 = 1, +} + +impl std::fmt::Display for MsgFlashReadRespFlashTargetToRead { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgFlashReadRespFlashTargetToRead::FlashStm => f.write_str("FLASH_STM"), + MsgFlashReadRespFlashTargetToRead::FlashM25 => f.write_str("FLASH_M25"), + } + } +} + /// Write M25 flash status register (host => device) /// /// The flash status message writes to the 8-bit M25 flash status register. diff --git a/rust/sbp/src/messages/gnss.rs b/rust/sbp/src/messages/gnss.rs index bc5954e35b..a5a3116acd 100644 --- a/rust/sbp/src/messages/gnss.rs +++ b/rust/sbp/src/messages/gnss.rs @@ -174,6 +174,30 @@ pub struct GnssSignal { pub code: u8, } +impl GnssSignal { + pub fn code(&self) -> Option { + match get_bit_range!(self.code, u8, u8, 7, 0) { + 0 => Some(GnssSignalcode::GpsL1Ca), + 1 => Some(GnssSignalcode::GpsL2Cm), + 2 => Some(GnssSignalcode::SbasL1Ca), + 3 => Some(GnssSignalcode::GloL1Ca), + 4 => Some(GnssSignalcode::GloL2Ca), + 5 => Some(GnssSignalcode::GpsL1P), + 6 => Some(GnssSignalcode::GpsL2P), + 12 => Some(GnssSignalcode::Bds2B1), + 13 => Some(GnssSignalcode::Bds2B2), + 14 => Some(GnssSignalcode::GalE1B), + 20 => Some(GnssSignalcode::GalE7I), + 47 => Some(GnssSignalcode::Bds3B2A), + _ => None, + } + } + + pub fn set_code(&mut self, code: GnssSignalcode) { + set_bit_range!(&mut self.code, code, u8, u8, 7, 0); + } +} + impl WireFormat for GnssSignal { const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; fn len(&self) -> usize { @@ -191,6 +215,64 @@ impl WireFormat for GnssSignal { } } +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GnssSignalcode { + /// GPS L1CA + GpsL1Ca = 0, + + /// GPS L2CM + GpsL2Cm = 1, + + /// SBAS L1CA + SbasL1Ca = 2, + + /// GLO L1CA + GloL1Ca = 3, + + /// GLO L2CA + GloL2Ca = 4, + + /// GPS L1P + GpsL1P = 5, + + /// GPS L2P + GpsL2P = 6, + + /// BDS2 B1 + Bds2B1 = 12, + + /// BDS2 B2 + Bds2B2 = 13, + + /// GAL E1B + GalE1B = 14, + + /// GAL E7I + GalE7I = 20, + + /// BDS3 B2a + Bds3B2A = 47, +} + +impl std::fmt::Display for GnssSignalcode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + GnssSignalcode::GpsL1Ca => f.write_str("GPS L1CA"), + GnssSignalcode::GpsL2Cm => f.write_str("GPS L2CM"), + GnssSignalcode::SbasL1Ca => f.write_str("SBAS L1CA"), + GnssSignalcode::GloL1Ca => f.write_str("GLO L1CA"), + GnssSignalcode::GloL2Ca => f.write_str("GLO L2CA"), + GnssSignalcode::GpsL1P => f.write_str("GPS L1P"), + GnssSignalcode::GpsL2P => f.write_str("GPS L2P"), + GnssSignalcode::Bds2B1 => f.write_str("BDS2 B1"), + GnssSignalcode::Bds2B2 => f.write_str("BDS2 B2"), + GnssSignalcode::GalE1B => f.write_str("GAL E1B"), + GnssSignalcode::GalE7I => f.write_str("GAL E7I"), + GnssSignalcode::Bds3B2A => f.write_str("BDS3 B2a"), + } + } +} + /// Deprecated /// /// Deprecated. @@ -212,6 +294,25 @@ pub struct GnssSignalDep { pub reserved: u8, } +impl GnssSignalDep { + pub fn code(&self) -> Option { + match get_bit_range!(self.code, u8, u8, 7, 0) { + 0 => Some(GnssSignalDepcode::GpsL1Ca), + 1 => Some(GnssSignalDepcode::GpsL2Cm), + 2 => Some(GnssSignalDepcode::SbasL1Ca), + 3 => Some(GnssSignalDepcode::GloL1Ca), + 4 => Some(GnssSignalDepcode::GloL2Ca), + 5 => Some(GnssSignalDepcode::GpsL1P), + 6 => Some(GnssSignalDepcode::GpsL2P), + _ => None, + } + } + + pub fn set_code(&mut self, code: GnssSignalDepcode) { + set_bit_range!(&mut self.code, code, u8, u8, 7, 0); + } +} + impl WireFormat for GnssSignalDep { const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN + ::MIN_LEN; @@ -232,6 +333,44 @@ impl WireFormat for GnssSignalDep { } } +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GnssSignalDepcode { + /// GPS L1CA + GpsL1Ca = 0, + + /// GPS L2CM + GpsL2Cm = 1, + + /// SBAS L1CA + SbasL1Ca = 2, + + /// GLO L1CA + GloL1Ca = 3, + + /// GLO L2CA + GloL2Ca = 4, + + /// GPS L1P + GpsL1P = 5, + + /// GPS L2P + GpsL2P = 6, +} + +impl std::fmt::Display for GnssSignalDepcode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + GnssSignalDepcode::GpsL1Ca => f.write_str("GPS L1CA"), + GnssSignalDepcode::GpsL2Cm => f.write_str("GPS L2CM"), + GnssSignalDepcode::SbasL1Ca => f.write_str("SBAS L1CA"), + GnssSignalDepcode::GloL1Ca => f.write_str("GLO L1CA"), + GnssSignalDepcode::GloL2Ca => f.write_str("GLO L2CA"), + GnssSignalDepcode::GpsL1P => f.write_str("GPS L1P"), + GnssSignalDepcode::GpsL2P => f.write_str("GPS L2P"), + } + } +} + /// Space vehicle identifier /// /// A (Constellation ID, satellite ID) tuple that uniquely identifies a space diff --git a/rust/sbp/src/messages/imu.rs b/rust/sbp/src/messages/imu.rs index dc6d8a16a9..15d9d8eb08 100644 --- a/rust/sbp/src/messages/imu.rs +++ b/rust/sbp/src/messages/imu.rs @@ -39,6 +39,49 @@ pub struct MsgImuAux { pub imu_conf: u8, } +impl MsgImuAux { + pub fn imu_type(&self) -> Option { + match get_bit_range!(self.imu_type, u8, u8, 7, 0) { + 0 => Some(MsgImuAuxImuType::BoschBmi160), + 1 => Some(MsgImuAuxImuType::StMicroelectronicsAsm330Llh), + _ => None, + } + } + + pub fn set_imu_type(&mut self, imu_type: MsgImuAuxImuType) { + set_bit_range!(&mut self.imu_type, imu_type, u8, u8, 7, 0); + } + + pub fn gyroscope_range(&self) -> Option { + match get_bit_range!(self.imu_conf, u8, u8, 7, 4) { + 0 => Some(MsgImuAuxGyroscopeRange::_2000DegS), + 1 => Some(MsgImuAuxGyroscopeRange::_1000DegS), + 2 => Some(MsgImuAuxGyroscopeRange::_500DegS), + 3 => Some(MsgImuAuxGyroscopeRange::_250DegS), + 4 => Some(MsgImuAuxGyroscopeRange::_125DegS), + _ => None, + } + } + + pub fn set_gyroscope_range(&mut self, gyroscope_range: MsgImuAuxGyroscopeRange) { + set_bit_range!(&mut self.imu_conf, gyroscope_range, u8, u8, 7, 4); + } + + pub fn accelerometer_range(&self) -> Option { + match get_bit_range!(self.imu_conf, u8, u8, 3, 0) { + 0 => Some(MsgImuAuxAccelerometerRange::_2G), + 1 => Some(MsgImuAuxAccelerometerRange::_4G), + 2 => Some(MsgImuAuxAccelerometerRange::_8G), + 3 => Some(MsgImuAuxAccelerometerRange::_16G), + _ => None, + } + } + + pub fn set_accelerometer_range(&mut self, accelerometer_range: MsgImuAuxAccelerometerRange) { + set_bit_range!(&mut self.imu_conf, accelerometer_range, u8, u8, 3, 0); + } +} + impl ConcreteMessage for MsgImuAux { const MESSAGE_TYPE: u16 = 2305; const MESSAGE_NAME: &'static str = "MSG_IMU_AUX"; @@ -95,6 +138,85 @@ impl WireFormat for MsgImuAux { } } +/// IMU Type +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgImuAuxImuType { + /// Bosch BMI160 + BoschBmi160 = 0, + + /// ST Microelectronics ASM330LLH + StMicroelectronicsAsm330Llh = 1, +} + +impl std::fmt::Display for MsgImuAuxImuType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgImuAuxImuType::BoschBmi160 => f.write_str("Bosch BMI160"), + MsgImuAuxImuType::StMicroelectronicsAsm330Llh => { + f.write_str("ST Microelectronics ASM330LLH") + } + } + } +} + +/// Gyroscope Range +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgImuAuxGyroscopeRange { + /// +/- 2000 deg / s + _2000DegS = 0, + + /// +/- 1000 deg / s + _1000DegS = 1, + + /// +/- 500 deg / s + _500DegS = 2, + + /// +/- 250 deg / s + _250DegS = 3, + + /// +/- 125 deg / s + _125DegS = 4, +} + +impl std::fmt::Display for MsgImuAuxGyroscopeRange { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgImuAuxGyroscopeRange::_2000DegS => f.write_str("+/- 2000 deg / s"), + MsgImuAuxGyroscopeRange::_1000DegS => f.write_str("+/- 1000 deg / s"), + MsgImuAuxGyroscopeRange::_500DegS => f.write_str("+/- 500 deg / s"), + MsgImuAuxGyroscopeRange::_250DegS => f.write_str("+/- 250 deg / s"), + MsgImuAuxGyroscopeRange::_125DegS => f.write_str("+/- 125 deg / s"), + } + } +} + +/// Accelerometer Range +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgImuAuxAccelerometerRange { + /// +/- 2g + _2G = 0, + + /// +/- 4g + _4G = 1, + + /// +/- 8g + _8G = 2, + + /// +/- 16g + _16G = 3, +} + +impl std::fmt::Display for MsgImuAuxAccelerometerRange { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgImuAuxAccelerometerRange::_2G => f.write_str("+/- 2g"), + MsgImuAuxAccelerometerRange::_4G => f.write_str("+/- 4g"), + MsgImuAuxAccelerometerRange::_8G => f.write_str("+/- 8g"), + MsgImuAuxAccelerometerRange::_16G => f.write_str("+/- 16g"), + } + } +} + /// Raw IMU data /// /// Raw data from the Inertial Measurement Unit, containing accelerometer and @@ -140,6 +262,40 @@ pub struct MsgImuRaw { pub gyr_z: i16, } +impl MsgImuRaw { + pub fn time_status(&self) -> Option { + match get_bit_range!(self.tow, u32, u8, 31, 30) { + 0 => Some(MsgImuRawTimeStatus::ReferenceEpochIsStartOfCurrentGpsWeek), + 1 => Some(MsgImuRawTimeStatus::ReferenceEpochIsTimeOfSystemStartup), + 2 => Some(MsgImuRawTimeStatus::ReferenceEpochIsUnknown), + 3 => Some(MsgImuRawTimeStatus::ReferenceEpochIsLastPps), + _ => None, + } + } + + pub fn set_time_status(&mut self, time_status: MsgImuRawTimeStatus) { + set_bit_range!(&mut self.tow, time_status, u32, u8, 31, 30); + } + + pub fn time_since_reference_epoch_in_milliseconds(&self) -> u32 { + get_bit_range!(self.tow, u32, u32, 29, 0) + } + + pub fn set_time_since_reference_epoch_in_milliseconds( + &mut self, + time_since_reference_epoch_in_milliseconds: u32, + ) { + set_bit_range!( + &mut self.tow, + time_since_reference_epoch_in_milliseconds, + u32, + u32, + 29, + 0 + ); + } +} + impl ConcreteMessage for MsgImuRaw { const MESSAGE_TYPE: u16 = 2304; const MESSAGE_NAME: &'static str = "MSG_IMU_RAW"; @@ -229,3 +385,38 @@ impl WireFormat for MsgImuRaw { } } } + +/// Time status +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgImuRawTimeStatus { + /// Reference epoch is start of current GPS week + ReferenceEpochIsStartOfCurrentGpsWeek = 0, + + /// Reference epoch is time of system startup + ReferenceEpochIsTimeOfSystemStartup = 1, + + /// Reference epoch is unknown + ReferenceEpochIsUnknown = 2, + + /// Reference epoch is last PPS + ReferenceEpochIsLastPps = 3, +} + +impl std::fmt::Display for MsgImuRawTimeStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgImuRawTimeStatus::ReferenceEpochIsStartOfCurrentGpsWeek => { + f.write_str("Reference epoch is start of current GPS week") + } + MsgImuRawTimeStatus::ReferenceEpochIsTimeOfSystemStartup => { + f.write_str("Reference epoch is time of system startup") + } + MsgImuRawTimeStatus::ReferenceEpochIsUnknown => { + f.write_str("Reference epoch is unknown") + } + MsgImuRawTimeStatus::ReferenceEpochIsLastPps => { + f.write_str("Reference epoch is last PPS") + } + } + } +} diff --git a/rust/sbp/src/messages/linux.rs b/rust/sbp/src/messages/linux.rs index 4417b61314..144d461857 100644 --- a/rust/sbp/src/messages/linux.rs +++ b/rust/sbp/src/messages/linux.rs @@ -50,6 +50,20 @@ pub struct MsgLinuxCpuState { pub cmdline: SbpString, Unterminated>, } +impl MsgLinuxCpuState { + pub fn timestamp_type(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgLinuxCpuStateTimestampType::SystemTimeInSeconds), + 1 => Some(MsgLinuxCpuStateTimestampType::GpsTowInMilliseconds), + _ => None, + } + } + + pub fn set_timestamp_type(&mut self, timestamp_type: MsgLinuxCpuStateTimestampType) { + set_bit_range!(&mut self.flags, timestamp_type, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgLinuxCpuState { const MESSAGE_TYPE: u16 = 32520; const MESSAGE_NAME: &'static str = "MSG_LINUX_CPU_STATE"; @@ -123,6 +137,29 @@ impl WireFormat for MsgLinuxCpuState { } } +/// timestamp type +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgLinuxCpuStateTimestampType { + /// System time in seconds + SystemTimeInSeconds = 0, + + /// GPS TOW in milliseconds + GpsTowInMilliseconds = 1, +} + +impl std::fmt::Display for MsgLinuxCpuStateTimestampType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgLinuxCpuStateTimestampType::SystemTimeInSeconds => { + f.write_str("System time in seconds") + } + MsgLinuxCpuStateTimestampType::GpsTowInMilliseconds => { + f.write_str("GPS TOW in milliseconds") + } + } + } +} + /// List CPU state on the system. DEPRECATED /// /// This message indicates the process state of the top 10 heaviest consumers @@ -250,6 +287,20 @@ pub struct MsgLinuxMemState { pub cmdline: SbpString, Unterminated>, } +impl MsgLinuxMemState { + pub fn timestamp_type(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgLinuxMemStateTimestampType::SystemTimeInSeconds), + 1 => Some(MsgLinuxMemStateTimestampType::GpsTowInMilliseconds), + _ => None, + } + } + + pub fn set_timestamp_type(&mut self, timestamp_type: MsgLinuxMemStateTimestampType) { + set_bit_range!(&mut self.flags, timestamp_type, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgLinuxMemState { const MESSAGE_TYPE: u16 = 32521; const MESSAGE_NAME: &'static str = "MSG_LINUX_MEM_STATE"; @@ -323,6 +374,29 @@ impl WireFormat for MsgLinuxMemState { } } +/// timestamp type +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgLinuxMemStateTimestampType { + /// System time in seconds + SystemTimeInSeconds = 0, + + /// GPS TOW in milliseconds + GpsTowInMilliseconds = 1, +} + +impl std::fmt::Display for MsgLinuxMemStateTimestampType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgLinuxMemStateTimestampType::SystemTimeInSeconds => { + f.write_str("System time in seconds") + } + MsgLinuxMemStateTimestampType::GpsTowInMilliseconds => { + f.write_str("GPS TOW in milliseconds") + } + } + } +} + /// List memory state on the system. DEPRECATED /// /// This message indicates the process state of the top 10 heaviest consumers @@ -922,6 +996,20 @@ pub struct MsgLinuxSysState { pub flags: u8, } +impl MsgLinuxSysState { + pub fn timestamp_type(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgLinuxSysStateTimestampType::SystemTimeInSeconds), + 1 => Some(MsgLinuxSysStateTimestampType::GpsTowInMilliseconds), + _ => None, + } + } + + pub fn set_timestamp_type(&mut self, timestamp_type: MsgLinuxSysStateTimestampType) { + set_bit_range!(&mut self.flags, timestamp_type, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgLinuxSysState { const MESSAGE_TYPE: u16 = 32522; const MESSAGE_NAME: &'static str = "MSG_LINUX_SYS_STATE"; @@ -999,6 +1087,29 @@ impl WireFormat for MsgLinuxSysState { } } +/// timestamp type +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgLinuxSysStateTimestampType { + /// System time in seconds + SystemTimeInSeconds = 0, + + /// GPS TOW in milliseconds + GpsTowInMilliseconds = 1, +} + +impl std::fmt::Display for MsgLinuxSysStateTimestampType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgLinuxSysStateTimestampType::SystemTimeInSeconds => { + f.write_str("System time in seconds") + } + MsgLinuxSysStateTimestampType::GpsTowInMilliseconds => { + f.write_str("GPS TOW in milliseconds") + } + } + } +} + /// CPU, Memory and Process Starts/Stops. DEPRECATED /// /// This presents a summary of CPU and memory utilization. diff --git a/rust/sbp/src/messages/logging.rs b/rust/sbp/src/messages/logging.rs index 59c13e07b1..96925d45f7 100644 --- a/rust/sbp/src/messages/logging.rs +++ b/rust/sbp/src/messages/logging.rs @@ -121,6 +121,26 @@ pub struct MsgLog { pub text: SbpString, Unterminated>, } +impl MsgLog { + pub fn logging_level(&self) -> Option { + match get_bit_range!(self.level, u8, u8, 2, 0) { + 0 => Some(MsgLogLoggingLevel::EMERG), + 1 => Some(MsgLogLoggingLevel::ALERT), + 2 => Some(MsgLogLoggingLevel::CRIT), + 3 => Some(MsgLogLoggingLevel::ERROR), + 4 => Some(MsgLogLoggingLevel::WARN), + 5 => Some(MsgLogLoggingLevel::NOTICE), + 6 => Some(MsgLogLoggingLevel::INFO), + 7 => Some(MsgLogLoggingLevel::DEBUG), + _ => None, + } + } + + pub fn set_logging_level(&mut self, logging_level: MsgLogLoggingLevel) { + set_bit_range!(&mut self.level, logging_level, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgLog { const MESSAGE_TYPE: u16 = 1025; const MESSAGE_NAME: &'static str = "MSG_LOG"; @@ -173,6 +193,49 @@ impl WireFormat for MsgLog { } } +/// Logging level +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgLogLoggingLevel { + /// EMERG + EMERG = 0, + + /// ALERT + ALERT = 1, + + /// CRIT + CRIT = 2, + + /// ERROR + ERROR = 3, + + /// WARN + WARN = 4, + + /// NOTICE + NOTICE = 5, + + /// INFO + INFO = 6, + + /// DEBUG + DEBUG = 7, +} + +impl std::fmt::Display for MsgLogLoggingLevel { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgLogLoggingLevel::EMERG => f.write_str("EMERG"), + MsgLogLoggingLevel::ALERT => f.write_str("ALERT"), + MsgLogLoggingLevel::CRIT => f.write_str("CRIT"), + MsgLogLoggingLevel::ERROR => f.write_str("ERROR"), + MsgLogLoggingLevel::WARN => f.write_str("WARN"), + MsgLogLoggingLevel::NOTICE => f.write_str("NOTICE"), + MsgLogLoggingLevel::INFO => f.write_str("INFO"), + MsgLogLoggingLevel::DEBUG => f.write_str("DEBUG"), + } + } +} + /// Deprecated /// /// Deprecated. diff --git a/rust/sbp/src/messages/mod.rs b/rust/sbp/src/messages/mod.rs index cb6f6530d3..b93d49c791 100644 --- a/rust/sbp/src/messages/mod.rs +++ b/rust/sbp/src/messages/mod.rs @@ -253,6 +253,31 @@ mod lib { pub use super::{ConcreteMessage, Sbp, SbpMessage, TryFromSbpError}; pub use bytes::{Buf, BufMut}; + + macro_rules! get_bit_range { + ($bitrange:expr, $source_ty:ty, $target_ty:ty, $msb:expr, $lsb:expr) => {{ + let bit_len = std::mem::size_of::<$source_ty>() * 8; + let result_bit_len = std::mem::size_of::<$target_ty>() * 8; + let result = + (($bitrange << (bit_len - $msb - 1)) >> (bit_len - $msb - 1 + $lsb)) as $target_ty; + result << (result_bit_len - ($msb - $lsb + 1)) >> (result_bit_len - ($msb - $lsb + 1)) + }}; + } + + macro_rules! set_bit_range { + ($bitrange:expr, $value: expr, $source_ty:ty, $target_ty:ty, $msb:expr, $lsb:expr) => { + let bit_len = std::mem::size_of::<$source_ty>() * 8; + let mask: $source_ty = !(0 as $source_ty) + << (bit_len - $msb - 1) + >> (bit_len - $msb - 1 + $lsb) + << ($lsb); + *$bitrange &= !mask; + *$bitrange |= ($value as $source_ty << $lsb) & mask; + }; + } + + pub(crate) use get_bit_range; + pub(crate) use set_bit_range; } use lib::*; diff --git a/rust/sbp/src/messages/navigation.rs b/rust/sbp/src/messages/navigation.rs index 1eb0421f09..562a1e3b6f 100644 --- a/rust/sbp/src/messages/navigation.rs +++ b/rust/sbp/src/messages/navigation.rs @@ -194,6 +194,22 @@ pub struct MsgBaselineEcef { pub flags: u8, } +impl MsgBaselineEcef { + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgBaselineEcefFixMode::Invalid), + 2 => Some(MsgBaselineEcefFixMode::DifferentialGnss), + 3 => Some(MsgBaselineEcefFixMode::FloatRtk), + 4 => Some(MsgBaselineEcefFixMode::FixedRtk), + _ => None, + } + } + + pub fn set_fix_mode(&mut self, fix_mode: MsgBaselineEcefFixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgBaselineEcef { const MESSAGE_TYPE: u16 = 523; const MESSAGE_NAME: &'static str = "MSG_BASELINE_ECEF"; @@ -276,6 +292,33 @@ impl WireFormat for MsgBaselineEcef { } } +/// Fix mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgBaselineEcefFixMode { + /// Invalid + Invalid = 0, + + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, + + /// Float RTK + FloatRtk = 3, + + /// Fixed RTK + FixedRtk = 4, +} + +impl std::fmt::Display for MsgBaselineEcefFixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgBaselineEcefFixMode::Invalid => f.write_str("Invalid"), + MsgBaselineEcefFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + MsgBaselineEcefFixMode::FloatRtk => f.write_str("Float RTK"), + MsgBaselineEcefFixMode::FixedRtk => f.write_str("Fixed RTK"), + } + } +} + /// Baseline Position in ECEF /// /// This message reports the baseline solution in Earth Centered Earth Fixed @@ -312,6 +355,47 @@ pub struct MsgBaselineEcefDepA { pub flags: u8, } +impl MsgBaselineEcefDepA { + pub fn raim_repair_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 0) { + 0 => Some(MsgBaselineEcefDepARaimRepairFlag::NoRepair), + 1 => Some(MsgBaselineEcefDepARaimRepairFlag::SolutionCameFromRaimRepair), + _ => None, + } + } + + pub fn set_raim_repair_flag(&mut self, raim_repair_flag: MsgBaselineEcefDepARaimRepairFlag) { + set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); + } + + pub fn raim_availability_flag(&self) -> Option { + match get_bit_range!( self.flags, u8, u8, 3, 0 ) { + 0 => Some( MsgBaselineEcefDepARaimAvailabilityFlag :: RaimCheckWasExplicitlyDisabledOrUnavailable ), + 1 => Some( MsgBaselineEcefDepARaimAvailabilityFlag :: RaimCheckWasAvailable ), + _ => None, + } + } + + pub fn set_raim_availability_flag( + &mut self, + raim_availability_flag: MsgBaselineEcefDepARaimAvailabilityFlag, + ) { + set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); + } + + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgBaselineEcefDepAFixMode::FloatRtk), + 1 => Some(MsgBaselineEcefDepAFixMode::FixedRtk), + _ => None, + } + } + + pub fn set_fix_mode(&mut self, fix_mode: MsgBaselineEcefDepAFixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgBaselineEcefDepA { const MESSAGE_TYPE: u16 = 514; const MESSAGE_NAME: &'static str = "MSG_BASELINE_ECEF_DEP_A"; @@ -394,6 +478,65 @@ impl WireFormat for MsgBaselineEcefDepA { } } +/// RAIM repair flag +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgBaselineEcefDepARaimRepairFlag { + /// No repair + NoRepair = 0, + + /// Solution came from RAIM repair + SolutionCameFromRaimRepair = 1, +} + +impl std::fmt::Display for MsgBaselineEcefDepARaimRepairFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgBaselineEcefDepARaimRepairFlag::NoRepair => f.write_str("No repair"), + MsgBaselineEcefDepARaimRepairFlag::SolutionCameFromRaimRepair => { + f.write_str("Solution came from RAIM repair") + } + } + } +} + +/// RAIM availability flag +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgBaselineEcefDepARaimAvailabilityFlag { + /// RAIM check was explicitly disabled or unavailable + RaimCheckWasExplicitlyDisabledOrUnavailable = 0, + + /// RAIM check was available + RaimCheckWasAvailable = 1, +} + +impl std::fmt::Display for MsgBaselineEcefDepARaimAvailabilityFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgBaselineEcefDepARaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable => f.write_str("RAIM check was explicitly disabled or unavailable"), + MsgBaselineEcefDepARaimAvailabilityFlag::RaimCheckWasAvailable => f.write_str("RAIM check was available"), + } + } +} + +/// Fix mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgBaselineEcefDepAFixMode { + /// Float RTK + FloatRtk = 0, + + /// Fixed RTK + FixedRtk = 1, +} + +impl std::fmt::Display for MsgBaselineEcefDepAFixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgBaselineEcefDepAFixMode::FloatRtk => f.write_str("Float RTK"), + MsgBaselineEcefDepAFixMode::FixedRtk => f.write_str("Fixed RTK"), + } + } +} + /// Heading relative to True North /// /// This message reports the baseline heading pointing from the base station @@ -420,6 +563,47 @@ pub struct MsgBaselineHeadingDepA { pub flags: u8, } +impl MsgBaselineHeadingDepA { + pub fn raim_repair_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 0) { + 0 => Some(MsgBaselineHeadingDepARaimRepairFlag::NoRepair), + 1 => Some(MsgBaselineHeadingDepARaimRepairFlag::SolutionCameFromRaimRepair), + _ => None, + } + } + + pub fn set_raim_repair_flag(&mut self, raim_repair_flag: MsgBaselineHeadingDepARaimRepairFlag) { + set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); + } + + pub fn raim_availability_flag(&self) -> Option { + match get_bit_range!( self.flags, u8, u8, 3, 0 ) { + 0 => Some( MsgBaselineHeadingDepARaimAvailabilityFlag :: RaimCheckWasExplicitlyDisabledOrUnavailable ), + 1 => Some( MsgBaselineHeadingDepARaimAvailabilityFlag :: RaimCheckWasAvailable ), + _ => None, + } + } + + pub fn set_raim_availability_flag( + &mut self, + raim_availability_flag: MsgBaselineHeadingDepARaimAvailabilityFlag, + ) { + set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); + } + + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgBaselineHeadingDepAFixMode::FloatRtk), + 1 => Some(MsgBaselineHeadingDepAFixMode::FixedRtk), + _ => None, + } + } + + pub fn set_fix_mode(&mut self, fix_mode: MsgBaselineHeadingDepAFixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgBaselineHeadingDepA { const MESSAGE_TYPE: u16 = 519; const MESSAGE_NAME: &'static str = "MSG_BASELINE_HEADING_DEP_A"; @@ -490,6 +674,65 @@ impl WireFormat for MsgBaselineHeadingDepA { } } +/// RAIM repair flag +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgBaselineHeadingDepARaimRepairFlag { + /// No repair + NoRepair = 0, + + /// Solution came from RAIM repair + SolutionCameFromRaimRepair = 1, +} + +impl std::fmt::Display for MsgBaselineHeadingDepARaimRepairFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgBaselineHeadingDepARaimRepairFlag::NoRepair => f.write_str("No repair"), + MsgBaselineHeadingDepARaimRepairFlag::SolutionCameFromRaimRepair => { + f.write_str("Solution came from RAIM repair") + } + } + } +} + +/// RAIM availability flag +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgBaselineHeadingDepARaimAvailabilityFlag { + /// RAIM check was explicitly disabled or unavailable + RaimCheckWasExplicitlyDisabledOrUnavailable = 0, + + /// RAIM check was available + RaimCheckWasAvailable = 1, +} + +impl std::fmt::Display for MsgBaselineHeadingDepARaimAvailabilityFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgBaselineHeadingDepARaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable => f.write_str("RAIM check was explicitly disabled or unavailable"), + MsgBaselineHeadingDepARaimAvailabilityFlag::RaimCheckWasAvailable => f.write_str("RAIM check was available"), + } + } +} + +/// Fix mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgBaselineHeadingDepAFixMode { + /// Float RTK + FloatRtk = 0, + + /// Fixed RTK + FixedRtk = 1, +} + +impl std::fmt::Display for MsgBaselineHeadingDepAFixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgBaselineHeadingDepAFixMode::FloatRtk => f.write_str("Float RTK"), + MsgBaselineHeadingDepAFixMode::FixedRtk => f.write_str("Fixed RTK"), + } + } +} + /// Baseline in NED /// /// This message reports the baseline solution in North East Down (NED) @@ -531,6 +774,22 @@ pub struct MsgBaselineNed { pub flags: u8, } +impl MsgBaselineNed { + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgBaselineNedFixMode::Invalid), + 2 => Some(MsgBaselineNedFixMode::DifferentialGnss), + 3 => Some(MsgBaselineNedFixMode::FloatRtk), + 4 => Some(MsgBaselineNedFixMode::FixedRtk), + _ => None, + } + } + + pub fn set_fix_mode(&mut self, fix_mode: MsgBaselineNedFixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgBaselineNed { const MESSAGE_TYPE: u16 = 524; const MESSAGE_NAME: &'static str = "MSG_BASELINE_NED"; @@ -617,6 +876,33 @@ impl WireFormat for MsgBaselineNed { } } +/// Fix mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgBaselineNedFixMode { + /// Invalid + Invalid = 0, + + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, + + /// Float RTK + FloatRtk = 3, + + /// Fixed RTK + FixedRtk = 4, +} + +impl std::fmt::Display for MsgBaselineNedFixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgBaselineNedFixMode::Invalid => f.write_str("Invalid"), + MsgBaselineNedFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + MsgBaselineNedFixMode::FloatRtk => f.write_str("Float RTK"), + MsgBaselineNedFixMode::FixedRtk => f.write_str("Fixed RTK"), + } + } +} + /// Baseline in NED /// /// This message reports the baseline solution in North East Down (NED) @@ -658,6 +944,49 @@ pub struct MsgBaselineNedDepA { pub flags: u8, } +impl MsgBaselineNedDepA { + pub fn raim_repair_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 0) { + 0 => Some(MsgBaselineNedDepARaimRepairFlag::NoRepair), + 1 => Some(MsgBaselineNedDepARaimRepairFlag::SolutionCameFromRaimRepair), + _ => None, + } + } + + pub fn set_raim_repair_flag(&mut self, raim_repair_flag: MsgBaselineNedDepARaimRepairFlag) { + set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); + } + + pub fn raim_availability_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 0) { + 0 => Some( + MsgBaselineNedDepARaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable, + ), + 1 => Some(MsgBaselineNedDepARaimAvailabilityFlag::RaimCheckWasAvailable), + _ => None, + } + } + + pub fn set_raim_availability_flag( + &mut self, + raim_availability_flag: MsgBaselineNedDepARaimAvailabilityFlag, + ) { + set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); + } + + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgBaselineNedDepAFixMode::FloatRtk), + 1 => Some(MsgBaselineNedDepAFixMode::FixedRtk), + _ => None, + } + } + + pub fn set_fix_mode(&mut self, fix_mode: MsgBaselineNedDepAFixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgBaselineNedDepA { const MESSAGE_TYPE: u16 = 515; const MESSAGE_NAME: &'static str = "MSG_BASELINE_NED_DEP_A"; @@ -744,6 +1073,69 @@ impl WireFormat for MsgBaselineNedDepA { } } +/// RAIM repair flag +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgBaselineNedDepARaimRepairFlag { + /// No repair + NoRepair = 0, + + /// Solution came from RAIM repair + SolutionCameFromRaimRepair = 1, +} + +impl std::fmt::Display for MsgBaselineNedDepARaimRepairFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgBaselineNedDepARaimRepairFlag::NoRepair => f.write_str("No repair"), + MsgBaselineNedDepARaimRepairFlag::SolutionCameFromRaimRepair => { + f.write_str("Solution came from RAIM repair") + } + } + } +} + +/// RAIM availability flag +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgBaselineNedDepARaimAvailabilityFlag { + /// RAIM check was explicitly disabled or unavailable + RaimCheckWasExplicitlyDisabledOrUnavailable = 0, + + /// RAIM check was available + RaimCheckWasAvailable = 1, +} + +impl std::fmt::Display for MsgBaselineNedDepARaimAvailabilityFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgBaselineNedDepARaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable => { + f.write_str("RAIM check was explicitly disabled or unavailable") + } + MsgBaselineNedDepARaimAvailabilityFlag::RaimCheckWasAvailable => { + f.write_str("RAIM check was available") + } + } + } +} + +/// Fix mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgBaselineNedDepAFixMode { + /// Float RTK + FloatRtk = 0, + + /// Fixed RTK + FixedRtk = 1, +} + +impl std::fmt::Display for MsgBaselineNedDepAFixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgBaselineNedDepAFixMode::FloatRtk => f.write_str("Float RTK"), + MsgBaselineNedDepAFixMode::FixedRtk => f.write_str("Fixed RTK"), + } + } +} + /// Dilution of Precision /// /// This dilution of precision (DOP) message describes the effect of @@ -780,6 +1172,33 @@ pub struct MsgDops { pub flags: u8, } +impl MsgDops { + pub fn raim_repair_flag(&self) -> u8 { + get_bit_range!(self.flags, u8, u8, 7, 0) + } + + pub fn set_raim_repair_flag(&mut self, raim_repair_flag: u8) { + set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 7, 0); + } + + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgDopsFixMode::Invalid), + 1 => Some(MsgDopsFixMode::SinglePointPosition), + 2 => Some(MsgDopsFixMode::DifferentialGnss), + 3 => Some(MsgDopsFixMode::FloatRtk), + 4 => Some(MsgDopsFixMode::FixedRtk), + 5 => Some(MsgDopsFixMode::Undefined), + 6 => Some(MsgDopsFixMode::SbasPosition), + _ => None, + } + } + + pub fn set_fix_mode(&mut self, fix_mode: MsgDopsFixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgDops { const MESSAGE_TYPE: u16 = 520; const MESSAGE_NAME: &'static str = "MSG_DOPS"; @@ -862,6 +1281,45 @@ impl WireFormat for MsgDops { } } +/// Fix mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgDopsFixMode { + /// Invalid + Invalid = 0, + + /// Single Point Position (SPP) + SinglePointPosition = 1, + + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, + + /// Float RTK + FloatRtk = 3, + + /// Fixed RTK + FixedRtk = 4, + + /// Undefined + Undefined = 5, + + /// SBAS Position + SbasPosition = 6, +} + +impl std::fmt::Display for MsgDopsFixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgDopsFixMode::Invalid => f.write_str("Invalid"), + MsgDopsFixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), + MsgDopsFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + MsgDopsFixMode::FloatRtk => f.write_str("Float RTK"), + MsgDopsFixMode::FixedRtk => f.write_str("Fixed RTK"), + MsgDopsFixMode::Undefined => f.write_str("Undefined"), + MsgDopsFixMode::SbasPosition => f.write_str("SBAS Position"), + } + } +} + /// Dilution of Precision /// /// This dilution of precision (DOP) message describes the effect of @@ -1006,6 +1464,21 @@ pub struct MsgGpsTime { pub flags: u8, } +impl MsgGpsTime { + pub fn time_source(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgGpsTimeTimeSource::None), + 1 => Some(MsgGpsTimeTimeSource::GnssSolution), + 2 => Some(MsgGpsTimeTimeSource::Propagated), + _ => None, + } + } + + pub fn set_time_source(&mut self, time_source: MsgGpsTimeTimeSource) { + set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgGpsTime { const MESSAGE_TYPE: u16 = 258; const MESSAGE_NAME: &'static str = "MSG_GPS_TIME"; @@ -1081,6 +1554,29 @@ impl WireFormat for MsgGpsTime { } } +/// Time source +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgGpsTimeTimeSource { + /// None (invalid) + None = 0, + + /// GNSS Solution + GnssSolution = 1, + + /// Propagated + Propagated = 2, +} + +impl std::fmt::Display for MsgGpsTimeTimeSource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgGpsTimeTimeSource::None => f.write_str("None (invalid)"), + MsgGpsTimeTimeSource::GnssSolution => f.write_str("GNSS Solution"), + MsgGpsTimeTimeSource::Propagated => f.write_str("Propagated"), + } + } +} + /// GPS Time (v1.0) /// /// This message reports the GPS time, representing the time since the GPS @@ -1226,6 +1722,21 @@ pub struct MsgGpsTimeGnss { pub flags: u8, } +impl MsgGpsTimeGnss { + pub fn time_source(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgGpsTimeGnssTimeSource::None), + 1 => Some(MsgGpsTimeGnssTimeSource::GnssSolution), + 2 => Some(MsgGpsTimeGnssTimeSource::Propagated), + _ => None, + } + } + + pub fn set_time_source(&mut self, time_source: MsgGpsTimeGnssTimeSource) { + set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgGpsTimeGnss { const MESSAGE_TYPE: u16 = 260; const MESSAGE_NAME: &'static str = "MSG_GPS_TIME_GNSS"; @@ -1301,6 +1812,29 @@ impl WireFormat for MsgGpsTimeGnss { } } +/// Time source +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgGpsTimeGnssTimeSource { + /// None (invalid) + None = 0, + + /// GNSS Solution + GnssSolution = 1, + + /// Propagated + Propagated = 2, +} + +impl std::fmt::Display for MsgGpsTimeGnssTimeSource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgGpsTimeGnssTimeSource::None => f.write_str("None (invalid)"), + MsgGpsTimeGnssTimeSource::GnssSolution => f.write_str("GNSS Solution"), + MsgGpsTimeGnssTimeSource::Propagated => f.write_str("Propagated"), + } + } +} + /// Single-point position in ECEF /// /// The position solution message reports absolute Earth Centered Earth Fixed @@ -1340,6 +1874,52 @@ pub struct MsgPosEcef { pub flags: u8, } +impl MsgPosEcef { + pub fn tow_type(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 5) { + 0 => Some(MsgPosEcefTowType::TimeOfMeasurement), + 1 => Some(MsgPosEcefTowType::Other), + _ => None, + } + } + + pub fn set_tow_type(&mut self, tow_type: MsgPosEcefTowType) { + set_bit_range!(&mut self.flags, tow_type, u8, u8, 5, 5); + } + + pub fn inertial_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(MsgPosEcefInertialNavigationMode::None), + 1 => Some(MsgPosEcefInertialNavigationMode::InsUsed), + _ => None, + } + } + + pub fn set_inertial_navigation_mode( + &mut self, + inertial_navigation_mode: MsgPosEcefInertialNavigationMode, + ) { + set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); + } + + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgPosEcefFixMode::Invalid), + 1 => Some(MsgPosEcefFixMode::SinglePointPosition), + 2 => Some(MsgPosEcefFixMode::DifferentialGnss), + 3 => Some(MsgPosEcefFixMode::FloatRtk), + 4 => Some(MsgPosEcefFixMode::FixedRtk), + 5 => Some(MsgPosEcefFixMode::DeadReckoning), + 6 => Some(MsgPosEcefFixMode::SbasPosition), + _ => None, + } + } + + pub fn set_fix_mode(&mut self, fix_mode: MsgPosEcefFixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgPosEcef { const MESSAGE_TYPE: u16 = 521; const MESSAGE_NAME: &'static str = "MSG_POS_ECEF"; @@ -1422,6 +2002,83 @@ impl WireFormat for MsgPosEcef { } } +/// TOW type +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosEcefTowType { + /// Time of Measurement + TimeOfMeasurement = 0, + + /// Other + Other = 1, +} + +impl std::fmt::Display for MsgPosEcefTowType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosEcefTowType::TimeOfMeasurement => f.write_str("Time of Measurement"), + MsgPosEcefTowType::Other => f.write_str("Other"), + } + } +} + +/// Inertial Navigation Mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosEcefInertialNavigationMode { + /// None + None = 0, + + /// INS used + InsUsed = 1, +} + +impl std::fmt::Display for MsgPosEcefInertialNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosEcefInertialNavigationMode::None => f.write_str("None"), + MsgPosEcefInertialNavigationMode::InsUsed => f.write_str("INS used"), + } + } +} + +/// Fix mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosEcefFixMode { + /// Invalid + Invalid = 0, + + /// Single Point Position (SPP) + SinglePointPosition = 1, + + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, + + /// Float RTK + FloatRtk = 3, + + /// Fixed RTK + FixedRtk = 4, + + /// Dead Reckoning + DeadReckoning = 5, + + /// SBAS Position + SbasPosition = 6, +} + +impl std::fmt::Display for MsgPosEcefFixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosEcefFixMode::Invalid => f.write_str("Invalid"), + MsgPosEcefFixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), + MsgPosEcefFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + MsgPosEcefFixMode::FloatRtk => f.write_str("Float RTK"), + MsgPosEcefFixMode::FixedRtk => f.write_str("Fixed RTK"), + MsgPosEcefFixMode::DeadReckoning => f.write_str("Dead Reckoning"), + MsgPosEcefFixMode::SbasPosition => f.write_str("SBAS Position"), + } + } +} + /// Single-point position in ECEF /// /// The position solution message reports absolute Earth Centered Earth Fixed @@ -1477,6 +2134,55 @@ pub struct MsgPosEcefCov { pub flags: u8, } +impl MsgPosEcefCov { + pub fn type_of_reported_tow(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 5) { + 0 => Some(MsgPosEcefCovTypeOfReportedTow::TimeOfMeasurement), + 1 => Some(MsgPosEcefCovTypeOfReportedTow::Other), + _ => None, + } + } + + pub fn set_type_of_reported_tow( + &mut self, + type_of_reported_tow: MsgPosEcefCovTypeOfReportedTow, + ) { + set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); + } + + pub fn inertial_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(MsgPosEcefCovInertialNavigationMode::None), + 1 => Some(MsgPosEcefCovInertialNavigationMode::InsUsed), + _ => None, + } + } + + pub fn set_inertial_navigation_mode( + &mut self, + inertial_navigation_mode: MsgPosEcefCovInertialNavigationMode, + ) { + set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); + } + + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgPosEcefCovFixMode::Invalid), + 1 => Some(MsgPosEcefCovFixMode::SinglePointPosition), + 2 => Some(MsgPosEcefCovFixMode::DifferentialGnss), + 3 => Some(MsgPosEcefCovFixMode::FloatRtk), + 4 => Some(MsgPosEcefCovFixMode::FixedRtk), + 5 => Some(MsgPosEcefCovFixMode::DeadReckoning), + 6 => Some(MsgPosEcefCovFixMode::SbasPosition), + _ => None, + } + } + + pub fn set_fix_mode(&mut self, fix_mode: MsgPosEcefCovFixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgPosEcefCov { const MESSAGE_TYPE: u16 = 532; const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_COV"; @@ -1579,13 +2285,90 @@ impl WireFormat for MsgPosEcefCov { } } -/// GNSS-only Position in ECEF -/// -/// The position solution message reports absolute Earth Centered Earth Fixed -/// (ECEF) coordinates and the status (single point vs pseudo-absolute RTK) of -/// the position solution. The message also reports the upper triangular -/// portion of the 3x3 covariance matrix. If the receiver knows the surveyed -/// position of the base station and has an RTK solution, this reports a +/// Type of reported TOW +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosEcefCovTypeOfReportedTow { + /// Time of Measurement + TimeOfMeasurement = 0, + + /// Other + Other = 1, +} + +impl std::fmt::Display for MsgPosEcefCovTypeOfReportedTow { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosEcefCovTypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), + MsgPosEcefCovTypeOfReportedTow::Other => f.write_str("Other"), + } + } +} + +/// Inertial Navigation Mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosEcefCovInertialNavigationMode { + /// None + None = 0, + + /// INS used + InsUsed = 1, +} + +impl std::fmt::Display for MsgPosEcefCovInertialNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosEcefCovInertialNavigationMode::None => f.write_str("None"), + MsgPosEcefCovInertialNavigationMode::InsUsed => f.write_str("INS used"), + } + } +} + +/// Fix mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosEcefCovFixMode { + /// Invalid + Invalid = 0, + + /// Single Point Position (SPP) + SinglePointPosition = 1, + + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, + + /// Float RTK + FloatRtk = 3, + + /// Fixed RTK + FixedRtk = 4, + + /// Dead Reckoning + DeadReckoning = 5, + + /// SBAS Position + SbasPosition = 6, +} + +impl std::fmt::Display for MsgPosEcefCovFixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosEcefCovFixMode::Invalid => f.write_str("Invalid"), + MsgPosEcefCovFixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), + MsgPosEcefCovFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + MsgPosEcefCovFixMode::FloatRtk => f.write_str("Float RTK"), + MsgPosEcefCovFixMode::FixedRtk => f.write_str("Fixed RTK"), + MsgPosEcefCovFixMode::DeadReckoning => f.write_str("Dead Reckoning"), + MsgPosEcefCovFixMode::SbasPosition => f.write_str("SBAS Position"), + } + } +} + +/// GNSS-only Position in ECEF +/// +/// The position solution message reports absolute Earth Centered Earth Fixed +/// (ECEF) coordinates and the status (single point vs pseudo-absolute RTK) of +/// the position solution. The message also reports the upper triangular +/// portion of the 3x3 covariance matrix. If the receiver knows the surveyed +/// position of the base station and has an RTK solution, this reports a /// pseudo-absolute position solution using the base station position and the /// rover's RTK baseline vector. The full GPS time is given by the preceding /// MSG_GPS_TIME with the matching time-of-week (tow). @@ -1634,6 +2417,24 @@ pub struct MsgPosEcefCovGnss { pub flags: u8, } +impl MsgPosEcefCovGnss { + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgPosEcefCovGnssFixMode::Invalid), + 1 => Some(MsgPosEcefCovGnssFixMode::SinglePointPosition), + 2 => Some(MsgPosEcefCovGnssFixMode::DifferentialGnss), + 3 => Some(MsgPosEcefCovGnssFixMode::FloatRtk), + 4 => Some(MsgPosEcefCovGnssFixMode::FixedRtk), + 6 => Some(MsgPosEcefCovGnssFixMode::SbasPosition), + _ => None, + } + } + + pub fn set_fix_mode(&mut self, fix_mode: MsgPosEcefCovGnssFixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgPosEcefCovGnss { const MESSAGE_TYPE: u16 = 564; const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_COV_GNSS"; @@ -1736,6 +2537,43 @@ impl WireFormat for MsgPosEcefCovGnss { } } +/// Fix mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosEcefCovGnssFixMode { + /// Invalid + Invalid = 0, + + /// Single Point Position (SPP) + SinglePointPosition = 1, + + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, + + /// Float RTK + FloatRtk = 3, + + /// Fixed RTK + FixedRtk = 4, + + /// SBAS Position + SbasPosition = 6, +} + +impl std::fmt::Display for MsgPosEcefCovGnssFixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosEcefCovGnssFixMode::Invalid => f.write_str("Invalid"), + MsgPosEcefCovGnssFixMode::SinglePointPosition => { + f.write_str("Single Point Position (SPP)") + } + MsgPosEcefCovGnssFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + MsgPosEcefCovGnssFixMode::FloatRtk => f.write_str("Float RTK"), + MsgPosEcefCovGnssFixMode::FixedRtk => f.write_str("Fixed RTK"), + MsgPosEcefCovGnssFixMode::SbasPosition => f.write_str("SBAS Position"), + } + } +} + /// Single-point position in ECEF /// /// The position solution message reports absolute Earth Centered Earth Fixed @@ -1775,6 +2613,50 @@ pub struct MsgPosEcefDepA { pub flags: u8, } +impl MsgPosEcefDepA { + pub fn raim_repair_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 0) { + 0 => Some(MsgPosEcefDepARaimRepairFlag::NoRepair), + 1 => Some(MsgPosEcefDepARaimRepairFlag::SolutionCameFromRaimRepair), + _ => None, + } + } + + pub fn set_raim_repair_flag(&mut self, raim_repair_flag: MsgPosEcefDepARaimRepairFlag) { + set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); + } + + pub fn raim_availability_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 0) { + 0 => Some( + MsgPosEcefDepARaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable, + ), + 1 => Some(MsgPosEcefDepARaimAvailabilityFlag::RaimCheckWasAvailable), + _ => None, + } + } + + pub fn set_raim_availability_flag( + &mut self, + raim_availability_flag: MsgPosEcefDepARaimAvailabilityFlag, + ) { + set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); + } + + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgPosEcefDepAFixMode::SinglePointPositioning), + 1 => Some(MsgPosEcefDepAFixMode::FixedRtk), + 2 => Some(MsgPosEcefDepAFixMode::FloatRtk), + _ => None, + } + } + + pub fn set_fix_mode(&mut self, fix_mode: MsgPosEcefDepAFixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgPosEcefDepA { const MESSAGE_TYPE: u16 = 512; const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_DEP_A"; @@ -1857,6 +2739,75 @@ impl WireFormat for MsgPosEcefDepA { } } +/// RAIM repair flag +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosEcefDepARaimRepairFlag { + /// No repair + NoRepair = 0, + + /// Solution came from RAIM repair + SolutionCameFromRaimRepair = 1, +} + +impl std::fmt::Display for MsgPosEcefDepARaimRepairFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosEcefDepARaimRepairFlag::NoRepair => f.write_str("No repair"), + MsgPosEcefDepARaimRepairFlag::SolutionCameFromRaimRepair => { + f.write_str("Solution came from RAIM repair") + } + } + } +} + +/// RAIM availability flag +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosEcefDepARaimAvailabilityFlag { + /// RAIM check was explicitly disabled or unavailable + RaimCheckWasExplicitlyDisabledOrUnavailable = 0, + + /// RAIM check was available + RaimCheckWasAvailable = 1, +} + +impl std::fmt::Display for MsgPosEcefDepARaimAvailabilityFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosEcefDepARaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable => { + f.write_str("RAIM check was explicitly disabled or unavailable") + } + MsgPosEcefDepARaimAvailabilityFlag::RaimCheckWasAvailable => { + f.write_str("RAIM check was available") + } + } + } +} + +/// Fix mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosEcefDepAFixMode { + /// Single Point Positioning (SPP) + SinglePointPositioning = 0, + + /// Fixed RTK + FixedRtk = 1, + + /// Float RTK + FloatRtk = 2, +} + +impl std::fmt::Display for MsgPosEcefDepAFixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosEcefDepAFixMode::SinglePointPositioning => { + f.write_str("Single Point Positioning (SPP)") + } + MsgPosEcefDepAFixMode::FixedRtk => f.write_str("Fixed RTK"), + MsgPosEcefDepAFixMode::FloatRtk => f.write_str("Float RTK"), + } + } +} + /// GNSS-only Position in ECEF /// /// The position solution message reports absolute Earth Centered Earth Fixed @@ -1896,6 +2847,24 @@ pub struct MsgPosEcefGnss { pub flags: u8, } +impl MsgPosEcefGnss { + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgPosEcefGnssFixMode::Invalid), + 1 => Some(MsgPosEcefGnssFixMode::SinglePointPosition), + 2 => Some(MsgPosEcefGnssFixMode::DifferentialGnss), + 3 => Some(MsgPosEcefGnssFixMode::FloatRtk), + 4 => Some(MsgPosEcefGnssFixMode::FixedRtk), + 6 => Some(MsgPosEcefGnssFixMode::SbasPosition), + _ => None, + } + } + + pub fn set_fix_mode(&mut self, fix_mode: MsgPosEcefGnssFixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgPosEcefGnss { const MESSAGE_TYPE: u16 = 553; const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_GNSS"; @@ -1978,6 +2947,43 @@ impl WireFormat for MsgPosEcefGnss { } } +/// Fix mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosEcefGnssFixMode { + /// Invalid + Invalid = 0, + + /// Single Point Position (SPP) + SinglePointPosition = 1, + + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, + + /// Float RTK + FloatRtk = 3, + + /// Fixed RTK + FixedRtk = 4, + + /// SBAS Position + SbasPosition = 6, +} + +impl std::fmt::Display for MsgPosEcefGnssFixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosEcefGnssFixMode::Invalid => f.write_str("Invalid"), + MsgPosEcefGnssFixMode::SinglePointPosition => { + f.write_str("Single Point Position (SPP)") + } + MsgPosEcefGnssFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + MsgPosEcefGnssFixMode::FloatRtk => f.write_str("Float RTK"), + MsgPosEcefGnssFixMode::FixedRtk => f.write_str("Fixed RTK"), + MsgPosEcefGnssFixMode::SbasPosition => f.write_str("SBAS Position"), + } + } +} + /// Geodetic Position /// /// This position solution message reports the absolute geodetic coordinates @@ -2020,6 +3026,52 @@ pub struct MsgPosLlh { pub flags: u8, } +impl MsgPosLlh { + pub fn type_of_reported_tow(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 5) { + 0 => Some(MsgPosLlhTypeOfReportedTow::TimeOfMeasurement), + 1 => Some(MsgPosLlhTypeOfReportedTow::Other), + _ => None, + } + } + + pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: MsgPosLlhTypeOfReportedTow) { + set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); + } + + pub fn inertial_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(MsgPosLlhInertialNavigationMode::None), + 1 => Some(MsgPosLlhInertialNavigationMode::InsUsed), + _ => None, + } + } + + pub fn set_inertial_navigation_mode( + &mut self, + inertial_navigation_mode: MsgPosLlhInertialNavigationMode, + ) { + set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); + } + + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgPosLlhFixMode::Invalid), + 1 => Some(MsgPosLlhFixMode::SinglePointPosition), + 2 => Some(MsgPosLlhFixMode::DifferentialGnss), + 3 => Some(MsgPosLlhFixMode::FloatRtk), + 4 => Some(MsgPosLlhFixMode::FixedRtk), + 5 => Some(MsgPosLlhFixMode::DeadReckoning), + 6 => Some(MsgPosLlhFixMode::SbasPosition), + _ => None, + } + } + + pub fn set_fix_mode(&mut self, fix_mode: MsgPosLlhFixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgPosLlh { const MESSAGE_TYPE: u16 = 522; const MESSAGE_NAME: &'static str = "MSG_POS_LLH"; @@ -2106,6 +3158,83 @@ impl WireFormat for MsgPosLlh { } } +/// Type of reported TOW +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosLlhTypeOfReportedTow { + /// Time of Measurement + TimeOfMeasurement = 0, + + /// Other + Other = 1, +} + +impl std::fmt::Display for MsgPosLlhTypeOfReportedTow { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosLlhTypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), + MsgPosLlhTypeOfReportedTow::Other => f.write_str("Other"), + } + } +} + +/// Inertial Navigation Mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosLlhInertialNavigationMode { + /// None + None = 0, + + /// INS used + InsUsed = 1, +} + +impl std::fmt::Display for MsgPosLlhInertialNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosLlhInertialNavigationMode::None => f.write_str("None"), + MsgPosLlhInertialNavigationMode::InsUsed => f.write_str("INS used"), + } + } +} + +/// Fix mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosLlhFixMode { + /// Invalid + Invalid = 0, + + /// Single Point Position (SPP) + SinglePointPosition = 1, + + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, + + /// Float RTK + FloatRtk = 3, + + /// Fixed RTK + FixedRtk = 4, + + /// Dead Reckoning + DeadReckoning = 5, + + /// SBAS Position + SbasPosition = 6, +} + +impl std::fmt::Display for MsgPosLlhFixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosLlhFixMode::Invalid => f.write_str("Invalid"), + MsgPosLlhFixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), + MsgPosLlhFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + MsgPosLlhFixMode::FloatRtk => f.write_str("Float RTK"), + MsgPosLlhFixMode::FixedRtk => f.write_str("Fixed RTK"), + MsgPosLlhFixMode::DeadReckoning => f.write_str("Dead Reckoning"), + MsgPosLlhFixMode::SbasPosition => f.write_str("SBAS Position"), + } + } +} + /// Geodetic Position and Accuracy /// /// This position solution message reports the absolute geodetic coordinates @@ -2174,6 +3303,88 @@ pub struct MsgPosLlhAcc { pub flags: u8, } +impl MsgPosLlhAcc { + pub fn geoid_model(&self) -> Option { + match get_bit_range!(self.confidence_and_geoid, u8, u8, 6, 4) { + 0 => Some(MsgPosLlhAccGeoidModel::NoModel), + 1 => Some(MsgPosLlhAccGeoidModel::EGM96), + 2 => Some(MsgPosLlhAccGeoidModel::EGM2008), + _ => None, + } + } + + pub fn set_geoid_model(&mut self, geoid_model: MsgPosLlhAccGeoidModel) { + set_bit_range!(&mut self.confidence_and_geoid, geoid_model, u8, u8, 6, 4); + } + + pub fn confidence_level(&self) -> Option { + match get_bit_range!(self.confidence_and_geoid, u8, u8, 3, 0) { + 1 => Some(MsgPosLlhAccConfidenceLevel::_3935), + 2 => Some(MsgPosLlhAccConfidenceLevel::_6827), + 3 => Some(MsgPosLlhAccConfidenceLevel::_9545), + _ => None, + } + } + + pub fn set_confidence_level(&mut self, confidence_level: MsgPosLlhAccConfidenceLevel) { + set_bit_range!( + &mut self.confidence_and_geoid, + confidence_level, + u8, + u8, + 3, + 0 + ); + } + + pub fn type_of_reported_tow(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 5) { + 0 => Some(MsgPosLlhAccTypeOfReportedTow::TimeOfMeasurement), + 1 => Some(MsgPosLlhAccTypeOfReportedTow::Other), + _ => None, + } + } + + pub fn set_type_of_reported_tow( + &mut self, + type_of_reported_tow: MsgPosLlhAccTypeOfReportedTow, + ) { + set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); + } + + pub fn inertial_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(MsgPosLlhAccInertialNavigationMode::None), + 1 => Some(MsgPosLlhAccInertialNavigationMode::InsUsed), + _ => None, + } + } + + pub fn set_inertial_navigation_mode( + &mut self, + inertial_navigation_mode: MsgPosLlhAccInertialNavigationMode, + ) { + set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); + } + + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgPosLlhAccFixMode::Invalid), + 1 => Some(MsgPosLlhAccFixMode::SinglePointPosition), + 2 => Some(MsgPosLlhAccFixMode::DifferentialGnss), + 3 => Some(MsgPosLlhAccFixMode::FloatRtk), + 4 => Some(MsgPosLlhAccFixMode::FixedRtk), + 5 => Some(MsgPosLlhAccFixMode::DeadReckoning), + 6 => Some(MsgPosLlhAccFixMode::SbasPosition), + _ => None, + } + } + + pub fn set_fix_mode(&mut self, fix_mode: MsgPosLlhAccFixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgPosLlhAcc { const MESSAGE_TYPE: u16 = 536; const MESSAGE_NAME: &'static str = "MSG_POS_LLH_ACC"; @@ -2280,6 +3491,129 @@ impl WireFormat for MsgPosLlhAcc { } } +/// Geoid model +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosLlhAccGeoidModel { + /// No model + NoModel = 0, + + /// EGM96 + EGM96 = 1, + + /// EGM2008 + EGM2008 = 2, +} + +impl std::fmt::Display for MsgPosLlhAccGeoidModel { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosLlhAccGeoidModel::NoModel => f.write_str("No model"), + MsgPosLlhAccGeoidModel::EGM96 => f.write_str("EGM96"), + MsgPosLlhAccGeoidModel::EGM2008 => f.write_str("EGM2008"), + } + } +} + +/// Confidence level +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosLlhAccConfidenceLevel { + /// 39.35% + _3935 = 1, + + /// 68.27% + _6827 = 2, + + /// 95.45% + _9545 = 3, +} + +impl std::fmt::Display for MsgPosLlhAccConfidenceLevel { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosLlhAccConfidenceLevel::_3935 => f.write_str("39.35%"), + MsgPosLlhAccConfidenceLevel::_6827 => f.write_str("68.27%"), + MsgPosLlhAccConfidenceLevel::_9545 => f.write_str("95.45%"), + } + } +} + +/// Type of reported TOW +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosLlhAccTypeOfReportedTow { + /// Time of Measurement + TimeOfMeasurement = 0, + + /// Other + Other = 1, +} + +impl std::fmt::Display for MsgPosLlhAccTypeOfReportedTow { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosLlhAccTypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), + MsgPosLlhAccTypeOfReportedTow::Other => f.write_str("Other"), + } + } +} + +/// Inertial Navigation Mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosLlhAccInertialNavigationMode { + /// None + None = 0, + + /// INS used + InsUsed = 1, +} + +impl std::fmt::Display for MsgPosLlhAccInertialNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosLlhAccInertialNavigationMode::None => f.write_str("None"), + MsgPosLlhAccInertialNavigationMode::InsUsed => f.write_str("INS used"), + } + } +} + +/// Fix mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosLlhAccFixMode { + /// Invalid + Invalid = 0, + + /// Single Point Position (SPP) + SinglePointPosition = 1, + + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, + + /// Float RTK + FloatRtk = 3, + + /// Fixed RTK + FixedRtk = 4, + + /// Dead Reckoning + DeadReckoning = 5, + + /// SBAS Position + SbasPosition = 6, +} + +impl std::fmt::Display for MsgPosLlhAccFixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosLlhAccFixMode::Invalid => f.write_str("Invalid"), + MsgPosLlhAccFixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), + MsgPosLlhAccFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + MsgPosLlhAccFixMode::FloatRtk => f.write_str("Float RTK"), + MsgPosLlhAccFixMode::FixedRtk => f.write_str("Fixed RTK"), + MsgPosLlhAccFixMode::DeadReckoning => f.write_str("Dead Reckoning"), + MsgPosLlhAccFixMode::SbasPosition => f.write_str("SBAS Position"), + } + } +} + /// Geodetic Position /// /// This position solution message reports the absolute geodetic coordinates @@ -2335,6 +3669,55 @@ pub struct MsgPosLlhCov { pub flags: u8, } +impl MsgPosLlhCov { + pub fn type_of_reported_tow(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 5) { + 0 => Some(MsgPosLlhCovTypeOfReportedTow::TimeOfMeasurement), + 1 => Some(MsgPosLlhCovTypeOfReportedTow::Other), + _ => None, + } + } + + pub fn set_type_of_reported_tow( + &mut self, + type_of_reported_tow: MsgPosLlhCovTypeOfReportedTow, + ) { + set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); + } + + pub fn inertial_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(MsgPosLlhCovInertialNavigationMode::None), + 1 => Some(MsgPosLlhCovInertialNavigationMode::InsUsed), + _ => None, + } + } + + pub fn set_inertial_navigation_mode( + &mut self, + inertial_navigation_mode: MsgPosLlhCovInertialNavigationMode, + ) { + set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); + } + + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgPosLlhCovFixMode::Invalid), + 1 => Some(MsgPosLlhCovFixMode::SinglePointPosition), + 2 => Some(MsgPosLlhCovFixMode::DifferentialGnss), + 3 => Some(MsgPosLlhCovFixMode::FloatRtk), + 4 => Some(MsgPosLlhCovFixMode::FixedRtk), + 5 => Some(MsgPosLlhCovFixMode::DeadReckoning), + 6 => Some(MsgPosLlhCovFixMode::SbasPosition), + _ => None, + } + } + + pub fn set_fix_mode(&mut self, fix_mode: MsgPosLlhCovFixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgPosLlhCov { const MESSAGE_TYPE: u16 = 529; const MESSAGE_NAME: &'static str = "MSG_POS_LLH_COV"; @@ -2437,6 +3820,83 @@ impl WireFormat for MsgPosLlhCov { } } +/// Type of reported TOW +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosLlhCovTypeOfReportedTow { + /// Time of Measurement + TimeOfMeasurement = 0, + + /// Other + Other = 1, +} + +impl std::fmt::Display for MsgPosLlhCovTypeOfReportedTow { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosLlhCovTypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), + MsgPosLlhCovTypeOfReportedTow::Other => f.write_str("Other"), + } + } +} + +/// Inertial Navigation Mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosLlhCovInertialNavigationMode { + /// None + None = 0, + + /// INS used + InsUsed = 1, +} + +impl std::fmt::Display for MsgPosLlhCovInertialNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosLlhCovInertialNavigationMode::None => f.write_str("None"), + MsgPosLlhCovInertialNavigationMode::InsUsed => f.write_str("INS used"), + } + } +} + +/// Fix mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosLlhCovFixMode { + /// Invalid + Invalid = 0, + + /// Single Point Position (SPP) + SinglePointPosition = 1, + + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, + + /// Float RTK + FloatRtk = 3, + + /// Fixed RTK + FixedRtk = 4, + + /// Dead Reckoning + DeadReckoning = 5, + + /// SBAS Position + SbasPosition = 6, +} + +impl std::fmt::Display for MsgPosLlhCovFixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosLlhCovFixMode::Invalid => f.write_str("Invalid"), + MsgPosLlhCovFixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), + MsgPosLlhCovFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + MsgPosLlhCovFixMode::FloatRtk => f.write_str("Float RTK"), + MsgPosLlhCovFixMode::FixedRtk => f.write_str("Fixed RTK"), + MsgPosLlhCovFixMode::DeadReckoning => f.write_str("Dead Reckoning"), + MsgPosLlhCovFixMode::SbasPosition => f.write_str("SBAS Position"), + } + } +} + /// GNSS-only Geodetic Position /// /// This position solution message reports the absolute geodetic coordinates @@ -2492,6 +3952,25 @@ pub struct MsgPosLlhCovGnss { pub flags: u8, } +impl MsgPosLlhCovGnss { + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgPosLlhCovGnssFixMode::Invalid), + 1 => Some(MsgPosLlhCovGnssFixMode::SinglePointPosition), + 2 => Some(MsgPosLlhCovGnssFixMode::DifferentialGnss), + 3 => Some(MsgPosLlhCovGnssFixMode::FloatRtk), + 4 => Some(MsgPosLlhCovGnssFixMode::FixedRtk), + 5 => Some(MsgPosLlhCovGnssFixMode::DeadReckoning), + 6 => Some(MsgPosLlhCovGnssFixMode::SbasPosition), + _ => None, + } + } + + pub fn set_fix_mode(&mut self, fix_mode: MsgPosLlhCovGnssFixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgPosLlhCovGnss { const MESSAGE_TYPE: u16 = 561; const MESSAGE_NAME: &'static str = "MSG_POS_LLH_COV_GNSS"; @@ -2594,6 +4073,47 @@ impl WireFormat for MsgPosLlhCovGnss { } } +/// Fix mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosLlhCovGnssFixMode { + /// Invalid + Invalid = 0, + + /// Single Point Position (SPP) + SinglePointPosition = 1, + + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, + + /// Float RTK + FloatRtk = 3, + + /// Fixed RTK + FixedRtk = 4, + + /// Dead Reckoning + DeadReckoning = 5, + + /// SBAS Position + SbasPosition = 6, +} + +impl std::fmt::Display for MsgPosLlhCovGnssFixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosLlhCovGnssFixMode::Invalid => f.write_str("Invalid"), + MsgPosLlhCovGnssFixMode::SinglePointPosition => { + f.write_str("Single Point Position (SPP)") + } + MsgPosLlhCovGnssFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + MsgPosLlhCovGnssFixMode::FloatRtk => f.write_str("Float RTK"), + MsgPosLlhCovGnssFixMode::FixedRtk => f.write_str("Fixed RTK"), + MsgPosLlhCovGnssFixMode::DeadReckoning => f.write_str("Dead Reckoning"), + MsgPosLlhCovGnssFixMode::SbasPosition => f.write_str("SBAS Position"), + } + } +} + /// Geodetic Position /// /// This position solution message reports the absolute geodetic coordinates @@ -2636,6 +4156,62 @@ pub struct MsgPosLlhDepA { pub flags: u8, } +impl MsgPosLlhDepA { + pub fn raim_repair_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 0) { + 0 => Some(MsgPosLlhDepARaimRepairFlag::NoRepair), + 1 => Some(MsgPosLlhDepARaimRepairFlag::SolutionCameFromRaimRepair), + _ => None, + } + } + + pub fn set_raim_repair_flag(&mut self, raim_repair_flag: MsgPosLlhDepARaimRepairFlag) { + set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 5, 0); + } + + pub fn raim_availability_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 0) { + 0 => { + Some(MsgPosLlhDepARaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable) + } + 1 => Some(MsgPosLlhDepARaimAvailabilityFlag::RaimCheckWasAvailable), + _ => None, + } + } + + pub fn set_raim_availability_flag( + &mut self, + raim_availability_flag: MsgPosLlhDepARaimAvailabilityFlag, + ) { + set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 4, 0); + } + + pub fn height_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 0) { + 0 => Some(MsgPosLlhDepAHeightMode::HeightAboveWgs84Ellipsoid), + 1 => Some(MsgPosLlhDepAHeightMode::HeightAboveMeanSeaLevel), + _ => None, + } + } + + pub fn set_height_mode(&mut self, height_mode: MsgPosLlhDepAHeightMode) { + set_bit_range!(&mut self.flags, height_mode, u8, u8, 3, 0); + } + + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgPosLlhDepAFixMode::SinglePointPositioning), + 1 => Some(MsgPosLlhDepAFixMode::FixedRtk), + 2 => Some(MsgPosLlhDepAFixMode::FloatRtk), + _ => None, + } + } + + pub fn set_fix_mode(&mut self, fix_mode: MsgPosLlhDepAFixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgPosLlhDepA { const MESSAGE_TYPE: u16 = 513; const MESSAGE_NAME: &'static str = "MSG_POS_LLH_DEP_A"; @@ -2722,6 +4298,98 @@ impl WireFormat for MsgPosLlhDepA { } } +/// RAIM repair flag +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosLlhDepARaimRepairFlag { + /// No repair + NoRepair = 0, + + /// Solution came from RAIM repair + SolutionCameFromRaimRepair = 1, +} + +impl std::fmt::Display for MsgPosLlhDepARaimRepairFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosLlhDepARaimRepairFlag::NoRepair => f.write_str("No repair"), + MsgPosLlhDepARaimRepairFlag::SolutionCameFromRaimRepair => { + f.write_str("Solution came from RAIM repair") + } + } + } +} + +/// RAIM availability flag +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosLlhDepARaimAvailabilityFlag { + /// RAIM check was explicitly disabled or unavailable + RaimCheckWasExplicitlyDisabledOrUnavailable = 0, + + /// RAIM check was available + RaimCheckWasAvailable = 1, +} + +impl std::fmt::Display for MsgPosLlhDepARaimAvailabilityFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosLlhDepARaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable => { + f.write_str("RAIM check was explicitly disabled or unavailable") + } + MsgPosLlhDepARaimAvailabilityFlag::RaimCheckWasAvailable => { + f.write_str("RAIM check was available") + } + } + } +} + +/// Height Mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosLlhDepAHeightMode { + /// Height above WGS84 ellipsoid + HeightAboveWgs84Ellipsoid = 0, + + /// Height above mean sea level + HeightAboveMeanSeaLevel = 1, +} + +impl std::fmt::Display for MsgPosLlhDepAHeightMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosLlhDepAHeightMode::HeightAboveWgs84Ellipsoid => { + f.write_str("Height above WGS84 ellipsoid") + } + MsgPosLlhDepAHeightMode::HeightAboveMeanSeaLevel => { + f.write_str("Height above mean sea level") + } + } + } +} + +/// Fix mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosLlhDepAFixMode { + /// Single Point Positioning (SPP) + SinglePointPositioning = 0, + + /// Fixed RTK + FixedRtk = 1, + + /// Float RTK + FloatRtk = 2, +} + +impl std::fmt::Display for MsgPosLlhDepAFixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosLlhDepAFixMode::SinglePointPositioning => { + f.write_str("Single Point Positioning (SPP)") + } + MsgPosLlhDepAFixMode::FixedRtk => f.write_str("Fixed RTK"), + MsgPosLlhDepAFixMode::FloatRtk => f.write_str("Float RTK"), + } + } +} + /// GNSS-only Geodetic Position /// /// This position solution message reports the absolute geodetic coordinates @@ -2764,6 +4432,24 @@ pub struct MsgPosLlhGnss { pub flags: u8, } +impl MsgPosLlhGnss { + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgPosLlhGnssFixMode::Invalid), + 1 => Some(MsgPosLlhGnssFixMode::SinglePointPosition), + 2 => Some(MsgPosLlhGnssFixMode::DifferentialGnss), + 3 => Some(MsgPosLlhGnssFixMode::FloatRtk), + 4 => Some(MsgPosLlhGnssFixMode::FixedRtk), + 6 => Some(MsgPosLlhGnssFixMode::SbasPosition), + _ => None, + } + } + + pub fn set_fix_mode(&mut self, fix_mode: MsgPosLlhGnssFixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgPosLlhGnss { const MESSAGE_TYPE: u16 = 554; const MESSAGE_NAME: &'static str = "MSG_POS_LLH_GNSS"; @@ -2850,6 +4536,41 @@ impl WireFormat for MsgPosLlhGnss { } } +/// Fix mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgPosLlhGnssFixMode { + /// Invalid + Invalid = 0, + + /// Single Point Position (SPP) + SinglePointPosition = 1, + + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, + + /// Float RTK + FloatRtk = 3, + + /// Fixed RTK + FixedRtk = 4, + + /// SBAS Position + SbasPosition = 6, +} + +impl std::fmt::Display for MsgPosLlhGnssFixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgPosLlhGnssFixMode::Invalid => f.write_str("Invalid"), + MsgPosLlhGnssFixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), + MsgPosLlhGnssFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + MsgPosLlhGnssFixMode::FloatRtk => f.write_str("Float RTK"), + MsgPosLlhGnssFixMode::FixedRtk => f.write_str("Fixed RTK"), + MsgPosLlhGnssFixMode::SbasPosition => f.write_str("SBAS Position"), + } + } +} + /// Computed state and Protection Levels /// /// This message reports the protection levels associated to the given state @@ -2929,6 +4650,155 @@ pub struct MsgProtectionLevel { pub flags: u32, } +impl MsgProtectionLevel { + pub fn target_integrity_risk_tir_level(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 2, 0) + } + + pub fn set_target_integrity_risk_tir_level(&mut self, target_integrity_risk_tir_level: u8) { + set_bit_range!( + &mut self.flags, + target_integrity_risk_tir_level, + u32, + u8, + 2, + 0 + ); + } + + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 17, 15) { + 0 => Some(MsgProtectionLevelFixMode::Invalid), + 1 => Some(MsgProtectionLevelFixMode::SinglePointPosition), + 2 => Some(MsgProtectionLevelFixMode::DifferentialGnss), + 3 => Some(MsgProtectionLevelFixMode::FloatRtk), + 4 => Some(MsgProtectionLevelFixMode::FixedRtk), + 5 => Some(MsgProtectionLevelFixMode::DeadReckoning), + 6 => Some(MsgProtectionLevelFixMode::SbasPosition), + _ => None, + } + } + + pub fn set_fix_mode(&mut self, fix_mode: MsgProtectionLevelFixMode) { + set_bit_range!(&mut self.flags, fix_mode, u32, u8, 17, 15); + } + + pub fn inertial_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 19, 18) { + 0 => Some(MsgProtectionLevelInertialNavigationMode::None), + 1 => Some(MsgProtectionLevelInertialNavigationMode::InsUsed), + _ => None, + } + } + + pub fn set_inertial_navigation_mode( + &mut self, + inertial_navigation_mode: MsgProtectionLevelInertialNavigationMode, + ) { + set_bit_range!(&mut self.flags, inertial_navigation_mode, u32, u8, 19, 18); + } + + pub fn time_status(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 20, 0) { + 0 => Some(MsgProtectionLevelTimeStatus::GnssTimeOfValidity), + 1 => Some(MsgProtectionLevelTimeStatus::Other), + _ => None, + } + } + + pub fn set_time_status(&mut self, time_status: MsgProtectionLevelTimeStatus) { + set_bit_range!(&mut self.flags, time_status, u32, u8, 20, 0); + } + + pub fn velocity_valid(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 21, 0) + } + + pub fn set_velocity_valid(&mut self, velocity_valid: u8) { + set_bit_range!(&mut self.flags, velocity_valid, u32, u8, 21, 0); + } + + pub fn attitude_valid(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 22, 0) + } + + pub fn set_attitude_valid(&mut self, attitude_valid: u8) { + set_bit_range!(&mut self.flags, attitude_valid, u32, u8, 22, 0); + } + + pub fn safe_state_hpl(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 23, 0) + } + + pub fn set_safe_state_hpl(&mut self, safe_state_hpl: u8) { + set_bit_range!(&mut self.flags, safe_state_hpl, u32, u8, 23, 0); + } + + pub fn safe_state_vpl(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 24, 0) + } + + pub fn set_safe_state_vpl(&mut self, safe_state_vpl: u8) { + set_bit_range!(&mut self.flags, safe_state_vpl, u32, u8, 24, 0); + } + + pub fn safe_state_atpl(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 25, 0) + } + + pub fn set_safe_state_atpl(&mut self, safe_state_atpl: u8) { + set_bit_range!(&mut self.flags, safe_state_atpl, u32, u8, 25, 0); + } + + pub fn safe_state_ctpl(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 26, 0) + } + + pub fn set_safe_state_ctpl(&mut self, safe_state_ctpl: u8) { + set_bit_range!(&mut self.flags, safe_state_ctpl, u32, u8, 26, 0); + } + + pub fn safe_state_hvpl(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 27, 0) + } + + pub fn set_safe_state_hvpl(&mut self, safe_state_hvpl: u8) { + set_bit_range!(&mut self.flags, safe_state_hvpl, u32, u8, 27, 0); + } + + pub fn safe_state_vvpl(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 28, 0) + } + + pub fn set_safe_state_vvpl(&mut self, safe_state_vvpl: u8) { + set_bit_range!(&mut self.flags, safe_state_vvpl, u32, u8, 28, 0); + } + + pub fn safe_state_hopl(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 29, 0) + } + + pub fn set_safe_state_hopl(&mut self, safe_state_hopl: u8) { + set_bit_range!(&mut self.flags, safe_state_hopl, u32, u8, 29, 0); + } + + pub fn safe_state_popl(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 30, 0) + } + + pub fn set_safe_state_popl(&mut self, safe_state_popl: u8) { + set_bit_range!(&mut self.flags, safe_state_popl, u32, u8, 30, 0); + } + + pub fn safe_state_ropl(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 31, 0) + } + + pub fn set_safe_state_ropl(&mut self, safe_state_ropl: u8) { + set_bit_range!(&mut self.flags, safe_state_ropl, u32, u8, 31, 0); + } +} + impl ConcreteMessage for MsgProtectionLevel { const MESSAGE_TYPE: u16 = 535; const MESSAGE_NAME: &'static str = "MSG_PROTECTION_LEVEL"; @@ -3072,6 +4942,87 @@ impl WireFormat for MsgProtectionLevel { } } +/// Fix mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgProtectionLevelFixMode { + /// Invalid + Invalid = 0, + + /// Single Point Position (SPP) + SinglePointPosition = 1, + + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, + + /// Float RTK + FloatRtk = 3, + + /// Fixed RTK + FixedRtk = 4, + + /// Dead Reckoning + DeadReckoning = 5, + + /// SBAS Position + SbasPosition = 6, +} + +impl std::fmt::Display for MsgProtectionLevelFixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgProtectionLevelFixMode::Invalid => f.write_str("Invalid"), + MsgProtectionLevelFixMode::SinglePointPosition => { + f.write_str("Single Point Position (SPP)") + } + MsgProtectionLevelFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + MsgProtectionLevelFixMode::FloatRtk => f.write_str("Float RTK"), + MsgProtectionLevelFixMode::FixedRtk => f.write_str("Fixed RTK"), + MsgProtectionLevelFixMode::DeadReckoning => f.write_str("Dead Reckoning"), + MsgProtectionLevelFixMode::SbasPosition => f.write_str("SBAS Position"), + } + } +} + +/// Inertial Navigation Mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgProtectionLevelInertialNavigationMode { + /// None + None = 0, + + /// INS used + InsUsed = 1, +} + +impl std::fmt::Display for MsgProtectionLevelInertialNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgProtectionLevelInertialNavigationMode::None => f.write_str("None"), + MsgProtectionLevelInertialNavigationMode::InsUsed => f.write_str("INS used"), + } + } +} + +/// Time status +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgProtectionLevelTimeStatus { + /// GNSS time of validity + GnssTimeOfValidity = 0, + + /// Other + Other = 1, +} + +impl std::fmt::Display for MsgProtectionLevelTimeStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgProtectionLevelTimeStatus::GnssTimeOfValidity => { + f.write_str("GNSS time of validity") + } + MsgProtectionLevelTimeStatus::Other => f.write_str("Other"), + } + } +} + /// Computed Position and Protection Level /// /// This message reports the local vertical and horizontal protection levels @@ -3107,6 +5058,34 @@ pub struct MsgProtectionLevelDepA { pub flags: u8, } +impl MsgProtectionLevelDepA { + pub fn target_integrity_risk_tir_level( + &self, + ) -> Option { + match get_bit_range!( self.flags, u8, u8, 2, 0 ) { + 0 => Some( MsgProtectionLevelDepATargetIntegrityRiskTirLevel :: SafeStateProtectionLevelShallNotBeUsedForSafetyCriticalApplication ), + 1 => Some( MsgProtectionLevelDepATargetIntegrityRiskTirLevel :: TirLevel1 ), + 2 => Some( MsgProtectionLevelDepATargetIntegrityRiskTirLevel :: TirLevel2 ), + 3 => Some( MsgProtectionLevelDepATargetIntegrityRiskTirLevel :: TirLevel3 ), + _ => None, + } + } + + pub fn set_target_integrity_risk_tir_level( + &mut self, + target_integrity_risk_tir_level: MsgProtectionLevelDepATargetIntegrityRiskTirLevel, + ) { + set_bit_range!( + &mut self.flags, + target_integrity_risk_tir_level, + u8, + u8, + 2, + 0 + ); + } +} + impl ConcreteMessage for MsgProtectionLevelDepA { const MESSAGE_TYPE: u16 = 534; const MESSAGE_NAME: &'static str = "MSG_PROTECTION_LEVEL_DEP_A"; @@ -3189,6 +5168,34 @@ impl WireFormat for MsgProtectionLevelDepA { } } +/// Target Integrity Risk (TIR) Level +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgProtectionLevelDepATargetIntegrityRiskTirLevel { + /// Safe state, protection level shall not be used for safety-critical + /// application + SafeStateProtectionLevelShallNotBeUsedForSafetyCriticalApplication = 0, + + /// TIR Level 1 + TirLevel1 = 1, + + /// TIR Level 2 + TirLevel2 = 2, + + /// TIR Level 3 + TirLevel3 = 3, +} + +impl std::fmt::Display for MsgProtectionLevelDepATargetIntegrityRiskTirLevel { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgProtectionLevelDepATargetIntegrityRiskTirLevel::SafeStateProtectionLevelShallNotBeUsedForSafetyCriticalApplication => f.write_str("Safe state, protection level shall not be used for safety-critical application"), + MsgProtectionLevelDepATargetIntegrityRiskTirLevel::TirLevel1 => f.write_str("TIR Level 1"), + MsgProtectionLevelDepATargetIntegrityRiskTirLevel::TirLevel2 => f.write_str("TIR Level 2"), + MsgProtectionLevelDepATargetIntegrityRiskTirLevel::TirLevel3 => f.write_str("TIR Level 3"), + } + } +} + /// UTC Time /// /// This message reports the Universal Coordinated Time (UTC). Note the flags @@ -3230,6 +5237,34 @@ pub struct MsgUtcTime { pub ns: u32, } +impl MsgUtcTime { + pub fn utc_offset_source(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(MsgUtcTimeUtcOffsetSource::FactoryDefault), + 1 => Some(MsgUtcTimeUtcOffsetSource::NonVolatileMemory), + 2 => Some(MsgUtcTimeUtcOffsetSource::DecodedThisSession), + _ => None, + } + } + + pub fn set_utc_offset_source(&mut self, utc_offset_source: MsgUtcTimeUtcOffsetSource) { + set_bit_range!(&mut self.flags, utc_offset_source, u8, u8, 4, 3); + } + + pub fn time_source(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgUtcTimeTimeSource::None), + 1 => Some(MsgUtcTimeTimeSource::GnssSolution), + 2 => Some(MsgUtcTimeTimeSource::Propagated), + _ => None, + } + } + + pub fn set_time_source(&mut self, time_source: MsgUtcTimeTimeSource) { + set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgUtcTime { const MESSAGE_TYPE: u16 = 259; const MESSAGE_NAME: &'static str = "MSG_UTC_TIME"; @@ -3320,6 +5355,52 @@ impl WireFormat for MsgUtcTime { } } +/// UTC offset source +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgUtcTimeUtcOffsetSource { + /// Factory Default + FactoryDefault = 0, + + /// Non Volatile Memory + NonVolatileMemory = 1, + + /// Decoded this Session + DecodedThisSession = 2, +} + +impl std::fmt::Display for MsgUtcTimeUtcOffsetSource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgUtcTimeUtcOffsetSource::FactoryDefault => f.write_str("Factory Default"), + MsgUtcTimeUtcOffsetSource::NonVolatileMemory => f.write_str("Non Volatile Memory"), + MsgUtcTimeUtcOffsetSource::DecodedThisSession => f.write_str("Decoded this Session"), + } + } +} + +/// Time source +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgUtcTimeTimeSource { + /// None (invalid) + None = 0, + + /// GNSS Solution + GnssSolution = 1, + + /// Propagated + Propagated = 2, +} + +impl std::fmt::Display for MsgUtcTimeTimeSource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgUtcTimeTimeSource::None => f.write_str("None (invalid)"), + MsgUtcTimeTimeSource::GnssSolution => f.write_str("GNSS Solution"), + MsgUtcTimeTimeSource::Propagated => f.write_str("Propagated"), + } + } +} + /// UTC Time /// /// This message reports the Universal Coordinated Time (UTC). Note the flags @@ -3361,6 +5442,34 @@ pub struct MsgUtcTimeGnss { pub ns: u32, } +impl MsgUtcTimeGnss { + pub fn utc_offset_source(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(MsgUtcTimeGnssUtcOffsetSource::FactoryDefault), + 1 => Some(MsgUtcTimeGnssUtcOffsetSource::NonVolatileMemory), + 2 => Some(MsgUtcTimeGnssUtcOffsetSource::DecodedThisSession), + _ => None, + } + } + + pub fn set_utc_offset_source(&mut self, utc_offset_source: MsgUtcTimeGnssUtcOffsetSource) { + set_bit_range!(&mut self.flags, utc_offset_source, u8, u8, 4, 3); + } + + pub fn time_source(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgUtcTimeGnssTimeSource::None), + 1 => Some(MsgUtcTimeGnssTimeSource::GnssSolution), + 2 => Some(MsgUtcTimeGnssTimeSource::Propagated), + _ => None, + } + } + + pub fn set_time_source(&mut self, time_source: MsgUtcTimeGnssTimeSource) { + set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgUtcTimeGnss { const MESSAGE_TYPE: u16 = 261; const MESSAGE_NAME: &'static str = "MSG_UTC_TIME_GNSS"; @@ -3451,6 +5560,54 @@ impl WireFormat for MsgUtcTimeGnss { } } +/// UTC offset source +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgUtcTimeGnssUtcOffsetSource { + /// Factory Default + FactoryDefault = 0, + + /// Non Volatile Memory + NonVolatileMemory = 1, + + /// Decoded this Session + DecodedThisSession = 2, +} + +impl std::fmt::Display for MsgUtcTimeGnssUtcOffsetSource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgUtcTimeGnssUtcOffsetSource::FactoryDefault => f.write_str("Factory Default"), + MsgUtcTimeGnssUtcOffsetSource::NonVolatileMemory => f.write_str("Non Volatile Memory"), + MsgUtcTimeGnssUtcOffsetSource::DecodedThisSession => { + f.write_str("Decoded this Session") + } + } + } +} + +/// Time source +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgUtcTimeGnssTimeSource { + /// None (invalid) + None = 0, + + /// GNSS Solution + GnssSolution = 1, + + /// Propagated + Propagated = 2, +} + +impl std::fmt::Display for MsgUtcTimeGnssTimeSource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgUtcTimeGnssTimeSource::None => f.write_str("None (invalid)"), + MsgUtcTimeGnssTimeSource::GnssSolution => f.write_str("GNSS Solution"), + MsgUtcTimeGnssTimeSource::Propagated => f.write_str("Propagated"), + } + } +} + /// Velocity in User Frame /// /// This message reports the velocity in the Vehicle Body Frame. By @@ -3507,6 +5664,34 @@ pub struct MsgVelBody { pub flags: u8, } +impl MsgVelBody { + pub fn ins_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(MsgVelBodyInsNavigationMode::None), + 1 => Some(MsgVelBodyInsNavigationMode::InsUsed), + _ => None, + } + } + + pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: MsgVelBodyInsNavigationMode) { + set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); + } + + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgVelBodyVelocityMode::Invalid), + 1 => Some(MsgVelBodyVelocityMode::MeasuredDopplerDerived), + 2 => Some(MsgVelBodyVelocityMode::ComputedDopplerDerived), + 3 => Some(MsgVelBodyVelocityMode::DeadReckoning), + _ => None, + } + } + + pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelBodyVelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgVelBody { const MESSAGE_TYPE: u16 = 531; const MESSAGE_NAME: &'static str = "MSG_VEL_BODY"; @@ -3609,6 +5794,56 @@ impl WireFormat for MsgVelBody { } } +/// INS Navigation Mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelBodyInsNavigationMode { + /// None + None = 0, + + /// INS used + InsUsed = 1, +} + +impl std::fmt::Display for MsgVelBodyInsNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelBodyInsNavigationMode::None => f.write_str("None"), + MsgVelBodyInsNavigationMode::InsUsed => f.write_str("INS used"), + } + } +} + +/// Velocity mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelBodyVelocityMode { + /// Invalid + Invalid = 0, + + /// Measured Doppler derived + MeasuredDopplerDerived = 1, + + /// Computed Doppler derived + ComputedDopplerDerived = 2, + + /// Dead Reckoning + DeadReckoning = 3, +} + +impl std::fmt::Display for MsgVelBodyVelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelBodyVelocityMode::Invalid => f.write_str("Invalid"), + MsgVelBodyVelocityMode::MeasuredDopplerDerived => { + f.write_str("Measured Doppler derived") + } + MsgVelBodyVelocityMode::ComputedDopplerDerived => { + f.write_str("Computed Doppler derived") + } + MsgVelBodyVelocityMode::DeadReckoning => f.write_str("Dead Reckoning"), + } + } +} + /// Velocity expressed as course over ground /// /// This message reports the receiver course over ground (COG) and speed over @@ -3655,6 +5890,73 @@ pub struct MsgVelCog { pub flags: u16, } +impl MsgVelCog { + pub fn vertical_velocity_validity(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 0) { + 0 => Some(MsgVelCogVerticalVelocityValidity::Invalid), + 1 => Some(MsgVelCogVerticalVelocityValidity::VerticalVelocityValid), + _ => None, + } + } + + pub fn set_vertical_velocity_validity( + &mut self, + vertical_velocity_validity: MsgVelCogVerticalVelocityValidity, + ) { + set_bit_range!(&mut self.flags, vertical_velocity_validity, u8, u8, 5, 0); + } + + pub fn sog_validity(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 0) { + 0 => Some(MsgVelCogSogValidity::Invalid), + 1 => Some(MsgVelCogSogValidity::SogValid), + _ => None, + } + } + + pub fn set_sog_validity(&mut self, sog_validity: MsgVelCogSogValidity) { + set_bit_range!(&mut self.flags, sog_validity, u8, u8, 4, 0); + } + + pub fn cog_validity(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 0) { + 0 => Some(MsgVelCogCogValidity::Invalid), + 1 => Some(MsgVelCogCogValidity::CogValid), + _ => None, + } + } + + pub fn set_cog_validity(&mut self, cog_validity: MsgVelCogCogValidity) { + set_bit_range!(&mut self.flags, cog_validity, u8, u8, 3, 0); + } + + pub fn ins_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgVelCogInsNavigationMode::None), + 1 => Some(MsgVelCogInsNavigationMode::InsUsed), + _ => None, + } + } + + pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: MsgVelCogInsNavigationMode) { + set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 2, 0); + } + + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 1, 0) { + 0 => Some(MsgVelCogVelocityMode::Invalid), + 1 => Some(MsgVelCogVelocityMode::MeasuredDopplerDerived), + 2 => Some(MsgVelCogVelocityMode::ComputedDopplerDerived), + 3 => Some(MsgVelCogVelocityMode::DeadReckoning), + _ => None, + } + } + + pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelCogVelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 1, 0); + } +} + impl ConcreteMessage for MsgVelCog { const MESSAGE_TYPE: u16 = 540; const MESSAGE_NAME: &'static str = "MSG_VEL_COG"; @@ -3741,6 +6043,115 @@ impl WireFormat for MsgVelCog { } } +/// Vertical velocity validity +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelCogVerticalVelocityValidity { + /// Invalid + Invalid = 0, + + /// Vertical velocity valid + VerticalVelocityValid = 1, +} + +impl std::fmt::Display for MsgVelCogVerticalVelocityValidity { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelCogVerticalVelocityValidity::Invalid => f.write_str("Invalid"), + MsgVelCogVerticalVelocityValidity::VerticalVelocityValid => { + f.write_str("Vertical velocity valid") + } + } + } +} + +/// SOG validity +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelCogSogValidity { + /// Invalid + Invalid = 0, + + /// SOG valid + SogValid = 1, +} + +impl std::fmt::Display for MsgVelCogSogValidity { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelCogSogValidity::Invalid => f.write_str("Invalid"), + MsgVelCogSogValidity::SogValid => f.write_str("SOG valid"), + } + } +} + +/// COG validity +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelCogCogValidity { + /// Invalid + Invalid = 0, + + /// COG valid + CogValid = 1, +} + +impl std::fmt::Display for MsgVelCogCogValidity { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelCogCogValidity::Invalid => f.write_str("Invalid"), + MsgVelCogCogValidity::CogValid => f.write_str("COG valid"), + } + } +} + +/// INS Navigation Mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelCogInsNavigationMode { + /// None + None = 0, + + /// INS used + InsUsed = 1, +} + +impl std::fmt::Display for MsgVelCogInsNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelCogInsNavigationMode::None => f.write_str("None"), + MsgVelCogInsNavigationMode::InsUsed => f.write_str("INS used"), + } + } +} + +/// Velocity mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelCogVelocityMode { + /// Invalid + Invalid = 0, + + /// Measured Doppler derived + MeasuredDopplerDerived = 1, + + /// Computed Doppler derived + ComputedDopplerDerived = 2, + + /// Dead Reckoning + DeadReckoning = 3, +} + +impl std::fmt::Display for MsgVelCogVelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelCogVelocityMode::Invalid => f.write_str("Invalid"), + MsgVelCogVelocityMode::MeasuredDopplerDerived => { + f.write_str("Measured Doppler derived") + } + MsgVelCogVelocityMode::ComputedDopplerDerived => { + f.write_str("Computed Doppler derived") + } + MsgVelCogVelocityMode::DeadReckoning => f.write_str("Dead Reckoning"), + } + } +} + /// Velocity in ECEF /// /// This message reports the velocity in Earth Centered Earth Fixed (ECEF) @@ -3776,6 +6187,46 @@ pub struct MsgVelEcef { pub flags: u8, } +impl MsgVelEcef { + pub fn type_of_reported_tow(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 5) { + 0 => Some(MsgVelEcefTypeOfReportedTow::TimeOfMeasurement), + 1 => Some(MsgVelEcefTypeOfReportedTow::Other), + _ => None, + } + } + + pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: MsgVelEcefTypeOfReportedTow) { + set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); + } + + pub fn ins_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(MsgVelEcefInsNavigationMode::None), + 1 => Some(MsgVelEcefInsNavigationMode::InsUsed), + _ => None, + } + } + + pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: MsgVelEcefInsNavigationMode) { + set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); + } + + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgVelEcefVelocityMode::Invalid), + 1 => Some(MsgVelEcefVelocityMode::MeasuredDopplerDerived), + 2 => Some(MsgVelEcefVelocityMode::ComputedDopplerDerived), + 3 => Some(MsgVelEcefVelocityMode::DeadReckoning), + _ => None, + } + } + + pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelEcefVelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgVelEcef { const MESSAGE_TYPE: u16 = 525; const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF"; @@ -3858,6 +6309,75 @@ impl WireFormat for MsgVelEcef { } } +/// Type of reported TOW +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelEcefTypeOfReportedTow { + /// Time of Measurement + TimeOfMeasurement = 0, + + /// Other + Other = 1, +} + +impl std::fmt::Display for MsgVelEcefTypeOfReportedTow { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelEcefTypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), + MsgVelEcefTypeOfReportedTow::Other => f.write_str("Other"), + } + } +} + +/// INS Navigation Mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelEcefInsNavigationMode { + /// None + None = 0, + + /// INS used + InsUsed = 1, +} + +impl std::fmt::Display for MsgVelEcefInsNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelEcefInsNavigationMode::None => f.write_str("None"), + MsgVelEcefInsNavigationMode::InsUsed => f.write_str("INS used"), + } + } +} + +/// Velocity mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelEcefVelocityMode { + /// Invalid + Invalid = 0, + + /// Measured Doppler derived + MeasuredDopplerDerived = 1, + + /// Computed Doppler derived + ComputedDopplerDerived = 2, + + /// Dead Reckoning + DeadReckoning = 3, +} + +impl std::fmt::Display for MsgVelEcefVelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelEcefVelocityMode::Invalid => f.write_str("Invalid"), + MsgVelEcefVelocityMode::MeasuredDopplerDerived => { + f.write_str("Measured Doppler derived") + } + MsgVelEcefVelocityMode::ComputedDopplerDerived => { + f.write_str("Computed Doppler derived") + } + MsgVelEcefVelocityMode::DeadReckoning => f.write_str("Dead Reckoning"), + } + } +} + /// Velocity in ECEF /// /// This message reports the velocity in Earth Centered Earth Fixed (ECEF) @@ -3908,6 +6428,49 @@ pub struct MsgVelEcefCov { pub flags: u8, } +impl MsgVelEcefCov { + pub fn type_of_reported_tow(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 5) { + 0 => Some(MsgVelEcefCovTypeOfReportedTow::TimeOfMeasurement), + 1 => Some(MsgVelEcefCovTypeOfReportedTow::Other), + _ => None, + } + } + + pub fn set_type_of_reported_tow( + &mut self, + type_of_reported_tow: MsgVelEcefCovTypeOfReportedTow, + ) { + set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); + } + + pub fn ins_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(MsgVelEcefCovInsNavigationMode::None), + 1 => Some(MsgVelEcefCovInsNavigationMode::InsUsed), + _ => None, + } + } + + pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: MsgVelEcefCovInsNavigationMode) { + set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); + } + + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgVelEcefCovVelocityMode::Invalid), + 1 => Some(MsgVelEcefCovVelocityMode::MeasuredDopplerDerived), + 2 => Some(MsgVelEcefCovVelocityMode::ComputedDopplerDerived), + 3 => Some(MsgVelEcefCovVelocityMode::DeadReckoning), + _ => None, + } + } + + pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelEcefCovVelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgVelEcefCov { const MESSAGE_TYPE: u16 = 533; const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF_COV"; @@ -4010,6 +6573,75 @@ impl WireFormat for MsgVelEcefCov { } } +/// Type of reported TOW +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelEcefCovTypeOfReportedTow { + /// Time of Measurement + TimeOfMeasurement = 0, + + /// Other + Other = 1, +} + +impl std::fmt::Display for MsgVelEcefCovTypeOfReportedTow { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelEcefCovTypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), + MsgVelEcefCovTypeOfReportedTow::Other => f.write_str("Other"), + } + } +} + +/// INS Navigation Mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelEcefCovInsNavigationMode { + /// None + None = 0, + + /// INS used + InsUsed = 1, +} + +impl std::fmt::Display for MsgVelEcefCovInsNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelEcefCovInsNavigationMode::None => f.write_str("None"), + MsgVelEcefCovInsNavigationMode::InsUsed => f.write_str("INS used"), + } + } +} + +/// Velocity mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelEcefCovVelocityMode { + /// Invalid + Invalid = 0, + + /// Measured Doppler derived + MeasuredDopplerDerived = 1, + + /// Computed Doppler derived + ComputedDopplerDerived = 2, + + /// Dead Reckoning + DeadReckoning = 3, +} + +impl std::fmt::Display for MsgVelEcefCovVelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelEcefCovVelocityMode::Invalid => f.write_str("Invalid"), + MsgVelEcefCovVelocityMode::MeasuredDopplerDerived => { + f.write_str("Measured Doppler derived") + } + MsgVelEcefCovVelocityMode::ComputedDopplerDerived => { + f.write_str("Computed Doppler derived") + } + MsgVelEcefCovVelocityMode::DeadReckoning => f.write_str("Dead Reckoning"), + } + } +} + /// GNSS-only Velocity in ECEF /// /// This message reports the velocity in Earth Centered Earth Fixed (ECEF) @@ -4060,6 +6692,21 @@ pub struct MsgVelEcefCovGnss { pub flags: u8, } +impl MsgVelEcefCovGnss { + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgVelEcefCovGnssVelocityMode::Invalid), + 1 => Some(MsgVelEcefCovGnssVelocityMode::MeasuredDopplerDerived), + 2 => Some(MsgVelEcefCovGnssVelocityMode::ComputedDopplerDerived), + _ => None, + } + } + + pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelEcefCovGnssVelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgVelEcefCovGnss { const MESSAGE_TYPE: u16 = 565; const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF_COV_GNSS"; @@ -4162,6 +6809,33 @@ impl WireFormat for MsgVelEcefCovGnss { } } +/// Velocity mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelEcefCovGnssVelocityMode { + /// Invalid + Invalid = 0, + + /// Measured Doppler derived + MeasuredDopplerDerived = 1, + + /// Computed Doppler derived + ComputedDopplerDerived = 2, +} + +impl std::fmt::Display for MsgVelEcefCovGnssVelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelEcefCovGnssVelocityMode::Invalid => f.write_str("Invalid"), + MsgVelEcefCovGnssVelocityMode::MeasuredDopplerDerived => { + f.write_str("Measured Doppler derived") + } + MsgVelEcefCovGnssVelocityMode::ComputedDopplerDerived => { + f.write_str("Computed Doppler derived") + } + } + } +} + /// Velocity in ECEF /// /// This message reports the velocity in Earth Centered Earth Fixed (ECEF) @@ -4314,6 +6988,21 @@ pub struct MsgVelEcefGnss { pub flags: u8, } +impl MsgVelEcefGnss { + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgVelEcefGnssVelocityMode::Invalid), + 1 => Some(MsgVelEcefGnssVelocityMode::MeasuredDopplerDerived), + 2 => Some(MsgVelEcefGnssVelocityMode::ComputedDopplerDerived), + _ => None, + } + } + + pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelEcefGnssVelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgVelEcefGnss { const MESSAGE_TYPE: u16 = 557; const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF_GNSS"; @@ -4396,6 +7085,33 @@ impl WireFormat for MsgVelEcefGnss { } } +/// Velocity mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelEcefGnssVelocityMode { + /// Invalid + Invalid = 0, + + /// Measured Doppler derived + MeasuredDopplerDerived = 1, + + /// Computed Doppler derived + ComputedDopplerDerived = 2, +} + +impl std::fmt::Display for MsgVelEcefGnssVelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelEcefGnssVelocityMode::Invalid => f.write_str("Invalid"), + MsgVelEcefGnssVelocityMode::MeasuredDopplerDerived => { + f.write_str("Measured Doppler derived") + } + MsgVelEcefGnssVelocityMode::ComputedDopplerDerived => { + f.write_str("Computed Doppler derived") + } + } + } +} + /// Velocity in NED /// /// This message reports the velocity in local North East Down (NED) @@ -4435,6 +7151,46 @@ pub struct MsgVelNed { pub flags: u8, } +impl MsgVelNed { + pub fn type_of_reported_tow(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 5) { + 0 => Some(MsgVelNedTypeOfReportedTow::TimeOfMeasurement), + 1 => Some(MsgVelNedTypeOfReportedTow::Other), + _ => None, + } + } + + pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: MsgVelNedTypeOfReportedTow) { + set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); + } + + pub fn ins_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(MsgVelNedInsNavigationMode::None), + 1 => Some(MsgVelNedInsNavigationMode::InsUsed), + _ => None, + } + } + + pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: MsgVelNedInsNavigationMode) { + set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); + } + + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgVelNedVelocityMode::Invalid), + 1 => Some(MsgVelNedVelocityMode::MeasuredDopplerDerived), + 2 => Some(MsgVelNedVelocityMode::ComputedDopplerDerived), + 3 => Some(MsgVelNedVelocityMode::DeadReckoning), + _ => None, + } + } + + pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelNedVelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgVelNed { const MESSAGE_TYPE: u16 = 526; const MESSAGE_NAME: &'static str = "MSG_VEL_NED"; @@ -4521,6 +7277,75 @@ impl WireFormat for MsgVelNed { } } +/// Type of reported TOW +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelNedTypeOfReportedTow { + /// Time of Measurement + TimeOfMeasurement = 0, + + /// Other + Other = 1, +} + +impl std::fmt::Display for MsgVelNedTypeOfReportedTow { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelNedTypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), + MsgVelNedTypeOfReportedTow::Other => f.write_str("Other"), + } + } +} + +/// INS Navigation Mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelNedInsNavigationMode { + /// None + None = 0, + + /// INS used + InsUsed = 1, +} + +impl std::fmt::Display for MsgVelNedInsNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelNedInsNavigationMode::None => f.write_str("None"), + MsgVelNedInsNavigationMode::InsUsed => f.write_str("INS used"), + } + } +} + +/// Velocity mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelNedVelocityMode { + /// Invalid + Invalid = 0, + + /// Measured Doppler derived + MeasuredDopplerDerived = 1, + + /// Computed Doppler derived + ComputedDopplerDerived = 2, + + /// Dead Reckoning + DeadReckoning = 3, +} + +impl std::fmt::Display for MsgVelNedVelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelNedVelocityMode::Invalid => f.write_str("Invalid"), + MsgVelNedVelocityMode::MeasuredDopplerDerived => { + f.write_str("Measured Doppler derived") + } + MsgVelNedVelocityMode::ComputedDopplerDerived => { + f.write_str("Computed Doppler derived") + } + MsgVelNedVelocityMode::DeadReckoning => f.write_str("Dead Reckoning"), + } + } +} + /// Velocity in NED /// /// This message reports the velocity in local North East Down (NED) @@ -4574,6 +7399,49 @@ pub struct MsgVelNedCov { pub flags: u8, } +impl MsgVelNedCov { + pub fn type_of_reported_tow(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 5) { + 0 => Some(MsgVelNedCovTypeOfReportedTow::TimeOfMeasurement), + 1 => Some(MsgVelNedCovTypeOfReportedTow::Other), + _ => None, + } + } + + pub fn set_type_of_reported_tow( + &mut self, + type_of_reported_tow: MsgVelNedCovTypeOfReportedTow, + ) { + set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); + } + + pub fn ins_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(MsgVelNedCovInsNavigationMode::None), + 1 => Some(MsgVelNedCovInsNavigationMode::InsUsed), + _ => None, + } + } + + pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: MsgVelNedCovInsNavigationMode) { + set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); + } + + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgVelNedCovVelocityMode::Invalid), + 1 => Some(MsgVelNedCovVelocityMode::MeasuredDopplerDerived), + 2 => Some(MsgVelNedCovVelocityMode::ComputedDopplerDerived), + 3 => Some(MsgVelNedCovVelocityMode::DeadReckoning), + _ => None, + } + } + + pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelNedCovVelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgVelNedCov { const MESSAGE_TYPE: u16 = 530; const MESSAGE_NAME: &'static str = "MSG_VEL_NED_COV"; @@ -4676,6 +7544,75 @@ impl WireFormat for MsgVelNedCov { } } +/// Type of reported TOW +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelNedCovTypeOfReportedTow { + /// Time of Measurement + TimeOfMeasurement = 0, + + /// Other + Other = 1, +} + +impl std::fmt::Display for MsgVelNedCovTypeOfReportedTow { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelNedCovTypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), + MsgVelNedCovTypeOfReportedTow::Other => f.write_str("Other"), + } + } +} + +/// INS Navigation Mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelNedCovInsNavigationMode { + /// None + None = 0, + + /// INS used + InsUsed = 1, +} + +impl std::fmt::Display for MsgVelNedCovInsNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelNedCovInsNavigationMode::None => f.write_str("None"), + MsgVelNedCovInsNavigationMode::InsUsed => f.write_str("INS used"), + } + } +} + +/// Velocity mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelNedCovVelocityMode { + /// Invalid + Invalid = 0, + + /// Measured Doppler derived + MeasuredDopplerDerived = 1, + + /// Computed Doppler derived + ComputedDopplerDerived = 2, + + /// Dead Reckoning + DeadReckoning = 3, +} + +impl std::fmt::Display for MsgVelNedCovVelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelNedCovVelocityMode::Invalid => f.write_str("Invalid"), + MsgVelNedCovVelocityMode::MeasuredDopplerDerived => { + f.write_str("Measured Doppler derived") + } + MsgVelNedCovVelocityMode::ComputedDopplerDerived => { + f.write_str("Computed Doppler derived") + } + MsgVelNedCovVelocityMode::DeadReckoning => f.write_str("Dead Reckoning"), + } + } +} + /// GNSS-only Velocity in NED /// /// This message reports the velocity in local North East Down (NED) @@ -4729,6 +7666,21 @@ pub struct MsgVelNedCovGnss { pub flags: u8, } +impl MsgVelNedCovGnss { + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgVelNedCovGnssVelocityMode::Invalid), + 1 => Some(MsgVelNedCovGnssVelocityMode::MeasuredDopplerDerived), + 2 => Some(MsgVelNedCovGnssVelocityMode::ComputedDopplerDerived), + _ => None, + } + } + + pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelNedCovGnssVelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgVelNedCovGnss { const MESSAGE_TYPE: u16 = 562; const MESSAGE_NAME: &'static str = "MSG_VEL_NED_COV_GNSS"; @@ -4831,6 +7783,33 @@ impl WireFormat for MsgVelNedCovGnss { } } +/// Velocity mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelNedCovGnssVelocityMode { + /// Invalid + Invalid = 0, + + /// Measured Doppler derived + MeasuredDopplerDerived = 1, + + /// Computed Doppler derived + ComputedDopplerDerived = 2, +} + +impl std::fmt::Display for MsgVelNedCovGnssVelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelNedCovGnssVelocityMode::Invalid => f.write_str("Invalid"), + MsgVelNedCovGnssVelocityMode::MeasuredDopplerDerived => { + f.write_str("Measured Doppler derived") + } + MsgVelNedCovGnssVelocityMode::ComputedDopplerDerived => { + f.write_str("Computed Doppler derived") + } + } + } +} + /// Velocity in NED /// /// This message reports the velocity in local North East Down (NED) @@ -4995,6 +7974,21 @@ pub struct MsgVelNedGnss { pub flags: u8, } +impl MsgVelNedGnss { + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgVelNedGnssVelocityMode::Invalid), + 1 => Some(MsgVelNedGnssVelocityMode::MeasuredDopplerDerived), + 2 => Some(MsgVelNedGnssVelocityMode::ComputedDopplerDerived), + _ => None, + } + } + + pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelNedGnssVelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgVelNedGnss { const MESSAGE_TYPE: u16 = 558; const MESSAGE_NAME: &'static str = "MSG_VEL_NED_GNSS"; @@ -5080,3 +8074,30 @@ impl WireFormat for MsgVelNedGnss { } } } + +/// Velocity mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgVelNedGnssVelocityMode { + /// Invalid + Invalid = 0, + + /// Measured Doppler derived + MeasuredDopplerDerived = 1, + + /// Computed Doppler derived + ComputedDopplerDerived = 2, +} + +impl std::fmt::Display for MsgVelNedGnssVelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgVelNedGnssVelocityMode::Invalid => f.write_str("Invalid"), + MsgVelNedGnssVelocityMode::MeasuredDopplerDerived => { + f.write_str("Measured Doppler derived") + } + MsgVelNedGnssVelocityMode::ComputedDopplerDerived => { + f.write_str("Computed Doppler derived") + } + } + } +} diff --git a/rust/sbp/src/messages/ndb.rs b/rust/sbp/src/messages/ndb.rs index 5b7d263d74..1d348dd65c 100644 --- a/rust/sbp/src/messages/ndb.rs +++ b/rust/sbp/src/messages/ndb.rs @@ -61,6 +61,74 @@ pub struct MsgNdbEvent { pub original_sender: u16, } +impl MsgNdbEvent { + pub fn event_type(&self) -> Option { + match get_bit_range!(self.event, u8, u8, 1, 0) { + 0 => Some(MsgNdbEventEventType::UNKNOWN), + 1 => Some(MsgNdbEventEventType::STORE), + 2 => Some(MsgNdbEventEventType::FETCH), + 3 => Some(MsgNdbEventEventType::ERASE), + _ => None, + } + } + + pub fn set_event_type(&mut self, event_type: MsgNdbEventEventType) { + set_bit_range!(&mut self.event, event_type, u8, u8, 1, 0); + } + + pub fn event_object_type(&self) -> Option { + match get_bit_range!(self.object_type, u8, u8, 2, 0) { + 0 => Some(MsgNdbEventEventObjectType::UNKNOWN), + 1 => Some(MsgNdbEventEventObjectType::EPHEMERIS), + 2 => Some(MsgNdbEventEventObjectType::ALMANAC), + 3 => Some(MsgNdbEventEventObjectType::AlmanacWn), + 4 => Some(MsgNdbEventEventObjectType::IoNO), + 5 => Some(MsgNdbEventEventObjectType::L2CCap), + 6 => Some(MsgNdbEventEventObjectType::LGF), + _ => None, + } + } + + pub fn set_event_object_type(&mut self, event_object_type: MsgNdbEventEventObjectType) { + set_bit_range!(&mut self.object_type, event_object_type, u8, u8, 2, 0); + } + + pub fn event_result(&self) -> Option { + match get_bit_range!(self.result, u8, u8, 3, 0) { + 0 => Some(MsgNdbEventEventResult::NdbErrNone), + 1 => Some(MsgNdbEventEventResult::NdbErrMissingIe), + 2 => Some(MsgNdbEventEventResult::NdbErrUnsupported), + 3 => Some(MsgNdbEventEventResult::NdbErrFileIo), + 4 => Some(MsgNdbEventEventResult::NdbErrInitDone), + 5 => Some(MsgNdbEventEventResult::NdbErrBadParam), + 6 => Some(MsgNdbEventEventResult::NdbErrUnreliableData), + 7 => Some(MsgNdbEventEventResult::NdbErrAlgorithmError), + 8 => Some(MsgNdbEventEventResult::NdbErrNoData), + 9 => Some(MsgNdbEventEventResult::NdbErrNoChange), + 10 => Some(MsgNdbEventEventResult::NdbErrOlderData), + _ => None, + } + } + + pub fn set_event_result(&mut self, event_result: MsgNdbEventEventResult) { + set_bit_range!(&mut self.result, event_result, u8, u8, 3, 0); + } + + pub fn data_source(&self) -> Option { + match get_bit_range!(self.data_source, u8, u8, 1, 0) { + 0 => Some(MsgNdbEventDataSource::NdbDsUndefined), + 1 => Some(MsgNdbEventDataSource::NdbDsInit), + 2 => Some(MsgNdbEventDataSource::NdbDsReceiver), + 3 => Some(MsgNdbEventDataSource::NdbDsSbp), + _ => None, + } + } + + pub fn set_data_source(&mut self, data_source: MsgNdbEventDataSource) { + set_bit_range!(&mut self.data_source, data_source, u8, u8, 1, 0); + } +} + impl ConcreteMessage for MsgNdbEvent { const MESSAGE_TYPE: u16 = 1024; const MESSAGE_NAME: &'static str = "MSG_NDB_EVENT"; @@ -137,3 +205,151 @@ impl WireFormat for MsgNdbEvent { } } } + +/// Event type. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgNdbEventEventType { + /// UNKNOWN + UNKNOWN = 0, + + /// STORE + STORE = 1, + + /// FETCH + FETCH = 2, + + /// ERASE + ERASE = 3, +} + +impl std::fmt::Display for MsgNdbEventEventType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgNdbEventEventType::UNKNOWN => f.write_str("UNKNOWN"), + MsgNdbEventEventType::STORE => f.write_str("STORE"), + MsgNdbEventEventType::FETCH => f.write_str("FETCH"), + MsgNdbEventEventType::ERASE => f.write_str("ERASE"), + } + } +} + +/// Event object type. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgNdbEventEventObjectType { + /// UNKNOWN + UNKNOWN = 0, + + /// EPHEMERIS + EPHEMERIS = 1, + + /// ALMANAC + ALMANAC = 2, + + /// ALMANAC_WN + AlmanacWn = 3, + + /// IONO + IoNO = 4, + + /// L2C_CAP + L2CCap = 5, + + /// LGF + LGF = 6, +} + +impl std::fmt::Display for MsgNdbEventEventObjectType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgNdbEventEventObjectType::UNKNOWN => f.write_str("UNKNOWN"), + MsgNdbEventEventObjectType::EPHEMERIS => f.write_str("EPHEMERIS"), + MsgNdbEventEventObjectType::ALMANAC => f.write_str("ALMANAC"), + MsgNdbEventEventObjectType::AlmanacWn => f.write_str("ALMANAC_WN"), + MsgNdbEventEventObjectType::IoNO => f.write_str("IONO"), + MsgNdbEventEventObjectType::L2CCap => f.write_str("L2C_CAP"), + MsgNdbEventEventObjectType::LGF => f.write_str("LGF"), + } + } +} + +/// Event result. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgNdbEventEventResult { + /// NDB_ERR_NONE + NdbErrNone = 0, + + /// NDB_ERR_MISSING_IE + NdbErrMissingIe = 1, + + /// NDB_ERR_UNSUPPORTED + NdbErrUnsupported = 2, + + /// NDB_ERR_FILE_IO + NdbErrFileIo = 3, + + /// NDB_ERR_INIT_DONE + NdbErrInitDone = 4, + + /// NDB_ERR_BAD_PARAM + NdbErrBadParam = 5, + + /// NDB_ERR_UNRELIABLE_DATA + NdbErrUnreliableData = 6, + + /// NDB_ERR_ALGORITHM_ERROR + NdbErrAlgorithmError = 7, + + /// NDB_ERR_NO_DATA + NdbErrNoData = 8, + + /// NDB_ERR_NO_CHANGE + NdbErrNoChange = 9, + + /// NDB_ERR_OLDER_DATA + NdbErrOlderData = 10, +} + +impl std::fmt::Display for MsgNdbEventEventResult { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgNdbEventEventResult::NdbErrNone => f.write_str("NDB_ERR_NONE"), + MsgNdbEventEventResult::NdbErrMissingIe => f.write_str("NDB_ERR_MISSING_IE"), + MsgNdbEventEventResult::NdbErrUnsupported => f.write_str("NDB_ERR_UNSUPPORTED"), + MsgNdbEventEventResult::NdbErrFileIo => f.write_str("NDB_ERR_FILE_IO"), + MsgNdbEventEventResult::NdbErrInitDone => f.write_str("NDB_ERR_INIT_DONE"), + MsgNdbEventEventResult::NdbErrBadParam => f.write_str("NDB_ERR_BAD_PARAM"), + MsgNdbEventEventResult::NdbErrUnreliableData => f.write_str("NDB_ERR_UNRELIABLE_DATA"), + MsgNdbEventEventResult::NdbErrAlgorithmError => f.write_str("NDB_ERR_ALGORITHM_ERROR"), + MsgNdbEventEventResult::NdbErrNoData => f.write_str("NDB_ERR_NO_DATA"), + MsgNdbEventEventResult::NdbErrNoChange => f.write_str("NDB_ERR_NO_CHANGE"), + MsgNdbEventEventResult::NdbErrOlderData => f.write_str("NDB_ERR_OLDER_DATA"), + } + } +} + +/// Data source. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgNdbEventDataSource { + /// NDB_DS_UNDEFINED + NdbDsUndefined = 0, + + /// NDB_DS_INIT + NdbDsInit = 1, + + /// NDB_DS_RECEIVER + NdbDsReceiver = 2, + + /// NDB_DS_SBP + NdbDsSbp = 3, +} + +impl std::fmt::Display for MsgNdbEventDataSource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgNdbEventDataSource::NdbDsUndefined => f.write_str("NDB_DS_UNDEFINED"), + MsgNdbEventDataSource::NdbDsInit => f.write_str("NDB_DS_INIT"), + MsgNdbEventDataSource::NdbDsReceiver => f.write_str("NDB_DS_RECEIVER"), + MsgNdbEventDataSource::NdbDsSbp => f.write_str("NDB_DS_SBP"), + } + } +} diff --git a/rust/sbp/src/messages/observation.rs b/rust/sbp/src/messages/observation.rs index 7fb1797527..42313a8fab 100644 --- a/rust/sbp/src/messages/observation.rs +++ b/rust/sbp/src/messages/observation.rs @@ -5914,6 +5914,76 @@ pub struct PackedObsContent { pub sid: GnssSignal, } +impl PackedObsContent { + pub fn raim_exclusion(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 7, 0) { + 0 => Some(PackedObsContentRaimExclusion::NoExclusion), + 1 => Some(PackedObsContentRaimExclusion::MeasurementWasExcludedBySppRaimUseWithCare), + _ => None, + } + } + + pub fn set_raim_exclusion(&mut self, raim_exclusion: PackedObsContentRaimExclusion) { + set_bit_range!(&mut self.flags, raim_exclusion, u8, u8, 7, 0); + } + + pub fn doppler_valid(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 0) { + 0 => Some(PackedObsContentDopplerValid::InvalidDopplerMeasurement), + 1 => Some(PackedObsContentDopplerValid::ValidDopplerMeasurement), + _ => None, + } + } + + pub fn set_doppler_valid(&mut self, doppler_valid: PackedObsContentDopplerValid) { + set_bit_range!(&mut self.flags, doppler_valid, u8, u8, 3, 0); + } + + pub fn halfcycle_ambiguity(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(PackedObsContentHalfCycleAmbiguity::HalfCyclePhaseAmbiguityUnresolved), + 1 => Some(PackedObsContentHalfCycleAmbiguity::HalfCyclePhaseAmbiguityResolved), + _ => None, + } + } + + pub fn set_halfcycle_ambiguity( + &mut self, + halfcycle_ambiguity: PackedObsContentHalfCycleAmbiguity, + ) { + set_bit_range!(&mut self.flags, halfcycle_ambiguity, u8, u8, 2, 0); + } + + pub fn carrier_phase_valid(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 1, 0) { + 0 => Some(PackedObsContentCarrierPhaseValid::InvalidCarrierPhaseMeasurement), + 1 => Some(PackedObsContentCarrierPhaseValid::ValidCarrierPhaseMeasurement), + _ => None, + } + } + + pub fn set_carrier_phase_valid( + &mut self, + carrier_phase_valid: PackedObsContentCarrierPhaseValid, + ) { + set_bit_range!(&mut self.flags, carrier_phase_valid, u8, u8, 1, 0); + } + + pub fn pseudorange_valid(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 0, 0) { + 0 => Some(PackedObsContentPseudorangeValid::InvalidPseudorangeMeasurement), + 1 => Some( + PackedObsContentPseudorangeValid::ValidPseudorangeMeasurementAndCoarseTowDecoded, + ), + _ => None, + } + } + + pub fn set_pseudorange_valid(&mut self, pseudorange_valid: PackedObsContentPseudorangeValid) { + set_bit_range!(&mut self.flags, pseudorange_valid, u8, u8, 0, 0); + } +} + impl WireFormat for PackedObsContent { const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN @@ -5953,6 +6023,119 @@ impl WireFormat for PackedObsContent { } } +/// RAIM exclusion +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum PackedObsContentRaimExclusion { + /// No exclusion + NoExclusion = 0, + + /// Measurement was excluded by SPP RAIM, use with care + MeasurementWasExcludedBySppRaimUseWithCare = 1, +} + +impl std::fmt::Display for PackedObsContentRaimExclusion { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + PackedObsContentRaimExclusion::NoExclusion => f.write_str("No exclusion"), + PackedObsContentRaimExclusion::MeasurementWasExcludedBySppRaimUseWithCare => { + f.write_str("Measurement was excluded by SPP RAIM, use with care") + } + } + } +} + +/// Doppler valid +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum PackedObsContentDopplerValid { + /// Invalid doppler measurement + InvalidDopplerMeasurement = 0, + + /// Valid doppler measurement + ValidDopplerMeasurement = 1, +} + +impl std::fmt::Display for PackedObsContentDopplerValid { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + PackedObsContentDopplerValid::InvalidDopplerMeasurement => { + f.write_str("Invalid doppler measurement") + } + PackedObsContentDopplerValid::ValidDopplerMeasurement => { + f.write_str("Valid doppler measurement") + } + } + } +} + +/// Half-cycle ambiguity +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum PackedObsContentHalfCycleAmbiguity { + /// Half cycle phase ambiguity unresolved + HalfCyclePhaseAmbiguityUnresolved = 0, + + /// Half cycle phase ambiguity resolved + HalfCyclePhaseAmbiguityResolved = 1, +} + +impl std::fmt::Display for PackedObsContentHalfCycleAmbiguity { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + PackedObsContentHalfCycleAmbiguity::HalfCyclePhaseAmbiguityUnresolved => { + f.write_str("Half cycle phase ambiguity unresolved") + } + PackedObsContentHalfCycleAmbiguity::HalfCyclePhaseAmbiguityResolved => { + f.write_str("Half cycle phase ambiguity resolved") + } + } + } +} + +/// Carrier phase valid +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum PackedObsContentCarrierPhaseValid { + /// Invalid carrier phase measurement + InvalidCarrierPhaseMeasurement = 0, + + /// Valid carrier phase measurement + ValidCarrierPhaseMeasurement = 1, +} + +impl std::fmt::Display for PackedObsContentCarrierPhaseValid { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + PackedObsContentCarrierPhaseValid::InvalidCarrierPhaseMeasurement => { + f.write_str("Invalid carrier phase measurement") + } + PackedObsContentCarrierPhaseValid::ValidCarrierPhaseMeasurement => { + f.write_str("Valid carrier phase measurement") + } + } + } +} + +/// Pseudorange valid +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum PackedObsContentPseudorangeValid { + /// Invalid pseudorange measurement + InvalidPseudorangeMeasurement = 0, + + /// Valid pseudorange measurement and coarse TOW decoded + ValidPseudorangeMeasurementAndCoarseTowDecoded = 1, +} + +impl std::fmt::Display for PackedObsContentPseudorangeValid { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + PackedObsContentPseudorangeValid::InvalidPseudorangeMeasurement => { + f.write_str("Invalid pseudorange measurement") + } + PackedObsContentPseudorangeValid::ValidPseudorangeMeasurementAndCoarseTowDecoded => { + f.write_str("Valid pseudorange measurement and coarse TOW decoded") + } + } + } +} + /// Deprecated /// /// Deprecated. @@ -6165,6 +6348,80 @@ pub struct PackedOsrContent { pub range_std: u16, } +impl PackedOsrContent { + pub fn invalid_phase_corrections(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 0) { + 0 => Some(PackedOsrContentInvalidPhaseCorrections::ValidPhaseCorrections), + 1 => Some(PackedOsrContentInvalidPhaseCorrections::DoNotUsePhaseCorrections), + _ => None, + } + } + + pub fn set_invalid_phase_corrections( + &mut self, + invalid_phase_corrections: PackedOsrContentInvalidPhaseCorrections, + ) { + set_bit_range!(&mut self.flags, invalid_phase_corrections, u8, u8, 4, 0); + } + + pub fn invalid_code_corrections(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 0) { + 0 => Some(PackedOsrContentInvalidCodeCorrections::ValidCodeCorrections), + 1 => Some(PackedOsrContentInvalidCodeCorrections::DoNotUseCodeCorrections), + _ => None, + } + } + + pub fn set_invalid_code_corrections( + &mut self, + invalid_code_corrections: PackedOsrContentInvalidCodeCorrections, + ) { + set_bit_range!(&mut self.flags, invalid_code_corrections, u8, u8, 3, 0); + } + + pub fn full_fixing_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(PackedOsrContentFullFixingFlag::FullFixingUnavailable), + 1 => Some(PackedOsrContentFullFixingFlag::FullFixingAvailable), + _ => None, + } + } + + pub fn set_full_fixing_flag(&mut self, full_fixing_flag: PackedOsrContentFullFixingFlag) { + set_bit_range!(&mut self.flags, full_fixing_flag, u8, u8, 2, 0); + } + + pub fn partial_fixing_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 1, 0) { + 0 => Some(PackedOsrContentPartialFixingFlag::PartialFixingUnavailable), + 1 => Some(PackedOsrContentPartialFixingFlag::PartialFixingAvailable), + _ => None, + } + } + + pub fn set_partial_fixing_flag( + &mut self, + partial_fixing_flag: PackedOsrContentPartialFixingFlag, + ) { + set_bit_range!(&mut self.flags, partial_fixing_flag, u8, u8, 1, 0); + } + + pub fn correction_validity(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 0, 0) { + 0 => Some(PackedOsrContentCorrectionValidity::DoNotUseSignal), + 1 => Some(PackedOsrContentCorrectionValidity::ValidSignal), + _ => None, + } + } + + pub fn set_correction_validity( + &mut self, + correction_validity: PackedOsrContentCorrectionValidity, + ) { + set_bit_range!(&mut self.flags, correction_validity, u8, u8, 0, 0); + } +} + impl WireFormat for PackedOsrContent { const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN @@ -6208,6 +6465,117 @@ impl WireFormat for PackedOsrContent { } } +/// Invalid phase corrections +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum PackedOsrContentInvalidPhaseCorrections { + /// Valid phase corrections + ValidPhaseCorrections = 0, + + /// Do not use phase corrections + DoNotUsePhaseCorrections = 1, +} + +impl std::fmt::Display for PackedOsrContentInvalidPhaseCorrections { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + PackedOsrContentInvalidPhaseCorrections::ValidPhaseCorrections => { + f.write_str("Valid phase corrections") + } + PackedOsrContentInvalidPhaseCorrections::DoNotUsePhaseCorrections => { + f.write_str("Do not use phase corrections") + } + } + } +} + +/// Invalid code corrections +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum PackedOsrContentInvalidCodeCorrections { + /// Valid code corrections + ValidCodeCorrections = 0, + + /// Do not use code corrections + DoNotUseCodeCorrections = 1, +} + +impl std::fmt::Display for PackedOsrContentInvalidCodeCorrections { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + PackedOsrContentInvalidCodeCorrections::ValidCodeCorrections => { + f.write_str("Valid code corrections") + } + PackedOsrContentInvalidCodeCorrections::DoNotUseCodeCorrections => { + f.write_str("Do not use code corrections") + } + } + } +} + +/// Full fixing flag +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum PackedOsrContentFullFixingFlag { + /// Full fixing unavailable + FullFixingUnavailable = 0, + + /// Full fixing available + FullFixingAvailable = 1, +} + +impl std::fmt::Display for PackedOsrContentFullFixingFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + PackedOsrContentFullFixingFlag::FullFixingUnavailable => { + f.write_str("Full fixing unavailable") + } + PackedOsrContentFullFixingFlag::FullFixingAvailable => { + f.write_str("Full fixing available") + } + } + } +} + +/// Partial fixing flag +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum PackedOsrContentPartialFixingFlag { + /// Partial fixing unavailable + PartialFixingUnavailable = 0, + + /// Partial fixing available + PartialFixingAvailable = 1, +} + +impl std::fmt::Display for PackedOsrContentPartialFixingFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + PackedOsrContentPartialFixingFlag::PartialFixingUnavailable => { + f.write_str("Partial fixing unavailable") + } + PackedOsrContentPartialFixingFlag::PartialFixingAvailable => { + f.write_str("Partial fixing available") + } + } + } +} + +/// Correction validity +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum PackedOsrContentCorrectionValidity { + /// Do not use signal + DoNotUseSignal = 0, + + /// Valid signal + ValidSignal = 1, +} + +impl std::fmt::Display for PackedOsrContentCorrectionValidity { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + PackedOsrContentCorrectionValidity::DoNotUseSignal => f.write_str("Do not use signal"), + PackedOsrContentCorrectionValidity::ValidSignal => f.write_str("Valid signal"), + } + } +} + /// Satellite azimuth and elevation /// /// Satellite azimuth and elevation. diff --git a/rust/sbp/src/messages/orientation.rs b/rust/sbp/src/messages/orientation.rs index 5b68f0aab5..5dad77076e 100644 --- a/rust/sbp/src/messages/orientation.rs +++ b/rust/sbp/src/messages/orientation.rs @@ -51,6 +51,23 @@ pub struct MsgAngularRate { pub flags: u8, } +impl MsgAngularRate { + pub fn ins_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgAngularRateInsNavigationMode::Invalid), + 1 => Some(MsgAngularRateInsNavigationMode::Valid), + _ => None, + } + } + + pub fn set_ins_navigation_mode( + &mut self, + ins_navigation_mode: MsgAngularRateInsNavigationMode, + ) { + set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgAngularRate { const MESSAGE_TYPE: u16 = 546; const MESSAGE_NAME: &'static str = "MSG_ANGULAR_RATE"; @@ -125,6 +142,25 @@ impl WireFormat for MsgAngularRate { } } +/// INS Navigation mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgAngularRateInsNavigationMode { + /// Invalid + Invalid = 0, + + /// Valid + Valid = 1, +} + +impl std::fmt::Display for MsgAngularRateInsNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgAngularRateInsNavigationMode::Invalid => f.write_str("Invalid"), + MsgAngularRateInsNavigationMode::Valid => f.write_str("Valid"), + } + } +} + /// Heading relative to True North /// /// This message reports the baseline heading pointing from the base station @@ -153,6 +189,22 @@ pub struct MsgBaselineHeading { pub flags: u8, } +impl MsgBaselineHeading { + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgBaselineHeadingFixMode::Invalid), + 2 => Some(MsgBaselineHeadingFixMode::DifferentialGnss), + 3 => Some(MsgBaselineHeadingFixMode::FloatRtk), + 4 => Some(MsgBaselineHeadingFixMode::FixedRtk), + _ => None, + } + } + + pub fn set_fix_mode(&mut self, fix_mode: MsgBaselineHeadingFixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgBaselineHeading { const MESSAGE_TYPE: u16 = 527; const MESSAGE_NAME: &'static str = "MSG_BASELINE_HEADING"; @@ -223,6 +275,33 @@ impl WireFormat for MsgBaselineHeading { } } +/// Fix mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgBaselineHeadingFixMode { + /// Invalid + Invalid = 0, + + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, + + /// Float RTK + FloatRtk = 3, + + /// Fixed RTK + FixedRtk = 4, +} + +impl std::fmt::Display for MsgBaselineHeadingFixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgBaselineHeadingFixMode::Invalid => f.write_str("Invalid"), + MsgBaselineHeadingFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + MsgBaselineHeadingFixMode::FloatRtk => f.write_str("Float RTK"), + MsgBaselineHeadingFixMode::FixedRtk => f.write_str("Fixed RTK"), + } + } +} + /// Euler angles /// /// This message reports the yaw, pitch, and roll angles of the vehicle body @@ -264,6 +343,23 @@ pub struct MsgOrientEuler { pub flags: u8, } +impl MsgOrientEuler { + pub fn ins_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgOrientEulerInsNavigationMode::Invalid), + 1 => Some(MsgOrientEulerInsNavigationMode::Valid), + _ => None, + } + } + + pub fn set_ins_navigation_mode( + &mut self, + ins_navigation_mode: MsgOrientEulerInsNavigationMode, + ) { + set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgOrientEuler { const MESSAGE_TYPE: u16 = 545; const MESSAGE_NAME: &'static str = "MSG_ORIENT_EULER"; @@ -350,6 +446,25 @@ impl WireFormat for MsgOrientEuler { } } +/// INS Navigation mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgOrientEulerInsNavigationMode { + /// Invalid + Invalid = 0, + + /// Valid + Valid = 1, +} + +impl std::fmt::Display for MsgOrientEulerInsNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgOrientEulerInsNavigationMode::Invalid => f.write_str("Invalid"), + MsgOrientEulerInsNavigationMode::Valid => f.write_str("Valid"), + } + } +} + /// Quaternion 4 component vector /// /// This message reports the quaternion vector describing the vehicle body @@ -397,6 +512,20 @@ pub struct MsgOrientQuat { pub flags: u8, } +impl MsgOrientQuat { + pub fn ins_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgOrientQuatInsNavigationMode::Invalid), + 1 => Some(MsgOrientQuatInsNavigationMode::Valid), + _ => None, + } + } + + pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: MsgOrientQuatInsNavigationMode) { + set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgOrientQuat { const MESSAGE_TYPE: u16 = 544; const MESSAGE_NAME: &'static str = "MSG_ORIENT_QUAT"; @@ -490,3 +619,22 @@ impl WireFormat for MsgOrientQuat { } } } + +/// INS Navigation mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgOrientQuatInsNavigationMode { + /// Invalid + Invalid = 0, + + /// Valid + Valid = 1, +} + +impl std::fmt::Display for MsgOrientQuatInsNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgOrientQuatInsNavigationMode::Invalid => f.write_str("Invalid"), + MsgOrientQuatInsNavigationMode::Valid => f.write_str("Valid"), + } + } +} diff --git a/rust/sbp/src/messages/piksi.rs b/rust/sbp/src/messages/piksi.rs index d900505d13..cf187d48e7 100644 --- a/rust/sbp/src/messages/piksi.rs +++ b/rust/sbp/src/messages/piksi.rs @@ -848,6 +848,35 @@ pub struct MsgMaskSatellite { pub sid: GnssSignal, } +impl MsgMaskSatellite { + pub fn tracking_channels(&self) -> Option { + match get_bit_range!(self.mask, u8, u8, 1, 0) { + 0 => Some(MsgMaskSatelliteTrackingChannels::Enabled), + 1 => Some(MsgMaskSatelliteTrackingChannels::DropThisPrnIfCurrentlyTracking), + _ => None, + } + } + + pub fn set_tracking_channels(&mut self, tracking_channels: MsgMaskSatelliteTrackingChannels) { + set_bit_range!(&mut self.mask, tracking_channels, u8, u8, 1, 0); + } + + pub fn acquisition_channel(&self) -> Option { + match get_bit_range!(self.mask, u8, u8, 0, 0) { + 0 => Some(MsgMaskSatelliteAcquisitionChannel::Enabled), + 1 => Some(MsgMaskSatelliteAcquisitionChannel::SkipThisSatelliteOnFutureAcquisitions), + _ => None, + } + } + + pub fn set_acquisition_channel( + &mut self, + acquisition_channel: MsgMaskSatelliteAcquisitionChannel, + ) { + set_bit_range!(&mut self.mask, acquisition_channel, u8, u8, 0, 0); + } +} + impl ConcreteMessage for MsgMaskSatellite { const MESSAGE_TYPE: u16 = 43; const MESSAGE_NAME: &'static str = "MSG_MASK_SATELLITE"; @@ -899,6 +928,48 @@ impl WireFormat for MsgMaskSatellite { } } +/// Tracking channels +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgMaskSatelliteTrackingChannels { + /// Enabled + Enabled = 0, + + /// Drop this PRN if currently tracking + DropThisPrnIfCurrentlyTracking = 1, +} + +impl std::fmt::Display for MsgMaskSatelliteTrackingChannels { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgMaskSatelliteTrackingChannels::Enabled => f.write_str("Enabled"), + MsgMaskSatelliteTrackingChannels::DropThisPrnIfCurrentlyTracking => { + f.write_str("Drop this PRN if currently tracking") + } + } + } +} + +/// Acquisition channel +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgMaskSatelliteAcquisitionChannel { + /// Enabled + Enabled = 0, + + /// Skip this satellite on future acquisitions + SkipThisSatelliteOnFutureAcquisitions = 1, +} + +impl std::fmt::Display for MsgMaskSatelliteAcquisitionChannel { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgMaskSatelliteAcquisitionChannel::Enabled => f.write_str("Enabled"), + MsgMaskSatelliteAcquisitionChannel::SkipThisSatelliteOnFutureAcquisitions => { + f.write_str("Skip this satellite on future acquisitions") + } + } + } +} + /// Deprecated /// /// Deprecated. @@ -917,6 +988,38 @@ pub struct MsgMaskSatelliteDep { pub sid: GnssSignalDep, } +impl MsgMaskSatelliteDep { + pub fn tracking_channels(&self) -> Option { + match get_bit_range!(self.mask, u8, u8, 1, 0) { + 0 => Some(MsgMaskSatelliteDepTrackingChannels::Enabled), + 1 => Some(MsgMaskSatelliteDepTrackingChannels::DropThisPrnIfCurrentlyTracking), + _ => None, + } + } + + pub fn set_tracking_channels( + &mut self, + tracking_channels: MsgMaskSatelliteDepTrackingChannels, + ) { + set_bit_range!(&mut self.mask, tracking_channels, u8, u8, 1, 0); + } + + pub fn acquisition_channel(&self) -> Option { + match get_bit_range!(self.mask, u8, u8, 0, 0) { + 0 => Some(MsgMaskSatelliteDepAcquisitionChannel::Enabled), + 1 => Some(MsgMaskSatelliteDepAcquisitionChannel::SkipThisSatelliteOnFutureAcquisitions), + _ => None, + } + } + + pub fn set_acquisition_channel( + &mut self, + acquisition_channel: MsgMaskSatelliteDepAcquisitionChannel, + ) { + set_bit_range!(&mut self.mask, acquisition_channel, u8, u8, 0, 0); + } +} + impl ConcreteMessage for MsgMaskSatelliteDep { const MESSAGE_TYPE: u16 = 27; const MESSAGE_NAME: &'static str = "MSG_MASK_SATELLITE_DEP"; @@ -968,6 +1071,48 @@ impl WireFormat for MsgMaskSatelliteDep { } } +/// Tracking channels +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgMaskSatelliteDepTrackingChannels { + /// Enabled + Enabled = 0, + + /// Drop this PRN if currently tracking + DropThisPrnIfCurrentlyTracking = 1, +} + +impl std::fmt::Display for MsgMaskSatelliteDepTrackingChannels { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgMaskSatelliteDepTrackingChannels::Enabled => f.write_str("Enabled"), + MsgMaskSatelliteDepTrackingChannels::DropThisPrnIfCurrentlyTracking => { + f.write_str("Drop this PRN if currently tracking") + } + } + } +} + +/// Acquisition channel +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgMaskSatelliteDepAcquisitionChannel { + /// Enabled + Enabled = 0, + + /// Skip this satellite on future acquisitions + SkipThisSatelliteOnFutureAcquisitions = 1, +} + +impl std::fmt::Display for MsgMaskSatelliteDepAcquisitionChannel { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgMaskSatelliteDepAcquisitionChannel::Enabled => f.write_str("Enabled"), + MsgMaskSatelliteDepAcquisitionChannel::SkipThisSatelliteOnFutureAcquisitions => { + f.write_str("Skip this satellite on future acquisitions") + } + } + } +} + /// Bandwidth usage reporting message /// /// The bandwidth usage, a list of usage by interface. @@ -1126,6 +1271,271 @@ pub struct MsgNetworkStateResp { pub flags: u32, } +impl MsgNetworkStateResp { + pub fn iff_multicast_supports_multicast(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 15, 0) + } + + pub fn set_iff_multicast_supports_multicast(&mut self, iff_multicast_supports_multicast: u8) { + set_bit_range!( + &mut self.flags, + iff_multicast_supports_multicast, + u32, + u8, + 15, + 0 + ); + } + + pub fn iff_link2_per_link_layer_defined_bit(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 14, 0) + } + + pub fn set_iff_link2_per_link_layer_defined_bit( + &mut self, + iff_link2_per_link_layer_defined_bit: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_link2_per_link_layer_defined_bit, + u32, + u8, + 14, + 0 + ); + } + + pub fn iff_link1_per_link_layer_defined_bit(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 13, 0) + } + + pub fn set_iff_link1_per_link_layer_defined_bit( + &mut self, + iff_link1_per_link_layer_defined_bit: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_link1_per_link_layer_defined_bit, + u32, + u8, + 13, + 0 + ); + } + + pub fn iff_link0_per_link_layer_defined_bit(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 12, 0) + } + + pub fn set_iff_link0_per_link_layer_defined_bit( + &mut self, + iff_link0_per_link_layer_defined_bit: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_link0_per_link_layer_defined_bit, + u32, + u8, + 12, + 0 + ); + } + + pub fn iff_simplex_cant_hear_own_transmissions(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 11, 0) + } + + pub fn set_iff_simplex_cant_hear_own_transmissions( + &mut self, + iff_simplex_cant_hear_own_transmissions: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_simplex_cant_hear_own_transmissions, + u32, + u8, + 11, + 0 + ); + } + + pub fn iff_oactive_transmission_in_progress(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 10, 0) + } + + pub fn set_iff_oactive_transmission_in_progress( + &mut self, + iff_oactive_transmission_in_progress: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_oactive_transmission_in_progress, + u32, + u8, + 10, + 0 + ); + } + + pub fn iff_allmulti_receive_all_multicast_packets(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 9, 0) + } + + pub fn set_iff_allmulti_receive_all_multicast_packets( + &mut self, + iff_allmulti_receive_all_multicast_packets: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_allmulti_receive_all_multicast_packets, + u32, + u8, + 9, + 0 + ); + } + + pub fn iff_promisc_receive_all_packets(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 8, 0) + } + + pub fn set_iff_promisc_receive_all_packets(&mut self, iff_promisc_receive_all_packets: u8) { + set_bit_range!( + &mut self.flags, + iff_promisc_receive_all_packets, + u32, + u8, + 8, + 0 + ); + } + + pub fn iff_noarp_no_address_resolution_protocol(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 7, 0) + } + + pub fn set_iff_noarp_no_address_resolution_protocol( + &mut self, + iff_noarp_no_address_resolution_protocol: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_noarp_no_address_resolution_protocol, + u32, + u8, + 7, + 0 + ); + } + + pub fn iff_running_resources_allocated(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 6, 0) + } + + pub fn set_iff_running_resources_allocated(&mut self, iff_running_resources_allocated: u8) { + set_bit_range!( + &mut self.flags, + iff_running_resources_allocated, + u32, + u8, + 6, + 0 + ); + } + + pub fn iff_notrailers_avoid_use_of_trailers(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 5, 0) + } + + pub fn set_iff_notrailers_avoid_use_of_trailers( + &mut self, + iff_notrailers_avoid_use_of_trailers: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_notrailers_avoid_use_of_trailers, + u32, + u8, + 5, + 0 + ); + } + + pub fn iff_pointopoint_interface_is_pointtopoint_link(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 4, 0) + } + + pub fn set_iff_pointopoint_interface_is_pointtopoint_link( + &mut self, + iff_pointopoint_interface_is_pointtopoint_link: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_pointopoint_interface_is_pointtopoint_link, + u32, + u8, + 4, + 0 + ); + } + + pub fn iff_loopback_is_a_loopback_net(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 3, 0) + } + + pub fn set_iff_loopback_is_a_loopback_net(&mut self, iff_loopback_is_a_loopback_net: u8) { + set_bit_range!( + &mut self.flags, + iff_loopback_is_a_loopback_net, + u32, + u8, + 3, + 0 + ); + } + + pub fn iff_debug_broadcast_address_valid(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 2, 0) + } + + pub fn set_iff_debug_broadcast_address_valid(&mut self, iff_debug_broadcast_address_valid: u8) { + set_bit_range!( + &mut self.flags, + iff_debug_broadcast_address_valid, + u32, + u8, + 2, + 0 + ); + } + + pub fn iff_broadcast_broadcast_address_valid(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 1, 0) + } + + pub fn set_iff_broadcast_broadcast_address_valid( + &mut self, + iff_broadcast_broadcast_address_valid: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_broadcast_broadcast_address_valid, + u32, + u8, + 1, + 0 + ); + } + + pub fn iff_up_interface_is_up(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 0, 0) + } + + pub fn set_iff_up_interface_is_up(&mut self, iff_up_interface_is_up: u8) { + set_bit_range!(&mut self.flags, iff_up_interface_is_up, u32, u8, 0, 0); + } +} + impl ConcreteMessage for MsgNetworkStateResp { const MESSAGE_TYPE: u16 = 187; const MESSAGE_NAME: &'static str = "MSG_NETWORK_STATE_RESP"; @@ -1218,6 +1628,20 @@ pub struct MsgReset { pub flags: u32, } +impl MsgReset { + pub fn default_settings(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 0, 0) { + 0 => Some(MsgResetDefaultSettings::PreserveExistingSettings), + 1 => Some(MsgResetDefaultSettings::ResoreDefaultSettings), + _ => None, + } + } + + pub fn set_default_settings(&mut self, default_settings: MsgResetDefaultSettings) { + set_bit_range!(&mut self.flags, default_settings, u32, u8, 0, 0); + } +} + impl ConcreteMessage for MsgReset { const MESSAGE_TYPE: u16 = 182; const MESSAGE_NAME: &'static str = "MSG_RESET"; @@ -1267,6 +1691,29 @@ impl WireFormat for MsgReset { } } +/// Default settings. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgResetDefaultSettings { + /// Preserve existing settings. + PreserveExistingSettings = 0, + + /// Resore default settings. + ResoreDefaultSettings = 1, +} + +impl std::fmt::Display for MsgResetDefaultSettings { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgResetDefaultSettings::PreserveExistingSettings => { + f.write_str("Preserve existing settings.") + } + MsgResetDefaultSettings::ResoreDefaultSettings => { + f.write_str("Resore default settings.") + } + } + } +} + /// Reset the device (host => Piksi) /// /// This message from the host resets the Piksi back into the bootloader. @@ -1339,6 +1786,24 @@ pub struct MsgResetFilters { pub filter: u8, } +impl MsgResetFilters { + pub fn filter_or_process_to_reset(&self) -> Option { + match get_bit_range!(self.filter, u8, u8, 1, 0) { + 0 => Some(MsgResetFiltersFilterOrProcessToReset::DgnssFilter), + 1 => Some(MsgResetFiltersFilterOrProcessToReset::IarProcess), + 2 => Some(MsgResetFiltersFilterOrProcessToReset::InertialFilter), + _ => None, + } + } + + pub fn set_filter_or_process_to_reset( + &mut self, + filter_or_process_to_reset: MsgResetFiltersFilterOrProcessToReset, + ) { + set_bit_range!(&mut self.filter, filter_or_process_to_reset, u8, u8, 1, 0); + } +} + impl ConcreteMessage for MsgResetFilters { const MESSAGE_TYPE: u16 = 34; const MESSAGE_NAME: &'static str = "MSG_RESET_FILTERS"; @@ -1388,6 +1853,29 @@ impl WireFormat for MsgResetFilters { } } +/// Filter or process to reset +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgResetFiltersFilterOrProcessToReset { + /// DGNSS filter + DgnssFilter = 0, + + /// IAR process + IarProcess = 1, + + /// Inertial filter + InertialFilter = 2, +} + +impl std::fmt::Display for MsgResetFiltersFilterOrProcessToReset { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgResetFiltersFilterOrProcessToReset::DgnssFilter => f.write_str("DGNSS filter"), + MsgResetFiltersFilterOrProcessToReset::IarProcess => f.write_str("IAR process"), + MsgResetFiltersFilterOrProcessToReset::InertialFilter => f.write_str("Inertial filter"), + } + } +} + /// Send GPS time from host (host => Piksi) /// /// This message sets up timing functionality using a coarse GPS time estimate diff --git a/rust/sbp/src/messages/settings.rs b/rust/sbp/src/messages/settings.rs index 75ec03690a..ce379fea7f 100644 --- a/rust/sbp/src/messages/settings.rs +++ b/rust/sbp/src/messages/settings.rs @@ -476,6 +476,22 @@ pub struct MsgSettingsRegisterResp { pub setting: SbpString, Multipart>, } +impl MsgSettingsRegisterResp { + pub fn register_status(&self) -> Option { + match get_bit_range!( self.status, u8, u8, 1, 0 ) { + 0 => Some( MsgSettingsRegisterRespRegisterStatus :: AcceptedRequestedDefaultValueReturned ), + 1 => Some( MsgSettingsRegisterRespRegisterStatus :: AcceptedSettingFoundInPermanentStorageValueFromStorageReturned ), + 2 => Some( MsgSettingsRegisterRespRegisterStatus :: RejectedSettingAlreadyRegisteredValueFromMemoryReturned ), + 3 => Some( MsgSettingsRegisterRespRegisterStatus :: RejectedMalformedMessage ), + _ => None, + } + } + + pub fn set_register_status(&mut self, register_status: MsgSettingsRegisterRespRegisterStatus) { + set_bit_range!(&mut self.status, register_status, u8, u8, 1, 0); + } +} + impl ConcreteMessage for MsgSettingsRegisterResp { const MESSAGE_TYPE: u16 = 431; const MESSAGE_NAME: &'static str = "MSG_SETTINGS_REGISTER_RESP"; @@ -528,6 +544,34 @@ impl WireFormat for MsgSettingsRegisterResp { } } +/// Register status +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgSettingsRegisterRespRegisterStatus { + /// Accepted; requested default value returned + AcceptedRequestedDefaultValueReturned = 0, + + /// Accepted; setting found in permanent storage, value from storage + /// returned + AcceptedSettingFoundInPermanentStorageValueFromStorageReturned = 1, + + /// Rejected; setting already registered, value from memory returned + RejectedSettingAlreadyRegisteredValueFromMemoryReturned = 2, + + /// Rejected; malformed message + RejectedMalformedMessage = 3, +} + +impl std::fmt::Display for MsgSettingsRegisterRespRegisterStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgSettingsRegisterRespRegisterStatus::AcceptedRequestedDefaultValueReturned => f.write_str("Accepted; requested default value returned"), + MsgSettingsRegisterRespRegisterStatus::AcceptedSettingFoundInPermanentStorageValueFromStorageReturned => f.write_str("Accepted; setting found in permanent storage, value from storage returned"), + MsgSettingsRegisterRespRegisterStatus::RejectedSettingAlreadyRegisteredValueFromMemoryReturned => f.write_str("Rejected; setting already registered, value from memory returned"), + MsgSettingsRegisterRespRegisterStatus::RejectedMalformedMessage => f.write_str("Rejected; malformed message"), + } + } +} + /// Save settings to flash (host => device) /// /// The save settings message persists the device's current settings @@ -681,6 +725,25 @@ pub struct MsgSettingsWriteResp { pub setting: SbpString, Multipart>, } +impl MsgSettingsWriteResp { + pub fn write_status(&self) -> Option { + match get_bit_range!(self.status, u8, u8, 1, 0) { + 0 => Some(MsgSettingsWriteRespWriteStatus::AcceptedValueUpdated), + 1 => Some(MsgSettingsWriteRespWriteStatus::RejectedValueUnparsableOrOutOfRange), + 2 => Some(MsgSettingsWriteRespWriteStatus::RejectedRequestedSettingDoesNotExist), + 3 => Some(MsgSettingsWriteRespWriteStatus::RejectedSettingNameCouldNotBeParsed), + 4 => Some(MsgSettingsWriteRespWriteStatus::RejectedSettingIsReadOnly), + 5 => Some(MsgSettingsWriteRespWriteStatus::RejectedModificationIsTemporarilyDisabled), + 6 => Some(MsgSettingsWriteRespWriteStatus::RejectedUnspecifiedError), + _ => None, + } + } + + pub fn set_write_status(&mut self, write_status: MsgSettingsWriteRespWriteStatus) { + set_bit_range!(&mut self.status, write_status, u8, u8, 1, 0); + } +} + impl ConcreteMessage for MsgSettingsWriteResp { const MESSAGE_TYPE: u16 = 175; const MESSAGE_NAME: &'static str = "MSG_SETTINGS_WRITE_RESP"; @@ -732,3 +795,56 @@ impl WireFormat for MsgSettingsWriteResp { } } } + +/// Write status +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgSettingsWriteRespWriteStatus { + /// Accepted; value updated + AcceptedValueUpdated = 0, + + /// Rejected; value unparsable or out-of-range + RejectedValueUnparsableOrOutOfRange = 1, + + /// Rejected; requested setting does not exist + RejectedRequestedSettingDoesNotExist = 2, + + /// Rejected; setting name could not be parsed + RejectedSettingNameCouldNotBeParsed = 3, + + /// Rejected; setting is read only + RejectedSettingIsReadOnly = 4, + + /// Rejected; modification is temporarily disabled + RejectedModificationIsTemporarilyDisabled = 5, + + /// Rejected; unspecified error + RejectedUnspecifiedError = 6, +} + +impl std::fmt::Display for MsgSettingsWriteRespWriteStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgSettingsWriteRespWriteStatus::AcceptedValueUpdated => { + f.write_str("Accepted; value updated") + } + MsgSettingsWriteRespWriteStatus::RejectedValueUnparsableOrOutOfRange => { + f.write_str("Rejected; value unparsable or out-of-range") + } + MsgSettingsWriteRespWriteStatus::RejectedRequestedSettingDoesNotExist => { + f.write_str("Rejected; requested setting does not exist") + } + MsgSettingsWriteRespWriteStatus::RejectedSettingNameCouldNotBeParsed => { + f.write_str("Rejected; setting name could not be parsed") + } + MsgSettingsWriteRespWriteStatus::RejectedSettingIsReadOnly => { + f.write_str("Rejected; setting is read only") + } + MsgSettingsWriteRespWriteStatus::RejectedModificationIsTemporarilyDisabled => { + f.write_str("Rejected; modification is temporarily disabled") + } + MsgSettingsWriteRespWriteStatus::RejectedUnspecifiedError => { + f.write_str("Rejected; unspecified error") + } + } + } +} diff --git a/rust/sbp/src/messages/solution_meta.rs b/rust/sbp/src/messages/solution_meta.rs index 06dfb86a91..d785fb6337 100644 --- a/rust/sbp/src/messages/solution_meta.rs +++ b/rust/sbp/src/messages/solution_meta.rs @@ -30,6 +30,24 @@ pub struct GnssInputType { pub flags: u8, } +impl GnssInputType { + pub fn type_of_gnss_measurement(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 1, 0) { + 0 => Some(GnssInputTypeTypeOfGnssMeasurement::GnssPosition), + 1 => Some(GnssInputTypeTypeOfGnssMeasurement::GnssVelocityDoppler), + 2 => Some(GnssInputTypeTypeOfGnssMeasurement::GnssVelocityDisplacement), + _ => None, + } + } + + pub fn set_type_of_gnss_measurement( + &mut self, + type_of_gnss_measurement: GnssInputTypeTypeOfGnssMeasurement, + ) { + set_bit_range!(&mut self.flags, type_of_gnss_measurement, u8, u8, 1, 0); + } +} + impl WireFormat for GnssInputType { const MIN_LEN: usize = ::MIN_LEN; fn len(&self) -> usize { @@ -45,6 +63,33 @@ impl WireFormat for GnssInputType { } } +/// Type of GNSS measurement +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum GnssInputTypeTypeOfGnssMeasurement { + /// GNSS Position + GnssPosition = 0, + + /// GNSS Velocity Doppler + GnssVelocityDoppler = 1, + + /// GNSS Velocity Displacement + GnssVelocityDisplacement = 2, +} + +impl std::fmt::Display for GnssInputTypeTypeOfGnssMeasurement { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + GnssInputTypeTypeOfGnssMeasurement::GnssPosition => f.write_str("GNSS Position"), + GnssInputTypeTypeOfGnssMeasurement::GnssVelocityDoppler => { + f.write_str("GNSS Velocity Doppler") + } + GnssInputTypeTypeOfGnssMeasurement::GnssVelocityDisplacement => { + f.write_str("GNSS Velocity Displacement") + } + } + } +} + /// Provides detail about the IMU sensor, its timestamping mode, and its quality for input to the fuzed solution /// @@ -59,6 +104,48 @@ pub struct ImuInputType { pub flags: u8, } +impl ImuInputType { + pub fn time_status(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 4) { + 0 => Some(ImuInputTypeTimeStatus::ReferenceEpochIsStartOfCurrentGpsWeek), + 1 => Some(ImuInputTypeTimeStatus::ReferenceEpochIsTimeOfSystemStartup), + 2 => Some(ImuInputTypeTimeStatus::ReferenceEpochIsUnknown), + 3 => Some(ImuInputTypeTimeStatus::ReferenceEpochIsLastPps), + _ => None, + } + } + + pub fn set_time_status(&mut self, time_status: ImuInputTypeTimeStatus) { + set_bit_range!(&mut self.flags, time_status, u8, u8, 5, 4); + } + + pub fn imu_grade(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 2) { + 0 => Some(ImuInputTypeImuGrade::ConsumerGrade), + 1 => Some(ImuInputTypeImuGrade::TacticalGrade), + 2 => Some(ImuInputTypeImuGrade::IntermediateGrade), + 3 => Some(ImuInputTypeImuGrade::SuperiorGrade), + _ => None, + } + } + + pub fn set_imu_grade(&mut self, imu_grade: ImuInputTypeImuGrade) { + set_bit_range!(&mut self.flags, imu_grade, u8, u8, 3, 2); + } + + pub fn imu_architecture(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 1, 0) { + 0 => Some(ImuInputTypeImuArchitecture::_6AxisMems), + 1 => Some(ImuInputTypeImuArchitecture::OtherType), + _ => None, + } + } + + pub fn set_imu_architecture(&mut self, imu_architecture: ImuInputTypeImuArchitecture) { + set_bit_range!(&mut self.flags, imu_architecture, u8, u8, 1, 0); + } +} + impl WireFormat for ImuInputType { const MIN_LEN: usize = ::MIN_LEN; fn len(&self) -> usize { @@ -74,6 +161,89 @@ impl WireFormat for ImuInputType { } } +/// Time status +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum ImuInputTypeTimeStatus { + /// Reference epoch is start of current GPS week + ReferenceEpochIsStartOfCurrentGpsWeek = 0, + + /// Reference epoch is time of system startup + ReferenceEpochIsTimeOfSystemStartup = 1, + + /// Reference epoch is unknown + ReferenceEpochIsUnknown = 2, + + /// Reference epoch is last PPS + ReferenceEpochIsLastPps = 3, +} + +impl std::fmt::Display for ImuInputTypeTimeStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ImuInputTypeTimeStatus::ReferenceEpochIsStartOfCurrentGpsWeek => { + f.write_str("Reference epoch is start of current GPS week") + } + ImuInputTypeTimeStatus::ReferenceEpochIsTimeOfSystemStartup => { + f.write_str("Reference epoch is time of system startup") + } + ImuInputTypeTimeStatus::ReferenceEpochIsUnknown => { + f.write_str("Reference epoch is unknown") + } + ImuInputTypeTimeStatus::ReferenceEpochIsLastPps => { + f.write_str("Reference epoch is last PPS") + } + } + } +} + +/// IMU Grade +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum ImuInputTypeImuGrade { + /// Consumer Grade + ConsumerGrade = 0, + + /// Tactical grade + TacticalGrade = 1, + + /// Intermediate Grade + IntermediateGrade = 2, + + /// Superior (Marine / Aviation) Grade + SuperiorGrade = 3, +} + +impl std::fmt::Display for ImuInputTypeImuGrade { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ImuInputTypeImuGrade::ConsumerGrade => f.write_str("Consumer Grade"), + ImuInputTypeImuGrade::TacticalGrade => f.write_str("Tactical grade"), + ImuInputTypeImuGrade::IntermediateGrade => f.write_str("Intermediate Grade"), + ImuInputTypeImuGrade::SuperiorGrade => { + f.write_str("Superior (Marine / Aviation) Grade") + } + } + } +} + +/// IMU architecture +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum ImuInputTypeImuArchitecture { + /// 6-axis MEMS + _6AxisMems = 0, + + /// Other type + OtherType = 1, +} + +impl std::fmt::Display for ImuInputTypeImuArchitecture { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ImuInputTypeImuArchitecture::_6AxisMems => f.write_str("6-axis MEMS"), + ImuInputTypeImuArchitecture::OtherType => f.write_str("Other type"), + } + } +} + /// Solution Sensors Metadata /// /// This message contains all metadata about the sensors received and/or used @@ -123,6 +293,38 @@ pub struct MsgSolnMeta { pub sol_in: Vec, } +impl MsgSolnMeta { + pub fn time_status(&self) -> Option { + match get_bit_range!(self.age_gnss, u32, u8, 31, 30) { + 0 => Some(MsgSolnMetaTimeStatus::AgeCanNotBeUsedToRetrieveTom), + 1 => Some(MsgSolnMetaTimeStatus::AgeCanBeUsedToRetrieveTom), + _ => None, + } + } + + pub fn set_time_status(&mut self, time_status: MsgSolnMetaTimeStatus) { + set_bit_range!(&mut self.age_gnss, time_status, u32, u8, 31, 30); + } + + pub fn age_of_the_last_received_valid_gnss_solution(&self) -> u32 { + get_bit_range!(self.age_gnss, u32, u32, 29, 0) + } + + pub fn set_age_of_the_last_received_valid_gnss_solution( + &mut self, + age_of_the_last_received_valid_gnss_solution: u32, + ) { + set_bit_range!( + &mut self.age_gnss, + age_of_the_last_received_valid_gnss_solution, + u32, + u32, + 29, + 0 + ); + } +} + impl ConcreteMessage for MsgSolnMeta { const MESSAGE_TYPE: u16 = 65294; const MESSAGE_NAME: &'static str = "MSG_SOLN_META"; @@ -205,6 +407,29 @@ impl WireFormat for MsgSolnMeta { } } +/// Time status +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgSolnMetaTimeStatus { + /// Age can not be used to retrieve TOM + AgeCanNotBeUsedToRetrieveTom = 0, + + /// Age can be used to retrieve TOM + AgeCanBeUsedToRetrieveTom = 1, +} + +impl std::fmt::Display for MsgSolnMetaTimeStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgSolnMetaTimeStatus::AgeCanNotBeUsedToRetrieveTom => { + f.write_str("Age can not be used to retrieve TOM") + } + MsgSolnMetaTimeStatus::AgeCanBeUsedToRetrieveTom => { + f.write_str("Age can be used to retrieve TOM") + } + } + } +} + /// Deprecated /// /// Deprecated. @@ -256,6 +481,23 @@ pub struct MsgSolnMetaDepA { pub sol_in: Vec, } +impl MsgSolnMetaDepA { + pub fn alignment_status(&self) -> Option { + match get_bit_range!(self.alignment_status, u8, u8, 2, 0) { + 0 => Some(MsgSolnMetaDepAAlignmentStatus::UnknownReasonOrAlreadyAligned), + 1 => Some(MsgSolnMetaDepAAlignmentStatus::SeedValuesLoadedAndAlignmentInProgress), + 2 => Some(MsgSolnMetaDepAAlignmentStatus::NoSeedValuesAndAlignmentInProgress), + 3 => Some(MsgSolnMetaDepAAlignmentStatus::SeedValuesLoadedButNoGnssMeasurements), + 4 => Some(MsgSolnMetaDepAAlignmentStatus::NoSeedValuesNorGnssMeasurements), + _ => None, + } + } + + pub fn set_alignment_status(&mut self, alignment_status: MsgSolnMetaDepAAlignmentStatus) { + set_bit_range!(&mut self.alignment_status, alignment_status, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgSolnMetaDepA { const MESSAGE_TYPE: u16 = 65295; const MESSAGE_NAME: &'static str = "MSG_SOLN_META_DEP_A"; @@ -337,6 +579,47 @@ impl WireFormat for MsgSolnMetaDepA { } } +/// Alignment status +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgSolnMetaDepAAlignmentStatus { + /// Unknown reason or already aligned + UnknownReasonOrAlreadyAligned = 0, + + /// Seed values loaded and Alignment in progress + SeedValuesLoadedAndAlignmentInProgress = 1, + + /// No seed values and Alignment in progress + NoSeedValuesAndAlignmentInProgress = 2, + + /// Seed values loaded but no GNSS measurements + SeedValuesLoadedButNoGnssMeasurements = 3, + + /// No seed values nor GNSS measurements + NoSeedValuesNorGnssMeasurements = 4, +} + +impl std::fmt::Display for MsgSolnMetaDepAAlignmentStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgSolnMetaDepAAlignmentStatus::UnknownReasonOrAlreadyAligned => { + f.write_str("Unknown reason or already aligned") + } + MsgSolnMetaDepAAlignmentStatus::SeedValuesLoadedAndAlignmentInProgress => { + f.write_str("Seed values loaded and Alignment in progress") + } + MsgSolnMetaDepAAlignmentStatus::NoSeedValuesAndAlignmentInProgress => { + f.write_str("No seed values and Alignment in progress") + } + MsgSolnMetaDepAAlignmentStatus::SeedValuesLoadedButNoGnssMeasurements => { + f.write_str("Seed values loaded but no GNSS measurements") + } + MsgSolnMetaDepAAlignmentStatus::NoSeedValuesNorGnssMeasurements => { + f.write_str("No seed values nor GNSS measurements") + } + } + } +} + /// Provides detail about the Odometry sensor, its timestamping mode, and its quality for input to the fuzed solution /// @@ -351,6 +634,47 @@ pub struct OdoInputType { pub flags: u8, } +impl OdoInputType { + pub fn rate(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 4) { + 0 => Some(OdoInputTypeRate::FixedIncomingRate), + 1 => Some(OdoInputTypeRate::TriggeredByMinimumDistanceOrSpeed), + _ => None, + } + } + + pub fn set_rate(&mut self, rate: OdoInputTypeRate) { + set_bit_range!(&mut self.flags, rate, u8, u8, 5, 4); + } + + pub fn odometer_grade(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 2) { + 0 => Some(OdoInputTypeOdometerGrade::LowGrade), + 1 => Some(OdoInputTypeOdometerGrade::MediumGrade), + 2 => Some(OdoInputTypeOdometerGrade::SuperiorGrade), + _ => None, + } + } + + pub fn set_odometer_grade(&mut self, odometer_grade: OdoInputTypeOdometerGrade) { + set_bit_range!(&mut self.flags, odometer_grade, u8, u8, 3, 2); + } + + pub fn odometer_class(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 1, 0) { + 0 => Some(OdoInputTypeOdometerClass::SingleOrAveragedTicks), + 1 => Some(OdoInputTypeOdometerClass::SingleOrAveragedSpeed), + 2 => Some(OdoInputTypeOdometerClass::MultiDimensionalTicks), + 3 => Some(OdoInputTypeOdometerClass::MultiDimensionalSpeed), + _ => None, + } + } + + pub fn set_odometer_class(&mut self, odometer_class: OdoInputTypeOdometerClass) { + set_bit_range!(&mut self.flags, odometer_class, u8, u8, 1, 0); + } +} + impl WireFormat for OdoInputType { const MIN_LEN: usize = ::MIN_LEN; fn len(&self) -> usize { @@ -366,6 +690,85 @@ impl WireFormat for OdoInputType { } } +/// Rate +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum OdoInputTypeRate { + /// Fixed incoming rate + FixedIncomingRate = 0, + + /// Triggered by minimum distance or speed + TriggeredByMinimumDistanceOrSpeed = 1, +} + +impl std::fmt::Display for OdoInputTypeRate { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + OdoInputTypeRate::FixedIncomingRate => f.write_str("Fixed incoming rate"), + OdoInputTypeRate::TriggeredByMinimumDistanceOrSpeed => { + f.write_str("Triggered by minimum distance or speed") + } + } + } +} + +/// Odometer grade +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum OdoInputTypeOdometerGrade { + /// Low Grade (e.g. quantized CAN) + LowGrade = 0, + + /// Medium Grade + MediumGrade = 1, + + /// Superior Grade + SuperiorGrade = 2, +} + +impl std::fmt::Display for OdoInputTypeOdometerGrade { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + OdoInputTypeOdometerGrade::LowGrade => f.write_str("Low Grade (e.g. quantized CAN)"), + OdoInputTypeOdometerGrade::MediumGrade => f.write_str("Medium Grade"), + OdoInputTypeOdometerGrade::SuperiorGrade => f.write_str("Superior Grade"), + } + } +} + +/// Odometer class +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum OdoInputTypeOdometerClass { + /// Single or averaged ticks + SingleOrAveragedTicks = 0, + + /// Single or averaged speed + SingleOrAveragedSpeed = 1, + + /// Multi-dimensional ticks + MultiDimensionalTicks = 2, + + /// Multi-dimensional speed + MultiDimensionalSpeed = 3, +} + +impl std::fmt::Display for OdoInputTypeOdometerClass { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + OdoInputTypeOdometerClass::SingleOrAveragedTicks => { + f.write_str("Single or averaged ticks") + } + OdoInputTypeOdometerClass::SingleOrAveragedSpeed => { + f.write_str("Single or averaged speed") + } + OdoInputTypeOdometerClass::MultiDimensionalTicks => { + f.write_str("Multi-dimensional ticks") + } + OdoInputTypeOdometerClass::MultiDimensionalSpeed => { + f.write_str("Multi-dimensional speed") + } + } + } +} + /// Flags for a given solution input type /// /// Metadata describing which sensors were involved in the solution. The @@ -387,6 +790,38 @@ pub struct SolutionInputType { pub flags: u8, } +impl SolutionInputType { + pub fn sensor_usage(&self) -> Option { + match get_bit_range!(self.sensor_type, u8, u8, 4, 3) { + 0 => Some(SolutionInputTypeSensorUsage::Unknown), + 1 => Some(SolutionInputTypeSensorUsage::ReceivedAndUsed), + 2 => Some(SolutionInputTypeSensorUsage::ReceivedButNotUsed), + _ => None, + } + } + + pub fn set_sensor_usage(&mut self, sensor_usage: SolutionInputTypeSensorUsage) { + set_bit_range!(&mut self.sensor_type, sensor_usage, u8, u8, 4, 3); + } + + pub fn sensor_type(&self) -> Option { + match get_bit_range!(self.sensor_type, u8, u8, 2, 0) { + 0 => Some(SolutionInputTypeSensorType::Invalid), + 1 => Some(SolutionInputTypeSensorType::GnssPosition), + 2 => Some(SolutionInputTypeSensorType::GnssVelocityDisplacement), + 3 => Some(SolutionInputTypeSensorType::GnssVelocityDoppler), + 4 => Some(SolutionInputTypeSensorType::OdometryTicks), + 5 => Some(SolutionInputTypeSensorType::OdometrySpeed), + 6 => Some(SolutionInputTypeSensorType::ImuSensor), + _ => None, + } + } + + pub fn set_sensor_type(&mut self, sensor_type: SolutionInputTypeSensorType) { + set_bit_range!(&mut self.sensor_type, sensor_type, u8, u8, 2, 0); + } +} + impl WireFormat for SolutionInputType { const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; fn len(&self) -> usize { @@ -403,3 +838,77 @@ impl WireFormat for SolutionInputType { } } } + +/// Sensor Usage +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum SolutionInputTypeSensorUsage { + /// Unknown + Unknown = 0, + + /// Received and used + ReceivedAndUsed = 1, + + /// Received but not used + ReceivedButNotUsed = 2, +} + +impl std::fmt::Display for SolutionInputTypeSensorUsage { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SolutionInputTypeSensorUsage::Unknown => f.write_str("Unknown"), + SolutionInputTypeSensorUsage::ReceivedAndUsed => f.write_str("Received and used"), + SolutionInputTypeSensorUsage::ReceivedButNotUsed => { + f.write_str("Received but not used") + } + } + } +} + +/// Sensor Type +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum SolutionInputTypeSensorType { + /// Invalid + Invalid = 0, + + /// GNSS Position (see GNSSInputType) + GnssPosition = 1, + + /// GNSS Velocity Displacement (see GNSSInputType) + GnssVelocityDisplacement = 2, + + /// GNSS Velocity Doppler (see GNSSInputType) + GnssVelocityDoppler = 3, + + /// Odometry Ticks (see OdoInputType) + OdometryTicks = 4, + + /// Odometry Speed (see OdoInputType) + OdometrySpeed = 5, + + /// IMU Sensor (see IMUInputType) + ImuSensor = 6, +} + +impl std::fmt::Display for SolutionInputTypeSensorType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SolutionInputTypeSensorType::Invalid => f.write_str("Invalid"), + SolutionInputTypeSensorType::GnssPosition => { + f.write_str("GNSS Position (see GNSSInputType)") + } + SolutionInputTypeSensorType::GnssVelocityDisplacement => { + f.write_str("GNSS Velocity Displacement (see GNSSInputType)") + } + SolutionInputTypeSensorType::GnssVelocityDoppler => { + f.write_str("GNSS Velocity Doppler (see GNSSInputType)") + } + SolutionInputTypeSensorType::OdometryTicks => { + f.write_str("Odometry Ticks (see OdoInputType)") + } + SolutionInputTypeSensorType::OdometrySpeed => { + f.write_str("Odometry Speed (see OdoInputType)") + } + SolutionInputTypeSensorType::ImuSensor => f.write_str("IMU Sensor (see IMUInputType)"), + } + } +} diff --git a/rust/sbp/src/messages/ssr.rs b/rust/sbp/src/messages/ssr.rs index 42f23aad63..edd5d61ec5 100644 --- a/rust/sbp/src/messages/ssr.rs +++ b/rust/sbp/src/messages/ssr.rs @@ -1823,6 +1823,38 @@ pub struct SatelliteAPC { pub pcv: [i8; 21], } +impl SatelliteAPC { + pub fn satellite_type(&self) -> Option { + match get_bit_range!(self.sat_info, u8, u8, 4, 0) { + 0 => Some(SatelliteAPCSatelliteType::UnknownType), + 1 => Some(SatelliteAPCSatelliteType::GpsI), + 2 => Some(SatelliteAPCSatelliteType::GpsIi), + 3 => Some(SatelliteAPCSatelliteType::GpsIia), + 4 => Some(SatelliteAPCSatelliteType::GpsIir), + 5 => Some(SatelliteAPCSatelliteType::GpsIif), + 6 => Some(SatelliteAPCSatelliteType::GpsIii), + 7 => Some(SatelliteAPCSatelliteType::GLONASS), + 8 => Some(SatelliteAPCSatelliteType::GlonassM), + 9 => Some(SatelliteAPCSatelliteType::GlonassK1), + 10 => Some(SatelliteAPCSatelliteType::GALILEO), + 11 => Some(SatelliteAPCSatelliteType::Beidou2G), + 12 => Some(SatelliteAPCSatelliteType::Beidou2I), + 13 => Some(SatelliteAPCSatelliteType::Beidou2M), + 14 => Some(SatelliteAPCSatelliteType::Beidou3MSecm), + 15 => Some(SatelliteAPCSatelliteType::Beidou3GSecm), + 16 => Some(SatelliteAPCSatelliteType::Beidou3MCast), + 17 => Some(SatelliteAPCSatelliteType::Beidou3GCast), + 18 => Some(SatelliteAPCSatelliteType::Beidou3ICast), + 19 => Some(SatelliteAPCSatelliteType::QZSS), + _ => None, + } + } + + pub fn set_satellite_type(&mut self, satellite_type: SatelliteAPCSatelliteType) { + set_bit_range!(&mut self.sat_info, satellite_type, u8, u8, 4, 0); + } +} + impl WireFormat for SatelliteAPC { const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN @@ -1854,6 +1886,97 @@ impl WireFormat for SatelliteAPC { } } +/// Satellite Type +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum SatelliteAPCSatelliteType { + /// Unknown Type + UnknownType = 0, + + /// GPS I + GpsI = 1, + + /// GPS II + GpsIi = 2, + + /// GPS IIA + GpsIia = 3, + + /// GPS IIR + GpsIir = 4, + + /// GPS IIF + GpsIif = 5, + + /// GPS III + GpsIii = 6, + + /// GLONASS + GLONASS = 7, + + /// GLONASS M + GlonassM = 8, + + /// GLONASS K1 + GlonassK1 = 9, + + /// GALILEO + GALILEO = 10, + + /// BEIDOU 2G + Beidou2G = 11, + + /// BEIDOU 2I + Beidou2I = 12, + + /// BEIDOU 2M + Beidou2M = 13, + + /// BEIDOU 3M, SECM + Beidou3MSecm = 14, + + /// BEIDOU 3G, SECM + Beidou3GSecm = 15, + + /// BEIDOU 3M, CAST + Beidou3MCast = 16, + + /// BEIDOU 3G, CAST + Beidou3GCast = 17, + + /// BEIDOU 3I, CAST + Beidou3ICast = 18, + + /// QZSS + QZSS = 19, +} + +impl std::fmt::Display for SatelliteAPCSatelliteType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SatelliteAPCSatelliteType::UnknownType => f.write_str("Unknown Type"), + SatelliteAPCSatelliteType::GpsI => f.write_str("GPS I"), + SatelliteAPCSatelliteType::GpsIi => f.write_str("GPS II"), + SatelliteAPCSatelliteType::GpsIia => f.write_str("GPS IIA"), + SatelliteAPCSatelliteType::GpsIir => f.write_str("GPS IIR"), + SatelliteAPCSatelliteType::GpsIif => f.write_str("GPS IIF"), + SatelliteAPCSatelliteType::GpsIii => f.write_str("GPS III"), + SatelliteAPCSatelliteType::GLONASS => f.write_str("GLONASS"), + SatelliteAPCSatelliteType::GlonassM => f.write_str("GLONASS M"), + SatelliteAPCSatelliteType::GlonassK1 => f.write_str("GLONASS K1"), + SatelliteAPCSatelliteType::GALILEO => f.write_str("GALILEO"), + SatelliteAPCSatelliteType::Beidou2G => f.write_str("BEIDOU 2G"), + SatelliteAPCSatelliteType::Beidou2I => f.write_str("BEIDOU 2I"), + SatelliteAPCSatelliteType::Beidou2M => f.write_str("BEIDOU 2M"), + SatelliteAPCSatelliteType::Beidou3MSecm => f.write_str("BEIDOU 3M, SECM"), + SatelliteAPCSatelliteType::Beidou3GSecm => f.write_str("BEIDOU 3G, SECM"), + SatelliteAPCSatelliteType::Beidou3MCast => f.write_str("BEIDOU 3M, CAST"), + SatelliteAPCSatelliteType::Beidou3GCast => f.write_str("BEIDOU 3G, CAST"), + SatelliteAPCSatelliteType::Beidou3ICast => f.write_str("BEIDOU 3I, CAST"), + SatelliteAPCSatelliteType::QZSS => f.write_str("QZSS"), + } + } +} + /// None /// /// Troposphere vertical delays (mean and standard deviation) at the grid diff --git a/rust/sbp/src/messages/system.rs b/rust/sbp/src/messages/system.rs index e03de5f0b5..9f96478a08 100644 --- a/rust/sbp/src/messages/system.rs +++ b/rust/sbp/src/messages/system.rs @@ -188,6 +188,21 @@ pub struct MsgDgnssStatus { pub source: SbpString, Unterminated>, } +impl MsgDgnssStatus { + pub fn differential_type(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 0) { + 0 => Some(MsgDgnssStatusDifferentialType::Invalid), + 1 => Some(MsgDgnssStatusDifferentialType::CodeDifference), + 2 => Some(MsgDgnssStatusDifferentialType::RTK), + _ => None, + } + } + + pub fn set_differential_type(&mut self, differential_type: MsgDgnssStatusDifferentialType) { + set_bit_range!(&mut self.flags, differential_type, u8, u8, 3, 0); + } +} + impl ConcreteMessage for MsgDgnssStatus { const MESSAGE_TYPE: u16 = 65282; const MESSAGE_NAME: &'static str = "MSG_DGNSS_STATUS"; @@ -249,6 +264,29 @@ impl WireFormat for MsgDgnssStatus { } } +/// Differential type +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgDgnssStatusDifferentialType { + /// Invalid + Invalid = 0, + + /// Code Difference + CodeDifference = 1, + + /// RTK + RTK = 2, +} + +impl std::fmt::Display for MsgDgnssStatusDifferentialType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgDgnssStatusDifferentialType::Invalid => f.write_str("Invalid"), + MsgDgnssStatusDifferentialType::CodeDifference => f.write_str("Code Difference"), + MsgDgnssStatusDifferentialType::RTK => f.write_str("RTK"), + } + } +} + /// Offset of the local time with respect to GNSS time /// /// The GNSS time offset message contains the information that is needed to @@ -363,6 +401,21 @@ pub struct MsgGroupMeta { pub group_msgs: Vec, } +impl MsgGroupMeta { + pub fn solution_group_type(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 1, 0) { + 0 => Some(MsgGroupMetaSolutionGroupType::None), + 1 => Some(MsgGroupMetaSolutionGroupType::GnssOnly), + 2 => Some(MsgGroupMetaSolutionGroupType::GnssINS), + _ => None, + } + } + + pub fn set_solution_group_type(&mut self, solution_group_type: MsgGroupMetaSolutionGroupType) { + set_bit_range!(&mut self.flags, solution_group_type, u8, u8, 1, 0); + } +} + impl ConcreteMessage for MsgGroupMeta { const MESSAGE_TYPE: u16 = 65290; const MESSAGE_NAME: &'static str = "MSG_GROUP_META"; @@ -424,6 +477,29 @@ impl WireFormat for MsgGroupMeta { } } +/// Solution Group type +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgGroupMetaSolutionGroupType { + /// None (invalid) + None = 0, + + /// GNSS only + GnssOnly = 1, + + /// GNSS+INS (Fuzed) + GnssINS = 2, +} + +impl std::fmt::Display for MsgGroupMetaSolutionGroupType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgGroupMetaSolutionGroupType::None => f.write_str("None (invalid)"), + MsgGroupMetaSolutionGroupType::GnssOnly => f.write_str("GNSS only"), + MsgGroupMetaSolutionGroupType::GnssINS => f.write_str("GNSS+INS (Fuzed)"), + } + } +} + /// System heartbeat message /// /// The heartbeat message is sent periodically to inform the host or other @@ -447,6 +523,104 @@ pub struct MsgHeartbeat { pub flags: u32, } +impl MsgHeartbeat { + pub fn external_antenna_present(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 31, 0) { + 0 => Some(MsgHeartbeatExternalAntennaPresent::NoExternalAntennaDetected), + 1 => Some(MsgHeartbeatExternalAntennaPresent::ExternalAntennaIsPresent), + _ => None, + } + } + + pub fn set_external_antenna_present( + &mut self, + external_antenna_present: MsgHeartbeatExternalAntennaPresent, + ) { + set_bit_range!(&mut self.flags, external_antenna_present, u32, u8, 31, 0); + } + + pub fn external_antenna_short(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 30, 0) { + 0 => Some(MsgHeartbeatExternalAntennaShort::NoShortDetected), + 1 => Some(MsgHeartbeatExternalAntennaShort::ShortDetected), + _ => None, + } + } + + pub fn set_external_antenna_short( + &mut self, + external_antenna_short: MsgHeartbeatExternalAntennaShort, + ) { + set_bit_range!(&mut self.flags, external_antenna_short, u32, u8, 30, 0); + } + + pub fn sbp_major_protocol_version_number(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 23, 16) + } + + pub fn set_sbp_major_protocol_version_number(&mut self, sbp_major_protocol_version_number: u8) { + set_bit_range!( + &mut self.flags, + sbp_major_protocol_version_number, + u32, + u8, + 23, + 16 + ); + } + + pub fn sbp_minor_protocol_version_number(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 15, 8) + } + + pub fn set_sbp_minor_protocol_version_number(&mut self, sbp_minor_protocol_version_number: u8) { + set_bit_range!( + &mut self.flags, + sbp_minor_protocol_version_number, + u32, + u8, + 15, + 8 + ); + } + + pub fn swift_nap_error(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 2, 0) { + 0 => Some(MsgHeartbeatSwiftNapError::SystemHealthy), + 1 => Some(MsgHeartbeatSwiftNapError::AnErrorHasOccurredInTheSwiftNap), + _ => None, + } + } + + pub fn set_swift_nap_error(&mut self, swift_nap_error: MsgHeartbeatSwiftNapError) { + set_bit_range!(&mut self.flags, swift_nap_error, u32, u8, 2, 0); + } + + pub fn io_error(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 1, 0) { + 0 => Some(MsgHeartbeatIoError::SystemHealthy), + 1 => Some(MsgHeartbeatIoError::AnIoErrorHasOccurred), + _ => None, + } + } + + pub fn set_io_error(&mut self, io_error: MsgHeartbeatIoError) { + set_bit_range!(&mut self.flags, io_error, u32, u8, 1, 0); + } + + pub fn system_error_flag(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 0, 0) { + 0 => Some(MsgHeartbeatSystemErrorFlag::SystemHealthy), + 1 => Some(MsgHeartbeatSystemErrorFlag::AnErrorHasOccurred), + _ => None, + } + } + + pub fn set_system_error_flag(&mut self, system_error_flag: MsgHeartbeatSystemErrorFlag) { + set_bit_range!(&mut self.flags, system_error_flag, u32, u8, 0, 0); + } +} + impl ConcreteMessage for MsgHeartbeat { const MESSAGE_TYPE: u16 = 65535; const MESSAGE_NAME: &'static str = "MSG_HEARTBEAT"; @@ -496,6 +670,107 @@ impl WireFormat for MsgHeartbeat { } } +/// External antenna present +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgHeartbeatExternalAntennaPresent { + /// No external antenna detected + NoExternalAntennaDetected = 0, + + /// External antenna is present + ExternalAntennaIsPresent = 1, +} + +impl std::fmt::Display for MsgHeartbeatExternalAntennaPresent { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgHeartbeatExternalAntennaPresent::NoExternalAntennaDetected => { + f.write_str("No external antenna detected") + } + MsgHeartbeatExternalAntennaPresent::ExternalAntennaIsPresent => { + f.write_str("External antenna is present") + } + } + } +} + +/// External antenna short +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgHeartbeatExternalAntennaShort { + /// No short detected + NoShortDetected = 0, + + /// Short detected + ShortDetected = 1, +} + +impl std::fmt::Display for MsgHeartbeatExternalAntennaShort { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgHeartbeatExternalAntennaShort::NoShortDetected => f.write_str("No short detected"), + MsgHeartbeatExternalAntennaShort::ShortDetected => f.write_str("Short detected"), + } + } +} + +/// SwiftNAP Error +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgHeartbeatSwiftNapError { + /// System Healthy + SystemHealthy = 0, + + /// An error has occurred in the SwiftNAP + AnErrorHasOccurredInTheSwiftNap = 1, +} + +impl std::fmt::Display for MsgHeartbeatSwiftNapError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgHeartbeatSwiftNapError::SystemHealthy => f.write_str("System Healthy"), + MsgHeartbeatSwiftNapError::AnErrorHasOccurredInTheSwiftNap => { + f.write_str("An error has occurred in the SwiftNAP") + } + } + } +} + +/// IO Error +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgHeartbeatIoError { + /// System Healthy + SystemHealthy = 0, + + /// An IO error has occurred + AnIoErrorHasOccurred = 1, +} + +impl std::fmt::Display for MsgHeartbeatIoError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgHeartbeatIoError::SystemHealthy => f.write_str("System Healthy"), + MsgHeartbeatIoError::AnIoErrorHasOccurred => f.write_str("An IO error has occurred"), + } + } +} + +/// System Error Flag +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgHeartbeatSystemErrorFlag { + /// System Healthy + SystemHealthy = 0, + + /// An error has occurred + AnErrorHasOccurred = 1, +} + +impl std::fmt::Display for MsgHeartbeatSystemErrorFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgHeartbeatSystemErrorFlag::SystemHealthy => f.write_str("System Healthy"), + MsgHeartbeatSystemErrorFlag::AnErrorHasOccurred => f.write_str("An error has occurred"), + } + } +} + /// Inertial Navigation System status message /// /// The INS status message describes the state of the operation and @@ -512,6 +787,101 @@ pub struct MsgInsStatus { pub flags: u32, } +impl MsgInsStatus { + pub fn ins_type(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 31, 29) { + 0 => Some(MsgInsStatusInsType::SmoothposeLooselyCoupled), + 1 => Some(MsgInsStatusInsType::Starling), + _ => None, + } + } + + pub fn set_ins_type(&mut self, ins_type: MsgInsStatusInsType) { + set_bit_range!(&mut self.flags, ins_type, u32, u8, 31, 29); + } + + pub fn motion_state(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 13, 11) { + 0 => Some(MsgInsStatusMotionState::UnknownOrInit), + 1 => Some(MsgInsStatusMotionState::ArbitraryMotion), + 2 => Some(MsgInsStatusMotionState::StraightMotion), + 3 => Some(MsgInsStatusMotionState::Stationary), + _ => None, + } + } + + pub fn set_motion_state(&mut self, motion_state: MsgInsStatusMotionState) { + set_bit_range!(&mut self.flags, motion_state, u32, u8, 13, 11); + } + + pub fn odometry_synch(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 10, 0) { + 0 => Some(MsgInsStatusOdometrySynch::OdometryTimestampNominal), + 1 => Some(MsgInsStatusOdometrySynch::OdometryTimestampOutOfBounds), + _ => None, + } + } + + pub fn set_odometry_synch(&mut self, odometry_synch: MsgInsStatusOdometrySynch) { + set_bit_range!(&mut self.flags, odometry_synch, u32, u8, 10, 0); + } + + pub fn odometry_status(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 9, 8) { + 0 => Some(MsgInsStatusOdometryStatus::NoOdometry), + 1 => Some(MsgInsStatusOdometryStatus::OdometryReceivedWithinLastSecond), + 2 => Some(MsgInsStatusOdometryStatus::OdometryNotReceivedWithinLastSecond), + _ => None, + } + } + + pub fn set_odometry_status(&mut self, odometry_status: MsgInsStatusOdometryStatus) { + set_bit_range!(&mut self.flags, odometry_status, u32, u8, 9, 8); + } + + pub fn ins_error(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 7, 4) { + 1 => Some(MsgInsStatusInsError::ImuDataError), + 2 => Some(MsgInsStatusInsError::InsLicenseError), + 3 => Some(MsgInsStatusInsError::ImuCalibrationDataError), + _ => None, + } + } + + pub fn set_ins_error(&mut self, ins_error: MsgInsStatusInsError) { + set_bit_range!(&mut self.flags, ins_error, u32, u8, 7, 4); + } + + pub fn gnss_fix(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 3, 0) { + 0 => Some(MsgInsStatusGnssFix::NoGnssFixAvailable), + 1 => Some(MsgInsStatusGnssFix::GnssFix), + _ => None, + } + } + + pub fn set_gnss_fix(&mut self, gnss_fix: MsgInsStatusGnssFix) { + set_bit_range!(&mut self.flags, gnss_fix, u32, u8, 3, 0); + } + + pub fn mode(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 2, 0) { + 0 => Some(MsgInsStatusMode::AwaitingInitialization), + 1 => Some(MsgInsStatusMode::DynamicallyAligning), + 2 => Some(MsgInsStatusMode::Ready), + 3 => Some(MsgInsStatusMode::GnssOutageExceedsMaxDuration), + 4 => Some(MsgInsStatusMode::FastStartSeeding), + 5 => Some(MsgInsStatusMode::FastStartValidating), + 6 => Some(MsgInsStatusMode::ValidatingUnsafeFastStartSeed), + _ => None, + } + } + + pub fn set_mode(&mut self, mode: MsgInsStatusMode) { + set_bit_range!(&mut self.flags, mode, u32, u8, 2, 0); + } +} + impl ConcreteMessage for MsgInsStatus { const MESSAGE_TYPE: u16 = 65283; const MESSAGE_NAME: &'static str = "MSG_INS_STATUS"; @@ -561,6 +931,191 @@ impl WireFormat for MsgInsStatus { } } +/// INS Type +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgInsStatusInsType { + /// Smoothpose Loosely Coupled + SmoothposeLooselyCoupled = 0, + + /// Starling + Starling = 1, +} + +impl std::fmt::Display for MsgInsStatusInsType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgInsStatusInsType::SmoothposeLooselyCoupled => { + f.write_str("Smoothpose Loosely Coupled") + } + MsgInsStatusInsType::Starling => f.write_str("Starling"), + } + } +} + +/// Motion State +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgInsStatusMotionState { + /// Unknown or Init + UnknownOrInit = 0, + + /// Arbitrary Motion + ArbitraryMotion = 1, + + /// Straight Motion + StraightMotion = 2, + + /// Stationary + Stationary = 3, +} + +impl std::fmt::Display for MsgInsStatusMotionState { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgInsStatusMotionState::UnknownOrInit => f.write_str("Unknown or Init"), + MsgInsStatusMotionState::ArbitraryMotion => f.write_str("Arbitrary Motion"), + MsgInsStatusMotionState::StraightMotion => f.write_str("Straight Motion"), + MsgInsStatusMotionState::Stationary => f.write_str("Stationary"), + } + } +} + +/// Odometry Synch +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgInsStatusOdometrySynch { + /// Odometry timestamp nominal + OdometryTimestampNominal = 0, + + /// Odometry timestamp out of bounds + OdometryTimestampOutOfBounds = 1, +} + +impl std::fmt::Display for MsgInsStatusOdometrySynch { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgInsStatusOdometrySynch::OdometryTimestampNominal => { + f.write_str("Odometry timestamp nominal") + } + MsgInsStatusOdometrySynch::OdometryTimestampOutOfBounds => { + f.write_str("Odometry timestamp out of bounds") + } + } + } +} + +/// Odometry status +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgInsStatusOdometryStatus { + /// No Odometry + NoOdometry = 0, + + /// Odometry received within last second + OdometryReceivedWithinLastSecond = 1, + + /// Odometry not received within last second + OdometryNotReceivedWithinLastSecond = 2, +} + +impl std::fmt::Display for MsgInsStatusOdometryStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgInsStatusOdometryStatus::NoOdometry => f.write_str("No Odometry"), + MsgInsStatusOdometryStatus::OdometryReceivedWithinLastSecond => { + f.write_str("Odometry received within last second") + } + MsgInsStatusOdometryStatus::OdometryNotReceivedWithinLastSecond => { + f.write_str("Odometry not received within last second") + } + } + } +} + +/// INS Error +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgInsStatusInsError { + /// IMU Data Error + ImuDataError = 1, + + /// INS License Error + InsLicenseError = 2, + + /// IMU Calibration Data Error + ImuCalibrationDataError = 3, +} + +impl std::fmt::Display for MsgInsStatusInsError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgInsStatusInsError::ImuDataError => f.write_str("IMU Data Error"), + MsgInsStatusInsError::InsLicenseError => f.write_str("INS License Error"), + MsgInsStatusInsError::ImuCalibrationDataError => { + f.write_str("IMU Calibration Data Error") + } + } + } +} + +/// GNSS Fix +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgInsStatusGnssFix { + /// No GNSS fix available + NoGnssFixAvailable = 0, + + /// GNSS fix + GnssFix = 1, +} + +impl std::fmt::Display for MsgInsStatusGnssFix { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgInsStatusGnssFix::NoGnssFixAvailable => f.write_str("No GNSS fix available"), + MsgInsStatusGnssFix::GnssFix => f.write_str("GNSS fix"), + } + } +} + +/// Mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgInsStatusMode { + /// Awaiting initialization + AwaitingInitialization = 0, + + /// Dynamically aligning + DynamicallyAligning = 1, + + /// Ready + Ready = 2, + + /// GNSS Outage exceeds max duration + GnssOutageExceedsMaxDuration = 3, + + /// FastStart seeding + FastStartSeeding = 4, + + /// FastStart validating + FastStartValidating = 5, + + /// Validating unsafe fast start seed + ValidatingUnsafeFastStartSeed = 6, +} + +impl std::fmt::Display for MsgInsStatusMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgInsStatusMode::AwaitingInitialization => f.write_str("Awaiting initialization"), + MsgInsStatusMode::DynamicallyAligning => f.write_str("Dynamically aligning"), + MsgInsStatusMode::Ready => f.write_str("Ready"), + MsgInsStatusMode::GnssOutageExceedsMaxDuration => { + f.write_str("GNSS Outage exceeds max duration") + } + MsgInsStatusMode::FastStartSeeding => f.write_str("FastStart seeding"), + MsgInsStatusMode::FastStartValidating => f.write_str("FastStart validating"), + MsgInsStatusMode::ValidatingUnsafeFastStartSeed => { + f.write_str("Validating unsafe fast start seed") + } + } + } +} + /// Inertial Navigation System update status message /// /// The INS update status message contains information about executed and @@ -596,6 +1151,224 @@ pub struct MsgInsUpdates { pub zerovel: u8, } +impl MsgInsUpdates { + pub fn number_of_attempted_gnss_position_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.gnsspos, u8, u8, 7, 4) + } + + pub fn set_number_of_attempted_gnss_position_updates_since_last_message( + &mut self, + number_of_attempted_gnss_position_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.gnsspos, + number_of_attempted_gnss_position_updates_since_last_message, + u8, + u8, + 7, + 4 + ); + } + + pub fn number_of_rejected_gnss_position_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.gnsspos, u8, u8, 3, 0) + } + + pub fn set_number_of_rejected_gnss_position_updates_since_last_message( + &mut self, + number_of_rejected_gnss_position_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.gnsspos, + number_of_rejected_gnss_position_updates_since_last_message, + u8, + u8, + 3, + 0 + ); + } + + pub fn number_of_attempted_gnss_velocity_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.gnssvel, u8, u8, 7, 4) + } + + pub fn set_number_of_attempted_gnss_velocity_updates_since_last_message( + &mut self, + number_of_attempted_gnss_velocity_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.gnssvel, + number_of_attempted_gnss_velocity_updates_since_last_message, + u8, + u8, + 7, + 4 + ); + } + + pub fn number_of_rejected_gnss_velocity_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.gnssvel, u8, u8, 3, 0) + } + + pub fn set_number_of_rejected_gnss_velocity_updates_since_last_message( + &mut self, + number_of_rejected_gnss_velocity_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.gnssvel, + number_of_rejected_gnss_velocity_updates_since_last_message, + u8, + u8, + 3, + 0 + ); + } + + pub fn number_of_attempted_wheeltick_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.wheelticks, u8, u8, 7, 4) + } + + pub fn set_number_of_attempted_wheeltick_updates_since_last_message( + &mut self, + number_of_attempted_wheeltick_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.wheelticks, + number_of_attempted_wheeltick_updates_since_last_message, + u8, + u8, + 7, + 4 + ); + } + + pub fn number_of_rejected_wheeltick_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.wheelticks, u8, u8, 3, 0) + } + + pub fn set_number_of_rejected_wheeltick_updates_since_last_message( + &mut self, + number_of_rejected_wheeltick_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.wheelticks, + number_of_rejected_wheeltick_updates_since_last_message, + u8, + u8, + 3, + 0 + ); + } + + pub fn number_of_attempted_speed_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.speed, u8, u8, 7, 4) + } + + pub fn set_number_of_attempted_speed_updates_since_last_message( + &mut self, + number_of_attempted_speed_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.speed, + number_of_attempted_speed_updates_since_last_message, + u8, + u8, + 7, + 4 + ); + } + + pub fn number_of_rejected_speed_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.speed, u8, u8, 3, 0) + } + + pub fn set_number_of_rejected_speed_updates_since_last_message( + &mut self, + number_of_rejected_speed_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.speed, + number_of_rejected_speed_updates_since_last_message, + u8, + u8, + 3, + 0 + ); + } + + pub fn number_of_attempted_nhc_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.nhc, u8, u8, 7, 4) + } + + pub fn set_number_of_attempted_nhc_updates_since_last_message( + &mut self, + number_of_attempted_nhc_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.nhc, + number_of_attempted_nhc_updates_since_last_message, + u8, + u8, + 7, + 4 + ); + } + + pub fn number_of_rejected_nhc_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.nhc, u8, u8, 3, 0) + } + + pub fn set_number_of_rejected_nhc_updates_since_last_message( + &mut self, + number_of_rejected_nhc_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.nhc, + number_of_rejected_nhc_updates_since_last_message, + u8, + u8, + 3, + 0 + ); + } + + pub fn number_of_attempted_zero_velocity_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.zerovel, u8, u8, 7, 4) + } + + pub fn set_number_of_attempted_zero_velocity_updates_since_last_message( + &mut self, + number_of_attempted_zero_velocity_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.zerovel, + number_of_attempted_zero_velocity_updates_since_last_message, + u8, + u8, + 7, + 4 + ); + } + + pub fn number_of_rejected_zero_velocity_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.zerovel, u8, u8, 3, 0) + } + + pub fn set_number_of_rejected_zero_velocity_updates_since_last_message( + &mut self, + number_of_rejected_zero_velocity_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.zerovel, + number_of_rejected_zero_velocity_updates_since_last_message, + u8, + u8, + 3, + 0 + ); + } +} + impl ConcreteMessage for MsgInsUpdates { const MESSAGE_TYPE: u16 = 65286; const MESSAGE_NAME: &'static str = "MSG_INS_UPDATES"; @@ -707,6 +1480,30 @@ pub struct MsgPpsTime { pub flags: u8, } +impl MsgPpsTime { + pub fn reserved_set_to_zero(&self) -> u8 { + get_bit_range!(self.flags, u8, u8, 7, 2) + } + + pub fn set_reserved_set_to_zero(&mut self, reserved_set_to_zero: u8) { + set_bit_range!(&mut self.flags, reserved_set_to_zero, u8, u8, 7, 2); + } + + pub fn time_uncertainty(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 1, 0) { + 0 => Some(MsgPpsTimeTimeUncertainty::Unknown), + 1 => Some(MsgPpsTimeTimeUncertainty::_10Milliseconds), + 2 => Some(MsgPpsTimeTimeUncertainty::_10Microseconds), + 3 => Some(MsgPpsTimeTimeUncertainty::_1Microseconds), + _ => None, + } + } + + pub fn set_time_uncertainty(&mut self, time_uncertainty: MsgPpsTimeTimeUncertainty) { + set_bit_range!(&mut self.flags, time_uncertainty, u8, u8, 1, 0); + } +} + impl ConcreteMessage for MsgPpsTime { const MESSAGE_TYPE: u16 = 65288; const MESSAGE_NAME: &'static str = "MSG_PPS_TIME"; @@ -897,6 +1694,34 @@ pub struct MsgStartup { pub reserved: u16, } +impl MsgStartup { + pub fn cause_of_startup(&self) -> Option { + match get_bit_range!(self.cause, u8, u8, 8, 0) { + 0 => Some(MsgStartupCauseOfStartup::PowerOn), + 1 => Some(MsgStartupCauseOfStartup::SoftwareReset), + 2 => Some(MsgStartupCauseOfStartup::WatchdogReset), + _ => None, + } + } + + pub fn set_cause_of_startup(&mut self, cause_of_startup: MsgStartupCauseOfStartup) { + set_bit_range!(&mut self.cause, cause_of_startup, u8, u8, 8, 0); + } + + pub fn startup_type(&self) -> Option { + match get_bit_range!(self.startup_type, u8, u8, 8, 0) { + 0 => Some(MsgStartupStartupType::ColdStart), + 1 => Some(MsgStartupStartupType::WarmStart), + 2 => Some(MsgStartupStartupType::HotStart), + _ => None, + } + } + + pub fn set_startup_type(&mut self, startup_type: MsgStartupStartupType) { + set_bit_range!(&mut self.startup_type, startup_type, u8, u8, 8, 0); + } +} + impl ConcreteMessage for MsgStartup { const MESSAGE_TYPE: u16 = 65280; const MESSAGE_NAME: &'static str = "MSG_STARTUP"; @@ -953,6 +1778,51 @@ impl WireFormat for MsgStartup { } } +/// Cause of startup +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgStartupCauseOfStartup { + /// Power on + PowerOn = 0, + + /// Software reset + SoftwareReset = 1, + + /// Watchdog reset + WatchdogReset = 2, +} + +impl std::fmt::Display for MsgStartupCauseOfStartup { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgStartupCauseOfStartup::PowerOn => f.write_str("Power on"), + MsgStartupCauseOfStartup::SoftwareReset => f.write_str("Software reset"), + MsgStartupCauseOfStartup::WatchdogReset => f.write_str("Watchdog reset"), + } + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgStartupStartupType { + /// Cold start + ColdStart = 0, + + /// Warm start + WarmStart = 1, + + /// Hot start + HotStart = 2, +} + +impl std::fmt::Display for MsgStartupStartupType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgStartupStartupType::ColdStart => f.write_str("Cold start"), + MsgStartupStartupType::WarmStart => f.write_str("Warm start"), + MsgStartupStartupType::HotStart => f.write_str("Hot start"), + } + } +} + /// Status report message /// /// The status report is sent periodically to inform the host or other @@ -987,6 +1857,50 @@ pub struct MsgStatusReport { pub status: Vec, } +impl MsgStatusReport { + pub fn system(&self) -> Option { + match get_bit_range!(self.reporting_system, u16, u16, 15, 0) { + 0 => Some(MsgStatusReportSystem::Starling), + 1 => Some(MsgStatusReportSystem::PrecisionGnssModule), + _ => None, + } + } + + pub fn set_system(&mut self, system: MsgStatusReportSystem) { + set_bit_range!(&mut self.reporting_system, system, u16, u16, 15, 0); + } + + pub fn sbp_major_protocol_version_number(&self) -> u8 { + get_bit_range!(self.sbp_version, u16, u8, 16, 8) + } + + pub fn set_sbp_major_protocol_version_number(&mut self, sbp_major_protocol_version_number: u8) { + set_bit_range!( + &mut self.sbp_version, + sbp_major_protocol_version_number, + u16, + u8, + 16, + 8 + ); + } + + pub fn sbp_minor_protocol_version_number(&self) -> u8 { + get_bit_range!(self.sbp_version, u16, u8, 7, 0) + } + + pub fn set_sbp_minor_protocol_version_number(&mut self, sbp_minor_protocol_version_number: u8) { + set_bit_range!( + &mut self.sbp_version, + sbp_minor_protocol_version_number, + u16, + u8, + 7, + 0 + ); + } +} + impl ConcreteMessage for MsgStatusReport { const MESSAGE_TYPE: u16 = 65534; const MESSAGE_NAME: &'static str = "MSG_STATUS_REPORT"; @@ -1052,6 +1966,27 @@ impl WireFormat for MsgStatusReport { } } +/// System +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgStatusReportSystem { + /// Starling + Starling = 0, + + /// Precision GNSS Module (PGM) + PrecisionGnssModule = 1, +} + +impl std::fmt::Display for MsgStatusReportSystem { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgStatusReportSystem::Starling => f.write_str("Starling"), + MsgStatusReportSystem::PrecisionGnssModule => { + f.write_str("Precision GNSS Module (PGM)") + } + } + } +} + /// Sub-system Status report /// /// Report the general and specific state of a sub-system. If the generic @@ -1071,6 +2006,40 @@ pub struct SubSystemReport { pub specific: u8, } +impl SubSystemReport { + pub fn subsystem(&self) -> Option { + match get_bit_range!(self.component, u16, u16, 15, 0) { + 0 => Some(SubSystemReportSubsystem::PrimaryGnssAntenna), + 1 => Some(SubSystemReportSubsystem::MeasurementEngine), + 2 => Some(SubSystemReportSubsystem::CorrectionsClient), + 3 => Some(SubSystemReportSubsystem::DifferentialGnssEngine), + 4 => Some(SubSystemReportSubsystem::CAN), + 5 => Some(SubSystemReportSubsystem::WheelOdometry), + 6 => Some(SubSystemReportSubsystem::SensorFusionEngine), + _ => None, + } + } + + pub fn set_subsystem(&mut self, subsystem: SubSystemReportSubsystem) { + set_bit_range!(&mut self.component, subsystem, u16, u16, 15, 0); + } + + pub fn generic(&self) -> Option { + match get_bit_range!(self.generic, u8, u8, 7, 0) { + 0 => Some(SubSystemReportGeneric::OKNominal), + 1 => Some(SubSystemReportGeneric::Initializing), + 2 => Some(SubSystemReportGeneric::Unknown), + 3 => Some(SubSystemReportGeneric::Degraded), + 4 => Some(SubSystemReportGeneric::Unusable), + _ => None, + } + } + + pub fn set_generic(&mut self, generic: SubSystemReportGeneric) { + set_bit_range!(&mut self.generic, generic, u8, u8, 7, 0); + } +} + impl WireFormat for SubSystemReport { const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN + ::MIN_LEN; @@ -1092,3 +2061,75 @@ impl WireFormat for SubSystemReport { } } } + +/// Subsystem +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum SubSystemReportSubsystem { + /// Primary GNSS Antenna + PrimaryGnssAntenna = 0, + + /// Measurement Engine + MeasurementEngine = 1, + + /// Corrections Client + CorrectionsClient = 2, + + /// Differential GNSS Engine + DifferentialGnssEngine = 3, + + /// CAN + CAN = 4, + + /// Wheel Odometry + WheelOdometry = 5, + + /// Sensor Fusion Engine + SensorFusionEngine = 6, +} + +impl std::fmt::Display for SubSystemReportSubsystem { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SubSystemReportSubsystem::PrimaryGnssAntenna => f.write_str("Primary GNSS Antenna"), + SubSystemReportSubsystem::MeasurementEngine => f.write_str("Measurement Engine"), + SubSystemReportSubsystem::CorrectionsClient => f.write_str("Corrections Client"), + SubSystemReportSubsystem::DifferentialGnssEngine => { + f.write_str("Differential GNSS Engine") + } + SubSystemReportSubsystem::CAN => f.write_str("CAN"), + SubSystemReportSubsystem::WheelOdometry => f.write_str("Wheel Odometry"), + SubSystemReportSubsystem::SensorFusionEngine => f.write_str("Sensor Fusion Engine"), + } + } +} + +/// Generic +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum SubSystemReportGeneric { + /// OK/Nominal + OKNominal = 0, + + /// Initializing + Initializing = 1, + + /// Unknown + Unknown = 2, + + /// Degraded + Degraded = 3, + + /// Unusable + Unusable = 4, +} + +impl std::fmt::Display for SubSystemReportGeneric { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SubSystemReportGeneric::OKNominal => f.write_str("OK/Nominal"), + SubSystemReportGeneric::Initializing => f.write_str("Initializing"), + SubSystemReportGeneric::Unknown => f.write_str("Unknown"), + SubSystemReportGeneric::Degraded => f.write_str("Degraded"), + SubSystemReportGeneric::Unusable => f.write_str("Unusable"), + } + } +} diff --git a/rust/sbp/src/messages/tracking.rs b/rust/sbp/src/messages/tracking.rs index 6f101e84af..f398e41d06 100644 --- a/rust/sbp/src/messages/tracking.rs +++ b/rust/sbp/src/messages/tracking.rs @@ -589,6 +589,290 @@ pub struct MsgTrackingStateDetailedDep { pub misc_flags: u8, } +impl MsgTrackingStateDetailedDep { + pub fn synchronization_status( + &self, + ) -> Option { + match get_bit_range!( self.sync_flags, u8, u8, 2, 0 ) { + 0 => Some( MsgTrackingStateDetailedDepSynchronizationStatus :: NoSynchronization ), + 1 => Some( MsgTrackingStateDetailedDepSynchronizationStatus :: BitSynchronization ), + 2 => Some( MsgTrackingStateDetailedDepSynchronizationStatus :: WordSynchronization ), + 3 => Some( MsgTrackingStateDetailedDepSynchronizationStatus :: SubFrameSynchronizationMessageSynchronization ), + _ => None, + } + } + + pub fn set_synchronization_status( + &mut self, + synchronization_status: MsgTrackingStateDetailedDepSynchronizationStatus, + ) { + set_bit_range!(&mut self.sync_flags, synchronization_status, u8, u8, 2, 0); + } + + pub fn week_number_validity_status( + &self, + ) -> Option { + match get_bit_range!(self.tow_flags, u8, u8, 3, 0) { + 0 => Some(MsgTrackingStateDetailedDepWeekNumberValidityStatus::WeekNumberIsNotValid), + 1 => Some(MsgTrackingStateDetailedDepWeekNumberValidityStatus::WeekNumberIsValid), + _ => None, + } + } + + pub fn set_week_number_validity_status( + &mut self, + week_number_validity_status: MsgTrackingStateDetailedDepWeekNumberValidityStatus, + ) { + set_bit_range!( + &mut self.tow_flags, + week_number_validity_status, + u8, + u8, + 3, + 0 + ); + } + + pub fn tow_status(&self) -> Option { + match get_bit_range!(self.tow_flags, u8, u8, 2, 0) { + 0 => Some(MsgTrackingStateDetailedDepTowStatus::TowIsNotAvailable), + 1 => Some(MsgTrackingStateDetailedDepTowStatus::DecodedTowIsAvailable), + 2 => Some(MsgTrackingStateDetailedDepTowStatus::PropagatedTowIsAvailable), + _ => None, + } + } + + pub fn set_tow_status(&mut self, tow_status: MsgTrackingStateDetailedDepTowStatus) { + set_bit_range!(&mut self.tow_flags, tow_status, u8, u8, 2, 0); + } + + pub fn fll_status(&self) -> Option { + match get_bit_range!(self.track_flags, u8, u8, 4, 0) { + 0 => Some(MsgTrackingStateDetailedDepFllStatus::FllIsInactive), + 1 => Some(MsgTrackingStateDetailedDepFllStatus::FllIsActive), + _ => None, + } + } + + pub fn set_fll_status(&mut self, fll_status: MsgTrackingStateDetailedDepFllStatus) { + set_bit_range!(&mut self.track_flags, fll_status, u8, u8, 4, 0); + } + + pub fn pll_status(&self) -> Option { + match get_bit_range!(self.track_flags, u8, u8, 3, 0) { + 0 => Some(MsgTrackingStateDetailedDepPllStatus::PllIsInactive), + 1 => Some(MsgTrackingStateDetailedDepPllStatus::PllIsActive), + _ => None, + } + } + + pub fn set_pll_status(&mut self, pll_status: MsgTrackingStateDetailedDepPllStatus) { + set_bit_range!(&mut self.track_flags, pll_status, u8, u8, 3, 0); + } + + pub fn tracking_loop_status(&self) -> Option { + match get_bit_range!(self.track_flags, u8, u8, 2, 0) { + 0 => Some(MsgTrackingStateDetailedDepTrackingLoopStatus::NoLocks), + 1 => Some(MsgTrackingStateDetailedDepTrackingLoopStatus::FlldllLock), + 2 => Some(MsgTrackingStateDetailedDepTrackingLoopStatus::PllOptimisticLock), + 3 => Some(MsgTrackingStateDetailedDepTrackingLoopStatus::PllPessimisticLock), + _ => None, + } + } + + pub fn set_tracking_loop_status( + &mut self, + tracking_loop_status: MsgTrackingStateDetailedDepTrackingLoopStatus, + ) { + set_bit_range!(&mut self.track_flags, tracking_loop_status, u8, u8, 2, 0); + } + + pub fn almanac_availability_status( + &self, + ) -> Option { + match get_bit_range!(self.nav_flags, u8, u8, 4, 0) { + 0 => Some(MsgTrackingStateDetailedDepAlmanacAvailabilityStatus::AlmanacIsNotAvailable), + 1 => Some(MsgTrackingStateDetailedDepAlmanacAvailabilityStatus::AlmanacIsAvailable), + _ => None, + } + } + + pub fn set_almanac_availability_status( + &mut self, + almanac_availability_status: MsgTrackingStateDetailedDepAlmanacAvailabilityStatus, + ) { + set_bit_range!( + &mut self.nav_flags, + almanac_availability_status, + u8, + u8, + 4, + 0 + ); + } + + pub fn ephemeris_availability_status( + &self, + ) -> Option { + match get_bit_range!(self.nav_flags, u8, u8, 3, 0) { + 0 => Some( + MsgTrackingStateDetailedDepEphemerisAvailabilityStatus::EphemerisIsNotAvailable, + ), + 1 => Some(MsgTrackingStateDetailedDepEphemerisAvailabilityStatus::EphemerisIsAvailable), + _ => None, + } + } + + pub fn set_ephemeris_availability_status( + &mut self, + ephemeris_availability_status: MsgTrackingStateDetailedDepEphemerisAvailabilityStatus, + ) { + set_bit_range!( + &mut self.nav_flags, + ephemeris_availability_status, + u8, + u8, + 3, + 0 + ); + } + + pub fn health_status(&self) -> Option { + match get_bit_range!(self.nav_flags, u8, u8, 2, 0) { + 0 => Some(MsgTrackingStateDetailedDepHealthStatus::HealthIsUnknown), + 1 => Some(MsgTrackingStateDetailedDepHealthStatus::SignalIsUnhealthy), + 2 => Some(MsgTrackingStateDetailedDepHealthStatus::SignalIsHealthy), + _ => None, + } + } + + pub fn set_health_status(&mut self, health_status: MsgTrackingStateDetailedDepHealthStatus) { + set_bit_range!(&mut self.nav_flags, health_status, u8, u8, 2, 0); + } + + pub fn parameter_sets(&self) -> Option { + match get_bit_range!(self.pset_flags, u8, u8, 2, 0) { + 0 => Some(MsgTrackingStateDetailedDepParameterSets::_1MsIntegrationTime), + 1 => Some(MsgTrackingStateDetailedDepParameterSets::_5MsIntegrationTime), + 2 => Some(MsgTrackingStateDetailedDepParameterSets::_10MsIntegrationTime), + 3 => Some(MsgTrackingStateDetailedDepParameterSets::_20MsIntegrationTime), + _ => None, + } + } + + pub fn set_parameter_sets(&mut self, parameter_sets: MsgTrackingStateDetailedDepParameterSets) { + set_bit_range!(&mut self.pset_flags, parameter_sets, u8, u8, 2, 0); + } + + pub fn clock_validity_status(&self) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 5, 0) { + 0 => { + Some(MsgTrackingStateDetailedDepClockValidityStatus::ClockOffsetAndDriftIsNotValid) + } + 1 => Some(MsgTrackingStateDetailedDepClockValidityStatus::ClockOffsetAndDriftIsValid), + _ => None, + } + } + + pub fn set_clock_validity_status( + &mut self, + clock_validity_status: MsgTrackingStateDetailedDepClockValidityStatus, + ) { + set_bit_range!(&mut self.misc_flags, clock_validity_status, u8, u8, 5, 0); + } + + pub fn pseudorange_validity_status( + &self, + ) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 4, 0) { + 0 => Some(MsgTrackingStateDetailedDepPseudorangeValidityStatus::PseudorangeIsNotValid), + 1 => Some(MsgTrackingStateDetailedDepPseudorangeValidityStatus::PseudorangeIsValid), + _ => None, + } + } + + pub fn set_pseudorange_validity_status( + &mut self, + pseudorange_validity_status: MsgTrackingStateDetailedDepPseudorangeValidityStatus, + ) { + set_bit_range!( + &mut self.misc_flags, + pseudorange_validity_status, + u8, + u8, + 4, + 0 + ); + } + + pub fn acceleration_validity_status( + &self, + ) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 3, 0) { + 0 => { + Some(MsgTrackingStateDetailedDepAccelerationValidityStatus::AccelerationIsNotValid) + } + 1 => Some(MsgTrackingStateDetailedDepAccelerationValidityStatus::AccelerationIsValid), + _ => None, + } + } + + pub fn set_acceleration_validity_status( + &mut self, + acceleration_validity_status: MsgTrackingStateDetailedDepAccelerationValidityStatus, + ) { + set_bit_range!( + &mut self.misc_flags, + acceleration_validity_status, + u8, + u8, + 3, + 0 + ); + } + + pub fn carrier_half_cycle_ambiguity_status( + &self, + ) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 2, 0) { + 0 => Some(MsgTrackingStateDetailedDepCarrierHalfCycleAmbiguityStatus::Unresolved), + 1 => Some(MsgTrackingStateDetailedDepCarrierHalfCycleAmbiguityStatus::Resolved), + _ => None, + } + } + + pub fn set_carrier_half_cycle_ambiguity_status( + &mut self, + carrier_half_cycle_ambiguity_status: MsgTrackingStateDetailedDepCarrierHalfCycleAmbiguityStatus, + ) { + set_bit_range!( + &mut self.misc_flags, + carrier_half_cycle_ambiguity_status, + u8, + u8, + 2, + 0 + ); + } + + pub fn tracking_channel_status( + &self, + ) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 1, 0) { + 0 => Some(MsgTrackingStateDetailedDepTrackingChannelStatus::ReAcquisition), + 1 => Some(MsgTrackingStateDetailedDepTrackingChannelStatus::Running), + _ => None, + } + } + + pub fn set_tracking_channel_status( + &mut self, + tracking_channel_status: MsgTrackingStateDetailedDepTrackingChannelStatus, + ) { + set_bit_range!(&mut self.misc_flags, tracking_channel_status, u8, u8, 1, 0); + } +} + impl ConcreteMessage for MsgTrackingStateDetailedDep { const MESSAGE_TYPE: u16 = 17; const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE_DETAILED_DEP"; @@ -718,6 +1002,380 @@ impl WireFormat for MsgTrackingStateDetailedDep { } } +/// Synchronization status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepSynchronizationStatus { + /// No synchronization + NoSynchronization = 0, + + /// Bit synchronization + BitSynchronization = 1, + + /// Word synchronization (L1 C/A only) + WordSynchronization = 2, + + /// Sub-frame synchronization (L1 C/A) / message synchronization (L2C) + SubFrameSynchronizationMessageSynchronization = 3, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepSynchronizationStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepSynchronizationStatus::NoSynchronization => f.write_str("No synchronization"), + MsgTrackingStateDetailedDepSynchronizationStatus::BitSynchronization => f.write_str("Bit synchronization"), + MsgTrackingStateDetailedDepSynchronizationStatus::WordSynchronization => f.write_str("Word synchronization (L1 C/A only)"), + MsgTrackingStateDetailedDepSynchronizationStatus::SubFrameSynchronizationMessageSynchronization => f.write_str("Sub-frame synchronization (L1 C/A) / message synchronization (L2C) +"), + } + } +} + +/// Week number validity status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepWeekNumberValidityStatus { + /// Week number is not valid + WeekNumberIsNotValid = 0, + + /// Week number is valid + WeekNumberIsValid = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepWeekNumberValidityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepWeekNumberValidityStatus::WeekNumberIsNotValid => { + f.write_str("Week number is not valid") + } + MsgTrackingStateDetailedDepWeekNumberValidityStatus::WeekNumberIsValid => { + f.write_str("Week number is valid") + } + } + } +} + +/// TOW status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepTowStatus { + /// TOW is not available + TowIsNotAvailable = 0, + + /// Decoded TOW is available + DecodedTowIsAvailable = 1, + + /// Propagated TOW is available + PropagatedTowIsAvailable = 2, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepTowStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepTowStatus::TowIsNotAvailable => { + f.write_str("TOW is not available") + } + MsgTrackingStateDetailedDepTowStatus::DecodedTowIsAvailable => { + f.write_str("Decoded TOW is available") + } + MsgTrackingStateDetailedDepTowStatus::PropagatedTowIsAvailable => { + f.write_str("Propagated TOW is available") + } + } + } +} + +/// FLL status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepFllStatus { + /// FLL is inactive + FllIsInactive = 0, + + /// FLL is active + FllIsActive = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepFllStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepFllStatus::FllIsInactive => f.write_str("FLL is inactive"), + MsgTrackingStateDetailedDepFllStatus::FllIsActive => f.write_str("FLL is active"), + } + } +} + +/// PLL status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepPllStatus { + /// PLL is inactive + PllIsInactive = 0, + + /// PLL is active + PllIsActive = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepPllStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepPllStatus::PllIsInactive => f.write_str("PLL is inactive"), + MsgTrackingStateDetailedDepPllStatus::PllIsActive => f.write_str("PLL is active"), + } + } +} + +/// Tracking loop status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepTrackingLoopStatus { + /// No locks + NoLocks = 0, + + /// FLL/DLL lock + FlldllLock = 1, + + /// PLL optimistic lock + PllOptimisticLock = 2, + + /// PLL pessimistic lock + PllPessimisticLock = 3, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepTrackingLoopStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepTrackingLoopStatus::NoLocks => f.write_str("No locks"), + MsgTrackingStateDetailedDepTrackingLoopStatus::FlldllLock => { + f.write_str("FLL/DLL lock") + } + MsgTrackingStateDetailedDepTrackingLoopStatus::PllOptimisticLock => { + f.write_str("PLL optimistic lock") + } + MsgTrackingStateDetailedDepTrackingLoopStatus::PllPessimisticLock => { + f.write_str("PLL pessimistic lock") + } + } + } +} + +/// Almanac availability status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepAlmanacAvailabilityStatus { + /// Almanac is not available + AlmanacIsNotAvailable = 0, + + /// Almanac is available + AlmanacIsAvailable = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepAlmanacAvailabilityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepAlmanacAvailabilityStatus::AlmanacIsNotAvailable => { + f.write_str("Almanac is not available") + } + MsgTrackingStateDetailedDepAlmanacAvailabilityStatus::AlmanacIsAvailable => { + f.write_str("Almanac is available") + } + } + } +} + +/// Ephemeris availability status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepEphemerisAvailabilityStatus { + /// Ephemeris is not available + EphemerisIsNotAvailable = 0, + + /// Ephemeris is available + EphemerisIsAvailable = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepEphemerisAvailabilityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepEphemerisAvailabilityStatus::EphemerisIsNotAvailable => { + f.write_str("Ephemeris is not available") + } + MsgTrackingStateDetailedDepEphemerisAvailabilityStatus::EphemerisIsAvailable => { + f.write_str("Ephemeris is available") + } + } + } +} + +/// Health status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepHealthStatus { + /// Health is unknown + HealthIsUnknown = 0, + + /// Signal is unhealthy + SignalIsUnhealthy = 1, + + /// Signal is healthy + SignalIsHealthy = 2, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepHealthStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepHealthStatus::HealthIsUnknown => { + f.write_str("Health is unknown") + } + MsgTrackingStateDetailedDepHealthStatus::SignalIsUnhealthy => { + f.write_str("Signal is unhealthy") + } + MsgTrackingStateDetailedDepHealthStatus::SignalIsHealthy => { + f.write_str("Signal is healthy") + } + } + } +} + +/// Parameter sets. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepParameterSets { + /// 1 ms integration time + _1MsIntegrationTime = 0, + + /// 5 ms integration time + _5MsIntegrationTime = 1, + + /// 10 ms integration time + _10MsIntegrationTime = 2, + + /// 20 ms integration time + _20MsIntegrationTime = 3, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepParameterSets { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepParameterSets::_1MsIntegrationTime => { + f.write_str("1 ms integration time") + } + MsgTrackingStateDetailedDepParameterSets::_5MsIntegrationTime => { + f.write_str("5 ms integration time") + } + MsgTrackingStateDetailedDepParameterSets::_10MsIntegrationTime => { + f.write_str("10 ms integration time") + } + MsgTrackingStateDetailedDepParameterSets::_20MsIntegrationTime => { + f.write_str("20 ms integration time") + } + } + } +} + +/// Clock validity status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepClockValidityStatus { + /// Clock offset and drift is not valid + ClockOffsetAndDriftIsNotValid = 0, + + /// Clock offset and drift is valid + ClockOffsetAndDriftIsValid = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepClockValidityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepClockValidityStatus::ClockOffsetAndDriftIsNotValid => { + f.write_str("Clock offset and drift is not valid") + } + MsgTrackingStateDetailedDepClockValidityStatus::ClockOffsetAndDriftIsValid => { + f.write_str("Clock offset and drift is valid") + } + } + } +} + +/// Pseudorange validity status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepPseudorangeValidityStatus { + /// Pseudorange is not valid + PseudorangeIsNotValid = 0, + + /// Pseudorange is valid + PseudorangeIsValid = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepPseudorangeValidityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepPseudorangeValidityStatus::PseudorangeIsNotValid => { + f.write_str("Pseudorange is not valid") + } + MsgTrackingStateDetailedDepPseudorangeValidityStatus::PseudorangeIsValid => { + f.write_str("Pseudorange is valid") + } + } + } +} + +/// Acceleration validity status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepAccelerationValidityStatus { + /// Acceleration is not valid + AccelerationIsNotValid = 0, + + /// Acceleration is valid + AccelerationIsValid = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepAccelerationValidityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepAccelerationValidityStatus::AccelerationIsNotValid => { + f.write_str("Acceleration is not valid") + } + MsgTrackingStateDetailedDepAccelerationValidityStatus::AccelerationIsValid => { + f.write_str("Acceleration is valid") + } + } + } +} + +/// Carrier half cycle ambiguity status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepCarrierHalfCycleAmbiguityStatus { + /// Unresolved + Unresolved = 0, + + /// Resolved + Resolved = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepCarrierHalfCycleAmbiguityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepCarrierHalfCycleAmbiguityStatus::Unresolved => { + f.write_str("Unresolved") + } + MsgTrackingStateDetailedDepCarrierHalfCycleAmbiguityStatus::Resolved => { + f.write_str("Resolved") + } + } + } +} + +/// Tracking channel status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepTrackingChannelStatus { + /// Re-acquisition + ReAcquisition = 0, + + /// Running + Running = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepTrackingChannelStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepTrackingChannelStatus::ReAcquisition => { + f.write_str("Re-acquisition") + } + MsgTrackingStateDetailedDepTrackingChannelStatus::Running => f.write_str("Running"), + } + } +} + /// Detailed signal tracking channel states. DEPRECATED /// /// The tracking message returns a set tracking channel parameters for a @@ -800,6 +1458,295 @@ pub struct MsgTrackingStateDetailedDepA { pub misc_flags: u8, } +impl MsgTrackingStateDetailedDepA { + pub fn synchronization_status( + &self, + ) -> Option { + match get_bit_range!( self.sync_flags, u8, u8, 2, 0 ) { + 0 => Some( MsgTrackingStateDetailedDepASynchronizationStatus :: NoSynchronization ), + 1 => Some( MsgTrackingStateDetailedDepASynchronizationStatus :: BitSynchronization ), + 2 => Some( MsgTrackingStateDetailedDepASynchronizationStatus :: WordSynchronization ), + 3 => Some( MsgTrackingStateDetailedDepASynchronizationStatus :: SubFrameSynchronizationMessageSynchronization ), + _ => None, + } + } + + pub fn set_synchronization_status( + &mut self, + synchronization_status: MsgTrackingStateDetailedDepASynchronizationStatus, + ) { + set_bit_range!(&mut self.sync_flags, synchronization_status, u8, u8, 2, 0); + } + + pub fn week_number_validity_status( + &self, + ) -> Option { + match get_bit_range!(self.tow_flags, u8, u8, 3, 0) { + 0 => Some(MsgTrackingStateDetailedDepAWeekNumberValidityStatus::WeekNumberIsNotValid), + 1 => Some(MsgTrackingStateDetailedDepAWeekNumberValidityStatus::WeekNumberIsValid), + _ => None, + } + } + + pub fn set_week_number_validity_status( + &mut self, + week_number_validity_status: MsgTrackingStateDetailedDepAWeekNumberValidityStatus, + ) { + set_bit_range!( + &mut self.tow_flags, + week_number_validity_status, + u8, + u8, + 3, + 0 + ); + } + + pub fn tow_status(&self) -> Option { + match get_bit_range!(self.tow_flags, u8, u8, 2, 0) { + 0 => Some(MsgTrackingStateDetailedDepATowStatus::TowIsNotAvailable), + 1 => Some(MsgTrackingStateDetailedDepATowStatus::DecodedTowIsAvailable), + 2 => Some(MsgTrackingStateDetailedDepATowStatus::PropagatedTowIsAvailable), + _ => None, + } + } + + pub fn set_tow_status(&mut self, tow_status: MsgTrackingStateDetailedDepATowStatus) { + set_bit_range!(&mut self.tow_flags, tow_status, u8, u8, 2, 0); + } + + pub fn fll_status(&self) -> Option { + match get_bit_range!(self.track_flags, u8, u8, 4, 0) { + 0 => Some(MsgTrackingStateDetailedDepAFllStatus::FllIsInactive), + 1 => Some(MsgTrackingStateDetailedDepAFllStatus::FllIsActive), + _ => None, + } + } + + pub fn set_fll_status(&mut self, fll_status: MsgTrackingStateDetailedDepAFllStatus) { + set_bit_range!(&mut self.track_flags, fll_status, u8, u8, 4, 0); + } + + pub fn pll_status(&self) -> Option { + match get_bit_range!(self.track_flags, u8, u8, 3, 0) { + 0 => Some(MsgTrackingStateDetailedDepAPllStatus::PllIsInactive), + 1 => Some(MsgTrackingStateDetailedDepAPllStatus::PllIsActive), + _ => None, + } + } + + pub fn set_pll_status(&mut self, pll_status: MsgTrackingStateDetailedDepAPllStatus) { + set_bit_range!(&mut self.track_flags, pll_status, u8, u8, 3, 0); + } + + pub fn tracking_loop_status(&self) -> Option { + match get_bit_range!(self.track_flags, u8, u8, 2, 0) { + 0 => Some(MsgTrackingStateDetailedDepATrackingLoopStatus::NoLocks), + 1 => Some(MsgTrackingStateDetailedDepATrackingLoopStatus::FlldllLock), + 2 => Some(MsgTrackingStateDetailedDepATrackingLoopStatus::PllOptimisticLock), + 3 => Some(MsgTrackingStateDetailedDepATrackingLoopStatus::PllPessimisticLock), + _ => None, + } + } + + pub fn set_tracking_loop_status( + &mut self, + tracking_loop_status: MsgTrackingStateDetailedDepATrackingLoopStatus, + ) { + set_bit_range!(&mut self.track_flags, tracking_loop_status, u8, u8, 2, 0); + } + + pub fn almanac_availability_status( + &self, + ) -> Option { + match get_bit_range!(self.nav_flags, u8, u8, 4, 0) { + 0 => Some(MsgTrackingStateDetailedDepAAlmanacAvailabilityStatus::AlmanacIsNotAvailable), + 1 => Some(MsgTrackingStateDetailedDepAAlmanacAvailabilityStatus::AlmanacIsAvailable), + _ => None, + } + } + + pub fn set_almanac_availability_status( + &mut self, + almanac_availability_status: MsgTrackingStateDetailedDepAAlmanacAvailabilityStatus, + ) { + set_bit_range!( + &mut self.nav_flags, + almanac_availability_status, + u8, + u8, + 4, + 0 + ); + } + + pub fn ephemeris_availability_status( + &self, + ) -> Option { + match get_bit_range!(self.nav_flags, u8, u8, 3, 0) { + 0 => Some( + MsgTrackingStateDetailedDepAEphemerisAvailabilityStatus::EphemerisIsNotAvailable, + ), + 1 => { + Some(MsgTrackingStateDetailedDepAEphemerisAvailabilityStatus::EphemerisIsAvailable) + } + _ => None, + } + } + + pub fn set_ephemeris_availability_status( + &mut self, + ephemeris_availability_status: MsgTrackingStateDetailedDepAEphemerisAvailabilityStatus, + ) { + set_bit_range!( + &mut self.nav_flags, + ephemeris_availability_status, + u8, + u8, + 3, + 0 + ); + } + + pub fn health_status(&self) -> Option { + match get_bit_range!(self.nav_flags, u8, u8, 2, 0) { + 0 => Some(MsgTrackingStateDetailedDepAHealthStatus::HealthIsUnknown), + 1 => Some(MsgTrackingStateDetailedDepAHealthStatus::SignalIsUnhealthy), + 2 => Some(MsgTrackingStateDetailedDepAHealthStatus::SignalIsHealthy), + _ => None, + } + } + + pub fn set_health_status(&mut self, health_status: MsgTrackingStateDetailedDepAHealthStatus) { + set_bit_range!(&mut self.nav_flags, health_status, u8, u8, 2, 0); + } + + pub fn parameter_sets(&self) -> Option { + match get_bit_range!(self.pset_flags, u8, u8, 2, 0) { + 0 => Some(MsgTrackingStateDetailedDepAParameterSets::_1MsIntegrationTime), + 1 => Some(MsgTrackingStateDetailedDepAParameterSets::_5MsIntegrationTime), + 2 => Some(MsgTrackingStateDetailedDepAParameterSets::_10MsIntegrationTime), + 3 => Some(MsgTrackingStateDetailedDepAParameterSets::_20MsIntegrationTime), + _ => None, + } + } + + pub fn set_parameter_sets( + &mut self, + parameter_sets: MsgTrackingStateDetailedDepAParameterSets, + ) { + set_bit_range!(&mut self.pset_flags, parameter_sets, u8, u8, 2, 0); + } + + pub fn clock_validity_status(&self) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 5, 0) { + 0 => { + Some(MsgTrackingStateDetailedDepAClockValidityStatus::ClockOffsetAndDriftIsNotValid) + } + 1 => Some(MsgTrackingStateDetailedDepAClockValidityStatus::ClockOffsetAndDriftIsValid), + _ => None, + } + } + + pub fn set_clock_validity_status( + &mut self, + clock_validity_status: MsgTrackingStateDetailedDepAClockValidityStatus, + ) { + set_bit_range!(&mut self.misc_flags, clock_validity_status, u8, u8, 5, 0); + } + + pub fn pseudorange_validity_status( + &self, + ) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 4, 0) { + 0 => Some(MsgTrackingStateDetailedDepAPseudorangeValidityStatus::PseudorangeIsNotValid), + 1 => Some(MsgTrackingStateDetailedDepAPseudorangeValidityStatus::PseudorangeIsValid), + _ => None, + } + } + + pub fn set_pseudorange_validity_status( + &mut self, + pseudorange_validity_status: MsgTrackingStateDetailedDepAPseudorangeValidityStatus, + ) { + set_bit_range!( + &mut self.misc_flags, + pseudorange_validity_status, + u8, + u8, + 4, + 0 + ); + } + + pub fn acceleration_validity_status( + &self, + ) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 3, 0) { + 0 => { + Some(MsgTrackingStateDetailedDepAAccelerationValidityStatus::AccelerationIsNotValid) + } + 1 => Some(MsgTrackingStateDetailedDepAAccelerationValidityStatus::AccelerationIsValid), + _ => None, + } + } + + pub fn set_acceleration_validity_status( + &mut self, + acceleration_validity_status: MsgTrackingStateDetailedDepAAccelerationValidityStatus, + ) { + set_bit_range!( + &mut self.misc_flags, + acceleration_validity_status, + u8, + u8, + 3, + 0 + ); + } + + pub fn carrier_half_cycle_ambiguity_status( + &self, + ) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 2, 0) { + 0 => Some(MsgTrackingStateDetailedDepACarrierHalfCycleAmbiguityStatus::Unresolved), + 1 => Some(MsgTrackingStateDetailedDepACarrierHalfCycleAmbiguityStatus::Resolved), + _ => None, + } + } + + pub fn set_carrier_half_cycle_ambiguity_status( + &mut self, + carrier_half_cycle_ambiguity_status: MsgTrackingStateDetailedDepACarrierHalfCycleAmbiguityStatus, + ) { + set_bit_range!( + &mut self.misc_flags, + carrier_half_cycle_ambiguity_status, + u8, + u8, + 2, + 0 + ); + } + + pub fn tracking_channel_status( + &self, + ) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 1, 0) { + 0 => Some(MsgTrackingStateDetailedDepATrackingChannelStatus::ReAcquisition), + 1 => Some(MsgTrackingStateDetailedDepATrackingChannelStatus::Running), + _ => None, + } + } + + pub fn set_tracking_channel_status( + &mut self, + tracking_channel_status: MsgTrackingStateDetailedDepATrackingChannelStatus, + ) { + set_bit_range!(&mut self.misc_flags, tracking_channel_status, u8, u8, 1, 0); + } +} + impl ConcreteMessage for MsgTrackingStateDetailedDepA { const MESSAGE_TYPE: u16 = 33; const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE_DETAILED_DEP_A"; @@ -929,6 +1876,380 @@ impl WireFormat for MsgTrackingStateDetailedDepA { } } +/// Synchronization status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepASynchronizationStatus { + /// No synchronization + NoSynchronization = 0, + + /// Bit synchronization + BitSynchronization = 1, + + /// Word synchronization (L1 C/A only) + WordSynchronization = 2, + + /// Sub-frame synchronization (L1 C/A) / message synchronization (L2C) + SubFrameSynchronizationMessageSynchronization = 3, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepASynchronizationStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepASynchronizationStatus::NoSynchronization => f.write_str("No synchronization"), + MsgTrackingStateDetailedDepASynchronizationStatus::BitSynchronization => f.write_str("Bit synchronization"), + MsgTrackingStateDetailedDepASynchronizationStatus::WordSynchronization => f.write_str("Word synchronization (L1 C/A only)"), + MsgTrackingStateDetailedDepASynchronizationStatus::SubFrameSynchronizationMessageSynchronization => f.write_str("Sub-frame synchronization (L1 C/A) / message synchronization (L2C) +"), + } + } +} + +/// Week number validity status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepAWeekNumberValidityStatus { + /// Week number is not valid + WeekNumberIsNotValid = 0, + + /// Week number is valid + WeekNumberIsValid = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepAWeekNumberValidityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepAWeekNumberValidityStatus::WeekNumberIsNotValid => { + f.write_str("Week number is not valid") + } + MsgTrackingStateDetailedDepAWeekNumberValidityStatus::WeekNumberIsValid => { + f.write_str("Week number is valid") + } + } + } +} + +/// TOW status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepATowStatus { + /// TOW is not available + TowIsNotAvailable = 0, + + /// Decoded TOW is available + DecodedTowIsAvailable = 1, + + /// Propagated TOW is available + PropagatedTowIsAvailable = 2, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepATowStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepATowStatus::TowIsNotAvailable => { + f.write_str("TOW is not available") + } + MsgTrackingStateDetailedDepATowStatus::DecodedTowIsAvailable => { + f.write_str("Decoded TOW is available") + } + MsgTrackingStateDetailedDepATowStatus::PropagatedTowIsAvailable => { + f.write_str("Propagated TOW is available") + } + } + } +} + +/// FLL status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepAFllStatus { + /// FLL is inactive + FllIsInactive = 0, + + /// FLL is active + FllIsActive = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepAFllStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepAFllStatus::FllIsInactive => f.write_str("FLL is inactive"), + MsgTrackingStateDetailedDepAFllStatus::FllIsActive => f.write_str("FLL is active"), + } + } +} + +/// PLL status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepAPllStatus { + /// PLL is inactive + PllIsInactive = 0, + + /// PLL is active + PllIsActive = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepAPllStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepAPllStatus::PllIsInactive => f.write_str("PLL is inactive"), + MsgTrackingStateDetailedDepAPllStatus::PllIsActive => f.write_str("PLL is active"), + } + } +} + +/// Tracking loop status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepATrackingLoopStatus { + /// No locks + NoLocks = 0, + + /// FLL/DLL lock + FlldllLock = 1, + + /// PLL optimistic lock + PllOptimisticLock = 2, + + /// PLL pessimistic lock + PllPessimisticLock = 3, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepATrackingLoopStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepATrackingLoopStatus::NoLocks => f.write_str("No locks"), + MsgTrackingStateDetailedDepATrackingLoopStatus::FlldllLock => { + f.write_str("FLL/DLL lock") + } + MsgTrackingStateDetailedDepATrackingLoopStatus::PllOptimisticLock => { + f.write_str("PLL optimistic lock") + } + MsgTrackingStateDetailedDepATrackingLoopStatus::PllPessimisticLock => { + f.write_str("PLL pessimistic lock") + } + } + } +} + +/// Almanac availability status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepAAlmanacAvailabilityStatus { + /// Almanac is not available + AlmanacIsNotAvailable = 0, + + /// Almanac is available + AlmanacIsAvailable = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepAAlmanacAvailabilityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepAAlmanacAvailabilityStatus::AlmanacIsNotAvailable => { + f.write_str("Almanac is not available") + } + MsgTrackingStateDetailedDepAAlmanacAvailabilityStatus::AlmanacIsAvailable => { + f.write_str("Almanac is available") + } + } + } +} + +/// Ephemeris availability status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepAEphemerisAvailabilityStatus { + /// Ephemeris is not available + EphemerisIsNotAvailable = 0, + + /// Ephemeris is available + EphemerisIsAvailable = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepAEphemerisAvailabilityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepAEphemerisAvailabilityStatus::EphemerisIsNotAvailable => { + f.write_str("Ephemeris is not available") + } + MsgTrackingStateDetailedDepAEphemerisAvailabilityStatus::EphemerisIsAvailable => { + f.write_str("Ephemeris is available") + } + } + } +} + +/// Health status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepAHealthStatus { + /// Health is unknown + HealthIsUnknown = 0, + + /// Signal is unhealthy + SignalIsUnhealthy = 1, + + /// Signal is healthy + SignalIsHealthy = 2, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepAHealthStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepAHealthStatus::HealthIsUnknown => { + f.write_str("Health is unknown") + } + MsgTrackingStateDetailedDepAHealthStatus::SignalIsUnhealthy => { + f.write_str("Signal is unhealthy") + } + MsgTrackingStateDetailedDepAHealthStatus::SignalIsHealthy => { + f.write_str("Signal is healthy") + } + } + } +} + +/// Parameter sets. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepAParameterSets { + /// 1 ms integration time + _1MsIntegrationTime = 0, + + /// 5 ms integration time + _5MsIntegrationTime = 1, + + /// 10 ms integration time + _10MsIntegrationTime = 2, + + /// 20 ms integration time + _20MsIntegrationTime = 3, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepAParameterSets { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepAParameterSets::_1MsIntegrationTime => { + f.write_str("1 ms integration time") + } + MsgTrackingStateDetailedDepAParameterSets::_5MsIntegrationTime => { + f.write_str("5 ms integration time") + } + MsgTrackingStateDetailedDepAParameterSets::_10MsIntegrationTime => { + f.write_str("10 ms integration time") + } + MsgTrackingStateDetailedDepAParameterSets::_20MsIntegrationTime => { + f.write_str("20 ms integration time") + } + } + } +} + +/// Clock validity status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepAClockValidityStatus { + /// Clock offset and drift is not valid + ClockOffsetAndDriftIsNotValid = 0, + + /// Clock offset and drift is valid + ClockOffsetAndDriftIsValid = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepAClockValidityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepAClockValidityStatus::ClockOffsetAndDriftIsNotValid => { + f.write_str("Clock offset and drift is not valid") + } + MsgTrackingStateDetailedDepAClockValidityStatus::ClockOffsetAndDriftIsValid => { + f.write_str("Clock offset and drift is valid") + } + } + } +} + +/// Pseudorange validity status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepAPseudorangeValidityStatus { + /// Pseudorange is not valid + PseudorangeIsNotValid = 0, + + /// Pseudorange is valid + PseudorangeIsValid = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepAPseudorangeValidityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepAPseudorangeValidityStatus::PseudorangeIsNotValid => { + f.write_str("Pseudorange is not valid") + } + MsgTrackingStateDetailedDepAPseudorangeValidityStatus::PseudorangeIsValid => { + f.write_str("Pseudorange is valid") + } + } + } +} + +/// Acceleration validity status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepAAccelerationValidityStatus { + /// Acceleration is not valid + AccelerationIsNotValid = 0, + + /// Acceleration is valid + AccelerationIsValid = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepAAccelerationValidityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepAAccelerationValidityStatus::AccelerationIsNotValid => { + f.write_str("Acceleration is not valid") + } + MsgTrackingStateDetailedDepAAccelerationValidityStatus::AccelerationIsValid => { + f.write_str("Acceleration is valid") + } + } + } +} + +/// Carrier half cycle ambiguity status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepACarrierHalfCycleAmbiguityStatus { + /// Unresolved + Unresolved = 0, + + /// Resolved + Resolved = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepACarrierHalfCycleAmbiguityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepACarrierHalfCycleAmbiguityStatus::Unresolved => { + f.write_str("Unresolved") + } + MsgTrackingStateDetailedDepACarrierHalfCycleAmbiguityStatus::Resolved => { + f.write_str("Resolved") + } + } + } +} + +/// Tracking channel status. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgTrackingStateDetailedDepATrackingChannelStatus { + /// Re-acquisition + ReAcquisition = 0, + + /// Running + Running = 1, +} + +impl std::fmt::Display for MsgTrackingStateDetailedDepATrackingChannelStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgTrackingStateDetailedDepATrackingChannelStatus::ReAcquisition => { + f.write_str("Re-acquisition") + } + MsgTrackingStateDetailedDepATrackingChannelStatus::Running => f.write_str("Running"), + } + } +} + /// Measurement Engine signal tracking channel state /// /// Measurement Engine tracking channel state for a specific satellite signal @@ -1087,6 +2408,20 @@ pub struct TrackingChannelStateDepA { pub cn0: f32, } +impl TrackingChannelStateDepA { + pub fn tracking_mode(&self) -> Option { + match get_bit_range!(self.state, u8, u8, 1, 0) { + 0 => Some(TrackingChannelStateDepATrackingMode::Disabled), + 1 => Some(TrackingChannelStateDepATrackingMode::Running), + _ => None, + } + } + + pub fn set_tracking_mode(&mut self, tracking_mode: TrackingChannelStateDepATrackingMode) { + set_bit_range!(&mut self.state, tracking_mode, u8, u8, 1, 0); + } +} + impl WireFormat for TrackingChannelStateDepA { const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN + ::MIN_LEN; @@ -1107,6 +2442,25 @@ impl WireFormat for TrackingChannelStateDepA { } } +/// Tracking mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum TrackingChannelStateDepATrackingMode { + /// Disabled + Disabled = 0, + + /// Running + Running = 1, +} + +impl std::fmt::Display for TrackingChannelStateDepATrackingMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TrackingChannelStateDepATrackingMode::Disabled => f.write_str("Disabled"), + TrackingChannelStateDepATrackingMode::Running => f.write_str("Running"), + } + } +} + /// Deprecated /// /// Deprecated. @@ -1125,6 +2479,20 @@ pub struct TrackingChannelStateDepB { pub cn0: f32, } +impl TrackingChannelStateDepB { + pub fn tracking_mode(&self) -> Option { + match get_bit_range!(self.state, u8, u8, 1, 0) { + 0 => Some(TrackingChannelStateDepBTrackingMode::Disabled), + 1 => Some(TrackingChannelStateDepBTrackingMode::Running), + _ => None, + } + } + + pub fn set_tracking_mode(&mut self, tracking_mode: TrackingChannelStateDepBTrackingMode) { + set_bit_range!(&mut self.state, tracking_mode, u8, u8, 1, 0); + } +} + impl WireFormat for TrackingChannelStateDepB { const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN @@ -1145,3 +2513,22 @@ impl WireFormat for TrackingChannelStateDepB { } } } + +/// Tracking mode +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum TrackingChannelStateDepBTrackingMode { + /// Disabled + Disabled = 0, + + /// Running + Running = 1, +} + +impl std::fmt::Display for TrackingChannelStateDepBTrackingMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TrackingChannelStateDepBTrackingMode::Disabled => f.write_str("Disabled"), + TrackingChannelStateDepBTrackingMode::Running => f.write_str("Running"), + } + } +} diff --git a/rust/sbp/src/messages/vehicle.rs b/rust/sbp/src/messages/vehicle.rs index 3ab5628a51..13ee68f584 100644 --- a/rust/sbp/src/messages/vehicle.rs +++ b/rust/sbp/src/messages/vehicle.rs @@ -47,6 +47,49 @@ pub struct MsgOdometry { pub flags: u8, } +impl MsgOdometry { + pub fn vehicle_metadata(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 6, 5) { + 0 => Some(MsgOdometryVehicleMetadata::Unavailable), + 1 => Some(MsgOdometryVehicleMetadata::Forward), + 2 => Some(MsgOdometryVehicleMetadata::Reverse), + 3 => Some(MsgOdometryVehicleMetadata::Park), + _ => None, + } + } + + pub fn set_vehicle_metadata(&mut self, vehicle_metadata: MsgOdometryVehicleMetadata) { + set_bit_range!(&mut self.flags, vehicle_metadata, u8, u8, 6, 5); + } + + pub fn velocity_source(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(MsgOdometryVelocitySource::Source0), + 1 => Some(MsgOdometryVelocitySource::Source1), + 2 => Some(MsgOdometryVelocitySource::Source2), + 3 => Some(MsgOdometryVelocitySource::Source3), + _ => None, + } + } + + pub fn set_velocity_source(&mut self, velocity_source: MsgOdometryVelocitySource) { + set_bit_range!(&mut self.flags, velocity_source, u8, u8, 4, 3); + } + + pub fn time_source(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(MsgOdometryTimeSource::None), + 1 => Some(MsgOdometryTimeSource::GpsSolution), + 2 => Some(MsgOdometryTimeSource::ProcessorTime), + _ => None, + } + } + + pub fn set_time_source(&mut self, time_source: MsgOdometryTimeSource) { + set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); + } +} + impl ConcreteMessage for MsgOdometry { const MESSAGE_TYPE: u16 = 2307; const MESSAGE_NAME: &'static str = "MSG_ODOMETRY"; @@ -110,6 +153,83 @@ impl WireFormat for MsgOdometry { } } +/// Vehicle Metadata +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgOdometryVehicleMetadata { + /// Unavailable + Unavailable = 0, + + /// Forward + Forward = 1, + + /// Reverse + Reverse = 2, + + /// Park + Park = 3, +} + +impl std::fmt::Display for MsgOdometryVehicleMetadata { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgOdometryVehicleMetadata::Unavailable => f.write_str("Unavailable"), + MsgOdometryVehicleMetadata::Forward => f.write_str("Forward"), + MsgOdometryVehicleMetadata::Reverse => f.write_str("Reverse"), + MsgOdometryVehicleMetadata::Park => f.write_str("Park"), + } + } +} + +/// Velocity Source +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgOdometryVelocitySource { + /// Source 0 + Source0 = 0, + + /// Source 1 + Source1 = 1, + + /// Source 2 + Source2 = 2, + + /// Source 3 + Source3 = 3, +} + +impl std::fmt::Display for MsgOdometryVelocitySource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgOdometryVelocitySource::Source0 => f.write_str("Source 0"), + MsgOdometryVelocitySource::Source1 => f.write_str("Source 1"), + MsgOdometryVelocitySource::Source2 => f.write_str("Source 2"), + MsgOdometryVelocitySource::Source3 => f.write_str("Source 3"), + } + } +} + +/// Time source +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgOdometryTimeSource { + /// None (invalid) + None = 0, + + /// GPS Solution (ms in week) + GpsSolution = 1, + + /// Processor Time + ProcessorTime = 2, +} + +impl std::fmt::Display for MsgOdometryTimeSource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgOdometryTimeSource::None => f.write_str("None (invalid)"), + MsgOdometryTimeSource::GpsSolution => f.write_str("GPS Solution (ms in week)"), + MsgOdometryTimeSource::ProcessorTime => f.write_str("Processor Time"), + } + } +} + /// Accumulated wheeltick count message /// /// Message containing the accumulated distance travelled by a wheel located @@ -149,6 +269,38 @@ pub struct MsgWheeltick { pub ticks: i32, } +impl MsgWheeltick { + pub fn vehicle_metadata(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 2) { + 0 => Some(MsgWheeltickVehicleMetadata::Unavailable), + 1 => Some(MsgWheeltickVehicleMetadata::Forward), + 2 => Some(MsgWheeltickVehicleMetadata::Reverse), + 3 => Some(MsgWheeltickVehicleMetadata::Park), + _ => None, + } + } + + pub fn set_vehicle_metadata(&mut self, vehicle_metadata: MsgWheeltickVehicleMetadata) { + set_bit_range!(&mut self.flags, vehicle_metadata, u8, u8, 3, 2); + } + + pub fn synchronization_type(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 1, 0) { + 0 => Some(MsgWheeltickSynchronizationType::MicrosecondsSinceLastPps), + 1 => Some(MsgWheeltickSynchronizationType::MicrosecondsInGpsWeek), + 2 => Some(MsgWheeltickSynchronizationType::LocalCpuTimeInNominalMicroseconds), + _ => None, + } + } + + pub fn set_synchronization_type( + &mut self, + synchronization_type: MsgWheeltickSynchronizationType, + ) { + set_bit_range!(&mut self.flags, synchronization_type, u8, u8, 1, 0); + } +} + impl ConcreteMessage for MsgWheeltick { const MESSAGE_TYPE: u16 = 2308; const MESSAGE_NAME: &'static str = "MSG_WHEELTICK"; @@ -222,3 +374,59 @@ impl WireFormat for MsgWheeltick { } } } + +/// Vehicle Metadata +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgWheeltickVehicleMetadata { + /// Unavailable + Unavailable = 0, + + /// Forward + Forward = 1, + + /// Reverse + Reverse = 2, + + /// Park + Park = 3, +} + +impl std::fmt::Display for MsgWheeltickVehicleMetadata { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgWheeltickVehicleMetadata::Unavailable => f.write_str("Unavailable"), + MsgWheeltickVehicleMetadata::Forward => f.write_str("Forward"), + MsgWheeltickVehicleMetadata::Reverse => f.write_str("Reverse"), + MsgWheeltickVehicleMetadata::Park => f.write_str("Park"), + } + } +} + +/// Synchronization type +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum MsgWheeltickSynchronizationType { + /// microseconds since last PPS + MicrosecondsSinceLastPps = 0, + + /// microseconds in GPS week + MicrosecondsInGpsWeek = 1, + + /// local CPU time in nominal microseconds + LocalCpuTimeInNominalMicroseconds = 2, +} + +impl std::fmt::Display for MsgWheeltickSynchronizationType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MsgWheeltickSynchronizationType::MicrosecondsSinceLastPps => { + f.write_str("microseconds since last PPS") + } + MsgWheeltickSynchronizationType::MicrosecondsInGpsWeek => { + f.write_str("microseconds in GPS week") + } + MsgWheeltickSynchronizationType::LocalCpuTimeInNominalMicroseconds => { + f.write_str("local CPU time in nominal microseconds") + } + } + } +} From 3c4574848bd0a0d1d5cc6578bcc8e5d19a371bc1 Mon Sep 17 00:00:00 2001 From: Steve Meyer Date: Mon, 27 Dec 2021 14:31:01 -0800 Subject: [PATCH 02/13] remove print --- generator/sbpg/targets/rust.py | 1 - 1 file changed, 1 deletion(-) diff --git a/generator/sbpg/targets/rust.py b/generator/sbpg/targets/rust.py index 2a3ae0f940..8ca2597a7b 100644 --- a/generator/sbpg/targets/rust.py +++ b/generator/sbpg/targets/rust.py @@ -300,7 +300,6 @@ def get_bitfield(field, msg): else: msb = bitrange[1] lsb = bitrange[0] - print(field_name, type_name, calc_item_size(item, field)) items.append( { "desc": item.get("desc"), From 1b558486385730b9e0320b9a94f212c0834daa8b Mon Sep 17 00:00:00 2001 From: Steve Meyer Date: Mon, 27 Dec 2021 14:48:59 -0800 Subject: [PATCH 03/13] cleanup --- .../targets/resources/rust/sbp_messages_mod.rs | 14 +++++++------- rust/sbp/src/messages/mod.rs | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs b/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs index 94a55debce..d4715d4241 100644 --- a/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs +++ b/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs @@ -39,20 +39,20 @@ mod lib { macro_rules! get_bit_range { ($bitrange:expr, $source_ty:ty, $target_ty:ty, $msb:expr, $lsb:expr) => {{ - let bit_len = std::mem::size_of::<$source_ty>() * 8; - let result_bit_len = std::mem::size_of::<$target_ty>() * 8; + let source_bit_len = std::mem::size_of::<$source_ty>() * 8; + let target_bit_len = std::mem::size_of::<$target_ty>() * 8; let result = - (($bitrange << (bit_len - $msb - 1)) >> (bit_len - $msb - 1 + $lsb)) as $target_ty; - result << (result_bit_len - ($msb - $lsb + 1)) >> (result_bit_len - ($msb - $lsb + 1)) + (($bitrange << (source_bit_len - $msb - 1)) >> (source_bit_len - $msb - 1 + $lsb)) as $target_ty; + result << (target_bit_len - ($msb - $lsb + 1)) >> (target_bit_len - ($msb - $lsb + 1)) }}; } macro_rules! set_bit_range { ($bitrange:expr, $value: expr, $source_ty:ty, $target_ty:ty, $msb:expr, $lsb:expr) => { - let bit_len = std::mem::size_of::<$source_ty>() * 8; + let source_bit_len = std::mem::size_of::<$source_ty>() * 8; let mask: $source_ty = !(0 as $source_ty) - << (bit_len - $msb - 1) - >> (bit_len - $msb - 1 + $lsb) + << (source_bit_len - $msb - 1) + >> (source_bit_len - $msb - 1 + $lsb) << ($lsb); *$bitrange &= !mask; *$bitrange |= ($value as $source_ty << $lsb) & mask; diff --git a/rust/sbp/src/messages/mod.rs b/rust/sbp/src/messages/mod.rs index b93d49c791..b48720fb7f 100644 --- a/rust/sbp/src/messages/mod.rs +++ b/rust/sbp/src/messages/mod.rs @@ -256,20 +256,20 @@ mod lib { macro_rules! get_bit_range { ($bitrange:expr, $source_ty:ty, $target_ty:ty, $msb:expr, $lsb:expr) => {{ - let bit_len = std::mem::size_of::<$source_ty>() * 8; - let result_bit_len = std::mem::size_of::<$target_ty>() * 8; - let result = - (($bitrange << (bit_len - $msb - 1)) >> (bit_len - $msb - 1 + $lsb)) as $target_ty; - result << (result_bit_len - ($msb - $lsb + 1)) >> (result_bit_len - ($msb - $lsb + 1)) + let source_bit_len = std::mem::size_of::<$source_ty>() * 8; + let target_bit_len = std::mem::size_of::<$target_ty>() * 8; + let result = (($bitrange << (source_bit_len - $msb - 1)) + >> (source_bit_len - $msb - 1 + $lsb)) as $target_ty; + result << (target_bit_len - ($msb - $lsb + 1)) >> (target_bit_len - ($msb - $lsb + 1)) }}; } macro_rules! set_bit_range { ($bitrange:expr, $value: expr, $source_ty:ty, $target_ty:ty, $msb:expr, $lsb:expr) => { - let bit_len = std::mem::size_of::<$source_ty>() * 8; + let source_bit_len = std::mem::size_of::<$source_ty>() * 8; let mask: $source_ty = !(0 as $source_ty) - << (bit_len - $msb - 1) - >> (bit_len - $msb - 1 + $lsb) + << (source_bit_len - $msb - 1) + >> (source_bit_len - $msb - 1 + $lsb) << ($lsb); *$bitrange &= !mask; *$bitrange |= ($value as $source_ty << $lsb) & mask; From 9f54d39a7ce749b2ce6bf3e80308ea3ee1fe1dff Mon Sep 17 00:00:00 2001 From: Steve Meyer Date: Thu, 6 Jan 2022 16:31:45 -0800 Subject: [PATCH 04/13] one module per message --- .../resources/rust/sbp_messages_mod.rs | 2 +- .../resources/rust/sbp_messages_template.rs | 20 +- generator/sbpg/targets/rust.py | 16 +- rust/sbp/src/messages/acquisition.rs | 1308 +- rust/sbp/src/messages/bootload.rs | 766 +- rust/sbp/src/messages/ext_events.rs | 302 +- rust/sbp/src/messages/file_io.rs | 1288 +- rust/sbp/src/messages/flash.rs | 1560 +- rust/sbp/src/messages/gnss.rs | 692 +- rust/sbp/src/messages/imu.rs | 693 +- rust/sbp/src/messages/linux.rs | 2188 +-- rust/sbp/src/messages/logging.rs | 488 +- rust/sbp/src/messages/mag.rs | 188 +- rust/sbp/src/messages/mod.rs | 6 +- rust/sbp/src/messages/navigation.rs | 14114 ++++++++-------- rust/sbp/src/messages/ndb.rs | 561 +- rust/sbp/src/messages/observation.rs | 12604 +++++++------- rust/sbp/src/messages/orientation.rs | 1112 +- rust/sbp/src/messages/piksi.rs | 4622 ++--- rust/sbp/src/messages/sbas.rs | 177 +- rust/sbp/src/messages/settings.rs | 1453 +- rust/sbp/src/messages/solution_meta.rs | 1502 +- rust/sbp/src/messages/ssr.rs | 3851 +++-- rust/sbp/src/messages/system.rs | 3492 ++-- rust/sbp/src/messages/tracking.rs | 4197 ++--- rust/sbp/src/messages/user.rs | 114 +- rust/sbp/src/messages/vehicle.rs | 704 +- 27 files changed, 29981 insertions(+), 28039 deletions(-) diff --git a/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs b/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs index d4715d4241..66cbbb30ab 100644 --- a/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs +++ b/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs @@ -16,7 +16,7 @@ pub mod unknown; ((*- for m in msgs *)) ((*- if m.is_real_message *)) -use self::(((m.mod_name)))::(((m.msg_name))); +use self::(((m.parent_mod_name)))::(((m.mod_name)))::(((m.msg_name))); ((*- endif *)) ((*- endfor *)) use self::unknown::Unknown; diff --git a/generator/sbpg/targets/resources/rust/sbp_messages_template.rs b/generator/sbpg/targets/resources/rust/sbp_messages_template.rs index d69edccd1f..cb4b22d297 100644 --- a/generator/sbpg/targets/resources/rust/sbp_messages_template.rs +++ b/generator/sbpg/targets/resources/rust/sbp_messages_template.rs @@ -15,15 +15,25 @@ //! (((description | commentify(prefix="//! ") ))) -((* for i in includes *)) -use super::(((i)))::*; -((* endfor *)) -use super::lib::*; +((*- for m in msgs *)) +pub use (((m.mod_name)))::(((m.msg_name))); +((*- endfor *)) + + ((* for m in msgs *)) +pub mod (((m.mod_name))) { +#![allow(unused_imports)] + +use super::*; +use crate::messages::lib::*; +((*- for i in includes *)) +use crate::messages::(((i)))::*; +((*- endfor *)) ((*- if m.desc *)) + /// (((m.short_desc))) /// /// (((m.desc | commentify))) @@ -189,4 +199,6 @@ impl std::fmt::Display for (((b.type_name))) { ((* endfor *)) ((* endif *)) +} + ((* endfor *)) diff --git a/generator/sbpg/targets/rust.py b/generator/sbpg/targets/rust.py index 8ca2597a7b..12fd53fd6f 100644 --- a/generator/sbpg/targets/rust.py +++ b/generator/sbpg/targets/rust.py @@ -91,6 +91,8 @@ def camel_case(s): Makes a classname. """ if "_" not in s: + if s[0].islower(): + s = s[0].upper() + s[1:] return lower_acronyms(s) s = re.sub("([a-z])([A-Z])", r"\1_\2", s) return "".join(w.title() for w in s.split("_")) @@ -238,13 +240,12 @@ def gen_ret(): """.strip() -def get_bitfield_basename(item, field, msg): - msg_name = camel_case(msg.identifier) +def get_bitfield_basename(item, field): if item.get("desc", False): basename = camel_case(item.get("desc", "").replace(" ", "_")) else: basename = camel_case(field.identifier) - basename = re.sub("[^A-Za-z0-9_]+", "", msg_name + basename) + basename = re.sub("[^A-Za-z0-9_]+", "", basename) return basename @@ -278,10 +279,10 @@ def get_bitfield_values(item): return vals -def get_bitfield(field, msg): +def get_bitfield(field): items = [] for item in field.options["fields"].value: - type_name = get_bitfield_basename(item, field, msg) + type_name = get_bitfield_basename(item, field) if type_name.endswith("Reserved"): continue vals = get_bitfield_values(item) @@ -333,13 +334,14 @@ def __init__(self, msg, package_specs, field): self.has_gps_time = True self.bitfield = [] if self.options.get("fields", False): - self.bitfield = get_bitfield(self, msg) + self.bitfield = get_bitfield(self) class MsgItem(object): def __init__(self, msg, package, package_specs): self.msg_name = camel_case(msg.identifier) - self.mod_name = package.mod_name + self.parent_mod_name = package.mod_name + self.mod_name = snake_case(msg.identifier) self.identifier = msg.identifier self.sbp_id = msg.sbp_id self.desc = msg.desc diff --git a/rust/sbp/src/messages/acquisition.rs b/rust/sbp/src/messages/acquisition.rs index 7745bf5605..1f3457bb5c 100644 --- a/rust/sbp/src/messages/acquisition.rs +++ b/rust/sbp/src/messages/acquisition.rs @@ -13,692 +13,760 @@ // with generate.py. Please do not hand edit! //****************************************************************************/ //! Satellite acquisition messages from the device. - -use super::gnss::*; - -use super::lib::*; - -/// Acq perfomance measurement and debug -/// -/// Profile for a specific SV for debugging purposes. The message describes SV -/// profile during acquisition time. The message is used to debug and measure -/// the performance. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 WireFormat for AcqSvProfile { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.job_type) - + WireFormat::len(&self.status) - + WireFormat::len(&self.cn0) - + WireFormat::len(&self.int_time) - + WireFormat::len(&self.sid) - + WireFormat::len(&self.bin_width) - + WireFormat::len(&self.timestamp) - + WireFormat::len(&self.time_spent) - + WireFormat::len(&self.cf_min) - + WireFormat::len(&self.cf_max) - + WireFormat::len(&self.cf) - + WireFormat::len(&self.cp) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), +pub use acq_sv_profile::AcqSvProfile; +pub use acq_sv_profile_dep::AcqSvProfileDep; +pub use msg_acq_result::MsgAcqResult; +pub use msg_acq_result_dep_a::MsgAcqResultDepA; +pub use msg_acq_result_dep_b::MsgAcqResultDepB; +pub use msg_acq_result_dep_c::MsgAcqResultDepC; +pub use msg_acq_sv_profile::MsgAcqSvProfile; +pub use msg_acq_sv_profile_dep::MsgAcqSvProfileDep; + +pub mod acq_sv_profile { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Acq perfomance measurement and debug + /// + /// Profile for a specific SV for debugging purposes. The message describes SV + /// profile during acquisition time. The message is used to debug and measure + /// the performance. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 WireFormat for AcqSvProfile { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.job_type) + + WireFormat::len(&self.status) + + WireFormat::len(&self.cn0) + + WireFormat::len(&self.int_time) + + WireFormat::len(&self.sid) + + WireFormat::len(&self.bin_width) + + WireFormat::len(&self.timestamp) + + WireFormat::len(&self.time_spent) + + WireFormat::len(&self.cf_min) + + WireFormat::len(&self.cf_max) + + WireFormat::len(&self.cf) + + WireFormat::len(&self.cp) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 WireFormat for AcqSvProfileDep { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.job_type) - + WireFormat::len(&self.status) - + WireFormat::len(&self.cn0) - + WireFormat::len(&self.int_time) - + WireFormat::len(&self.sid) - + WireFormat::len(&self.bin_width) - + WireFormat::len(&self.timestamp) - + WireFormat::len(&self.time_spent) - + WireFormat::len(&self.cf_min) - + WireFormat::len(&self.cf_max) - + WireFormat::len(&self.cf) - + WireFormat::len(&self.cp) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), +pub mod acq_sv_profile_dep { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Deprecated + /// + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 WireFormat for AcqSvProfileDep { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.job_type) + + WireFormat::len(&self.status) + + WireFormat::len(&self.cn0) + + WireFormat::len(&self.int_time) + + WireFormat::len(&self.sid) + + WireFormat::len(&self.bin_width) + + WireFormat::len(&self.timestamp) + + WireFormat::len(&self.time_spent) + + WireFormat::len(&self.cf_min) + + WireFormat::len(&self.cf_max) + + WireFormat::len(&self.cf) + + WireFormat::len(&self.cp) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Satellite acquisition result -/// -/// This message describes the results from an attempted GPS signal -/// acquisition search for a satellite PRN over a code phase/carrier frequency -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgAcqResult { - /// 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 ConcreteMessage for MsgAcqResult { - const MESSAGE_TYPE: u16 = 47; - const MESSAGE_NAME: &'static str = "MSG_ACQ_RESULT"; -} - -impl SbpMessage for MsgAcqResult { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_acq_result { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Satellite acquisition result + /// + /// This message describes the results from an attempted GPS signal + /// acquisition search for a satellite PRN over a code phase/carrier frequency + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgAcqResult { + /// 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 ConcreteMessage for MsgAcqResult { + const MESSAGE_TYPE: u16 = 47; + const MESSAGE_NAME: &'static str = "MSG_ACQ_RESULT"; + } + + impl SbpMessage for MsgAcqResult { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgAcqResult { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgAcqResult(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgAcqResult { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgAcqResult(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgAcqResult { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.cn0) - + WireFormat::len(&self.cp) - + WireFormat::len(&self.cf) - + WireFormat::len(&self.sid) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgAcqResult { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.cn0) + + WireFormat::len(&self.cp) + + WireFormat::len(&self.cf) + + WireFormat::len(&self.sid) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgAcqResultDepA { - /// 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 ConcreteMessage for MsgAcqResultDepA { - const MESSAGE_TYPE: u16 = 21; - const MESSAGE_NAME: &'static str = "MSG_ACQ_RESULT_DEP_A"; -} - -impl SbpMessage for MsgAcqResultDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_acq_result_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Deprecated + /// + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgAcqResultDepA { + /// 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 ConcreteMessage for MsgAcqResultDepA { + const MESSAGE_TYPE: u16 = 21; + const MESSAGE_NAME: &'static str = "MSG_ACQ_RESULT_DEP_A"; + } + + impl SbpMessage for MsgAcqResultDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgAcqResultDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgAcqResultDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgAcqResultDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgAcqResultDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgAcqResultDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.snr) - + WireFormat::len(&self.cp) - + WireFormat::len(&self.cf) - + WireFormat::len(&self.prn) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgAcqResultDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.snr) + + WireFormat::len(&self.cp) + + WireFormat::len(&self.cf) + + WireFormat::len(&self.prn) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgAcqResultDepB { - /// 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 ConcreteMessage for MsgAcqResultDepB { - const MESSAGE_TYPE: u16 = 20; - const MESSAGE_NAME: &'static str = "MSG_ACQ_RESULT_DEP_B"; -} - -impl SbpMessage for MsgAcqResultDepB { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_acq_result_dep_b { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Deprecated + /// + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgAcqResultDepB { + /// 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 ConcreteMessage for MsgAcqResultDepB { + const MESSAGE_TYPE: u16 = 20; + const MESSAGE_NAME: &'static str = "MSG_ACQ_RESULT_DEP_B"; + } + + impl SbpMessage for MsgAcqResultDepB { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgAcqResultDepB { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgAcqResultDepB(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgAcqResultDepB { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgAcqResultDepB(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgAcqResultDepB { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.snr) - + WireFormat::len(&self.cp) - + WireFormat::len(&self.cf) - + WireFormat::len(&self.sid) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgAcqResultDepB { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.snr) + + WireFormat::len(&self.cp) + + WireFormat::len(&self.cf) + + WireFormat::len(&self.sid) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgAcqResultDepC { - /// 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 ConcreteMessage for MsgAcqResultDepC { - const MESSAGE_TYPE: u16 = 31; - const MESSAGE_NAME: &'static str = "MSG_ACQ_RESULT_DEP_C"; -} - -impl SbpMessage for MsgAcqResultDepC { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_acq_result_dep_c { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Deprecated + /// + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgAcqResultDepC { + /// 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 ConcreteMessage for MsgAcqResultDepC { + const MESSAGE_TYPE: u16 = 31; + const MESSAGE_NAME: &'static str = "MSG_ACQ_RESULT_DEP_C"; + } + + impl SbpMessage for MsgAcqResultDepC { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgAcqResultDepC { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgAcqResultDepC(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgAcqResultDepC { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgAcqResultDepC(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgAcqResultDepC { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.cn0) - + WireFormat::len(&self.cp) - + WireFormat::len(&self.cf) - + WireFormat::len(&self.sid) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgAcqResultDepC { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.cn0) + + WireFormat::len(&self.cp) + + WireFormat::len(&self.cf) + + WireFormat::len(&self.sid) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Acquisition perfomance measurement and debug -/// -/// The message describes all SV profiles during acquisition time. The message -/// is used to debug and measure the performance. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgAcqSvProfile { - /// 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, -} +pub mod msg_acq_sv_profile { + #![allow(unused_imports)] -impl ConcreteMessage for MsgAcqSvProfile { - const MESSAGE_TYPE: u16 = 46; - const MESSAGE_NAME: &'static str = "MSG_ACQ_SV_PROFILE"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgAcqSvProfile { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + /// Acquisition perfomance measurement and debug + /// + /// The message describes all SV profiles during acquisition time. The message + /// is used to debug and measure the performance. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgAcqSvProfile { + /// 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, } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgAcqSvProfile { + const MESSAGE_TYPE: u16 = 46; + const MESSAGE_NAME: &'static str = "MSG_ACQ_SV_PROFILE"; } -} -impl TryFrom for MsgAcqSvProfile { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgAcqSvProfile(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgAcqSvProfile { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgAcqSvProfile { - const MIN_LEN: usize = as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.acq_sv_profile) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.acq_sv_profile, buf); + impl TryFrom for MsgAcqSvProfile { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgAcqSvProfile(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgAcqSvProfile { - sender_id: None, - acq_sv_profile: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgAcqSvProfile { + const MIN_LEN: usize = as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.acq_sv_profile) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.acq_sv_profile, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgAcqSvProfile { + sender_id: None, + acq_sv_profile: WireFormat::parse_unchecked(buf), + } } } } -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgAcqSvProfileDep { - /// 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, -} +pub mod msg_acq_sv_profile_dep { + #![allow(unused_imports)] -impl ConcreteMessage for MsgAcqSvProfileDep { - const MESSAGE_TYPE: u16 = 30; - const MESSAGE_NAME: &'static str = "MSG_ACQ_SV_PROFILE_DEP"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgAcqSvProfileDep { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + /// Deprecated + /// + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgAcqSvProfileDep { + /// 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, } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgAcqSvProfileDep { + const MESSAGE_TYPE: u16 = 30; + const MESSAGE_NAME: &'static str = "MSG_ACQ_SV_PROFILE_DEP"; } -} -impl TryFrom for MsgAcqSvProfileDep { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgAcqSvProfileDep(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgAcqSvProfileDep { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgAcqSvProfileDep { - const MIN_LEN: usize = as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.acq_sv_profile) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.acq_sv_profile, buf); + impl TryFrom for MsgAcqSvProfileDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgAcqSvProfileDep(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgAcqSvProfileDep { - sender_id: None, - acq_sv_profile: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgAcqSvProfileDep { + const MIN_LEN: usize = as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.acq_sv_profile) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.acq_sv_profile, buf); + } + fn parse_unchecked(buf: &mut B) -> 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 5b8a08318f..ac91cf0ade 100644 --- a/rust/sbp/src/messages/bootload.rs +++ b/rust/sbp/src/messages/bootload.rs @@ -17,426 +17,478 @@ //! //! Note that some of these messages share the same message type ID for both //! the host request and the device response. - -use super::lib::*; - -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgBootloaderHandshakeDepA { - /// 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 ConcreteMessage for MsgBootloaderHandshakeDepA { - const MESSAGE_TYPE: u16 = 176; - const MESSAGE_NAME: &'static str = "MSG_BOOTLOADER_HANDSHAKE_DEP_A"; -} - -impl SbpMessage for MsgBootloaderHandshakeDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub use msg_bootloader_handshake_dep_a::MsgBootloaderHandshakeDepA; +pub use msg_bootloader_handshake_req::MsgBootloaderHandshakeReq; +pub use msg_bootloader_handshake_resp::MsgBootloaderHandshakeResp; +pub use msg_bootloader_jump_to_app::MsgBootloaderJumpToApp; +pub use msg_nap_device_dna_req::MsgNapDeviceDnaReq; +pub use msg_nap_device_dna_resp::MsgNapDeviceDnaResp; + +pub mod msg_bootloader_handshake_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Deprecated + /// + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgBootloaderHandshakeDepA { + /// 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 ConcreteMessage for MsgBootloaderHandshakeDepA { + const MESSAGE_TYPE: u16 = 176; + const MESSAGE_NAME: &'static str = "MSG_BOOTLOADER_HANDSHAKE_DEP_A"; + } + + impl SbpMessage for MsgBootloaderHandshakeDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgBootloaderHandshakeDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgBootloaderHandshakeDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgBootloaderHandshakeDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgBootloaderHandshakeDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgBootloaderHandshakeDepA { - const MIN_LEN: usize = as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.handshake) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.handshake, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgBootloaderHandshakeDepA { - sender_id: None, - handshake: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgBootloaderHandshakeDepA { + const MIN_LEN: usize = as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.handshake) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.handshake, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgBootloaderHandshakeDepA { + sender_id: None, + handshake: WireFormat::parse_unchecked(buf), + } } } } -/// Bootloading handshake request (host => device) -/// -/// The handshake message request from the host establishes a handshake -/// between the device bootloader and the host. The response from the device -/// is MSG_BOOTLOADER_HANDSHAKE_RESP. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgBootloaderHandshakeReq { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, -} +pub mod msg_bootloader_handshake_req { + #![allow(unused_imports)] -impl ConcreteMessage for MsgBootloaderHandshakeReq { - const MESSAGE_TYPE: u16 = 179; - const MESSAGE_NAME: &'static str = "MSG_BOOTLOADER_HANDSHAKE_REQ"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgBootloaderHandshakeReq { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE + /// Bootloading handshake request (host => device) + /// + /// The handshake message request from the host establishes a handshake + /// between the device bootloader and the host. The response from the device + /// is MSG_BOOTLOADER_HANDSHAKE_RESP. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgBootloaderHandshakeReq { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgBootloaderHandshakeReq { + const MESSAGE_TYPE: u16 = 179; + const MESSAGE_NAME: &'static str = "MSG_BOOTLOADER_HANDSHAKE_REQ"; } -} -impl TryFrom for MsgBootloaderHandshakeReq { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgBootloaderHandshakeReq(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgBootloaderHandshakeReq { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgBootloaderHandshakeReq { - const MIN_LEN: usize = 0; - fn len(&self) -> usize { - 0 + impl TryFrom for MsgBootloaderHandshakeReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgBootloaderHandshakeReq(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn write(&self, _buf: &mut B) {} - fn parse_unchecked(_buf: &mut B) -> Self { - MsgBootloaderHandshakeReq { sender_id: None } + + impl WireFormat for MsgBootloaderHandshakeReq { + const MIN_LEN: usize = 0; + fn len(&self) -> usize { + 0 + } + fn write(&self, _buf: &mut B) {} + fn parse_unchecked(_buf: &mut B) -> Self { + MsgBootloaderHandshakeReq { sender_id: None } + } } } -/// Bootloading handshake response (host <= device) -/// -/// The handshake message response from the device establishes a handshake -/// between the device bootloader and the host. The request from the host is -/// MSG_BOOTLOADER_HANDSHAKE_REQ. The payload contains the bootloader version -/// number and the SBP protocol version number. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgBootloaderHandshakeResp { - /// 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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "version")))] - pub version: SbpString, Unterminated>, -} +pub mod msg_bootloader_handshake_resp { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Bootloading handshake response (host <= device) + /// + /// The handshake message response from the device establishes a handshake + /// between the device bootloader and the host. The request from the host is + /// MSG_BOOTLOADER_HANDSHAKE_REQ. The payload contains the bootloader version + /// number and the SBP protocol version number. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgBootloaderHandshakeResp { + /// 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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "version")))] + pub version: SbpString, Unterminated>, + } + + impl MsgBootloaderHandshakeResp { + pub fn sbp_major_protocol_version_number(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 15, 8) + } -impl MsgBootloaderHandshakeResp { - pub fn sbp_major_protocol_version_number(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 15, 8) - } + pub fn set_sbp_major_protocol_version_number( + &mut self, + sbp_major_protocol_version_number: u8, + ) { + set_bit_range!( + &mut self.flags, + sbp_major_protocol_version_number, + u32, + u8, + 15, + 8 + ); + } - pub fn set_sbp_major_protocol_version_number(&mut self, sbp_major_protocol_version_number: u8) { - set_bit_range!( - &mut self.flags, - sbp_major_protocol_version_number, - u32, - u8, - 15, - 8 - ); - } + pub fn sbp_minor_protocol_version_number(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 7, 0) + } - pub fn sbp_minor_protocol_version_number(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 7, 0) + pub fn set_sbp_minor_protocol_version_number( + &mut self, + sbp_minor_protocol_version_number: u8, + ) { + set_bit_range!( + &mut self.flags, + sbp_minor_protocol_version_number, + u32, + u8, + 7, + 0 + ); + } } - pub fn set_sbp_minor_protocol_version_number(&mut self, sbp_minor_protocol_version_number: u8) { - set_bit_range!( - &mut self.flags, - sbp_minor_protocol_version_number, - u32, - u8, - 7, - 0 - ); + impl ConcreteMessage for MsgBootloaderHandshakeResp { + const MESSAGE_TYPE: u16 = 180; + const MESSAGE_NAME: &'static str = "MSG_BOOTLOADER_HANDSHAKE_RESP"; } -} - -impl ConcreteMessage for MsgBootloaderHandshakeResp { - const MESSAGE_TYPE: u16 = 180; - const MESSAGE_NAME: &'static str = "MSG_BOOTLOADER_HANDSHAKE_RESP"; -} -impl SbpMessage for MsgBootloaderHandshakeResp { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgBootloaderHandshakeResp { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgBootloaderHandshakeResp { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgBootloaderHandshakeResp(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgBootloaderHandshakeResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgBootloaderHandshakeResp(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgBootloaderHandshakeResp { - const MIN_LEN: usize = - ::MIN_LEN + , Unterminated> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.flags) + WireFormat::len(&self.version) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.flags, buf); - WireFormat::write(&self.version, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgBootloaderHandshakeResp { - sender_id: None, - flags: WireFormat::parse_unchecked(buf), - version: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgBootloaderHandshakeResp { + const MIN_LEN: usize = ::MIN_LEN + + , Unterminated> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.flags) + WireFormat::len(&self.version) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.flags, buf); + WireFormat::write(&self.version, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgBootloaderHandshakeResp { + sender_id: None, + flags: WireFormat::parse_unchecked(buf), + version: WireFormat::parse_unchecked(buf), + } } } } -/// Bootloader jump to application (host => device) -/// -/// The host initiates the bootloader to jump to the application. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgBootloaderJumpToApp { - /// 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, -} +pub mod msg_bootloader_jump_to_app { + #![allow(unused_imports)] -impl ConcreteMessage for MsgBootloaderJumpToApp { - const MESSAGE_TYPE: u16 = 177; - const MESSAGE_NAME: &'static str = "MSG_BOOTLOADER_JUMP_TO_APP"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgBootloaderJumpToApp { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + /// Bootloader jump to application (host => device) + /// + /// The host initiates the bootloader to jump to the application. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgBootloaderJumpToApp { + /// 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, } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgBootloaderJumpToApp { + const MESSAGE_TYPE: u16 = 177; + const MESSAGE_NAME: &'static str = "MSG_BOOTLOADER_JUMP_TO_APP"; } -} -impl TryFrom for MsgBootloaderJumpToApp { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgBootloaderJumpToApp(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgBootloaderJumpToApp { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgBootloaderJumpToApp { - const MIN_LEN: usize = ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.jump) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.jump, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgBootloaderJumpToApp { - sender_id: None, - jump: WireFormat::parse_unchecked(buf), + impl TryFrom for MsgBootloaderJumpToApp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgBootloaderJumpToApp(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} - -/// Read FPGA device ID over UART request (host => device) -/// -/// The device message from the host reads a unique device identifier from the -/// SwiftNAP, an FPGA. The host requests the ID by sending a -/// MSG_NAP_DEVICE_DNA_REQ message. The device responds with a -/// MSG_NAP_DEVICE_DNA_RESP message with the device ID in the payload. Note -/// that this ID is tied to the FPGA, and not related to the Piksi's serial -/// number. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgNapDeviceDnaReq { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, -} - -impl ConcreteMessage for MsgNapDeviceDnaReq { - const MESSAGE_TYPE: u16 = 222; - const MESSAGE_NAME: &'static str = "MSG_NAP_DEVICE_DNA_REQ"; -} -impl SbpMessage for MsgNapDeviceDnaReq { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl WireFormat for MsgBootloaderJumpToApp { + const MIN_LEN: usize = ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.jump) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.jump, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgBootloaderJumpToApp { + sender_id: None, + jump: WireFormat::parse_unchecked(buf), + } + } } } -impl TryFrom for MsgNapDeviceDnaReq { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgNapDeviceDnaReq(m) => Ok(m), - _ => Err(TryFromSbpError), +pub mod msg_nap_device_dna_req { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Read FPGA device ID over UART request (host => device) + /// + /// The device message from the host reads a unique device identifier from the + /// SwiftNAP, an FPGA. The host requests the ID by sending a + /// MSG_NAP_DEVICE_DNA_REQ message. The device responds with a + /// MSG_NAP_DEVICE_DNA_RESP message with the device ID in the payload. Note + /// that this ID is tied to the FPGA, and not related to the Piksi's serial + /// number. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgNapDeviceDnaReq { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + } + + impl ConcreteMessage for MsgNapDeviceDnaReq { + const MESSAGE_TYPE: u16 = 222; + const MESSAGE_NAME: &'static str = "MSG_NAP_DEVICE_DNA_REQ"; + } + + impl SbpMessage for MsgNapDeviceDnaReq { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgNapDeviceDnaReq { - const MIN_LEN: usize = 0; - fn len(&self) -> usize { - 0 - } - fn write(&self, _buf: &mut B) {} - fn parse_unchecked(_buf: &mut B) -> Self { - MsgNapDeviceDnaReq { sender_id: None } + impl TryFrom for MsgNapDeviceDnaReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgNapDeviceDnaReq(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } -} -/// Read FPGA device ID over UART response (host <= device) -/// -/// The device message from the host reads a unique device identifier from the -/// SwiftNAP, an FPGA. The host requests the ID by sending a -/// MSG_NAP_DEVICE_DNA_REQ message. The device responds with a -/// MSG_NAP_DEVICE_DNA_RESP message with the device ID in the payload. Note -/// that this ID is tied to the FPGA, and not related to the Piksi's serial -/// number. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgNapDeviceDnaResp { - /// 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. - #[cfg_attr(feature = "serde", serde(rename(serialize = "dna")))] - pub dna: [u8; 8], -} - -impl ConcreteMessage for MsgNapDeviceDnaResp { - const MESSAGE_TYPE: u16 = 221; - const MESSAGE_NAME: &'static str = "MSG_NAP_DEVICE_DNA_RESP"; -} - -impl SbpMessage for MsgNapDeviceDnaResp { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl WireFormat for MsgNapDeviceDnaReq { + const MIN_LEN: usize = 0; + fn len(&self) -> usize { + 0 + } + fn write(&self, _buf: &mut B) {} + fn parse_unchecked(_buf: &mut B) -> Self { + MsgNapDeviceDnaReq { sender_id: None } + } } } -impl TryFrom for MsgNapDeviceDnaResp { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgNapDeviceDnaResp(m) => Ok(m), - _ => Err(TryFromSbpError), +pub mod msg_nap_device_dna_resp { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Read FPGA device ID over UART response (host <= device) + /// + /// The device message from the host reads a unique device identifier from the + /// SwiftNAP, an FPGA. The host requests the ID by sending a + /// MSG_NAP_DEVICE_DNA_REQ message. The device responds with a + /// MSG_NAP_DEVICE_DNA_RESP message with the device ID in the payload. Note + /// that this ID is tied to the FPGA, and not related to the Piksi's serial + /// number. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgNapDeviceDnaResp { + /// 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. + #[cfg_attr(feature = "serde", serde(rename(serialize = "dna")))] + pub dna: [u8; 8], + } + + impl ConcreteMessage for MsgNapDeviceDnaResp { + const MESSAGE_TYPE: u16 = 221; + const MESSAGE_NAME: &'static str = "MSG_NAP_DEVICE_DNA_RESP"; + } + + impl SbpMessage for MsgNapDeviceDnaResp { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgNapDeviceDnaResp { - const MIN_LEN: usize = <[u8; 8] as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.dna) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.dna, buf); + impl TryFrom for MsgNapDeviceDnaResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgNapDeviceDnaResp(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgNapDeviceDnaResp { - sender_id: None, - dna: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgNapDeviceDnaResp { + const MIN_LEN: usize = <[u8; 8] as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.dna) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.dna, buf); + } + fn parse_unchecked(buf: &mut B) -> 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 18a4f63634..9afa215cbf 100644 --- a/rust/sbp/src/messages/ext_events.rs +++ b/rust/sbp/src/messages/ext_events.rs @@ -14,179 +14,185 @@ //****************************************************************************/ //! Messages reporting accurately-timestamped external events, e.g. camera //! shutter time. +pub use msg_ext_event::MsgExtEvent; + +pub mod msg_ext_event { + #![allow(unused_imports)] + + use super::*; + use crate::messages::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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgExtEvent { + /// 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 { + pub fn time_quality(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 1, 0) { + 0 => Some(TimeQuality::UnknownDontHaveNavSolution), + 1 => Some(TimeQuality::Good), + _ => None, + } + } -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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgExtEvent { - /// 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 { - pub fn time_quality(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 1, 0) { - 0 => Some(MsgExtEventTimeQuality::UnknownDontHaveNavSolution), - 1 => Some(MsgExtEventTimeQuality::Good), - _ => None, + pub fn set_time_quality(&mut self, time_quality: TimeQuality) { + set_bit_range!(&mut self.flags, time_quality, u8, u8, 1, 0); } - } - pub fn set_time_quality(&mut self, time_quality: MsgExtEventTimeQuality) { - set_bit_range!(&mut self.flags, time_quality, u8, u8, 1, 0); - } + pub fn new_level_of_pin(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 0, 0) { + 0 => Some(NewLevelOfPin::Low), + 1 => Some(NewLevelOfPin::High), + _ => None, + } + } - pub fn new_level_of_pin(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 0, 0) { - 0 => Some(MsgExtEventNewLevelOfPin::Low), - 1 => Some(MsgExtEventNewLevelOfPin::High), - _ => None, + pub fn set_new_level_of_pin(&mut self, new_level_of_pin: NewLevelOfPin) { + set_bit_range!(&mut self.flags, new_level_of_pin, u8, u8, 0, 0); } } - pub fn set_new_level_of_pin(&mut self, new_level_of_pin: MsgExtEventNewLevelOfPin) { - set_bit_range!(&mut self.flags, new_level_of_pin, u8, u8, 0, 0); + impl ConcreteMessage for MsgExtEvent { + const MESSAGE_TYPE: u16 = 257; + const MESSAGE_NAME: &'static str = "MSG_EXT_EVENT"; } -} -impl ConcreteMessage for MsgExtEvent { - const MESSAGE_TYPE: u16 = 257; - const MESSAGE_NAME: &'static str = "MSG_EXT_EVENT"; -} - -impl SbpMessage for MsgExtEvent { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - #[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 time::GpsTime::new(wn, tow_s) { - Ok(gps_time) => gps_time, - Err(e) => return Some(Err(e.into())), - }; - Some(Ok(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgExtEvent { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + #[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 time::GpsTime::new(wn, tow_s) { + Ok(gps_time) => gps_time, + Err(e) => return Some(Err(e.into())), + }; + Some(Ok(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgExtEvent { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgExtEvent(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgExtEvent { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgExtEvent(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgExtEvent { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.wn) - + WireFormat::len(&self.tow) - + WireFormat::len(&self.ns_residual) - + WireFormat::len(&self.flags) - + WireFormat::len(&self.pin) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgExtEvent { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.wn) + + WireFormat::len(&self.tow) + + WireFormat::len(&self.ns_residual) + + WireFormat::len(&self.flags) + + WireFormat::len(&self.pin) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Time quality -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgExtEventTimeQuality { - /// Unknown - don't have nav solution - UnknownDontHaveNavSolution = 0, + /// Time quality + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TimeQuality { + /// Unknown - don't have nav solution + UnknownDontHaveNavSolution = 0, - /// Good (< 1 microsecond) - Good = 1, -} + /// Good (< 1 microsecond) + Good = 1, + } -impl std::fmt::Display for MsgExtEventTimeQuality { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgExtEventTimeQuality::UnknownDontHaveNavSolution => { - f.write_str("Unknown - don't have nav solution") + impl std::fmt::Display for TimeQuality { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TimeQuality::UnknownDontHaveNavSolution => { + f.write_str("Unknown - don't have nav solution") + } + TimeQuality::Good => f.write_str("Good (< 1 microsecond)"), } - MsgExtEventTimeQuality::Good => f.write_str("Good (< 1 microsecond)"), } } -} -/// New level of pin -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgExtEventNewLevelOfPin { - /// Low (falling edge) - Low = 0, + /// New level of pin + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum NewLevelOfPin { + /// Low (falling edge) + Low = 0, - /// High (rising edge) - High = 1, -} + /// High (rising edge) + High = 1, + } -impl std::fmt::Display for MsgExtEventNewLevelOfPin { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgExtEventNewLevelOfPin::Low => f.write_str("Low (falling edge)"), - MsgExtEventNewLevelOfPin::High => f.write_str("High (rising edge)"), + impl std::fmt::Display for NewLevelOfPin { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + NewLevelOfPin::Low => f.write_str("Low (falling edge)"), + NewLevelOfPin::High => f.write_str("High (rising edge)"), + } } } } diff --git a/rust/sbp/src/messages/file_io.rs b/rust/sbp/src/messages/file_io.rs index 6f5e4cda5a..35825bea3e 100644 --- a/rust/sbp/src/messages/file_io.rs +++ b/rust/sbp/src/messages/file_io.rs @@ -20,708 +20,778 @@ //! //! Note that some of these messages share the same message type ID for both //! the host request and the device response. - -use super::lib::*; - -/// Request advice on the optimal configuration for FileIO -/// -/// Requests advice on the optimal configuration for a FileIO transfer. Newer -/// version of FileIO can support greater throughput by supporting a large -/// window of FileIO data that can be in-flight during read or write -/// operations. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgFileioConfigReq { - /// 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 ConcreteMessage for MsgFileioConfigReq { - const MESSAGE_TYPE: u16 = 4097; - const MESSAGE_NAME: &'static str = "MSG_FILEIO_CONFIG_REQ"; -} - -impl SbpMessage for MsgFileioConfigReq { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub use msg_fileio_config_req::MsgFileioConfigReq; +pub use msg_fileio_config_resp::MsgFileioConfigResp; +pub use msg_fileio_read_dir_req::MsgFileioReadDirReq; +pub use msg_fileio_read_dir_resp::MsgFileioReadDirResp; +pub use msg_fileio_read_req::MsgFileioReadReq; +pub use msg_fileio_read_resp::MsgFileioReadResp; +pub use msg_fileio_remove::MsgFileioRemove; +pub use msg_fileio_write_req::MsgFileioWriteReq; +pub use msg_fileio_write_resp::MsgFileioWriteResp; + +pub mod msg_fileio_config_req { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Request advice on the optimal configuration for FileIO + /// + /// Requests advice on the optimal configuration for a FileIO transfer. Newer + /// version of FileIO can support greater throughput by supporting a large + /// window of FileIO data that can be in-flight during read or write + /// operations. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgFileioConfigReq { + /// 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 ConcreteMessage for MsgFileioConfigReq { + const MESSAGE_TYPE: u16 = 4097; + const MESSAGE_NAME: &'static str = "MSG_FILEIO_CONFIG_REQ"; + } + + impl SbpMessage for MsgFileioConfigReq { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgFileioConfigReq { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgFileioConfigReq(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgFileioConfigReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgFileioConfigReq(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgFileioConfigReq { - const MIN_LEN: usize = ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sequence) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sequence, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgFileioConfigReq { - sender_id: None, - sequence: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgFileioConfigReq { + const MIN_LEN: usize = ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sequence) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sequence, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgFileioConfigReq { + sender_id: None, + sequence: WireFormat::parse_unchecked(buf), + } } } } -/// Response with advice on the optimal configuration for FileIO. - -/// -/// The advice on the optimal configuration for a FileIO transfer. Newer -/// version of FileIO can support greater throughput by supporting a large -/// window of FileIO data that can be in-flight during read or write -/// operations. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgFileioConfigResp { - /// 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 ConcreteMessage for MsgFileioConfigResp { - const MESSAGE_TYPE: u16 = 4098; - const MESSAGE_NAME: &'static str = "MSG_FILEIO_CONFIG_RESP"; -} - -impl SbpMessage for MsgFileioConfigResp { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_fileio_config_resp { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Response with advice on the optimal configuration for FileIO. + + /// + /// The advice on the optimal configuration for a FileIO transfer. Newer + /// version of FileIO can support greater throughput by supporting a large + /// window of FileIO data that can be in-flight during read or write + /// operations. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgFileioConfigResp { + /// 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 ConcreteMessage for MsgFileioConfigResp { + const MESSAGE_TYPE: u16 = 4098; + const MESSAGE_NAME: &'static str = "MSG_FILEIO_CONFIG_RESP"; + } + + impl SbpMessage for MsgFileioConfigResp { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgFileioConfigResp { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgFileioConfigResp(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgFileioConfigResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgFileioConfigResp(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgFileioConfigResp { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sequence) - + WireFormat::len(&self.window_size) - + WireFormat::len(&self.batch_size) - + WireFormat::len(&self.fileio_version) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgFileioConfigResp { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sequence) + + WireFormat::len(&self.window_size) + + WireFormat::len(&self.batch_size) + + WireFormat::len(&self.fileio_version) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// List files in a directory (host => device) -/// -/// The read directory message lists the files in a directory on the device's -/// onboard flash file system. The offset parameter can be used to skip the -/// first n elements of the file list. Returns a MSG_FILEIO_READ_DIR_RESP -/// message containing the directory listings as a NULL delimited list. The -/// listing is chunked over multiple SBP packets. The sequence number in the -/// request will be returned in the response. If message is invalid, a -/// followup MSG_PRINT message will print "Invalid fileio read message". A -/// device will only respond to this message when it is received from sender -/// ID 0x42. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgFileioReadDirReq { - /// 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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "dirname")))] - pub dirname: SbpString, NullTerminated>, -} - -impl ConcreteMessage for MsgFileioReadDirReq { - const MESSAGE_TYPE: u16 = 169; - const MESSAGE_NAME: &'static str = "MSG_FILEIO_READ_DIR_REQ"; -} - -impl SbpMessage for MsgFileioReadDirReq { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_fileio_read_dir_req { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// List files in a directory (host => device) + /// + /// The read directory message lists the files in a directory on the device's + /// onboard flash file system. The offset parameter can be used to skip the + /// first n elements of the file list. Returns a MSG_FILEIO_READ_DIR_RESP + /// message containing the directory listings as a NULL delimited list. The + /// listing is chunked over multiple SBP packets. The sequence number in the + /// request will be returned in the response. If message is invalid, a + /// followup MSG_PRINT message will print "Invalid fileio read message". A + /// device will only respond to this message when it is received from sender + /// ID 0x42. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgFileioReadDirReq { + /// 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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "dirname")))] + pub dirname: SbpString, NullTerminated>, + } + + impl ConcreteMessage for MsgFileioReadDirReq { + const MESSAGE_TYPE: u16 = 169; + const MESSAGE_NAME: &'static str = "MSG_FILEIO_READ_DIR_REQ"; + } + + impl SbpMessage for MsgFileioReadDirReq { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgFileioReadDirReq { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgFileioReadDirReq(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgFileioReadDirReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgFileioReadDirReq(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgFileioReadDirReq { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + , NullTerminated> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sequence) - + WireFormat::len(&self.offset) - + WireFormat::len(&self.dirname) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sequence, buf); - WireFormat::write(&self.offset, buf); - WireFormat::write(&self.dirname, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgFileioReadDirReq { - sender_id: None, - sequence: WireFormat::parse_unchecked(buf), - offset: WireFormat::parse_unchecked(buf), - dirname: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgFileioReadDirReq { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + , NullTerminated> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sequence) + + WireFormat::len(&self.offset) + + WireFormat::len(&self.dirname) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sequence, buf); + WireFormat::write(&self.offset, buf); + WireFormat::write(&self.dirname, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgFileioReadDirReq { + sender_id: None, + sequence: WireFormat::parse_unchecked(buf), + offset: WireFormat::parse_unchecked(buf), + dirname: WireFormat::parse_unchecked(buf), + } } } } -/// Files listed in a directory (host <= device) -/// -/// The read directory message lists the files in a directory on the device's -/// onboard flash file system. Message contains the directory listings as a -/// NULL delimited list. The listing is chunked over multiple SBP packets and -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgFileioReadDirResp { - /// 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, -} +pub mod msg_fileio_read_dir_resp { + #![allow(unused_imports)] -impl ConcreteMessage for MsgFileioReadDirResp { - const MESSAGE_TYPE: u16 = 170; - const MESSAGE_NAME: &'static str = "MSG_FILEIO_READ_DIR_RESP"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgFileioReadDirResp { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + /// Files listed in a directory (host <= device) + /// + /// The read directory message lists the files in a directory on the device's + /// onboard flash file system. Message contains the directory listings as a + /// NULL delimited list. The listing is chunked over multiple SBP packets and + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgFileioReadDirResp { + /// 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, } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgFileioReadDirResp { + const MESSAGE_TYPE: u16 = 170; + const MESSAGE_NAME: &'static str = "MSG_FILEIO_READ_DIR_RESP"; } -} -impl TryFrom for MsgFileioReadDirResp { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgFileioReadDirResp(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgFileioReadDirResp { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgFileioReadDirResp { - const MIN_LEN: usize = ::MIN_LEN + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sequence) + WireFormat::len(&self.contents) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sequence, buf); - WireFormat::write(&self.contents, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgFileioReadDirResp { - sender_id: None, - sequence: WireFormat::parse_unchecked(buf), - contents: WireFormat::parse_unchecked(buf), + impl TryFrom for MsgFileioReadDirResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgFileioReadDirResp(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} - -/// Read file from the file system (host => device) -/// -/// The file read message reads a certain length (up to 255 bytes) from a -/// given offset into a file, and returns the data in a MSG_FILEIO_READ_RESP -/// message where the message length field indicates how many bytes were -/// successfully read. The sequence number in the request will be returned in -/// the response. If the message is invalid, a followup MSG_PRINT message will -/// print "Invalid fileio read message". A device will only respond to this -/// message when it is received from sender ID 0x42. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgFileioReadReq { - /// 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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "filename")))] - pub filename: SbpString, NullTerminated>, -} -impl ConcreteMessage for MsgFileioReadReq { - const MESSAGE_TYPE: u16 = 168; - const MESSAGE_NAME: &'static str = "MSG_FILEIO_READ_REQ"; + impl WireFormat for MsgFileioReadDirResp { + const MIN_LEN: usize = ::MIN_LEN + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sequence) + WireFormat::len(&self.contents) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sequence, buf); + WireFormat::write(&self.contents, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgFileioReadDirResp { + sender_id: None, + sequence: WireFormat::parse_unchecked(buf), + contents: WireFormat::parse_unchecked(buf), + } + } + } } -impl SbpMessage for MsgFileioReadReq { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_fileio_read_req { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Read file from the file system (host => device) + /// + /// The file read message reads a certain length (up to 255 bytes) from a + /// given offset into a file, and returns the data in a MSG_FILEIO_READ_RESP + /// message where the message length field indicates how many bytes were + /// successfully read. The sequence number in the request will be returned in + /// the response. If the message is invalid, a followup MSG_PRINT message will + /// print "Invalid fileio read message". A device will only respond to this + /// message when it is received from sender ID 0x42. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgFileioReadReq { + /// 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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "filename")))] + pub filename: SbpString, NullTerminated>, + } + + impl ConcreteMessage for MsgFileioReadReq { + const MESSAGE_TYPE: u16 = 168; + const MESSAGE_NAME: &'static str = "MSG_FILEIO_READ_REQ"; + } + + impl SbpMessage for MsgFileioReadReq { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgFileioReadReq { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgFileioReadReq(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgFileioReadReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgFileioReadReq(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgFileioReadReq { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + , NullTerminated> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sequence) - + WireFormat::len(&self.offset) - + WireFormat::len(&self.chunk_size) - + WireFormat::len(&self.filename) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgFileioReadReq { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + , NullTerminated> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sequence) + + WireFormat::len(&self.offset) + + WireFormat::len(&self.chunk_size) + + WireFormat::len(&self.filename) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// File read from the file system (host <= device) -/// -/// The file read message reads a certain length (up to 255 bytes) from a -/// given offset into a file, and returns the data in a message where the -/// message length field indicates how many bytes were successfully read. The -/// sequence number in the response is preserved from the request. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgFileioReadResp { - /// 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, -} +pub mod msg_fileio_read_resp { + #![allow(unused_imports)] -impl ConcreteMessage for MsgFileioReadResp { - const MESSAGE_TYPE: u16 = 163; - const MESSAGE_NAME: &'static str = "MSG_FILEIO_READ_RESP"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgFileioReadResp { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + /// File read from the file system (host <= device) + /// + /// The file read message reads a certain length (up to 255 bytes) from a + /// given offset into a file, and returns the data in a message where the + /// message length field indicates how many bytes were successfully read. The + /// sequence number in the response is preserved from the request. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgFileioReadResp { + /// 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, } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgFileioReadResp { + const MESSAGE_TYPE: u16 = 163; + const MESSAGE_NAME: &'static str = "MSG_FILEIO_READ_RESP"; } -} -impl TryFrom for MsgFileioReadResp { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgFileioReadResp(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgFileioReadResp { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgFileioReadResp { - const MIN_LEN: usize = ::MIN_LEN + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sequence) + WireFormat::len(&self.contents) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sequence, buf); - WireFormat::write(&self.contents, buf); + impl TryFrom for MsgFileioReadResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgFileioReadResp(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgFileioReadResp { - sender_id: None, - sequence: WireFormat::parse_unchecked(buf), - contents: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgFileioReadResp { + const MIN_LEN: usize = ::MIN_LEN + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sequence) + WireFormat::len(&self.contents) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sequence, buf); + WireFormat::write(&self.contents, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgFileioReadResp { + sender_id: None, + sequence: WireFormat::parse_unchecked(buf), + contents: WireFormat::parse_unchecked(buf), + } } } } -/// Delete a file from the file system (host => device) -/// -/// The file remove message deletes a file from the file system. If the -/// message is invalid, a followup MSG_PRINT message will print "Invalid -/// fileio remove message". A device will only process this message when it is -/// received from sender ID 0x42. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgFileioRemove { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, - /// Name of the file to delete - #[cfg_attr(feature = "serde", serde(rename(serialize = "filename")))] - pub filename: SbpString, NullTerminated>, -} +pub mod msg_fileio_remove { + #![allow(unused_imports)] -impl ConcreteMessage for MsgFileioRemove { - const MESSAGE_TYPE: u16 = 172; - const MESSAGE_NAME: &'static str = "MSG_FILEIO_REMOVE"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgFileioRemove { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME + /// Delete a file from the file system (host => device) + /// + /// The file remove message deletes a file from the file system. If the + /// message is invalid, a followup MSG_PRINT message will print "Invalid + /// fileio remove message". A device will only process this message when it is + /// received from sender ID 0x42. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgFileioRemove { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + /// Name of the file to delete + #[cfg_attr(feature = "serde", serde(rename(serialize = "filename")))] + pub filename: SbpString, NullTerminated>, } - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgFileioRemove { + const MESSAGE_TYPE: u16 = 172; + const MESSAGE_NAME: &'static str = "MSG_FILEIO_REMOVE"; } -} -impl TryFrom for MsgFileioRemove { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgFileioRemove(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgFileioRemove { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgFileioRemove { - const MIN_LEN: usize = , NullTerminated> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.filename) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.filename, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgFileioRemove { - sender_id: None, - filename: WireFormat::parse_unchecked(buf), + impl TryFrom for MsgFileioRemove { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgFileioRemove(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} - -/// Write to file (host => device) -/// -/// The file write message writes a certain length (up to 255 bytes) of data -/// to a file at a given offset. Returns a copy of the original -/// MSG_FILEIO_WRITE_RESP message to check integrity of the write. The -/// sequence number in the request will be returned in the response. If -/// message is invalid, a followup MSG_PRINT message will print "Invalid -/// fileio write message". A device will only process this message when it is -/// received from sender ID 0x42. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgFileioWriteReq { - /// 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 - #[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 ConcreteMessage for MsgFileioWriteReq { - const MESSAGE_TYPE: u16 = 173; - const MESSAGE_NAME: &'static str = "MSG_FILEIO_WRITE_REQ"; + impl WireFormat for MsgFileioRemove { + const MIN_LEN: usize = , NullTerminated> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.filename) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.filename, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgFileioRemove { + sender_id: None, + filename: WireFormat::parse_unchecked(buf), + } + } + } } -impl SbpMessage for MsgFileioWriteReq { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_fileio_write_req { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Write to file (host => device) + /// + /// The file write message writes a certain length (up to 255 bytes) of data + /// to a file at a given offset. Returns a copy of the original + /// MSG_FILEIO_WRITE_RESP message to check integrity of the write. The + /// sequence number in the request will be returned in the response. If + /// message is invalid, a followup MSG_PRINT message will print "Invalid + /// fileio write message". A device will only process this message when it is + /// received from sender ID 0x42. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgFileioWriteReq { + /// 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 + #[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 ConcreteMessage for MsgFileioWriteReq { + const MESSAGE_TYPE: u16 = 173; + const MESSAGE_NAME: &'static str = "MSG_FILEIO_WRITE_REQ"; + } + + impl SbpMessage for MsgFileioWriteReq { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgFileioWriteReq { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgFileioWriteReq(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgFileioWriteReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgFileioWriteReq(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgFileioWriteReq { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + , NullTerminated> as WireFormat>::MIN_LEN - + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sequence) - + WireFormat::len(&self.offset) - + WireFormat::len(&self.filename) - + WireFormat::len(&self.data) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgFileioWriteReq { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + , NullTerminated> as WireFormat>::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sequence) + + WireFormat::len(&self.offset) + + WireFormat::len(&self.filename) + + WireFormat::len(&self.data) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// File written to (host <= device) -/// -/// The file write message writes a certain length (up to 255 bytes) of data -/// to a file at a given offset. The message is a copy of the original -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgFileioWriteResp { - /// 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, -} +pub mod msg_fileio_write_resp { + #![allow(unused_imports)] -impl ConcreteMessage for MsgFileioWriteResp { - const MESSAGE_TYPE: u16 = 171; - const MESSAGE_NAME: &'static str = "MSG_FILEIO_WRITE_RESP"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgFileioWriteResp { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE + /// File written to (host <= device) + /// + /// The file write message writes a certain length (up to 255 bytes) of data + /// to a file at a given offset. The message is a copy of the original + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgFileioWriteResp { + /// 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, } - fn sender_id(&self) -> Option { - self.sender_id - } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgFileioWriteResp { + const MESSAGE_TYPE: u16 = 171; + const MESSAGE_NAME: &'static str = "MSG_FILEIO_WRITE_RESP"; } -} -impl TryFrom for MsgFileioWriteResp { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgFileioWriteResp(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgFileioWriteResp { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgFileioWriteResp { - const MIN_LEN: usize = ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sequence) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sequence, buf); + impl TryFrom for MsgFileioWriteResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgFileioWriteResp(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgFileioWriteResp { - sender_id: None, - sequence: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgFileioWriteResp { + const MIN_LEN: usize = ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sequence) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sequence, buf); + } + fn parse_unchecked(buf: &mut B) -> 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 4cbdd8d1e4..43432e3760 100644 --- a/rust/sbp/src/messages/flash.rs +++ b/rust/sbp/src/messages/flash.rs @@ -16,917 +16,983 @@ //! these messages target specific flash memory peripherals used in Swift //! Navigation devices: the STM32 flash and the M25Pxx FPGA configuration //! flash from Piksi 2.3.1. This module does not apply to Piksi Multi. +pub use msg_flash_done::MsgFlashDone; +pub use msg_flash_erase::MsgFlashErase; +pub use msg_flash_program::MsgFlashProgram; +pub use msg_flash_read_req::MsgFlashReadReq; +pub use msg_flash_read_resp::MsgFlashReadResp; +pub use msg_m25_flash_write_status::MsgM25FlashWriteStatus; +pub use msg_stm_flash_lock_sector::MsgStmFlashLockSector; +pub use msg_stm_flash_unlock_sector::MsgStmFlashUnlockSector; +pub use msg_stm_unique_id_req::MsgStmUniqueIdReq; +pub use msg_stm_unique_id_resp::MsgStmUniqueIdResp; + +pub mod msg_flash_done { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Flash response message (host <= device) + /// + /// This message defines success or failure codes for a variety of flash + /// memory requests from the host to the device. Flash read and write + /// messages, such as MSG_FLASH_READ_REQ, or MSG_FLASH_PROGRAM, may return + /// this message on failure. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgFlashDone { + /// 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 { + pub fn response_code(&self) -> Option { + match get_bit_range!(self.response, u8, u8, 2, 0) { + 0 => Some(ResponseCode::FlashOk), + 1 => Some(ResponseCode::FlashInvalidFlash), + 2 => Some(ResponseCode::FlashInvalidLen), + 3 => Some(ResponseCode::FlashInvalidAddr), + 4 => Some(ResponseCode::FlashInvalidRange), + 5 => Some(ResponseCode::FlashInvalidSector), + _ => None, + } + } -use super::lib::*; - -/// Flash response message (host <= device) -/// -/// This message defines success or failure codes for a variety of flash -/// memory requests from the host to the device. Flash read and write -/// messages, such as MSG_FLASH_READ_REQ, or MSG_FLASH_PROGRAM, may return -/// this message on failure. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgFlashDone { - /// 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 { - pub fn response_code(&self) -> Option { - match get_bit_range!(self.response, u8, u8, 2, 0) { - 0 => Some(MsgFlashDoneResponseCode::FlashOk), - 1 => Some(MsgFlashDoneResponseCode::FlashInvalidFlash), - 2 => Some(MsgFlashDoneResponseCode::FlashInvalidLen), - 3 => Some(MsgFlashDoneResponseCode::FlashInvalidAddr), - 4 => Some(MsgFlashDoneResponseCode::FlashInvalidRange), - 5 => Some(MsgFlashDoneResponseCode::FlashInvalidSector), - _ => None, + pub fn set_response_code(&mut self, response_code: ResponseCode) { + set_bit_range!(&mut self.response, response_code, u8, u8, 2, 0); } } - pub fn set_response_code(&mut self, response_code: MsgFlashDoneResponseCode) { - set_bit_range!(&mut self.response, response_code, u8, u8, 2, 0); + impl ConcreteMessage for MsgFlashDone { + const MESSAGE_TYPE: u16 = 224; + const MESSAGE_NAME: &'static str = "MSG_FLASH_DONE"; } -} -impl ConcreteMessage for MsgFlashDone { - const MESSAGE_TYPE: u16 = 224; - const MESSAGE_NAME: &'static str = "MSG_FLASH_DONE"; -} - -impl SbpMessage for MsgFlashDone { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgFlashDone { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgFlashDone { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgFlashDone(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgFlashDone { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgFlashDone(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgFlashDone { - const MIN_LEN: usize = ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.response) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.response, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgFlashDone { - sender_id: None, - response: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgFlashDone { + const MIN_LEN: usize = ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.response) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.response, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgFlashDone { + sender_id: None, + response: WireFormat::parse_unchecked(buf), + } } } -} -/// Response code -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgFlashDoneResponseCode { - /// FLASH_OK - FlashOk = 0, + /// Response code + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum ResponseCode { + /// FLASH_OK + FlashOk = 0, - /// FLASH_INVALID_FLASH - FlashInvalidFlash = 1, + /// FLASH_INVALID_FLASH + FlashInvalidFlash = 1, - /// FLASH_INVALID_LEN - FlashInvalidLen = 2, + /// FLASH_INVALID_LEN + FlashInvalidLen = 2, - /// FLASH_INVALID_ADDR - FlashInvalidAddr = 3, + /// FLASH_INVALID_ADDR + FlashInvalidAddr = 3, - /// FLASH_INVALID_RANGE - FlashInvalidRange = 4, + /// FLASH_INVALID_RANGE + FlashInvalidRange = 4, - /// FLASH_INVALID_SECTOR - FlashInvalidSector = 5, -} + /// FLASH_INVALID_SECTOR + FlashInvalidSector = 5, + } -impl std::fmt::Display for MsgFlashDoneResponseCode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgFlashDoneResponseCode::FlashOk => f.write_str("FLASH_OK"), - MsgFlashDoneResponseCode::FlashInvalidFlash => f.write_str("FLASH_INVALID_FLASH"), - MsgFlashDoneResponseCode::FlashInvalidLen => f.write_str("FLASH_INVALID_LEN"), - MsgFlashDoneResponseCode::FlashInvalidAddr => f.write_str("FLASH_INVALID_ADDR"), - MsgFlashDoneResponseCode::FlashInvalidRange => f.write_str("FLASH_INVALID_RANGE"), - MsgFlashDoneResponseCode::FlashInvalidSector => f.write_str("FLASH_INVALID_SECTOR"), + impl std::fmt::Display for ResponseCode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ResponseCode::FlashOk => f.write_str("FLASH_OK"), + ResponseCode::FlashInvalidFlash => f.write_str("FLASH_INVALID_FLASH"), + ResponseCode::FlashInvalidLen => f.write_str("FLASH_INVALID_LEN"), + ResponseCode::FlashInvalidAddr => f.write_str("FLASH_INVALID_ADDR"), + ResponseCode::FlashInvalidRange => f.write_str("FLASH_INVALID_RANGE"), + ResponseCode::FlashInvalidSector => f.write_str("FLASH_INVALID_SECTOR"), + } } } } -/// Erase sector of device flash memory (host => device) -/// -/// The flash erase message from the host erases a sector of either the STM or -/// M25 onboard flash memory. The device will reply with a MSG_FLASH_DONE -/// message containing the return code - FLASH_OK (0) on success or -/// FLASH_INVALID_FLASH (1) if the flash specified is invalid. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgFlashErase { - /// 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, -} +pub mod msg_flash_erase { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Erase sector of device flash memory (host => device) + /// + /// The flash erase message from the host erases a sector of either the STM or + /// M25 onboard flash memory. The device will reply with a MSG_FLASH_DONE + /// message containing the return code - FLASH_OK (0) on success or + /// FLASH_INVALID_FLASH (1) if the flash specified is invalid. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgFlashErase { + /// 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 { + pub fn flash_target_to_read(&self) -> Option { + match get_bit_range!(self.target, u8, u8, 0, 0) { + 0 => Some(FlashTargetToRead::FlashStm), + 1 => Some(FlashTargetToRead::FlashM25), + _ => None, + } + } -impl MsgFlashErase { - pub fn flash_target_to_read(&self) -> Option { - match get_bit_range!(self.target, u8, u8, 0, 0) { - 0 => Some(MsgFlashEraseFlashTargetToRead::FlashStm), - 1 => Some(MsgFlashEraseFlashTargetToRead::FlashM25), - _ => None, + pub fn set_flash_target_to_read(&mut self, flash_target_to_read: FlashTargetToRead) { + set_bit_range!(&mut self.target, flash_target_to_read, u8, u8, 0, 0); } } - pub fn set_flash_target_to_read( - &mut self, - flash_target_to_read: MsgFlashEraseFlashTargetToRead, - ) { - set_bit_range!(&mut self.target, flash_target_to_read, u8, u8, 0, 0); + impl ConcreteMessage for MsgFlashErase { + const MESSAGE_TYPE: u16 = 226; + const MESSAGE_NAME: &'static str = "MSG_FLASH_ERASE"; } -} - -impl ConcreteMessage for MsgFlashErase { - const MESSAGE_TYPE: u16 = 226; - const MESSAGE_NAME: &'static str = "MSG_FLASH_ERASE"; -} -impl SbpMessage for MsgFlashErase { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgFlashErase { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgFlashErase { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgFlashErase(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgFlashErase { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgFlashErase(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgFlashErase { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.target) + WireFormat::len(&self.sector_num) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.target, buf); - WireFormat::write(&self.sector_num, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgFlashErase { - sender_id: None, - target: WireFormat::parse_unchecked(buf), - sector_num: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgFlashErase { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.target) + WireFormat::len(&self.sector_num) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.target, buf); + WireFormat::write(&self.sector_num, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgFlashErase { + sender_id: None, + target: WireFormat::parse_unchecked(buf), + sector_num: WireFormat::parse_unchecked(buf), + } } } -} -/// Flash target to read -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgFlashEraseFlashTargetToRead { - /// FLASH_STM - FlashStm = 0, + /// Flash target to read + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FlashTargetToRead { + /// FLASH_STM + FlashStm = 0, - /// FLASH_M25 - FlashM25 = 1, -} + /// FLASH_M25 + FlashM25 = 1, + } -impl std::fmt::Display for MsgFlashEraseFlashTargetToRead { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgFlashEraseFlashTargetToRead::FlashStm => f.write_str("FLASH_STM"), - MsgFlashEraseFlashTargetToRead::FlashM25 => f.write_str("FLASH_M25"), + impl std::fmt::Display for FlashTargetToRead { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FlashTargetToRead::FlashStm => f.write_str("FLASH_STM"), + FlashTargetToRead::FlashM25 => f.write_str("FLASH_M25"), + } } } } -/// Program flash addresses -/// -/// The flash program message programs a set of addresses of either the STM or -/// M25 flash. The device replies with either a MSG_FLASH_DONE message -/// containing the return code FLASH_OK (0) on success, or FLASH_INVALID_LEN -/// (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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgFlashProgram { - /// 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 - #[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, -} +pub mod msg_flash_program { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Program flash addresses + /// + /// The flash program message programs a set of addresses of either the STM or + /// M25 flash. The device replies with either a MSG_FLASH_DONE message + /// containing the return code FLASH_OK (0) on success, or FLASH_INVALID_LEN + /// (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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgFlashProgram { + /// 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 + #[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 { + pub fn flash_target_to_read(&self) -> Option { + match get_bit_range!(self.target, u8, u8, 0, 0) { + 0 => Some(FlashTargetToRead::FlashStm), + 1 => Some(FlashTargetToRead::FlashM25), + _ => None, + } + } -impl MsgFlashProgram { - pub fn flash_target_to_read(&self) -> Option { - match get_bit_range!(self.target, u8, u8, 0, 0) { - 0 => Some(MsgFlashProgramFlashTargetToRead::FlashStm), - 1 => Some(MsgFlashProgramFlashTargetToRead::FlashM25), - _ => None, + pub fn set_flash_target_to_read(&mut self, flash_target_to_read: FlashTargetToRead) { + set_bit_range!(&mut self.target, flash_target_to_read, u8, u8, 0, 0); } } - pub fn set_flash_target_to_read( - &mut self, - flash_target_to_read: MsgFlashProgramFlashTargetToRead, - ) { - set_bit_range!(&mut self.target, flash_target_to_read, u8, u8, 0, 0); + impl ConcreteMessage for MsgFlashProgram { + const MESSAGE_TYPE: u16 = 230; + const MESSAGE_NAME: &'static str = "MSG_FLASH_PROGRAM"; } -} -impl ConcreteMessage for MsgFlashProgram { - const MESSAGE_TYPE: u16 = 230; - const MESSAGE_NAME: &'static str = "MSG_FLASH_PROGRAM"; -} - -impl SbpMessage for MsgFlashProgram { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgFlashProgram { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgFlashProgram { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgFlashProgram(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgFlashProgram { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgFlashProgram(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgFlashProgram { - const MIN_LEN: usize = ::MIN_LEN - + <[u8; 3] as WireFormat>::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.target) - + WireFormat::len(&self.addr_start) - + WireFormat::len(&self.addr_len) - + WireFormat::len(&self.data) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgFlashProgram { + const MIN_LEN: usize = ::MIN_LEN + + <[u8; 3] as WireFormat>::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.target) + + WireFormat::len(&self.addr_start) + + WireFormat::len(&self.addr_len) + + WireFormat::len(&self.data) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Flash target to read -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgFlashProgramFlashTargetToRead { - /// FLASH_STM - FlashStm = 0, + /// Flash target to read + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FlashTargetToRead { + /// FLASH_STM + FlashStm = 0, - /// FLASH_M25 - FlashM25 = 1, -} + /// FLASH_M25 + FlashM25 = 1, + } -impl std::fmt::Display for MsgFlashProgramFlashTargetToRead { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgFlashProgramFlashTargetToRead::FlashStm => f.write_str("FLASH_STM"), - MsgFlashProgramFlashTargetToRead::FlashM25 => f.write_str("FLASH_M25"), + impl std::fmt::Display for FlashTargetToRead { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FlashTargetToRead::FlashStm => f.write_str("FLASH_STM"), + FlashTargetToRead::FlashM25 => f.write_str("FLASH_M25"), + } } } } -/// Read STM or M25 flash address request (host => device) -/// -/// The flash read message reads a set of addresses of either the STM or M25 -/// onboard flash. The device replies with a MSG_FLASH_READ_RESP message -/// containing either the read data on success or a MSG_FLASH_DONE message -/// containing the return code FLASH_INVALID_LEN (2) if the maximum read size -/// is exceeded or FLASH_INVALID_ADDR (3) if the address is outside of the -/// allowed range. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgFlashReadReq { - /// 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 - #[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, -} +pub mod msg_flash_read_req { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Read STM or M25 flash address request (host => device) + /// + /// The flash read message reads a set of addresses of either the STM or M25 + /// onboard flash. The device replies with a MSG_FLASH_READ_RESP message + /// containing either the read data on success or a MSG_FLASH_DONE message + /// containing the return code FLASH_INVALID_LEN (2) if the maximum read size + /// is exceeded or FLASH_INVALID_ADDR (3) if the address is outside of the + /// allowed range. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgFlashReadReq { + /// 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 + #[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 { + pub fn flash_target_to_read(&self) -> Option { + match get_bit_range!(self.target, u8, u8, 0, 0) { + 0 => Some(FlashTargetToRead::FlashStm), + 1 => Some(FlashTargetToRead::FlashM25), + _ => None, + } + } -impl MsgFlashReadReq { - pub fn flash_target_to_read(&self) -> Option { - match get_bit_range!(self.target, u8, u8, 0, 0) { - 0 => Some(MsgFlashReadReqFlashTargetToRead::FlashStm), - 1 => Some(MsgFlashReadReqFlashTargetToRead::FlashM25), - _ => None, + pub fn set_flash_target_to_read(&mut self, flash_target_to_read: FlashTargetToRead) { + set_bit_range!(&mut self.target, flash_target_to_read, u8, u8, 0, 0); } } - pub fn set_flash_target_to_read( - &mut self, - flash_target_to_read: MsgFlashReadReqFlashTargetToRead, - ) { - set_bit_range!(&mut self.target, flash_target_to_read, u8, u8, 0, 0); + impl ConcreteMessage for MsgFlashReadReq { + const MESSAGE_TYPE: u16 = 231; + const MESSAGE_NAME: &'static str = "MSG_FLASH_READ_REQ"; } -} - -impl ConcreteMessage for MsgFlashReadReq { - const MESSAGE_TYPE: u16 = 231; - const MESSAGE_NAME: &'static str = "MSG_FLASH_READ_REQ"; -} -impl SbpMessage for MsgFlashReadReq { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgFlashReadReq { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgFlashReadReq { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgFlashReadReq(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgFlashReadReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgFlashReadReq(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgFlashReadReq { - const MIN_LEN: usize = ::MIN_LEN - + <[u8; 3] as WireFormat>::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.target) - + WireFormat::len(&self.addr_start) - + WireFormat::len(&self.addr_len) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.target, buf); - WireFormat::write(&self.addr_start, buf); - WireFormat::write(&self.addr_len, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgFlashReadReq { - sender_id: None, - target: WireFormat::parse_unchecked(buf), - addr_start: WireFormat::parse_unchecked(buf), - addr_len: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgFlashReadReq { + const MIN_LEN: usize = ::MIN_LEN + + <[u8; 3] as WireFormat>::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.target) + + WireFormat::len(&self.addr_start) + + WireFormat::len(&self.addr_len) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.target, buf); + WireFormat::write(&self.addr_start, buf); + WireFormat::write(&self.addr_len, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgFlashReadReq { + sender_id: None, + target: WireFormat::parse_unchecked(buf), + addr_start: WireFormat::parse_unchecked(buf), + addr_len: WireFormat::parse_unchecked(buf), + } } } -} -/// Flash target to read -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgFlashReadReqFlashTargetToRead { - /// FLASH_STM - FlashStm = 0, + /// Flash target to read + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FlashTargetToRead { + /// FLASH_STM + FlashStm = 0, - /// FLASH_M25 - FlashM25 = 1, -} + /// FLASH_M25 + FlashM25 = 1, + } -impl std::fmt::Display for MsgFlashReadReqFlashTargetToRead { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgFlashReadReqFlashTargetToRead::FlashStm => f.write_str("FLASH_STM"), - MsgFlashReadReqFlashTargetToRead::FlashM25 => f.write_str("FLASH_M25"), + impl std::fmt::Display for FlashTargetToRead { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FlashTargetToRead::FlashStm => f.write_str("FLASH_STM"), + FlashTargetToRead::FlashM25 => f.write_str("FLASH_M25"), + } } } } -/// Read STM or M25 flash address response (host <= device) -/// -/// The flash read message reads a set of addresses of either the STM or M25 -/// onboard flash. The device replies with a MSG_FLASH_READ_RESP message -/// containing either the read data on success or a MSG_FLASH_DONE message -/// containing the return code FLASH_INVALID_LEN (2) if the maximum read size -/// is exceeded or FLASH_INVALID_ADDR (3) if the address is outside of the -/// allowed range. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgFlashReadResp { - /// 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 - #[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, -} +pub mod msg_flash_read_resp { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Read STM or M25 flash address response (host <= device) + /// + /// The flash read message reads a set of addresses of either the STM or M25 + /// onboard flash. The device replies with a MSG_FLASH_READ_RESP message + /// containing either the read data on success or a MSG_FLASH_DONE message + /// containing the return code FLASH_INVALID_LEN (2) if the maximum read size + /// is exceeded or FLASH_INVALID_ADDR (3) if the address is outside of the + /// allowed range. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgFlashReadResp { + /// 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 + #[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 { + pub fn flash_target_to_read(&self) -> Option { + match get_bit_range!(self.target, u8, u8, 0, 0) { + 0 => Some(FlashTargetToRead::FlashStm), + 1 => Some(FlashTargetToRead::FlashM25), + _ => None, + } + } -impl MsgFlashReadResp { - pub fn flash_target_to_read(&self) -> Option { - match get_bit_range!(self.target, u8, u8, 0, 0) { - 0 => Some(MsgFlashReadRespFlashTargetToRead::FlashStm), - 1 => Some(MsgFlashReadRespFlashTargetToRead::FlashM25), - _ => None, + pub fn set_flash_target_to_read(&mut self, flash_target_to_read: FlashTargetToRead) { + set_bit_range!(&mut self.target, flash_target_to_read, u8, u8, 0, 0); } } - pub fn set_flash_target_to_read( - &mut self, - flash_target_to_read: MsgFlashReadRespFlashTargetToRead, - ) { - set_bit_range!(&mut self.target, flash_target_to_read, u8, u8, 0, 0); + impl ConcreteMessage for MsgFlashReadResp { + const MESSAGE_TYPE: u16 = 225; + const MESSAGE_NAME: &'static str = "MSG_FLASH_READ_RESP"; } -} -impl ConcreteMessage for MsgFlashReadResp { - const MESSAGE_TYPE: u16 = 225; - const MESSAGE_NAME: &'static str = "MSG_FLASH_READ_RESP"; -} - -impl SbpMessage for MsgFlashReadResp { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgFlashReadResp { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgFlashReadResp { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgFlashReadResp(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgFlashReadResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgFlashReadResp(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgFlashReadResp { - const MIN_LEN: usize = ::MIN_LEN - + <[u8; 3] as WireFormat>::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.target) - + WireFormat::len(&self.addr_start) - + WireFormat::len(&self.addr_len) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.target, buf); - WireFormat::write(&self.addr_start, buf); - WireFormat::write(&self.addr_len, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgFlashReadResp { - sender_id: None, - target: WireFormat::parse_unchecked(buf), - addr_start: WireFormat::parse_unchecked(buf), - addr_len: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgFlashReadResp { + const MIN_LEN: usize = ::MIN_LEN + + <[u8; 3] as WireFormat>::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.target) + + WireFormat::len(&self.addr_start) + + WireFormat::len(&self.addr_len) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.target, buf); + WireFormat::write(&self.addr_start, buf); + WireFormat::write(&self.addr_len, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgFlashReadResp { + sender_id: None, + target: WireFormat::parse_unchecked(buf), + addr_start: WireFormat::parse_unchecked(buf), + addr_len: WireFormat::parse_unchecked(buf), + } } } -} -/// Flash target to read -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgFlashReadRespFlashTargetToRead { - /// FLASH_STM - FlashStm = 0, + /// Flash target to read + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FlashTargetToRead { + /// FLASH_STM + FlashStm = 0, - /// FLASH_M25 - FlashM25 = 1, -} + /// FLASH_M25 + FlashM25 = 1, + } -impl std::fmt::Display for MsgFlashReadRespFlashTargetToRead { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgFlashReadRespFlashTargetToRead::FlashStm => f.write_str("FLASH_STM"), - MsgFlashReadRespFlashTargetToRead::FlashM25 => f.write_str("FLASH_M25"), + impl std::fmt::Display for FlashTargetToRead { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FlashTargetToRead::FlashStm => f.write_str("FLASH_STM"), + FlashTargetToRead::FlashM25 => f.write_str("FLASH_M25"), + } } } } -/// Write M25 flash status register (host => device) -/// -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgM25FlashWriteStatus { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, - /// Byte to write to the M25 flash status register - #[cfg_attr(feature = "serde", serde(rename(serialize = "status")))] - pub status: [u8; 1], -} +pub mod msg_m25_flash_write_status { + #![allow(unused_imports)] -impl ConcreteMessage for MsgM25FlashWriteStatus { - const MESSAGE_TYPE: u16 = 243; - const MESSAGE_NAME: &'static str = "MSG_M25_FLASH_WRITE_STATUS"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgM25FlashWriteStatus { - 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); + /// Write M25 flash status register (host => device) + /// + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgM25FlashWriteStatus { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + /// Byte to write to the M25 flash status register + #[cfg_attr(feature = "serde", serde(rename(serialize = "status")))] + pub status: [u8; 1], } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgM25FlashWriteStatus { + const MESSAGE_TYPE: u16 = 243; + const MESSAGE_NAME: &'static str = "MSG_M25_FLASH_WRITE_STATUS"; } -} -impl TryFrom for MsgM25FlashWriteStatus { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgM25FlashWriteStatus(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgM25FlashWriteStatus { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgM25FlashWriteStatus { - const MIN_LEN: usize = <[u8; 1] as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.status) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.status, buf); + impl TryFrom for MsgM25FlashWriteStatus { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgM25FlashWriteStatus(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgM25FlashWriteStatus { - sender_id: None, - status: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgM25FlashWriteStatus { + const MIN_LEN: usize = <[u8; 1] as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.status) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.status, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgM25FlashWriteStatus { + sender_id: None, + status: WireFormat::parse_unchecked(buf), + } } } } -/// Lock sector of STM flash memory (host => device) -/// -/// The flash lock message locks a sector of the STM flash memory. The device -/// replies with a MSG_FLASH_DONE message. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgStmFlashLockSector { - /// 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, -} +pub mod msg_stm_flash_lock_sector { + #![allow(unused_imports)] -impl ConcreteMessage for MsgStmFlashLockSector { - const MESSAGE_TYPE: u16 = 227; - const MESSAGE_NAME: &'static str = "MSG_STM_FLASH_LOCK_SECTOR"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgStmFlashLockSector { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + /// Lock sector of STM flash memory (host => device) + /// + /// The flash lock message locks a sector of the STM flash memory. The device + /// replies with a MSG_FLASH_DONE message. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgStmFlashLockSector { + /// 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, } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgStmFlashLockSector { + const MESSAGE_TYPE: u16 = 227; + const MESSAGE_NAME: &'static str = "MSG_STM_FLASH_LOCK_SECTOR"; } -} -impl TryFrom for MsgStmFlashLockSector { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgStmFlashLockSector(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgStmFlashLockSector { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgStmFlashLockSector { - const MIN_LEN: usize = ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sector) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sector, buf); + impl TryFrom for MsgStmFlashLockSector { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgStmFlashLockSector(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgStmFlashLockSector { - sender_id: None, - sector: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgStmFlashLockSector { + const MIN_LEN: usize = ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sector) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sector, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgStmFlashLockSector { + sender_id: None, + sector: WireFormat::parse_unchecked(buf), + } } } } -/// Unlock sector of STM flash memory (host => device) -/// -/// The flash unlock message unlocks a sector of the STM flash memory. The -/// device replies with a MSG_FLASH_DONE message. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgStmFlashUnlockSector { - /// 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, -} +pub mod msg_stm_flash_unlock_sector { + #![allow(unused_imports)] -impl ConcreteMessage for MsgStmFlashUnlockSector { - const MESSAGE_TYPE: u16 = 228; - const MESSAGE_NAME: &'static str = "MSG_STM_FLASH_UNLOCK_SECTOR"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgStmFlashUnlockSector { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME + /// Unlock sector of STM flash memory (host => device) + /// + /// The flash unlock message unlocks a sector of the STM flash memory. The + /// device replies with a MSG_FLASH_DONE message. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgStmFlashUnlockSector { + /// 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, } - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgStmFlashUnlockSector { + const MESSAGE_TYPE: u16 = 228; + const MESSAGE_NAME: &'static str = "MSG_STM_FLASH_UNLOCK_SECTOR"; } -} -impl TryFrom for MsgStmFlashUnlockSector { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgStmFlashUnlockSector(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgStmFlashUnlockSector { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgStmFlashUnlockSector { - const MIN_LEN: usize = ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sector) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sector, buf); + impl TryFrom for MsgStmFlashUnlockSector { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgStmFlashUnlockSector(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgStmFlashUnlockSector { - sender_id: None, - sector: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgStmFlashUnlockSector { + const MIN_LEN: usize = ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sector) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sector, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgStmFlashUnlockSector { + sender_id: None, + sector: WireFormat::parse_unchecked(buf), + } } } } -/// Read device's hard-coded unique ID request (host => device) - -/// -/// This message reads the device's hard-coded unique ID. The host requests -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgStmUniqueIdReq { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, -} +pub mod msg_stm_unique_id_req { + #![allow(unused_imports)] -impl ConcreteMessage for MsgStmUniqueIdReq { - const MESSAGE_TYPE: u16 = 232; - const MESSAGE_NAME: &'static str = "MSG_STM_UNIQUE_ID_REQ"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgStmUniqueIdReq { - 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); + /// Read device's hard-coded unique ID request (host => device) + + /// + /// This message reads the device's hard-coded unique ID. The host requests + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgStmUniqueIdReq { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgStmUniqueIdReq { + const MESSAGE_TYPE: u16 = 232; + const MESSAGE_NAME: &'static str = "MSG_STM_UNIQUE_ID_REQ"; } -} -impl TryFrom for MsgStmUniqueIdReq { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgStmUniqueIdReq(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgStmUniqueIdReq { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgStmUniqueIdReq { - const MIN_LEN: usize = 0; - fn len(&self) -> usize { - 0 + impl TryFrom for MsgStmUniqueIdReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgStmUniqueIdReq(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn write(&self, _buf: &mut B) {} - fn parse_unchecked(_buf: &mut B) -> Self { - MsgStmUniqueIdReq { sender_id: None } + + impl WireFormat for MsgStmUniqueIdReq { + const MIN_LEN: usize = 0; + fn len(&self) -> usize { + 0 + } + fn write(&self, _buf: &mut B) {} + fn parse_unchecked(_buf: &mut B) -> Self { + MsgStmUniqueIdReq { sender_id: None } + } } } -/// Read device's hard-coded unique ID response (host <= device) - -/// -/// This message reads the device's hard-coded unique ID. The host requests -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgStmUniqueIdResp { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, - /// Device unique ID - #[cfg_attr(feature = "serde", serde(rename(serialize = "stm_id")))] - pub stm_id: [u8; 12], -} +pub mod msg_stm_unique_id_resp { + #![allow(unused_imports)] -impl ConcreteMessage for MsgStmUniqueIdResp { - const MESSAGE_TYPE: u16 = 229; - const MESSAGE_NAME: &'static str = "MSG_STM_UNIQUE_ID_RESP"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgStmUniqueIdResp { - 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); + /// Read device's hard-coded unique ID response (host <= device) + + /// + /// This message reads the device's hard-coded unique ID. The host requests + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgStmUniqueIdResp { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + /// Device unique ID + #[cfg_attr(feature = "serde", serde(rename(serialize = "stm_id")))] + pub stm_id: [u8; 12], } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgStmUniqueIdResp { + const MESSAGE_TYPE: u16 = 229; + const MESSAGE_NAME: &'static str = "MSG_STM_UNIQUE_ID_RESP"; } -} -impl TryFrom for MsgStmUniqueIdResp { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgStmUniqueIdResp(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgStmUniqueIdResp { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgStmUniqueIdResp { - const MIN_LEN: usize = <[u8; 12] as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.stm_id) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.stm_id, buf); + impl TryFrom for MsgStmUniqueIdResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgStmUniqueIdResp(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgStmUniqueIdResp { - sender_id: None, - stm_id: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgStmUniqueIdResp { + const MIN_LEN: usize = <[u8; 12] as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.stm_id) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.stm_id, buf); + } + fn parse_unchecked(buf: &mut B) -> 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 a5a3116acd..381e0d8af5 100644 --- a/rust/sbp/src/messages/gnss.rs +++ b/rust/sbp/src/messages/gnss.rs @@ -13,393 +13,453 @@ // with generate.py. Please do not hand edit! //****************************************************************************/ //! Various structs shared between modules +pub use carrier_phase::CarrierPhase; +pub use gnss_signal::GnssSignal; +pub use gnss_signal_dep::GnssSignalDep; +pub use gps_time::GpsTime; +pub use gps_time_dep::GpsTimeDep; +pub use gps_time_sec::GpsTimeSec; +pub use sv_id::SvId; -use super::lib::*; - -/// GNSS carrier phase measurement -/// -/// Carrier phase measurement in cycles represented as a 40-bit fixed point -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod carrier_phase { + #![allow(unused_imports)] -impl WireFormat for CarrierPhase { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.i) + WireFormat::len(&self.f) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.i, buf); - WireFormat::write(&self.f, buf); + use super::*; + use crate::messages::lib::*; + + /// GNSS carrier phase measurement + /// + /// Carrier phase measurement in cycles represented as a 40-bit fixed point + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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, } - fn parse_unchecked(buf: &mut B) -> Self { - CarrierPhase { - i: WireFormat::parse_unchecked(buf), - f: WireFormat::parse_unchecked(buf), + + impl WireFormat for CarrierPhase { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.i) + WireFormat::len(&self.f) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.i, buf); + WireFormat::write(&self.f, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + CarrierPhase { + i: WireFormat::parse_unchecked(buf), + f: WireFormat::parse_unchecked(buf), + } } } } -/// Nanosecond-accurate receiver clock time -/// -/// A wire-appropriate receiver clock time, defined as the time since the -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod gps_time { + #![allow(unused_imports)] -impl WireFormat for GpsTime { - const MIN_LEN: usize = - ::MIN_LEN + ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) + WireFormat::len(&self.ns_residual) + WireFormat::len(&self.wn) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.tow, buf); - WireFormat::write(&self.ns_residual, buf); - WireFormat::write(&self.wn, buf); + use super::*; + use crate::messages::lib::*; + + /// Nanosecond-accurate receiver clock time + /// + /// A wire-appropriate receiver clock time, defined as the time since the + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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, } - fn parse_unchecked(buf: &mut B) -> Self { - GpsTime { - tow: WireFormat::parse_unchecked(buf), - ns_residual: WireFormat::parse_unchecked(buf), - wn: WireFormat::parse_unchecked(buf), + + impl WireFormat for GpsTime { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.ns_residual) + + WireFormat::len(&self.wn) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.ns_residual, buf); + WireFormat::write(&self.wn, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + GpsTime { + tow: WireFormat::parse_unchecked(buf), + ns_residual: WireFormat::parse_unchecked(buf), + wn: WireFormat::parse_unchecked(buf), + } } } } -/// Millisecond-accurate GPS time -/// -/// A wire-appropriate GPS time, defined as the number of milliseconds since -/// beginning of the week on the Saturday/Sunday transition. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod gps_time_dep { + #![allow(unused_imports)] -impl WireFormat for GpsTimeDep { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) + WireFormat::len(&self.wn) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.tow, buf); - WireFormat::write(&self.wn, buf); + use super::*; + use crate::messages::lib::*; + + /// Millisecond-accurate GPS time + /// + /// A wire-appropriate GPS time, defined as the number of milliseconds since + /// beginning of the week on the Saturday/Sunday transition. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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, } - fn parse_unchecked(buf: &mut B) -> Self { - GpsTimeDep { - tow: WireFormat::parse_unchecked(buf), - wn: WireFormat::parse_unchecked(buf), + + impl WireFormat for GpsTimeDep { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + WireFormat::len(&self.wn) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.wn, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + GpsTimeDep { + tow: WireFormat::parse_unchecked(buf), + wn: WireFormat::parse_unchecked(buf), + } } } } -/// Whole second accurate GPS time -/// -/// A GPS time, defined as the number of seconds since beginning of the week -/// on the Saturday/Sunday transition. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod gps_time_sec { + #![allow(unused_imports)] -impl WireFormat for GpsTimeSec { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) + WireFormat::len(&self.wn) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.tow, buf); - WireFormat::write(&self.wn, buf); + use super::*; + use crate::messages::lib::*; + + /// Whole second accurate GPS time + /// + /// A GPS time, defined as the number of seconds since beginning of the week + /// on the Saturday/Sunday transition. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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, } - fn parse_unchecked(buf: &mut B) -> Self { - GpsTimeSec { - tow: WireFormat::parse_unchecked(buf), - wn: WireFormat::parse_unchecked(buf), + + impl WireFormat for GpsTimeSec { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + WireFormat::len(&self.wn) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.wn, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + GpsTimeSec { + tow: WireFormat::parse_unchecked(buf), + wn: WireFormat::parse_unchecked(buf), + } } } } -/// Represents all the relevant information about the signal -/// -/// Signal identifier containing constellation, band, and satellite -/// identifier. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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\]. - #[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, -} +pub mod gnss_signal { + #![allow(unused_imports)] -impl GnssSignal { - pub fn code(&self) -> Option { - match get_bit_range!(self.code, u8, u8, 7, 0) { - 0 => Some(GnssSignalcode::GpsL1Ca), - 1 => Some(GnssSignalcode::GpsL2Cm), - 2 => Some(GnssSignalcode::SbasL1Ca), - 3 => Some(GnssSignalcode::GloL1Ca), - 4 => Some(GnssSignalcode::GloL2Ca), - 5 => Some(GnssSignalcode::GpsL1P), - 6 => Some(GnssSignalcode::GpsL2P), - 12 => Some(GnssSignalcode::Bds2B1), - 13 => Some(GnssSignalcode::Bds2B2), - 14 => Some(GnssSignalcode::GalE1B), - 20 => Some(GnssSignalcode::GalE7I), - 47 => Some(GnssSignalcode::Bds3B2A), - _ => None, - } - } + use super::*; + use crate::messages::lib::*; - pub fn set_code(&mut self, code: GnssSignalcode) { - set_bit_range!(&mut self.code, code, u8, u8, 7, 0); + /// Represents all the relevant information about the signal + /// + /// Signal identifier containing constellation, band, and satellite + /// identifier. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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\]. + #[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 WireFormat for GnssSignal { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sat) + WireFormat::len(&self.code) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sat, buf); - WireFormat::write(&self.code, buf); + impl GnssSignal { + pub fn code(&self) -> Option { + match get_bit_range!(self.code, u8, u8, 7, 0) { + 0 => Some(Code::GpsL1Ca), + 1 => Some(Code::GpsL2Cm), + 2 => Some(Code::SbasL1Ca), + 3 => Some(Code::GloL1Ca), + 4 => Some(Code::GloL2Ca), + 5 => Some(Code::GpsL1P), + 6 => Some(Code::GpsL2P), + 12 => Some(Code::Bds2B1), + 13 => Some(Code::Bds2B2), + 14 => Some(Code::GalE1B), + 20 => Some(Code::GalE7I), + 47 => Some(Code::Bds3B2A), + _ => None, + } + } + + pub fn set_code(&mut self, code: Code) { + set_bit_range!(&mut self.code, code, u8, u8, 7, 0); + } } - fn parse_unchecked(buf: &mut B) -> Self { - GnssSignal { - sat: WireFormat::parse_unchecked(buf), - code: WireFormat::parse_unchecked(buf), + + impl WireFormat for GnssSignal { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sat) + WireFormat::len(&self.code) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sat, buf); + WireFormat::write(&self.code, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + GnssSignal { + sat: WireFormat::parse_unchecked(buf), + code: WireFormat::parse_unchecked(buf), + } } } -} -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum GnssSignalcode { - /// GPS L1CA - GpsL1Ca = 0, + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum Code { + /// GPS L1CA + GpsL1Ca = 0, - /// GPS L2CM - GpsL2Cm = 1, + /// GPS L2CM + GpsL2Cm = 1, - /// SBAS L1CA - SbasL1Ca = 2, + /// SBAS L1CA + SbasL1Ca = 2, - /// GLO L1CA - GloL1Ca = 3, + /// GLO L1CA + GloL1Ca = 3, - /// GLO L2CA - GloL2Ca = 4, + /// GLO L2CA + GloL2Ca = 4, - /// GPS L1P - GpsL1P = 5, + /// GPS L1P + GpsL1P = 5, - /// GPS L2P - GpsL2P = 6, + /// GPS L2P + GpsL2P = 6, - /// BDS2 B1 - Bds2B1 = 12, + /// BDS2 B1 + Bds2B1 = 12, - /// BDS2 B2 - Bds2B2 = 13, + /// BDS2 B2 + Bds2B2 = 13, - /// GAL E1B - GalE1B = 14, + /// GAL E1B + GalE1B = 14, - /// GAL E7I - GalE7I = 20, + /// GAL E7I + GalE7I = 20, - /// BDS3 B2a - Bds3B2A = 47, -} + /// BDS3 B2a + Bds3B2A = 47, + } -impl std::fmt::Display for GnssSignalcode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - GnssSignalcode::GpsL1Ca => f.write_str("GPS L1CA"), - GnssSignalcode::GpsL2Cm => f.write_str("GPS L2CM"), - GnssSignalcode::SbasL1Ca => f.write_str("SBAS L1CA"), - GnssSignalcode::GloL1Ca => f.write_str("GLO L1CA"), - GnssSignalcode::GloL2Ca => f.write_str("GLO L2CA"), - GnssSignalcode::GpsL1P => f.write_str("GPS L1P"), - GnssSignalcode::GpsL2P => f.write_str("GPS L2P"), - GnssSignalcode::Bds2B1 => f.write_str("BDS2 B1"), - GnssSignalcode::Bds2B2 => f.write_str("BDS2 B2"), - GnssSignalcode::GalE1B => f.write_str("GAL E1B"), - GnssSignalcode::GalE7I => f.write_str("GAL E7I"), - GnssSignalcode::Bds3B2A => f.write_str("BDS3 B2a"), + impl std::fmt::Display for Code { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Code::GpsL1Ca => f.write_str("GPS L1CA"), + Code::GpsL2Cm => f.write_str("GPS L2CM"), + Code::SbasL1Ca => f.write_str("SBAS L1CA"), + Code::GloL1Ca => f.write_str("GLO L1CA"), + Code::GloL2Ca => f.write_str("GLO L2CA"), + Code::GpsL1P => f.write_str("GPS L1P"), + Code::GpsL2P => f.write_str("GPS L2P"), + Code::Bds2B1 => f.write_str("BDS2 B1"), + Code::Bds2B2 => f.write_str("BDS2 B2"), + Code::GalE1B => f.write_str("GAL E1B"), + Code::GalE7I => f.write_str("GAL E7I"), + Code::Bds3B2A => f.write_str("BDS3 B2a"), + } } } } -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct GnssSignalDep { - /// Constellation-specific satellite identifier. +pub mod gnss_signal_dep { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Deprecated /// - /// 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, -} + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { - pub fn code(&self) -> Option { - match get_bit_range!(self.code, u8, u8, 7, 0) { - 0 => Some(GnssSignalDepcode::GpsL1Ca), - 1 => Some(GnssSignalDepcode::GpsL2Cm), - 2 => Some(GnssSignalDepcode::SbasL1Ca), - 3 => Some(GnssSignalDepcode::GloL1Ca), - 4 => Some(GnssSignalDepcode::GloL2Ca), - 5 => Some(GnssSignalDepcode::GpsL1P), - 6 => Some(GnssSignalDepcode::GpsL2P), - _ => None, + impl GnssSignalDep { + pub fn code(&self) -> Option { + match get_bit_range!(self.code, u8, u8, 7, 0) { + 0 => Some(Code::GpsL1Ca), + 1 => Some(Code::GpsL2Cm), + 2 => Some(Code::SbasL1Ca), + 3 => Some(Code::GloL1Ca), + 4 => Some(Code::GloL2Ca), + 5 => Some(Code::GpsL1P), + 6 => Some(Code::GpsL2P), + _ => None, + } } - } - pub fn set_code(&mut self, code: GnssSignalDepcode) { - set_bit_range!(&mut self.code, code, u8, u8, 7, 0); + pub fn set_code(&mut self, code: Code) { + set_bit_range!(&mut self.code, code, u8, u8, 7, 0); + } } -} -impl WireFormat for GnssSignalDep { - const MIN_LEN: usize = - ::MIN_LEN + ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sat) + WireFormat::len(&self.code) + WireFormat::len(&self.reserved) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sat, buf); - WireFormat::write(&self.code, buf); - WireFormat::write(&self.reserved, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - GnssSignalDep { - sat: WireFormat::parse_unchecked(buf), - code: WireFormat::parse_unchecked(buf), - reserved: WireFormat::parse_unchecked(buf), + impl WireFormat for GnssSignalDep { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sat) + + WireFormat::len(&self.code) + + WireFormat::len(&self.reserved) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sat, buf); + WireFormat::write(&self.code, buf); + WireFormat::write(&self.reserved, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + GnssSignalDep { + sat: WireFormat::parse_unchecked(buf), + code: WireFormat::parse_unchecked(buf), + reserved: WireFormat::parse_unchecked(buf), + } } } -} -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum GnssSignalDepcode { - /// GPS L1CA - GpsL1Ca = 0, + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum Code { + /// GPS L1CA + GpsL1Ca = 0, - /// GPS L2CM - GpsL2Cm = 1, + /// GPS L2CM + GpsL2Cm = 1, - /// SBAS L1CA - SbasL1Ca = 2, + /// SBAS L1CA + SbasL1Ca = 2, - /// GLO L1CA - GloL1Ca = 3, + /// GLO L1CA + GloL1Ca = 3, - /// GLO L2CA - GloL2Ca = 4, + /// GLO L2CA + GloL2Ca = 4, - /// GPS L1P - GpsL1P = 5, + /// GPS L1P + GpsL1P = 5, - /// GPS L2P - GpsL2P = 6, -} + /// GPS L2P + GpsL2P = 6, + } -impl std::fmt::Display for GnssSignalDepcode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - GnssSignalDepcode::GpsL1Ca => f.write_str("GPS L1CA"), - GnssSignalDepcode::GpsL2Cm => f.write_str("GPS L2CM"), - GnssSignalDepcode::SbasL1Ca => f.write_str("SBAS L1CA"), - GnssSignalDepcode::GloL1Ca => f.write_str("GLO L1CA"), - GnssSignalDepcode::GloL2Ca => f.write_str("GLO L2CA"), - GnssSignalDepcode::GpsL1P => f.write_str("GPS L1P"), - GnssSignalDepcode::GpsL2P => f.write_str("GPS L2P"), + impl std::fmt::Display for Code { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Code::GpsL1Ca => f.write_str("GPS L1CA"), + Code::GpsL2Cm => f.write_str("GPS L2CM"), + Code::SbasL1Ca => f.write_str("SBAS L1CA"), + Code::GloL1Ca => f.write_str("GLO L1CA"), + Code::GloL2Ca => f.write_str("GLO L2CA"), + Code::GpsL1P => f.write_str("GPS L1P"), + Code::GpsL2P => f.write_str("GPS L2P"), + } } } } -/// Space vehicle identifier -/// -/// A (Constellation ID, satellite ID) tuple that uniquely identifies a space -/// vehicle. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct SvId { - /// ID of the space vehicle within its constellation - #[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, -} +pub mod sv_id { + #![allow(unused_imports)] -impl WireFormat for SvId { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sat_id) + WireFormat::len(&self.constellation) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sat_id, buf); - WireFormat::write(&self.constellation, buf); + use super::*; + use crate::messages::lib::*; + + /// Space vehicle identifier + /// + /// A (Constellation ID, satellite ID) tuple that uniquely identifies a space + /// vehicle. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct SvId { + /// ID of the space vehicle within its constellation + #[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, } - fn parse_unchecked(buf: &mut B) -> Self { - SvId { - sat_id: WireFormat::parse_unchecked(buf), - constellation: WireFormat::parse_unchecked(buf), + + impl WireFormat for SvId { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sat_id) + WireFormat::len(&self.constellation) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sat_id, buf); + WireFormat::write(&self.constellation, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + SvId { + sat_id: WireFormat::parse_unchecked(buf), + constellation: WireFormat::parse_unchecked(buf), + } } } } diff --git a/rust/sbp/src/messages/imu.rs b/rust/sbp/src/messages/imu.rs index 15d9d8eb08..86b1788d3e 100644 --- a/rust/sbp/src/messages/imu.rs +++ b/rust/sbp/src/messages/imu.rs @@ -13,409 +13,420 @@ // with generate.py. Please do not hand edit! //****************************************************************************/ //! Inertial Measurement Unit (IMU) messages. +pub use msg_imu_aux::MsgImuAux; +pub use msg_imu_raw::MsgImuRaw; + +pub mod msg_imu_aux { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Auxiliary IMU data + /// + /// Auxiliary data specific to a particular IMU. The `imu_type` field will + /// always be consistent but the rest of the payload is device specific and + /// depends on the value of `imu_type`. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgImuAux { + /// 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 { + pub fn imu_type(&self) -> Option { + match get_bit_range!(self.imu_type, u8, u8, 7, 0) { + 0 => Some(ImuType::BoschBmi160), + 1 => Some(ImuType::StMicroelectronicsAsm330Llh), + _ => None, + } + } -use super::lib::*; - -/// Auxiliary IMU data -/// -/// Auxiliary data specific to a particular IMU. The `imu_type` field will -/// always be consistent but the rest of the payload is device specific and -/// depends on the value of `imu_type`. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgImuAux { - /// 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 { - pub fn imu_type(&self) -> Option { - match get_bit_range!(self.imu_type, u8, u8, 7, 0) { - 0 => Some(MsgImuAuxImuType::BoschBmi160), - 1 => Some(MsgImuAuxImuType::StMicroelectronicsAsm330Llh), - _ => None, + pub fn set_imu_type(&mut self, imu_type: ImuType) { + set_bit_range!(&mut self.imu_type, imu_type, u8, u8, 7, 0); } - } - pub fn set_imu_type(&mut self, imu_type: MsgImuAuxImuType) { - set_bit_range!(&mut self.imu_type, imu_type, u8, u8, 7, 0); - } + pub fn gyroscope_range(&self) -> Option { + match get_bit_range!(self.imu_conf, u8, u8, 7, 4) { + 0 => Some(GyroscopeRange::_2000DegS), + 1 => Some(GyroscopeRange::_1000DegS), + 2 => Some(GyroscopeRange::_500DegS), + 3 => Some(GyroscopeRange::_250DegS), + 4 => Some(GyroscopeRange::_125DegS), + _ => None, + } + } - pub fn gyroscope_range(&self) -> Option { - match get_bit_range!(self.imu_conf, u8, u8, 7, 4) { - 0 => Some(MsgImuAuxGyroscopeRange::_2000DegS), - 1 => Some(MsgImuAuxGyroscopeRange::_1000DegS), - 2 => Some(MsgImuAuxGyroscopeRange::_500DegS), - 3 => Some(MsgImuAuxGyroscopeRange::_250DegS), - 4 => Some(MsgImuAuxGyroscopeRange::_125DegS), - _ => None, + pub fn set_gyroscope_range(&mut self, gyroscope_range: GyroscopeRange) { + set_bit_range!(&mut self.imu_conf, gyroscope_range, u8, u8, 7, 4); } - } - pub fn set_gyroscope_range(&mut self, gyroscope_range: MsgImuAuxGyroscopeRange) { - set_bit_range!(&mut self.imu_conf, gyroscope_range, u8, u8, 7, 4); - } + pub fn accelerometer_range(&self) -> Option { + match get_bit_range!(self.imu_conf, u8, u8, 3, 0) { + 0 => Some(AccelerometerRange::_2G), + 1 => Some(AccelerometerRange::_4G), + 2 => Some(AccelerometerRange::_8G), + 3 => Some(AccelerometerRange::_16G), + _ => None, + } + } - pub fn accelerometer_range(&self) -> Option { - match get_bit_range!(self.imu_conf, u8, u8, 3, 0) { - 0 => Some(MsgImuAuxAccelerometerRange::_2G), - 1 => Some(MsgImuAuxAccelerometerRange::_4G), - 2 => Some(MsgImuAuxAccelerometerRange::_8G), - 3 => Some(MsgImuAuxAccelerometerRange::_16G), - _ => None, + pub fn set_accelerometer_range(&mut self, accelerometer_range: AccelerometerRange) { + set_bit_range!(&mut self.imu_conf, accelerometer_range, u8, u8, 3, 0); } } - pub fn set_accelerometer_range(&mut self, accelerometer_range: MsgImuAuxAccelerometerRange) { - set_bit_range!(&mut self.imu_conf, accelerometer_range, u8, u8, 3, 0); + impl ConcreteMessage for MsgImuAux { + const MESSAGE_TYPE: u16 = 2305; + const MESSAGE_NAME: &'static str = "MSG_IMU_AUX"; } -} - -impl ConcreteMessage for MsgImuAux { - const MESSAGE_TYPE: u16 = 2305; - const MESSAGE_NAME: &'static str = "MSG_IMU_AUX"; -} -impl SbpMessage for MsgImuAux { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgImuAux { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgImuAux { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgImuAux(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgImuAux { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgImuAux(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgImuAux { - const MIN_LEN: usize = - ::MIN_LEN + ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.imu_type) - + WireFormat::len(&self.temp) - + WireFormat::len(&self.imu_conf) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.imu_type, buf); - WireFormat::write(&self.temp, buf); - WireFormat::write(&self.imu_conf, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgImuAux { - sender_id: None, - imu_type: WireFormat::parse_unchecked(buf), - temp: WireFormat::parse_unchecked(buf), - imu_conf: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgImuAux { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.imu_type) + + WireFormat::len(&self.temp) + + WireFormat::len(&self.imu_conf) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.imu_type, buf); + WireFormat::write(&self.temp, buf); + WireFormat::write(&self.imu_conf, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgImuAux { + sender_id: None, + imu_type: WireFormat::parse_unchecked(buf), + temp: WireFormat::parse_unchecked(buf), + imu_conf: WireFormat::parse_unchecked(buf), + } } } -} -/// IMU Type -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgImuAuxImuType { - /// Bosch BMI160 - BoschBmi160 = 0, + /// IMU Type + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum ImuType { + /// Bosch BMI160 + BoschBmi160 = 0, - /// ST Microelectronics ASM330LLH - StMicroelectronicsAsm330Llh = 1, -} + /// ST Microelectronics ASM330LLH + StMicroelectronicsAsm330Llh = 1, + } -impl std::fmt::Display for MsgImuAuxImuType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgImuAuxImuType::BoschBmi160 => f.write_str("Bosch BMI160"), - MsgImuAuxImuType::StMicroelectronicsAsm330Llh => { - f.write_str("ST Microelectronics ASM330LLH") + impl std::fmt::Display for ImuType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ImuType::BoschBmi160 => f.write_str("Bosch BMI160"), + ImuType::StMicroelectronicsAsm330Llh => { + f.write_str("ST Microelectronics ASM330LLH") + } } } } -} -/// Gyroscope Range -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgImuAuxGyroscopeRange { - /// +/- 2000 deg / s - _2000DegS = 0, + /// Gyroscope Range + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum GyroscopeRange { + /// +/- 2000 deg / s + _2000DegS = 0, - /// +/- 1000 deg / s - _1000DegS = 1, + /// +/- 1000 deg / s + _1000DegS = 1, - /// +/- 500 deg / s - _500DegS = 2, + /// +/- 500 deg / s + _500DegS = 2, - /// +/- 250 deg / s - _250DegS = 3, + /// +/- 250 deg / s + _250DegS = 3, - /// +/- 125 deg / s - _125DegS = 4, -} + /// +/- 125 deg / s + _125DegS = 4, + } -impl std::fmt::Display for MsgImuAuxGyroscopeRange { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgImuAuxGyroscopeRange::_2000DegS => f.write_str("+/- 2000 deg / s"), - MsgImuAuxGyroscopeRange::_1000DegS => f.write_str("+/- 1000 deg / s"), - MsgImuAuxGyroscopeRange::_500DegS => f.write_str("+/- 500 deg / s"), - MsgImuAuxGyroscopeRange::_250DegS => f.write_str("+/- 250 deg / s"), - MsgImuAuxGyroscopeRange::_125DegS => f.write_str("+/- 125 deg / s"), + impl std::fmt::Display for GyroscopeRange { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + GyroscopeRange::_2000DegS => f.write_str("+/- 2000 deg / s"), + GyroscopeRange::_1000DegS => f.write_str("+/- 1000 deg / s"), + GyroscopeRange::_500DegS => f.write_str("+/- 500 deg / s"), + GyroscopeRange::_250DegS => f.write_str("+/- 250 deg / s"), + GyroscopeRange::_125DegS => f.write_str("+/- 125 deg / s"), + } } } -} -/// Accelerometer Range -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgImuAuxAccelerometerRange { - /// +/- 2g - _2G = 0, + /// Accelerometer Range + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum AccelerometerRange { + /// +/- 2g + _2G = 0, - /// +/- 4g - _4G = 1, + /// +/- 4g + _4G = 1, - /// +/- 8g - _8G = 2, + /// +/- 8g + _8G = 2, - /// +/- 16g - _16G = 3, -} + /// +/- 16g + _16G = 3, + } -impl std::fmt::Display for MsgImuAuxAccelerometerRange { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgImuAuxAccelerometerRange::_2G => f.write_str("+/- 2g"), - MsgImuAuxAccelerometerRange::_4G => f.write_str("+/- 4g"), - MsgImuAuxAccelerometerRange::_8G => f.write_str("+/- 8g"), - MsgImuAuxAccelerometerRange::_16G => f.write_str("+/- 16g"), + impl std::fmt::Display for AccelerometerRange { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + AccelerometerRange::_2G => f.write_str("+/- 2g"), + AccelerometerRange::_4G => f.write_str("+/- 4g"), + AccelerometerRange::_8G => f.write_str("+/- 8g"), + AccelerometerRange::_16G => f.write_str("+/- 16g"), + } } } } -/// Raw IMU data -/// -/// Raw data from the Inertial Measurement Unit, containing accelerometer and -/// gyroscope readings. The sense of the measurements are to be aligned with -/// the indications on the device itself. Measurement units, which are -/// specific to the device hardware and settings, are communicated via the -/// MSG_IMU_AUX message. If using "time since startup" time tags, the -/// receiving end will expect a `MSG_GNSS_TIME_OFFSET` when a PVT fix becomes -/// available to synchronise IMU measurements with GNSS. The timestamp must -/// wrap around to zero when reaching one week (604800 seconds). -/// -/// The time-tagging mode should not change throughout a run. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgImuRaw { - /// 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, -} +pub mod msg_imu_raw { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Raw IMU data + /// + /// Raw data from the Inertial Measurement Unit, containing accelerometer and + /// gyroscope readings. The sense of the measurements are to be aligned with + /// the indications on the device itself. Measurement units, which are + /// specific to the device hardware and settings, are communicated via the + /// MSG_IMU_AUX message. If using "time since startup" time tags, the + /// receiving end will expect a `MSG_GNSS_TIME_OFFSET` when a PVT fix becomes + /// available to synchronise IMU measurements with GNSS. The timestamp must + /// wrap around to zero when reaching one week (604800 seconds). + /// + /// The time-tagging mode should not change throughout a run. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgImuRaw { + /// 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 { + pub fn time_status(&self) -> Option { + match get_bit_range!(self.tow, u32, u8, 31, 30) { + 0 => Some(TimeStatus::ReferenceEpochIsStartOfCurrentGpsWeek), + 1 => Some(TimeStatus::ReferenceEpochIsTimeOfSystemStartup), + 2 => Some(TimeStatus::ReferenceEpochIsUnknown), + 3 => Some(TimeStatus::ReferenceEpochIsLastPps), + _ => None, + } + } -impl MsgImuRaw { - pub fn time_status(&self) -> Option { - match get_bit_range!(self.tow, u32, u8, 31, 30) { - 0 => Some(MsgImuRawTimeStatus::ReferenceEpochIsStartOfCurrentGpsWeek), - 1 => Some(MsgImuRawTimeStatus::ReferenceEpochIsTimeOfSystemStartup), - 2 => Some(MsgImuRawTimeStatus::ReferenceEpochIsUnknown), - 3 => Some(MsgImuRawTimeStatus::ReferenceEpochIsLastPps), - _ => None, + pub fn set_time_status(&mut self, time_status: TimeStatus) { + set_bit_range!(&mut self.tow, time_status, u32, u8, 31, 30); } - } - pub fn set_time_status(&mut self, time_status: MsgImuRawTimeStatus) { - set_bit_range!(&mut self.tow, time_status, u32, u8, 31, 30); - } + pub fn time_since_reference_epoch_in_milliseconds(&self) -> u32 { + get_bit_range!(self.tow, u32, u32, 29, 0) + } - pub fn time_since_reference_epoch_in_milliseconds(&self) -> u32 { - get_bit_range!(self.tow, u32, u32, 29, 0) + pub fn set_time_since_reference_epoch_in_milliseconds( + &mut self, + time_since_reference_epoch_in_milliseconds: u32, + ) { + set_bit_range!( + &mut self.tow, + time_since_reference_epoch_in_milliseconds, + u32, + u32, + 29, + 0 + ); + } } - pub fn set_time_since_reference_epoch_in_milliseconds( - &mut self, - time_since_reference_epoch_in_milliseconds: u32, - ) { - set_bit_range!( - &mut self.tow, - time_since_reference_epoch_in_milliseconds, - u32, - u32, - 29, - 0 - ); + impl ConcreteMessage for MsgImuRaw { + const MESSAGE_TYPE: u16 = 2304; + const MESSAGE_NAME: &'static str = "MSG_IMU_RAW"; } -} - -impl ConcreteMessage for MsgImuRaw { - const MESSAGE_TYPE: u16 = 2304; - const MESSAGE_NAME: &'static str = "MSG_IMU_RAW"; -} -impl SbpMessage for MsgImuRaw { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - 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 time::GpsTime::new(0, tow_s) { - Ok(gps_time) => gps_time.tow(), - Err(e) => return Some(Err(e.into())), - }; - Some(Ok(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgImuRaw { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + 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 time::GpsTime::new(0, tow_s) { + Ok(gps_time) => gps_time.tow(), + Err(e) => return Some(Err(e.into())), + }; + Some(Ok(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgImuRaw { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgImuRaw(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgImuRaw { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgImuRaw(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgImuRaw { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.tow_f) - + WireFormat::len(&self.acc_x) - + WireFormat::len(&self.acc_y) - + WireFormat::len(&self.acc_z) - + WireFormat::len(&self.gyr_x) - + WireFormat::len(&self.gyr_y) - + WireFormat::len(&self.gyr_z) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgImuRaw { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.tow_f) + + WireFormat::len(&self.acc_x) + + WireFormat::len(&self.acc_y) + + WireFormat::len(&self.acc_z) + + WireFormat::len(&self.gyr_x) + + WireFormat::len(&self.gyr_y) + + WireFormat::len(&self.gyr_z) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Time status -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgImuRawTimeStatus { - /// Reference epoch is start of current GPS week - ReferenceEpochIsStartOfCurrentGpsWeek = 0, + /// Time status + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TimeStatus { + /// Reference epoch is start of current GPS week + ReferenceEpochIsStartOfCurrentGpsWeek = 0, - /// Reference epoch is time of system startup - ReferenceEpochIsTimeOfSystemStartup = 1, + /// Reference epoch is time of system startup + ReferenceEpochIsTimeOfSystemStartup = 1, - /// Reference epoch is unknown - ReferenceEpochIsUnknown = 2, + /// Reference epoch is unknown + ReferenceEpochIsUnknown = 2, - /// Reference epoch is last PPS - ReferenceEpochIsLastPps = 3, -} + /// Reference epoch is last PPS + ReferenceEpochIsLastPps = 3, + } -impl std::fmt::Display for MsgImuRawTimeStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgImuRawTimeStatus::ReferenceEpochIsStartOfCurrentGpsWeek => { - f.write_str("Reference epoch is start of current GPS week") - } - MsgImuRawTimeStatus::ReferenceEpochIsTimeOfSystemStartup => { - f.write_str("Reference epoch is time of system startup") - } - MsgImuRawTimeStatus::ReferenceEpochIsUnknown => { - f.write_str("Reference epoch is unknown") - } - MsgImuRawTimeStatus::ReferenceEpochIsLastPps => { - f.write_str("Reference epoch is last PPS") + impl std::fmt::Display for TimeStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TimeStatus::ReferenceEpochIsStartOfCurrentGpsWeek => { + f.write_str("Reference epoch is start of current GPS week") + } + TimeStatus::ReferenceEpochIsTimeOfSystemStartup => { + f.write_str("Reference epoch is time of system startup") + } + TimeStatus::ReferenceEpochIsUnknown => f.write_str("Reference epoch is unknown"), + TimeStatus::ReferenceEpochIsLastPps => f.write_str("Reference epoch is last PPS"), } } } diff --git a/rust/sbp/src/messages/linux.rs b/rust/sbp/src/messages/linux.rs index 144d461857..dc359f041b 100644 --- a/rust/sbp/src/messages/linux.rs +++ b/rust/sbp/src/messages/linux.rs @@ -13,1198 +13,1272 @@ // with generate.py. Please do not hand edit! //****************************************************************************/ //! Linux state monitoring. +pub use msg_linux_cpu_state::MsgLinuxCpuState; +pub use msg_linux_cpu_state_dep_a::MsgLinuxCpuStateDepA; +pub use msg_linux_mem_state::MsgLinuxMemState; +pub use msg_linux_mem_state_dep_a::MsgLinuxMemStateDepA; +pub use msg_linux_process_fd_count::MsgLinuxProcessFdCount; +pub use msg_linux_process_fd_summary::MsgLinuxProcessFdSummary; +pub use msg_linux_process_socket_counts::MsgLinuxProcessSocketCounts; +pub use msg_linux_process_socket_queues::MsgLinuxProcessSocketQueues; +pub use msg_linux_socket_usage::MsgLinuxSocketUsage; +pub use msg_linux_sys_state::MsgLinuxSysState; +pub use msg_linux_sys_state_dep_a::MsgLinuxSysStateDepA; + +pub mod msg_linux_cpu_state { + #![allow(unused_imports)] + + use super::*; + use crate::messages::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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgLinuxCpuState { + /// 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 + #[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) + #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] + pub cmdline: SbpString, Unterminated>, + } + + impl MsgLinuxCpuState { + pub fn timestamp_type(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(TimestampType::SystemTimeInSeconds), + 1 => Some(TimestampType::GpsTowInMilliseconds), + _ => None, + } + } -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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgLinuxCpuState { - /// 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 - #[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) - #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] - pub cmdline: SbpString, Unterminated>, -} - -impl MsgLinuxCpuState { - pub fn timestamp_type(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgLinuxCpuStateTimestampType::SystemTimeInSeconds), - 1 => Some(MsgLinuxCpuStateTimestampType::GpsTowInMilliseconds), - _ => None, + pub fn set_timestamp_type(&mut self, timestamp_type: TimestampType) { + set_bit_range!(&mut self.flags, timestamp_type, u8, u8, 2, 0); } } - pub fn set_timestamp_type(&mut self, timestamp_type: MsgLinuxCpuStateTimestampType) { - set_bit_range!(&mut self.flags, timestamp_type, u8, u8, 2, 0); + impl ConcreteMessage for MsgLinuxCpuState { + const MESSAGE_TYPE: u16 = 32520; + const MESSAGE_NAME: &'static str = "MSG_LINUX_CPU_STATE"; } -} - -impl ConcreteMessage for MsgLinuxCpuState { - const MESSAGE_TYPE: u16 = 32520; - const MESSAGE_NAME: &'static str = "MSG_LINUX_CPU_STATE"; -} -impl SbpMessage for MsgLinuxCpuState { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgLinuxCpuState { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgLinuxCpuState { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgLinuxCpuState(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgLinuxCpuState { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgLinuxCpuState(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgLinuxCpuState { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN - + , Unterminated> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.index) - + WireFormat::len(&self.pid) - + WireFormat::len(&self.pcpu) - + WireFormat::len(&self.time) - + WireFormat::len(&self.flags) - + WireFormat::len(&self.tname) - + WireFormat::len(&self.cmdline) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgLinuxCpuState { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN + + , Unterminated> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.index) + + WireFormat::len(&self.pid) + + WireFormat::len(&self.pcpu) + + WireFormat::len(&self.time) + + WireFormat::len(&self.flags) + + WireFormat::len(&self.tname) + + WireFormat::len(&self.cmdline) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// timestamp type -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgLinuxCpuStateTimestampType { - /// System time in seconds - SystemTimeInSeconds = 0, + /// timestamp type + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TimestampType { + /// System time in seconds + SystemTimeInSeconds = 0, - /// GPS TOW in milliseconds - GpsTowInMilliseconds = 1, -} + /// GPS TOW in milliseconds + GpsTowInMilliseconds = 1, + } -impl std::fmt::Display for MsgLinuxCpuStateTimestampType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgLinuxCpuStateTimestampType::SystemTimeInSeconds => { - f.write_str("System time in seconds") - } - MsgLinuxCpuStateTimestampType::GpsTowInMilliseconds => { - f.write_str("GPS TOW in milliseconds") + impl std::fmt::Display for TimestampType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TimestampType::SystemTimeInSeconds => f.write_str("System time in seconds"), + TimestampType::GpsTowInMilliseconds => f.write_str("GPS TOW in milliseconds"), } } } } -/// List CPU state on the system. DEPRECATED -/// -/// This message indicates the process state of the top 10 heaviest consumers -/// of CPU on the system. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgLinuxCpuStateDepA { - /// 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 - #[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) - #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] - pub cmdline: SbpString, Unterminated>, -} - -impl ConcreteMessage for MsgLinuxCpuStateDepA { - const MESSAGE_TYPE: u16 = 32512; - const MESSAGE_NAME: &'static str = "MSG_LINUX_CPU_STATE_DEP_A"; -} - -impl SbpMessage for MsgLinuxCpuStateDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_linux_cpu_state_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// List CPU state on the system. DEPRECATED + /// + /// This message indicates the process state of the top 10 heaviest consumers + /// of CPU on the system. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgLinuxCpuStateDepA { + /// 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 + #[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) + #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] + pub cmdline: SbpString, Unterminated>, + } + + impl ConcreteMessage for MsgLinuxCpuStateDepA { + const MESSAGE_TYPE: u16 = 32512; + const MESSAGE_NAME: &'static str = "MSG_LINUX_CPU_STATE_DEP_A"; + } + + impl SbpMessage for MsgLinuxCpuStateDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgLinuxCpuStateDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgLinuxCpuStateDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgLinuxCpuStateDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgLinuxCpuStateDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgLinuxCpuStateDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN - + , Unterminated> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.index) - + WireFormat::len(&self.pid) - + WireFormat::len(&self.pcpu) - + WireFormat::len(&self.tname) - + WireFormat::len(&self.cmdline) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgLinuxCpuStateDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN + + , Unterminated> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.index) + + WireFormat::len(&self.pid) + + WireFormat::len(&self.pcpu) + + WireFormat::len(&self.tname) + + WireFormat::len(&self.cmdline) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// List memory state on the system -/// -/// This message indicates the process state of the top 10 heaviest consumers -/// of memory on the system, including a timestamp. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgLinuxMemState { - /// 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 - #[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) - #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] - pub cmdline: SbpString, Unterminated>, -} +pub mod msg_linux_mem_state { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// List memory state on the system + /// + /// This message indicates the process state of the top 10 heaviest consumers + /// of memory on the system, including a timestamp. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgLinuxMemState { + /// 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 + #[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) + #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] + pub cmdline: SbpString, Unterminated>, + } + + impl MsgLinuxMemState { + pub fn timestamp_type(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(TimestampType::SystemTimeInSeconds), + 1 => Some(TimestampType::GpsTowInMilliseconds), + _ => None, + } + } -impl MsgLinuxMemState { - pub fn timestamp_type(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgLinuxMemStateTimestampType::SystemTimeInSeconds), - 1 => Some(MsgLinuxMemStateTimestampType::GpsTowInMilliseconds), - _ => None, + pub fn set_timestamp_type(&mut self, timestamp_type: TimestampType) { + set_bit_range!(&mut self.flags, timestamp_type, u8, u8, 2, 0); } } - pub fn set_timestamp_type(&mut self, timestamp_type: MsgLinuxMemStateTimestampType) { - set_bit_range!(&mut self.flags, timestamp_type, u8, u8, 2, 0); + impl ConcreteMessage for MsgLinuxMemState { + const MESSAGE_TYPE: u16 = 32521; + const MESSAGE_NAME: &'static str = "MSG_LINUX_MEM_STATE"; } -} - -impl ConcreteMessage for MsgLinuxMemState { - const MESSAGE_TYPE: u16 = 32521; - const MESSAGE_NAME: &'static str = "MSG_LINUX_MEM_STATE"; -} -impl SbpMessage for MsgLinuxMemState { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgLinuxMemState { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgLinuxMemState { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgLinuxMemState(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgLinuxMemState { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgLinuxMemState(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgLinuxMemState { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN - + , Unterminated> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.index) - + WireFormat::len(&self.pid) - + WireFormat::len(&self.pmem) - + WireFormat::len(&self.time) - + WireFormat::len(&self.flags) - + WireFormat::len(&self.tname) - + WireFormat::len(&self.cmdline) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgLinuxMemState { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN + + , Unterminated> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.index) + + WireFormat::len(&self.pid) + + WireFormat::len(&self.pmem) + + WireFormat::len(&self.time) + + WireFormat::len(&self.flags) + + WireFormat::len(&self.tname) + + WireFormat::len(&self.cmdline) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// timestamp type -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgLinuxMemStateTimestampType { - /// System time in seconds - SystemTimeInSeconds = 0, + /// timestamp type + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TimestampType { + /// System time in seconds + SystemTimeInSeconds = 0, - /// GPS TOW in milliseconds - GpsTowInMilliseconds = 1, -} + /// GPS TOW in milliseconds + GpsTowInMilliseconds = 1, + } -impl std::fmt::Display for MsgLinuxMemStateTimestampType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgLinuxMemStateTimestampType::SystemTimeInSeconds => { - f.write_str("System time in seconds") - } - MsgLinuxMemStateTimestampType::GpsTowInMilliseconds => { - f.write_str("GPS TOW in milliseconds") + impl std::fmt::Display for TimestampType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TimestampType::SystemTimeInSeconds => f.write_str("System time in seconds"), + TimestampType::GpsTowInMilliseconds => f.write_str("GPS TOW in milliseconds"), } } } } -/// List memory state on the system. DEPRECATED -/// -/// This message indicates the process state of the top 10 heaviest consumers -/// of memory on the system. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgLinuxMemStateDepA { - /// 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 - #[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) - #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] - pub cmdline: SbpString, Unterminated>, -} - -impl ConcreteMessage for MsgLinuxMemStateDepA { - const MESSAGE_TYPE: u16 = 32513; - const MESSAGE_NAME: &'static str = "MSG_LINUX_MEM_STATE_DEP_A"; -} - -impl SbpMessage for MsgLinuxMemStateDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_linux_mem_state_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// List memory state on the system. DEPRECATED + /// + /// This message indicates the process state of the top 10 heaviest consumers + /// of memory on the system. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgLinuxMemStateDepA { + /// 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 + #[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) + #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] + pub cmdline: SbpString, Unterminated>, + } + + impl ConcreteMessage for MsgLinuxMemStateDepA { + const MESSAGE_TYPE: u16 = 32513; + const MESSAGE_NAME: &'static str = "MSG_LINUX_MEM_STATE_DEP_A"; + } + + impl SbpMessage for MsgLinuxMemStateDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgLinuxMemStateDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgLinuxMemStateDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgLinuxMemStateDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgLinuxMemStateDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgLinuxMemStateDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN - + , Unterminated> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.index) - + WireFormat::len(&self.pid) - + WireFormat::len(&self.pmem) - + WireFormat::len(&self.tname) - + WireFormat::len(&self.cmdline) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgLinuxMemStateDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN + + , Unterminated> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.index) + + WireFormat::len(&self.pid) + + WireFormat::len(&self.pmem) + + WireFormat::len(&self.tname) + + WireFormat::len(&self.cmdline) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Summary of processes with large amounts of open file descriptors -/// -/// Top 10 list of processes with a large number of open file descriptors. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgLinuxProcessFdCount { - /// 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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] - pub cmdline: SbpString, Unterminated>, -} - -impl ConcreteMessage for MsgLinuxProcessFdCount { - const MESSAGE_TYPE: u16 = 32518; - const MESSAGE_NAME: &'static str = "MSG_LINUX_PROCESS_FD_COUNT"; -} - -impl SbpMessage for MsgLinuxProcessFdCount { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_linux_process_fd_count { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Summary of processes with large amounts of open file descriptors + /// + /// Top 10 list of processes with a large number of open file descriptors. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgLinuxProcessFdCount { + /// 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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] + pub cmdline: SbpString, Unterminated>, + } + + impl ConcreteMessage for MsgLinuxProcessFdCount { + const MESSAGE_TYPE: u16 = 32518; + const MESSAGE_NAME: &'static str = "MSG_LINUX_PROCESS_FD_COUNT"; + } + + impl SbpMessage for MsgLinuxProcessFdCount { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgLinuxProcessFdCount { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgLinuxProcessFdCount(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgLinuxProcessFdCount { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgLinuxProcessFdCount(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgLinuxProcessFdCount { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + , Unterminated> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.index) - + WireFormat::len(&self.pid) - + WireFormat::len(&self.fd_count) - + WireFormat::len(&self.cmdline) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgLinuxProcessFdCount { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + , Unterminated> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.index) + + WireFormat::len(&self.pid) + + WireFormat::len(&self.fd_count) + + WireFormat::len(&self.cmdline) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Summary of open file descriptors on the system -/// -/// Summary of open file descriptors on the system. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgLinuxProcessFdSummary { - /// 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. - #[cfg_attr(feature = "serde", serde(rename(serialize = "most_opened")))] - pub most_opened: SbpString, DoubleNullTerminated>, -} +pub mod msg_linux_process_fd_summary { + #![allow(unused_imports)] -impl ConcreteMessage for MsgLinuxProcessFdSummary { - const MESSAGE_TYPE: u16 = 32519; - const MESSAGE_NAME: &'static str = "MSG_LINUX_PROCESS_FD_SUMMARY"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgLinuxProcessFdSummary { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE + /// Summary of open file descriptors on the system + /// + /// Summary of open file descriptors on the system. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgLinuxProcessFdSummary { + /// 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. + #[cfg_attr(feature = "serde", serde(rename(serialize = "most_opened")))] + pub most_opened: SbpString, DoubleNullTerminated>, } - fn sender_id(&self) -> Option { - self.sender_id - } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgLinuxProcessFdSummary { + const MESSAGE_TYPE: u16 = 32519; + const MESSAGE_NAME: &'static str = "MSG_LINUX_PROCESS_FD_SUMMARY"; } -} -impl TryFrom for MsgLinuxProcessFdSummary { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgLinuxProcessFdSummary(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgLinuxProcessFdSummary { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgLinuxProcessFdSummary { - const MIN_LEN: usize = ::MIN_LEN - + , DoubleNullTerminated> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sys_fd_count) + WireFormat::len(&self.most_opened) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sys_fd_count, buf); - WireFormat::write(&self.most_opened, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgLinuxProcessFdSummary { - sender_id: None, - sys_fd_count: WireFormat::parse_unchecked(buf), - most_opened: WireFormat::parse_unchecked(buf), + impl TryFrom for MsgLinuxProcessFdSummary { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgLinuxProcessFdSummary(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} - -/// A list of processes with high socket counts -/// -/// Top 10 list of processes with high socket counts. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgLinuxProcessSocketCounts { - /// 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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] - pub cmdline: SbpString, Unterminated>, -} -impl ConcreteMessage for MsgLinuxProcessSocketCounts { - const MESSAGE_TYPE: u16 = 32515; - const MESSAGE_NAME: &'static str = "MSG_LINUX_PROCESS_SOCKET_COUNTS"; -} - -impl SbpMessage for MsgLinuxProcessSocketCounts { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl WireFormat for MsgLinuxProcessFdSummary { + const MIN_LEN: usize = ::MIN_LEN + + , DoubleNullTerminated> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sys_fd_count) + WireFormat::len(&self.most_opened) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sys_fd_count, buf); + WireFormat::write(&self.most_opened, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgLinuxProcessFdSummary { + sender_id: None, + sys_fd_count: WireFormat::parse_unchecked(buf), + most_opened: WireFormat::parse_unchecked(buf), + } + } } } -impl TryFrom for MsgLinuxProcessSocketCounts { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgLinuxProcessSocketCounts(m) => Ok(m), - _ => Err(TryFromSbpError), +pub mod msg_linux_process_socket_counts { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// A list of processes with high socket counts + /// + /// Top 10 list of processes with high socket counts. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgLinuxProcessSocketCounts { + /// 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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] + pub cmdline: SbpString, Unterminated>, + } + + impl ConcreteMessage for MsgLinuxProcessSocketCounts { + const MESSAGE_TYPE: u16 = 32515; + const MESSAGE_NAME: &'static str = "MSG_LINUX_PROCESS_SOCKET_COUNTS"; + } + + impl SbpMessage for MsgLinuxProcessSocketCounts { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgLinuxProcessSocketCounts { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + , Unterminated> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.index) - + WireFormat::len(&self.pid) - + WireFormat::len(&self.socket_count) - + WireFormat::len(&self.socket_types) - + WireFormat::len(&self.socket_states) - + WireFormat::len(&self.cmdline) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl TryFrom for MsgLinuxProcessSocketCounts { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgLinuxProcessSocketCounts(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -/// A list of processes with deep socket queues -/// -/// Top 10 list of sockets with deep queues. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgLinuxProcessSocketQueues { - /// 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. - #[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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] - pub cmdline: SbpString, Unterminated>, -} - -impl ConcreteMessage for MsgLinuxProcessSocketQueues { - const MESSAGE_TYPE: u16 = 32516; - const MESSAGE_NAME: &'static str = "MSG_LINUX_PROCESS_SOCKET_QUEUES"; -} - -impl SbpMessage for MsgLinuxProcessSocketQueues { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl WireFormat for MsgLinuxProcessSocketCounts { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + , Unterminated> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.index) + + WireFormat::len(&self.pid) + + WireFormat::len(&self.socket_count) + + WireFormat::len(&self.socket_types) + + WireFormat::len(&self.socket_states) + + WireFormat::len(&self.cmdline) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } + } } } -impl TryFrom for MsgLinuxProcessSocketQueues { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgLinuxProcessSocketQueues(m) => Ok(m), - _ => Err(TryFromSbpError), +pub mod msg_linux_process_socket_queues { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// A list of processes with deep socket queues + /// + /// Top 10 list of sockets with deep queues. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgLinuxProcessSocketQueues { + /// 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. + #[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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "cmdline")))] + pub cmdline: SbpString, Unterminated>, + } + + impl ConcreteMessage for MsgLinuxProcessSocketQueues { + const MESSAGE_TYPE: u16 = 32516; + const MESSAGE_NAME: &'static str = "MSG_LINUX_PROCESS_SOCKET_QUEUES"; + } + + impl SbpMessage for MsgLinuxProcessSocketQueues { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgLinuxProcessSocketQueues { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN - + , Unterminated> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.index) - + WireFormat::len(&self.pid) - + WireFormat::len(&self.recv_queued) - + WireFormat::len(&self.send_queued) - + WireFormat::len(&self.socket_types) - + WireFormat::len(&self.socket_states) - + WireFormat::len(&self.address_of_largest) - + WireFormat::len(&self.cmdline) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl TryFrom for MsgLinuxProcessSocketQueues { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgLinuxProcessSocketQueues(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} - -/// Summary of socket usage across the system -/// -/// Summaries the socket usage across the system. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgLinuxSocketUsage { - /// 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`. - #[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`. - #[cfg_attr(feature = "serde", serde(rename(serialize = "socket_type_counts")))] - pub socket_type_counts: [u16; 16], -} -impl ConcreteMessage for MsgLinuxSocketUsage { - const MESSAGE_TYPE: u16 = 32517; - const MESSAGE_NAME: &'static str = "MSG_LINUX_SOCKET_USAGE"; + impl WireFormat for MsgLinuxProcessSocketQueues { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN + + , Unterminated> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.index) + + WireFormat::len(&self.pid) + + WireFormat::len(&self.recv_queued) + + WireFormat::len(&self.send_queued) + + WireFormat::len(&self.socket_types) + + WireFormat::len(&self.socket_states) + + WireFormat::len(&self.address_of_largest) + + WireFormat::len(&self.cmdline) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } + } + } } -impl SbpMessage for MsgLinuxSocketUsage { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_linux_socket_usage { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Summary of socket usage across the system + /// + /// Summaries the socket usage across the system. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgLinuxSocketUsage { + /// 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`. + #[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`. + #[cfg_attr(feature = "serde", serde(rename(serialize = "socket_type_counts")))] + pub socket_type_counts: [u16; 16], + } + + impl ConcreteMessage for MsgLinuxSocketUsage { + const MESSAGE_TYPE: u16 = 32517; + const MESSAGE_NAME: &'static str = "MSG_LINUX_SOCKET_USAGE"; + } + + impl SbpMessage for MsgLinuxSocketUsage { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgLinuxSocketUsage { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgLinuxSocketUsage(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgLinuxSocketUsage { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgLinuxSocketUsage(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgLinuxSocketUsage { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + <[u16; 16] as WireFormat>::MIN_LEN - + <[u16; 16] as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.avg_queue_depth) - + WireFormat::len(&self.max_queue_depth) - + WireFormat::len(&self.socket_state_counts) - + WireFormat::len(&self.socket_type_counts) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgLinuxSocketUsage { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + <[u16; 16] as WireFormat>::MIN_LEN + + <[u16; 16] as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.avg_queue_depth) + + WireFormat::len(&self.max_queue_depth) + + WireFormat::len(&self.socket_state_counts) + + WireFormat::len(&self.socket_type_counts) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// CPU, Memory and Process Starts/Stops -/// -/// This presents a summary of CPU and memory utilization, including a -/// timestamp. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgLinuxSysState { - /// 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, -} +pub mod msg_linux_sys_state { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// CPU, Memory and Process Starts/Stops + /// + /// This presents a summary of CPU and memory utilization, including a + /// timestamp. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgLinuxSysState { + /// 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 { + pub fn timestamp_type(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(TimestampType::SystemTimeInSeconds), + 1 => Some(TimestampType::GpsTowInMilliseconds), + _ => None, + } + } -impl MsgLinuxSysState { - pub fn timestamp_type(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgLinuxSysStateTimestampType::SystemTimeInSeconds), - 1 => Some(MsgLinuxSysStateTimestampType::GpsTowInMilliseconds), - _ => None, + pub fn set_timestamp_type(&mut self, timestamp_type: TimestampType) { + set_bit_range!(&mut self.flags, timestamp_type, u8, u8, 2, 0); } } - pub fn set_timestamp_type(&mut self, timestamp_type: MsgLinuxSysStateTimestampType) { - set_bit_range!(&mut self.flags, timestamp_type, u8, u8, 2, 0); + impl ConcreteMessage for MsgLinuxSysState { + const MESSAGE_TYPE: u16 = 32522; + const MESSAGE_NAME: &'static str = "MSG_LINUX_SYS_STATE"; } -} - -impl ConcreteMessage for MsgLinuxSysState { - const MESSAGE_TYPE: u16 = 32522; - const MESSAGE_NAME: &'static str = "MSG_LINUX_SYS_STATE"; -} -impl SbpMessage for MsgLinuxSysState { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgLinuxSysState { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgLinuxSysState { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgLinuxSysState(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgLinuxSysState { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgLinuxSysState(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgLinuxSysState { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.mem_total) - + WireFormat::len(&self.pcpu) - + WireFormat::len(&self.pmem) - + WireFormat::len(&self.procs_starting) - + WireFormat::len(&self.procs_stopping) - + WireFormat::len(&self.pid_count) - + WireFormat::len(&self.time) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgLinuxSysState { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.mem_total) + + WireFormat::len(&self.pcpu) + + WireFormat::len(&self.pmem) + + WireFormat::len(&self.procs_starting) + + WireFormat::len(&self.procs_stopping) + + WireFormat::len(&self.pid_count) + + WireFormat::len(&self.time) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// timestamp type -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgLinuxSysStateTimestampType { - /// System time in seconds - SystemTimeInSeconds = 0, + /// timestamp type + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TimestampType { + /// System time in seconds + SystemTimeInSeconds = 0, - /// GPS TOW in milliseconds - GpsTowInMilliseconds = 1, -} + /// GPS TOW in milliseconds + GpsTowInMilliseconds = 1, + } -impl std::fmt::Display for MsgLinuxSysStateTimestampType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgLinuxSysStateTimestampType::SystemTimeInSeconds => { - f.write_str("System time in seconds") - } - MsgLinuxSysStateTimestampType::GpsTowInMilliseconds => { - f.write_str("GPS TOW in milliseconds") + impl std::fmt::Display for TimestampType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TimestampType::SystemTimeInSeconds => f.write_str("System time in seconds"), + TimestampType::GpsTowInMilliseconds => f.write_str("GPS TOW in milliseconds"), } } } } -/// CPU, Memory and Process Starts/Stops. DEPRECATED -/// -/// This presents a summary of CPU and memory utilization. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgLinuxSysStateDepA { - /// 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 ConcreteMessage for MsgLinuxSysStateDepA { - const MESSAGE_TYPE: u16 = 32514; - const MESSAGE_NAME: &'static str = "MSG_LINUX_SYS_STATE_DEP_A"; -} - -impl SbpMessage for MsgLinuxSysStateDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_linux_sys_state_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// CPU, Memory and Process Starts/Stops. DEPRECATED + /// + /// This presents a summary of CPU and memory utilization. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgLinuxSysStateDepA { + /// 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 ConcreteMessage for MsgLinuxSysStateDepA { + const MESSAGE_TYPE: u16 = 32514; + const MESSAGE_NAME: &'static str = "MSG_LINUX_SYS_STATE_DEP_A"; + } + + impl SbpMessage for MsgLinuxSysStateDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgLinuxSysStateDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgLinuxSysStateDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgLinuxSysStateDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgLinuxSysStateDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgLinuxSysStateDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.mem_total) - + WireFormat::len(&self.pcpu) - + WireFormat::len(&self.pmem) - + WireFormat::len(&self.procs_starting) - + WireFormat::len(&self.procs_stopping) - + WireFormat::len(&self.pid_count) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgLinuxSysStateDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.mem_total) + + WireFormat::len(&self.pcpu) + + WireFormat::len(&self.pmem) + + WireFormat::len(&self.procs_starting) + + WireFormat::len(&self.procs_stopping) + + WireFormat::len(&self.pid_count) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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 96925d45f7..72b63f11e6 100644 --- a/rust/sbp/src/messages/logging.rs +++ b/rust/sbp/src/messages/logging.rs @@ -13,289 +13,311 @@ // with generate.py. Please do not hand edit! //****************************************************************************/ //! Logging and debugging messages from the device. +pub use msg_fwd::MsgFwd; +pub use msg_log::MsgLog; +pub use msg_print_dep::MsgPrintDep; -use super::lib::*; - -/// Wrapper for FWD a separate stream of information over SBP -/// -/// This message provides the ability to forward messages over SBP. This may -/// take the form of wrapping up SBP messages received by Piksi for logging -/// purposes or wrapping another protocol with SBP. -/// -/// The source identifier indicates from what interface a forwarded stream -/// derived. The protocol identifier identifies what the expected protocol the -/// forwarded msg contains. Protocol 0 represents SBP and the remaining values -/// are implementation defined. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgFwd { - /// 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, -} +pub mod msg_fwd { + #![allow(unused_imports)] -impl ConcreteMessage for MsgFwd { - const MESSAGE_TYPE: u16 = 1026; - const MESSAGE_NAME: &'static str = "MSG_FWD"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgFwd { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + /// Wrapper for FWD a separate stream of information over SBP + /// + /// This message provides the ability to forward messages over SBP. This may + /// take the form of wrapping up SBP messages received by Piksi for logging + /// purposes or wrapping another protocol with SBP. + /// + /// The source identifier indicates from what interface a forwarded stream + /// derived. The protocol identifier identifies what the expected protocol the + /// forwarded msg contains. Protocol 0 represents SBP and the remaining values + /// are implementation defined. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgFwd { + /// 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, } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgFwd { + const MESSAGE_TYPE: u16 = 1026; + const MESSAGE_NAME: &'static str = "MSG_FWD"; } -} -impl TryFrom for MsgFwd { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgFwd(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgFwd { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgFwd { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.source) - + WireFormat::len(&self.protocol) - + WireFormat::len(&self.fwd_payload) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.source, buf); - WireFormat::write(&self.protocol, buf); - WireFormat::write(&self.fwd_payload, buf); + impl TryFrom for MsgFwd { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgFwd(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgFwd { - sender_id: None, - source: WireFormat::parse_unchecked(buf), - protocol: WireFormat::parse_unchecked(buf), - fwd_payload: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgFwd { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.source) + + WireFormat::len(&self.protocol) + + WireFormat::len(&self.fwd_payload) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.source, buf); + WireFormat::write(&self.protocol, buf); + WireFormat::write(&self.fwd_payload, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgFwd { + sender_id: None, + source: WireFormat::parse_unchecked(buf), + protocol: WireFormat::parse_unchecked(buf), + fwd_payload: WireFormat::parse_unchecked(buf), + } } } } -/// Plaintext logging messages with levels -/// -/// This message contains a human-readable payload string from the device -/// containing errors, warnings and informational messages at ERROR, WARNING, -/// DEBUG, INFO logging levels. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgLog { - /// 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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "text")))] - pub text: SbpString, Unterminated>, -} +pub mod msg_log { + #![allow(unused_imports)] -impl MsgLog { - pub fn logging_level(&self) -> Option { - match get_bit_range!(self.level, u8, u8, 2, 0) { - 0 => Some(MsgLogLoggingLevel::EMERG), - 1 => Some(MsgLogLoggingLevel::ALERT), - 2 => Some(MsgLogLoggingLevel::CRIT), - 3 => Some(MsgLogLoggingLevel::ERROR), - 4 => Some(MsgLogLoggingLevel::WARN), - 5 => Some(MsgLogLoggingLevel::NOTICE), - 6 => Some(MsgLogLoggingLevel::INFO), - 7 => Some(MsgLogLoggingLevel::DEBUG), - _ => None, - } - } + use super::*; + use crate::messages::lib::*; - pub fn set_logging_level(&mut self, logging_level: MsgLogLoggingLevel) { - set_bit_range!(&mut self.level, logging_level, u8, u8, 2, 0); + /// Plaintext logging messages with levels + /// + /// This message contains a human-readable payload string from the device + /// containing errors, warnings and informational messages at ERROR, WARNING, + /// DEBUG, INFO logging levels. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgLog { + /// 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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "text")))] + pub text: SbpString, Unterminated>, } -} -impl ConcreteMessage for MsgLog { - const MESSAGE_TYPE: u16 = 1025; - const MESSAGE_NAME: &'static str = "MSG_LOG"; -} + impl MsgLog { + pub fn logging_level(&self) -> Option { + match get_bit_range!(self.level, u8, u8, 2, 0) { + 0 => Some(LoggingLevel::EMERG), + 1 => Some(LoggingLevel::ALERT), + 2 => Some(LoggingLevel::CRIT), + 3 => Some(LoggingLevel::ERROR), + 4 => Some(LoggingLevel::WARN), + 5 => Some(LoggingLevel::NOTICE), + 6 => Some(LoggingLevel::INFO), + 7 => Some(LoggingLevel::DEBUG), + _ => None, + } + } -impl SbpMessage for MsgLog { - 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); + pub fn set_logging_level(&mut self, logging_level: LoggingLevel) { + set_bit_range!(&mut self.level, logging_level, u8, u8, 2, 0); + } } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgLog { + const MESSAGE_TYPE: u16 = 1025; + const MESSAGE_NAME: &'static str = "MSG_LOG"; } -} -impl TryFrom for MsgLog { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgLog(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgLog { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgLog { - const MIN_LEN: usize = - ::MIN_LEN + , Unterminated> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.level) + WireFormat::len(&self.text) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.level, buf); - WireFormat::write(&self.text, buf); + impl TryFrom for MsgLog { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgLog(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgLog { - sender_id: None, - level: WireFormat::parse_unchecked(buf), - text: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgLog { + const MIN_LEN: usize = + ::MIN_LEN + , Unterminated> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.level) + WireFormat::len(&self.text) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.level, buf); + WireFormat::write(&self.text, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgLog { + sender_id: None, + level: WireFormat::parse_unchecked(buf), + text: WireFormat::parse_unchecked(buf), + } } } -} -/// Logging level -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgLogLoggingLevel { - /// EMERG - EMERG = 0, + /// Logging level + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum LoggingLevel { + /// EMERG + EMERG = 0, - /// ALERT - ALERT = 1, + /// ALERT + ALERT = 1, - /// CRIT - CRIT = 2, + /// CRIT + CRIT = 2, - /// ERROR - ERROR = 3, + /// ERROR + ERROR = 3, - /// WARN - WARN = 4, + /// WARN + WARN = 4, - /// NOTICE - NOTICE = 5, + /// NOTICE + NOTICE = 5, - /// INFO - INFO = 6, + /// INFO + INFO = 6, - /// DEBUG - DEBUG = 7, -} + /// DEBUG + DEBUG = 7, + } -impl std::fmt::Display for MsgLogLoggingLevel { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgLogLoggingLevel::EMERG => f.write_str("EMERG"), - MsgLogLoggingLevel::ALERT => f.write_str("ALERT"), - MsgLogLoggingLevel::CRIT => f.write_str("CRIT"), - MsgLogLoggingLevel::ERROR => f.write_str("ERROR"), - MsgLogLoggingLevel::WARN => f.write_str("WARN"), - MsgLogLoggingLevel::NOTICE => f.write_str("NOTICE"), - MsgLogLoggingLevel::INFO => f.write_str("INFO"), - MsgLogLoggingLevel::DEBUG => f.write_str("DEBUG"), + impl std::fmt::Display for LoggingLevel { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + LoggingLevel::EMERG => f.write_str("EMERG"), + LoggingLevel::ALERT => f.write_str("ALERT"), + LoggingLevel::CRIT => f.write_str("CRIT"), + LoggingLevel::ERROR => f.write_str("ERROR"), + LoggingLevel::WARN => f.write_str("WARN"), + LoggingLevel::NOTICE => f.write_str("NOTICE"), + LoggingLevel::INFO => f.write_str("INFO"), + LoggingLevel::DEBUG => f.write_str("DEBUG"), + } } } } -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgPrintDep { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, - /// Human-readable string - #[cfg_attr(feature = "serde", serde(rename(serialize = "text")))] - pub text: SbpString, Unterminated>, -} +pub mod msg_print_dep { + #![allow(unused_imports)] -impl ConcreteMessage for MsgPrintDep { - const MESSAGE_TYPE: u16 = 16; - const MESSAGE_NAME: &'static str = "MSG_PRINT_DEP"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgPrintDep { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME + /// Deprecated + /// + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgPrintDep { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + /// Human-readable string + #[cfg_attr(feature = "serde", serde(rename(serialize = "text")))] + pub text: SbpString, Unterminated>, } - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgPrintDep { + const MESSAGE_TYPE: u16 = 16; + const MESSAGE_NAME: &'static str = "MSG_PRINT_DEP"; } -} -impl TryFrom for MsgPrintDep { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgPrintDep(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgPrintDep { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgPrintDep { - const MIN_LEN: usize = , Unterminated> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.text) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.text, buf); + impl TryFrom for MsgPrintDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgPrintDep(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgPrintDep { - sender_id: None, - text: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgPrintDep { + const MIN_LEN: usize = , Unterminated> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.text) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.text, buf); + } + fn parse_unchecked(buf: &mut B) -> 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 485f6b8c9c..af16b4c4d8 100644 --- a/rust/sbp/src/messages/mag.rs +++ b/rust/sbp/src/messages/mag.rs @@ -13,107 +13,113 @@ // with generate.py. Please do not hand edit! //****************************************************************************/ //! Magnetometer (mag) messages. +pub use msg_mag_raw::MsgMagRaw; -use super::lib::*; +pub mod msg_mag_raw { + #![allow(unused_imports)] -/// Raw magnetometer data -/// -/// Raw data from the magnetometer. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgMagRaw { - /// 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 ConcreteMessage for MsgMagRaw { - const MESSAGE_TYPE: u16 = 2306; - const MESSAGE_NAME: &'static str = "MSG_MAG_RAW"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgMagRaw { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + /// Raw magnetometer data + /// + /// Raw data from the magnetometer. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgMagRaw { + /// 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, } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + + impl ConcreteMessage for MsgMagRaw { + const MESSAGE_TYPE: u16 = 2306; + const MESSAGE_NAME: &'static str = "MSG_MAG_RAW"; } -} -impl TryFrom for MsgMagRaw { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgMagRaw(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgMagRaw { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) } } -} -impl WireFormat for MsgMagRaw { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.tow_f) - + WireFormat::len(&self.mag_x) - + WireFormat::len(&self.mag_y) - + WireFormat::len(&self.mag_z) - } - fn write(&self, buf: &mut B) { - 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); + impl TryFrom for MsgMagRaw { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgMagRaw(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> 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), + + impl WireFormat for MsgMagRaw { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.tow_f) + + WireFormat::len(&self.mag_x) + + WireFormat::len(&self.mag_y) + + WireFormat::len(&self.mag_z) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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 b48720fb7f..e38da22d25 100644 --- a/rust/sbp/src/messages/mod.rs +++ b/rust/sbp/src/messages/mod.rs @@ -234,9 +234,9 @@ use self::tracking::MsgTrackingStateDepB; use self::tracking::MsgTrackingStateDetailedDep; use self::tracking::MsgTrackingStateDetailedDepA; use self::unknown::Unknown; -use self::user::MsgUserData; -use self::vehicle::MsgOdometry; -use self::vehicle::MsgWheeltick; +use self::user::msg_user_data::MsgUserData; +use self::vehicle::msg_odometry::MsgOdometry; +use self::vehicle::msg_wheeltick::MsgWheeltick; mod lib { //! Common imports so we can just `use super::lib::*` in all the message files diff --git a/rust/sbp/src/messages/navigation.rs b/rust/sbp/src/messages/navigation.rs index 562a1e3b6f..9e18ca2f95 100644 --- a/rust/sbp/src/messages/navigation.rs +++ b/rust/sbp/src/messages/navigation.rs @@ -36,8067 +36,8351 @@ //! When this is not the case, the tow may be a time of arrival or a local //! system timestamp, irrespective of the time reference (GPS Week or else), //! but not a Time of Measurement. - -use super::lib::*; - -/// Horizontal estimated error ellipse -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 WireFormat for EstimatedHorizontalErrorEllipse { - const MIN_LEN: usize = - ::MIN_LEN + ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.semi_major) - + WireFormat::len(&self.semi_minor) - + WireFormat::len(&self.orientation) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.semi_major, buf); - WireFormat::write(&self.semi_minor, buf); - WireFormat::write(&self.orientation, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - EstimatedHorizontalErrorEllipse { - semi_major: WireFormat::parse_unchecked(buf), - semi_minor: WireFormat::parse_unchecked(buf), - orientation: WireFormat::parse_unchecked(buf), +pub use estimated_horizontal_error_ellipse::EstimatedHorizontalErrorEllipse; +pub use msg_age_corrections::MsgAgeCorrections; +pub use msg_baseline_ecef::MsgBaselineEcef; +pub use msg_baseline_ecef_dep_a::MsgBaselineEcefDepA; +pub use msg_baseline_heading_dep_a::MsgBaselineHeadingDepA; +pub use msg_baseline_ned::MsgBaselineNed; +pub use msg_baseline_ned_dep_a::MsgBaselineNedDepA; +pub use msg_dops::MsgDops; +pub use msg_dops_dep_a::MsgDopsDepA; +pub use msg_gps_time::MsgGpsTime; +pub use msg_gps_time_dep_a::MsgGpsTimeDepA; +pub use msg_gps_time_gnss::MsgGpsTimeGnss; +pub use msg_pos_ecef::MsgPosEcef; +pub use msg_pos_ecef_cov::MsgPosEcefCov; +pub use msg_pos_ecef_cov_gnss::MsgPosEcefCovGnss; +pub use msg_pos_ecef_dep_a::MsgPosEcefDepA; +pub use msg_pos_ecef_gnss::MsgPosEcefGnss; +pub use msg_pos_llh::MsgPosLlh; +pub use msg_pos_llh_acc::MsgPosLlhAcc; +pub use msg_pos_llh_cov::MsgPosLlhCov; +pub use msg_pos_llh_cov_gnss::MsgPosLlhCovGnss; +pub use msg_pos_llh_dep_a::MsgPosLlhDepA; +pub use msg_pos_llh_gnss::MsgPosLlhGnss; +pub use msg_protection_level::MsgProtectionLevel; +pub use msg_protection_level_dep_a::MsgProtectionLevelDepA; +pub use msg_utc_time::MsgUtcTime; +pub use msg_utc_time_gnss::MsgUtcTimeGnss; +pub use msg_vel_body::MsgVelBody; +pub use msg_vel_cog::MsgVelCog; +pub use msg_vel_ecef::MsgVelEcef; +pub use msg_vel_ecef_cov::MsgVelEcefCov; +pub use msg_vel_ecef_cov_gnss::MsgVelEcefCovGnss; +pub use msg_vel_ecef_dep_a::MsgVelEcefDepA; +pub use msg_vel_ecef_gnss::MsgVelEcefGnss; +pub use msg_vel_ned::MsgVelNed; +pub use msg_vel_ned_cov::MsgVelNedCov; +pub use msg_vel_ned_cov_gnss::MsgVelNedCovGnss; +pub use msg_vel_ned_dep_a::MsgVelNedDepA; +pub use msg_vel_ned_gnss::MsgVelNedGnss; + +pub mod estimated_horizontal_error_ellipse { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + /// Horizontal estimated error ellipse + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 WireFormat for EstimatedHorizontalErrorEllipse { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.semi_major) + + WireFormat::len(&self.semi_minor) + + WireFormat::len(&self.orientation) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.semi_major, buf); + WireFormat::write(&self.semi_minor, buf); + WireFormat::write(&self.orientation, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + EstimatedHorizontalErrorEllipse { + semi_major: WireFormat::parse_unchecked(buf), + semi_minor: WireFormat::parse_unchecked(buf), + orientation: WireFormat::parse_unchecked(buf), + } } } } -/// Age of corrections -/// -/// This message reports the Age of the corrections used for the current -/// Differential solution. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgAgeCorrections { - /// 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, -} +pub mod msg_age_corrections { + #![allow(unused_imports)] -impl ConcreteMessage for MsgAgeCorrections { - const MESSAGE_TYPE: u16 = 528; - const MESSAGE_NAME: &'static str = "MSG_AGE_CORRECTIONS"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgAgeCorrections { - 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); + /// Age of corrections + /// + /// This message reports the Age of the corrections used for the current + /// Differential solution. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgAgeCorrections { + /// 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, } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + + impl ConcreteMessage for MsgAgeCorrections { + const MESSAGE_TYPE: u16 = 528; + const MESSAGE_NAME: &'static str = "MSG_AGE_CORRECTIONS"; } -} -impl TryFrom for MsgAgeCorrections { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgAgeCorrections(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgAgeCorrections { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) } } -} -impl WireFormat for MsgAgeCorrections { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) + WireFormat::len(&self.age) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.tow, buf); - WireFormat::write(&self.age, buf); + impl TryFrom for MsgAgeCorrections { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgAgeCorrections(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgAgeCorrections { - sender_id: None, - tow: WireFormat::parse_unchecked(buf), - age: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgAgeCorrections { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + WireFormat::len(&self.age) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.age, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgAgeCorrections { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + age: WireFormat::parse_unchecked(buf), + } } } } -/// Baseline Position in ECEF -/// -/// This message reports the baseline solution in Earth Centered Earth Fixed -/// (ECEF) coordinates. This baseline is the relative vector distance from the -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_baseline_ecef { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Baseline Position in ECEF + /// + /// This message reports the baseline solution in Earth Centered Earth Fixed + /// (ECEF) coordinates. This baseline is the relative vector distance from the + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(FixMode::Invalid), + 2 => Some(FixMode::DifferentialGnss), + 3 => Some(FixMode::FloatRtk), + 4 => Some(FixMode::FixedRtk), + _ => None, + } + } -impl MsgBaselineEcef { - pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgBaselineEcefFixMode::Invalid), - 2 => Some(MsgBaselineEcefFixMode::DifferentialGnss), - 3 => Some(MsgBaselineEcefFixMode::FloatRtk), - 4 => Some(MsgBaselineEcefFixMode::FixedRtk), - _ => None, + pub fn set_fix_mode(&mut self, fix_mode: FixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } } - pub fn set_fix_mode(&mut self, fix_mode: MsgBaselineEcefFixMode) { - set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgBaselineEcef { + const MESSAGE_TYPE: u16 = 523; + const MESSAGE_NAME: &'static str = "MSG_BASELINE_ECEF"; } -} - -impl ConcreteMessage for MsgBaselineEcef { - const MESSAGE_TYPE: u16 = 523; - const MESSAGE_NAME: &'static str = "MSG_BASELINE_ECEF"; -} -impl SbpMessage for MsgBaselineEcef { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgBaselineEcef { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgBaselineEcef { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgBaselineEcef(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgBaselineEcef { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgBaselineEcef(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgBaselineEcef { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.x) - + WireFormat::len(&self.y) - + WireFormat::len(&self.z) - + WireFormat::len(&self.accuracy) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgBaselineEcef { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.x) + + WireFormat::len(&self.y) + + WireFormat::len(&self.z) + + WireFormat::len(&self.accuracy) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Fix mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgBaselineEcefFixMode { - /// Invalid - Invalid = 0, + /// Fix mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FixMode { + /// Invalid + Invalid = 0, - /// Differential GNSS (DGNSS) - DifferentialGnss = 2, + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, - /// Float RTK - FloatRtk = 3, + /// Float RTK + FloatRtk = 3, - /// Fixed RTK - FixedRtk = 4, -} + /// Fixed RTK + FixedRtk = 4, + } -impl std::fmt::Display for MsgBaselineEcefFixMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgBaselineEcefFixMode::Invalid => f.write_str("Invalid"), - MsgBaselineEcefFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), - MsgBaselineEcefFixMode::FloatRtk => f.write_str("Float RTK"), - MsgBaselineEcefFixMode::FixedRtk => f.write_str("Fixed RTK"), + impl std::fmt::Display for FixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FixMode::Invalid => f.write_str("Invalid"), + FixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + FixMode::FloatRtk => f.write_str("Float RTK"), + FixMode::FixedRtk => f.write_str("Fixed RTK"), + } } } } -/// Baseline Position in ECEF -/// -/// This message reports the baseline solution in Earth Centered Earth Fixed -/// (ECEF) coordinates. This baseline is the relative vector distance from the -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_baseline_ecef_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Baseline Position in ECEF + /// + /// This message reports the baseline solution in Earth Centered Earth Fixed + /// (ECEF) coordinates. This baseline is the relative vector distance from the + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn raim_repair_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 0) { + 0 => Some(RaimRepairFlag::NoRepair), + 1 => Some(RaimRepairFlag::SolutionCameFromRaimRepair), + _ => None, + } + } -impl MsgBaselineEcefDepA { - pub fn raim_repair_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 0) { - 0 => Some(MsgBaselineEcefDepARaimRepairFlag::NoRepair), - 1 => Some(MsgBaselineEcefDepARaimRepairFlag::SolutionCameFromRaimRepair), - _ => None, + pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { + set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); } - } - pub fn set_raim_repair_flag(&mut self, raim_repair_flag: MsgBaselineEcefDepARaimRepairFlag) { - set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); - } + pub fn raim_availability_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 0) { + 0 => Some(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), + 1 => Some(RaimAvailabilityFlag::RaimCheckWasAvailable), + _ => None, + } + } - pub fn raim_availability_flag(&self) -> Option { - match get_bit_range!( self.flags, u8, u8, 3, 0 ) { - 0 => Some( MsgBaselineEcefDepARaimAvailabilityFlag :: RaimCheckWasExplicitlyDisabledOrUnavailable ), - 1 => Some( MsgBaselineEcefDepARaimAvailabilityFlag :: RaimCheckWasAvailable ), - _ => None, + pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { + set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); } - } - pub fn set_raim_availability_flag( - &mut self, - raim_availability_flag: MsgBaselineEcefDepARaimAvailabilityFlag, - ) { - set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); - } + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(FixMode::FloatRtk), + 1 => Some(FixMode::FixedRtk), + _ => None, + } + } - pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgBaselineEcefDepAFixMode::FloatRtk), - 1 => Some(MsgBaselineEcefDepAFixMode::FixedRtk), - _ => None, + pub fn set_fix_mode(&mut self, fix_mode: FixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } } - pub fn set_fix_mode(&mut self, fix_mode: MsgBaselineEcefDepAFixMode) { - set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgBaselineEcefDepA { + const MESSAGE_TYPE: u16 = 514; + const MESSAGE_NAME: &'static str = "MSG_BASELINE_ECEF_DEP_A"; } -} - -impl ConcreteMessage for MsgBaselineEcefDepA { - const MESSAGE_TYPE: u16 = 514; - const MESSAGE_NAME: &'static str = "MSG_BASELINE_ECEF_DEP_A"; -} -impl SbpMessage for MsgBaselineEcefDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgBaselineEcefDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgBaselineEcefDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgBaselineEcefDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgBaselineEcefDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgBaselineEcefDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgBaselineEcefDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.x) - + WireFormat::len(&self.y) - + WireFormat::len(&self.z) - + WireFormat::len(&self.accuracy) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgBaselineEcefDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.x) + + WireFormat::len(&self.y) + + WireFormat::len(&self.z) + + WireFormat::len(&self.accuracy) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// RAIM repair flag -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgBaselineEcefDepARaimRepairFlag { - /// No repair - NoRepair = 0, + /// RAIM repair flag + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum RaimRepairFlag { + /// No repair + NoRepair = 0, - /// Solution came from RAIM repair - SolutionCameFromRaimRepair = 1, -} + /// Solution came from RAIM repair + SolutionCameFromRaimRepair = 1, + } -impl std::fmt::Display for MsgBaselineEcefDepARaimRepairFlag { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgBaselineEcefDepARaimRepairFlag::NoRepair => f.write_str("No repair"), - MsgBaselineEcefDepARaimRepairFlag::SolutionCameFromRaimRepair => { - f.write_str("Solution came from RAIM repair") + impl std::fmt::Display for RaimRepairFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + RaimRepairFlag::NoRepair => f.write_str("No repair"), + RaimRepairFlag::SolutionCameFromRaimRepair => { + f.write_str("Solution came from RAIM repair") + } } } } -} -/// RAIM availability flag -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgBaselineEcefDepARaimAvailabilityFlag { - /// RAIM check was explicitly disabled or unavailable - RaimCheckWasExplicitlyDisabledOrUnavailable = 0, + /// RAIM availability flag + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum RaimAvailabilityFlag { + /// RAIM check was explicitly disabled or unavailable + RaimCheckWasExplicitlyDisabledOrUnavailable = 0, - /// RAIM check was available - RaimCheckWasAvailable = 1, -} + /// RAIM check was available + RaimCheckWasAvailable = 1, + } -impl std::fmt::Display for MsgBaselineEcefDepARaimAvailabilityFlag { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgBaselineEcefDepARaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable => f.write_str("RAIM check was explicitly disabled or unavailable"), - MsgBaselineEcefDepARaimAvailabilityFlag::RaimCheckWasAvailable => f.write_str("RAIM check was available"), + impl std::fmt::Display for RaimAvailabilityFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable => { + f.write_str("RAIM check was explicitly disabled or unavailable") + } + RaimAvailabilityFlag::RaimCheckWasAvailable => { + f.write_str("RAIM check was available") + } + } } } -} -/// Fix mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgBaselineEcefDepAFixMode { - /// Float RTK - FloatRtk = 0, + /// Fix mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FixMode { + /// Float RTK + FloatRtk = 0, - /// Fixed RTK - FixedRtk = 1, -} + /// Fixed RTK + FixedRtk = 1, + } -impl std::fmt::Display for MsgBaselineEcefDepAFixMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgBaselineEcefDepAFixMode::FloatRtk => f.write_str("Float RTK"), - MsgBaselineEcefDepAFixMode::FixedRtk => f.write_str("Fixed RTK"), + impl std::fmt::Display for FixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FixMode::FloatRtk => f.write_str("Float RTK"), + FixMode::FixedRtk => f.write_str("Fixed RTK"), + } } } } -/// Heading relative to True North -/// -/// This message reports the baseline heading pointing from the base station -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgBaselineHeadingDepA { - /// 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, -} +pub mod msg_baseline_heading_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Heading relative to True North + /// + /// This message reports the baseline heading pointing from the base station + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgBaselineHeadingDepA { + /// 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 { + pub fn raim_repair_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 0) { + 0 => Some(RaimRepairFlag::NoRepair), + 1 => Some(RaimRepairFlag::SolutionCameFromRaimRepair), + _ => None, + } + } -impl MsgBaselineHeadingDepA { - pub fn raim_repair_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 0) { - 0 => Some(MsgBaselineHeadingDepARaimRepairFlag::NoRepair), - 1 => Some(MsgBaselineHeadingDepARaimRepairFlag::SolutionCameFromRaimRepair), - _ => None, + pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { + set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); } - } - pub fn set_raim_repair_flag(&mut self, raim_repair_flag: MsgBaselineHeadingDepARaimRepairFlag) { - set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); - } + pub fn raim_availability_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 0) { + 0 => Some(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), + 1 => Some(RaimAvailabilityFlag::RaimCheckWasAvailable), + _ => None, + } + } - pub fn raim_availability_flag(&self) -> Option { - match get_bit_range!( self.flags, u8, u8, 3, 0 ) { - 0 => Some( MsgBaselineHeadingDepARaimAvailabilityFlag :: RaimCheckWasExplicitlyDisabledOrUnavailable ), - 1 => Some( MsgBaselineHeadingDepARaimAvailabilityFlag :: RaimCheckWasAvailable ), - _ => None, + pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { + set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); } - } - pub fn set_raim_availability_flag( - &mut self, - raim_availability_flag: MsgBaselineHeadingDepARaimAvailabilityFlag, - ) { - set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); - } + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(FixMode::FloatRtk), + 1 => Some(FixMode::FixedRtk), + _ => None, + } + } - pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgBaselineHeadingDepAFixMode::FloatRtk), - 1 => Some(MsgBaselineHeadingDepAFixMode::FixedRtk), - _ => None, + pub fn set_fix_mode(&mut self, fix_mode: FixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } } - pub fn set_fix_mode(&mut self, fix_mode: MsgBaselineHeadingDepAFixMode) { - set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgBaselineHeadingDepA { + const MESSAGE_TYPE: u16 = 519; + const MESSAGE_NAME: &'static str = "MSG_BASELINE_HEADING_DEP_A"; } -} - -impl ConcreteMessage for MsgBaselineHeadingDepA { - const MESSAGE_TYPE: u16 = 519; - const MESSAGE_NAME: &'static str = "MSG_BASELINE_HEADING_DEP_A"; -} -impl SbpMessage for MsgBaselineHeadingDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgBaselineHeadingDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgBaselineHeadingDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgBaselineHeadingDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgBaselineHeadingDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgBaselineHeadingDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgBaselineHeadingDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.heading) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgBaselineHeadingDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.heading) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// RAIM repair flag -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgBaselineHeadingDepARaimRepairFlag { - /// No repair - NoRepair = 0, + /// RAIM repair flag + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum RaimRepairFlag { + /// No repair + NoRepair = 0, - /// Solution came from RAIM repair - SolutionCameFromRaimRepair = 1, -} + /// Solution came from RAIM repair + SolutionCameFromRaimRepair = 1, + } -impl std::fmt::Display for MsgBaselineHeadingDepARaimRepairFlag { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgBaselineHeadingDepARaimRepairFlag::NoRepair => f.write_str("No repair"), - MsgBaselineHeadingDepARaimRepairFlag::SolutionCameFromRaimRepair => { - f.write_str("Solution came from RAIM repair") + impl std::fmt::Display for RaimRepairFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + RaimRepairFlag::NoRepair => f.write_str("No repair"), + RaimRepairFlag::SolutionCameFromRaimRepair => { + f.write_str("Solution came from RAIM repair") + } } } } -} -/// RAIM availability flag -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgBaselineHeadingDepARaimAvailabilityFlag { - /// RAIM check was explicitly disabled or unavailable - RaimCheckWasExplicitlyDisabledOrUnavailable = 0, + /// RAIM availability flag + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum RaimAvailabilityFlag { + /// RAIM check was explicitly disabled or unavailable + RaimCheckWasExplicitlyDisabledOrUnavailable = 0, - /// RAIM check was available - RaimCheckWasAvailable = 1, -} + /// RAIM check was available + RaimCheckWasAvailable = 1, + } -impl std::fmt::Display for MsgBaselineHeadingDepARaimAvailabilityFlag { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgBaselineHeadingDepARaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable => f.write_str("RAIM check was explicitly disabled or unavailable"), - MsgBaselineHeadingDepARaimAvailabilityFlag::RaimCheckWasAvailable => f.write_str("RAIM check was available"), + impl std::fmt::Display for RaimAvailabilityFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable => { + f.write_str("RAIM check was explicitly disabled or unavailable") + } + RaimAvailabilityFlag::RaimCheckWasAvailable => { + f.write_str("RAIM check was available") + } + } } } -} -/// Fix mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgBaselineHeadingDepAFixMode { - /// Float RTK - FloatRtk = 0, + /// Fix mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FixMode { + /// Float RTK + FloatRtk = 0, - /// Fixed RTK - FixedRtk = 1, -} + /// Fixed RTK + FixedRtk = 1, + } -impl std::fmt::Display for MsgBaselineHeadingDepAFixMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgBaselineHeadingDepAFixMode::FloatRtk => f.write_str("Float RTK"), - MsgBaselineHeadingDepAFixMode::FixedRtk => f.write_str("Fixed RTK"), + impl std::fmt::Display for FixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FixMode::FloatRtk => f.write_str("Float RTK"), + FixMode::FixedRtk => f.write_str("Fixed RTK"), + } } } } -/// Baseline in NED -/// -/// This message reports the baseline solution in North East Down (NED) -/// coordinates. This baseline is the relative vector distance from the base -/// station to the rover receiver, and NED coordinate system is defined at the -/// local WGS84 tangent plane centered at the base station position. The full -/// GPS time is given by the preceding MSG_GPS_TIME with the matching time-of- -/// week (tow). -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_baseline_ned { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Baseline in NED + /// + /// This message reports the baseline solution in North East Down (NED) + /// coordinates. This baseline is the relative vector distance from the base + /// station to the rover receiver, and NED coordinate system is defined at the + /// local WGS84 tangent plane centered at the base station position. The full + /// GPS time is given by the preceding MSG_GPS_TIME with the matching time-of- + /// week (tow). + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(FixMode::Invalid), + 2 => Some(FixMode::DifferentialGnss), + 3 => Some(FixMode::FloatRtk), + 4 => Some(FixMode::FixedRtk), + _ => None, + } + } -impl MsgBaselineNed { - pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgBaselineNedFixMode::Invalid), - 2 => Some(MsgBaselineNedFixMode::DifferentialGnss), - 3 => Some(MsgBaselineNedFixMode::FloatRtk), - 4 => Some(MsgBaselineNedFixMode::FixedRtk), - _ => None, + pub fn set_fix_mode(&mut self, fix_mode: FixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } } - pub fn set_fix_mode(&mut self, fix_mode: MsgBaselineNedFixMode) { - set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgBaselineNed { + const MESSAGE_TYPE: u16 = 524; + const MESSAGE_NAME: &'static str = "MSG_BASELINE_NED"; } -} - -impl ConcreteMessage for MsgBaselineNed { - const MESSAGE_TYPE: u16 = 524; - const MESSAGE_NAME: &'static str = "MSG_BASELINE_NED"; -} -impl SbpMessage for MsgBaselineNed { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgBaselineNed { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgBaselineNed { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgBaselineNed(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgBaselineNed { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgBaselineNed(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgBaselineNed { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.n) - + WireFormat::len(&self.e) - + WireFormat::len(&self.d) - + WireFormat::len(&self.h_accuracy) - + WireFormat::len(&self.v_accuracy) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgBaselineNed { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.n) + + WireFormat::len(&self.e) + + WireFormat::len(&self.d) + + WireFormat::len(&self.h_accuracy) + + WireFormat::len(&self.v_accuracy) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Fix mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgBaselineNedFixMode { - /// Invalid - Invalid = 0, + /// Fix mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FixMode { + /// Invalid + Invalid = 0, - /// Differential GNSS (DGNSS) - DifferentialGnss = 2, + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, - /// Float RTK - FloatRtk = 3, + /// Float RTK + FloatRtk = 3, - /// Fixed RTK - FixedRtk = 4, -} + /// Fixed RTK + FixedRtk = 4, + } -impl std::fmt::Display for MsgBaselineNedFixMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgBaselineNedFixMode::Invalid => f.write_str("Invalid"), - MsgBaselineNedFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), - MsgBaselineNedFixMode::FloatRtk => f.write_str("Float RTK"), - MsgBaselineNedFixMode::FixedRtk => f.write_str("Fixed RTK"), + impl std::fmt::Display for FixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FixMode::Invalid => f.write_str("Invalid"), + FixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + FixMode::FloatRtk => f.write_str("Float RTK"), + FixMode::FixedRtk => f.write_str("Fixed RTK"), + } } } } -/// Baseline in NED -/// -/// This message reports the baseline solution in North East Down (NED) -/// coordinates. This baseline is the relative vector distance from the base -/// station to the rover receiver, and NED coordinate system is defined at the -/// local WGS84 tangent plane centered at the base station position. The full -/// GPS time is given by the preceding MSG_GPS_TIME with the matching time-of- -/// week (tow). -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_baseline_ned_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Baseline in NED + /// + /// This message reports the baseline solution in North East Down (NED) + /// coordinates. This baseline is the relative vector distance from the base + /// station to the rover receiver, and NED coordinate system is defined at the + /// local WGS84 tangent plane centered at the base station position. The full + /// GPS time is given by the preceding MSG_GPS_TIME with the matching time-of- + /// week (tow). + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn raim_repair_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 0) { + 0 => Some(RaimRepairFlag::NoRepair), + 1 => Some(RaimRepairFlag::SolutionCameFromRaimRepair), + _ => None, + } + } -impl MsgBaselineNedDepA { - pub fn raim_repair_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 0) { - 0 => Some(MsgBaselineNedDepARaimRepairFlag::NoRepair), - 1 => Some(MsgBaselineNedDepARaimRepairFlag::SolutionCameFromRaimRepair), - _ => None, + pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { + set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); } - } - pub fn set_raim_repair_flag(&mut self, raim_repair_flag: MsgBaselineNedDepARaimRepairFlag) { - set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); - } + pub fn raim_availability_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 0) { + 0 => Some(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), + 1 => Some(RaimAvailabilityFlag::RaimCheckWasAvailable), + _ => None, + } + } - pub fn raim_availability_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 0) { - 0 => Some( - MsgBaselineNedDepARaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable, - ), - 1 => Some(MsgBaselineNedDepARaimAvailabilityFlag::RaimCheckWasAvailable), - _ => None, + pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { + set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); } - } - pub fn set_raim_availability_flag( - &mut self, - raim_availability_flag: MsgBaselineNedDepARaimAvailabilityFlag, - ) { - set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); - } + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(FixMode::FloatRtk), + 1 => Some(FixMode::FixedRtk), + _ => None, + } + } - pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgBaselineNedDepAFixMode::FloatRtk), - 1 => Some(MsgBaselineNedDepAFixMode::FixedRtk), - _ => None, + pub fn set_fix_mode(&mut self, fix_mode: FixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } } - pub fn set_fix_mode(&mut self, fix_mode: MsgBaselineNedDepAFixMode) { - set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgBaselineNedDepA { + const MESSAGE_TYPE: u16 = 515; + const MESSAGE_NAME: &'static str = "MSG_BASELINE_NED_DEP_A"; } -} -impl ConcreteMessage for MsgBaselineNedDepA { - const MESSAGE_TYPE: u16 = 515; - const MESSAGE_NAME: &'static str = "MSG_BASELINE_NED_DEP_A"; -} - -impl SbpMessage for MsgBaselineNedDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgBaselineNedDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgBaselineNedDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgBaselineNedDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgBaselineNedDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgBaselineNedDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgBaselineNedDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.n) - + WireFormat::len(&self.e) - + WireFormat::len(&self.d) - + WireFormat::len(&self.h_accuracy) - + WireFormat::len(&self.v_accuracy) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgBaselineNedDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.n) + + WireFormat::len(&self.e) + + WireFormat::len(&self.d) + + WireFormat::len(&self.h_accuracy) + + WireFormat::len(&self.v_accuracy) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// RAIM repair flag -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgBaselineNedDepARaimRepairFlag { - /// No repair - NoRepair = 0, + /// RAIM repair flag + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum RaimRepairFlag { + /// No repair + NoRepair = 0, - /// Solution came from RAIM repair - SolutionCameFromRaimRepair = 1, -} + /// Solution came from RAIM repair + SolutionCameFromRaimRepair = 1, + } -impl std::fmt::Display for MsgBaselineNedDepARaimRepairFlag { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgBaselineNedDepARaimRepairFlag::NoRepair => f.write_str("No repair"), - MsgBaselineNedDepARaimRepairFlag::SolutionCameFromRaimRepair => { - f.write_str("Solution came from RAIM repair") + impl std::fmt::Display for RaimRepairFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + RaimRepairFlag::NoRepair => f.write_str("No repair"), + RaimRepairFlag::SolutionCameFromRaimRepair => { + f.write_str("Solution came from RAIM repair") + } } } } -} -/// RAIM availability flag -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgBaselineNedDepARaimAvailabilityFlag { - /// RAIM check was explicitly disabled or unavailable - RaimCheckWasExplicitlyDisabledOrUnavailable = 0, + /// RAIM availability flag + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum RaimAvailabilityFlag { + /// RAIM check was explicitly disabled or unavailable + RaimCheckWasExplicitlyDisabledOrUnavailable = 0, - /// RAIM check was available - RaimCheckWasAvailable = 1, -} + /// RAIM check was available + RaimCheckWasAvailable = 1, + } -impl std::fmt::Display for MsgBaselineNedDepARaimAvailabilityFlag { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgBaselineNedDepARaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable => { - f.write_str("RAIM check was explicitly disabled or unavailable") - } - MsgBaselineNedDepARaimAvailabilityFlag::RaimCheckWasAvailable => { - f.write_str("RAIM check was available") + impl std::fmt::Display for RaimAvailabilityFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable => { + f.write_str("RAIM check was explicitly disabled or unavailable") + } + RaimAvailabilityFlag::RaimCheckWasAvailable => { + f.write_str("RAIM check was available") + } } } } -} -/// Fix mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgBaselineNedDepAFixMode { - /// Float RTK - FloatRtk = 0, + /// Fix mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FixMode { + /// Float RTK + FloatRtk = 0, - /// Fixed RTK - FixedRtk = 1, -} + /// Fixed RTK + FixedRtk = 1, + } -impl std::fmt::Display for MsgBaselineNedDepAFixMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgBaselineNedDepAFixMode::FloatRtk => f.write_str("Float RTK"), - MsgBaselineNedDepAFixMode::FixedRtk => f.write_str("Fixed RTK"), + impl std::fmt::Display for FixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FixMode::FloatRtk => f.write_str("Float RTK"), + FixMode::FixedRtk => f.write_str("Fixed RTK"), + } } } } -/// Dilution of Precision -/// -/// This dilution of precision (DOP) message describes the effect of -/// navigation satellite geometry on positional measurement precision. The -/// flags field indicated whether the DOP reported corresponds to differential -/// or SPP solution. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgDops { - /// 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 { - pub fn raim_repair_flag(&self) -> u8 { - get_bit_range!(self.flags, u8, u8, 7, 0) - } - - pub fn set_raim_repair_flag(&mut self, raim_repair_flag: u8) { - set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 7, 0); - } +pub mod msg_dops { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Dilution of Precision + /// + /// This dilution of precision (DOP) message describes the effect of + /// navigation satellite geometry on positional measurement precision. The + /// flags field indicated whether the DOP reported corresponds to differential + /// or SPP solution. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgDops { + /// 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 { + pub fn raim_repair_flag(&self) -> u8 { + get_bit_range!(self.flags, u8, u8, 7, 0) + } + + pub fn set_raim_repair_flag(&mut self, raim_repair_flag: u8) { + set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 7, 0); + } + + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(FixMode::Invalid), + 1 => Some(FixMode::SinglePointPosition), + 2 => Some(FixMode::DifferentialGnss), + 3 => Some(FixMode::FloatRtk), + 4 => Some(FixMode::FixedRtk), + 5 => Some(FixMode::Undefined), + 6 => Some(FixMode::SbasPosition), + _ => None, + } + } - pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgDopsFixMode::Invalid), - 1 => Some(MsgDopsFixMode::SinglePointPosition), - 2 => Some(MsgDopsFixMode::DifferentialGnss), - 3 => Some(MsgDopsFixMode::FloatRtk), - 4 => Some(MsgDopsFixMode::FixedRtk), - 5 => Some(MsgDopsFixMode::Undefined), - 6 => Some(MsgDopsFixMode::SbasPosition), - _ => None, + pub fn set_fix_mode(&mut self, fix_mode: FixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } } - pub fn set_fix_mode(&mut self, fix_mode: MsgDopsFixMode) { - set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgDops { + const MESSAGE_TYPE: u16 = 520; + const MESSAGE_NAME: &'static str = "MSG_DOPS"; } -} -impl ConcreteMessage for MsgDops { - const MESSAGE_TYPE: u16 = 520; - const MESSAGE_NAME: &'static str = "MSG_DOPS"; -} - -impl SbpMessage for MsgDops { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgDops { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgDops { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgDops(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgDops { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgDops(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgDops { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.gdop) - + WireFormat::len(&self.pdop) - + WireFormat::len(&self.tdop) - + WireFormat::len(&self.hdop) - + WireFormat::len(&self.vdop) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgDops { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.gdop) + + WireFormat::len(&self.pdop) + + WireFormat::len(&self.tdop) + + WireFormat::len(&self.hdop) + + WireFormat::len(&self.vdop) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Fix mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgDopsFixMode { - /// Invalid - Invalid = 0, + /// Fix mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FixMode { + /// Invalid + Invalid = 0, - /// Single Point Position (SPP) - SinglePointPosition = 1, + /// Single Point Position (SPP) + SinglePointPosition = 1, - /// Differential GNSS (DGNSS) - DifferentialGnss = 2, + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, - /// Float RTK - FloatRtk = 3, + /// Float RTK + FloatRtk = 3, - /// Fixed RTK - FixedRtk = 4, + /// Fixed RTK + FixedRtk = 4, - /// Undefined - Undefined = 5, + /// Undefined + Undefined = 5, - /// SBAS Position - SbasPosition = 6, -} - -impl std::fmt::Display for MsgDopsFixMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgDopsFixMode::Invalid => f.write_str("Invalid"), - MsgDopsFixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), - MsgDopsFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), - MsgDopsFixMode::FloatRtk => f.write_str("Float RTK"), - MsgDopsFixMode::FixedRtk => f.write_str("Fixed RTK"), - MsgDopsFixMode::Undefined => f.write_str("Undefined"), - MsgDopsFixMode::SbasPosition => f.write_str("SBAS Position"), - } + /// SBAS Position + SbasPosition = 6, } -} -/// Dilution of Precision -/// -/// This dilution of precision (DOP) message describes the effect of -/// navigation satellite geometry on positional measurement precision. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgDopsDepA { - /// 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 ConcreteMessage for MsgDopsDepA { - const MESSAGE_TYPE: u16 = 518; - const MESSAGE_NAME: &'static str = "MSG_DOPS_DEP_A"; -} - -impl SbpMessage for MsgDopsDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl std::fmt::Display for FixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FixMode::Invalid => f.write_str("Invalid"), + FixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), + FixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + FixMode::FloatRtk => f.write_str("Float RTK"), + FixMode::FixedRtk => f.write_str("Fixed RTK"), + FixMode::Undefined => f.write_str("Undefined"), + FixMode::SbasPosition => f.write_str("SBAS Position"), + } + } } } -impl TryFrom for MsgDopsDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgDopsDepA(m) => Ok(m), - _ => Err(TryFromSbpError), +pub mod msg_dops_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Dilution of Precision + /// + /// This dilution of precision (DOP) message describes the effect of + /// navigation satellite geometry on positional measurement precision. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgDopsDepA { + /// 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 ConcreteMessage for MsgDopsDepA { + const MESSAGE_TYPE: u16 = 518; + const MESSAGE_NAME: &'static str = "MSG_DOPS_DEP_A"; + } + + impl SbpMessage for MsgDopsDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } + } + + impl TryFrom for MsgDopsDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgDopsDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgDopsDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.gdop) - + WireFormat::len(&self.pdop) - + WireFormat::len(&self.tdop) - + WireFormat::len(&self.hdop) - + WireFormat::len(&self.vdop) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgDopsDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.gdop) + + WireFormat::len(&self.pdop) + + WireFormat::len(&self.tdop) + + WireFormat::len(&self.hdop) + + WireFormat::len(&self.vdop) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// GPS Time -/// -/// This message reports the GPS time, representing the time since the GPS -/// epoch began on midnight January 6, 1980 UTC. GPS time counts the weeks and -/// seconds of the week. The weeks begin at the Saturday/Sunday transition. -/// GPS week 0 began at the beginning of the GPS time scale. -/// -/// Within each week number, the GPS time of the week is between between 0 and -/// 604800 seconds (=60*60*24*7). Note that GPS time does not accumulate leap -/// seconds, and as of now, has a small offset from UTC. In a message stream, -/// this message precedes a set of other navigation messages referenced to the -/// same time (but lacking the ns field) and indicates a more precise time of -/// these messages. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_gps_time { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// GPS Time + /// + /// This message reports the GPS time, representing the time since the GPS + /// epoch began on midnight January 6, 1980 UTC. GPS time counts the weeks and + /// seconds of the week. The weeks begin at the Saturday/Sunday transition. + /// GPS week 0 began at the beginning of the GPS time scale. + /// + /// Within each week number, the GPS time of the week is between between 0 and + /// 604800 seconds (=60*60*24*7). Note that GPS time does not accumulate leap + /// seconds, and as of now, has a small offset from UTC. In a message stream, + /// this message precedes a set of other navigation messages referenced to the + /// same time (but lacking the ns field) and indicates a more precise time of + /// these messages. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn time_source(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(TimeSource::None), + 1 => Some(TimeSource::GnssSolution), + 2 => Some(TimeSource::Propagated), + _ => None, + } + } -impl MsgGpsTime { - pub fn time_source(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgGpsTimeTimeSource::None), - 1 => Some(MsgGpsTimeTimeSource::GnssSolution), - 2 => Some(MsgGpsTimeTimeSource::Propagated), - _ => None, + pub fn set_time_source(&mut self, time_source: TimeSource) { + set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); } } - pub fn set_time_source(&mut self, time_source: MsgGpsTimeTimeSource) { - set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); + impl ConcreteMessage for MsgGpsTime { + const MESSAGE_TYPE: u16 = 258; + const MESSAGE_NAME: &'static str = "MSG_GPS_TIME"; } -} -impl ConcreteMessage for MsgGpsTime { - const MESSAGE_TYPE: u16 = 258; - const MESSAGE_NAME: &'static str = "MSG_GPS_TIME"; -} - -impl SbpMessage for MsgGpsTime { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - #[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 time::GpsTime::new(wn, tow_s) { - Ok(gps_time) => gps_time, - Err(e) => return Some(Err(e.into())), - }; - Some(Ok(time::MessageTime::Rover(gps_time.into()))) - } -} - -impl TryFrom for MsgGpsTime { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgGpsTime(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgGpsTime { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + #[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 time::GpsTime::new(wn, tow_s) { + Ok(gps_time) => gps_time, + Err(e) => return Some(Err(e.into())), + }; + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -} -impl WireFormat for MsgGpsTime { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.wn) - + WireFormat::len(&self.tow) - + WireFormat::len(&self.ns_residual) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl TryFrom for MsgGpsTime { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgGpsTime(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} - -/// Time source -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgGpsTimeTimeSource { - /// None (invalid) - None = 0, - - /// GNSS Solution - GnssSolution = 1, - /// Propagated - Propagated = 2, -} - -impl std::fmt::Display for MsgGpsTimeTimeSource { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgGpsTimeTimeSource::None => f.write_str("None (invalid)"), - MsgGpsTimeTimeSource::GnssSolution => f.write_str("GNSS Solution"), - MsgGpsTimeTimeSource::Propagated => f.write_str("Propagated"), + impl WireFormat for MsgGpsTime { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.wn) + + WireFormat::len(&self.tow) + + WireFormat::len(&self.ns_residual) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// GPS Time (v1.0) -/// -/// This message reports the GPS time, representing the time since the GPS -/// epoch began on midnight January 6, 1980 UTC. GPS time counts the weeks and -/// seconds of the week. The weeks begin at the Saturday/Sunday transition. -/// GPS week 0 began at the beginning of the GPS time scale. -/// -/// Within each week number, the GPS time of the week is between between 0 and -/// 604800 seconds (=60*60*24*7). Note that GPS time does not accumulate leap -/// seconds, and as of now, has a small offset from UTC. In a message stream, -/// this message precedes a set of other navigation messages referenced to the -/// same time (but lacking the ns field) and indicates a more precise time of -/// these messages. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} + /// Time source + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TimeSource { + /// None (invalid) + None = 0, -impl ConcreteMessage for MsgGpsTimeDepA { - const MESSAGE_TYPE: u16 = 256; - const MESSAGE_NAME: &'static str = "MSG_GPS_TIME_DEP_A"; -} + /// GNSS Solution + GnssSolution = 1, -impl SbpMessage for MsgGpsTimeDepA { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + /// Propagated + Propagated = 2, } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - #[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 time::GpsTime::new(wn, tow_s) { - Ok(gps_time) => gps_time, - Err(e) => return Some(Err(e.into())), - }; - Some(Ok(time::MessageTime::Rover(gps_time.into()))) + + impl std::fmt::Display for TimeSource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TimeSource::None => f.write_str("None (invalid)"), + TimeSource::GnssSolution => f.write_str("GNSS Solution"), + TimeSource::Propagated => f.write_str("Propagated"), + } + } } } -impl TryFrom for MsgGpsTimeDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgGpsTimeDepA(m) => Ok(m), - _ => Err(TryFromSbpError), +pub mod msg_gps_time_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// GPS Time (v1.0) + /// + /// This message reports the GPS time, representing the time since the GPS + /// epoch began on midnight January 6, 1980 UTC. GPS time counts the weeks and + /// seconds of the week. The weeks begin at the Saturday/Sunday transition. + /// GPS week 0 began at the beginning of the GPS time scale. + /// + /// Within each week number, the GPS time of the week is between between 0 and + /// 604800 seconds (=60*60*24*7). Note that GPS time does not accumulate leap + /// seconds, and as of now, has a small offset from UTC. In a message stream, + /// this message precedes a set of other navigation messages referenced to the + /// same time (but lacking the ns field) and indicates a more precise time of + /// these messages. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 ConcreteMessage for MsgGpsTimeDepA { + const MESSAGE_TYPE: u16 = 256; + const MESSAGE_NAME: &'static str = "MSG_GPS_TIME_DEP_A"; + } + + impl SbpMessage for MsgGpsTimeDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + #[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 time::GpsTime::new(wn, tow_s) { + Ok(gps_time) => gps_time, + Err(e) => return Some(Err(e.into())), + }; + Some(Ok(time::MessageTime::Rover(gps_time.into()))) + } + } + + impl TryFrom for MsgGpsTimeDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgGpsTimeDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgGpsTimeDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.wn) - + WireFormat::len(&self.tow) - + WireFormat::len(&self.ns_residual) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgGpsTimeDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.wn) + + WireFormat::len(&self.tow) + + WireFormat::len(&self.ns_residual) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// GPS Time -/// -/// This message reports the GPS time, representing the time since the GPS -/// epoch began on midnight January 6, 1980 UTC. GPS time counts the weeks and -/// seconds of the week. The weeks begin at the Saturday/Sunday transition. -/// GPS week 0 began at the beginning of the GPS time scale. -/// -/// Within each week number, the GPS time of the week is between between 0 and -/// 604800 seconds (=60*60*24*7). Note that GPS time does not accumulate leap -/// seconds, and as of now, has a small offset from UTC. In a message stream, -/// this message precedes a set of other navigation messages referenced to the -/// same time (but lacking the ns field) and indicates a more precise time of -/// these messages. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_gps_time_gnss { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// GPS Time + /// + /// This message reports the GPS time, representing the time since the GPS + /// epoch began on midnight January 6, 1980 UTC. GPS time counts the weeks and + /// seconds of the week. The weeks begin at the Saturday/Sunday transition. + /// GPS week 0 began at the beginning of the GPS time scale. + /// + /// Within each week number, the GPS time of the week is between between 0 and + /// 604800 seconds (=60*60*24*7). Note that GPS time does not accumulate leap + /// seconds, and as of now, has a small offset from UTC. In a message stream, + /// this message precedes a set of other navigation messages referenced to the + /// same time (but lacking the ns field) and indicates a more precise time of + /// these messages. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn time_source(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(TimeSource::None), + 1 => Some(TimeSource::GnssSolution), + 2 => Some(TimeSource::Propagated), + _ => None, + } + } -impl MsgGpsTimeGnss { - pub fn time_source(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgGpsTimeGnssTimeSource::None), - 1 => Some(MsgGpsTimeGnssTimeSource::GnssSolution), - 2 => Some(MsgGpsTimeGnssTimeSource::Propagated), - _ => None, + pub fn set_time_source(&mut self, time_source: TimeSource) { + set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); } } - pub fn set_time_source(&mut self, time_source: MsgGpsTimeGnssTimeSource) { - set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); + impl ConcreteMessage for MsgGpsTimeGnss { + const MESSAGE_TYPE: u16 = 260; + const MESSAGE_NAME: &'static str = "MSG_GPS_TIME_GNSS"; } -} -impl ConcreteMessage for MsgGpsTimeGnss { - const MESSAGE_TYPE: u16 = 260; - const MESSAGE_NAME: &'static str = "MSG_GPS_TIME_GNSS"; -} - -impl SbpMessage for MsgGpsTimeGnss { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - #[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 time::GpsTime::new(wn, tow_s) { - Ok(gps_time) => gps_time, - Err(e) => return Some(Err(e.into())), - }; - Some(Ok(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgGpsTimeGnss { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + #[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 time::GpsTime::new(wn, tow_s) { + Ok(gps_time) => gps_time, + Err(e) => return Some(Err(e.into())), + }; + Some(Ok(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgGpsTimeGnss { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgGpsTimeGnss(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgGpsTimeGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgGpsTimeGnss(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgGpsTimeGnss { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.wn) - + WireFormat::len(&self.tow) - + WireFormat::len(&self.ns_residual) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgGpsTimeGnss { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.wn) + + WireFormat::len(&self.tow) + + WireFormat::len(&self.ns_residual) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Time source -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgGpsTimeGnssTimeSource { - /// None (invalid) - None = 0, + /// Time source + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TimeSource { + /// None (invalid) + None = 0, - /// GNSS Solution - GnssSolution = 1, + /// GNSS Solution + GnssSolution = 1, - /// Propagated - Propagated = 2, -} + /// Propagated + Propagated = 2, + } -impl std::fmt::Display for MsgGpsTimeGnssTimeSource { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgGpsTimeGnssTimeSource::None => f.write_str("None (invalid)"), - MsgGpsTimeGnssTimeSource::GnssSolution => f.write_str("GNSS Solution"), - MsgGpsTimeGnssTimeSource::Propagated => f.write_str("Propagated"), + impl std::fmt::Display for TimeSource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TimeSource::None => f.write_str("None (invalid)"), + TimeSource::GnssSolution => f.write_str("GNSS Solution"), + TimeSource::Propagated => f.write_str("Propagated"), + } } } } -/// Single-point position in ECEF -/// -/// The position solution message reports absolute Earth Centered Earth Fixed -/// (ECEF) coordinates and the status (single point vs pseudo-absolute RTK) of -/// the position solution. If the rover receiver knows the surveyed position -/// of the base station and has an RTK solution, this reports a pseudo- -/// absolute position solution using the base station position and the 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_pos_ecef { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Single-point position in ECEF + /// + /// The position solution message reports absolute Earth Centered Earth Fixed + /// (ECEF) coordinates and the status (single point vs pseudo-absolute RTK) of + /// the position solution. If the rover receiver knows the surveyed position + /// of the base station and has an RTK solution, this reports a pseudo- + /// absolute position solution using the base station position and the 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn tow_type(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 5) { + 0 => Some(TowType::TimeOfMeasurement), + 1 => Some(TowType::Other), + _ => None, + } + } -impl MsgPosEcef { - pub fn tow_type(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 5) { - 0 => Some(MsgPosEcefTowType::TimeOfMeasurement), - 1 => Some(MsgPosEcefTowType::Other), - _ => None, + pub fn set_tow_type(&mut self, tow_type: TowType) { + set_bit_range!(&mut self.flags, tow_type, u8, u8, 5, 5); } - } - pub fn set_tow_type(&mut self, tow_type: MsgPosEcefTowType) { - set_bit_range!(&mut self.flags, tow_type, u8, u8, 5, 5); - } + pub fn inertial_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(InertialNavigationMode::None), + 1 => Some(InertialNavigationMode::InsUsed), + _ => None, + } + } - pub fn inertial_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(MsgPosEcefInertialNavigationMode::None), - 1 => Some(MsgPosEcefInertialNavigationMode::InsUsed), - _ => None, + pub fn set_inertial_navigation_mode( + &mut self, + inertial_navigation_mode: InertialNavigationMode, + ) { + set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); } - } - pub fn set_inertial_navigation_mode( - &mut self, - inertial_navigation_mode: MsgPosEcefInertialNavigationMode, - ) { - set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); - } + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(FixMode::Invalid), + 1 => Some(FixMode::SinglePointPosition), + 2 => Some(FixMode::DifferentialGnss), + 3 => Some(FixMode::FloatRtk), + 4 => Some(FixMode::FixedRtk), + 5 => Some(FixMode::DeadReckoning), + 6 => Some(FixMode::SbasPosition), + _ => None, + } + } - pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgPosEcefFixMode::Invalid), - 1 => Some(MsgPosEcefFixMode::SinglePointPosition), - 2 => Some(MsgPosEcefFixMode::DifferentialGnss), - 3 => Some(MsgPosEcefFixMode::FloatRtk), - 4 => Some(MsgPosEcefFixMode::FixedRtk), - 5 => Some(MsgPosEcefFixMode::DeadReckoning), - 6 => Some(MsgPosEcefFixMode::SbasPosition), - _ => None, + pub fn set_fix_mode(&mut self, fix_mode: FixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } } - pub fn set_fix_mode(&mut self, fix_mode: MsgPosEcefFixMode) { - set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgPosEcef { + const MESSAGE_TYPE: u16 = 521; + const MESSAGE_NAME: &'static str = "MSG_POS_ECEF"; } -} - -impl ConcreteMessage for MsgPosEcef { - const MESSAGE_TYPE: u16 = 521; - const MESSAGE_NAME: &'static str = "MSG_POS_ECEF"; -} -impl SbpMessage for MsgPosEcef { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgPosEcef { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgPosEcef { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgPosEcef(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgPosEcef { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgPosEcef(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgPosEcef { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.x) - + WireFormat::len(&self.y) - + WireFormat::len(&self.z) - + WireFormat::len(&self.accuracy) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgPosEcef { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.x) + + WireFormat::len(&self.y) + + WireFormat::len(&self.z) + + WireFormat::len(&self.accuracy) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// TOW type -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosEcefTowType { - /// Time of Measurement - TimeOfMeasurement = 0, + /// TOW type + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TowType { + /// Time of Measurement + TimeOfMeasurement = 0, - /// Other - Other = 1, -} + /// Other + Other = 1, + } -impl std::fmt::Display for MsgPosEcefTowType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosEcefTowType::TimeOfMeasurement => f.write_str("Time of Measurement"), - MsgPosEcefTowType::Other => f.write_str("Other"), + impl std::fmt::Display for TowType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TowType::TimeOfMeasurement => f.write_str("Time of Measurement"), + TowType::Other => f.write_str("Other"), + } } } -} -/// Inertial Navigation Mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosEcefInertialNavigationMode { - /// None - None = 0, + /// Inertial Navigation Mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum InertialNavigationMode { + /// None + None = 0, - /// INS used - InsUsed = 1, -} + /// INS used + InsUsed = 1, + } -impl std::fmt::Display for MsgPosEcefInertialNavigationMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosEcefInertialNavigationMode::None => f.write_str("None"), - MsgPosEcefInertialNavigationMode::InsUsed => f.write_str("INS used"), + impl std::fmt::Display for InertialNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + InertialNavigationMode::None => f.write_str("None"), + InertialNavigationMode::InsUsed => f.write_str("INS used"), + } } } -} -/// Fix mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosEcefFixMode { - /// Invalid - Invalid = 0, + /// Fix mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FixMode { + /// Invalid + Invalid = 0, - /// Single Point Position (SPP) - SinglePointPosition = 1, + /// Single Point Position (SPP) + SinglePointPosition = 1, - /// Differential GNSS (DGNSS) - DifferentialGnss = 2, + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, - /// Float RTK - FloatRtk = 3, + /// Float RTK + FloatRtk = 3, - /// Fixed RTK - FixedRtk = 4, + /// Fixed RTK + FixedRtk = 4, - /// Dead Reckoning - DeadReckoning = 5, + /// Dead Reckoning + DeadReckoning = 5, - /// SBAS Position - SbasPosition = 6, -} + /// SBAS Position + SbasPosition = 6, + } -impl std::fmt::Display for MsgPosEcefFixMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosEcefFixMode::Invalid => f.write_str("Invalid"), - MsgPosEcefFixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), - MsgPosEcefFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), - MsgPosEcefFixMode::FloatRtk => f.write_str("Float RTK"), - MsgPosEcefFixMode::FixedRtk => f.write_str("Fixed RTK"), - MsgPosEcefFixMode::DeadReckoning => f.write_str("Dead Reckoning"), - MsgPosEcefFixMode::SbasPosition => f.write_str("SBAS Position"), + impl std::fmt::Display for FixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FixMode::Invalid => f.write_str("Invalid"), + FixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), + FixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + FixMode::FloatRtk => f.write_str("Float RTK"), + FixMode::FixedRtk => f.write_str("Fixed RTK"), + FixMode::DeadReckoning => f.write_str("Dead Reckoning"), + FixMode::SbasPosition => f.write_str("SBAS Position"), + } } } } -/// Single-point position in ECEF -/// -/// The position solution message reports absolute Earth Centered Earth Fixed -/// (ECEF) coordinates and the status (single point vs pseudo-absolute RTK) of -/// the position solution. The message also reports the upper triangular -/// portion of the 3x3 covariance matrix. If the receiver knows the surveyed -/// position of the base station and has an RTK solution, this reports a -/// pseudo-absolute position solution using the base station position and the -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_pos_ecef_cov { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Single-point position in ECEF + /// + /// The position solution message reports absolute Earth Centered Earth Fixed + /// (ECEF) coordinates and the status (single point vs pseudo-absolute RTK) of + /// the position solution. The message also reports the upper triangular + /// portion of the 3x3 covariance matrix. If the receiver knows the surveyed + /// position of the base station and has an RTK solution, this reports a + /// pseudo-absolute position solution using the base station position and the + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn type_of_reported_tow(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 5) { + 0 => Some(TypeOfReportedTow::TimeOfMeasurement), + 1 => Some(TypeOfReportedTow::Other), + _ => None, + } + } -impl MsgPosEcefCov { - pub fn type_of_reported_tow(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 5) { - 0 => Some(MsgPosEcefCovTypeOfReportedTow::TimeOfMeasurement), - 1 => Some(MsgPosEcefCovTypeOfReportedTow::Other), - _ => None, + pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { + set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } - } - pub fn set_type_of_reported_tow( - &mut self, - type_of_reported_tow: MsgPosEcefCovTypeOfReportedTow, - ) { - set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); - } + pub fn inertial_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(InertialNavigationMode::None), + 1 => Some(InertialNavigationMode::InsUsed), + _ => None, + } + } - pub fn inertial_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(MsgPosEcefCovInertialNavigationMode::None), - 1 => Some(MsgPosEcefCovInertialNavigationMode::InsUsed), - _ => None, + pub fn set_inertial_navigation_mode( + &mut self, + inertial_navigation_mode: InertialNavigationMode, + ) { + set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); } - } - pub fn set_inertial_navigation_mode( - &mut self, - inertial_navigation_mode: MsgPosEcefCovInertialNavigationMode, - ) { - set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); - } + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(FixMode::Invalid), + 1 => Some(FixMode::SinglePointPosition), + 2 => Some(FixMode::DifferentialGnss), + 3 => Some(FixMode::FloatRtk), + 4 => Some(FixMode::FixedRtk), + 5 => Some(FixMode::DeadReckoning), + 6 => Some(FixMode::SbasPosition), + _ => None, + } + } - pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgPosEcefCovFixMode::Invalid), - 1 => Some(MsgPosEcefCovFixMode::SinglePointPosition), - 2 => Some(MsgPosEcefCovFixMode::DifferentialGnss), - 3 => Some(MsgPosEcefCovFixMode::FloatRtk), - 4 => Some(MsgPosEcefCovFixMode::FixedRtk), - 5 => Some(MsgPosEcefCovFixMode::DeadReckoning), - 6 => Some(MsgPosEcefCovFixMode::SbasPosition), - _ => None, + pub fn set_fix_mode(&mut self, fix_mode: FixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } } - pub fn set_fix_mode(&mut self, fix_mode: MsgPosEcefCovFixMode) { - set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgPosEcefCov { + const MESSAGE_TYPE: u16 = 532; + const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_COV"; } -} -impl ConcreteMessage for MsgPosEcefCov { - const MESSAGE_TYPE: u16 = 532; - const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_COV"; -} - -impl SbpMessage for MsgPosEcefCov { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgPosEcefCov { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgPosEcefCov { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgPosEcefCov(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgPosEcefCov { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgPosEcefCov(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgPosEcefCov { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.x) - + WireFormat::len(&self.y) - + WireFormat::len(&self.z) - + WireFormat::len(&self.cov_x_x) - + WireFormat::len(&self.cov_x_y) - + WireFormat::len(&self.cov_x_z) - + WireFormat::len(&self.cov_y_y) - + WireFormat::len(&self.cov_y_z) - + WireFormat::len(&self.cov_z_z) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgPosEcefCov { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.x) + + WireFormat::len(&self.y) + + WireFormat::len(&self.z) + + WireFormat::len(&self.cov_x_x) + + WireFormat::len(&self.cov_x_y) + + WireFormat::len(&self.cov_x_z) + + WireFormat::len(&self.cov_y_y) + + WireFormat::len(&self.cov_y_z) + + WireFormat::len(&self.cov_z_z) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Type of reported TOW -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosEcefCovTypeOfReportedTow { - /// Time of Measurement - TimeOfMeasurement = 0, + /// Type of reported TOW + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TypeOfReportedTow { + /// Time of Measurement + TimeOfMeasurement = 0, - /// Other - Other = 1, -} + /// Other + Other = 1, + } -impl std::fmt::Display for MsgPosEcefCovTypeOfReportedTow { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosEcefCovTypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), - MsgPosEcefCovTypeOfReportedTow::Other => f.write_str("Other"), + impl std::fmt::Display for TypeOfReportedTow { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), + TypeOfReportedTow::Other => f.write_str("Other"), + } } } -} -/// Inertial Navigation Mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosEcefCovInertialNavigationMode { - /// None - None = 0, + /// Inertial Navigation Mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum InertialNavigationMode { + /// None + None = 0, - /// INS used - InsUsed = 1, -} + /// INS used + InsUsed = 1, + } -impl std::fmt::Display for MsgPosEcefCovInertialNavigationMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosEcefCovInertialNavigationMode::None => f.write_str("None"), - MsgPosEcefCovInertialNavigationMode::InsUsed => f.write_str("INS used"), + impl std::fmt::Display for InertialNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + InertialNavigationMode::None => f.write_str("None"), + InertialNavigationMode::InsUsed => f.write_str("INS used"), + } } } -} -/// Fix mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosEcefCovFixMode { - /// Invalid - Invalid = 0, + /// Fix mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FixMode { + /// Invalid + Invalid = 0, - /// Single Point Position (SPP) - SinglePointPosition = 1, + /// Single Point Position (SPP) + SinglePointPosition = 1, - /// Differential GNSS (DGNSS) - DifferentialGnss = 2, + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, - /// Float RTK - FloatRtk = 3, + /// Float RTK + FloatRtk = 3, - /// Fixed RTK - FixedRtk = 4, + /// Fixed RTK + FixedRtk = 4, - /// Dead Reckoning - DeadReckoning = 5, + /// Dead Reckoning + DeadReckoning = 5, - /// SBAS Position - SbasPosition = 6, -} + /// SBAS Position + SbasPosition = 6, + } -impl std::fmt::Display for MsgPosEcefCovFixMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosEcefCovFixMode::Invalid => f.write_str("Invalid"), - MsgPosEcefCovFixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), - MsgPosEcefCovFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), - MsgPosEcefCovFixMode::FloatRtk => f.write_str("Float RTK"), - MsgPosEcefCovFixMode::FixedRtk => f.write_str("Fixed RTK"), - MsgPosEcefCovFixMode::DeadReckoning => f.write_str("Dead Reckoning"), - MsgPosEcefCovFixMode::SbasPosition => f.write_str("SBAS Position"), + impl std::fmt::Display for FixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FixMode::Invalid => f.write_str("Invalid"), + FixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), + FixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + FixMode::FloatRtk => f.write_str("Float RTK"), + FixMode::FixedRtk => f.write_str("Fixed RTK"), + FixMode::DeadReckoning => f.write_str("Dead Reckoning"), + FixMode::SbasPosition => f.write_str("SBAS Position"), + } } } } -/// GNSS-only Position in ECEF -/// -/// The position solution message reports absolute Earth Centered Earth Fixed -/// (ECEF) coordinates and the status (single point vs pseudo-absolute RTK) of -/// the position solution. The message also reports the upper triangular -/// portion of the 3x3 covariance matrix. If the receiver knows the surveyed -/// position of the base station and has an RTK solution, this reports a -/// pseudo-absolute position solution using the base station position and the -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_pos_ecef_cov_gnss { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// GNSS-only Position in ECEF + /// + /// The position solution message reports absolute Earth Centered Earth Fixed + /// (ECEF) coordinates and the status (single point vs pseudo-absolute RTK) of + /// the position solution. The message also reports the upper triangular + /// portion of the 3x3 covariance matrix. If the receiver knows the surveyed + /// position of the base station and has an RTK solution, this reports a + /// pseudo-absolute position solution using the base station position and the + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(FixMode::Invalid), + 1 => Some(FixMode::SinglePointPosition), + 2 => Some(FixMode::DifferentialGnss), + 3 => Some(FixMode::FloatRtk), + 4 => Some(FixMode::FixedRtk), + 6 => Some(FixMode::SbasPosition), + _ => None, + } + } -impl MsgPosEcefCovGnss { - pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgPosEcefCovGnssFixMode::Invalid), - 1 => Some(MsgPosEcefCovGnssFixMode::SinglePointPosition), - 2 => Some(MsgPosEcefCovGnssFixMode::DifferentialGnss), - 3 => Some(MsgPosEcefCovGnssFixMode::FloatRtk), - 4 => Some(MsgPosEcefCovGnssFixMode::FixedRtk), - 6 => Some(MsgPosEcefCovGnssFixMode::SbasPosition), - _ => None, + pub fn set_fix_mode(&mut self, fix_mode: FixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } } - pub fn set_fix_mode(&mut self, fix_mode: MsgPosEcefCovGnssFixMode) { - set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgPosEcefCovGnss { + const MESSAGE_TYPE: u16 = 564; + const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_COV_GNSS"; } -} - -impl ConcreteMessage for MsgPosEcefCovGnss { - const MESSAGE_TYPE: u16 = 564; - const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_COV_GNSS"; -} -impl SbpMessage for MsgPosEcefCovGnss { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgPosEcefCovGnss { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgPosEcefCovGnss { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgPosEcefCovGnss(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgPosEcefCovGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgPosEcefCovGnss(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgPosEcefCovGnss { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.x) - + WireFormat::len(&self.y) - + WireFormat::len(&self.z) - + WireFormat::len(&self.cov_x_x) - + WireFormat::len(&self.cov_x_y) - + WireFormat::len(&self.cov_x_z) - + WireFormat::len(&self.cov_y_y) - + WireFormat::len(&self.cov_y_z) - + WireFormat::len(&self.cov_z_z) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgPosEcefCovGnss { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.x) + + WireFormat::len(&self.y) + + WireFormat::len(&self.z) + + WireFormat::len(&self.cov_x_x) + + WireFormat::len(&self.cov_x_y) + + WireFormat::len(&self.cov_x_z) + + WireFormat::len(&self.cov_y_y) + + WireFormat::len(&self.cov_y_z) + + WireFormat::len(&self.cov_z_z) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Fix mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosEcefCovGnssFixMode { - /// Invalid - Invalid = 0, + /// Fix mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FixMode { + /// Invalid + Invalid = 0, - /// Single Point Position (SPP) - SinglePointPosition = 1, + /// Single Point Position (SPP) + SinglePointPosition = 1, - /// Differential GNSS (DGNSS) - DifferentialGnss = 2, + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, - /// Float RTK - FloatRtk = 3, + /// Float RTK + FloatRtk = 3, - /// Fixed RTK - FixedRtk = 4, + /// Fixed RTK + FixedRtk = 4, - /// SBAS Position - SbasPosition = 6, -} + /// SBAS Position + SbasPosition = 6, + } -impl std::fmt::Display for MsgPosEcefCovGnssFixMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosEcefCovGnssFixMode::Invalid => f.write_str("Invalid"), - MsgPosEcefCovGnssFixMode::SinglePointPosition => { - f.write_str("Single Point Position (SPP)") + impl std::fmt::Display for FixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FixMode::Invalid => f.write_str("Invalid"), + FixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), + FixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + FixMode::FloatRtk => f.write_str("Float RTK"), + FixMode::FixedRtk => f.write_str("Fixed RTK"), + FixMode::SbasPosition => f.write_str("SBAS Position"), } - MsgPosEcefCovGnssFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), - MsgPosEcefCovGnssFixMode::FloatRtk => f.write_str("Float RTK"), - MsgPosEcefCovGnssFixMode::FixedRtk => f.write_str("Fixed RTK"), - MsgPosEcefCovGnssFixMode::SbasPosition => f.write_str("SBAS Position"), } } } -/// Single-point position in ECEF -/// -/// The position solution message reports absolute Earth Centered Earth Fixed -/// (ECEF) coordinates and the status (single point vs pseudo-absolute RTK) of -/// the position solution. If the rover receiver knows the surveyed position -/// of the base station and has an RTK solution, this reports a pseudo- -/// absolute position solution using the base station position and the 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_pos_ecef_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Single-point position in ECEF + /// + /// The position solution message reports absolute Earth Centered Earth Fixed + /// (ECEF) coordinates and the status (single point vs pseudo-absolute RTK) of + /// the position solution. If the rover receiver knows the surveyed position + /// of the base station and has an RTK solution, this reports a pseudo- + /// absolute position solution using the base station position and the 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn raim_repair_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 0) { + 0 => Some(RaimRepairFlag::NoRepair), + 1 => Some(RaimRepairFlag::SolutionCameFromRaimRepair), + _ => None, + } + } -impl MsgPosEcefDepA { - pub fn raim_repair_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 0) { - 0 => Some(MsgPosEcefDepARaimRepairFlag::NoRepair), - 1 => Some(MsgPosEcefDepARaimRepairFlag::SolutionCameFromRaimRepair), - _ => None, + pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { + set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); } - } - pub fn set_raim_repair_flag(&mut self, raim_repair_flag: MsgPosEcefDepARaimRepairFlag) { - set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); - } + pub fn raim_availability_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 0) { + 0 => Some(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), + 1 => Some(RaimAvailabilityFlag::RaimCheckWasAvailable), + _ => None, + } + } - pub fn raim_availability_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 0) { - 0 => Some( - MsgPosEcefDepARaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable, - ), - 1 => Some(MsgPosEcefDepARaimAvailabilityFlag::RaimCheckWasAvailable), - _ => None, + pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { + set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); } - } - pub fn set_raim_availability_flag( - &mut self, - raim_availability_flag: MsgPosEcefDepARaimAvailabilityFlag, - ) { - set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); - } + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(FixMode::SinglePointPositioning), + 1 => Some(FixMode::FixedRtk), + 2 => Some(FixMode::FloatRtk), + _ => None, + } + } - pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgPosEcefDepAFixMode::SinglePointPositioning), - 1 => Some(MsgPosEcefDepAFixMode::FixedRtk), - 2 => Some(MsgPosEcefDepAFixMode::FloatRtk), - _ => None, + pub fn set_fix_mode(&mut self, fix_mode: FixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } } - pub fn set_fix_mode(&mut self, fix_mode: MsgPosEcefDepAFixMode) { - set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgPosEcefDepA { + const MESSAGE_TYPE: u16 = 512; + const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_DEP_A"; } -} - -impl ConcreteMessage for MsgPosEcefDepA { - const MESSAGE_TYPE: u16 = 512; - const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_DEP_A"; -} -impl SbpMessage for MsgPosEcefDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgPosEcefDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgPosEcefDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgPosEcefDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgPosEcefDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgPosEcefDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgPosEcefDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.x) - + WireFormat::len(&self.y) - + WireFormat::len(&self.z) - + WireFormat::len(&self.accuracy) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgPosEcefDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.x) + + WireFormat::len(&self.y) + + WireFormat::len(&self.z) + + WireFormat::len(&self.accuracy) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// RAIM repair flag -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosEcefDepARaimRepairFlag { - /// No repair - NoRepair = 0, + /// RAIM repair flag + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum RaimRepairFlag { + /// No repair + NoRepair = 0, - /// Solution came from RAIM repair - SolutionCameFromRaimRepair = 1, -} + /// Solution came from RAIM repair + SolutionCameFromRaimRepair = 1, + } -impl std::fmt::Display for MsgPosEcefDepARaimRepairFlag { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosEcefDepARaimRepairFlag::NoRepair => f.write_str("No repair"), - MsgPosEcefDepARaimRepairFlag::SolutionCameFromRaimRepair => { - f.write_str("Solution came from RAIM repair") + impl std::fmt::Display for RaimRepairFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + RaimRepairFlag::NoRepair => f.write_str("No repair"), + RaimRepairFlag::SolutionCameFromRaimRepair => { + f.write_str("Solution came from RAIM repair") + } } } } -} -/// RAIM availability flag -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosEcefDepARaimAvailabilityFlag { - /// RAIM check was explicitly disabled or unavailable - RaimCheckWasExplicitlyDisabledOrUnavailable = 0, + /// RAIM availability flag + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum RaimAvailabilityFlag { + /// RAIM check was explicitly disabled or unavailable + RaimCheckWasExplicitlyDisabledOrUnavailable = 0, - /// RAIM check was available - RaimCheckWasAvailable = 1, -} + /// RAIM check was available + RaimCheckWasAvailable = 1, + } -impl std::fmt::Display for MsgPosEcefDepARaimAvailabilityFlag { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosEcefDepARaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable => { - f.write_str("RAIM check was explicitly disabled or unavailable") - } - MsgPosEcefDepARaimAvailabilityFlag::RaimCheckWasAvailable => { - f.write_str("RAIM check was available") + impl std::fmt::Display for RaimAvailabilityFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable => { + f.write_str("RAIM check was explicitly disabled or unavailable") + } + RaimAvailabilityFlag::RaimCheckWasAvailable => { + f.write_str("RAIM check was available") + } } } } -} -/// Fix mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosEcefDepAFixMode { - /// Single Point Positioning (SPP) - SinglePointPositioning = 0, + /// Fix mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FixMode { + /// Single Point Positioning (SPP) + SinglePointPositioning = 0, - /// Fixed RTK - FixedRtk = 1, + /// Fixed RTK + FixedRtk = 1, - /// Float RTK - FloatRtk = 2, -} + /// Float RTK + FloatRtk = 2, + } -impl std::fmt::Display for MsgPosEcefDepAFixMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosEcefDepAFixMode::SinglePointPositioning => { - f.write_str("Single Point Positioning (SPP)") + impl std::fmt::Display for FixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FixMode::SinglePointPositioning => f.write_str("Single Point Positioning (SPP)"), + FixMode::FixedRtk => f.write_str("Fixed RTK"), + FixMode::FloatRtk => f.write_str("Float RTK"), } - MsgPosEcefDepAFixMode::FixedRtk => f.write_str("Fixed RTK"), - MsgPosEcefDepAFixMode::FloatRtk => f.write_str("Float RTK"), } } } -/// GNSS-only Position in ECEF -/// -/// The position solution message reports absolute Earth Centered Earth Fixed -/// (ECEF) coordinates and the status (single point vs pseudo-absolute RTK) of -/// the position solution. If the rover receiver knows the surveyed position -/// of the base station and has an RTK solution, this reports a pseudo- -/// absolute position solution using the base station position and the 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_pos_ecef_gnss { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// GNSS-only Position in ECEF + /// + /// The position solution message reports absolute Earth Centered Earth Fixed + /// (ECEF) coordinates and the status (single point vs pseudo-absolute RTK) of + /// the position solution. If the rover receiver knows the surveyed position + /// of the base station and has an RTK solution, this reports a pseudo- + /// absolute position solution using the base station position and the 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(FixMode::Invalid), + 1 => Some(FixMode::SinglePointPosition), + 2 => Some(FixMode::DifferentialGnss), + 3 => Some(FixMode::FloatRtk), + 4 => Some(FixMode::FixedRtk), + 6 => Some(FixMode::SbasPosition), + _ => None, + } + } -impl MsgPosEcefGnss { - pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgPosEcefGnssFixMode::Invalid), - 1 => Some(MsgPosEcefGnssFixMode::SinglePointPosition), - 2 => Some(MsgPosEcefGnssFixMode::DifferentialGnss), - 3 => Some(MsgPosEcefGnssFixMode::FloatRtk), - 4 => Some(MsgPosEcefGnssFixMode::FixedRtk), - 6 => Some(MsgPosEcefGnssFixMode::SbasPosition), - _ => None, + pub fn set_fix_mode(&mut self, fix_mode: FixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } } - pub fn set_fix_mode(&mut self, fix_mode: MsgPosEcefGnssFixMode) { - set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgPosEcefGnss { + const MESSAGE_TYPE: u16 = 553; + const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_GNSS"; } -} - -impl ConcreteMessage for MsgPosEcefGnss { - const MESSAGE_TYPE: u16 = 553; - const MESSAGE_NAME: &'static str = "MSG_POS_ECEF_GNSS"; -} -impl SbpMessage for MsgPosEcefGnss { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgPosEcefGnss { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgPosEcefGnss { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgPosEcefGnss(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgPosEcefGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgPosEcefGnss(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgPosEcefGnss { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.x) - + WireFormat::len(&self.y) - + WireFormat::len(&self.z) - + WireFormat::len(&self.accuracy) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgPosEcefGnss { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.x) + + WireFormat::len(&self.y) + + WireFormat::len(&self.z) + + WireFormat::len(&self.accuracy) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Fix mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosEcefGnssFixMode { - /// Invalid - Invalid = 0, + /// Fix mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FixMode { + /// Invalid + Invalid = 0, - /// Single Point Position (SPP) - SinglePointPosition = 1, + /// Single Point Position (SPP) + SinglePointPosition = 1, - /// Differential GNSS (DGNSS) - DifferentialGnss = 2, + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, - /// Float RTK - FloatRtk = 3, + /// Float RTK + FloatRtk = 3, - /// Fixed RTK - FixedRtk = 4, + /// Fixed RTK + FixedRtk = 4, - /// SBAS Position - SbasPosition = 6, -} + /// SBAS Position + SbasPosition = 6, + } -impl std::fmt::Display for MsgPosEcefGnssFixMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosEcefGnssFixMode::Invalid => f.write_str("Invalid"), - MsgPosEcefGnssFixMode::SinglePointPosition => { - f.write_str("Single Point Position (SPP)") + impl std::fmt::Display for FixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FixMode::Invalid => f.write_str("Invalid"), + FixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), + FixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + FixMode::FloatRtk => f.write_str("Float RTK"), + FixMode::FixedRtk => f.write_str("Fixed RTK"), + FixMode::SbasPosition => f.write_str("SBAS Position"), } - MsgPosEcefGnssFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), - MsgPosEcefGnssFixMode::FloatRtk => f.write_str("Float RTK"), - MsgPosEcefGnssFixMode::FixedRtk => f.write_str("Fixed RTK"), - MsgPosEcefGnssFixMode::SbasPosition => f.write_str("SBAS Position"), } } } -/// Geodetic Position -/// -/// This position solution message reports the absolute geodetic coordinates -/// and the status (single point vs pseudo-absolute RTK) of the position -/// solution. If the rover receiver knows the surveyed position of the base -/// station and has an RTK solution, this reports a pseudo-absolute position -/// solution using the base station position and the 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_pos_llh { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Geodetic Position + /// + /// This position solution message reports the absolute geodetic coordinates + /// and the status (single point vs pseudo-absolute RTK) of the position + /// solution. If the rover receiver knows the surveyed position of the base + /// station and has an RTK solution, this reports a pseudo-absolute position + /// solution using the base station position and the 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn type_of_reported_tow(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 5) { + 0 => Some(TypeOfReportedTow::TimeOfMeasurement), + 1 => Some(TypeOfReportedTow::Other), + _ => None, + } + } -impl MsgPosLlh { - pub fn type_of_reported_tow(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 5) { - 0 => Some(MsgPosLlhTypeOfReportedTow::TimeOfMeasurement), - 1 => Some(MsgPosLlhTypeOfReportedTow::Other), - _ => None, + pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { + set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } - } - pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: MsgPosLlhTypeOfReportedTow) { - set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); - } + pub fn inertial_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(InertialNavigationMode::None), + 1 => Some(InertialNavigationMode::InsUsed), + _ => None, + } + } - pub fn inertial_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(MsgPosLlhInertialNavigationMode::None), - 1 => Some(MsgPosLlhInertialNavigationMode::InsUsed), - _ => None, + pub fn set_inertial_navigation_mode( + &mut self, + inertial_navigation_mode: InertialNavigationMode, + ) { + set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); } - } - pub fn set_inertial_navigation_mode( - &mut self, - inertial_navigation_mode: MsgPosLlhInertialNavigationMode, - ) { - set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); - } + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(FixMode::Invalid), + 1 => Some(FixMode::SinglePointPosition), + 2 => Some(FixMode::DifferentialGnss), + 3 => Some(FixMode::FloatRtk), + 4 => Some(FixMode::FixedRtk), + 5 => Some(FixMode::DeadReckoning), + 6 => Some(FixMode::SbasPosition), + _ => None, + } + } - pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgPosLlhFixMode::Invalid), - 1 => Some(MsgPosLlhFixMode::SinglePointPosition), - 2 => Some(MsgPosLlhFixMode::DifferentialGnss), - 3 => Some(MsgPosLlhFixMode::FloatRtk), - 4 => Some(MsgPosLlhFixMode::FixedRtk), - 5 => Some(MsgPosLlhFixMode::DeadReckoning), - 6 => Some(MsgPosLlhFixMode::SbasPosition), - _ => None, + pub fn set_fix_mode(&mut self, fix_mode: FixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } } - pub fn set_fix_mode(&mut self, fix_mode: MsgPosLlhFixMode) { - set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgPosLlh { + const MESSAGE_TYPE: u16 = 522; + const MESSAGE_NAME: &'static str = "MSG_POS_LLH"; } -} -impl ConcreteMessage for MsgPosLlh { - const MESSAGE_TYPE: u16 = 522; - const MESSAGE_NAME: &'static str = "MSG_POS_LLH"; -} - -impl SbpMessage for MsgPosLlh { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgPosLlh { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgPosLlh { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgPosLlh(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgPosLlh { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgPosLlh(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgPosLlh { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.lat) - + WireFormat::len(&self.lon) - + WireFormat::len(&self.height) - + WireFormat::len(&self.h_accuracy) - + WireFormat::len(&self.v_accuracy) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgPosLlh { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.lat) + + WireFormat::len(&self.lon) + + WireFormat::len(&self.height) + + WireFormat::len(&self.h_accuracy) + + WireFormat::len(&self.v_accuracy) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Type of reported TOW -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosLlhTypeOfReportedTow { - /// Time of Measurement - TimeOfMeasurement = 0, + /// Type of reported TOW + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TypeOfReportedTow { + /// Time of Measurement + TimeOfMeasurement = 0, - /// Other - Other = 1, -} + /// Other + Other = 1, + } -impl std::fmt::Display for MsgPosLlhTypeOfReportedTow { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosLlhTypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), - MsgPosLlhTypeOfReportedTow::Other => f.write_str("Other"), + impl std::fmt::Display for TypeOfReportedTow { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), + TypeOfReportedTow::Other => f.write_str("Other"), + } } } -} -/// Inertial Navigation Mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosLlhInertialNavigationMode { - /// None - None = 0, + /// Inertial Navigation Mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum InertialNavigationMode { + /// None + None = 0, - /// INS used - InsUsed = 1, -} + /// INS used + InsUsed = 1, + } -impl std::fmt::Display for MsgPosLlhInertialNavigationMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosLlhInertialNavigationMode::None => f.write_str("None"), - MsgPosLlhInertialNavigationMode::InsUsed => f.write_str("INS used"), + impl std::fmt::Display for InertialNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + InertialNavigationMode::None => f.write_str("None"), + InertialNavigationMode::InsUsed => f.write_str("INS used"), + } } } -} -/// Fix mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosLlhFixMode { - /// Invalid - Invalid = 0, + /// Fix mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FixMode { + /// Invalid + Invalid = 0, - /// Single Point Position (SPP) - SinglePointPosition = 1, + /// Single Point Position (SPP) + SinglePointPosition = 1, - /// Differential GNSS (DGNSS) - DifferentialGnss = 2, + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, - /// Float RTK - FloatRtk = 3, + /// Float RTK + FloatRtk = 3, - /// Fixed RTK - FixedRtk = 4, + /// Fixed RTK + FixedRtk = 4, - /// Dead Reckoning - DeadReckoning = 5, + /// Dead Reckoning + DeadReckoning = 5, - /// SBAS Position - SbasPosition = 6, -} + /// SBAS Position + SbasPosition = 6, + } -impl std::fmt::Display for MsgPosLlhFixMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosLlhFixMode::Invalid => f.write_str("Invalid"), - MsgPosLlhFixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), - MsgPosLlhFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), - MsgPosLlhFixMode::FloatRtk => f.write_str("Float RTK"), - MsgPosLlhFixMode::FixedRtk => f.write_str("Fixed RTK"), - MsgPosLlhFixMode::DeadReckoning => f.write_str("Dead Reckoning"), - MsgPosLlhFixMode::SbasPosition => f.write_str("SBAS Position"), + impl std::fmt::Display for FixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FixMode::Invalid => f.write_str("Invalid"), + FixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), + FixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + FixMode::FloatRtk => f.write_str("Float RTK"), + FixMode::FixedRtk => f.write_str("Fixed RTK"), + FixMode::DeadReckoning => f.write_str("Dead Reckoning"), + FixMode::SbasPosition => f.write_str("SBAS Position"), + } } } } -/// Geodetic Position and Accuracy -/// -/// This position solution message reports the absolute geodetic coordinates -/// and the status (single point vs pseudo-absolute RTK) of the position -/// solution as well as the estimated horizontal, vertical, cross-track and -/// along-track errors. The position information and Fix Mode flags follow -/// the MSG_POS_LLH message. Since the covariance matrix is computed in the -/// local-level North, East, Down frame, the estimated error terms follow that -/// convention. -/// -/// The estimated errors are reported at a user-configurable confidence level. -/// The user-configured percentile is encoded in the percentile field. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_pos_llh_acc { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Geodetic Position and Accuracy + /// + /// This position solution message reports the absolute geodetic coordinates + /// and the status (single point vs pseudo-absolute RTK) of the position + /// solution as well as the estimated horizontal, vertical, cross-track and + /// along-track errors. The position information and Fix Mode flags follow + /// the MSG_POS_LLH message. Since the covariance matrix is computed in the + /// local-level North, East, Down frame, the estimated error terms follow that + /// convention. + /// + /// The estimated errors are reported at a user-configurable confidence level. + /// The user-configured percentile is encoded in the percentile field. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn geoid_model(&self) -> Option { + match get_bit_range!(self.confidence_and_geoid, u8, u8, 6, 4) { + 0 => Some(GeoidModel::NoModel), + 1 => Some(GeoidModel::EGM96), + 2 => Some(GeoidModel::EGM2008), + _ => None, + } + } -impl MsgPosLlhAcc { - pub fn geoid_model(&self) -> Option { - match get_bit_range!(self.confidence_and_geoid, u8, u8, 6, 4) { - 0 => Some(MsgPosLlhAccGeoidModel::NoModel), - 1 => Some(MsgPosLlhAccGeoidModel::EGM96), - 2 => Some(MsgPosLlhAccGeoidModel::EGM2008), - _ => None, + pub fn set_geoid_model(&mut self, geoid_model: GeoidModel) { + set_bit_range!(&mut self.confidence_and_geoid, geoid_model, u8, u8, 6, 4); } - } - pub fn set_geoid_model(&mut self, geoid_model: MsgPosLlhAccGeoidModel) { - set_bit_range!(&mut self.confidence_and_geoid, geoid_model, u8, u8, 6, 4); - } + pub fn confidence_level(&self) -> Option { + match get_bit_range!(self.confidence_and_geoid, u8, u8, 3, 0) { + 1 => Some(ConfidenceLevel::_3935), + 2 => Some(ConfidenceLevel::_6827), + 3 => Some(ConfidenceLevel::_9545), + _ => None, + } + } - pub fn confidence_level(&self) -> Option { - match get_bit_range!(self.confidence_and_geoid, u8, u8, 3, 0) { - 1 => Some(MsgPosLlhAccConfidenceLevel::_3935), - 2 => Some(MsgPosLlhAccConfidenceLevel::_6827), - 3 => Some(MsgPosLlhAccConfidenceLevel::_9545), - _ => None, + pub fn set_confidence_level(&mut self, confidence_level: ConfidenceLevel) { + set_bit_range!( + &mut self.confidence_and_geoid, + confidence_level, + u8, + u8, + 3, + 0 + ); } - } - pub fn set_confidence_level(&mut self, confidence_level: MsgPosLlhAccConfidenceLevel) { - set_bit_range!( - &mut self.confidence_and_geoid, - confidence_level, - u8, - u8, - 3, - 0 - ); - } + pub fn type_of_reported_tow(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 5) { + 0 => Some(TypeOfReportedTow::TimeOfMeasurement), + 1 => Some(TypeOfReportedTow::Other), + _ => None, + } + } - pub fn type_of_reported_tow(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 5) { - 0 => Some(MsgPosLlhAccTypeOfReportedTow::TimeOfMeasurement), - 1 => Some(MsgPosLlhAccTypeOfReportedTow::Other), - _ => None, + pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { + set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } - } - pub fn set_type_of_reported_tow( - &mut self, - type_of_reported_tow: MsgPosLlhAccTypeOfReportedTow, - ) { - set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); - } + pub fn inertial_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(InertialNavigationMode::None), + 1 => Some(InertialNavigationMode::InsUsed), + _ => None, + } + } - pub fn inertial_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(MsgPosLlhAccInertialNavigationMode::None), - 1 => Some(MsgPosLlhAccInertialNavigationMode::InsUsed), - _ => None, + pub fn set_inertial_navigation_mode( + &mut self, + inertial_navigation_mode: InertialNavigationMode, + ) { + set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); } - } - pub fn set_inertial_navigation_mode( - &mut self, - inertial_navigation_mode: MsgPosLlhAccInertialNavigationMode, - ) { - set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); - } + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(FixMode::Invalid), + 1 => Some(FixMode::SinglePointPosition), + 2 => Some(FixMode::DifferentialGnss), + 3 => Some(FixMode::FloatRtk), + 4 => Some(FixMode::FixedRtk), + 5 => Some(FixMode::DeadReckoning), + 6 => Some(FixMode::SbasPosition), + _ => None, + } + } - pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgPosLlhAccFixMode::Invalid), - 1 => Some(MsgPosLlhAccFixMode::SinglePointPosition), - 2 => Some(MsgPosLlhAccFixMode::DifferentialGnss), - 3 => Some(MsgPosLlhAccFixMode::FloatRtk), - 4 => Some(MsgPosLlhAccFixMode::FixedRtk), - 5 => Some(MsgPosLlhAccFixMode::DeadReckoning), - 6 => Some(MsgPosLlhAccFixMode::SbasPosition), - _ => None, + pub fn set_fix_mode(&mut self, fix_mode: FixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } } - pub fn set_fix_mode(&mut self, fix_mode: MsgPosLlhAccFixMode) { - set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgPosLlhAcc { + const MESSAGE_TYPE: u16 = 536; + const MESSAGE_NAME: &'static str = "MSG_POS_LLH_ACC"; } -} - -impl ConcreteMessage for MsgPosLlhAcc { - const MESSAGE_TYPE: u16 = 536; - const MESSAGE_NAME: &'static str = "MSG_POS_LLH_ACC"; -} -impl SbpMessage for MsgPosLlhAcc { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgPosLlhAcc { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgPosLlhAcc { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgPosLlhAcc(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgPosLlhAcc { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgPosLlhAcc(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgPosLlhAcc { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.lat) - + WireFormat::len(&self.lon) - + WireFormat::len(&self.height) - + WireFormat::len(&self.orthometric_height) - + WireFormat::len(&self.h_accuracy) - + WireFormat::len(&self.v_accuracy) - + WireFormat::len(&self.ct_accuracy) - + WireFormat::len(&self.at_accuracy) - + WireFormat::len(&self.h_ellipse) - + WireFormat::len(&self.confidence_and_geoid) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgPosLlhAcc { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.lat) + + WireFormat::len(&self.lon) + + WireFormat::len(&self.height) + + WireFormat::len(&self.orthometric_height) + + WireFormat::len(&self.h_accuracy) + + WireFormat::len(&self.v_accuracy) + + WireFormat::len(&self.ct_accuracy) + + WireFormat::len(&self.at_accuracy) + + WireFormat::len(&self.h_ellipse) + + WireFormat::len(&self.confidence_and_geoid) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Geoid model -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosLlhAccGeoidModel { - /// No model - NoModel = 0, + /// Geoid model + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum GeoidModel { + /// No model + NoModel = 0, - /// EGM96 - EGM96 = 1, + /// EGM96 + EGM96 = 1, - /// EGM2008 - EGM2008 = 2, -} + /// EGM2008 + EGM2008 = 2, + } -impl std::fmt::Display for MsgPosLlhAccGeoidModel { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosLlhAccGeoidModel::NoModel => f.write_str("No model"), - MsgPosLlhAccGeoidModel::EGM96 => f.write_str("EGM96"), - MsgPosLlhAccGeoidModel::EGM2008 => f.write_str("EGM2008"), + impl std::fmt::Display for GeoidModel { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + GeoidModel::NoModel => f.write_str("No model"), + GeoidModel::EGM96 => f.write_str("EGM96"), + GeoidModel::EGM2008 => f.write_str("EGM2008"), + } } } -} -/// Confidence level -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosLlhAccConfidenceLevel { - /// 39.35% - _3935 = 1, + /// Confidence level + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum ConfidenceLevel { + /// 39.35% + _3935 = 1, - /// 68.27% - _6827 = 2, + /// 68.27% + _6827 = 2, - /// 95.45% - _9545 = 3, -} + /// 95.45% + _9545 = 3, + } -impl std::fmt::Display for MsgPosLlhAccConfidenceLevel { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosLlhAccConfidenceLevel::_3935 => f.write_str("39.35%"), - MsgPosLlhAccConfidenceLevel::_6827 => f.write_str("68.27%"), - MsgPosLlhAccConfidenceLevel::_9545 => f.write_str("95.45%"), + impl std::fmt::Display for ConfidenceLevel { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ConfidenceLevel::_3935 => f.write_str("39.35%"), + ConfidenceLevel::_6827 => f.write_str("68.27%"), + ConfidenceLevel::_9545 => f.write_str("95.45%"), + } } } -} -/// Type of reported TOW -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosLlhAccTypeOfReportedTow { - /// Time of Measurement - TimeOfMeasurement = 0, + /// Type of reported TOW + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TypeOfReportedTow { + /// Time of Measurement + TimeOfMeasurement = 0, - /// Other - Other = 1, -} + /// Other + Other = 1, + } -impl std::fmt::Display for MsgPosLlhAccTypeOfReportedTow { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosLlhAccTypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), - MsgPosLlhAccTypeOfReportedTow::Other => f.write_str("Other"), + impl std::fmt::Display for TypeOfReportedTow { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), + TypeOfReportedTow::Other => f.write_str("Other"), + } } } -} -/// Inertial Navigation Mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosLlhAccInertialNavigationMode { - /// None - None = 0, + /// Inertial Navigation Mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum InertialNavigationMode { + /// None + None = 0, - /// INS used - InsUsed = 1, -} + /// INS used + InsUsed = 1, + } -impl std::fmt::Display for MsgPosLlhAccInertialNavigationMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosLlhAccInertialNavigationMode::None => f.write_str("None"), - MsgPosLlhAccInertialNavigationMode::InsUsed => f.write_str("INS used"), + impl std::fmt::Display for InertialNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + InertialNavigationMode::None => f.write_str("None"), + InertialNavigationMode::InsUsed => f.write_str("INS used"), + } } } -} -/// Fix mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosLlhAccFixMode { - /// Invalid - Invalid = 0, + /// Fix mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FixMode { + /// Invalid + Invalid = 0, - /// Single Point Position (SPP) - SinglePointPosition = 1, + /// Single Point Position (SPP) + SinglePointPosition = 1, - /// Differential GNSS (DGNSS) - DifferentialGnss = 2, + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, - /// Float RTK - FloatRtk = 3, + /// Float RTK + FloatRtk = 3, - /// Fixed RTK - FixedRtk = 4, + /// Fixed RTK + FixedRtk = 4, - /// Dead Reckoning - DeadReckoning = 5, + /// Dead Reckoning + DeadReckoning = 5, - /// SBAS Position - SbasPosition = 6, -} + /// SBAS Position + SbasPosition = 6, + } -impl std::fmt::Display for MsgPosLlhAccFixMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosLlhAccFixMode::Invalid => f.write_str("Invalid"), - MsgPosLlhAccFixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), - MsgPosLlhAccFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), - MsgPosLlhAccFixMode::FloatRtk => f.write_str("Float RTK"), - MsgPosLlhAccFixMode::FixedRtk => f.write_str("Fixed RTK"), - MsgPosLlhAccFixMode::DeadReckoning => f.write_str("Dead Reckoning"), - MsgPosLlhAccFixMode::SbasPosition => f.write_str("SBAS Position"), + impl std::fmt::Display for FixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FixMode::Invalid => f.write_str("Invalid"), + FixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), + FixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + FixMode::FloatRtk => f.write_str("Float RTK"), + FixMode::FixedRtk => f.write_str("Fixed RTK"), + FixMode::DeadReckoning => f.write_str("Dead Reckoning"), + FixMode::SbasPosition => f.write_str("SBAS Position"), + } } } } -/// Geodetic Position -/// -/// This position solution message reports the absolute geodetic coordinates -/// and the status (single point vs pseudo-absolute RTK) of the position -/// solution as well as the upper triangle of the 3x3 covariance matrix. The -/// position information and Fix Mode flags follow the MSG_POS_LLH message. -/// Since the covariance matrix is computed in the local-level North, East, -/// Down frame, the covariance terms follow that convention. Thus, covariances -/// are reported against the "downward" measurement and care should be taken -/// with the sign convention. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_pos_llh_cov { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Geodetic Position + /// + /// This position solution message reports the absolute geodetic coordinates + /// and the status (single point vs pseudo-absolute RTK) of the position + /// solution as well as the upper triangle of the 3x3 covariance matrix. The + /// position information and Fix Mode flags follow the MSG_POS_LLH message. + /// Since the covariance matrix is computed in the local-level North, East, + /// Down frame, the covariance terms follow that convention. Thus, covariances + /// are reported against the "downward" measurement and care should be taken + /// with the sign convention. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn type_of_reported_tow(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 5) { + 0 => Some(TypeOfReportedTow::TimeOfMeasurement), + 1 => Some(TypeOfReportedTow::Other), + _ => None, + } + } -impl MsgPosLlhCov { - pub fn type_of_reported_tow(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 5) { - 0 => Some(MsgPosLlhCovTypeOfReportedTow::TimeOfMeasurement), - 1 => Some(MsgPosLlhCovTypeOfReportedTow::Other), - _ => None, + pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { + set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } - } - pub fn set_type_of_reported_tow( - &mut self, - type_of_reported_tow: MsgPosLlhCovTypeOfReportedTow, - ) { - set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); - } + pub fn inertial_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(InertialNavigationMode::None), + 1 => Some(InertialNavigationMode::InsUsed), + _ => None, + } + } - pub fn inertial_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(MsgPosLlhCovInertialNavigationMode::None), - 1 => Some(MsgPosLlhCovInertialNavigationMode::InsUsed), - _ => None, + pub fn set_inertial_navigation_mode( + &mut self, + inertial_navigation_mode: InertialNavigationMode, + ) { + set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); } - } - pub fn set_inertial_navigation_mode( - &mut self, - inertial_navigation_mode: MsgPosLlhCovInertialNavigationMode, - ) { - set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); - } + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(FixMode::Invalid), + 1 => Some(FixMode::SinglePointPosition), + 2 => Some(FixMode::DifferentialGnss), + 3 => Some(FixMode::FloatRtk), + 4 => Some(FixMode::FixedRtk), + 5 => Some(FixMode::DeadReckoning), + 6 => Some(FixMode::SbasPosition), + _ => None, + } + } - pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgPosLlhCovFixMode::Invalid), - 1 => Some(MsgPosLlhCovFixMode::SinglePointPosition), - 2 => Some(MsgPosLlhCovFixMode::DifferentialGnss), - 3 => Some(MsgPosLlhCovFixMode::FloatRtk), - 4 => Some(MsgPosLlhCovFixMode::FixedRtk), - 5 => Some(MsgPosLlhCovFixMode::DeadReckoning), - 6 => Some(MsgPosLlhCovFixMode::SbasPosition), - _ => None, + pub fn set_fix_mode(&mut self, fix_mode: FixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } } - pub fn set_fix_mode(&mut self, fix_mode: MsgPosLlhCovFixMode) { - set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgPosLlhCov { + const MESSAGE_TYPE: u16 = 529; + const MESSAGE_NAME: &'static str = "MSG_POS_LLH_COV"; } -} - -impl ConcreteMessage for MsgPosLlhCov { - const MESSAGE_TYPE: u16 = 529; - const MESSAGE_NAME: &'static str = "MSG_POS_LLH_COV"; -} -impl SbpMessage for MsgPosLlhCov { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgPosLlhCov { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgPosLlhCov { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgPosLlhCov(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgPosLlhCov { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgPosLlhCov(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgPosLlhCov { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.lat) - + WireFormat::len(&self.lon) - + WireFormat::len(&self.height) - + WireFormat::len(&self.cov_n_n) - + WireFormat::len(&self.cov_n_e) - + WireFormat::len(&self.cov_n_d) - + WireFormat::len(&self.cov_e_e) - + WireFormat::len(&self.cov_e_d) - + WireFormat::len(&self.cov_d_d) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgPosLlhCov { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.lat) + + WireFormat::len(&self.lon) + + WireFormat::len(&self.height) + + WireFormat::len(&self.cov_n_n) + + WireFormat::len(&self.cov_n_e) + + WireFormat::len(&self.cov_n_d) + + WireFormat::len(&self.cov_e_e) + + WireFormat::len(&self.cov_e_d) + + WireFormat::len(&self.cov_d_d) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Type of reported TOW -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosLlhCovTypeOfReportedTow { - /// Time of Measurement - TimeOfMeasurement = 0, + /// Type of reported TOW + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TypeOfReportedTow { + /// Time of Measurement + TimeOfMeasurement = 0, - /// Other - Other = 1, -} + /// Other + Other = 1, + } -impl std::fmt::Display for MsgPosLlhCovTypeOfReportedTow { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosLlhCovTypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), - MsgPosLlhCovTypeOfReportedTow::Other => f.write_str("Other"), + impl std::fmt::Display for TypeOfReportedTow { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), + TypeOfReportedTow::Other => f.write_str("Other"), + } } } -} -/// Inertial Navigation Mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosLlhCovInertialNavigationMode { - /// None - None = 0, + /// Inertial Navigation Mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum InertialNavigationMode { + /// None + None = 0, - /// INS used - InsUsed = 1, -} + /// INS used + InsUsed = 1, + } -impl std::fmt::Display for MsgPosLlhCovInertialNavigationMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosLlhCovInertialNavigationMode::None => f.write_str("None"), - MsgPosLlhCovInertialNavigationMode::InsUsed => f.write_str("INS used"), + impl std::fmt::Display for InertialNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + InertialNavigationMode::None => f.write_str("None"), + InertialNavigationMode::InsUsed => f.write_str("INS used"), + } } } -} -/// Fix mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosLlhCovFixMode { - /// Invalid - Invalid = 0, + /// Fix mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FixMode { + /// Invalid + Invalid = 0, - /// Single Point Position (SPP) - SinglePointPosition = 1, + /// Single Point Position (SPP) + SinglePointPosition = 1, - /// Differential GNSS (DGNSS) - DifferentialGnss = 2, + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, - /// Float RTK - FloatRtk = 3, + /// Float RTK + FloatRtk = 3, - /// Fixed RTK - FixedRtk = 4, + /// Fixed RTK + FixedRtk = 4, - /// Dead Reckoning - DeadReckoning = 5, + /// Dead Reckoning + DeadReckoning = 5, - /// SBAS Position - SbasPosition = 6, -} + /// SBAS Position + SbasPosition = 6, + } -impl std::fmt::Display for MsgPosLlhCovFixMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosLlhCovFixMode::Invalid => f.write_str("Invalid"), - MsgPosLlhCovFixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), - MsgPosLlhCovFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), - MsgPosLlhCovFixMode::FloatRtk => f.write_str("Float RTK"), - MsgPosLlhCovFixMode::FixedRtk => f.write_str("Fixed RTK"), - MsgPosLlhCovFixMode::DeadReckoning => f.write_str("Dead Reckoning"), - MsgPosLlhCovFixMode::SbasPosition => f.write_str("SBAS Position"), + impl std::fmt::Display for FixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FixMode::Invalid => f.write_str("Invalid"), + FixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), + FixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + FixMode::FloatRtk => f.write_str("Float RTK"), + FixMode::FixedRtk => f.write_str("Fixed RTK"), + FixMode::DeadReckoning => f.write_str("Dead Reckoning"), + FixMode::SbasPosition => f.write_str("SBAS Position"), + } } } } -/// GNSS-only Geodetic Position -/// -/// This position solution message reports the absolute geodetic coordinates -/// and the status (single point vs pseudo-absolute RTK) of the position -/// solution as well as the upper triangle of the 3x3 covariance matrix. The -/// position information and Fix Mode flags should follow the MSG_POS_LLH -/// message. Since the covariance matrix is computed in the local-level -/// North, East, Down frame, the covariance terms follow with that convention. -/// Thus, covariances are reported against the "downward" measurement and care -/// should be taken with the sign convention. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_pos_llh_cov_gnss { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// GNSS-only Geodetic Position + /// + /// This position solution message reports the absolute geodetic coordinates + /// and the status (single point vs pseudo-absolute RTK) of the position + /// solution as well as the upper triangle of the 3x3 covariance matrix. The + /// position information and Fix Mode flags should follow the MSG_POS_LLH + /// message. Since the covariance matrix is computed in the local-level + /// North, East, Down frame, the covariance terms follow with that convention. + /// Thus, covariances are reported against the "downward" measurement and care + /// should be taken with the sign convention. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(FixMode::Invalid), + 1 => Some(FixMode::SinglePointPosition), + 2 => Some(FixMode::DifferentialGnss), + 3 => Some(FixMode::FloatRtk), + 4 => Some(FixMode::FixedRtk), + 5 => Some(FixMode::DeadReckoning), + 6 => Some(FixMode::SbasPosition), + _ => None, + } + } -impl MsgPosLlhCovGnss { - pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgPosLlhCovGnssFixMode::Invalid), - 1 => Some(MsgPosLlhCovGnssFixMode::SinglePointPosition), - 2 => Some(MsgPosLlhCovGnssFixMode::DifferentialGnss), - 3 => Some(MsgPosLlhCovGnssFixMode::FloatRtk), - 4 => Some(MsgPosLlhCovGnssFixMode::FixedRtk), - 5 => Some(MsgPosLlhCovGnssFixMode::DeadReckoning), - 6 => Some(MsgPosLlhCovGnssFixMode::SbasPosition), - _ => None, + pub fn set_fix_mode(&mut self, fix_mode: FixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } } - pub fn set_fix_mode(&mut self, fix_mode: MsgPosLlhCovGnssFixMode) { - set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgPosLlhCovGnss { + const MESSAGE_TYPE: u16 = 561; + const MESSAGE_NAME: &'static str = "MSG_POS_LLH_COV_GNSS"; } -} -impl ConcreteMessage for MsgPosLlhCovGnss { - const MESSAGE_TYPE: u16 = 561; - const MESSAGE_NAME: &'static str = "MSG_POS_LLH_COV_GNSS"; -} - -impl SbpMessage for MsgPosLlhCovGnss { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgPosLlhCovGnss { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgPosLlhCovGnss { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgPosLlhCovGnss(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgPosLlhCovGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgPosLlhCovGnss(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgPosLlhCovGnss { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.lat) - + WireFormat::len(&self.lon) - + WireFormat::len(&self.height) - + WireFormat::len(&self.cov_n_n) - + WireFormat::len(&self.cov_n_e) - + WireFormat::len(&self.cov_n_d) - + WireFormat::len(&self.cov_e_e) - + WireFormat::len(&self.cov_e_d) - + WireFormat::len(&self.cov_d_d) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgPosLlhCovGnss { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.lat) + + WireFormat::len(&self.lon) + + WireFormat::len(&self.height) + + WireFormat::len(&self.cov_n_n) + + WireFormat::len(&self.cov_n_e) + + WireFormat::len(&self.cov_n_d) + + WireFormat::len(&self.cov_e_e) + + WireFormat::len(&self.cov_e_d) + + WireFormat::len(&self.cov_d_d) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Fix mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosLlhCovGnssFixMode { - /// Invalid - Invalid = 0, + /// Fix mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FixMode { + /// Invalid + Invalid = 0, - /// Single Point Position (SPP) - SinglePointPosition = 1, + /// Single Point Position (SPP) + SinglePointPosition = 1, - /// Differential GNSS (DGNSS) - DifferentialGnss = 2, + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, - /// Float RTK - FloatRtk = 3, + /// Float RTK + FloatRtk = 3, - /// Fixed RTK - FixedRtk = 4, + /// Fixed RTK + FixedRtk = 4, - /// Dead Reckoning - DeadReckoning = 5, + /// Dead Reckoning + DeadReckoning = 5, - /// SBAS Position - SbasPosition = 6, -} + /// SBAS Position + SbasPosition = 6, + } -impl std::fmt::Display for MsgPosLlhCovGnssFixMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosLlhCovGnssFixMode::Invalid => f.write_str("Invalid"), - MsgPosLlhCovGnssFixMode::SinglePointPosition => { - f.write_str("Single Point Position (SPP)") + impl std::fmt::Display for FixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FixMode::Invalid => f.write_str("Invalid"), + FixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), + FixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + FixMode::FloatRtk => f.write_str("Float RTK"), + FixMode::FixedRtk => f.write_str("Fixed RTK"), + FixMode::DeadReckoning => f.write_str("Dead Reckoning"), + FixMode::SbasPosition => f.write_str("SBAS Position"), } - MsgPosLlhCovGnssFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), - MsgPosLlhCovGnssFixMode::FloatRtk => f.write_str("Float RTK"), - MsgPosLlhCovGnssFixMode::FixedRtk => f.write_str("Fixed RTK"), - MsgPosLlhCovGnssFixMode::DeadReckoning => f.write_str("Dead Reckoning"), - MsgPosLlhCovGnssFixMode::SbasPosition => f.write_str("SBAS Position"), } } } -/// Geodetic Position -/// -/// This position solution message reports the absolute geodetic coordinates -/// and the status (single point vs pseudo-absolute RTK) of the position -/// solution. If the rover receiver knows the surveyed position of the base -/// station and has an RTK solution, this reports a pseudo-absolute position -/// solution using the base station position and the 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 { - pub fn raim_repair_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 0) { - 0 => Some(MsgPosLlhDepARaimRepairFlag::NoRepair), - 1 => Some(MsgPosLlhDepARaimRepairFlag::SolutionCameFromRaimRepair), - _ => None, +pub mod msg_pos_llh_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Geodetic Position + /// + /// This position solution message reports the absolute geodetic coordinates + /// and the status (single point vs pseudo-absolute RTK) of the position + /// solution. If the rover receiver knows the surveyed position of the base + /// station and has an RTK solution, this reports a pseudo-absolute position + /// solution using the base station position and the 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn raim_repair_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 0) { + 0 => Some(RaimRepairFlag::NoRepair), + 1 => Some(RaimRepairFlag::SolutionCameFromRaimRepair), + _ => None, + } } - } - pub fn set_raim_repair_flag(&mut self, raim_repair_flag: MsgPosLlhDepARaimRepairFlag) { - set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 5, 0); - } + pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { + set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 5, 0); + } - pub fn raim_availability_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 0) { - 0 => { - Some(MsgPosLlhDepARaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable) + pub fn raim_availability_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 0) { + 0 => Some(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), + 1 => Some(RaimAvailabilityFlag::RaimCheckWasAvailable), + _ => None, } - 1 => Some(MsgPosLlhDepARaimAvailabilityFlag::RaimCheckWasAvailable), - _ => None, } - } - pub fn set_raim_availability_flag( - &mut self, - raim_availability_flag: MsgPosLlhDepARaimAvailabilityFlag, - ) { - set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 4, 0); - } + pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { + set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 4, 0); + } - pub fn height_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 0) { - 0 => Some(MsgPosLlhDepAHeightMode::HeightAboveWgs84Ellipsoid), - 1 => Some(MsgPosLlhDepAHeightMode::HeightAboveMeanSeaLevel), - _ => None, + pub fn height_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 0) { + 0 => Some(HeightMode::HeightAboveWgs84Ellipsoid), + 1 => Some(HeightMode::HeightAboveMeanSeaLevel), + _ => None, + } } - } - pub fn set_height_mode(&mut self, height_mode: MsgPosLlhDepAHeightMode) { - set_bit_range!(&mut self.flags, height_mode, u8, u8, 3, 0); - } + pub fn set_height_mode(&mut self, height_mode: HeightMode) { + set_bit_range!(&mut self.flags, height_mode, u8, u8, 3, 0); + } - pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgPosLlhDepAFixMode::SinglePointPositioning), - 1 => Some(MsgPosLlhDepAFixMode::FixedRtk), - 2 => Some(MsgPosLlhDepAFixMode::FloatRtk), - _ => None, + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(FixMode::SinglePointPositioning), + 1 => Some(FixMode::FixedRtk), + 2 => Some(FixMode::FloatRtk), + _ => None, + } } - } - pub fn set_fix_mode(&mut self, fix_mode: MsgPosLlhDepAFixMode) { - set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + pub fn set_fix_mode(&mut self, fix_mode: FixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + } } -} - -impl ConcreteMessage for MsgPosLlhDepA { - const MESSAGE_TYPE: u16 = 513; - const MESSAGE_NAME: &'static str = "MSG_POS_LLH_DEP_A"; -} -impl SbpMessage for MsgPosLlhDepA { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE + impl ConcreteMessage for MsgPosLlhDepA { + const MESSAGE_TYPE: u16 = 513; + const MESSAGE_NAME: &'static str = "MSG_POS_LLH_DEP_A"; } - fn sender_id(&self) -> Option { - self.sender_id - } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + + impl SbpMessage for MsgPosLlhDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgPosLlhDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgPosLlhDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgPosLlhDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgPosLlhDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgPosLlhDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.lat) - + WireFormat::len(&self.lon) - + WireFormat::len(&self.height) - + WireFormat::len(&self.h_accuracy) - + WireFormat::len(&self.v_accuracy) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgPosLlhDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.lat) + + WireFormat::len(&self.lon) + + WireFormat::len(&self.height) + + WireFormat::len(&self.h_accuracy) + + WireFormat::len(&self.v_accuracy) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// RAIM repair flag -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosLlhDepARaimRepairFlag { - /// No repair - NoRepair = 0, + /// RAIM repair flag + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum RaimRepairFlag { + /// No repair + NoRepair = 0, - /// Solution came from RAIM repair - SolutionCameFromRaimRepair = 1, -} + /// Solution came from RAIM repair + SolutionCameFromRaimRepair = 1, + } -impl std::fmt::Display for MsgPosLlhDepARaimRepairFlag { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosLlhDepARaimRepairFlag::NoRepair => f.write_str("No repair"), - MsgPosLlhDepARaimRepairFlag::SolutionCameFromRaimRepair => { - f.write_str("Solution came from RAIM repair") + impl std::fmt::Display for RaimRepairFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + RaimRepairFlag::NoRepair => f.write_str("No repair"), + RaimRepairFlag::SolutionCameFromRaimRepair => { + f.write_str("Solution came from RAIM repair") + } } } } -} -/// RAIM availability flag -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosLlhDepARaimAvailabilityFlag { - /// RAIM check was explicitly disabled or unavailable - RaimCheckWasExplicitlyDisabledOrUnavailable = 0, + /// RAIM availability flag + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum RaimAvailabilityFlag { + /// RAIM check was explicitly disabled or unavailable + RaimCheckWasExplicitlyDisabledOrUnavailable = 0, - /// RAIM check was available - RaimCheckWasAvailable = 1, -} + /// RAIM check was available + RaimCheckWasAvailable = 1, + } -impl std::fmt::Display for MsgPosLlhDepARaimAvailabilityFlag { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosLlhDepARaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable => { - f.write_str("RAIM check was explicitly disabled or unavailable") - } - MsgPosLlhDepARaimAvailabilityFlag::RaimCheckWasAvailable => { - f.write_str("RAIM check was available") + impl std::fmt::Display for RaimAvailabilityFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable => { + f.write_str("RAIM check was explicitly disabled or unavailable") + } + RaimAvailabilityFlag::RaimCheckWasAvailable => { + f.write_str("RAIM check was available") + } } } } -} -/// Height Mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosLlhDepAHeightMode { - /// Height above WGS84 ellipsoid - HeightAboveWgs84Ellipsoid = 0, + /// Height Mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum HeightMode { + /// Height above WGS84 ellipsoid + HeightAboveWgs84Ellipsoid = 0, - /// Height above mean sea level - HeightAboveMeanSeaLevel = 1, -} + /// Height above mean sea level + HeightAboveMeanSeaLevel = 1, + } -impl std::fmt::Display for MsgPosLlhDepAHeightMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosLlhDepAHeightMode::HeightAboveWgs84Ellipsoid => { - f.write_str("Height above WGS84 ellipsoid") - } - MsgPosLlhDepAHeightMode::HeightAboveMeanSeaLevel => { - f.write_str("Height above mean sea level") + impl std::fmt::Display for HeightMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + HeightMode::HeightAboveWgs84Ellipsoid => { + f.write_str("Height above WGS84 ellipsoid") + } + HeightMode::HeightAboveMeanSeaLevel => f.write_str("Height above mean sea level"), } } } -} -/// Fix mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosLlhDepAFixMode { - /// Single Point Positioning (SPP) - SinglePointPositioning = 0, + /// Fix mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FixMode { + /// Single Point Positioning (SPP) + SinglePointPositioning = 0, - /// Fixed RTK - FixedRtk = 1, + /// Fixed RTK + FixedRtk = 1, - /// Float RTK - FloatRtk = 2, -} + /// Float RTK + FloatRtk = 2, + } -impl std::fmt::Display for MsgPosLlhDepAFixMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosLlhDepAFixMode::SinglePointPositioning => { - f.write_str("Single Point Positioning (SPP)") + impl std::fmt::Display for FixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FixMode::SinglePointPositioning => f.write_str("Single Point Positioning (SPP)"), + FixMode::FixedRtk => f.write_str("Fixed RTK"), + FixMode::FloatRtk => f.write_str("Float RTK"), } - MsgPosLlhDepAFixMode::FixedRtk => f.write_str("Fixed RTK"), - MsgPosLlhDepAFixMode::FloatRtk => f.write_str("Float RTK"), } } } -/// GNSS-only Geodetic Position -/// -/// This position solution message reports the absolute geodetic coordinates -/// and the status (single point vs pseudo-absolute RTK) of the position -/// solution. If the rover receiver knows the surveyed position of the base -/// station and has an RTK solution, this reports a pseudo-absolute position -/// solution using the base station position and the 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_pos_llh_gnss { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// GNSS-only Geodetic Position + /// + /// This position solution message reports the absolute geodetic coordinates + /// and the status (single point vs pseudo-absolute RTK) of the position + /// solution. If the rover receiver knows the surveyed position of the base + /// station and has an RTK solution, this reports a pseudo-absolute position + /// solution using the base station position and the 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(FixMode::Invalid), + 1 => Some(FixMode::SinglePointPosition), + 2 => Some(FixMode::DifferentialGnss), + 3 => Some(FixMode::FloatRtk), + 4 => Some(FixMode::FixedRtk), + 6 => Some(FixMode::SbasPosition), + _ => None, + } + } -impl MsgPosLlhGnss { - pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgPosLlhGnssFixMode::Invalid), - 1 => Some(MsgPosLlhGnssFixMode::SinglePointPosition), - 2 => Some(MsgPosLlhGnssFixMode::DifferentialGnss), - 3 => Some(MsgPosLlhGnssFixMode::FloatRtk), - 4 => Some(MsgPosLlhGnssFixMode::FixedRtk), - 6 => Some(MsgPosLlhGnssFixMode::SbasPosition), - _ => None, + pub fn set_fix_mode(&mut self, fix_mode: FixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } } - pub fn set_fix_mode(&mut self, fix_mode: MsgPosLlhGnssFixMode) { - set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgPosLlhGnss { + const MESSAGE_TYPE: u16 = 554; + const MESSAGE_NAME: &'static str = "MSG_POS_LLH_GNSS"; } -} - -impl ConcreteMessage for MsgPosLlhGnss { - const MESSAGE_TYPE: u16 = 554; - const MESSAGE_NAME: &'static str = "MSG_POS_LLH_GNSS"; -} -impl SbpMessage for MsgPosLlhGnss { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgPosLlhGnss { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgPosLlhGnss { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgPosLlhGnss(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgPosLlhGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgPosLlhGnss(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgPosLlhGnss { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.lat) - + WireFormat::len(&self.lon) - + WireFormat::len(&self.height) - + WireFormat::len(&self.h_accuracy) - + WireFormat::len(&self.v_accuracy) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgPosLlhGnss { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.lat) + + WireFormat::len(&self.lon) + + WireFormat::len(&self.height) + + WireFormat::len(&self.h_accuracy) + + WireFormat::len(&self.v_accuracy) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Fix mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgPosLlhGnssFixMode { - /// Invalid - Invalid = 0, + /// Fix mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FixMode { + /// Invalid + Invalid = 0, - /// Single Point Position (SPP) - SinglePointPosition = 1, + /// Single Point Position (SPP) + SinglePointPosition = 1, - /// Differential GNSS (DGNSS) - DifferentialGnss = 2, + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, - /// Float RTK - FloatRtk = 3, + /// Float RTK + FloatRtk = 3, - /// Fixed RTK - FixedRtk = 4, + /// Fixed RTK + FixedRtk = 4, - /// SBAS Position - SbasPosition = 6, -} + /// SBAS Position + SbasPosition = 6, + } -impl std::fmt::Display for MsgPosLlhGnssFixMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgPosLlhGnssFixMode::Invalid => f.write_str("Invalid"), - MsgPosLlhGnssFixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), - MsgPosLlhGnssFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), - MsgPosLlhGnssFixMode::FloatRtk => f.write_str("Float RTK"), - MsgPosLlhGnssFixMode::FixedRtk => f.write_str("Fixed RTK"), - MsgPosLlhGnssFixMode::SbasPosition => f.write_str("SBAS Position"), + impl std::fmt::Display for FixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FixMode::Invalid => f.write_str("Invalid"), + FixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), + FixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + FixMode::FloatRtk => f.write_str("Float RTK"), + FixMode::FixedRtk => f.write_str("Fixed RTK"), + FixMode::SbasPosition => f.write_str("SBAS Position"), + } } } } -/// Computed state and Protection Levels -/// -/// This message reports the protection levels associated to the given state -/// estimate. The full GPS time is given by the preceding MSG_GPS_TIME with -/// the matching time-of-week (tow). -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgProtectionLevel { - /// 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, -} +pub mod msg_protection_level { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Computed state and Protection Levels + /// + /// This message reports the protection levels associated to the given state + /// estimate. The full GPS time is given by the preceding MSG_GPS_TIME with + /// the matching time-of-week (tow). + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgProtectionLevel { + /// 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 { + pub fn target_integrity_risk_tir_level(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 2, 0) + } + + pub fn set_target_integrity_risk_tir_level(&mut self, target_integrity_risk_tir_level: u8) { + set_bit_range!( + &mut self.flags, + target_integrity_risk_tir_level, + u32, + u8, + 2, + 0 + ); + } + + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 17, 15) { + 0 => Some(FixMode::Invalid), + 1 => Some(FixMode::SinglePointPosition), + 2 => Some(FixMode::DifferentialGnss), + 3 => Some(FixMode::FloatRtk), + 4 => Some(FixMode::FixedRtk), + 5 => Some(FixMode::DeadReckoning), + 6 => Some(FixMode::SbasPosition), + _ => None, + } + } -impl MsgProtectionLevel { - pub fn target_integrity_risk_tir_level(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 2, 0) - } - - pub fn set_target_integrity_risk_tir_level(&mut self, target_integrity_risk_tir_level: u8) { - set_bit_range!( - &mut self.flags, - target_integrity_risk_tir_level, - u32, - u8, - 2, - 0 - ); - } - - pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 17, 15) { - 0 => Some(MsgProtectionLevelFixMode::Invalid), - 1 => Some(MsgProtectionLevelFixMode::SinglePointPosition), - 2 => Some(MsgProtectionLevelFixMode::DifferentialGnss), - 3 => Some(MsgProtectionLevelFixMode::FloatRtk), - 4 => Some(MsgProtectionLevelFixMode::FixedRtk), - 5 => Some(MsgProtectionLevelFixMode::DeadReckoning), - 6 => Some(MsgProtectionLevelFixMode::SbasPosition), - _ => None, + pub fn set_fix_mode(&mut self, fix_mode: FixMode) { + set_bit_range!(&mut self.flags, fix_mode, u32, u8, 17, 15); } - } - pub fn set_fix_mode(&mut self, fix_mode: MsgProtectionLevelFixMode) { - set_bit_range!(&mut self.flags, fix_mode, u32, u8, 17, 15); - } + pub fn inertial_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 19, 18) { + 0 => Some(InertialNavigationMode::None), + 1 => Some(InertialNavigationMode::InsUsed), + _ => None, + } + } - pub fn inertial_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 19, 18) { - 0 => Some(MsgProtectionLevelInertialNavigationMode::None), - 1 => Some(MsgProtectionLevelInertialNavigationMode::InsUsed), - _ => None, + pub fn set_inertial_navigation_mode( + &mut self, + inertial_navigation_mode: InertialNavigationMode, + ) { + set_bit_range!(&mut self.flags, inertial_navigation_mode, u32, u8, 19, 18); } - } - pub fn set_inertial_navigation_mode( - &mut self, - inertial_navigation_mode: MsgProtectionLevelInertialNavigationMode, - ) { - set_bit_range!(&mut self.flags, inertial_navigation_mode, u32, u8, 19, 18); - } + pub fn time_status(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 20, 0) { + 0 => Some(TimeStatus::GnssTimeOfValidity), + 1 => Some(TimeStatus::Other), + _ => None, + } + } - pub fn time_status(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 20, 0) { - 0 => Some(MsgProtectionLevelTimeStatus::GnssTimeOfValidity), - 1 => Some(MsgProtectionLevelTimeStatus::Other), - _ => None, + pub fn set_time_status(&mut self, time_status: TimeStatus) { + set_bit_range!(&mut self.flags, time_status, u32, u8, 20, 0); } - } - pub fn set_time_status(&mut self, time_status: MsgProtectionLevelTimeStatus) { - set_bit_range!(&mut self.flags, time_status, u32, u8, 20, 0); - } + pub fn velocity_valid(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 21, 0) + } - pub fn velocity_valid(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 21, 0) - } + pub fn set_velocity_valid(&mut self, velocity_valid: u8) { + set_bit_range!(&mut self.flags, velocity_valid, u32, u8, 21, 0); + } - pub fn set_velocity_valid(&mut self, velocity_valid: u8) { - set_bit_range!(&mut self.flags, velocity_valid, u32, u8, 21, 0); - } + pub fn attitude_valid(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 22, 0) + } - pub fn attitude_valid(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 22, 0) - } + pub fn set_attitude_valid(&mut self, attitude_valid: u8) { + set_bit_range!(&mut self.flags, attitude_valid, u32, u8, 22, 0); + } - pub fn set_attitude_valid(&mut self, attitude_valid: u8) { - set_bit_range!(&mut self.flags, attitude_valid, u32, u8, 22, 0); - } + pub fn safe_state_hpl(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 23, 0) + } - pub fn safe_state_hpl(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 23, 0) - } + pub fn set_safe_state_hpl(&mut self, safe_state_hpl: u8) { + set_bit_range!(&mut self.flags, safe_state_hpl, u32, u8, 23, 0); + } - pub fn set_safe_state_hpl(&mut self, safe_state_hpl: u8) { - set_bit_range!(&mut self.flags, safe_state_hpl, u32, u8, 23, 0); - } + pub fn safe_state_vpl(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 24, 0) + } - pub fn safe_state_vpl(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 24, 0) - } + pub fn set_safe_state_vpl(&mut self, safe_state_vpl: u8) { + set_bit_range!(&mut self.flags, safe_state_vpl, u32, u8, 24, 0); + } - pub fn set_safe_state_vpl(&mut self, safe_state_vpl: u8) { - set_bit_range!(&mut self.flags, safe_state_vpl, u32, u8, 24, 0); - } + pub fn safe_state_atpl(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 25, 0) + } - pub fn safe_state_atpl(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 25, 0) - } + pub fn set_safe_state_atpl(&mut self, safe_state_atpl: u8) { + set_bit_range!(&mut self.flags, safe_state_atpl, u32, u8, 25, 0); + } - pub fn set_safe_state_atpl(&mut self, safe_state_atpl: u8) { - set_bit_range!(&mut self.flags, safe_state_atpl, u32, u8, 25, 0); - } + pub fn safe_state_ctpl(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 26, 0) + } - pub fn safe_state_ctpl(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 26, 0) - } + pub fn set_safe_state_ctpl(&mut self, safe_state_ctpl: u8) { + set_bit_range!(&mut self.flags, safe_state_ctpl, u32, u8, 26, 0); + } - pub fn set_safe_state_ctpl(&mut self, safe_state_ctpl: u8) { - set_bit_range!(&mut self.flags, safe_state_ctpl, u32, u8, 26, 0); - } + pub fn safe_state_hvpl(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 27, 0) + } - pub fn safe_state_hvpl(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 27, 0) - } + pub fn set_safe_state_hvpl(&mut self, safe_state_hvpl: u8) { + set_bit_range!(&mut self.flags, safe_state_hvpl, u32, u8, 27, 0); + } - pub fn set_safe_state_hvpl(&mut self, safe_state_hvpl: u8) { - set_bit_range!(&mut self.flags, safe_state_hvpl, u32, u8, 27, 0); - } + pub fn safe_state_vvpl(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 28, 0) + } - pub fn safe_state_vvpl(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 28, 0) - } + pub fn set_safe_state_vvpl(&mut self, safe_state_vvpl: u8) { + set_bit_range!(&mut self.flags, safe_state_vvpl, u32, u8, 28, 0); + } - pub fn set_safe_state_vvpl(&mut self, safe_state_vvpl: u8) { - set_bit_range!(&mut self.flags, safe_state_vvpl, u32, u8, 28, 0); - } + pub fn safe_state_hopl(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 29, 0) + } - pub fn safe_state_hopl(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 29, 0) - } + pub fn set_safe_state_hopl(&mut self, safe_state_hopl: u8) { + set_bit_range!(&mut self.flags, safe_state_hopl, u32, u8, 29, 0); + } - pub fn set_safe_state_hopl(&mut self, safe_state_hopl: u8) { - set_bit_range!(&mut self.flags, safe_state_hopl, u32, u8, 29, 0); - } + pub fn safe_state_popl(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 30, 0) + } - pub fn safe_state_popl(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 30, 0) - } + pub fn set_safe_state_popl(&mut self, safe_state_popl: u8) { + set_bit_range!(&mut self.flags, safe_state_popl, u32, u8, 30, 0); + } - pub fn set_safe_state_popl(&mut self, safe_state_popl: u8) { - set_bit_range!(&mut self.flags, safe_state_popl, u32, u8, 30, 0); - } + pub fn safe_state_ropl(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 31, 0) + } - pub fn safe_state_ropl(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 31, 0) + pub fn set_safe_state_ropl(&mut self, safe_state_ropl: u8) { + set_bit_range!(&mut self.flags, safe_state_ropl, u32, u8, 31, 0); + } } - pub fn set_safe_state_ropl(&mut self, safe_state_ropl: u8) { - set_bit_range!(&mut self.flags, safe_state_ropl, u32, u8, 31, 0); + impl ConcreteMessage for MsgProtectionLevel { + const MESSAGE_TYPE: u16 = 535; + const MESSAGE_NAME: &'static str = "MSG_PROTECTION_LEVEL"; } -} - -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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - #[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 time::GpsTime::new(wn, tow_s) { - Ok(gps_time) => gps_time, - Err(e) => return Some(Err(e.into())), - }; - Some(Ok(time::MessageTime::Rover(gps_time.into()))) + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + #[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 time::GpsTime::new(wn, tow_s) { + Ok(gps_time) => gps_time, + Err(e) => return Some(Err(e.into())), + }; + Some(Ok(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgProtectionLevel { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgProtectionLevel(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgProtectionLevel { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgProtectionLevel(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgProtectionLevel { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.wn) - + WireFormat::len(&self.hpl) - + WireFormat::len(&self.vpl) - + WireFormat::len(&self.atpl) - + WireFormat::len(&self.ctpl) - + WireFormat::len(&self.hvpl) - + WireFormat::len(&self.vvpl) - + WireFormat::len(&self.hopl) - + WireFormat::len(&self.popl) - + WireFormat::len(&self.ropl) - + WireFormat::len(&self.lat) - + WireFormat::len(&self.lon) - + WireFormat::len(&self.height) - + WireFormat::len(&self.v_x) - + WireFormat::len(&self.v_y) - + WireFormat::len(&self.v_z) - + WireFormat::len(&self.roll) - + WireFormat::len(&self.pitch) - + WireFormat::len(&self.heading) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgProtectionLevel { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.wn) + + WireFormat::len(&self.hpl) + + WireFormat::len(&self.vpl) + + WireFormat::len(&self.atpl) + + WireFormat::len(&self.ctpl) + + WireFormat::len(&self.hvpl) + + WireFormat::len(&self.vvpl) + + WireFormat::len(&self.hopl) + + WireFormat::len(&self.popl) + + WireFormat::len(&self.ropl) + + WireFormat::len(&self.lat) + + WireFormat::len(&self.lon) + + WireFormat::len(&self.height) + + WireFormat::len(&self.v_x) + + WireFormat::len(&self.v_y) + + WireFormat::len(&self.v_z) + + WireFormat::len(&self.roll) + + WireFormat::len(&self.pitch) + + WireFormat::len(&self.heading) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Fix mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgProtectionLevelFixMode { - /// Invalid - Invalid = 0, + /// Fix mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FixMode { + /// Invalid + Invalid = 0, - /// Single Point Position (SPP) - SinglePointPosition = 1, + /// Single Point Position (SPP) + SinglePointPosition = 1, - /// Differential GNSS (DGNSS) - DifferentialGnss = 2, + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, - /// Float RTK - FloatRtk = 3, + /// Float RTK + FloatRtk = 3, - /// Fixed RTK - FixedRtk = 4, + /// Fixed RTK + FixedRtk = 4, - /// Dead Reckoning - DeadReckoning = 5, + /// Dead Reckoning + DeadReckoning = 5, - /// SBAS Position - SbasPosition = 6, -} + /// SBAS Position + SbasPosition = 6, + } -impl std::fmt::Display for MsgProtectionLevelFixMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgProtectionLevelFixMode::Invalid => f.write_str("Invalid"), - MsgProtectionLevelFixMode::SinglePointPosition => { - f.write_str("Single Point Position (SPP)") + impl std::fmt::Display for FixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FixMode::Invalid => f.write_str("Invalid"), + FixMode::SinglePointPosition => f.write_str("Single Point Position (SPP)"), + FixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + FixMode::FloatRtk => f.write_str("Float RTK"), + FixMode::FixedRtk => f.write_str("Fixed RTK"), + FixMode::DeadReckoning => f.write_str("Dead Reckoning"), + FixMode::SbasPosition => f.write_str("SBAS Position"), } - MsgProtectionLevelFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), - MsgProtectionLevelFixMode::FloatRtk => f.write_str("Float RTK"), - MsgProtectionLevelFixMode::FixedRtk => f.write_str("Fixed RTK"), - MsgProtectionLevelFixMode::DeadReckoning => f.write_str("Dead Reckoning"), - MsgProtectionLevelFixMode::SbasPosition => f.write_str("SBAS Position"), } } -} -/// Inertial Navigation Mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgProtectionLevelInertialNavigationMode { - /// None - None = 0, - - /// INS used - InsUsed = 1, -} + /// Inertial Navigation Mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum InertialNavigationMode { + /// None + None = 0, -impl std::fmt::Display for MsgProtectionLevelInertialNavigationMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgProtectionLevelInertialNavigationMode::None => f.write_str("None"), - MsgProtectionLevelInertialNavigationMode::InsUsed => f.write_str("INS used"), - } + /// INS used + InsUsed = 1, } -} - -/// Time status -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgProtectionLevelTimeStatus { - /// GNSS time of validity - GnssTimeOfValidity = 0, - - /// Other - Other = 1, -} -impl std::fmt::Display for MsgProtectionLevelTimeStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgProtectionLevelTimeStatus::GnssTimeOfValidity => { - f.write_str("GNSS time of validity") + impl std::fmt::Display for InertialNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + InertialNavigationMode::None => f.write_str("None"), + InertialNavigationMode::InsUsed => f.write_str("INS used"), } - MsgProtectionLevelTimeStatus::Other => f.write_str("Other"), - } - } -} - -/// Computed Position and Protection Level -/// -/// This message reports the local vertical and horizontal protection levels -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgProtectionLevelDepA { - /// 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 { - pub fn target_integrity_risk_tir_level( - &self, - ) -> Option { - match get_bit_range!( self.flags, u8, u8, 2, 0 ) { - 0 => Some( MsgProtectionLevelDepATargetIntegrityRiskTirLevel :: SafeStateProtectionLevelShallNotBeUsedForSafetyCriticalApplication ), - 1 => Some( MsgProtectionLevelDepATargetIntegrityRiskTirLevel :: TirLevel1 ), - 2 => Some( MsgProtectionLevelDepATargetIntegrityRiskTirLevel :: TirLevel2 ), - 3 => Some( MsgProtectionLevelDepATargetIntegrityRiskTirLevel :: TirLevel3 ), - _ => None, } } - pub fn set_target_integrity_risk_tir_level( - &mut self, - target_integrity_risk_tir_level: MsgProtectionLevelDepATargetIntegrityRiskTirLevel, - ) { - set_bit_range!( - &mut self.flags, - target_integrity_risk_tir_level, - u8, - u8, - 2, - 0 - ); - } -} - -impl ConcreteMessage for MsgProtectionLevelDepA { - const MESSAGE_TYPE: u16 = 534; - const MESSAGE_NAME: &'static str = "MSG_PROTECTION_LEVEL_DEP_A"; -} - -impl SbpMessage for MsgProtectionLevelDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) - } -} + /// Time status + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TimeStatus { + /// GNSS time of validity + GnssTimeOfValidity = 0, -impl TryFrom for MsgProtectionLevelDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgProtectionLevelDepA(m) => Ok(m), - _ => Err(TryFromSbpError), - } + /// Other + Other = 1, } -} -impl WireFormat for MsgProtectionLevelDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.vpl) - + WireFormat::len(&self.hpl) - + WireFormat::len(&self.lat) - + WireFormat::len(&self.lon) - + WireFormat::len(&self.height) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl std::fmt::Display for TimeStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TimeStatus::GnssTimeOfValidity => f.write_str("GNSS time of validity"), + TimeStatus::Other => f.write_str("Other"), + } } } } -/// Target Integrity Risk (TIR) Level -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgProtectionLevelDepATargetIntegrityRiskTirLevel { - /// Safe state, protection level shall not be used for safety-critical - /// application - SafeStateProtectionLevelShallNotBeUsedForSafetyCriticalApplication = 0, - - /// TIR Level 1 - TirLevel1 = 1, - - /// TIR Level 2 - TirLevel2 = 2, - - /// TIR Level 3 - TirLevel3 = 3, -} +pub mod msg_protection_level_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Computed Position and Protection Level + /// + /// This message reports the local vertical and horizontal protection levels + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgProtectionLevelDepA { + /// 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 { + pub fn target_integrity_risk_tir_level(&self) -> Option { + match get_bit_range!( self.flags, u8, u8, 2, 0 ) { + 0 => Some( TargetIntegrityRiskTirLevel :: SafeStateProtectionLevelShallNotBeUsedForSafetyCriticalApplication ), + 1 => Some( TargetIntegrityRiskTirLevel :: TirLevel1 ), + 2 => Some( TargetIntegrityRiskTirLevel :: TirLevel2 ), + 3 => Some( TargetIntegrityRiskTirLevel :: TirLevel3 ), + _ => None, + } + } -impl std::fmt::Display for MsgProtectionLevelDepATargetIntegrityRiskTirLevel { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgProtectionLevelDepATargetIntegrityRiskTirLevel::SafeStateProtectionLevelShallNotBeUsedForSafetyCriticalApplication => f.write_str("Safe state, protection level shall not be used for safety-critical application"), - MsgProtectionLevelDepATargetIntegrityRiskTirLevel::TirLevel1 => f.write_str("TIR Level 1"), - MsgProtectionLevelDepATargetIntegrityRiskTirLevel::TirLevel2 => f.write_str("TIR Level 2"), - MsgProtectionLevelDepATargetIntegrityRiskTirLevel::TirLevel3 => f.write_str("TIR Level 3"), + pub fn set_target_integrity_risk_tir_level( + &mut self, + target_integrity_risk_tir_level: TargetIntegrityRiskTirLevel, + ) { + set_bit_range!( + &mut self.flags, + target_integrity_risk_tir_level, + u8, + u8, + 2, + 0 + ); } } -} -/// UTC Time -/// -/// This message reports the Universal Coordinated Time (UTC). Note the flags -/// which indicate the source of the UTC offset value and source of the time -/// fix. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgUtcTime { - /// 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 ConcreteMessage for MsgProtectionLevelDepA { + const MESSAGE_TYPE: u16 = 534; + const MESSAGE_NAME: &'static str = "MSG_PROTECTION_LEVEL_DEP_A"; + } -impl MsgUtcTime { - pub fn utc_offset_source(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(MsgUtcTimeUtcOffsetSource::FactoryDefault), - 1 => Some(MsgUtcTimeUtcOffsetSource::NonVolatileMemory), - 2 => Some(MsgUtcTimeUtcOffsetSource::DecodedThisSession), - _ => None, + impl SbpMessage for MsgProtectionLevelDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) } } - pub fn set_utc_offset_source(&mut self, utc_offset_source: MsgUtcTimeUtcOffsetSource) { - set_bit_range!(&mut self.flags, utc_offset_source, u8, u8, 4, 3); + impl TryFrom for MsgProtectionLevelDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgProtectionLevelDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - pub fn time_source(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgUtcTimeTimeSource::None), - 1 => Some(MsgUtcTimeTimeSource::GnssSolution), - 2 => Some(MsgUtcTimeTimeSource::Propagated), - _ => None, + impl WireFormat for MsgProtectionLevelDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.vpl) + + WireFormat::len(&self.hpl) + + WireFormat::len(&self.lat) + + WireFormat::len(&self.lon) + + WireFormat::len(&self.height) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } - pub fn set_time_source(&mut self, time_source: MsgUtcTimeTimeSource) { - set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); - } -} + /// Target Integrity Risk (TIR) Level + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TargetIntegrityRiskTirLevel { + /// Safe state, protection level shall not be used for safety-critical + /// application + SafeStateProtectionLevelShallNotBeUsedForSafetyCriticalApplication = 0, + + /// TIR Level 1 + TirLevel1 = 1, + + /// TIR Level 2 + TirLevel2 = 2, + + /// TIR Level 3 + TirLevel3 = 3, + } + + impl std::fmt::Display for TargetIntegrityRiskTirLevel { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TargetIntegrityRiskTirLevel::SafeStateProtectionLevelShallNotBeUsedForSafetyCriticalApplication => f.write_str("Safe state, protection level shall not be used for safety-critical application"), + TargetIntegrityRiskTirLevel::TirLevel1 => f.write_str("TIR Level 1"), + TargetIntegrityRiskTirLevel::TirLevel2 => f.write_str("TIR Level 2"), + TargetIntegrityRiskTirLevel::TirLevel3 => f.write_str("TIR Level 3"), + } + } + } +} + +pub mod msg_utc_time { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// UTC Time + /// + /// This message reports the Universal Coordinated Time (UTC). Note the flags + /// which indicate the source of the UTC offset value and source of the time + /// fix. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgUtcTime { + /// 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 { + pub fn utc_offset_source(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(UtcOffsetSource::FactoryDefault), + 1 => Some(UtcOffsetSource::NonVolatileMemory), + 2 => Some(UtcOffsetSource::DecodedThisSession), + _ => None, + } + } -impl ConcreteMessage for MsgUtcTime { - const MESSAGE_TYPE: u16 = 259; - const MESSAGE_NAME: &'static str = "MSG_UTC_TIME"; -} + pub fn set_utc_offset_source(&mut self, utc_offset_source: UtcOffsetSource) { + set_bit_range!(&mut self.flags, utc_offset_source, u8, u8, 4, 3); + } -impl SbpMessage for MsgUtcTime { - 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); + pub fn time_source(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(TimeSource::None), + 1 => Some(TimeSource::GnssSolution), + 2 => Some(TimeSource::Propagated), + _ => None, + } + } + + pub fn set_time_source(&mut self, time_source: TimeSource) { + set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); + } } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgUtcTime { + const MESSAGE_TYPE: u16 = 259; + const MESSAGE_NAME: &'static str = "MSG_UTC_TIME"; } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + + impl SbpMessage for MsgUtcTime { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgUtcTime { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgUtcTime(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgUtcTime { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgUtcTime(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgUtcTime { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.flags) - + WireFormat::len(&self.tow) - + WireFormat::len(&self.year) - + WireFormat::len(&self.month) - + WireFormat::len(&self.day) - + WireFormat::len(&self.hours) - + WireFormat::len(&self.minutes) - + WireFormat::len(&self.seconds) - + WireFormat::len(&self.ns) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgUtcTime { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.flags) + + WireFormat::len(&self.tow) + + WireFormat::len(&self.year) + + WireFormat::len(&self.month) + + WireFormat::len(&self.day) + + WireFormat::len(&self.hours) + + WireFormat::len(&self.minutes) + + WireFormat::len(&self.seconds) + + WireFormat::len(&self.ns) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// UTC offset source -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgUtcTimeUtcOffsetSource { - /// Factory Default - FactoryDefault = 0, + /// UTC offset source + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum UtcOffsetSource { + /// Factory Default + FactoryDefault = 0, - /// Non Volatile Memory - NonVolatileMemory = 1, + /// Non Volatile Memory + NonVolatileMemory = 1, - /// Decoded this Session - DecodedThisSession = 2, -} + /// Decoded this Session + DecodedThisSession = 2, + } -impl std::fmt::Display for MsgUtcTimeUtcOffsetSource { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgUtcTimeUtcOffsetSource::FactoryDefault => f.write_str("Factory Default"), - MsgUtcTimeUtcOffsetSource::NonVolatileMemory => f.write_str("Non Volatile Memory"), - MsgUtcTimeUtcOffsetSource::DecodedThisSession => f.write_str("Decoded this Session"), + impl std::fmt::Display for UtcOffsetSource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + UtcOffsetSource::FactoryDefault => f.write_str("Factory Default"), + UtcOffsetSource::NonVolatileMemory => f.write_str("Non Volatile Memory"), + UtcOffsetSource::DecodedThisSession => f.write_str("Decoded this Session"), + } } } -} -/// Time source -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgUtcTimeTimeSource { - /// None (invalid) - None = 0, + /// Time source + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TimeSource { + /// None (invalid) + None = 0, - /// GNSS Solution - GnssSolution = 1, + /// GNSS Solution + GnssSolution = 1, - /// Propagated - Propagated = 2, -} + /// Propagated + Propagated = 2, + } -impl std::fmt::Display for MsgUtcTimeTimeSource { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgUtcTimeTimeSource::None => f.write_str("None (invalid)"), - MsgUtcTimeTimeSource::GnssSolution => f.write_str("GNSS Solution"), - MsgUtcTimeTimeSource::Propagated => f.write_str("Propagated"), + impl std::fmt::Display for TimeSource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TimeSource::None => f.write_str("None (invalid)"), + TimeSource::GnssSolution => f.write_str("GNSS Solution"), + TimeSource::Propagated => f.write_str("Propagated"), + } } } } -/// UTC Time -/// -/// This message reports the Universal Coordinated Time (UTC). Note the flags -/// which indicate the source of the UTC offset value and source of the time -/// fix. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgUtcTimeGnss { - /// 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, -} +pub mod msg_utc_time_gnss { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// UTC Time + /// + /// This message reports the Universal Coordinated Time (UTC). Note the flags + /// which indicate the source of the UTC offset value and source of the time + /// fix. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgUtcTimeGnss { + /// 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 { + pub fn utc_offset_source(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(UtcOffsetSource::FactoryDefault), + 1 => Some(UtcOffsetSource::NonVolatileMemory), + 2 => Some(UtcOffsetSource::DecodedThisSession), + _ => None, + } + } -impl MsgUtcTimeGnss { - pub fn utc_offset_source(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(MsgUtcTimeGnssUtcOffsetSource::FactoryDefault), - 1 => Some(MsgUtcTimeGnssUtcOffsetSource::NonVolatileMemory), - 2 => Some(MsgUtcTimeGnssUtcOffsetSource::DecodedThisSession), - _ => None, + pub fn set_utc_offset_source(&mut self, utc_offset_source: UtcOffsetSource) { + set_bit_range!(&mut self.flags, utc_offset_source, u8, u8, 4, 3); } - } - pub fn set_utc_offset_source(&mut self, utc_offset_source: MsgUtcTimeGnssUtcOffsetSource) { - set_bit_range!(&mut self.flags, utc_offset_source, u8, u8, 4, 3); - } + pub fn time_source(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(TimeSource::None), + 1 => Some(TimeSource::GnssSolution), + 2 => Some(TimeSource::Propagated), + _ => None, + } + } - pub fn time_source(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgUtcTimeGnssTimeSource::None), - 1 => Some(MsgUtcTimeGnssTimeSource::GnssSolution), - 2 => Some(MsgUtcTimeGnssTimeSource::Propagated), - _ => None, + pub fn set_time_source(&mut self, time_source: TimeSource) { + set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); } } - pub fn set_time_source(&mut self, time_source: MsgUtcTimeGnssTimeSource) { - set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); + impl ConcreteMessage for MsgUtcTimeGnss { + const MESSAGE_TYPE: u16 = 261; + const MESSAGE_NAME: &'static str = "MSG_UTC_TIME_GNSS"; } -} - -impl ConcreteMessage for MsgUtcTimeGnss { - const MESSAGE_TYPE: u16 = 261; - const MESSAGE_NAME: &'static str = "MSG_UTC_TIME_GNSS"; -} -impl SbpMessage for MsgUtcTimeGnss { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgUtcTimeGnss { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgUtcTimeGnss { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgUtcTimeGnss(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgUtcTimeGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgUtcTimeGnss(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgUtcTimeGnss { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.flags) - + WireFormat::len(&self.tow) - + WireFormat::len(&self.year) - + WireFormat::len(&self.month) - + WireFormat::len(&self.day) - + WireFormat::len(&self.hours) - + WireFormat::len(&self.minutes) - + WireFormat::len(&self.seconds) - + WireFormat::len(&self.ns) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgUtcTimeGnss { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.flags) + + WireFormat::len(&self.tow) + + WireFormat::len(&self.year) + + WireFormat::len(&self.month) + + WireFormat::len(&self.day) + + WireFormat::len(&self.hours) + + WireFormat::len(&self.minutes) + + WireFormat::len(&self.seconds) + + WireFormat::len(&self.ns) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// UTC offset source -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgUtcTimeGnssUtcOffsetSource { - /// Factory Default - FactoryDefault = 0, + /// UTC offset source + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum UtcOffsetSource { + /// Factory Default + FactoryDefault = 0, - /// Non Volatile Memory - NonVolatileMemory = 1, + /// Non Volatile Memory + NonVolatileMemory = 1, - /// Decoded this Session - DecodedThisSession = 2, -} + /// Decoded this Session + DecodedThisSession = 2, + } -impl std::fmt::Display for MsgUtcTimeGnssUtcOffsetSource { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgUtcTimeGnssUtcOffsetSource::FactoryDefault => f.write_str("Factory Default"), - MsgUtcTimeGnssUtcOffsetSource::NonVolatileMemory => f.write_str("Non Volatile Memory"), - MsgUtcTimeGnssUtcOffsetSource::DecodedThisSession => { - f.write_str("Decoded this Session") + impl std::fmt::Display for UtcOffsetSource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + UtcOffsetSource::FactoryDefault => f.write_str("Factory Default"), + UtcOffsetSource::NonVolatileMemory => f.write_str("Non Volatile Memory"), + UtcOffsetSource::DecodedThisSession => f.write_str("Decoded this Session"), } } } -} -/// Time source -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgUtcTimeGnssTimeSource { - /// None (invalid) - None = 0, + /// Time source + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TimeSource { + /// None (invalid) + None = 0, - /// GNSS Solution - GnssSolution = 1, + /// GNSS Solution + GnssSolution = 1, - /// Propagated - Propagated = 2, -} + /// Propagated + Propagated = 2, + } -impl std::fmt::Display for MsgUtcTimeGnssTimeSource { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgUtcTimeGnssTimeSource::None => f.write_str("None (invalid)"), - MsgUtcTimeGnssTimeSource::GnssSolution => f.write_str("GNSS Solution"), - MsgUtcTimeGnssTimeSource::Propagated => f.write_str("Propagated"), + impl std::fmt::Display for TimeSource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TimeSource::None => f.write_str("None (invalid)"), + TimeSource::GnssSolution => f.write_str("GNSS Solution"), + TimeSource::Propagated => f.write_str("Propagated"), + } } } } -/// Velocity in User Frame -/// -/// This message reports the velocity in the Vehicle Body Frame. By -/// convention, the x-axis should point out the nose of the vehicle and -/// represent the forward direction, while as the y-axis should point out the -/// right hand side of the vehicle. Since this is a right handed system, z -/// should point out the bottom of the vehicle. The orientation and origin of -/// the Vehicle Body Frame are specified via the device settings. The full GPS -/// time is given by the preceding MSG_GPS_TIME with the matching time-of-week -/// (tow). This message is only produced by inertial versions of Swift -/// products and is not available from Piksi Multi or Duro. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgVelBody { - /// 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, -} +pub mod msg_vel_body { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Velocity in User Frame + /// + /// This message reports the velocity in the Vehicle Body Frame. By + /// convention, the x-axis should point out the nose of the vehicle and + /// represent the forward direction, while as the y-axis should point out the + /// right hand side of the vehicle. Since this is a right handed system, z + /// should point out the bottom of the vehicle. The orientation and origin of + /// the Vehicle Body Frame are specified via the device settings. The full GPS + /// time is given by the preceding MSG_GPS_TIME with the matching time-of-week + /// (tow). This message is only produced by inertial versions of Swift + /// products and is not available from Piksi Multi or Duro. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgVelBody { + /// 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 { + pub fn ins_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(InsNavigationMode::None), + 1 => Some(InsNavigationMode::InsUsed), + _ => None, + } + } -impl MsgVelBody { - pub fn ins_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(MsgVelBodyInsNavigationMode::None), - 1 => Some(MsgVelBodyInsNavigationMode::InsUsed), - _ => None, + pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { + set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); } - } - pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: MsgVelBodyInsNavigationMode) { - set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); - } + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(VelocityMode::Invalid), + 1 => Some(VelocityMode::MeasuredDopplerDerived), + 2 => Some(VelocityMode::ComputedDopplerDerived), + 3 => Some(VelocityMode::DeadReckoning), + _ => None, + } + } - pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgVelBodyVelocityMode::Invalid), - 1 => Some(MsgVelBodyVelocityMode::MeasuredDopplerDerived), - 2 => Some(MsgVelBodyVelocityMode::ComputedDopplerDerived), - 3 => Some(MsgVelBodyVelocityMode::DeadReckoning), - _ => None, + pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); } } - pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelBodyVelocityMode) { - set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgVelBody { + const MESSAGE_TYPE: u16 = 531; + const MESSAGE_NAME: &'static str = "MSG_VEL_BODY"; } -} -impl ConcreteMessage for MsgVelBody { - const MESSAGE_TYPE: u16 = 531; - const MESSAGE_NAME: &'static str = "MSG_VEL_BODY"; -} - -impl SbpMessage for MsgVelBody { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgVelBody { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgVelBody { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgVelBody(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgVelBody { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgVelBody(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgVelBody { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.x) - + WireFormat::len(&self.y) - + WireFormat::len(&self.z) - + WireFormat::len(&self.cov_x_x) - + WireFormat::len(&self.cov_x_y) - + WireFormat::len(&self.cov_x_z) - + WireFormat::len(&self.cov_y_y) - + WireFormat::len(&self.cov_y_z) - + WireFormat::len(&self.cov_z_z) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgVelBody { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.x) + + WireFormat::len(&self.y) + + WireFormat::len(&self.z) + + WireFormat::len(&self.cov_x_x) + + WireFormat::len(&self.cov_x_y) + + WireFormat::len(&self.cov_x_z) + + WireFormat::len(&self.cov_y_y) + + WireFormat::len(&self.cov_y_z) + + WireFormat::len(&self.cov_z_z) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// INS Navigation Mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelBodyInsNavigationMode { - /// None - None = 0, + /// INS Navigation Mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum InsNavigationMode { + /// None + None = 0, - /// INS used - InsUsed = 1, -} + /// INS used + InsUsed = 1, + } -impl std::fmt::Display for MsgVelBodyInsNavigationMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelBodyInsNavigationMode::None => f.write_str("None"), - MsgVelBodyInsNavigationMode::InsUsed => f.write_str("INS used"), + impl std::fmt::Display for InsNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + InsNavigationMode::None => f.write_str("None"), + InsNavigationMode::InsUsed => f.write_str("INS used"), + } } } -} -/// Velocity mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelBodyVelocityMode { - /// Invalid - Invalid = 0, + /// Velocity mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum VelocityMode { + /// Invalid + Invalid = 0, - /// Measured Doppler derived - MeasuredDopplerDerived = 1, + /// Measured Doppler derived + MeasuredDopplerDerived = 1, - /// Computed Doppler derived - ComputedDopplerDerived = 2, + /// Computed Doppler derived + ComputedDopplerDerived = 2, - /// Dead Reckoning - DeadReckoning = 3, -} + /// Dead Reckoning + DeadReckoning = 3, + } -impl std::fmt::Display for MsgVelBodyVelocityMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelBodyVelocityMode::Invalid => f.write_str("Invalid"), - MsgVelBodyVelocityMode::MeasuredDopplerDerived => { - f.write_str("Measured Doppler derived") + impl std::fmt::Display for VelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + VelocityMode::Invalid => f.write_str("Invalid"), + VelocityMode::MeasuredDopplerDerived => f.write_str("Measured Doppler derived"), + VelocityMode::ComputedDopplerDerived => f.write_str("Computed Doppler derived"), + VelocityMode::DeadReckoning => f.write_str("Dead Reckoning"), } - MsgVelBodyVelocityMode::ComputedDopplerDerived => { - f.write_str("Computed Doppler derived") - } - MsgVelBodyVelocityMode::DeadReckoning => f.write_str("Dead Reckoning"), } } } -/// Velocity expressed as course over ground -/// -/// This message reports the receiver course over ground (COG) and speed over -/// ground (SOG) based on the horizontal (N-E) components of the NED velocity -/// vector. It also includes the vertical velocity coordinate. A flag is -/// provided to indicate whether the COG value has been frozen. When the flag -/// is set to true, the COG field is set to its last valid value until the -/// system exceeds a minimum velocity threshold. No other fields are affected -/// by this flag. The NED coordinate system is defined as the local WGS84 -/// 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). -/// Note: course over ground represents the receiver's direction of travel, -/// but not necessarily the device heading. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgVelCog { - /// 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, - /// Course over ground relative to north direction - #[cfg_attr(feature = "serde", serde(rename(serialize = "cog")))] - pub cog: u32, - /// Speed over ground (based on horizontal velocity) - #[cfg_attr(feature = "serde", serde(rename(serialize = "sog")))] - pub sog: u32, - /// Vertical velocity component (positive up) - #[cfg_attr(feature = "serde", serde(rename(serialize = "v_up")))] - pub v_up: i32, - /// Course over ground estimated standard deviation - #[cfg_attr(feature = "serde", serde(rename(serialize = "cog_accuracy")))] - pub cog_accuracy: u32, - /// Speed over ground estimated standard deviation - #[cfg_attr(feature = "serde", serde(rename(serialize = "sog_accuracy")))] - pub sog_accuracy: u32, - /// Vertical velocity estimated standard deviation - #[cfg_attr(feature = "serde", serde(rename(serialize = "v_up_accuracy")))] - pub v_up_accuracy: u32, - /// Status flags - #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] - pub flags: u16, -} +pub mod msg_vel_cog { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Velocity expressed as course over ground + /// + /// This message reports the receiver course over ground (COG) and speed over + /// ground (SOG) based on the horizontal (N-E) components of the NED velocity + /// vector. It also includes the vertical velocity coordinate. A flag is + /// provided to indicate whether the COG value has been frozen. When the flag + /// is set to true, the COG field is set to its last valid value until the + /// system exceeds a minimum velocity threshold. No other fields are affected + /// by this flag. The NED coordinate system is defined as the local WGS84 + /// 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). + /// Note: course over ground represents the receiver's direction of travel, + /// but not necessarily the device heading. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgVelCog { + /// 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, + /// Course over ground relative to north direction + #[cfg_attr(feature = "serde", serde(rename(serialize = "cog")))] + pub cog: u32, + /// Speed over ground (based on horizontal velocity) + #[cfg_attr(feature = "serde", serde(rename(serialize = "sog")))] + pub sog: u32, + /// Vertical velocity component (positive up) + #[cfg_attr(feature = "serde", serde(rename(serialize = "v_up")))] + pub v_up: i32, + /// Course over ground estimated standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "cog_accuracy")))] + pub cog_accuracy: u32, + /// Speed over ground estimated standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "sog_accuracy")))] + pub sog_accuracy: u32, + /// Vertical velocity estimated standard deviation + #[cfg_attr(feature = "serde", serde(rename(serialize = "v_up_accuracy")))] + pub v_up_accuracy: u32, + /// Status flags + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] + pub flags: u16, + } + + impl MsgVelCog { + pub fn cog_frozen(&self) -> Option { + match get_bit_range!(self.flags, u16, u8, 9, 0) { + 0 => Some(CogFrozen::NotFrozen), + 1 => Some(CogFrozen::Frozen), + _ => None, + } + } -impl MsgVelCog { - pub fn vertical_velocity_validity(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 0) { - 0 => Some(MsgVelCogVerticalVelocityValidity::Invalid), - 1 => Some(MsgVelCogVerticalVelocityValidity::VerticalVelocityValid), - _ => None, + pub fn set_cog_frozen(&mut self, cog_frozen: CogFrozen) { + set_bit_range!(&mut self.flags, cog_frozen, u16, u8, 9, 0); } - } - pub fn set_vertical_velocity_validity( - &mut self, - vertical_velocity_validity: MsgVelCogVerticalVelocityValidity, - ) { - set_bit_range!(&mut self.flags, vertical_velocity_validity, u8, u8, 5, 0); - } + pub fn vertical_velocity_validity(&self) -> Option { + match get_bit_range!(self.flags, u16, u8, 8, 0) { + 0 => Some(VerticalVelocityValidity::Invalid), + 1 => Some(VerticalVelocityValidity::VerticalVelocityValid), + _ => None, + } + } - pub fn sog_validity(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 0) { - 0 => Some(MsgVelCogSogValidity::Invalid), - 1 => Some(MsgVelCogSogValidity::SogValid), - _ => None, + pub fn set_vertical_velocity_validity( + &mut self, + vertical_velocity_validity: VerticalVelocityValidity, + ) { + set_bit_range!(&mut self.flags, vertical_velocity_validity, u16, u8, 8, 0); } - } - pub fn set_sog_validity(&mut self, sog_validity: MsgVelCogSogValidity) { - set_bit_range!(&mut self.flags, sog_validity, u8, u8, 4, 0); - } + pub fn sog_validity(&self) -> Option { + match get_bit_range!(self.flags, u16, u8, 7, 0) { + 0 => Some(SogValidity::Invalid), + 1 => Some(SogValidity::SogValid), + _ => None, + } + } - pub fn cog_validity(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 0) { - 0 => Some(MsgVelCogCogValidity::Invalid), - 1 => Some(MsgVelCogCogValidity::CogValid), - _ => None, + pub fn set_sog_validity(&mut self, sog_validity: SogValidity) { + set_bit_range!(&mut self.flags, sog_validity, u16, u8, 7, 0); } - } - pub fn set_cog_validity(&mut self, cog_validity: MsgVelCogCogValidity) { - set_bit_range!(&mut self.flags, cog_validity, u8, u8, 3, 0); - } + pub fn cog_validity(&self) -> Option { + match get_bit_range!(self.flags, u16, u8, 6, 0) { + 0 => Some(CogValidity::Invalid), + 1 => Some(CogValidity::CogValid), + _ => None, + } + } - pub fn ins_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgVelCogInsNavigationMode::None), - 1 => Some(MsgVelCogInsNavigationMode::InsUsed), - _ => None, + pub fn set_cog_validity(&mut self, cog_validity: CogValidity) { + set_bit_range!(&mut self.flags, cog_validity, u16, u8, 6, 0); } - } - pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: MsgVelCogInsNavigationMode) { - set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 2, 0); - } + pub fn type_of_reported_tow(&self) -> Option { + match get_bit_range!(self.flags, u16, u8, 5, 0) { + 0 => Some(TypeOfReportedTow::TimeOfMeasurement), + 1 => Some(TypeOfReportedTow::Other), + _ => None, + } + } - pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 1, 0) { - 0 => Some(MsgVelCogVelocityMode::Invalid), - 1 => Some(MsgVelCogVelocityMode::MeasuredDopplerDerived), - 2 => Some(MsgVelCogVelocityMode::ComputedDopplerDerived), - 3 => Some(MsgVelCogVelocityMode::DeadReckoning), - _ => None, + pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { + set_bit_range!(&mut self.flags, type_of_reported_tow, u16, u8, 5, 0); } - } - pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelCogVelocityMode) { - set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 1, 0); - } -} + pub fn ins_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u16, u8, 4, 3) { + 0 => Some(InsNavigationMode::None), + 1 => Some(InsNavigationMode::InsUsed), + _ => None, + } + } -impl ConcreteMessage for MsgVelCog { - const MESSAGE_TYPE: u16 = 540; - const MESSAGE_NAME: &'static str = "MSG_VEL_COG"; -} + pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { + set_bit_range!(&mut self.flags, ins_navigation_mode, u16, u8, 4, 3); + } -impl SbpMessage for MsgVelCog { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u16, u8, 2, 0) { + 0 => Some(VelocityMode::Invalid), + 1 => Some(VelocityMode::MeasuredDopplerDerived), + 2 => Some(VelocityMode::ComputedDopplerDerived), + 3 => Some(VelocityMode::DeadReckoning), + _ => None, + } + } + + pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u16, u8, 2, 0); + } } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE + + impl ConcreteMessage for MsgVelCog { + const MESSAGE_TYPE: u16 = 540; + const MESSAGE_NAME: &'static str = "MSG_VEL_COG"; } - fn sender_id(&self) -> Option { - self.sender_id + + impl SbpMessage for MsgVelCog { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); + + impl TryFrom for MsgVelCog { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgVelCog(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl WireFormat for MsgVelCog { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.cog) + + WireFormat::len(&self.sog) + + WireFormat::len(&self.v_up) + + WireFormat::len(&self.cog_accuracy) + + WireFormat::len(&self.sog_accuracy) + + WireFormat::len(&self.v_up_accuracy) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.cog, buf); + WireFormat::write(&self.sog, buf); + WireFormat::write(&self.v_up, buf); + WireFormat::write(&self.cog_accuracy, buf); + WireFormat::write(&self.sog_accuracy, buf); + WireFormat::write(&self.v_up_accuracy, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgVelCog { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + cog: WireFormat::parse_unchecked(buf), + sog: WireFormat::parse_unchecked(buf), + v_up: WireFormat::parse_unchecked(buf), + cog_accuracy: WireFormat::parse_unchecked(buf), + sog_accuracy: WireFormat::parse_unchecked(buf), + v_up_accuracy: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } + } } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + + /// COG frozen + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum CogFrozen { + /// Not frozen + NotFrozen = 0, + + /// Frozen + Frozen = 1, } -} -impl TryFrom for MsgVelCog { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgVelCog(m) => Ok(m), - _ => Err(TryFromSbpError), + impl std::fmt::Display for CogFrozen { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + CogFrozen::NotFrozen => f.write_str("Not frozen"), + CogFrozen::Frozen => f.write_str("Frozen"), + } } } -} -impl WireFormat for MsgVelCog { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.cog) - + WireFormat::len(&self.sog) - + WireFormat::len(&self.v_up) - + WireFormat::len(&self.cog_accuracy) - + WireFormat::len(&self.sog_accuracy) - + WireFormat::len(&self.v_up_accuracy) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.tow, buf); - WireFormat::write(&self.cog, buf); - WireFormat::write(&self.sog, buf); - WireFormat::write(&self.v_up, buf); - WireFormat::write(&self.cog_accuracy, buf); - WireFormat::write(&self.sog_accuracy, buf); - WireFormat::write(&self.v_up_accuracy, buf); - WireFormat::write(&self.flags, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgVelCog { - sender_id: None, - tow: WireFormat::parse_unchecked(buf), - cog: WireFormat::parse_unchecked(buf), - sog: WireFormat::parse_unchecked(buf), - v_up: WireFormat::parse_unchecked(buf), - cog_accuracy: WireFormat::parse_unchecked(buf), - sog_accuracy: WireFormat::parse_unchecked(buf), - v_up_accuracy: WireFormat::parse_unchecked(buf), - flags: WireFormat::parse_unchecked(buf), + /// Vertical velocity validity + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum VerticalVelocityValidity { + /// Invalid + Invalid = 0, + + /// Vertical velocity valid + VerticalVelocityValid = 1, + } + + impl std::fmt::Display for VerticalVelocityValidity { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + VerticalVelocityValidity::Invalid => f.write_str("Invalid"), + VerticalVelocityValidity::VerticalVelocityValid => { + f.write_str("Vertical velocity valid") + } + } } } -} -/// Vertical velocity validity -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelCogVerticalVelocityValidity { - /// Invalid - Invalid = 0, + /// SOG validity + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum SogValidity { + /// Invalid + Invalid = 0, - /// Vertical velocity valid - VerticalVelocityValid = 1, -} + /// SOG valid + SogValid = 1, + } -impl std::fmt::Display for MsgVelCogVerticalVelocityValidity { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelCogVerticalVelocityValidity::Invalid => f.write_str("Invalid"), - MsgVelCogVerticalVelocityValidity::VerticalVelocityValid => { - f.write_str("Vertical velocity valid") + impl std::fmt::Display for SogValidity { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SogValidity::Invalid => f.write_str("Invalid"), + SogValidity::SogValid => f.write_str("SOG valid"), } } } -} -/// SOG validity -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelCogSogValidity { - /// Invalid - Invalid = 0, + /// COG validity + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum CogValidity { + /// Invalid + Invalid = 0, - /// SOG valid - SogValid = 1, -} + /// COG valid + CogValid = 1, + } -impl std::fmt::Display for MsgVelCogSogValidity { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelCogSogValidity::Invalid => f.write_str("Invalid"), - MsgVelCogSogValidity::SogValid => f.write_str("SOG valid"), + impl std::fmt::Display for CogValidity { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + CogValidity::Invalid => f.write_str("Invalid"), + CogValidity::CogValid => f.write_str("COG valid"), + } } } -} -/// COG validity -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelCogCogValidity { - /// Invalid - Invalid = 0, + /// Type of reported TOW + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TypeOfReportedTow { + /// Time of Measurement + TimeOfMeasurement = 0, - /// COG valid - CogValid = 1, -} + /// Other + Other = 1, + } -impl std::fmt::Display for MsgVelCogCogValidity { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelCogCogValidity::Invalid => f.write_str("Invalid"), - MsgVelCogCogValidity::CogValid => f.write_str("COG valid"), + impl std::fmt::Display for TypeOfReportedTow { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), + TypeOfReportedTow::Other => f.write_str("Other"), + } } } -} -/// INS Navigation Mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelCogInsNavigationMode { - /// None - None = 0, + /// INS Navigation Mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum InsNavigationMode { + /// None + None = 0, - /// INS used - InsUsed = 1, -} + /// INS used + InsUsed = 1, + } -impl std::fmt::Display for MsgVelCogInsNavigationMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelCogInsNavigationMode::None => f.write_str("None"), - MsgVelCogInsNavigationMode::InsUsed => f.write_str("INS used"), + impl std::fmt::Display for InsNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + InsNavigationMode::None => f.write_str("None"), + InsNavigationMode::InsUsed => f.write_str("INS used"), + } } } -} -/// Velocity mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelCogVelocityMode { - /// Invalid - Invalid = 0, + /// Velocity mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum VelocityMode { + /// Invalid + Invalid = 0, - /// Measured Doppler derived - MeasuredDopplerDerived = 1, + /// Measured Doppler derived + MeasuredDopplerDerived = 1, - /// Computed Doppler derived - ComputedDopplerDerived = 2, + /// Computed Doppler derived + ComputedDopplerDerived = 2, - /// Dead Reckoning - DeadReckoning = 3, -} + /// Dead Reckoning + DeadReckoning = 3, + } -impl std::fmt::Display for MsgVelCogVelocityMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelCogVelocityMode::Invalid => f.write_str("Invalid"), - MsgVelCogVelocityMode::MeasuredDopplerDerived => { - f.write_str("Measured Doppler derived") - } - MsgVelCogVelocityMode::ComputedDopplerDerived => { - f.write_str("Computed Doppler derived") + impl std::fmt::Display for VelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + VelocityMode::Invalid => f.write_str("Invalid"), + VelocityMode::MeasuredDopplerDerived => f.write_str("Measured Doppler derived"), + VelocityMode::ComputedDopplerDerived => f.write_str("Computed Doppler derived"), + VelocityMode::DeadReckoning => f.write_str("Dead Reckoning"), } - MsgVelCogVelocityMode::DeadReckoning => f.write_str("Dead Reckoning"), } } } -/// Velocity in ECEF -/// -/// This message reports the velocity in Earth Centered Earth Fixed (ECEF) -/// coordinates. The full GPS time is given by the preceding MSG_GPS_TIME with -/// the matching time-of-week (tow). -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_vel_ecef { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Velocity in ECEF + /// + /// This message reports the velocity in Earth Centered Earth Fixed (ECEF) + /// coordinates. The full GPS time is given by the preceding MSG_GPS_TIME with + /// the matching time-of-week (tow). + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn type_of_reported_tow(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 5) { + 0 => Some(TypeOfReportedTow::TimeOfMeasurement), + 1 => Some(TypeOfReportedTow::Other), + _ => None, + } + } -impl MsgVelEcef { - pub fn type_of_reported_tow(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 5) { - 0 => Some(MsgVelEcefTypeOfReportedTow::TimeOfMeasurement), - 1 => Some(MsgVelEcefTypeOfReportedTow::Other), - _ => None, + pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { + set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } - } - pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: MsgVelEcefTypeOfReportedTow) { - set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); - } + pub fn ins_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(InsNavigationMode::None), + 1 => Some(InsNavigationMode::InsUsed), + _ => None, + } + } - pub fn ins_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(MsgVelEcefInsNavigationMode::None), - 1 => Some(MsgVelEcefInsNavigationMode::InsUsed), - _ => None, + pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { + set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); } - } - pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: MsgVelEcefInsNavigationMode) { - set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); - } + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(VelocityMode::Invalid), + 1 => Some(VelocityMode::MeasuredDopplerDerived), + 2 => Some(VelocityMode::ComputedDopplerDerived), + 3 => Some(VelocityMode::DeadReckoning), + _ => None, + } + } - pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgVelEcefVelocityMode::Invalid), - 1 => Some(MsgVelEcefVelocityMode::MeasuredDopplerDerived), - 2 => Some(MsgVelEcefVelocityMode::ComputedDopplerDerived), - 3 => Some(MsgVelEcefVelocityMode::DeadReckoning), - _ => None, + pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); } } - pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelEcefVelocityMode) { - set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgVelEcef { + const MESSAGE_TYPE: u16 = 525; + const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF"; } -} - -impl ConcreteMessage for MsgVelEcef { - const MESSAGE_TYPE: u16 = 525; - const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF"; -} -impl SbpMessage for MsgVelEcef { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgVelEcef { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgVelEcef { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgVelEcef(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgVelEcef { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgVelEcef(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgVelEcef { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.x) - + WireFormat::len(&self.y) - + WireFormat::len(&self.z) - + WireFormat::len(&self.accuracy) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgVelEcef { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.x) + + WireFormat::len(&self.y) + + WireFormat::len(&self.z) + + WireFormat::len(&self.accuracy) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Type of reported TOW -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelEcefTypeOfReportedTow { - /// Time of Measurement - TimeOfMeasurement = 0, + /// Type of reported TOW + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TypeOfReportedTow { + /// Time of Measurement + TimeOfMeasurement = 0, - /// Other - Other = 1, -} + /// Other + Other = 1, + } -impl std::fmt::Display for MsgVelEcefTypeOfReportedTow { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelEcefTypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), - MsgVelEcefTypeOfReportedTow::Other => f.write_str("Other"), + impl std::fmt::Display for TypeOfReportedTow { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), + TypeOfReportedTow::Other => f.write_str("Other"), + } } } -} -/// INS Navigation Mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelEcefInsNavigationMode { - /// None - None = 0, + /// INS Navigation Mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum InsNavigationMode { + /// None + None = 0, - /// INS used - InsUsed = 1, -} + /// INS used + InsUsed = 1, + } -impl std::fmt::Display for MsgVelEcefInsNavigationMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelEcefInsNavigationMode::None => f.write_str("None"), - MsgVelEcefInsNavigationMode::InsUsed => f.write_str("INS used"), + impl std::fmt::Display for InsNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + InsNavigationMode::None => f.write_str("None"), + InsNavigationMode::InsUsed => f.write_str("INS used"), + } } } -} -/// Velocity mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelEcefVelocityMode { - /// Invalid - Invalid = 0, + /// Velocity mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum VelocityMode { + /// Invalid + Invalid = 0, - /// Measured Doppler derived - MeasuredDopplerDerived = 1, + /// Measured Doppler derived + MeasuredDopplerDerived = 1, - /// Computed Doppler derived - ComputedDopplerDerived = 2, + /// Computed Doppler derived + ComputedDopplerDerived = 2, - /// Dead Reckoning - DeadReckoning = 3, -} + /// Dead Reckoning + DeadReckoning = 3, + } -impl std::fmt::Display for MsgVelEcefVelocityMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelEcefVelocityMode::Invalid => f.write_str("Invalid"), - MsgVelEcefVelocityMode::MeasuredDopplerDerived => { - f.write_str("Measured Doppler derived") - } - MsgVelEcefVelocityMode::ComputedDopplerDerived => { - f.write_str("Computed Doppler derived") + impl std::fmt::Display for VelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + VelocityMode::Invalid => f.write_str("Invalid"), + VelocityMode::MeasuredDopplerDerived => f.write_str("Measured Doppler derived"), + VelocityMode::ComputedDopplerDerived => f.write_str("Computed Doppler derived"), + VelocityMode::DeadReckoning => f.write_str("Dead Reckoning"), } - MsgVelEcefVelocityMode::DeadReckoning => f.write_str("Dead Reckoning"), } } } -/// Velocity in ECEF -/// -/// This message reports the velocity in Earth Centered Earth Fixed (ECEF) -/// coordinates. The full GPS time is given by the preceding MSG_GPS_TIME with -/// the matching time-of-week (tow). -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_vel_ecef_cov { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Velocity in ECEF + /// + /// This message reports the velocity in Earth Centered Earth Fixed (ECEF) + /// coordinates. The full GPS time is given by the preceding MSG_GPS_TIME with + /// the matching time-of-week (tow). + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn type_of_reported_tow(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 5) { + 0 => Some(TypeOfReportedTow::TimeOfMeasurement), + 1 => Some(TypeOfReportedTow::Other), + _ => None, + } + } -impl MsgVelEcefCov { - pub fn type_of_reported_tow(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 5) { - 0 => Some(MsgVelEcefCovTypeOfReportedTow::TimeOfMeasurement), - 1 => Some(MsgVelEcefCovTypeOfReportedTow::Other), - _ => None, + pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { + set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } - } - pub fn set_type_of_reported_tow( - &mut self, - type_of_reported_tow: MsgVelEcefCovTypeOfReportedTow, - ) { - set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); - } + pub fn ins_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(InsNavigationMode::None), + 1 => Some(InsNavigationMode::InsUsed), + _ => None, + } + } - pub fn ins_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(MsgVelEcefCovInsNavigationMode::None), - 1 => Some(MsgVelEcefCovInsNavigationMode::InsUsed), - _ => None, + pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { + set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); } - } - pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: MsgVelEcefCovInsNavigationMode) { - set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); - } + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(VelocityMode::Invalid), + 1 => Some(VelocityMode::MeasuredDopplerDerived), + 2 => Some(VelocityMode::ComputedDopplerDerived), + 3 => Some(VelocityMode::DeadReckoning), + _ => None, + } + } - pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgVelEcefCovVelocityMode::Invalid), - 1 => Some(MsgVelEcefCovVelocityMode::MeasuredDopplerDerived), - 2 => Some(MsgVelEcefCovVelocityMode::ComputedDopplerDerived), - 3 => Some(MsgVelEcefCovVelocityMode::DeadReckoning), - _ => None, + pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); } } - pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelEcefCovVelocityMode) { - set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgVelEcefCov { + const MESSAGE_TYPE: u16 = 533; + const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF_COV"; } -} - -impl ConcreteMessage for MsgVelEcefCov { - const MESSAGE_TYPE: u16 = 533; - const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF_COV"; -} -impl SbpMessage for MsgVelEcefCov { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgVelEcefCov { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgVelEcefCov { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgVelEcefCov(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgVelEcefCov { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgVelEcefCov(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgVelEcefCov { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.x) - + WireFormat::len(&self.y) - + WireFormat::len(&self.z) - + WireFormat::len(&self.cov_x_x) - + WireFormat::len(&self.cov_x_y) - + WireFormat::len(&self.cov_x_z) - + WireFormat::len(&self.cov_y_y) - + WireFormat::len(&self.cov_y_z) - + WireFormat::len(&self.cov_z_z) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgVelEcefCov { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.x) + + WireFormat::len(&self.y) + + WireFormat::len(&self.z) + + WireFormat::len(&self.cov_x_x) + + WireFormat::len(&self.cov_x_y) + + WireFormat::len(&self.cov_x_z) + + WireFormat::len(&self.cov_y_y) + + WireFormat::len(&self.cov_y_z) + + WireFormat::len(&self.cov_z_z) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Type of reported TOW -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelEcefCovTypeOfReportedTow { - /// Time of Measurement - TimeOfMeasurement = 0, + /// Type of reported TOW + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TypeOfReportedTow { + /// Time of Measurement + TimeOfMeasurement = 0, - /// Other - Other = 1, -} + /// Other + Other = 1, + } -impl std::fmt::Display for MsgVelEcefCovTypeOfReportedTow { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelEcefCovTypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), - MsgVelEcefCovTypeOfReportedTow::Other => f.write_str("Other"), + impl std::fmt::Display for TypeOfReportedTow { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), + TypeOfReportedTow::Other => f.write_str("Other"), + } } } -} -/// INS Navigation Mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelEcefCovInsNavigationMode { - /// None - None = 0, + /// INS Navigation Mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum InsNavigationMode { + /// None + None = 0, - /// INS used - InsUsed = 1, -} + /// INS used + InsUsed = 1, + } -impl std::fmt::Display for MsgVelEcefCovInsNavigationMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelEcefCovInsNavigationMode::None => f.write_str("None"), - MsgVelEcefCovInsNavigationMode::InsUsed => f.write_str("INS used"), + impl std::fmt::Display for InsNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + InsNavigationMode::None => f.write_str("None"), + InsNavigationMode::InsUsed => f.write_str("INS used"), + } } } -} -/// Velocity mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelEcefCovVelocityMode { - /// Invalid - Invalid = 0, + /// Velocity mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum VelocityMode { + /// Invalid + Invalid = 0, - /// Measured Doppler derived - MeasuredDopplerDerived = 1, + /// Measured Doppler derived + MeasuredDopplerDerived = 1, - /// Computed Doppler derived - ComputedDopplerDerived = 2, + /// Computed Doppler derived + ComputedDopplerDerived = 2, - /// Dead Reckoning - DeadReckoning = 3, -} + /// Dead Reckoning + DeadReckoning = 3, + } -impl std::fmt::Display for MsgVelEcefCovVelocityMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelEcefCovVelocityMode::Invalid => f.write_str("Invalid"), - MsgVelEcefCovVelocityMode::MeasuredDopplerDerived => { - f.write_str("Measured Doppler derived") - } - MsgVelEcefCovVelocityMode::ComputedDopplerDerived => { - f.write_str("Computed Doppler derived") + impl std::fmt::Display for VelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + VelocityMode::Invalid => f.write_str("Invalid"), + VelocityMode::MeasuredDopplerDerived => f.write_str("Measured Doppler derived"), + VelocityMode::ComputedDopplerDerived => f.write_str("Computed Doppler derived"), + VelocityMode::DeadReckoning => f.write_str("Dead Reckoning"), } - MsgVelEcefCovVelocityMode::DeadReckoning => f.write_str("Dead Reckoning"), } } } -/// GNSS-only Velocity in ECEF -/// -/// This message reports the velocity in Earth Centered Earth Fixed (ECEF) -/// coordinates. The full GPS time is given by the preceding MSG_GPS_TIME with -/// the matching time-of-week (tow). -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 { - pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgVelEcefCovGnssVelocityMode::Invalid), - 1 => Some(MsgVelEcefCovGnssVelocityMode::MeasuredDopplerDerived), - 2 => Some(MsgVelEcefCovGnssVelocityMode::ComputedDopplerDerived), - _ => None, +pub mod msg_vel_ecef_cov_gnss { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// GNSS-only Velocity in ECEF + /// + /// This message reports the velocity in Earth Centered Earth Fixed (ECEF) + /// coordinates. The full GPS time is given by the preceding MSG_GPS_TIME with + /// the matching time-of-week (tow). + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(VelocityMode::Invalid), + 1 => Some(VelocityMode::MeasuredDopplerDerived), + 2 => Some(VelocityMode::ComputedDopplerDerived), + _ => None, + } } - } - pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelEcefCovGnssVelocityMode) { - set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + } } -} - -impl ConcreteMessage for MsgVelEcefCovGnss { - const MESSAGE_TYPE: u16 = 565; - const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF_COV_GNSS"; -} -impl SbpMessage for MsgVelEcefCovGnss { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl ConcreteMessage for MsgVelEcefCovGnss { + const MESSAGE_TYPE: u16 = 565; + const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF_COV_GNSS"; } -} -impl TryFrom for MsgVelEcefCovGnss { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgVelEcefCovGnss(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgVelEcefCovGnss { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) } } -} -impl WireFormat for MsgVelEcefCovGnss { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.x) - + WireFormat::len(&self.y) - + WireFormat::len(&self.z) - + WireFormat::len(&self.cov_x_x) - + WireFormat::len(&self.cov_x_y) - + WireFormat::len(&self.cov_x_z) - + WireFormat::len(&self.cov_y_y) - + WireFormat::len(&self.cov_y_z) - + WireFormat::len(&self.cov_z_z) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl TryFrom for MsgVelEcefCovGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgVelEcefCovGnss(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} - -/// Velocity mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelEcefCovGnssVelocityMode { - /// Invalid - Invalid = 0, - - /// Measured Doppler derived - MeasuredDopplerDerived = 1, - - /// Computed Doppler derived - ComputedDopplerDerived = 2, -} -impl std::fmt::Display for MsgVelEcefCovGnssVelocityMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelEcefCovGnssVelocityMode::Invalid => f.write_str("Invalid"), - MsgVelEcefCovGnssVelocityMode::MeasuredDopplerDerived => { - f.write_str("Measured Doppler derived") - } - MsgVelEcefCovGnssVelocityMode::ComputedDopplerDerived => { - f.write_str("Computed Doppler derived") + impl WireFormat for MsgVelEcefCovGnss { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.x) + + WireFormat::len(&self.y) + + WireFormat::len(&self.z) + + WireFormat::len(&self.cov_x_x) + + WireFormat::len(&self.cov_x_y) + + WireFormat::len(&self.cov_x_z) + + WireFormat::len(&self.cov_y_y) + + WireFormat::len(&self.cov_y_z) + + WireFormat::len(&self.cov_z_z) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), } } } -} -/// Velocity in ECEF -/// -/// This message reports the velocity in Earth Centered Earth Fixed (ECEF) -/// coordinates. The full GPS time is given by the preceding MSG_GPS_TIME with -/// the matching time-of-week (tow). -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} + /// Velocity mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum VelocityMode { + /// Invalid + Invalid = 0, -impl ConcreteMessage for MsgVelEcefDepA { - const MESSAGE_TYPE: u16 = 516; - const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF_DEP_A"; -} + /// Measured Doppler derived + MeasuredDopplerDerived = 1, -impl SbpMessage for MsgVelEcefDepA { - 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); + /// Computed Doppler derived + ComputedDopplerDerived = 2, } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + + impl std::fmt::Display for VelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + VelocityMode::Invalid => f.write_str("Invalid"), + VelocityMode::MeasuredDopplerDerived => f.write_str("Measured Doppler derived"), + VelocityMode::ComputedDopplerDerived => f.write_str("Computed Doppler derived"), + } + } } } -impl TryFrom for MsgVelEcefDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgVelEcefDepA(m) => Ok(m), - _ => Err(TryFromSbpError), +pub mod msg_vel_ecef_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Velocity in ECEF + /// + /// This message reports the velocity in Earth Centered Earth Fixed (ECEF) + /// coordinates. The full GPS time is given by the preceding MSG_GPS_TIME with + /// the matching time-of-week (tow). + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 ConcreteMessage for MsgVelEcefDepA { + const MESSAGE_TYPE: u16 = 516; + const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF_DEP_A"; + } + + impl SbpMessage for MsgVelEcefDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } + } + + impl TryFrom for MsgVelEcefDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgVelEcefDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgVelEcefDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.x) - + WireFormat::len(&self.y) - + WireFormat::len(&self.z) - + WireFormat::len(&self.accuracy) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgVelEcefDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.x) + + WireFormat::len(&self.y) + + WireFormat::len(&self.z) + + WireFormat::len(&self.accuracy) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// GNSS-only Velocity in ECEF -/// -/// This message reports the velocity in Earth Centered Earth Fixed (ECEF) -/// coordinates. The full GPS time is given by the preceding MSG_GPS_TIME with -/// the matching time-of-week (tow). -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_vel_ecef_gnss { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// GNSS-only Velocity in ECEF + /// + /// This message reports the velocity in Earth Centered Earth Fixed (ECEF) + /// coordinates. The full GPS time is given by the preceding MSG_GPS_TIME with + /// the matching time-of-week (tow). + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(VelocityMode::Invalid), + 1 => Some(VelocityMode::MeasuredDopplerDerived), + 2 => Some(VelocityMode::ComputedDopplerDerived), + _ => None, + } + } -impl MsgVelEcefGnss { - pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgVelEcefGnssVelocityMode::Invalid), - 1 => Some(MsgVelEcefGnssVelocityMode::MeasuredDopplerDerived), - 2 => Some(MsgVelEcefGnssVelocityMode::ComputedDopplerDerived), - _ => None, + pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); } } - pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelEcefGnssVelocityMode) { - set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgVelEcefGnss { + const MESSAGE_TYPE: u16 = 557; + const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF_GNSS"; } -} -impl ConcreteMessage for MsgVelEcefGnss { - const MESSAGE_TYPE: u16 = 557; - const MESSAGE_NAME: &'static str = "MSG_VEL_ECEF_GNSS"; -} - -impl SbpMessage for MsgVelEcefGnss { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgVelEcefGnss { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgVelEcefGnss { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgVelEcefGnss(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgVelEcefGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgVelEcefGnss(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgVelEcefGnss { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.x) - + WireFormat::len(&self.y) - + WireFormat::len(&self.z) - + WireFormat::len(&self.accuracy) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgVelEcefGnss { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.x) + + WireFormat::len(&self.y) + + WireFormat::len(&self.z) + + WireFormat::len(&self.accuracy) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Velocity mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelEcefGnssVelocityMode { - /// Invalid - Invalid = 0, + /// Velocity mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum VelocityMode { + /// Invalid + Invalid = 0, - /// Measured Doppler derived - MeasuredDopplerDerived = 1, + /// Measured Doppler derived + MeasuredDopplerDerived = 1, - /// Computed Doppler derived - ComputedDopplerDerived = 2, -} + /// Computed Doppler derived + ComputedDopplerDerived = 2, + } -impl std::fmt::Display for MsgVelEcefGnssVelocityMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelEcefGnssVelocityMode::Invalid => f.write_str("Invalid"), - MsgVelEcefGnssVelocityMode::MeasuredDopplerDerived => { - f.write_str("Measured Doppler derived") - } - MsgVelEcefGnssVelocityMode::ComputedDopplerDerived => { - f.write_str("Computed Doppler derived") + impl std::fmt::Display for VelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + VelocityMode::Invalid => f.write_str("Invalid"), + VelocityMode::MeasuredDopplerDerived => f.write_str("Measured Doppler derived"), + VelocityMode::ComputedDopplerDerived => f.write_str("Computed Doppler derived"), } } } } -/// Velocity in NED -/// -/// This message reports the velocity in local North East Down (NED) -/// coordinates. The NED coordinate system is defined as the local WGS84 -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_vel_ned { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Velocity in NED + /// + /// This message reports the velocity in local North East Down (NED) + /// coordinates. The NED coordinate system is defined as the local WGS84 + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn type_of_reported_tow(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 5) { + 0 => Some(TypeOfReportedTow::TimeOfMeasurement), + 1 => Some(TypeOfReportedTow::Other), + _ => None, + } + } -impl MsgVelNed { - pub fn type_of_reported_tow(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 5) { - 0 => Some(MsgVelNedTypeOfReportedTow::TimeOfMeasurement), - 1 => Some(MsgVelNedTypeOfReportedTow::Other), - _ => None, + pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { + set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } - } - pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: MsgVelNedTypeOfReportedTow) { - set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); - } + pub fn ins_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(InsNavigationMode::None), + 1 => Some(InsNavigationMode::InsUsed), + _ => None, + } + } - pub fn ins_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(MsgVelNedInsNavigationMode::None), - 1 => Some(MsgVelNedInsNavigationMode::InsUsed), - _ => None, + pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { + set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); } - } - pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: MsgVelNedInsNavigationMode) { - set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); - } + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(VelocityMode::Invalid), + 1 => Some(VelocityMode::MeasuredDopplerDerived), + 2 => Some(VelocityMode::ComputedDopplerDerived), + 3 => Some(VelocityMode::DeadReckoning), + _ => None, + } + } - pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgVelNedVelocityMode::Invalid), - 1 => Some(MsgVelNedVelocityMode::MeasuredDopplerDerived), - 2 => Some(MsgVelNedVelocityMode::ComputedDopplerDerived), - 3 => Some(MsgVelNedVelocityMode::DeadReckoning), - _ => None, + pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); } } - pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelNedVelocityMode) { - set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgVelNed { + const MESSAGE_TYPE: u16 = 526; + const MESSAGE_NAME: &'static str = "MSG_VEL_NED"; } -} -impl ConcreteMessage for MsgVelNed { - const MESSAGE_TYPE: u16 = 526; - const MESSAGE_NAME: &'static str = "MSG_VEL_NED"; -} - -impl SbpMessage for MsgVelNed { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgVelNed { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgVelNed { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgVelNed(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgVelNed { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgVelNed(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgVelNed { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.n) - + WireFormat::len(&self.e) - + WireFormat::len(&self.d) - + WireFormat::len(&self.h_accuracy) - + WireFormat::len(&self.v_accuracy) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgVelNed { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.n) + + WireFormat::len(&self.e) + + WireFormat::len(&self.d) + + WireFormat::len(&self.h_accuracy) + + WireFormat::len(&self.v_accuracy) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Type of reported TOW -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelNedTypeOfReportedTow { - /// Time of Measurement - TimeOfMeasurement = 0, + /// Type of reported TOW + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TypeOfReportedTow { + /// Time of Measurement + TimeOfMeasurement = 0, - /// Other - Other = 1, -} + /// Other + Other = 1, + } -impl std::fmt::Display for MsgVelNedTypeOfReportedTow { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelNedTypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), - MsgVelNedTypeOfReportedTow::Other => f.write_str("Other"), + impl std::fmt::Display for TypeOfReportedTow { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), + TypeOfReportedTow::Other => f.write_str("Other"), + } } } -} -/// INS Navigation Mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelNedInsNavigationMode { - /// None - None = 0, + /// INS Navigation Mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum InsNavigationMode { + /// None + None = 0, - /// INS used - InsUsed = 1, -} + /// INS used + InsUsed = 1, + } -impl std::fmt::Display for MsgVelNedInsNavigationMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelNedInsNavigationMode::None => f.write_str("None"), - MsgVelNedInsNavigationMode::InsUsed => f.write_str("INS used"), + impl std::fmt::Display for InsNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + InsNavigationMode::None => f.write_str("None"), + InsNavigationMode::InsUsed => f.write_str("INS used"), + } } } -} -/// Velocity mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelNedVelocityMode { - /// Invalid - Invalid = 0, + /// Velocity mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum VelocityMode { + /// Invalid + Invalid = 0, - /// Measured Doppler derived - MeasuredDopplerDerived = 1, + /// Measured Doppler derived + MeasuredDopplerDerived = 1, - /// Computed Doppler derived - ComputedDopplerDerived = 2, + /// Computed Doppler derived + ComputedDopplerDerived = 2, - /// Dead Reckoning - DeadReckoning = 3, -} + /// Dead Reckoning + DeadReckoning = 3, + } -impl std::fmt::Display for MsgVelNedVelocityMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelNedVelocityMode::Invalid => f.write_str("Invalid"), - MsgVelNedVelocityMode::MeasuredDopplerDerived => { - f.write_str("Measured Doppler derived") + impl std::fmt::Display for VelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + VelocityMode::Invalid => f.write_str("Invalid"), + VelocityMode::MeasuredDopplerDerived => f.write_str("Measured Doppler derived"), + VelocityMode::ComputedDopplerDerived => f.write_str("Computed Doppler derived"), + VelocityMode::DeadReckoning => f.write_str("Dead Reckoning"), } - MsgVelNedVelocityMode::ComputedDopplerDerived => { - f.write_str("Computed Doppler derived") - } - MsgVelNedVelocityMode::DeadReckoning => f.write_str("Dead Reckoning"), } } } -/// Velocity in NED -/// -/// This message reports the velocity in local North East Down (NED) -/// coordinates. The NED coordinate system is defined as the local WGS84 -/// 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). This -/// message is similar to the MSG_VEL_NED, but it includes the upper -/// triangular portion of the 3x3 covariance matrix. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_vel_ned_cov { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Velocity in NED + /// + /// This message reports the velocity in local North East Down (NED) + /// coordinates. The NED coordinate system is defined as the local WGS84 + /// 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). This + /// message is similar to the MSG_VEL_NED, but it includes the upper + /// triangular portion of the 3x3 covariance matrix. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn type_of_reported_tow(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 5) { + 0 => Some(TypeOfReportedTow::TimeOfMeasurement), + 1 => Some(TypeOfReportedTow::Other), + _ => None, + } + } -impl MsgVelNedCov { - pub fn type_of_reported_tow(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 5) { - 0 => Some(MsgVelNedCovTypeOfReportedTow::TimeOfMeasurement), - 1 => Some(MsgVelNedCovTypeOfReportedTow::Other), - _ => None, + pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { + set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } - } - pub fn set_type_of_reported_tow( - &mut self, - type_of_reported_tow: MsgVelNedCovTypeOfReportedTow, - ) { - set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); - } + pub fn ins_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(InsNavigationMode::None), + 1 => Some(InsNavigationMode::InsUsed), + _ => None, + } + } - pub fn ins_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(MsgVelNedCovInsNavigationMode::None), - 1 => Some(MsgVelNedCovInsNavigationMode::InsUsed), - _ => None, + pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { + set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); } - } - pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: MsgVelNedCovInsNavigationMode) { - set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); - } + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(VelocityMode::Invalid), + 1 => Some(VelocityMode::MeasuredDopplerDerived), + 2 => Some(VelocityMode::ComputedDopplerDerived), + 3 => Some(VelocityMode::DeadReckoning), + _ => None, + } + } - pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgVelNedCovVelocityMode::Invalid), - 1 => Some(MsgVelNedCovVelocityMode::MeasuredDopplerDerived), - 2 => Some(MsgVelNedCovVelocityMode::ComputedDopplerDerived), - 3 => Some(MsgVelNedCovVelocityMode::DeadReckoning), - _ => None, + pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); } } - pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelNedCovVelocityMode) { - set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgVelNedCov { + const MESSAGE_TYPE: u16 = 530; + const MESSAGE_NAME: &'static str = "MSG_VEL_NED_COV"; } -} -impl ConcreteMessage for MsgVelNedCov { - const MESSAGE_TYPE: u16 = 530; - const MESSAGE_NAME: &'static str = "MSG_VEL_NED_COV"; -} - -impl SbpMessage for MsgVelNedCov { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgVelNedCov { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgVelNedCov { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgVelNedCov(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgVelNedCov { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgVelNedCov(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgVelNedCov { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.n) - + WireFormat::len(&self.e) - + WireFormat::len(&self.d) - + WireFormat::len(&self.cov_n_n) - + WireFormat::len(&self.cov_n_e) - + WireFormat::len(&self.cov_n_d) - + WireFormat::len(&self.cov_e_e) - + WireFormat::len(&self.cov_e_d) - + WireFormat::len(&self.cov_d_d) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgVelNedCov { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.n) + + WireFormat::len(&self.e) + + WireFormat::len(&self.d) + + WireFormat::len(&self.cov_n_n) + + WireFormat::len(&self.cov_n_e) + + WireFormat::len(&self.cov_n_d) + + WireFormat::len(&self.cov_e_e) + + WireFormat::len(&self.cov_e_d) + + WireFormat::len(&self.cov_d_d) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Type of reported TOW -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelNedCovTypeOfReportedTow { - /// Time of Measurement - TimeOfMeasurement = 0, + /// Type of reported TOW + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TypeOfReportedTow { + /// Time of Measurement + TimeOfMeasurement = 0, - /// Other - Other = 1, -} + /// Other + Other = 1, + } -impl std::fmt::Display for MsgVelNedCovTypeOfReportedTow { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelNedCovTypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), - MsgVelNedCovTypeOfReportedTow::Other => f.write_str("Other"), + impl std::fmt::Display for TypeOfReportedTow { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), + TypeOfReportedTow::Other => f.write_str("Other"), + } } } -} -/// INS Navigation Mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelNedCovInsNavigationMode { - /// None - None = 0, + /// INS Navigation Mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum InsNavigationMode { + /// None + None = 0, - /// INS used - InsUsed = 1, -} + /// INS used + InsUsed = 1, + } -impl std::fmt::Display for MsgVelNedCovInsNavigationMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelNedCovInsNavigationMode::None => f.write_str("None"), - MsgVelNedCovInsNavigationMode::InsUsed => f.write_str("INS used"), + impl std::fmt::Display for InsNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + InsNavigationMode::None => f.write_str("None"), + InsNavigationMode::InsUsed => f.write_str("INS used"), + } } } -} -/// Velocity mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelNedCovVelocityMode { - /// Invalid - Invalid = 0, + /// Velocity mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum VelocityMode { + /// Invalid + Invalid = 0, - /// Measured Doppler derived - MeasuredDopplerDerived = 1, + /// Measured Doppler derived + MeasuredDopplerDerived = 1, - /// Computed Doppler derived - ComputedDopplerDerived = 2, + /// Computed Doppler derived + ComputedDopplerDerived = 2, - /// Dead Reckoning - DeadReckoning = 3, -} + /// Dead Reckoning + DeadReckoning = 3, + } -impl std::fmt::Display for MsgVelNedCovVelocityMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelNedCovVelocityMode::Invalid => f.write_str("Invalid"), - MsgVelNedCovVelocityMode::MeasuredDopplerDerived => { - f.write_str("Measured Doppler derived") + impl std::fmt::Display for VelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + VelocityMode::Invalid => f.write_str("Invalid"), + VelocityMode::MeasuredDopplerDerived => f.write_str("Measured Doppler derived"), + VelocityMode::ComputedDopplerDerived => f.write_str("Computed Doppler derived"), + VelocityMode::DeadReckoning => f.write_str("Dead Reckoning"), } - MsgVelNedCovVelocityMode::ComputedDopplerDerived => { - f.write_str("Computed Doppler derived") - } - MsgVelNedCovVelocityMode::DeadReckoning => f.write_str("Dead Reckoning"), } } } -/// GNSS-only Velocity in NED -/// -/// This message reports the velocity in local North East Down (NED) -/// coordinates. The NED coordinate system is defined as the local WGS84 -/// 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). This -/// message is similar to the MSG_VEL_NED, but it includes the upper -/// triangular portion of the 3x3 covariance matrix. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 { - pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgVelNedCovGnssVelocityMode::Invalid), - 1 => Some(MsgVelNedCovGnssVelocityMode::MeasuredDopplerDerived), - 2 => Some(MsgVelNedCovGnssVelocityMode::ComputedDopplerDerived), - _ => None, +pub mod msg_vel_ned_cov_gnss { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// GNSS-only Velocity in NED + /// + /// This message reports the velocity in local North East Down (NED) + /// coordinates. The NED coordinate system is defined as the local WGS84 + /// 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). This + /// message is similar to the MSG_VEL_NED, but it includes the upper + /// triangular portion of the 3x3 covariance matrix. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(VelocityMode::Invalid), + 1 => Some(VelocityMode::MeasuredDopplerDerived), + 2 => Some(VelocityMode::ComputedDopplerDerived), + _ => None, + } } - } - pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelNedCovGnssVelocityMode) { - set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + } } -} -impl ConcreteMessage for MsgVelNedCovGnss { - const MESSAGE_TYPE: u16 = 562; - const MESSAGE_NAME: &'static str = "MSG_VEL_NED_COV_GNSS"; -} - -impl SbpMessage for MsgVelNedCovGnss { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + impl ConcreteMessage for MsgVelNedCovGnss { + const MESSAGE_TYPE: u16 = 562; + const MESSAGE_NAME: &'static str = "MSG_VEL_NED_COV_GNSS"; } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) - } -} -impl TryFrom for MsgVelNedCovGnss { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgVelNedCovGnss(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgVelNedCovGnss { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) } } -} -impl WireFormat for MsgVelNedCovGnss { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.n) - + WireFormat::len(&self.e) - + WireFormat::len(&self.d) - + WireFormat::len(&self.cov_n_n) - + WireFormat::len(&self.cov_n_e) - + WireFormat::len(&self.cov_n_d) - + WireFormat::len(&self.cov_e_e) - + WireFormat::len(&self.cov_e_d) - + WireFormat::len(&self.cov_d_d) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl TryFrom for MsgVelNedCovGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgVelNedCovGnss(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} - -/// Velocity mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelNedCovGnssVelocityMode { - /// Invalid - Invalid = 0, - - /// Measured Doppler derived - MeasuredDopplerDerived = 1, - - /// Computed Doppler derived - ComputedDopplerDerived = 2, -} -impl std::fmt::Display for MsgVelNedCovGnssVelocityMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelNedCovGnssVelocityMode::Invalid => f.write_str("Invalid"), - MsgVelNedCovGnssVelocityMode::MeasuredDopplerDerived => { - f.write_str("Measured Doppler derived") - } - MsgVelNedCovGnssVelocityMode::ComputedDopplerDerived => { - f.write_str("Computed Doppler derived") + impl WireFormat for MsgVelNedCovGnss { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.n) + + WireFormat::len(&self.e) + + WireFormat::len(&self.d) + + WireFormat::len(&self.cov_n_n) + + WireFormat::len(&self.cov_n_e) + + WireFormat::len(&self.cov_n_d) + + WireFormat::len(&self.cov_e_e) + + WireFormat::len(&self.cov_e_d) + + WireFormat::len(&self.cov_d_d) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), } } } -} -/// Velocity in NED -/// -/// This message reports the velocity in local North East Down (NED) -/// coordinates. The NED coordinate system is defined as the local WGS84 -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} + /// Velocity mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum VelocityMode { + /// Invalid + Invalid = 0, -impl ConcreteMessage for MsgVelNedDepA { - const MESSAGE_TYPE: u16 = 517; - const MESSAGE_NAME: &'static str = "MSG_VEL_NED_DEP_A"; -} + /// Measured Doppler derived + MeasuredDopplerDerived = 1, -impl SbpMessage for MsgVelNedDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + /// Computed Doppler derived + ComputedDopplerDerived = 2, } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + + impl std::fmt::Display for VelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + VelocityMode::Invalid => f.write_str("Invalid"), + VelocityMode::MeasuredDopplerDerived => f.write_str("Measured Doppler derived"), + VelocityMode::ComputedDopplerDerived => f.write_str("Computed Doppler derived"), + } + } } } -impl TryFrom for MsgVelNedDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgVelNedDepA(m) => Ok(m), - _ => Err(TryFromSbpError), +pub mod msg_vel_ned_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Velocity in NED + /// + /// This message reports the velocity in local North East Down (NED) + /// coordinates. The NED coordinate system is defined as the local WGS84 + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 ConcreteMessage for MsgVelNedDepA { + const MESSAGE_TYPE: u16 = 517; + const MESSAGE_NAME: &'static str = "MSG_VEL_NED_DEP_A"; + } + + impl SbpMessage for MsgVelNedDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } + } + + impl TryFrom for MsgVelNedDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgVelNedDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgVelNedDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.n) - + WireFormat::len(&self.e) - + WireFormat::len(&self.d) - + WireFormat::len(&self.h_accuracy) - + WireFormat::len(&self.v_accuracy) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgVelNedDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.n) + + WireFormat::len(&self.e) + + WireFormat::len(&self.d) + + WireFormat::len(&self.h_accuracy) + + WireFormat::len(&self.v_accuracy) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// GNSS-only Velocity in NED -/// -/// This message reports the velocity in local North East Down (NED) -/// coordinates. The NED coordinate system is defined as the local WGS84 -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod msg_vel_ned_gnss { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// GNSS-only Velocity in NED + /// + /// This message reports the velocity in local North East Down (NED) + /// coordinates. The NED coordinate system is defined as the local WGS84 + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn velocity_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(VelocityMode::Invalid), + 1 => Some(VelocityMode::MeasuredDopplerDerived), + 2 => Some(VelocityMode::ComputedDopplerDerived), + _ => None, + } + } -impl MsgVelNedGnss { - pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgVelNedGnssVelocityMode::Invalid), - 1 => Some(MsgVelNedGnssVelocityMode::MeasuredDopplerDerived), - 2 => Some(MsgVelNedGnssVelocityMode::ComputedDopplerDerived), - _ => None, + pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { + set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); } } - pub fn set_velocity_mode(&mut self, velocity_mode: MsgVelNedGnssVelocityMode) { - set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgVelNedGnss { + const MESSAGE_TYPE: u16 = 558; + const MESSAGE_NAME: &'static str = "MSG_VEL_NED_GNSS"; } -} - -impl ConcreteMessage for MsgVelNedGnss { - const MESSAGE_TYPE: u16 = 558; - const MESSAGE_NAME: &'static str = "MSG_VEL_NED_GNSS"; -} -impl SbpMessage for MsgVelNedGnss { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgVelNedGnss { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgVelNedGnss { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgVelNedGnss(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgVelNedGnss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgVelNedGnss(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgVelNedGnss { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.n) - + WireFormat::len(&self.e) - + WireFormat::len(&self.d) - + WireFormat::len(&self.h_accuracy) - + WireFormat::len(&self.v_accuracy) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgVelNedGnss { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.n) + + WireFormat::len(&self.e) + + WireFormat::len(&self.d) + + WireFormat::len(&self.h_accuracy) + + WireFormat::len(&self.v_accuracy) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Velocity mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgVelNedGnssVelocityMode { - /// Invalid - Invalid = 0, + /// Velocity mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum VelocityMode { + /// Invalid + Invalid = 0, - /// Measured Doppler derived - MeasuredDopplerDerived = 1, + /// Measured Doppler derived + MeasuredDopplerDerived = 1, - /// Computed Doppler derived - ComputedDopplerDerived = 2, -} + /// Computed Doppler derived + ComputedDopplerDerived = 2, + } -impl std::fmt::Display for MsgVelNedGnssVelocityMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgVelNedGnssVelocityMode::Invalid => f.write_str("Invalid"), - MsgVelNedGnssVelocityMode::MeasuredDopplerDerived => { - f.write_str("Measured Doppler derived") - } - MsgVelNedGnssVelocityMode::ComputedDopplerDerived => { - f.write_str("Computed Doppler derived") + impl std::fmt::Display for VelocityMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + VelocityMode::Invalid => f.write_str("Invalid"), + VelocityMode::MeasuredDopplerDerived => f.write_str("Measured Doppler derived"), + VelocityMode::ComputedDopplerDerived => f.write_str("Computed Doppler derived"), } } } diff --git a/rust/sbp/src/messages/ndb.rs b/rust/sbp/src/messages/ndb.rs index 1d348dd65c..962a265fe2 100644 --- a/rust/sbp/src/messages/ndb.rs +++ b/rust/sbp/src/messages/ndb.rs @@ -13,343 +13,348 @@ // with generate.py. Please do not hand edit! //****************************************************************************/ //! Messages for logging NDB events. +pub use msg_ndb_event::MsgNdbEvent; + +pub mod msg_ndb_event { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgNdbEvent { + /// 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, + } -use super::gnss::*; - -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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgNdbEvent { - /// 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 { + pub fn event_type(&self) -> Option { + match get_bit_range!(self.event, u8, u8, 1, 0) { + 0 => Some(EventType::UNKNOWN), + 1 => Some(EventType::STORE), + 2 => Some(EventType::FETCH), + 3 => Some(EventType::ERASE), + _ => None, + } + } -impl MsgNdbEvent { - pub fn event_type(&self) -> Option { - match get_bit_range!(self.event, u8, u8, 1, 0) { - 0 => Some(MsgNdbEventEventType::UNKNOWN), - 1 => Some(MsgNdbEventEventType::STORE), - 2 => Some(MsgNdbEventEventType::FETCH), - 3 => Some(MsgNdbEventEventType::ERASE), - _ => None, + pub fn set_event_type(&mut self, event_type: EventType) { + set_bit_range!(&mut self.event, event_type, u8, u8, 1, 0); } - } - pub fn set_event_type(&mut self, event_type: MsgNdbEventEventType) { - set_bit_range!(&mut self.event, event_type, u8, u8, 1, 0); - } + pub fn event_object_type(&self) -> Option { + match get_bit_range!(self.object_type, u8, u8, 2, 0) { + 0 => Some(EventObjectType::UNKNOWN), + 1 => Some(EventObjectType::EPHEMERIS), + 2 => Some(EventObjectType::ALMANAC), + 3 => Some(EventObjectType::AlmanacWn), + 4 => Some(EventObjectType::IoNO), + 5 => Some(EventObjectType::L2CCap), + 6 => Some(EventObjectType::LGF), + _ => None, + } + } - pub fn event_object_type(&self) -> Option { - match get_bit_range!(self.object_type, u8, u8, 2, 0) { - 0 => Some(MsgNdbEventEventObjectType::UNKNOWN), - 1 => Some(MsgNdbEventEventObjectType::EPHEMERIS), - 2 => Some(MsgNdbEventEventObjectType::ALMANAC), - 3 => Some(MsgNdbEventEventObjectType::AlmanacWn), - 4 => Some(MsgNdbEventEventObjectType::IoNO), - 5 => Some(MsgNdbEventEventObjectType::L2CCap), - 6 => Some(MsgNdbEventEventObjectType::LGF), - _ => None, + pub fn set_event_object_type(&mut self, event_object_type: EventObjectType) { + set_bit_range!(&mut self.object_type, event_object_type, u8, u8, 2, 0); } - } - pub fn set_event_object_type(&mut self, event_object_type: MsgNdbEventEventObjectType) { - set_bit_range!(&mut self.object_type, event_object_type, u8, u8, 2, 0); - } + pub fn event_result(&self) -> Option { + match get_bit_range!(self.result, u8, u8, 3, 0) { + 0 => Some(EventResult::NdbErrNone), + 1 => Some(EventResult::NdbErrMissingIe), + 2 => Some(EventResult::NdbErrUnsupported), + 3 => Some(EventResult::NdbErrFileIo), + 4 => Some(EventResult::NdbErrInitDone), + 5 => Some(EventResult::NdbErrBadParam), + 6 => Some(EventResult::NdbErrUnreliableData), + 7 => Some(EventResult::NdbErrAlgorithmError), + 8 => Some(EventResult::NdbErrNoData), + 9 => Some(EventResult::NdbErrNoChange), + 10 => Some(EventResult::NdbErrOlderData), + _ => None, + } + } - pub fn event_result(&self) -> Option { - match get_bit_range!(self.result, u8, u8, 3, 0) { - 0 => Some(MsgNdbEventEventResult::NdbErrNone), - 1 => Some(MsgNdbEventEventResult::NdbErrMissingIe), - 2 => Some(MsgNdbEventEventResult::NdbErrUnsupported), - 3 => Some(MsgNdbEventEventResult::NdbErrFileIo), - 4 => Some(MsgNdbEventEventResult::NdbErrInitDone), - 5 => Some(MsgNdbEventEventResult::NdbErrBadParam), - 6 => Some(MsgNdbEventEventResult::NdbErrUnreliableData), - 7 => Some(MsgNdbEventEventResult::NdbErrAlgorithmError), - 8 => Some(MsgNdbEventEventResult::NdbErrNoData), - 9 => Some(MsgNdbEventEventResult::NdbErrNoChange), - 10 => Some(MsgNdbEventEventResult::NdbErrOlderData), - _ => None, + pub fn set_event_result(&mut self, event_result: EventResult) { + set_bit_range!(&mut self.result, event_result, u8, u8, 3, 0); } - } - pub fn set_event_result(&mut self, event_result: MsgNdbEventEventResult) { - set_bit_range!(&mut self.result, event_result, u8, u8, 3, 0); - } + pub fn data_source(&self) -> Option { + match get_bit_range!(self.data_source, u8, u8, 1, 0) { + 0 => Some(DataSource::NdbDsUndefined), + 1 => Some(DataSource::NdbDsInit), + 2 => Some(DataSource::NdbDsReceiver), + 3 => Some(DataSource::NdbDsSbp), + _ => None, + } + } - pub fn data_source(&self) -> Option { - match get_bit_range!(self.data_source, u8, u8, 1, 0) { - 0 => Some(MsgNdbEventDataSource::NdbDsUndefined), - 1 => Some(MsgNdbEventDataSource::NdbDsInit), - 2 => Some(MsgNdbEventDataSource::NdbDsReceiver), - 3 => Some(MsgNdbEventDataSource::NdbDsSbp), - _ => None, + pub fn set_data_source(&mut self, data_source: DataSource) { + set_bit_range!(&mut self.data_source, data_source, u8, u8, 1, 0); } } - pub fn set_data_source(&mut self, data_source: MsgNdbEventDataSource) { - set_bit_range!(&mut self.data_source, data_source, u8, u8, 1, 0); + impl ConcreteMessage for MsgNdbEvent { + const MESSAGE_TYPE: u16 = 1024; + const MESSAGE_NAME: &'static str = "MSG_NDB_EVENT"; } -} - -impl ConcreteMessage for MsgNdbEvent { - const MESSAGE_TYPE: u16 = 1024; - const MESSAGE_NAME: &'static str = "MSG_NDB_EVENT"; -} -impl SbpMessage for MsgNdbEvent { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgNdbEvent { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgNdbEvent { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgNdbEvent(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgNdbEvent { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgNdbEvent(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgNdbEvent { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.recv_time) - + WireFormat::len(&self.event) - + WireFormat::len(&self.object_type) - + WireFormat::len(&self.result) - + WireFormat::len(&self.data_source) - + WireFormat::len(&self.object_sid) - + WireFormat::len(&self.src_sid) - + WireFormat::len(&self.original_sender) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgNdbEvent { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.recv_time) + + WireFormat::len(&self.event) + + WireFormat::len(&self.object_type) + + WireFormat::len(&self.result) + + WireFormat::len(&self.data_source) + + WireFormat::len(&self.object_sid) + + WireFormat::len(&self.src_sid) + + WireFormat::len(&self.original_sender) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Event type. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgNdbEventEventType { - /// UNKNOWN - UNKNOWN = 0, + /// Event type. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum EventType { + /// UNKNOWN + UNKNOWN = 0, - /// STORE - STORE = 1, + /// STORE + STORE = 1, - /// FETCH - FETCH = 2, + /// FETCH + FETCH = 2, - /// ERASE - ERASE = 3, -} + /// ERASE + ERASE = 3, + } -impl std::fmt::Display for MsgNdbEventEventType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgNdbEventEventType::UNKNOWN => f.write_str("UNKNOWN"), - MsgNdbEventEventType::STORE => f.write_str("STORE"), - MsgNdbEventEventType::FETCH => f.write_str("FETCH"), - MsgNdbEventEventType::ERASE => f.write_str("ERASE"), + impl std::fmt::Display for EventType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + EventType::UNKNOWN => f.write_str("UNKNOWN"), + EventType::STORE => f.write_str("STORE"), + EventType::FETCH => f.write_str("FETCH"), + EventType::ERASE => f.write_str("ERASE"), + } } } -} -/// Event object type. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgNdbEventEventObjectType { - /// UNKNOWN - UNKNOWN = 0, + /// Event object type. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum EventObjectType { + /// UNKNOWN + UNKNOWN = 0, - /// EPHEMERIS - EPHEMERIS = 1, + /// EPHEMERIS + EPHEMERIS = 1, - /// ALMANAC - ALMANAC = 2, + /// ALMANAC + ALMANAC = 2, - /// ALMANAC_WN - AlmanacWn = 3, + /// ALMANAC_WN + AlmanacWn = 3, - /// IONO - IoNO = 4, + /// IONO + IoNO = 4, - /// L2C_CAP - L2CCap = 5, + /// L2C_CAP + L2CCap = 5, - /// LGF - LGF = 6, -} + /// LGF + LGF = 6, + } -impl std::fmt::Display for MsgNdbEventEventObjectType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgNdbEventEventObjectType::UNKNOWN => f.write_str("UNKNOWN"), - MsgNdbEventEventObjectType::EPHEMERIS => f.write_str("EPHEMERIS"), - MsgNdbEventEventObjectType::ALMANAC => f.write_str("ALMANAC"), - MsgNdbEventEventObjectType::AlmanacWn => f.write_str("ALMANAC_WN"), - MsgNdbEventEventObjectType::IoNO => f.write_str("IONO"), - MsgNdbEventEventObjectType::L2CCap => f.write_str("L2C_CAP"), - MsgNdbEventEventObjectType::LGF => f.write_str("LGF"), + impl std::fmt::Display for EventObjectType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + EventObjectType::UNKNOWN => f.write_str("UNKNOWN"), + EventObjectType::EPHEMERIS => f.write_str("EPHEMERIS"), + EventObjectType::ALMANAC => f.write_str("ALMANAC"), + EventObjectType::AlmanacWn => f.write_str("ALMANAC_WN"), + EventObjectType::IoNO => f.write_str("IONO"), + EventObjectType::L2CCap => f.write_str("L2C_CAP"), + EventObjectType::LGF => f.write_str("LGF"), + } } } -} -/// Event result. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgNdbEventEventResult { - /// NDB_ERR_NONE - NdbErrNone = 0, + /// Event result. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum EventResult { + /// NDB_ERR_NONE + NdbErrNone = 0, - /// NDB_ERR_MISSING_IE - NdbErrMissingIe = 1, + /// NDB_ERR_MISSING_IE + NdbErrMissingIe = 1, - /// NDB_ERR_UNSUPPORTED - NdbErrUnsupported = 2, + /// NDB_ERR_UNSUPPORTED + NdbErrUnsupported = 2, - /// NDB_ERR_FILE_IO - NdbErrFileIo = 3, + /// NDB_ERR_FILE_IO + NdbErrFileIo = 3, - /// NDB_ERR_INIT_DONE - NdbErrInitDone = 4, + /// NDB_ERR_INIT_DONE + NdbErrInitDone = 4, - /// NDB_ERR_BAD_PARAM - NdbErrBadParam = 5, + /// NDB_ERR_BAD_PARAM + NdbErrBadParam = 5, - /// NDB_ERR_UNRELIABLE_DATA - NdbErrUnreliableData = 6, + /// NDB_ERR_UNRELIABLE_DATA + NdbErrUnreliableData = 6, - /// NDB_ERR_ALGORITHM_ERROR - NdbErrAlgorithmError = 7, + /// NDB_ERR_ALGORITHM_ERROR + NdbErrAlgorithmError = 7, - /// NDB_ERR_NO_DATA - NdbErrNoData = 8, + /// NDB_ERR_NO_DATA + NdbErrNoData = 8, - /// NDB_ERR_NO_CHANGE - NdbErrNoChange = 9, + /// NDB_ERR_NO_CHANGE + NdbErrNoChange = 9, - /// NDB_ERR_OLDER_DATA - NdbErrOlderData = 10, -} + /// NDB_ERR_OLDER_DATA + NdbErrOlderData = 10, + } -impl std::fmt::Display for MsgNdbEventEventResult { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgNdbEventEventResult::NdbErrNone => f.write_str("NDB_ERR_NONE"), - MsgNdbEventEventResult::NdbErrMissingIe => f.write_str("NDB_ERR_MISSING_IE"), - MsgNdbEventEventResult::NdbErrUnsupported => f.write_str("NDB_ERR_UNSUPPORTED"), - MsgNdbEventEventResult::NdbErrFileIo => f.write_str("NDB_ERR_FILE_IO"), - MsgNdbEventEventResult::NdbErrInitDone => f.write_str("NDB_ERR_INIT_DONE"), - MsgNdbEventEventResult::NdbErrBadParam => f.write_str("NDB_ERR_BAD_PARAM"), - MsgNdbEventEventResult::NdbErrUnreliableData => f.write_str("NDB_ERR_UNRELIABLE_DATA"), - MsgNdbEventEventResult::NdbErrAlgorithmError => f.write_str("NDB_ERR_ALGORITHM_ERROR"), - MsgNdbEventEventResult::NdbErrNoData => f.write_str("NDB_ERR_NO_DATA"), - MsgNdbEventEventResult::NdbErrNoChange => f.write_str("NDB_ERR_NO_CHANGE"), - MsgNdbEventEventResult::NdbErrOlderData => f.write_str("NDB_ERR_OLDER_DATA"), + impl std::fmt::Display for EventResult { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + EventResult::NdbErrNone => f.write_str("NDB_ERR_NONE"), + EventResult::NdbErrMissingIe => f.write_str("NDB_ERR_MISSING_IE"), + EventResult::NdbErrUnsupported => f.write_str("NDB_ERR_UNSUPPORTED"), + EventResult::NdbErrFileIo => f.write_str("NDB_ERR_FILE_IO"), + EventResult::NdbErrInitDone => f.write_str("NDB_ERR_INIT_DONE"), + EventResult::NdbErrBadParam => f.write_str("NDB_ERR_BAD_PARAM"), + EventResult::NdbErrUnreliableData => f.write_str("NDB_ERR_UNRELIABLE_DATA"), + EventResult::NdbErrAlgorithmError => f.write_str("NDB_ERR_ALGORITHM_ERROR"), + EventResult::NdbErrNoData => f.write_str("NDB_ERR_NO_DATA"), + EventResult::NdbErrNoChange => f.write_str("NDB_ERR_NO_CHANGE"), + EventResult::NdbErrOlderData => f.write_str("NDB_ERR_OLDER_DATA"), + } } } -} -/// Data source. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgNdbEventDataSource { - /// NDB_DS_UNDEFINED - NdbDsUndefined = 0, + /// Data source. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum DataSource { + /// NDB_DS_UNDEFINED + NdbDsUndefined = 0, - /// NDB_DS_INIT - NdbDsInit = 1, + /// NDB_DS_INIT + NdbDsInit = 1, - /// NDB_DS_RECEIVER - NdbDsReceiver = 2, + /// NDB_DS_RECEIVER + NdbDsReceiver = 2, - /// NDB_DS_SBP - NdbDsSbp = 3, -} + /// NDB_DS_SBP + NdbDsSbp = 3, + } -impl std::fmt::Display for MsgNdbEventDataSource { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgNdbEventDataSource::NdbDsUndefined => f.write_str("NDB_DS_UNDEFINED"), - MsgNdbEventDataSource::NdbDsInit => f.write_str("NDB_DS_INIT"), - MsgNdbEventDataSource::NdbDsReceiver => f.write_str("NDB_DS_RECEIVER"), - MsgNdbEventDataSource::NdbDsSbp => f.write_str("NDB_DS_SBP"), + impl std::fmt::Display for DataSource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + DataSource::NdbDsUndefined => f.write_str("NDB_DS_UNDEFINED"), + DataSource::NdbDsInit => f.write_str("NDB_DS_INIT"), + DataSource::NdbDsReceiver => f.write_str("NDB_DS_RECEIVER"), + DataSource::NdbDsSbp => f.write_str("NDB_DS_SBP"), + } } } } diff --git a/rust/sbp/src/messages/observation.rs b/rust/sbp/src/messages/observation.rs index 42313a8fab..d86c4fcf24 100644 --- a/rust/sbp/src/messages/observation.rs +++ b/rust/sbp/src/messages/observation.rs @@ -15,6602 +15,7058 @@ //! Satellite observation messages from the device. The SBP sender ID of 0 //! indicates remote observations from a GNSS base station, correction //! network, or Skylark, Swift's cloud GNSS correction product. - -use super::gnss::*; - -use super::lib::*; - -/// Common fields for every almanac message -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct AlmanacCommonContent { - /// GNSS signal identifier - #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] - pub sid: GnssSignal, - /// Reference time of almanac - #[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 - /// Table 20-VII: NAV Data Health Indications. - /// - bits 0-4: Signal health status. See IS-GPS-200H - /// Table 20-VIII. Codes for Health of SV Signal - /// Components. - /// Satellite health status for GLO (see GLO ICD 5.1 table 5.1 for details): - /// - bit 0: C(n), "unhealthy" flag that is transmitted within - /// non-immediate data and indicates overall constellation status - /// at the moment of almanac uploading. - /// '0' indicates malfunction of n-satellite. - /// '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 WireFormat for AlmanacCommonContent { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sid) - + WireFormat::len(&self.toa) - + WireFormat::len(&self.ura) - + WireFormat::len(&self.fit_interval) - + WireFormat::len(&self.valid) - + WireFormat::len(&self.health_bits) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), +pub use almanac_common_content::AlmanacCommonContent; +pub use almanac_common_content_dep::AlmanacCommonContentDep; +pub use carrier_phase_dep_a::CarrierPhaseDepA; +pub use doppler::Doppler; +pub use ephemeris_common_content::EphemerisCommonContent; +pub use ephemeris_common_content_dep_a::EphemerisCommonContentDepA; +pub use ephemeris_common_content_dep_b::EphemerisCommonContentDepB; +pub use gnss_capb::GnssCapb; +pub use msg_almanac_glo::MsgAlmanacGlo; +pub use msg_almanac_glo_dep::MsgAlmanacGloDep; +pub use msg_almanac_gps::MsgAlmanacGps; +pub use msg_almanac_gps_dep::MsgAlmanacGpsDep; +pub use msg_base_pos_ecef::MsgBasePosEcef; +pub use msg_base_pos_llh::MsgBasePosLlh; +pub use msg_ephemeris_bds::MsgEphemerisBds; +pub use msg_ephemeris_dep_a::MsgEphemerisDepA; +pub use msg_ephemeris_dep_b::MsgEphemerisDepB; +pub use msg_ephemeris_dep_c::MsgEphemerisDepC; +pub use msg_ephemeris_dep_d::MsgEphemerisDepD; +pub use msg_ephemeris_gal::MsgEphemerisGal; +pub use msg_ephemeris_gal_dep_a::MsgEphemerisGalDepA; +pub use msg_ephemeris_glo::MsgEphemerisGlo; +pub use msg_ephemeris_glo_dep_a::MsgEphemerisGloDepA; +pub use msg_ephemeris_glo_dep_b::MsgEphemerisGloDepB; +pub use msg_ephemeris_glo_dep_c::MsgEphemerisGloDepC; +pub use msg_ephemeris_glo_dep_d::MsgEphemerisGloDepD; +pub use msg_ephemeris_gps::MsgEphemerisGps; +pub use msg_ephemeris_gps_dep_e::MsgEphemerisGpsDepE; +pub use msg_ephemeris_gps_dep_f::MsgEphemerisGpsDepF; +pub use msg_ephemeris_qzss::MsgEphemerisQzss; +pub use msg_ephemeris_sbas::MsgEphemerisSbas; +pub use msg_ephemeris_sbas_dep_a::MsgEphemerisSbasDepA; +pub use msg_ephemeris_sbas_dep_b::MsgEphemerisSbasDepB; +pub use msg_glo_biases::MsgGloBiases; +pub use msg_gnss_capb::MsgGnssCapb; +pub use msg_group_delay::MsgGroupDelay; +pub use msg_group_delay_dep_a::MsgGroupDelayDepA; +pub use msg_group_delay_dep_b::MsgGroupDelayDepB; +pub use msg_iono::MsgIono; +pub use msg_obs::MsgObs; +pub use msg_obs_dep_a::MsgObsDepA; +pub use msg_obs_dep_b::MsgObsDepB; +pub use msg_obs_dep_c::MsgObsDepC; +pub use msg_osr::MsgOsr; +pub use msg_sv_az_el::MsgSvAzEl; +pub use msg_sv_configuration_gps_dep::MsgSvConfigurationGpsDep; +pub use observation_header::ObservationHeader; +pub use observation_header_dep::ObservationHeaderDep; +pub use packed_obs_content::PackedObsContent; +pub use packed_obs_content_dep_a::PackedObsContentDepA; +pub use packed_obs_content_dep_b::PackedObsContentDepB; +pub use packed_obs_content_dep_c::PackedObsContentDepC; +pub use packed_osr_content::PackedOsrContent; +pub use sv_az_el::SvAzEl; + +pub mod almanac_common_content { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + /// Common fields for every almanac message + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct AlmanacCommonContent { + /// GNSS signal identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] + pub sid: GnssSignal, + /// Reference time of almanac + #[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 + /// Table 20-VII: NAV Data Health Indications. + /// - bits 0-4: Signal health status. See IS-GPS-200H + /// Table 20-VIII. Codes for Health of SV Signal + /// Components. + /// Satellite health status for GLO (see GLO ICD 5.1 table 5.1 for details): + /// - bit 0: C(n), "unhealthy" flag that is transmitted within + /// non-immediate data and indicates overall constellation status + /// at the moment of almanac uploading. + /// '0' indicates malfunction of n-satellite. + /// '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 WireFormat for AlmanacCommonContent { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sid) + + WireFormat::len(&self.toa) + + WireFormat::len(&self.ura) + + WireFormat::len(&self.fit_interval) + + WireFormat::len(&self.valid) + + WireFormat::len(&self.health_bits) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Common fields for every almanac message -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct AlmanacCommonContentDep { - /// GNSS signal identifier - #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] - pub sid: GnssSignalDep, - /// Reference time of almanac - #[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 - /// Table 20-VII: NAV Data Health Indications. - /// - bits 0-4: Signal health status. See IS-GPS-200H - /// Table 20-VIII. Codes for Health of SV Signal - /// Components. - /// Satellite health status for GLO (see GLO ICD 5.1 table 5.1 for details): - /// - bit 0: C(n), "unhealthy" flag that is transmitted within - /// non-immediate data and indicates overall constellation status - /// at the moment of almanac uploading. - /// '0' indicates malfunction of n-satellite. - /// '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 WireFormat for AlmanacCommonContentDep { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sid) - + WireFormat::len(&self.toa) - + WireFormat::len(&self.ura) - + WireFormat::len(&self.fit_interval) - + WireFormat::len(&self.valid) - + WireFormat::len(&self.health_bits) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), +pub mod almanac_common_content_dep { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + /// Common fields for every almanac message + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct AlmanacCommonContentDep { + /// GNSS signal identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] + pub sid: GnssSignalDep, + /// Reference time of almanac + #[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 + /// Table 20-VII: NAV Data Health Indications. + /// - bits 0-4: Signal health status. See IS-GPS-200H + /// Table 20-VIII. Codes for Health of SV Signal + /// Components. + /// Satellite health status for GLO (see GLO ICD 5.1 table 5.1 for details): + /// - bit 0: C(n), "unhealthy" flag that is transmitted within + /// non-immediate data and indicates overall constellation status + /// at the moment of almanac uploading. + /// '0' indicates malfunction of n-satellite. + /// '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 WireFormat for AlmanacCommonContentDep { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sid) + + WireFormat::len(&self.toa) + + WireFormat::len(&self.ura) + + WireFormat::len(&self.fit_interval) + + WireFormat::len(&self.valid) + + WireFormat::len(&self.health_bits) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// GPS carrier phase measurement -/// -/// Carrier phase measurement in cycles represented as a 40-bit fixed point -/// number with Q32.8 layout, i.e. 32-bits of whole cycles and 8-bits of -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 WireFormat for CarrierPhaseDepA { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.i) + WireFormat::len(&self.f) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.i, buf); - WireFormat::write(&self.f, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - CarrierPhaseDepA { - i: WireFormat::parse_unchecked(buf), - f: WireFormat::parse_unchecked(buf), +pub mod carrier_phase_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// GPS carrier phase measurement + /// + /// Carrier phase measurement in cycles represented as a 40-bit fixed point + /// number with Q32.8 layout, i.e. 32-bits of whole cycles and 8-bits of + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 WireFormat for CarrierPhaseDepA { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.i) + WireFormat::len(&self.f) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.i, buf); + WireFormat::write(&self.f, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + CarrierPhaseDepA { + i: WireFormat::parse_unchecked(buf), + f: WireFormat::parse_unchecked(buf), + } } } } -/// GNSS doppler measurement -/// -/// Doppler measurement in Hz represented as a 24-bit fixed point number with -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod doppler { + #![allow(unused_imports)] -impl WireFormat for Doppler { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.i) + WireFormat::len(&self.f) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.i, buf); - WireFormat::write(&self.f, buf); + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// GNSS doppler measurement + /// + /// Doppler measurement in Hz represented as a 24-bit fixed point number with + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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, } - fn parse_unchecked(buf: &mut B) -> Self { - Doppler { - i: WireFormat::parse_unchecked(buf), - f: WireFormat::parse_unchecked(buf), + + impl WireFormat for Doppler { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.i) + WireFormat::len(&self.f) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.i, buf); + WireFormat::write(&self.f, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + Doppler { + i: WireFormat::parse_unchecked(buf), + f: WireFormat::parse_unchecked(buf), + } } } } -/// Common fields for every ephemeris message -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct EphemerisCommonContent { - /// GNSS signal identifier (16 bit) - #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] - pub sid: GnssSignal, - /// Time of Ephemerides - #[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 WireFormat for EphemerisCommonContent { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sid) - + WireFormat::len(&self.toe) - + WireFormat::len(&self.ura) - + WireFormat::len(&self.fit_interval) - + WireFormat::len(&self.valid) - + WireFormat::len(&self.health_bits) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), +pub mod ephemeris_common_content { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + /// Common fields for every ephemeris message + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct EphemerisCommonContent { + /// GNSS signal identifier (16 bit) + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] + pub sid: GnssSignal, + /// Time of Ephemerides + #[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 WireFormat for EphemerisCommonContent { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sid) + + WireFormat::len(&self.toe) + + WireFormat::len(&self.ura) + + WireFormat::len(&self.fit_interval) + + WireFormat::len(&self.valid) + + WireFormat::len(&self.health_bits) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Common fields for every ephemeris message -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct EphemerisCommonContentDepA { - /// GNSS signal identifier - #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] - pub sid: GnssSignalDep, - /// Time of Ephemerides - #[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 WireFormat for EphemerisCommonContentDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sid) - + WireFormat::len(&self.toe) - + WireFormat::len(&self.ura) - + WireFormat::len(&self.fit_interval) - + WireFormat::len(&self.valid) - + WireFormat::len(&self.health_bits) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), +pub mod ephemeris_common_content_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + /// Common fields for every ephemeris message + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct EphemerisCommonContentDepA { + /// GNSS signal identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] + pub sid: GnssSignalDep, + /// Time of Ephemerides + #[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 WireFormat for EphemerisCommonContentDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sid) + + WireFormat::len(&self.toe) + + WireFormat::len(&self.ura) + + WireFormat::len(&self.fit_interval) + + WireFormat::len(&self.valid) + + WireFormat::len(&self.health_bits) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Common fields for every ephemeris message -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct EphemerisCommonContentDepB { - /// GNSS signal identifier (16 bit) - #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] - pub sid: GnssSignal, - /// Time of Ephemerides - #[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 WireFormat for EphemerisCommonContentDepB { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sid) - + WireFormat::len(&self.toe) - + WireFormat::len(&self.ura) - + WireFormat::len(&self.fit_interval) - + WireFormat::len(&self.valid) - + WireFormat::len(&self.health_bits) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), +pub mod ephemeris_common_content_dep_b { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + /// Common fields for every ephemeris message + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct EphemerisCommonContentDepB { + /// GNSS signal identifier (16 bit) + #[cfg_attr(feature = "serde", serde(rename(serialize = "sid")))] + pub sid: GnssSignal, + /// Time of Ephemerides + #[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 WireFormat for EphemerisCommonContentDepB { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sid) + + WireFormat::len(&self.toe) + + WireFormat::len(&self.ura) + + WireFormat::len(&self.fit_interval) + + WireFormat::len(&self.valid) + + WireFormat::len(&self.health_bits) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// GNSS capabilities masks -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, - /// ) - #[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, - /// ) - #[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, -} +pub mod gnss_capb { + #![allow(unused_imports)] -impl WireFormat for GnssCapb { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.gps_active) - + WireFormat::len(&self.gps_l2c) - + WireFormat::len(&self.gps_l5) - + WireFormat::len(&self.glo_active) - + WireFormat::len(&self.glo_l2of) - + WireFormat::len(&self.glo_l3) - + WireFormat::len(&self.sbas_active) - + WireFormat::len(&self.sbas_l5) - + WireFormat::len(&self.bds_active) - + WireFormat::len(&self.bds_d2nav) - + WireFormat::len(&self.bds_b2) - + WireFormat::len(&self.bds_b2a) - + WireFormat::len(&self.qzss_active) - + WireFormat::len(&self.gal_active) - + WireFormat::len(&self.gal_e5) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + /// GNSS capabilities masks + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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, + /// ) + #[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, + /// ) + #[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 WireFormat for GnssCapb { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.gps_active) + + WireFormat::len(&self.gps_l2c) + + WireFormat::len(&self.gps_l5) + + WireFormat::len(&self.glo_active) + + WireFormat::len(&self.glo_l2of) + + WireFormat::len(&self.glo_l3) + + WireFormat::len(&self.sbas_active) + + WireFormat::len(&self.sbas_l5) + + WireFormat::len(&self.bds_active) + + WireFormat::len(&self.bds_d2nav) + + WireFormat::len(&self.bds_b2) + + WireFormat::len(&self.bds_b2a) + + WireFormat::len(&self.qzss_active) + + WireFormat::len(&self.gal_active) + + WireFormat::len(&self.gal_e5) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Satellite broadcast ephemeris for GLO -/// -/// The almanac message returns a set of satellite orbit parameters. Almanac -/// data is not very precise and is considered valid for up to several months. -/// Please see the GLO ICD 5.1 "Chapter 4.5 Non-immediate information and -/// almanac" for details. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgAlmanacGlo { - /// 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 ConcreteMessage for MsgAlmanacGlo { - const MESSAGE_TYPE: u16 = 115; - const MESSAGE_NAME: &'static str = "MSG_ALMANAC_GLO"; -} - -impl SbpMessage for MsgAlmanacGlo { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_almanac_glo { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Satellite broadcast ephemeris for GLO + /// + /// The almanac message returns a set of satellite orbit parameters. Almanac + /// data is not very precise and is considered valid for up to several months. + /// Please see the GLO ICD 5.1 "Chapter 4.5 Non-immediate information and + /// almanac" for details. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgAlmanacGlo { + /// 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 ConcreteMessage for MsgAlmanacGlo { + const MESSAGE_TYPE: u16 = 115; + const MESSAGE_NAME: &'static str = "MSG_ALMANAC_GLO"; + } + + impl SbpMessage for MsgAlmanacGlo { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgAlmanacGlo { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgAlmanacGlo(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgAlmanacGlo { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgAlmanacGlo(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgAlmanacGlo { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.common) - + WireFormat::len(&self.lambda_na) - + WireFormat::len(&self.t_lambda_na) - + WireFormat::len(&self.i) - + WireFormat::len(&self.t) - + WireFormat::len(&self.t_dot) - + WireFormat::len(&self.epsilon) - + WireFormat::len(&self.omega) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgAlmanacGlo { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.common) + + WireFormat::len(&self.lambda_na) + + WireFormat::len(&self.t_lambda_na) + + WireFormat::len(&self.i) + + WireFormat::len(&self.t) + + WireFormat::len(&self.t_dot) + + WireFormat::len(&self.epsilon) + + WireFormat::len(&self.omega) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Satellite broadcast ephemeris for GLO -/// -/// The almanac message returns a set of satellite orbit parameters. Almanac -/// data is not very precise and is considered valid for up to several months. -/// Please see the GLO ICD 5.1 "Chapter 4.5 Non-immediate information and -/// almanac" for details. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgAlmanacGloDep { - /// 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 ConcreteMessage for MsgAlmanacGloDep { - const MESSAGE_TYPE: u16 = 113; - const MESSAGE_NAME: &'static str = "MSG_ALMANAC_GLO_DEP"; -} - -impl SbpMessage for MsgAlmanacGloDep { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_almanac_glo_dep { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Satellite broadcast ephemeris for GLO + /// + /// The almanac message returns a set of satellite orbit parameters. Almanac + /// data is not very precise and is considered valid for up to several months. + /// Please see the GLO ICD 5.1 "Chapter 4.5 Non-immediate information and + /// almanac" for details. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgAlmanacGloDep { + /// 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 ConcreteMessage for MsgAlmanacGloDep { + const MESSAGE_TYPE: u16 = 113; + const MESSAGE_NAME: &'static str = "MSG_ALMANAC_GLO_DEP"; + } + + impl SbpMessage for MsgAlmanacGloDep { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgAlmanacGloDep { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgAlmanacGloDep(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgAlmanacGloDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgAlmanacGloDep(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgAlmanacGloDep { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.common) - + WireFormat::len(&self.lambda_na) - + WireFormat::len(&self.t_lambda_na) - + WireFormat::len(&self.i) - + WireFormat::len(&self.t) - + WireFormat::len(&self.t_dot) - + WireFormat::len(&self.epsilon) - + WireFormat::len(&self.omega) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgAlmanacGloDep { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.common) + + WireFormat::len(&self.lambda_na) + + WireFormat::len(&self.t_lambda_na) + + WireFormat::len(&self.i) + + WireFormat::len(&self.t) + + WireFormat::len(&self.t_dot) + + WireFormat::len(&self.epsilon) + + WireFormat::len(&self.omega) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Satellite broadcast ephemeris for GPS -/// -/// The almanac message returns a set of satellite orbit parameters. Almanac -/// data is not very precise and is considered valid for up to several months. -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 ConcreteMessage for MsgAlmanacGps { - const MESSAGE_TYPE: u16 = 114; - const MESSAGE_NAME: &'static str = "MSG_ALMANAC_GPS"; -} - -impl SbpMessage for MsgAlmanacGps { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_almanac_gps { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Satellite broadcast ephemeris for GPS + /// + /// The almanac message returns a set of satellite orbit parameters. Almanac + /// data is not very precise and is considered valid for up to several months. + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 ConcreteMessage for MsgAlmanacGps { + const MESSAGE_TYPE: u16 = 114; + const MESSAGE_NAME: &'static str = "MSG_ALMANAC_GPS"; + } + + impl SbpMessage for MsgAlmanacGps { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgAlmanacGps { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgAlmanacGps(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgAlmanacGps { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgAlmanacGps(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgAlmanacGps { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.common) - + WireFormat::len(&self.m0) - + WireFormat::len(&self.ecc) - + WireFormat::len(&self.sqrta) - + WireFormat::len(&self.omega0) - + WireFormat::len(&self.omegadot) - + WireFormat::len(&self.w) - + WireFormat::len(&self.inc) - + WireFormat::len(&self.af0) - + WireFormat::len(&self.af1) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgAlmanacGps { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.common) + + WireFormat::len(&self.m0) + + WireFormat::len(&self.ecc) + + WireFormat::len(&self.sqrta) + + WireFormat::len(&self.omega0) + + WireFormat::len(&self.omegadot) + + WireFormat::len(&self.w) + + WireFormat::len(&self.inc) + + WireFormat::len(&self.af0) + + WireFormat::len(&self.af1) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Satellite broadcast ephemeris for GPS -/// -/// The almanac message returns a set of satellite orbit parameters. Almanac -/// data is not very precise and is considered valid for up to several months. -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 ConcreteMessage for MsgAlmanacGpsDep { - const MESSAGE_TYPE: u16 = 112; - const MESSAGE_NAME: &'static str = "MSG_ALMANAC_GPS_DEP"; -} - -impl SbpMessage for MsgAlmanacGpsDep { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_almanac_gps_dep { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Satellite broadcast ephemeris for GPS + /// + /// The almanac message returns a set of satellite orbit parameters. Almanac + /// data is not very precise and is considered valid for up to several months. + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 ConcreteMessage for MsgAlmanacGpsDep { + const MESSAGE_TYPE: u16 = 112; + const MESSAGE_NAME: &'static str = "MSG_ALMANAC_GPS_DEP"; + } + + impl SbpMessage for MsgAlmanacGpsDep { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgAlmanacGpsDep { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgAlmanacGpsDep(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgAlmanacGpsDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgAlmanacGpsDep(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgAlmanacGpsDep { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.common) - + WireFormat::len(&self.m0) - + WireFormat::len(&self.ecc) - + WireFormat::len(&self.sqrta) - + WireFormat::len(&self.omega0) - + WireFormat::len(&self.omegadot) - + WireFormat::len(&self.w) - + WireFormat::len(&self.inc) - + WireFormat::len(&self.af0) - + WireFormat::len(&self.af1) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgAlmanacGpsDep { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.common) + + WireFormat::len(&self.m0) + + WireFormat::len(&self.ecc) + + WireFormat::len(&self.sqrta) + + WireFormat::len(&self.omega0) + + WireFormat::len(&self.omegadot) + + WireFormat::len(&self.w) + + WireFormat::len(&self.inc) + + WireFormat::len(&self.af0) + + WireFormat::len(&self.af1) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Base station position in ECEF -/// -/// The base station position message is the position reported by the base -/// station itself in absolute Earth Centered Earth Fixed coordinates. It is -/// used for pseudo-absolute RTK positioning, and is 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 ConcreteMessage for MsgBasePosEcef { - const MESSAGE_TYPE: u16 = 72; - const MESSAGE_NAME: &'static str = "MSG_BASE_POS_ECEF"; -} - -impl SbpMessage for MsgBasePosEcef { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_base_pos_ecef { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Base station position in ECEF + /// + /// The base station position message is the position reported by the base + /// station itself in absolute Earth Centered Earth Fixed coordinates. It is + /// used for pseudo-absolute RTK positioning, and is 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 ConcreteMessage for MsgBasePosEcef { + const MESSAGE_TYPE: u16 = 72; + const MESSAGE_NAME: &'static str = "MSG_BASE_POS_ECEF"; + } + + impl SbpMessage for MsgBasePosEcef { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgBasePosEcef { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgBasePosEcef(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgBasePosEcef { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgBasePosEcef(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgBasePosEcef { - const MIN_LEN: usize = - ::MIN_LEN + ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.x) + WireFormat::len(&self.y) + WireFormat::len(&self.z) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.x, buf); - WireFormat::write(&self.y, buf); - WireFormat::write(&self.z, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgBasePosEcef { - sender_id: None, - x: WireFormat::parse_unchecked(buf), - y: WireFormat::parse_unchecked(buf), - z: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgBasePosEcef { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.x) + WireFormat::len(&self.y) + WireFormat::len(&self.z) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.x, buf); + WireFormat::write(&self.y, buf); + WireFormat::write(&self.z, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgBasePosEcef { + sender_id: None, + x: WireFormat::parse_unchecked(buf), + y: WireFormat::parse_unchecked(buf), + z: WireFormat::parse_unchecked(buf), + } } } } -/// Base station position -/// -/// The base station position message is the position reported by the base -/// station itself. It is used for pseudo-absolute RTK positioning, and is -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 ConcreteMessage for MsgBasePosLlh { - const MESSAGE_TYPE: u16 = 68; - const MESSAGE_NAME: &'static str = "MSG_BASE_POS_LLH"; -} - -impl SbpMessage for MsgBasePosLlh { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_base_pos_llh { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Base station position + /// + /// The base station position message is the position reported by the base + /// station itself. It is used for pseudo-absolute RTK positioning, and is + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 ConcreteMessage for MsgBasePosLlh { + const MESSAGE_TYPE: u16 = 68; + const MESSAGE_NAME: &'static str = "MSG_BASE_POS_LLH"; + } + + impl SbpMessage for MsgBasePosLlh { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgBasePosLlh { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgBasePosLlh(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgBasePosLlh { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgBasePosLlh(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgBasePosLlh { - const MIN_LEN: usize = - ::MIN_LEN + ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.lat) + WireFormat::len(&self.lon) + WireFormat::len(&self.height) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.lat, buf); - WireFormat::write(&self.lon, buf); - WireFormat::write(&self.height, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgBasePosLlh { - sender_id: None, - lat: WireFormat::parse_unchecked(buf), - lon: WireFormat::parse_unchecked(buf), - height: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgBasePosLlh { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.lat) + WireFormat::len(&self.lon) + WireFormat::len(&self.height) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.lat, buf); + WireFormat::write(&self.lon, buf); + WireFormat::write(&self.height, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgBasePosLlh { + sender_id: None, + lat: WireFormat::parse_unchecked(buf), + lon: WireFormat::parse_unchecked(buf), + height: WireFormat::parse_unchecked(buf), + } } } } -/// Satellite broadcast ephemeris for BDS -/// -/// The ephemeris message returns a set of satellite orbit parameters that is -/// used to calculate BDS satellite position, velocity, and clock offset. -/// Please see the BeiDou Navigation Satellite System SIS-ICD Version 2.1, -/// Table 5-9 for more details. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgEphemerisBds { - /// 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 - #[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 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ephemeris_bds { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Satellite broadcast ephemeris for BDS + /// + /// The ephemeris message returns a set of satellite orbit parameters that is + /// used to calculate BDS satellite position, velocity, and clock offset. + /// Please see the BeiDou Navigation Satellite System SIS-ICD Version 2.1, + /// Table 5-9 for more details. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgEphemerisBds { + /// 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 + #[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 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgEphemerisBds { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgEphemerisBds(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgEphemerisBds { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisBds(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgEphemerisBds { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.common) - + WireFormat::len(&self.tgd1) - + WireFormat::len(&self.tgd2) - + WireFormat::len(&self.c_rs) - + WireFormat::len(&self.c_rc) - + WireFormat::len(&self.c_uc) - + WireFormat::len(&self.c_us) - + WireFormat::len(&self.c_ic) - + WireFormat::len(&self.c_is) - + WireFormat::len(&self.dn) - + WireFormat::len(&self.m0) - + WireFormat::len(&self.ecc) - + WireFormat::len(&self.sqrta) - + WireFormat::len(&self.omega0) - + WireFormat::len(&self.omegadot) - + WireFormat::len(&self.w) - + WireFormat::len(&self.inc) - + WireFormat::len(&self.inc_dot) - + WireFormat::len(&self.af0) - + WireFormat::len(&self.af1) - + WireFormat::len(&self.af2) - + WireFormat::len(&self.toc) - + WireFormat::len(&self.iode) - + WireFormat::len(&self.iodc) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgEphemerisBds { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.common) + + WireFormat::len(&self.tgd1) + + WireFormat::len(&self.tgd2) + + WireFormat::len(&self.c_rs) + + WireFormat::len(&self.c_rc) + + WireFormat::len(&self.c_uc) + + WireFormat::len(&self.c_us) + + WireFormat::len(&self.c_ic) + + WireFormat::len(&self.c_is) + + WireFormat::len(&self.dn) + + WireFormat::len(&self.m0) + + WireFormat::len(&self.ecc) + + WireFormat::len(&self.sqrta) + + WireFormat::len(&self.omega0) + + WireFormat::len(&self.omegadot) + + WireFormat::len(&self.w) + + WireFormat::len(&self.inc) + + WireFormat::len(&self.inc_dot) + + WireFormat::len(&self.af0) + + WireFormat::len(&self.af1) + + WireFormat::len(&self.af2) + + WireFormat::len(&self.toc) + + WireFormat::len(&self.iode) + + WireFormat::len(&self.iodc) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgEphemerisDepA { - /// 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 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ephemeris_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Deprecated + /// + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgEphemerisDepA { + /// 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 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgEphemerisDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgEphemerisDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgEphemerisDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgEphemerisDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tgd) - + WireFormat::len(&self.c_rs) - + WireFormat::len(&self.c_rc) - + WireFormat::len(&self.c_uc) - + WireFormat::len(&self.c_us) - + WireFormat::len(&self.c_ic) - + WireFormat::len(&self.c_is) - + WireFormat::len(&self.dn) - + WireFormat::len(&self.m0) - + WireFormat::len(&self.ecc) - + WireFormat::len(&self.sqrta) - + WireFormat::len(&self.omega0) - + WireFormat::len(&self.omegadot) - + WireFormat::len(&self.w) - + WireFormat::len(&self.inc) - + WireFormat::len(&self.inc_dot) - + WireFormat::len(&self.af0) - + WireFormat::len(&self.af1) - + WireFormat::len(&self.af2) - + WireFormat::len(&self.toe_tow) - + WireFormat::len(&self.toe_wn) - + WireFormat::len(&self.toc_tow) - + WireFormat::len(&self.toc_wn) - + WireFormat::len(&self.valid) - + WireFormat::len(&self.healthy) - + WireFormat::len(&self.prn) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgEphemerisDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tgd) + + WireFormat::len(&self.c_rs) + + WireFormat::len(&self.c_rc) + + WireFormat::len(&self.c_uc) + + WireFormat::len(&self.c_us) + + WireFormat::len(&self.c_ic) + + WireFormat::len(&self.c_is) + + WireFormat::len(&self.dn) + + WireFormat::len(&self.m0) + + WireFormat::len(&self.ecc) + + WireFormat::len(&self.sqrta) + + WireFormat::len(&self.omega0) + + WireFormat::len(&self.omegadot) + + WireFormat::len(&self.w) + + WireFormat::len(&self.inc) + + WireFormat::len(&self.inc_dot) + + WireFormat::len(&self.af0) + + WireFormat::len(&self.af1) + + WireFormat::len(&self.af2) + + WireFormat::len(&self.toe_tow) + + WireFormat::len(&self.toe_wn) + + WireFormat::len(&self.toc_tow) + + WireFormat::len(&self.toc_wn) + + WireFormat::len(&self.valid) + + WireFormat::len(&self.healthy) + + WireFormat::len(&self.prn) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgEphemerisDepB { - /// 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 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ephemeris_dep_b { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Deprecated + /// + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgEphemerisDepB { + /// 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 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgEphemerisDepB { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgEphemerisDepB(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgEphemerisDepB { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisDepB(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgEphemerisDepB { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tgd) - + WireFormat::len(&self.c_rs) - + WireFormat::len(&self.c_rc) - + WireFormat::len(&self.c_uc) - + WireFormat::len(&self.c_us) - + WireFormat::len(&self.c_ic) - + WireFormat::len(&self.c_is) - + WireFormat::len(&self.dn) - + WireFormat::len(&self.m0) - + WireFormat::len(&self.ecc) - + WireFormat::len(&self.sqrta) - + WireFormat::len(&self.omega0) - + WireFormat::len(&self.omegadot) - + WireFormat::len(&self.w) - + WireFormat::len(&self.inc) - + WireFormat::len(&self.inc_dot) - + WireFormat::len(&self.af0) - + WireFormat::len(&self.af1) - + WireFormat::len(&self.af2) - + WireFormat::len(&self.toe_tow) - + WireFormat::len(&self.toe_wn) - + WireFormat::len(&self.toc_tow) - + WireFormat::len(&self.toc_wn) - + WireFormat::len(&self.valid) - + WireFormat::len(&self.healthy) - + WireFormat::len(&self.prn) - + WireFormat::len(&self.iode) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgEphemerisDepB { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tgd) + + WireFormat::len(&self.c_rs) + + WireFormat::len(&self.c_rc) + + WireFormat::len(&self.c_uc) + + WireFormat::len(&self.c_us) + + WireFormat::len(&self.c_ic) + + WireFormat::len(&self.c_is) + + WireFormat::len(&self.dn) + + WireFormat::len(&self.m0) + + WireFormat::len(&self.ecc) + + WireFormat::len(&self.sqrta) + + WireFormat::len(&self.omega0) + + WireFormat::len(&self.omegadot) + + WireFormat::len(&self.w) + + WireFormat::len(&self.inc) + + WireFormat::len(&self.inc_dot) + + WireFormat::len(&self.af0) + + WireFormat::len(&self.af1) + + WireFormat::len(&self.af2) + + WireFormat::len(&self.toe_tow) + + WireFormat::len(&self.toe_wn) + + WireFormat::len(&self.toc_tow) + + WireFormat::len(&self.toc_wn) + + WireFormat::len(&self.valid) + + WireFormat::len(&self.healthy) + + WireFormat::len(&self.prn) + + WireFormat::len(&self.iode) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Satellite broadcast ephemeris -/// -/// The ephemeris message returns a set of satellite orbit parameters that is -/// used to calculate GPS satellite position, velocity, and clock offset. -/// Please see the Navstar GPS Space Segment/Navigation user interfaces (ICD- -/// GPS-200, Table 20-III) for more details. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgEphemerisDepC { - /// 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 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ephemeris_dep_c { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Satellite broadcast ephemeris + /// + /// The ephemeris message returns a set of satellite orbit parameters that is + /// used to calculate GPS satellite position, velocity, and clock offset. + /// Please see the Navstar GPS Space Segment/Navigation user interfaces (ICD- + /// GPS-200, Table 20-III) for more details. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgEphemerisDepC { + /// 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 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgEphemerisDepC { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgEphemerisDepC(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgEphemerisDepC { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisDepC(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgEphemerisDepC { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tgd) - + WireFormat::len(&self.c_rs) - + WireFormat::len(&self.c_rc) - + WireFormat::len(&self.c_uc) - + WireFormat::len(&self.c_us) - + WireFormat::len(&self.c_ic) - + WireFormat::len(&self.c_is) - + WireFormat::len(&self.dn) - + WireFormat::len(&self.m0) - + WireFormat::len(&self.ecc) - + WireFormat::len(&self.sqrta) - + WireFormat::len(&self.omega0) - + WireFormat::len(&self.omegadot) - + WireFormat::len(&self.w) - + WireFormat::len(&self.inc) - + WireFormat::len(&self.inc_dot) - + WireFormat::len(&self.af0) - + WireFormat::len(&self.af1) - + WireFormat::len(&self.af2) - + WireFormat::len(&self.toe_tow) - + WireFormat::len(&self.toe_wn) - + WireFormat::len(&self.toc_tow) - + WireFormat::len(&self.toc_wn) - + WireFormat::len(&self.valid) - + WireFormat::len(&self.healthy) - + WireFormat::len(&self.sid) - + WireFormat::len(&self.iode) - + WireFormat::len(&self.iodc) - + WireFormat::len(&self.reserved) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgEphemerisDepC { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tgd) + + WireFormat::len(&self.c_rs) + + WireFormat::len(&self.c_rc) + + WireFormat::len(&self.c_uc) + + WireFormat::len(&self.c_us) + + WireFormat::len(&self.c_ic) + + WireFormat::len(&self.c_is) + + WireFormat::len(&self.dn) + + WireFormat::len(&self.m0) + + WireFormat::len(&self.ecc) + + WireFormat::len(&self.sqrta) + + WireFormat::len(&self.omega0) + + WireFormat::len(&self.omegadot) + + WireFormat::len(&self.w) + + WireFormat::len(&self.inc) + + WireFormat::len(&self.inc_dot) + + WireFormat::len(&self.af0) + + WireFormat::len(&self.af1) + + WireFormat::len(&self.af2) + + WireFormat::len(&self.toe_tow) + + WireFormat::len(&self.toe_wn) + + WireFormat::len(&self.toc_tow) + + WireFormat::len(&self.toc_wn) + + WireFormat::len(&self.valid) + + WireFormat::len(&self.healthy) + + WireFormat::len(&self.sid) + + WireFormat::len(&self.iode) + + WireFormat::len(&self.iodc) + + WireFormat::len(&self.reserved) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Satellite broadcast ephemeris -/// -/// The ephemeris message returns a set of satellite orbit parameters that is -/// used to calculate GPS satellite position, velocity, and clock offset. -/// Please see the Navstar GPS Space Segment/Navigation user interfaces (ICD- -/// GPS-200, Table 20-III) for more details. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgEphemerisDepD { - /// 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 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ephemeris_dep_d { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Satellite broadcast ephemeris + /// + /// The ephemeris message returns a set of satellite orbit parameters that is + /// used to calculate GPS satellite position, velocity, and clock offset. + /// Please see the Navstar GPS Space Segment/Navigation user interfaces (ICD- + /// GPS-200, Table 20-III) for more details. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgEphemerisDepD { + /// 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 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgEphemerisDepD { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgEphemerisDepD(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgEphemerisDepD { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisDepD(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgEphemerisDepD { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tgd) - + WireFormat::len(&self.c_rs) - + WireFormat::len(&self.c_rc) - + WireFormat::len(&self.c_uc) - + WireFormat::len(&self.c_us) - + WireFormat::len(&self.c_ic) - + WireFormat::len(&self.c_is) - + WireFormat::len(&self.dn) - + WireFormat::len(&self.m0) - + WireFormat::len(&self.ecc) - + WireFormat::len(&self.sqrta) - + WireFormat::len(&self.omega0) - + WireFormat::len(&self.omegadot) - + WireFormat::len(&self.w) - + WireFormat::len(&self.inc) - + WireFormat::len(&self.inc_dot) - + WireFormat::len(&self.af0) - + WireFormat::len(&self.af1) - + WireFormat::len(&self.af2) - + WireFormat::len(&self.toe_tow) - + WireFormat::len(&self.toe_wn) - + WireFormat::len(&self.toc_tow) - + WireFormat::len(&self.toc_wn) - + WireFormat::len(&self.valid) - + WireFormat::len(&self.healthy) - + WireFormat::len(&self.sid) - + WireFormat::len(&self.iode) - + WireFormat::len(&self.iodc) - + WireFormat::len(&self.reserved) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgEphemerisDepD { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tgd) + + WireFormat::len(&self.c_rs) + + WireFormat::len(&self.c_rc) + + WireFormat::len(&self.c_uc) + + WireFormat::len(&self.c_us) + + WireFormat::len(&self.c_ic) + + WireFormat::len(&self.c_is) + + WireFormat::len(&self.dn) + + WireFormat::len(&self.m0) + + WireFormat::len(&self.ecc) + + WireFormat::len(&self.sqrta) + + WireFormat::len(&self.omega0) + + WireFormat::len(&self.omegadot) + + WireFormat::len(&self.w) + + WireFormat::len(&self.inc) + + WireFormat::len(&self.inc_dot) + + WireFormat::len(&self.af0) + + WireFormat::len(&self.af1) + + WireFormat::len(&self.af2) + + WireFormat::len(&self.toe_tow) + + WireFormat::len(&self.toe_wn) + + WireFormat::len(&self.toc_tow) + + WireFormat::len(&self.toc_wn) + + WireFormat::len(&self.valid) + + WireFormat::len(&self.healthy) + + WireFormat::len(&self.sid) + + WireFormat::len(&self.iode) + + WireFormat::len(&self.iodc) + + WireFormat::len(&self.reserved) } - } -} - -/// Satellite broadcast ephemeris for Galileo -/// -/// The ephemeris message returns a set of satellite orbit parameters that is -/// used to calculate Galileo satellite position, velocity, and clock offset. -/// Please see the Signal In Space ICD OS SIS ICD, Issue 1.3, December 2016 -/// for more details. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgEphemerisGal { - /// 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 - #[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 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } -} - -impl TryFrom for MsgEphemerisGal { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgEphemerisGal(m) => Ok(m), - _ => Err(TryFromSbpError), + fn write(&self, buf: &mut B) { + 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); } - } -} - -impl WireFormat for MsgEphemerisGal { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.common) - + WireFormat::len(&self.bgd_e1e5a) - + WireFormat::len(&self.bgd_e1e5b) - + WireFormat::len(&self.c_rs) - + WireFormat::len(&self.c_rc) - + WireFormat::len(&self.c_uc) - + WireFormat::len(&self.c_us) - + WireFormat::len(&self.c_ic) - + WireFormat::len(&self.c_is) - + WireFormat::len(&self.dn) - + WireFormat::len(&self.m0) - + WireFormat::len(&self.ecc) - + WireFormat::len(&self.sqrta) - + WireFormat::len(&self.omega0) - + WireFormat::len(&self.omegadot) - + WireFormat::len(&self.w) - + WireFormat::len(&self.inc) - + WireFormat::len(&self.inc_dot) - + WireFormat::len(&self.af0) - + WireFormat::len(&self.af1) - + WireFormat::len(&self.af2) - + WireFormat::len(&self.toc) - + WireFormat::len(&self.iode) - + WireFormat::len(&self.iodc) - + WireFormat::len(&self.source) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + fn parse_unchecked(buf: &mut B) -> 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), + } } } } -/// Deprecated -/// -/// This observation message has been deprecated in favor of an ephemeris -/// message with explicit source of NAV data. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgEphemerisGalDepA { - /// 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 - #[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 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ephemeris_gal { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Satellite broadcast ephemeris for Galileo + /// + /// The ephemeris message returns a set of satellite orbit parameters that is + /// used to calculate Galileo satellite position, velocity, and clock offset. + /// Please see the Signal In Space ICD OS SIS ICD, Issue 1.3, December 2016 + /// for more details. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgEphemerisGal { + /// 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 + #[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 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgEphemerisGalDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgEphemerisGalDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgEphemerisGal { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisGal(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgEphemerisGalDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.common) - + WireFormat::len(&self.bgd_e1e5a) - + WireFormat::len(&self.bgd_e1e5b) - + WireFormat::len(&self.c_rs) - + WireFormat::len(&self.c_rc) - + WireFormat::len(&self.c_uc) - + WireFormat::len(&self.c_us) - + WireFormat::len(&self.c_ic) - + WireFormat::len(&self.c_is) - + WireFormat::len(&self.dn) - + WireFormat::len(&self.m0) - + WireFormat::len(&self.ecc) - + WireFormat::len(&self.sqrta) - + WireFormat::len(&self.omega0) - + WireFormat::len(&self.omegadot) - + WireFormat::len(&self.w) - + WireFormat::len(&self.inc) - + WireFormat::len(&self.inc_dot) - + WireFormat::len(&self.af0) - + WireFormat::len(&self.af1) - + WireFormat::len(&self.af2) - + WireFormat::len(&self.toc) - + WireFormat::len(&self.iode) - + WireFormat::len(&self.iodc) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgEphemerisGal { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.common) + + WireFormat::len(&self.bgd_e1e5a) + + WireFormat::len(&self.bgd_e1e5b) + + WireFormat::len(&self.c_rs) + + WireFormat::len(&self.c_rc) + + WireFormat::len(&self.c_uc) + + WireFormat::len(&self.c_us) + + WireFormat::len(&self.c_ic) + + WireFormat::len(&self.c_is) + + WireFormat::len(&self.dn) + + WireFormat::len(&self.m0) + + WireFormat::len(&self.ecc) + + WireFormat::len(&self.sqrta) + + WireFormat::len(&self.omega0) + + WireFormat::len(&self.omegadot) + + WireFormat::len(&self.w) + + WireFormat::len(&self.inc) + + WireFormat::len(&self.inc_dot) + + WireFormat::len(&self.af0) + + WireFormat::len(&self.af1) + + WireFormat::len(&self.af2) + + WireFormat::len(&self.toc) + + WireFormat::len(&self.iode) + + WireFormat::len(&self.iodc) + + WireFormat::len(&self.source) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Satellite broadcast ephemeris for GLO -/// -/// The ephemeris message returns a set of satellite orbit parameters that is -/// used to calculate GLO satellite position, velocity, and clock offset. -/// Please see the GLO ICD 5.1 "Table 4.5 Characteristics of words of -/// immediate information (ephemeris parameters)" for more details. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgEphemerisGlo { - /// 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 - #[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 - #[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 - #[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 ConcreteMessage for MsgEphemerisGlo { - const MESSAGE_TYPE: u16 = 139; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO"; -} - -impl SbpMessage for MsgEphemerisGlo { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ephemeris_gal_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Deprecated + /// + /// This observation message has been deprecated in favor of an ephemeris + /// message with explicit source of NAV data. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgEphemerisGalDepA { + /// 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 + #[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 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgEphemerisGlo { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgEphemerisGlo(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgEphemerisGalDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisGalDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgEphemerisGlo { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN - + <[f32; 3] as WireFormat>::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.common) - + WireFormat::len(&self.gamma) - + WireFormat::len(&self.tau) - + WireFormat::len(&self.d_tau) - + WireFormat::len(&self.pos) - + WireFormat::len(&self.vel) - + WireFormat::len(&self.acc) - + WireFormat::len(&self.fcn) - + WireFormat::len(&self.iod) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgEphemerisGalDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.common) + + WireFormat::len(&self.bgd_e1e5a) + + WireFormat::len(&self.bgd_e1e5b) + + WireFormat::len(&self.c_rs) + + WireFormat::len(&self.c_rc) + + WireFormat::len(&self.c_uc) + + WireFormat::len(&self.c_us) + + WireFormat::len(&self.c_ic) + + WireFormat::len(&self.c_is) + + WireFormat::len(&self.dn) + + WireFormat::len(&self.m0) + + WireFormat::len(&self.ecc) + + WireFormat::len(&self.sqrta) + + WireFormat::len(&self.omega0) + + WireFormat::len(&self.omegadot) + + WireFormat::len(&self.w) + + WireFormat::len(&self.inc) + + WireFormat::len(&self.inc_dot) + + WireFormat::len(&self.af0) + + WireFormat::len(&self.af1) + + WireFormat::len(&self.af2) + + WireFormat::len(&self.toc) + + WireFormat::len(&self.iode) + + WireFormat::len(&self.iodc) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Satellite broadcast ephemeris for GLO -/// -/// The ephemeris message returns a set of satellite orbit parameters that is -/// used to calculate GLO satellite position, velocity, and clock offset. -/// Please see the GLO ICD 5.1 "Table 4.5 Characteristics of words of -/// immediate information (ephemeris parameters)" for more details. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgEphemerisGloDepA { - /// 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 - #[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 - #[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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "acc")))] - pub acc: [f64; 3], -} - -impl ConcreteMessage for MsgEphemerisGloDepA { - const MESSAGE_TYPE: u16 = 131; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO_DEP_A"; -} - -impl SbpMessage for MsgEphemerisGloDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ephemeris_glo { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Satellite broadcast ephemeris for GLO + /// + /// The ephemeris message returns a set of satellite orbit parameters that is + /// used to calculate GLO satellite position, velocity, and clock offset. + /// Please see the GLO ICD 5.1 "Table 4.5 Characteristics of words of + /// immediate information (ephemeris parameters)" for more details. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgEphemerisGlo { + /// 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 + #[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 + #[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 + #[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 ConcreteMessage for MsgEphemerisGlo { + const MESSAGE_TYPE: u16 = 139; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO"; + } + + impl SbpMessage for MsgEphemerisGlo { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgEphemerisGloDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgEphemerisGloDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgEphemerisGlo { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisGlo(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgEphemerisGloDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.common) - + WireFormat::len(&self.gamma) - + WireFormat::len(&self.tau) - + WireFormat::len(&self.pos) - + WireFormat::len(&self.vel) - + WireFormat::len(&self.acc) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgEphemerisGlo { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN + + <[f32; 3] as WireFormat>::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.common) + + WireFormat::len(&self.gamma) + + WireFormat::len(&self.tau) + + WireFormat::len(&self.d_tau) + + WireFormat::len(&self.pos) + + WireFormat::len(&self.vel) + + WireFormat::len(&self.acc) + + WireFormat::len(&self.fcn) + + WireFormat::len(&self.iod) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Satellite broadcast ephemeris for GLO -/// -/// The ephemeris message returns a set of satellite orbit parameters that is -/// used to calculate GLO satellite position, velocity, and clock offset. -/// Please see the GLO ICD 5.1 "Table 4.5 Characteristics of words of -/// immediate information (ephemeris parameters)" for more details. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgEphemerisGloDepB { - /// 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 - #[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 - #[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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "acc")))] - pub acc: [f64; 3], -} - -impl ConcreteMessage for MsgEphemerisGloDepB { - const MESSAGE_TYPE: u16 = 133; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO_DEP_B"; -} - -impl SbpMessage for MsgEphemerisGloDepB { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ephemeris_glo_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Satellite broadcast ephemeris for GLO + /// + /// The ephemeris message returns a set of satellite orbit parameters that is + /// used to calculate GLO satellite position, velocity, and clock offset. + /// Please see the GLO ICD 5.1 "Table 4.5 Characteristics of words of + /// immediate information (ephemeris parameters)" for more details. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgEphemerisGloDepA { + /// 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 + #[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 + #[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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "acc")))] + pub acc: [f64; 3], + } + + impl ConcreteMessage for MsgEphemerisGloDepA { + const MESSAGE_TYPE: u16 = 131; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO_DEP_A"; + } + + impl SbpMessage for MsgEphemerisGloDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgEphemerisGloDepB { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgEphemerisGloDepB(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgEphemerisGloDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisGloDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgEphemerisGloDepB { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.common) - + WireFormat::len(&self.gamma) - + WireFormat::len(&self.tau) - + WireFormat::len(&self.pos) - + WireFormat::len(&self.vel) - + WireFormat::len(&self.acc) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgEphemerisGloDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.common) + + WireFormat::len(&self.gamma) + + WireFormat::len(&self.tau) + + WireFormat::len(&self.pos) + + WireFormat::len(&self.vel) + + WireFormat::len(&self.acc) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Satellite broadcast ephemeris for GLO -/// -/// The ephemeris message returns a set of satellite orbit parameters that is -/// used to calculate GLO satellite position, velocity, and clock offset. -/// Please see the GLO ICD 5.1 "Table 4.5 Characteristics of words of -/// immediate information (ephemeris parameters)" for more details. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgEphemerisGloDepC { - /// 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 - #[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 - #[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 - #[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 ConcreteMessage for MsgEphemerisGloDepC { - const MESSAGE_TYPE: u16 = 135; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO_DEP_C"; -} - -impl SbpMessage for MsgEphemerisGloDepC { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ephemeris_glo_dep_b { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Satellite broadcast ephemeris for GLO + /// + /// The ephemeris message returns a set of satellite orbit parameters that is + /// used to calculate GLO satellite position, velocity, and clock offset. + /// Please see the GLO ICD 5.1 "Table 4.5 Characteristics of words of + /// immediate information (ephemeris parameters)" for more details. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgEphemerisGloDepB { + /// 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 + #[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 + #[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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "acc")))] + pub acc: [f64; 3], + } + + impl ConcreteMessage for MsgEphemerisGloDepB { + const MESSAGE_TYPE: u16 = 133; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO_DEP_B"; + } + + impl SbpMessage for MsgEphemerisGloDepB { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgEphemerisGloDepC { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgEphemerisGloDepC(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgEphemerisGloDepB { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisGloDepB(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgEphemerisGloDepC { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.common) - + WireFormat::len(&self.gamma) - + WireFormat::len(&self.tau) - + WireFormat::len(&self.d_tau) - + WireFormat::len(&self.pos) - + WireFormat::len(&self.vel) - + WireFormat::len(&self.acc) - + WireFormat::len(&self.fcn) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgEphemerisGloDepB { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.common) + + WireFormat::len(&self.gamma) + + WireFormat::len(&self.tau) + + WireFormat::len(&self.pos) + + WireFormat::len(&self.vel) + + WireFormat::len(&self.acc) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Deprecated -/// -/// This observation message has been deprecated in favor of ephemeris message -/// using floats for size reduction. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgEphemerisGloDepD { - /// 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 - #[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 - #[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 - #[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 ConcreteMessage for MsgEphemerisGloDepD { - const MESSAGE_TYPE: u16 = 136; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO_DEP_D"; -} - -impl SbpMessage for MsgEphemerisGloDepD { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ephemeris_glo_dep_c { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Satellite broadcast ephemeris for GLO + /// + /// The ephemeris message returns a set of satellite orbit parameters that is + /// used to calculate GLO satellite position, velocity, and clock offset. + /// Please see the GLO ICD 5.1 "Table 4.5 Characteristics of words of + /// immediate information (ephemeris parameters)" for more details. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgEphemerisGloDepC { + /// 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 + #[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 + #[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 + #[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 ConcreteMessage for MsgEphemerisGloDepC { + const MESSAGE_TYPE: u16 = 135; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO_DEP_C"; + } + + impl SbpMessage for MsgEphemerisGloDepC { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgEphemerisGloDepD { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgEphemerisGloDepD(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgEphemerisGloDepC { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisGloDepC(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgEphemerisGloDepD { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.common) - + WireFormat::len(&self.gamma) - + WireFormat::len(&self.tau) - + WireFormat::len(&self.d_tau) - + WireFormat::len(&self.pos) - + WireFormat::len(&self.vel) - + WireFormat::len(&self.acc) - + WireFormat::len(&self.fcn) - + WireFormat::len(&self.iod) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgEphemerisGloDepC { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.common) + + WireFormat::len(&self.gamma) + + WireFormat::len(&self.tau) + + WireFormat::len(&self.d_tau) + + WireFormat::len(&self.pos) + + WireFormat::len(&self.vel) + + WireFormat::len(&self.acc) + + WireFormat::len(&self.fcn) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Satellite broadcast ephemeris for GPS -/// -/// The ephemeris message returns a set of satellite orbit parameters that is -/// used to calculate GPS satellite position, velocity, and clock offset. -/// Please see the Navstar GPS Space Segment/Navigation user interfaces (ICD- -/// GPS-200, Table 20-III) for more details. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 - #[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 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ephemeris_glo_dep_d { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Deprecated + /// + /// This observation message has been deprecated in favor of ephemeris message + /// using floats for size reduction. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgEphemerisGloDepD { + /// 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 + #[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 + #[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 + #[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 ConcreteMessage for MsgEphemerisGloDepD { + const MESSAGE_TYPE: u16 = 136; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_GLO_DEP_D"; + } + + impl SbpMessage for MsgEphemerisGloDepD { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgEphemerisGps { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgEphemerisGps(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgEphemerisGloDepD { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisGloDepD(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgEphemerisGps { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.common) - + WireFormat::len(&self.tgd) - + WireFormat::len(&self.c_rs) - + WireFormat::len(&self.c_rc) - + WireFormat::len(&self.c_uc) - + WireFormat::len(&self.c_us) - + WireFormat::len(&self.c_ic) - + WireFormat::len(&self.c_is) - + WireFormat::len(&self.dn) - + WireFormat::len(&self.m0) - + WireFormat::len(&self.ecc) - + WireFormat::len(&self.sqrta) - + WireFormat::len(&self.omega0) - + WireFormat::len(&self.omegadot) - + WireFormat::len(&self.w) - + WireFormat::len(&self.inc) - + WireFormat::len(&self.inc_dot) - + WireFormat::len(&self.af0) - + WireFormat::len(&self.af1) - + WireFormat::len(&self.af2) - + WireFormat::len(&self.toc) - + WireFormat::len(&self.iode) - + WireFormat::len(&self.iodc) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgEphemerisGloDepD { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.common) + + WireFormat::len(&self.gamma) + + WireFormat::len(&self.tau) + + WireFormat::len(&self.d_tau) + + WireFormat::len(&self.pos) + + WireFormat::len(&self.vel) + + WireFormat::len(&self.acc) + + WireFormat::len(&self.fcn) + + WireFormat::len(&self.iod) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Satellite broadcast ephemeris for GPS -/// -/// The ephemeris message returns a set of satellite orbit parameters that is -/// used to calculate GPS satellite position, velocity, and clock offset. -/// Please see the Navstar GPS Space Segment/Navigation user interfaces (ICD- -/// GPS-200, Table 20-III) for more details. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 - #[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 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ephemeris_gps { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Satellite broadcast ephemeris for GPS + /// + /// The ephemeris message returns a set of satellite orbit parameters that is + /// used to calculate GPS satellite position, velocity, and clock offset. + /// Please see the Navstar GPS Space Segment/Navigation user interfaces (ICD- + /// GPS-200, Table 20-III) for more details. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 + #[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 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgEphemerisGpsDepE { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgEphemerisGpsDepE(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgEphemerisGps { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisGps(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgEphemerisGpsDepE { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.common) - + WireFormat::len(&self.tgd) - + WireFormat::len(&self.c_rs) - + WireFormat::len(&self.c_rc) - + WireFormat::len(&self.c_uc) - + WireFormat::len(&self.c_us) - + WireFormat::len(&self.c_ic) - + WireFormat::len(&self.c_is) - + WireFormat::len(&self.dn) - + WireFormat::len(&self.m0) - + WireFormat::len(&self.ecc) - + WireFormat::len(&self.sqrta) - + WireFormat::len(&self.omega0) - + WireFormat::len(&self.omegadot) - + WireFormat::len(&self.w) - + WireFormat::len(&self.inc) - + WireFormat::len(&self.inc_dot) - + WireFormat::len(&self.af0) - + WireFormat::len(&self.af1) - + WireFormat::len(&self.af2) - + WireFormat::len(&self.toc) - + WireFormat::len(&self.iode) - + WireFormat::len(&self.iodc) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgEphemerisGps { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.common) + + WireFormat::len(&self.tgd) + + WireFormat::len(&self.c_rs) + + WireFormat::len(&self.c_rc) + + WireFormat::len(&self.c_uc) + + WireFormat::len(&self.c_us) + + WireFormat::len(&self.c_ic) + + WireFormat::len(&self.c_is) + + WireFormat::len(&self.dn) + + WireFormat::len(&self.m0) + + WireFormat::len(&self.ecc) + + WireFormat::len(&self.sqrta) + + WireFormat::len(&self.omega0) + + WireFormat::len(&self.omegadot) + + WireFormat::len(&self.w) + + WireFormat::len(&self.inc) + + WireFormat::len(&self.inc_dot) + + WireFormat::len(&self.af0) + + WireFormat::len(&self.af1) + + WireFormat::len(&self.af2) + + WireFormat::len(&self.toc) + + WireFormat::len(&self.iode) + + WireFormat::len(&self.iodc) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Deprecated -/// -/// This observation message has been deprecated in favor of ephemeris message -/// using floats for size reduction. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 - #[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 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ephemeris_gps_dep_e { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Satellite broadcast ephemeris for GPS + /// + /// The ephemeris message returns a set of satellite orbit parameters that is + /// used to calculate GPS satellite position, velocity, and clock offset. + /// Please see the Navstar GPS Space Segment/Navigation user interfaces (ICD- + /// GPS-200, Table 20-III) for more details. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 + #[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 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgEphemerisGpsDepF { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgEphemerisGpsDepF(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgEphemerisGpsDepE { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisGpsDepE(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgEphemerisGpsDepF { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.common) - + WireFormat::len(&self.tgd) - + WireFormat::len(&self.c_rs) - + WireFormat::len(&self.c_rc) - + WireFormat::len(&self.c_uc) - + WireFormat::len(&self.c_us) - + WireFormat::len(&self.c_ic) - + WireFormat::len(&self.c_is) - + WireFormat::len(&self.dn) - + WireFormat::len(&self.m0) - + WireFormat::len(&self.ecc) - + WireFormat::len(&self.sqrta) - + WireFormat::len(&self.omega0) - + WireFormat::len(&self.omegadot) - + WireFormat::len(&self.w) - + WireFormat::len(&self.inc) - + WireFormat::len(&self.inc_dot) - + WireFormat::len(&self.af0) - + WireFormat::len(&self.af1) - + WireFormat::len(&self.af2) - + WireFormat::len(&self.toc) - + WireFormat::len(&self.iode) - + WireFormat::len(&self.iodc) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgEphemerisGpsDepE { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.common) + + WireFormat::len(&self.tgd) + + WireFormat::len(&self.c_rs) + + WireFormat::len(&self.c_rc) + + WireFormat::len(&self.c_uc) + + WireFormat::len(&self.c_us) + + WireFormat::len(&self.c_ic) + + WireFormat::len(&self.c_is) + + WireFormat::len(&self.dn) + + WireFormat::len(&self.m0) + + WireFormat::len(&self.ecc) + + WireFormat::len(&self.sqrta) + + WireFormat::len(&self.omega0) + + WireFormat::len(&self.omegadot) + + WireFormat::len(&self.w) + + WireFormat::len(&self.inc) + + WireFormat::len(&self.inc_dot) + + WireFormat::len(&self.af0) + + WireFormat::len(&self.af1) + + WireFormat::len(&self.af2) + + WireFormat::len(&self.toc) + + WireFormat::len(&self.iode) + + WireFormat::len(&self.iodc) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Satellite broadcast ephemeris for QZSS -/// -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgEphemerisQzss { - /// 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 - #[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 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ephemeris_gps_dep_f { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Deprecated + /// + /// This observation message has been deprecated in favor of ephemeris message + /// using floats for size reduction. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 + #[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 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgEphemerisQzss { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgEphemerisQzss(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgEphemerisGpsDepF { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisGpsDepF(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgEphemerisQzss { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.common) - + WireFormat::len(&self.tgd) - + WireFormat::len(&self.c_rs) - + WireFormat::len(&self.c_rc) - + WireFormat::len(&self.c_uc) - + WireFormat::len(&self.c_us) - + WireFormat::len(&self.c_ic) - + WireFormat::len(&self.c_is) - + WireFormat::len(&self.dn) - + WireFormat::len(&self.m0) - + WireFormat::len(&self.ecc) - + WireFormat::len(&self.sqrta) - + WireFormat::len(&self.omega0) - + WireFormat::len(&self.omegadot) - + WireFormat::len(&self.w) - + WireFormat::len(&self.inc) - + WireFormat::len(&self.inc_dot) - + WireFormat::len(&self.af0) - + WireFormat::len(&self.af1) - + WireFormat::len(&self.af2) - + WireFormat::len(&self.toc) - + WireFormat::len(&self.iode) - + WireFormat::len(&self.iodc) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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 WireFormat for MsgEphemerisGpsDepF { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.common) + + WireFormat::len(&self.tgd) + + WireFormat::len(&self.c_rs) + + WireFormat::len(&self.c_rc) + + WireFormat::len(&self.c_uc) + + WireFormat::len(&self.c_us) + + WireFormat::len(&self.c_ic) + + WireFormat::len(&self.c_is) + + WireFormat::len(&self.dn) + + WireFormat::len(&self.m0) + + WireFormat::len(&self.ecc) + + WireFormat::len(&self.sqrta) + + WireFormat::len(&self.omega0) + + WireFormat::len(&self.omegadot) + + WireFormat::len(&self.w) + + WireFormat::len(&self.inc) + + WireFormat::len(&self.inc_dot) + + WireFormat::len(&self.af0) + + WireFormat::len(&self.af1) + + WireFormat::len(&self.af2) + + WireFormat::len(&self.toc) + + WireFormat::len(&self.iode) + + WireFormat::len(&self.iodc) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Satellite broadcast ephemeris for SBAS -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgEphemerisSbas { - /// 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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "pos")))] - pub pos: [f64; 3], - /// Velocity of the GEO at time toe - #[cfg_attr(feature = "serde", serde(rename(serialize = "vel")))] - pub vel: [f32; 3], - /// Acceleration of the GEO at time toe - #[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 ConcreteMessage for MsgEphemerisSbas { - const MESSAGE_TYPE: u16 = 140; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_SBAS"; -} - -impl SbpMessage for MsgEphemerisSbas { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ephemeris_qzss { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Satellite broadcast ephemeris for QZSS + /// + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgEphemerisQzss { + /// 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 + #[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 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgEphemerisSbas { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgEphemerisSbas(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgEphemerisQzss { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisQzss(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgEphemerisSbas { - const MIN_LEN: usize = ::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN - + <[f32; 3] as WireFormat>::MIN_LEN - + <[f32; 3] as WireFormat>::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.common) - + WireFormat::len(&self.pos) - + WireFormat::len(&self.vel) - + WireFormat::len(&self.acc) - + WireFormat::len(&self.a_gf0) - + WireFormat::len(&self.a_gf1) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgEphemerisQzss { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.common) + + WireFormat::len(&self.tgd) + + WireFormat::len(&self.c_rs) + + WireFormat::len(&self.c_rc) + + WireFormat::len(&self.c_uc) + + WireFormat::len(&self.c_us) + + WireFormat::len(&self.c_ic) + + WireFormat::len(&self.c_is) + + WireFormat::len(&self.dn) + + WireFormat::len(&self.m0) + + WireFormat::len(&self.ecc) + + WireFormat::len(&self.sqrta) + + WireFormat::len(&self.omega0) + + WireFormat::len(&self.omegadot) + + WireFormat::len(&self.w) + + WireFormat::len(&self.inc) + + WireFormat::len(&self.inc_dot) + + WireFormat::len(&self.af0) + + WireFormat::len(&self.af1) + + WireFormat::len(&self.af2) + + WireFormat::len(&self.toc) + + WireFormat::len(&self.iode) + + WireFormat::len(&self.iodc) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Satellite broadcast ephemeris for SBAS -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgEphemerisSbasDepA { - /// 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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "pos")))] - pub pos: [f64; 3], - /// Velocity of the GEO at time toe - #[cfg_attr(feature = "serde", serde(rename(serialize = "vel")))] - pub vel: [f64; 3], - /// Acceleration of the GEO at time toe - #[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 ConcreteMessage for MsgEphemerisSbasDepA { - const MESSAGE_TYPE: u16 = 130; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_SBAS_DEP_A"; -} - -impl SbpMessage for MsgEphemerisSbasDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ephemeris_sbas { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + /// Satellite broadcast ephemeris for SBAS + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgEphemerisSbas { + /// 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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "pos")))] + pub pos: [f64; 3], + /// Velocity of the GEO at time toe + #[cfg_attr(feature = "serde", serde(rename(serialize = "vel")))] + pub vel: [f32; 3], + /// Acceleration of the GEO at time toe + #[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 ConcreteMessage for MsgEphemerisSbas { + const MESSAGE_TYPE: u16 = 140; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_SBAS"; + } + + impl SbpMessage for MsgEphemerisSbas { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgEphemerisSbasDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgEphemerisSbasDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgEphemerisSbas { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisSbas(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgEphemerisSbasDepA { - const MIN_LEN: usize = ::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.common) - + WireFormat::len(&self.pos) - + WireFormat::len(&self.vel) - + WireFormat::len(&self.acc) - + WireFormat::len(&self.a_gf0) - + WireFormat::len(&self.a_gf1) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgEphemerisSbas { + const MIN_LEN: usize = ::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN + + <[f32; 3] as WireFormat>::MIN_LEN + + <[f32; 3] as WireFormat>::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.common) + + WireFormat::len(&self.pos) + + WireFormat::len(&self.vel) + + WireFormat::len(&self.acc) + + WireFormat::len(&self.a_gf0) + + WireFormat::len(&self.a_gf1) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Deprecated -/// -/// This observation message has been deprecated in favor of ephemeris message -/// using floats for size reduction. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgEphemerisSbasDepB { - /// 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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "pos")))] - pub pos: [f64; 3], - /// Velocity of the GEO at time toe - #[cfg_attr(feature = "serde", serde(rename(serialize = "vel")))] - pub vel: [f64; 3], - /// Acceleration of the GEO at time toe - #[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 ConcreteMessage for MsgEphemerisSbasDepB { - const MESSAGE_TYPE: u16 = 132; - const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_SBAS_DEP_B"; -} - -impl SbpMessage for MsgEphemerisSbasDepB { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ephemeris_sbas_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + /// Satellite broadcast ephemeris for SBAS + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgEphemerisSbasDepA { + /// 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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "pos")))] + pub pos: [f64; 3], + /// Velocity of the GEO at time toe + #[cfg_attr(feature = "serde", serde(rename(serialize = "vel")))] + pub vel: [f64; 3], + /// Acceleration of the GEO at time toe + #[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 ConcreteMessage for MsgEphemerisSbasDepA { + const MESSAGE_TYPE: u16 = 130; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_SBAS_DEP_A"; + } + + impl SbpMessage for MsgEphemerisSbasDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgEphemerisSbasDepB { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgEphemerisSbasDepB(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgEphemerisSbasDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisSbasDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgEphemerisSbasDepB { - const MIN_LEN: usize = ::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN - + <[f64; 3] as WireFormat>::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.common) - + WireFormat::len(&self.pos) - + WireFormat::len(&self.vel) - + WireFormat::len(&self.acc) - + WireFormat::len(&self.a_gf0) - + WireFormat::len(&self.a_gf1) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgEphemerisSbasDepA { + const MIN_LEN: usize = ::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.common) + + WireFormat::len(&self.pos) + + WireFormat::len(&self.vel) + + WireFormat::len(&self.acc) + + WireFormat::len(&self.a_gf0) + + WireFormat::len(&self.a_gf1) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// GLONASS L1/L2 Code-Phase biases -/// -/// The GLONASS L1/L2 Code-Phase biases allows to perform GPS+GLONASS integer -/// ambiguity resolution for baselines with mixed receiver types (e.g. -/// receiver of different manufacturers). -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgGloBiases { - /// 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 ConcreteMessage for MsgGloBiases { - const MESSAGE_TYPE: u16 = 117; - const MESSAGE_NAME: &'static str = "MSG_GLO_BIASES"; -} - -impl SbpMessage for MsgGloBiases { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ephemeris_sbas_dep_b { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Deprecated + /// + /// This observation message has been deprecated in favor of ephemeris message + /// using floats for size reduction. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgEphemerisSbasDepB { + /// 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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "pos")))] + pub pos: [f64; 3], + /// Velocity of the GEO at time toe + #[cfg_attr(feature = "serde", serde(rename(serialize = "vel")))] + pub vel: [f64; 3], + /// Acceleration of the GEO at time toe + #[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 ConcreteMessage for MsgEphemerisSbasDepB { + const MESSAGE_TYPE: u16 = 132; + const MESSAGE_NAME: &'static str = "MSG_EPHEMERIS_SBAS_DEP_B"; + } + + impl SbpMessage for MsgEphemerisSbasDepB { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgGloBiases { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgGloBiases(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgEphemerisSbasDepB { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgEphemerisSbasDepB(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgGloBiases { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.mask) - + WireFormat::len(&self.l1ca_bias) - + WireFormat::len(&self.l1p_bias) - + WireFormat::len(&self.l2ca_bias) - + WireFormat::len(&self.l2p_bias) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgEphemerisSbasDepB { + const MIN_LEN: usize = ::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN + + <[f64; 3] as WireFormat>::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.common) + + WireFormat::len(&self.pos) + + WireFormat::len(&self.vel) + + WireFormat::len(&self.acc) + + WireFormat::len(&self.a_gf0) + + WireFormat::len(&self.a_gf1) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// GNSS capabilities -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgGnssCapb { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, - /// Navigation Message Correction Table Validity Time - #[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 ConcreteMessage for MsgGnssCapb { - const MESSAGE_TYPE: u16 = 150; - const MESSAGE_NAME: &'static str = "MSG_GNSS_CAPB"; -} - -impl SbpMessage for MsgGnssCapb { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_glo_biases { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// GLONASS L1/L2 Code-Phase biases + /// + /// The GLONASS L1/L2 Code-Phase biases allows to perform GPS+GLONASS integer + /// ambiguity resolution for baselines with mixed receiver types (e.g. + /// receiver of different manufacturers). + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgGloBiases { + /// 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 ConcreteMessage for MsgGloBiases { + const MESSAGE_TYPE: u16 = 117; + const MESSAGE_NAME: &'static str = "MSG_GLO_BIASES"; + } + + impl SbpMessage for MsgGloBiases { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgGnssCapb { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgGnssCapb(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgGloBiases { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgGloBiases(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgGnssCapb { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.t_nmct) + WireFormat::len(&self.gc) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.t_nmct, buf); - WireFormat::write(&self.gc, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgGnssCapb { - sender_id: None, - t_nmct: WireFormat::parse_unchecked(buf), - gc: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgGloBiases { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.mask) + + WireFormat::len(&self.l1ca_bias) + + WireFormat::len(&self.l1p_bias) + + WireFormat::len(&self.l2ca_bias) + + WireFormat::len(&self.l2p_bias) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Group Delay -/// -/// Please see ICD-GPS-200 (30.3.3.3.1.1) for more details. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgGroupDelay { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, - /// Data Predict Time of Week - #[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 ConcreteMessage for MsgGroupDelay { - const MESSAGE_TYPE: u16 = 148; - const MESSAGE_NAME: &'static str = "MSG_GROUP_DELAY"; -} +pub mod msg_gnss_capb { + #![allow(unused_imports)] -impl SbpMessage for MsgGroupDelay { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + /// GNSS capabilities + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgGnssCapb { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + /// Navigation Message Correction Table Validity Time + #[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, } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } -} -impl TryFrom for MsgGroupDelay { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgGroupDelay(m) => Ok(m), - _ => Err(TryFromSbpError), - } + impl ConcreteMessage for MsgGnssCapb { + const MESSAGE_TYPE: u16 = 150; + const MESSAGE_NAME: &'static str = "MSG_GNSS_CAPB"; } -} -impl WireFormat for MsgGroupDelay { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.t_op) - + WireFormat::len(&self.sid) - + WireFormat::len(&self.valid) - + WireFormat::len(&self.tgd) - + WireFormat::len(&self.isc_l1ca) - + WireFormat::len(&self.isc_l2c) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl SbpMessage for MsgGnssCapb { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} - -/// Group Delay -/// -/// Please see ICD-GPS-200 (30.3.3.3.1.1) for more details. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgGroupDelayDepA { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, - /// Data Predict Time of Week - #[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 ConcreteMessage for MsgGroupDelayDepA { - const MESSAGE_TYPE: u16 = 146; - const MESSAGE_NAME: &'static str = "MSG_GROUP_DELAY_DEP_A"; -} -impl SbpMessage for MsgGroupDelayDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl TryFrom for MsgGnssCapb { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgGnssCapb(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } -} -impl TryFrom for MsgGroupDelayDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgGroupDelayDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl WireFormat for MsgGnssCapb { + const MIN_LEN: usize = + ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.t_nmct) + WireFormat::len(&self.gc) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.t_nmct, buf); + WireFormat::write(&self.gc, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgGnssCapb { + sender_id: None, + t_nmct: WireFormat::parse_unchecked(buf), + gc: WireFormat::parse_unchecked(buf), + } } } } -impl WireFormat for MsgGroupDelayDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.t_op) - + WireFormat::len(&self.prn) - + WireFormat::len(&self.valid) - + WireFormat::len(&self.tgd) - + WireFormat::len(&self.isc_l1ca) - + WireFormat::len(&self.isc_l2c) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), +pub mod msg_group_delay { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Group Delay + /// + /// Please see ICD-GPS-200 (30.3.3.3.1.1) for more details. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgGroupDelay { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + /// Data Predict Time of Week + #[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 ConcreteMessage for MsgGroupDelay { + const MESSAGE_TYPE: u16 = 148; + const MESSAGE_NAME: &'static str = "MSG_GROUP_DELAY"; + } + + impl SbpMessage for MsgGroupDelay { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} - -/// Group Delay -/// -/// Please see ICD-GPS-200 (30.3.3.3.1.1) for more details. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgGroupDelayDepB { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, - /// Data Predict Time of Week - #[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 ConcreteMessage for MsgGroupDelayDepB { - const MESSAGE_TYPE: u16 = 147; - const MESSAGE_NAME: &'static str = "MSG_GROUP_DELAY_DEP_B"; -} -impl SbpMessage for MsgGroupDelayDepB { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl TryFrom for MsgGroupDelay { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgGroupDelay(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } -} -impl TryFrom for MsgGroupDelayDepB { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgGroupDelayDepB(m) => Ok(m), - _ => Err(TryFromSbpError), + impl WireFormat for MsgGroupDelay { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.t_op) + + WireFormat::len(&self.sid) + + WireFormat::len(&self.valid) + + WireFormat::len(&self.tgd) + + WireFormat::len(&self.isc_l1ca) + + WireFormat::len(&self.isc_l2c) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -impl WireFormat for MsgGroupDelayDepB { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.t_op) - + WireFormat::len(&self.sid) - + WireFormat::len(&self.valid) - + WireFormat::len(&self.tgd) - + WireFormat::len(&self.isc_l1ca) - + WireFormat::len(&self.isc_l2c) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), +pub mod msg_group_delay_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Group Delay + /// + /// Please see ICD-GPS-200 (30.3.3.3.1.1) for more details. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgGroupDelayDepA { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + /// Data Predict Time of Week + #[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 ConcreteMessage for MsgGroupDelayDepA { + const MESSAGE_TYPE: u16 = 146; + const MESSAGE_NAME: &'static str = "MSG_GROUP_DELAY_DEP_A"; + } + + impl SbpMessage for MsgGroupDelayDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} - -/// Iono corrections -/// -/// The ionospheric parameters which allow the "L1 only" or "L2 only" user to -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgIono { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, - /// Navigation Message Correction Table Validity Time - #[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 ConcreteMessage for MsgIono { - const MESSAGE_TYPE: u16 = 144; - const MESSAGE_NAME: &'static str = "MSG_IONO"; -} -impl SbpMessage for MsgIono { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl TryFrom for MsgGroupDelayDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgGroupDelayDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } -} -impl TryFrom for MsgIono { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgIono(m) => Ok(m), - _ => Err(TryFromSbpError), + impl WireFormat for MsgGroupDelayDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.t_op) + + WireFormat::len(&self.prn) + + WireFormat::len(&self.valid) + + WireFormat::len(&self.tgd) + + WireFormat::len(&self.isc_l1ca) + + WireFormat::len(&self.isc_l2c) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -impl WireFormat for MsgIono { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.t_nmct) - + WireFormat::len(&self.a0) - + WireFormat::len(&self.a1) - + WireFormat::len(&self.a2) - + WireFormat::len(&self.a3) - + WireFormat::len(&self.b0) - + WireFormat::len(&self.b1) - + WireFormat::len(&self.b2) - + WireFormat::len(&self.b3) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), +pub mod msg_group_delay_dep_b { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Group Delay + /// + /// Please see ICD-GPS-200 (30.3.3.3.1.1) for more details. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgGroupDelayDepB { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + /// Data Predict Time of Week + #[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 ConcreteMessage for MsgGroupDelayDepB { + const MESSAGE_TYPE: u16 = 147; + const MESSAGE_NAME: &'static str = "MSG_GROUP_DELAY_DEP_B"; + } + + impl SbpMessage for MsgGroupDelayDepB { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} - -/// GPS satellite observations -/// -/// The GPS observations message reports all the raw pseudorange and carrier -/// phase observations for the satellites being tracked by the device. Carrier -/// phase observation here is represented as a 40-bit fixed point number with -/// Q32.8 layout (i.e. 32-bits of whole cycles and 8-bits of fractional -/// cycles). The observations are be interoperable with 3rd party receivers -/// and conform with typical RTCMv3 GNSS observations. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgObs { - /// 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 ConcreteMessage for MsgObs { - const MESSAGE_TYPE: u16 = 74; - const MESSAGE_NAME: &'static str = "MSG_OBS"; -} -impl SbpMessage for MsgObs { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.header.t.tow as f64) / 1000.0; - let wn: i16 = match self.header.t.wn.try_into() { - Ok(wn) => wn, - Err(e) => return Some(Err(e.into())), - }; - let gps_time = match time::GpsTime::new(wn, tow_s) { - Ok(gps_time) => gps_time, - Err(e) => return Some(Err(e.into())), - }; - Some(Ok(time::MessageTime::Base(gps_time.into()))) + impl TryFrom for MsgGroupDelayDepB { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgGroupDelayDepB(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } -} -impl TryFrom for MsgObs { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgObs(m) => Ok(m), - _ => Err(TryFromSbpError), + impl WireFormat for MsgGroupDelayDepB { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.t_op) + + WireFormat::len(&self.sid) + + WireFormat::len(&self.valid) + + WireFormat::len(&self.tgd) + + WireFormat::len(&self.isc_l1ca) + + WireFormat::len(&self.isc_l2c) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -impl WireFormat for MsgObs { - const MIN_LEN: usize = - ::MIN_LEN + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.header) + WireFormat::len(&self.obs) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.header, buf); - WireFormat::write(&self.obs, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgObs { - sender_id: None, - header: WireFormat::parse_unchecked(buf), - obs: WireFormat::parse_unchecked(buf), +pub mod msg_iono { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Iono corrections + /// + /// The ionospheric parameters which allow the "L1 only" or "L2 only" user to + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgIono { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + /// Navigation Message Correction Table Validity Time + #[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 ConcreteMessage for MsgIono { + const MESSAGE_TYPE: u16 = 144; + const MESSAGE_NAME: &'static str = "MSG_IONO"; + } + + impl SbpMessage for MsgIono { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgObsDepA { - /// 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 ConcreteMessage for MsgObsDepA { - const MESSAGE_TYPE: u16 = 69; - const MESSAGE_NAME: &'static str = "MSG_OBS_DEP_A"; -} - -impl SbpMessage for MsgObsDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.header.t.tow as f64) / 1000.0; - let wn: i16 = match self.header.t.wn.try_into() { - Ok(wn) => wn, - Err(e) => return Some(Err(e.into())), - }; - let gps_time = match time::GpsTime::new(wn, tow_s) { - Ok(gps_time) => gps_time, - Err(e) => return Some(Err(e.into())), - }; - Some(Ok(time::MessageTime::Rover(gps_time.into()))) + impl TryFrom for MsgIono { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgIono(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } -} -impl TryFrom for MsgObsDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgObsDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl WireFormat for MsgIono { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.t_nmct) + + WireFormat::len(&self.a0) + + WireFormat::len(&self.a1) + + WireFormat::len(&self.a2) + + WireFormat::len(&self.a3) + + WireFormat::len(&self.b0) + + WireFormat::len(&self.b1) + + WireFormat::len(&self.b2) + + WireFormat::len(&self.b3) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -impl WireFormat for MsgObsDepA { - const MIN_LEN: usize = ::MIN_LEN - + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.header) + WireFormat::len(&self.obs) +pub mod msg_obs { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// GPS satellite observations + /// + /// The GPS observations message reports all the raw pseudorange and carrier + /// phase observations for the satellites being tracked by the device. Carrier + /// phase observation here is represented as a 40-bit fixed point number with + /// Q32.8 layout (i.e. 32-bits of whole cycles and 8-bits of fractional + /// cycles). The observations are be interoperable with 3rd party receivers + /// and conform with typical RTCMv3 GNSS observations. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgObs { + /// 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 ConcreteMessage for MsgObs { + const MESSAGE_TYPE: u16 = 74; + const MESSAGE_NAME: &'static str = "MSG_OBS"; + } + + impl SbpMessage for MsgObs { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.header.t.tow as f64) / 1000.0; + let wn: i16 = match self.header.t.wn.try_into() { + Ok(wn) => wn, + Err(e) => return Some(Err(e.into())), + }; + let gps_time = match time::GpsTime::new(wn, tow_s) { + Ok(gps_time) => gps_time, + Err(e) => return Some(Err(e.into())), + }; + Some(Ok(time::MessageTime::Base(gps_time.into()))) + } } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.header, buf); - WireFormat::write(&self.obs, buf); + + impl TryFrom for MsgObs { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgObs(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgObsDepA { - sender_id: None, - header: WireFormat::parse_unchecked(buf), - obs: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgObs { + const MIN_LEN: usize = ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.header) + WireFormat::len(&self.obs) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.header, buf); + WireFormat::write(&self.obs, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgObs { + sender_id: None, + header: WireFormat::parse_unchecked(buf), + obs: WireFormat::parse_unchecked(buf), + } } } } -/// Deprecated -/// -/// This observation message has been deprecated in favor of observations that -/// are more interoperable. This message should be used for observations -/// referenced to a nominal pseudorange which are not interoperable with most -/// 3rd party GNSS receivers or typical RTCMv3 observations. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgObsDepB { - /// 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, -} +pub mod msg_obs_dep_a { + #![allow(unused_imports)] -impl ConcreteMessage for MsgObsDepB { - const MESSAGE_TYPE: u16 = 67; - const MESSAGE_NAME: &'static str = "MSG_OBS_DEP_B"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgObsDepB { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE + /// Deprecated + /// + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgObsDepA { + /// 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, } - fn sender_id(&self) -> Option { - self.sender_id - } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.header.t.tow as f64) / 1000.0; - let wn: i16 = match self.header.t.wn.try_into() { - Ok(wn) => wn, - Err(e) => return Some(Err(e.into())), - }; - let gps_time = match time::GpsTime::new(wn, tow_s) { - Ok(gps_time) => gps_time, - Err(e) => return Some(Err(e.into())), - }; - Some(Ok(time::MessageTime::Rover(gps_time.into()))) + + impl ConcreteMessage for MsgObsDepA { + const MESSAGE_TYPE: u16 = 69; + const MESSAGE_NAME: &'static str = "MSG_OBS_DEP_A"; } -} -impl TryFrom for MsgObsDepB { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgObsDepB(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgObsDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.header.t.tow as f64) / 1000.0; + let wn: i16 = match self.header.t.wn.try_into() { + Ok(wn) => wn, + Err(e) => return Some(Err(e.into())), + }; + let gps_time = match time::GpsTime::new(wn, tow_s) { + Ok(gps_time) => gps_time, + Err(e) => return Some(Err(e.into())), + }; + Some(Ok(time::MessageTime::Rover(gps_time.into()))) } } -} -impl WireFormat for MsgObsDepB { - const MIN_LEN: usize = ::MIN_LEN - + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.header) + WireFormat::len(&self.obs) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.header, buf); - WireFormat::write(&self.obs, buf); + impl TryFrom for MsgObsDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgObsDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgObsDepB { - sender_id: None, - header: WireFormat::parse_unchecked(buf), - obs: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgObsDepA { + const MIN_LEN: usize = ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.header) + WireFormat::len(&self.obs) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.header, buf); + WireFormat::write(&self.obs, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgObsDepA { + sender_id: None, + header: WireFormat::parse_unchecked(buf), + obs: WireFormat::parse_unchecked(buf), + } } } } -/// Deprecated -/// -/// The GPS observations message reports all the raw pseudorange and carrier -/// phase observations for the satellites being tracked by the device. Carrier -/// phase observation here is represented as a 40-bit fixed point number with -/// Q32.8 layout (i.e. 32-bits of whole cycles and 8-bits of fractional -/// cycles). The observations are interoperable with 3rd party receivers and -/// conform with typical RTCMv3 GNSS observations. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgObsDepC { - /// 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, -} +pub mod msg_obs_dep_b { + #![allow(unused_imports)] -impl ConcreteMessage for MsgObsDepC { - const MESSAGE_TYPE: u16 = 73; - const MESSAGE_NAME: &'static str = "MSG_OBS_DEP_C"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgObsDepC { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE + /// Deprecated + /// + /// This observation message has been deprecated in favor of observations that + /// are more interoperable. This message should be used for observations + /// referenced to a nominal pseudorange which are not interoperable with most + /// 3rd party GNSS receivers or typical RTCMv3 observations. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgObsDepB { + /// 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, } - fn sender_id(&self) -> Option { - self.sender_id - } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); + + impl ConcreteMessage for MsgObsDepB { + const MESSAGE_TYPE: u16 = 67; + const MESSAGE_NAME: &'static str = "MSG_OBS_DEP_B"; } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl SbpMessage for MsgObsDepB { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.header.t.tow as f64) / 1000.0; + let wn: i16 = match self.header.t.wn.try_into() { + Ok(wn) => wn, + Err(e) => return Some(Err(e.into())), + }; + let gps_time = match time::GpsTime::new(wn, tow_s) { + Ok(gps_time) => gps_time, + Err(e) => return Some(Err(e.into())), + }; + Some(Ok(time::MessageTime::Rover(gps_time.into()))) + } } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.header.t.tow as f64) / 1000.0; - let wn: i16 = match self.header.t.wn.try_into() { - Ok(wn) => wn, - Err(e) => return Some(Err(e.into())), - }; - let gps_time = match time::GpsTime::new(wn, tow_s) { - Ok(gps_time) => gps_time, - Err(e) => return Some(Err(e.into())), - }; - Some(Ok(time::MessageTime::Rover(gps_time.into()))) + + impl TryFrom for MsgObsDepB { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgObsDepB(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } -} -impl TryFrom for MsgObsDepC { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgObsDepC(m) => Ok(m), - _ => Err(TryFromSbpError), + impl WireFormat for MsgObsDepB { + const MIN_LEN: usize = ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.header) + WireFormat::len(&self.obs) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.header, buf); + WireFormat::write(&self.obs, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgObsDepB { + sender_id: None, + header: WireFormat::parse_unchecked(buf), + obs: WireFormat::parse_unchecked(buf), + } } } } -impl WireFormat for MsgObsDepC { - const MIN_LEN: usize = ::MIN_LEN - + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.header) + WireFormat::len(&self.obs) +pub mod msg_obs_dep_c { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Deprecated + /// + /// The GPS observations message reports all the raw pseudorange and carrier + /// phase observations for the satellites being tracked by the device. Carrier + /// phase observation here is represented as a 40-bit fixed point number with + /// Q32.8 layout (i.e. 32-bits of whole cycles and 8-bits of fractional + /// cycles). The observations are interoperable with 3rd party receivers and + /// conform with typical RTCMv3 GNSS observations. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgObsDepC { + /// 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 ConcreteMessage for MsgObsDepC { + const MESSAGE_TYPE: u16 = 73; + const MESSAGE_NAME: &'static str = "MSG_OBS_DEP_C"; + } + + impl SbpMessage for MsgObsDepC { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.header.t.tow as f64) / 1000.0; + let wn: i16 = match self.header.t.wn.try_into() { + Ok(wn) => wn, + Err(e) => return Some(Err(e.into())), + }; + let gps_time = match time::GpsTime::new(wn, tow_s) { + Ok(gps_time) => gps_time, + Err(e) => return Some(Err(e.into())), + }; + Some(Ok(time::MessageTime::Rover(gps_time.into()))) + } } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.header, buf); - WireFormat::write(&self.obs, buf); + + impl TryFrom for MsgObsDepC { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgObsDepC(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgObsDepC { - sender_id: None, - header: WireFormat::parse_unchecked(buf), - obs: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgObsDepC { + const MIN_LEN: usize = ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.header) + WireFormat::len(&self.obs) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.header, buf); + WireFormat::write(&self.obs, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgObsDepC { + sender_id: None, + header: WireFormat::parse_unchecked(buf), + obs: WireFormat::parse_unchecked(buf), + } } } } -/// OSR corrections -/// -/// The OSR message contains network corrections in an observation-like -/// format. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgOsr { - /// 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, -} +pub mod msg_osr { + #![allow(unused_imports)] -impl ConcreteMessage for MsgOsr { - const MESSAGE_TYPE: u16 = 1600; - const MESSAGE_NAME: &'static str = "MSG_OSR"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgOsr { - 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); + /// OSR corrections + /// + /// The OSR message contains network corrections in an observation-like + /// format. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgOsr { + /// 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, } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.header.t.tow as f64) / 1000.0; - let wn: i16 = match self.header.t.wn.try_into() { - Ok(wn) => wn, - Err(e) => return Some(Err(e.into())), - }; - let gps_time = match time::GpsTime::new(wn, tow_s) { - Ok(gps_time) => gps_time, - Err(e) => return Some(Err(e.into())), - }; - Some(Ok(time::MessageTime::Base(gps_time.into()))) + + impl ConcreteMessage for MsgOsr { + const MESSAGE_TYPE: u16 = 1600; + const MESSAGE_NAME: &'static str = "MSG_OSR"; } -} -impl TryFrom for MsgOsr { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgOsr(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgOsr { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.header.t.tow as f64) / 1000.0; + let wn: i16 = match self.header.t.wn.try_into() { + Ok(wn) => wn, + Err(e) => return Some(Err(e.into())), + }; + let gps_time = match time::GpsTime::new(wn, tow_s) { + Ok(gps_time) => gps_time, + Err(e) => return Some(Err(e.into())), + }; + Some(Ok(time::MessageTime::Base(gps_time.into()))) } } -} -impl WireFormat for MsgOsr { - const MIN_LEN: usize = - ::MIN_LEN + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.header) + WireFormat::len(&self.obs) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.header, buf); - WireFormat::write(&self.obs, buf); + impl TryFrom for MsgOsr { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgOsr(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgOsr { - sender_id: None, - header: WireFormat::parse_unchecked(buf), - obs: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgOsr { + const MIN_LEN: usize = ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.header) + WireFormat::len(&self.obs) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.header, buf); + WireFormat::write(&self.obs, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgOsr { + sender_id: None, + header: WireFormat::parse_unchecked(buf), + obs: WireFormat::parse_unchecked(buf), + } } } } -/// Satellite azimuths and elevations -/// -/// Azimuth and elevation angles of all the visible satellites that the device -/// does have ephemeris or almanac for. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSvAzEl { - /// 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, -} +pub mod msg_sv_az_el { + #![allow(unused_imports)] -impl ConcreteMessage for MsgSvAzEl { - const MESSAGE_TYPE: u16 = 151; - const MESSAGE_NAME: &'static str = "MSG_SV_AZ_EL"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgSvAzEl { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + /// Satellite azimuths and elevations + /// + /// Azimuth and elevation angles of all the visible satellites that the device + /// does have ephemeris or almanac for. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSvAzEl { + /// 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, } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgSvAzEl { + const MESSAGE_TYPE: u16 = 151; + const MESSAGE_NAME: &'static str = "MSG_SV_AZ_EL"; } -} -impl TryFrom for MsgSvAzEl { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSvAzEl(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgSvAzEl { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgSvAzEl { - const MIN_LEN: usize = as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.azel) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.azel, buf); + impl TryFrom for MsgSvAzEl { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSvAzEl(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgSvAzEl { - sender_id: None, - azel: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgSvAzEl { + const MIN_LEN: usize = as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.azel) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.azel, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgSvAzEl { + sender_id: None, + azel: WireFormat::parse_unchecked(buf), + } } } } -/// L2C capability mask -/// -/// Please see ICD-GPS-200 (Chapter 20.3.3.5.1.4) for more details. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSvConfigurationGpsDep { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, - /// Navigation Message Correction Table Validity Time - #[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, -} +pub mod msg_sv_configuration_gps_dep { + #![allow(unused_imports)] -impl ConcreteMessage for MsgSvConfigurationGpsDep { - const MESSAGE_TYPE: u16 = 145; - const MESSAGE_NAME: &'static str = "MSG_SV_CONFIGURATION_GPS_DEP"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgSvConfigurationGpsDep { - 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); + /// L2C capability mask + /// + /// Please see ICD-GPS-200 (Chapter 20.3.3.5.1.4) for more details. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSvConfigurationGpsDep { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + /// Navigation Message Correction Table Validity Time + #[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, } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgSvConfigurationGpsDep { + const MESSAGE_TYPE: u16 = 145; + const MESSAGE_NAME: &'static str = "MSG_SV_CONFIGURATION_GPS_DEP"; } -} -impl TryFrom for MsgSvConfigurationGpsDep { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSvConfigurationGpsDep(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgSvConfigurationGpsDep { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgSvConfigurationGpsDep { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.t_nmct) + WireFormat::len(&self.l2c_mask) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.t_nmct, buf); - WireFormat::write(&self.l2c_mask, buf); + impl TryFrom for MsgSvConfigurationGpsDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSvConfigurationGpsDep(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgSvConfigurationGpsDep { - sender_id: None, - t_nmct: WireFormat::parse_unchecked(buf), - l2c_mask: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgSvConfigurationGpsDep { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.t_nmct) + WireFormat::len(&self.l2c_mask) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.t_nmct, buf); + WireFormat::write(&self.l2c_mask, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgSvConfigurationGpsDep { + sender_id: None, + t_nmct: WireFormat::parse_unchecked(buf), + l2c_mask: WireFormat::parse_unchecked(buf), + } } } } -/// Header for observation message -/// -/// Header of a GNSS observation message. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct ObservationHeader { - /// GNSS time of this observation - #[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, -} +pub mod observation_header { + #![allow(unused_imports)] -impl WireFormat for ObservationHeader { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.t) + WireFormat::len(&self.n_obs) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.t, buf); - WireFormat::write(&self.n_obs, buf); + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Header for observation message + /// + /// Header of a GNSS observation message. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct ObservationHeader { + /// GNSS time of this observation + #[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, } - fn parse_unchecked(buf: &mut B) -> Self { - ObservationHeader { - t: WireFormat::parse_unchecked(buf), - n_obs: WireFormat::parse_unchecked(buf), + + impl WireFormat for ObservationHeader { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.t) + WireFormat::len(&self.n_obs) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.t, buf); + WireFormat::write(&self.n_obs, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + ObservationHeader { + t: WireFormat::parse_unchecked(buf), + n_obs: WireFormat::parse_unchecked(buf), + } } } } -/// Header for observation message -/// -/// Header of a GPS observation message. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct ObservationHeaderDep { - /// GPS time of this observation - #[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, -} +pub mod observation_header_dep { + #![allow(unused_imports)] -impl WireFormat for ObservationHeaderDep { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.t) + WireFormat::len(&self.n_obs) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.t, buf); - WireFormat::write(&self.n_obs, buf); + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Header for observation message + /// + /// Header of a GPS observation message. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct ObservationHeaderDep { + /// GPS time of this observation + #[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, } - fn parse_unchecked(buf: &mut B) -> Self { - ObservationHeaderDep { - t: WireFormat::parse_unchecked(buf), - n_obs: WireFormat::parse_unchecked(buf), + + impl WireFormat for ObservationHeaderDep { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.t) + WireFormat::len(&self.n_obs) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.t, buf); + WireFormat::write(&self.n_obs, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + ObservationHeaderDep { + t: WireFormat::parse_unchecked(buf), + n_obs: WireFormat::parse_unchecked(buf), + } } } } -/// GNSS observations for a particular satellite signal -/// -/// Pseudorange and carrier phase observation for a satellite being tracked. -/// The observations are interoperable with 3rd party receivers and conform -/// with typical RTCM 3.1 message GPS/GLO observations. -/// -/// Carrier phase observations are not guaranteed to be aligned to the RINEX 3 -/// or RTCM 3.3 MSM reference signal and no 1/4 cycle adjustments are -/// currently performed. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct PackedObsContent { - /// Pseudorange observation - #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] - pub p: u32, - /// Carrier phase observation with typical sign convention. - #[cfg_attr(feature = "serde", serde(rename(serialize = "L")))] - pub l: CarrierPhase, - /// Doppler observation with typical sign convention. - #[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 - /// 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, - /// 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, -} +pub mod packed_obs_content { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl PackedObsContent { - pub fn raim_exclusion(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 7, 0) { - 0 => Some(PackedObsContentRaimExclusion::NoExclusion), - 1 => Some(PackedObsContentRaimExclusion::MeasurementWasExcludedBySppRaimUseWithCare), - _ => None, + /// GNSS observations for a particular satellite signal + /// + /// Pseudorange and carrier phase observation for a satellite being tracked. + /// The observations are interoperable with 3rd party receivers and conform + /// with typical RTCM 3.1 message GPS/GLO observations. + /// + /// Carrier phase observations are not guaranteed to be aligned to the RINEX 3 + /// or RTCM 3.3 MSM reference signal and no 1/4 cycle adjustments are + /// currently performed. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct PackedObsContent { + /// Pseudorange observation + #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] + pub p: u32, + /// Carrier phase observation with typical sign convention. + #[cfg_attr(feature = "serde", serde(rename(serialize = "L")))] + pub l: CarrierPhase, + /// Doppler observation with typical sign convention. + #[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 + /// 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, + /// 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 { + pub fn raim_exclusion(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 7, 0) { + 0 => Some(RaimExclusion::NoExclusion), + 1 => Some(RaimExclusion::MeasurementWasExcludedBySppRaimUseWithCare), + _ => None, + } } - } - pub fn set_raim_exclusion(&mut self, raim_exclusion: PackedObsContentRaimExclusion) { - set_bit_range!(&mut self.flags, raim_exclusion, u8, u8, 7, 0); - } + pub fn set_raim_exclusion(&mut self, raim_exclusion: RaimExclusion) { + set_bit_range!(&mut self.flags, raim_exclusion, u8, u8, 7, 0); + } - pub fn doppler_valid(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 0) { - 0 => Some(PackedObsContentDopplerValid::InvalidDopplerMeasurement), - 1 => Some(PackedObsContentDopplerValid::ValidDopplerMeasurement), - _ => None, + pub fn doppler_valid(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 0) { + 0 => Some(DopplerValid::InvalidDopplerMeasurement), + 1 => Some(DopplerValid::ValidDopplerMeasurement), + _ => None, + } } - } - pub fn set_doppler_valid(&mut self, doppler_valid: PackedObsContentDopplerValid) { - set_bit_range!(&mut self.flags, doppler_valid, u8, u8, 3, 0); - } + pub fn set_doppler_valid(&mut self, doppler_valid: DopplerValid) { + set_bit_range!(&mut self.flags, doppler_valid, u8, u8, 3, 0); + } - pub fn halfcycle_ambiguity(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(PackedObsContentHalfCycleAmbiguity::HalfCyclePhaseAmbiguityUnresolved), - 1 => Some(PackedObsContentHalfCycleAmbiguity::HalfCyclePhaseAmbiguityResolved), - _ => None, + pub fn halfcycle_ambiguity(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(HalfCycleAmbiguity::HalfCyclePhaseAmbiguityUnresolved), + 1 => Some(HalfCycleAmbiguity::HalfCyclePhaseAmbiguityResolved), + _ => None, + } } - } - pub fn set_halfcycle_ambiguity( - &mut self, - halfcycle_ambiguity: PackedObsContentHalfCycleAmbiguity, - ) { - set_bit_range!(&mut self.flags, halfcycle_ambiguity, u8, u8, 2, 0); - } + pub fn set_halfcycle_ambiguity(&mut self, halfcycle_ambiguity: HalfCycleAmbiguity) { + set_bit_range!(&mut self.flags, halfcycle_ambiguity, u8, u8, 2, 0); + } - pub fn carrier_phase_valid(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 1, 0) { - 0 => Some(PackedObsContentCarrierPhaseValid::InvalidCarrierPhaseMeasurement), - 1 => Some(PackedObsContentCarrierPhaseValid::ValidCarrierPhaseMeasurement), - _ => None, + pub fn carrier_phase_valid(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 1, 0) { + 0 => Some(CarrierPhaseValid::InvalidCarrierPhaseMeasurement), + 1 => Some(CarrierPhaseValid::ValidCarrierPhaseMeasurement), + _ => None, + } } - } - pub fn set_carrier_phase_valid( - &mut self, - carrier_phase_valid: PackedObsContentCarrierPhaseValid, - ) { - set_bit_range!(&mut self.flags, carrier_phase_valid, u8, u8, 1, 0); - } + pub fn set_carrier_phase_valid(&mut self, carrier_phase_valid: CarrierPhaseValid) { + set_bit_range!(&mut self.flags, carrier_phase_valid, u8, u8, 1, 0); + } - pub fn pseudorange_valid(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 0, 0) { - 0 => Some(PackedObsContentPseudorangeValid::InvalidPseudorangeMeasurement), - 1 => Some( - PackedObsContentPseudorangeValid::ValidPseudorangeMeasurementAndCoarseTowDecoded, - ), - _ => None, + pub fn pseudorange_valid(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 0, 0) { + 0 => Some(PseudorangeValid::InvalidPseudorangeMeasurement), + 1 => Some(PseudorangeValid::ValidPseudorangeMeasurementAndCoarseTowDecoded), + _ => None, + } } - } - pub fn set_pseudorange_valid(&mut self, pseudorange_valid: PackedObsContentPseudorangeValid) { - set_bit_range!(&mut self.flags, pseudorange_valid, u8, u8, 0, 0); + pub fn set_pseudorange_valid(&mut self, pseudorange_valid: PseudorangeValid) { + set_bit_range!(&mut self.flags, pseudorange_valid, u8, u8, 0, 0); + } } -} -impl WireFormat for PackedObsContent { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.p) - + WireFormat::len(&self.l) - + WireFormat::len(&self.d) - + WireFormat::len(&self.cn0) - + WireFormat::len(&self.lock) - + WireFormat::len(&self.flags) - + WireFormat::len(&self.sid) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for PackedObsContent { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.p) + + WireFormat::len(&self.l) + + WireFormat::len(&self.d) + + WireFormat::len(&self.cn0) + + WireFormat::len(&self.lock) + + WireFormat::len(&self.flags) + + WireFormat::len(&self.sid) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// RAIM exclusion -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum PackedObsContentRaimExclusion { - /// No exclusion - NoExclusion = 0, + /// RAIM exclusion + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum RaimExclusion { + /// No exclusion + NoExclusion = 0, - /// Measurement was excluded by SPP RAIM, use with care - MeasurementWasExcludedBySppRaimUseWithCare = 1, -} + /// Measurement was excluded by SPP RAIM, use with care + MeasurementWasExcludedBySppRaimUseWithCare = 1, + } -impl std::fmt::Display for PackedObsContentRaimExclusion { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - PackedObsContentRaimExclusion::NoExclusion => f.write_str("No exclusion"), - PackedObsContentRaimExclusion::MeasurementWasExcludedBySppRaimUseWithCare => { - f.write_str("Measurement was excluded by SPP RAIM, use with care") + impl std::fmt::Display for RaimExclusion { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + RaimExclusion::NoExclusion => f.write_str("No exclusion"), + RaimExclusion::MeasurementWasExcludedBySppRaimUseWithCare => { + f.write_str("Measurement was excluded by SPP RAIM, use with care") + } } } } -} -/// Doppler valid -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum PackedObsContentDopplerValid { - /// Invalid doppler measurement - InvalidDopplerMeasurement = 0, + /// Doppler valid + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum DopplerValid { + /// Invalid doppler measurement + InvalidDopplerMeasurement = 0, - /// Valid doppler measurement - ValidDopplerMeasurement = 1, -} + /// Valid doppler measurement + ValidDopplerMeasurement = 1, + } -impl std::fmt::Display for PackedObsContentDopplerValid { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - PackedObsContentDopplerValid::InvalidDopplerMeasurement => { - f.write_str("Invalid doppler measurement") - } - PackedObsContentDopplerValid::ValidDopplerMeasurement => { - f.write_str("Valid doppler measurement") + impl std::fmt::Display for DopplerValid { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + DopplerValid::InvalidDopplerMeasurement => { + f.write_str("Invalid doppler measurement") + } + DopplerValid::ValidDopplerMeasurement => f.write_str("Valid doppler measurement"), } } } -} -/// Half-cycle ambiguity -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum PackedObsContentHalfCycleAmbiguity { - /// Half cycle phase ambiguity unresolved - HalfCyclePhaseAmbiguityUnresolved = 0, + /// Half-cycle ambiguity + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum HalfCycleAmbiguity { + /// Half cycle phase ambiguity unresolved + HalfCyclePhaseAmbiguityUnresolved = 0, - /// Half cycle phase ambiguity resolved - HalfCyclePhaseAmbiguityResolved = 1, -} + /// Half cycle phase ambiguity resolved + HalfCyclePhaseAmbiguityResolved = 1, + } -impl std::fmt::Display for PackedObsContentHalfCycleAmbiguity { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - PackedObsContentHalfCycleAmbiguity::HalfCyclePhaseAmbiguityUnresolved => { - f.write_str("Half cycle phase ambiguity unresolved") - } - PackedObsContentHalfCycleAmbiguity::HalfCyclePhaseAmbiguityResolved => { - f.write_str("Half cycle phase ambiguity resolved") + impl std::fmt::Display for HalfCycleAmbiguity { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + HalfCycleAmbiguity::HalfCyclePhaseAmbiguityUnresolved => { + f.write_str("Half cycle phase ambiguity unresolved") + } + HalfCycleAmbiguity::HalfCyclePhaseAmbiguityResolved => { + f.write_str("Half cycle phase ambiguity resolved") + } } } } -} -/// Carrier phase valid -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum PackedObsContentCarrierPhaseValid { - /// Invalid carrier phase measurement - InvalidCarrierPhaseMeasurement = 0, + /// Carrier phase valid + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum CarrierPhaseValid { + /// Invalid carrier phase measurement + InvalidCarrierPhaseMeasurement = 0, - /// Valid carrier phase measurement - ValidCarrierPhaseMeasurement = 1, -} + /// Valid carrier phase measurement + ValidCarrierPhaseMeasurement = 1, + } -impl std::fmt::Display for PackedObsContentCarrierPhaseValid { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - PackedObsContentCarrierPhaseValid::InvalidCarrierPhaseMeasurement => { - f.write_str("Invalid carrier phase measurement") - } - PackedObsContentCarrierPhaseValid::ValidCarrierPhaseMeasurement => { - f.write_str("Valid carrier phase measurement") + impl std::fmt::Display for CarrierPhaseValid { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + CarrierPhaseValid::InvalidCarrierPhaseMeasurement => { + f.write_str("Invalid carrier phase measurement") + } + CarrierPhaseValid::ValidCarrierPhaseMeasurement => { + f.write_str("Valid carrier phase measurement") + } } } } -} -/// Pseudorange valid -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum PackedObsContentPseudorangeValid { - /// Invalid pseudorange measurement - InvalidPseudorangeMeasurement = 0, + /// Pseudorange valid + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum PseudorangeValid { + /// Invalid pseudorange measurement + InvalidPseudorangeMeasurement = 0, - /// Valid pseudorange measurement and coarse TOW decoded - ValidPseudorangeMeasurementAndCoarseTowDecoded = 1, -} + /// Valid pseudorange measurement and coarse TOW decoded + ValidPseudorangeMeasurementAndCoarseTowDecoded = 1, + } -impl std::fmt::Display for PackedObsContentPseudorangeValid { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - PackedObsContentPseudorangeValid::InvalidPseudorangeMeasurement => { - f.write_str("Invalid pseudorange measurement") - } - PackedObsContentPseudorangeValid::ValidPseudorangeMeasurementAndCoarseTowDecoded => { - f.write_str("Valid pseudorange measurement and coarse TOW decoded") + impl std::fmt::Display for PseudorangeValid { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + PseudorangeValid::InvalidPseudorangeMeasurement => { + f.write_str("Invalid pseudorange measurement") + } + PseudorangeValid::ValidPseudorangeMeasurementAndCoarseTowDecoded => { + f.write_str("Valid pseudorange measurement and coarse TOW decoded") + } } } } } -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct PackedObsContentDepA { - /// Pseudorange observation - #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] - pub p: u32, - /// Carrier phase observation with opposite sign from typical convention - #[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 WireFormat for PackedObsContentDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.p) - + WireFormat::len(&self.l) - + WireFormat::len(&self.cn0) - + WireFormat::len(&self.lock) - + WireFormat::len(&self.prn) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), +pub mod packed_obs_content_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Deprecated + /// + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct PackedObsContentDepA { + /// Pseudorange observation + #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] + pub p: u32, + /// Carrier phase observation with opposite sign from typical convention + #[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 WireFormat for PackedObsContentDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.p) + + WireFormat::len(&self.l) + + WireFormat::len(&self.cn0) + + WireFormat::len(&self.lock) + + WireFormat::len(&self.prn) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// GPS observations for a particular satellite signal -/// -/// Pseudorange and carrier phase observation for a satellite being tracked. -/// Pseudoranges are referenced to a nominal pseudorange. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct PackedObsContentDepB { - /// Pseudorange observation - #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] - pub p: u32, - /// Carrier phase observation with opposite sign from typical convention. - #[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, -} +pub mod packed_obs_content_dep_b { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl WireFormat for PackedObsContentDepB { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.p) - + WireFormat::len(&self.l) - + WireFormat::len(&self.cn0) - + WireFormat::len(&self.lock) - + WireFormat::len(&self.sid) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + /// GPS observations for a particular satellite signal + /// + /// Pseudorange and carrier phase observation for a satellite being tracked. + /// Pseudoranges are referenced to a nominal pseudorange. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct PackedObsContentDepB { + /// Pseudorange observation + #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] + pub p: u32, + /// Carrier phase observation with opposite sign from typical convention. + #[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 WireFormat for PackedObsContentDepB { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.p) + + WireFormat::len(&self.l) + + WireFormat::len(&self.cn0) + + WireFormat::len(&self.lock) + + WireFormat::len(&self.sid) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// GPS observations for a particular satellite signal -/// -/// Pseudorange and carrier phase observation for a satellite being tracked. -/// The observations are be interoperable with 3rd party receivers and conform -/// with typical RTCMv3 GNSS observations. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct PackedObsContentDepC { - /// Pseudorange observation - #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] - pub p: u32, - /// Carrier phase observation with typical sign convention. - #[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, -} +pub mod packed_obs_content_dep_c { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl WireFormat for PackedObsContentDepC { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.p) - + WireFormat::len(&self.l) - + WireFormat::len(&self.cn0) - + WireFormat::len(&self.lock) - + WireFormat::len(&self.sid) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + /// GPS observations for a particular satellite signal + /// + /// Pseudorange and carrier phase observation for a satellite being tracked. + /// The observations are be interoperable with 3rd party receivers and conform + /// with typical RTCMv3 GNSS observations. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct PackedObsContentDepC { + /// Pseudorange observation + #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] + pub p: u32, + /// Carrier phase observation with typical sign convention. + #[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 WireFormat for PackedObsContentDepC { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.p) + + WireFormat::len(&self.l) + + WireFormat::len(&self.cn0) + + WireFormat::len(&self.lock) + + WireFormat::len(&self.sid) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Network correction for a particular satellite signal -/// -/// Pseudorange and carrier phase network corrections for a satellite signal. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct PackedOsrContent { - /// Pseudorange observation - #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] - pub p: u32, - /// Carrier phase observation with typical sign convention. - #[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 { - pub fn invalid_phase_corrections(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 0) { - 0 => Some(PackedOsrContentInvalidPhaseCorrections::ValidPhaseCorrections), - 1 => Some(PackedOsrContentInvalidPhaseCorrections::DoNotUsePhaseCorrections), - _ => None, +pub mod packed_osr_content { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Network correction for a particular satellite signal + /// + /// Pseudorange and carrier phase network corrections for a satellite signal. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct PackedOsrContent { + /// Pseudorange observation + #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] + pub p: u32, + /// Carrier phase observation with typical sign convention. + #[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 { + pub fn invalid_phase_corrections(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 0) { + 0 => Some(InvalidPhaseCorrections::ValidPhaseCorrections), + 1 => Some(InvalidPhaseCorrections::DoNotUsePhaseCorrections), + _ => None, + } } - } - pub fn set_invalid_phase_corrections( - &mut self, - invalid_phase_corrections: PackedOsrContentInvalidPhaseCorrections, - ) { - set_bit_range!(&mut self.flags, invalid_phase_corrections, u8, u8, 4, 0); - } + pub fn set_invalid_phase_corrections( + &mut self, + invalid_phase_corrections: InvalidPhaseCorrections, + ) { + set_bit_range!(&mut self.flags, invalid_phase_corrections, u8, u8, 4, 0); + } - pub fn invalid_code_corrections(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 0) { - 0 => Some(PackedOsrContentInvalidCodeCorrections::ValidCodeCorrections), - 1 => Some(PackedOsrContentInvalidCodeCorrections::DoNotUseCodeCorrections), - _ => None, + pub fn invalid_code_corrections(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 0) { + 0 => Some(InvalidCodeCorrections::ValidCodeCorrections), + 1 => Some(InvalidCodeCorrections::DoNotUseCodeCorrections), + _ => None, + } } - } - pub fn set_invalid_code_corrections( - &mut self, - invalid_code_corrections: PackedOsrContentInvalidCodeCorrections, - ) { - set_bit_range!(&mut self.flags, invalid_code_corrections, u8, u8, 3, 0); - } + pub fn set_invalid_code_corrections( + &mut self, + invalid_code_corrections: InvalidCodeCorrections, + ) { + set_bit_range!(&mut self.flags, invalid_code_corrections, u8, u8, 3, 0); + } - pub fn full_fixing_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(PackedOsrContentFullFixingFlag::FullFixingUnavailable), - 1 => Some(PackedOsrContentFullFixingFlag::FullFixingAvailable), - _ => None, + pub fn full_fixing_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(FullFixingFlag::FullFixingUnavailable), + 1 => Some(FullFixingFlag::FullFixingAvailable), + _ => None, + } } - } - pub fn set_full_fixing_flag(&mut self, full_fixing_flag: PackedOsrContentFullFixingFlag) { - set_bit_range!(&mut self.flags, full_fixing_flag, u8, u8, 2, 0); - } + pub fn set_full_fixing_flag(&mut self, full_fixing_flag: FullFixingFlag) { + set_bit_range!(&mut self.flags, full_fixing_flag, u8, u8, 2, 0); + } - pub fn partial_fixing_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 1, 0) { - 0 => Some(PackedOsrContentPartialFixingFlag::PartialFixingUnavailable), - 1 => Some(PackedOsrContentPartialFixingFlag::PartialFixingAvailable), - _ => None, + pub fn partial_fixing_flag(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 1, 0) { + 0 => Some(PartialFixingFlag::PartialFixingUnavailable), + 1 => Some(PartialFixingFlag::PartialFixingAvailable), + _ => None, + } } - } - pub fn set_partial_fixing_flag( - &mut self, - partial_fixing_flag: PackedOsrContentPartialFixingFlag, - ) { - set_bit_range!(&mut self.flags, partial_fixing_flag, u8, u8, 1, 0); - } + pub fn set_partial_fixing_flag(&mut self, partial_fixing_flag: PartialFixingFlag) { + set_bit_range!(&mut self.flags, partial_fixing_flag, u8, u8, 1, 0); + } - pub fn correction_validity(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 0, 0) { - 0 => Some(PackedOsrContentCorrectionValidity::DoNotUseSignal), - 1 => Some(PackedOsrContentCorrectionValidity::ValidSignal), - _ => None, + pub fn correction_validity(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 0, 0) { + 0 => Some(CorrectionValidity::DoNotUseSignal), + 1 => Some(CorrectionValidity::ValidSignal), + _ => None, + } } - } - pub fn set_correction_validity( - &mut self, - correction_validity: PackedOsrContentCorrectionValidity, - ) { - set_bit_range!(&mut self.flags, correction_validity, u8, u8, 0, 0); + pub fn set_correction_validity(&mut self, correction_validity: CorrectionValidity) { + set_bit_range!(&mut self.flags, correction_validity, u8, u8, 0, 0); + } } -} -impl WireFormat for PackedOsrContent { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.p) - + WireFormat::len(&self.l) - + WireFormat::len(&self.lock) - + WireFormat::len(&self.flags) - + WireFormat::len(&self.sid) - + WireFormat::len(&self.iono_std) - + WireFormat::len(&self.tropo_std) - + WireFormat::len(&self.range_std) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for PackedOsrContent { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.p) + + WireFormat::len(&self.l) + + WireFormat::len(&self.lock) + + WireFormat::len(&self.flags) + + WireFormat::len(&self.sid) + + WireFormat::len(&self.iono_std) + + WireFormat::len(&self.tropo_std) + + WireFormat::len(&self.range_std) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Invalid phase corrections -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum PackedOsrContentInvalidPhaseCorrections { - /// Valid phase corrections - ValidPhaseCorrections = 0, + /// Invalid phase corrections + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum InvalidPhaseCorrections { + /// Valid phase corrections + ValidPhaseCorrections = 0, - /// Do not use phase corrections - DoNotUsePhaseCorrections = 1, -} + /// Do not use phase corrections + DoNotUsePhaseCorrections = 1, + } -impl std::fmt::Display for PackedOsrContentInvalidPhaseCorrections { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - PackedOsrContentInvalidPhaseCorrections::ValidPhaseCorrections => { - f.write_str("Valid phase corrections") - } - PackedOsrContentInvalidPhaseCorrections::DoNotUsePhaseCorrections => { - f.write_str("Do not use phase corrections") + impl std::fmt::Display for InvalidPhaseCorrections { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + InvalidPhaseCorrections::ValidPhaseCorrections => { + f.write_str("Valid phase corrections") + } + InvalidPhaseCorrections::DoNotUsePhaseCorrections => { + f.write_str("Do not use phase corrections") + } } } } -} -/// Invalid code corrections -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum PackedOsrContentInvalidCodeCorrections { - /// Valid code corrections - ValidCodeCorrections = 0, + /// Invalid code corrections + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum InvalidCodeCorrections { + /// Valid code corrections + ValidCodeCorrections = 0, - /// Do not use code corrections - DoNotUseCodeCorrections = 1, -} + /// Do not use code corrections + DoNotUseCodeCorrections = 1, + } -impl std::fmt::Display for PackedOsrContentInvalidCodeCorrections { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - PackedOsrContentInvalidCodeCorrections::ValidCodeCorrections => { - f.write_str("Valid code corrections") - } - PackedOsrContentInvalidCodeCorrections::DoNotUseCodeCorrections => { - f.write_str("Do not use code corrections") + impl std::fmt::Display for InvalidCodeCorrections { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + InvalidCodeCorrections::ValidCodeCorrections => { + f.write_str("Valid code corrections") + } + InvalidCodeCorrections::DoNotUseCodeCorrections => { + f.write_str("Do not use code corrections") + } } } } -} -/// Full fixing flag -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum PackedOsrContentFullFixingFlag { - /// Full fixing unavailable - FullFixingUnavailable = 0, + /// Full fixing flag + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FullFixingFlag { + /// Full fixing unavailable + FullFixingUnavailable = 0, - /// Full fixing available - FullFixingAvailable = 1, -} + /// Full fixing available + FullFixingAvailable = 1, + } -impl std::fmt::Display for PackedOsrContentFullFixingFlag { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - PackedOsrContentFullFixingFlag::FullFixingUnavailable => { - f.write_str("Full fixing unavailable") - } - PackedOsrContentFullFixingFlag::FullFixingAvailable => { - f.write_str("Full fixing available") + impl std::fmt::Display for FullFixingFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FullFixingFlag::FullFixingUnavailable => f.write_str("Full fixing unavailable"), + FullFixingFlag::FullFixingAvailable => f.write_str("Full fixing available"), } } } -} -/// Partial fixing flag -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum PackedOsrContentPartialFixingFlag { - /// Partial fixing unavailable - PartialFixingUnavailable = 0, + /// Partial fixing flag + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum PartialFixingFlag { + /// Partial fixing unavailable + PartialFixingUnavailable = 0, - /// Partial fixing available - PartialFixingAvailable = 1, -} + /// Partial fixing available + PartialFixingAvailable = 1, + } -impl std::fmt::Display for PackedOsrContentPartialFixingFlag { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - PackedOsrContentPartialFixingFlag::PartialFixingUnavailable => { - f.write_str("Partial fixing unavailable") - } - PackedOsrContentPartialFixingFlag::PartialFixingAvailable => { - f.write_str("Partial fixing available") + impl std::fmt::Display for PartialFixingFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + PartialFixingFlag::PartialFixingUnavailable => { + f.write_str("Partial fixing unavailable") + } + PartialFixingFlag::PartialFixingAvailable => { + f.write_str("Partial fixing available") + } } } } -} -/// Correction validity -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum PackedOsrContentCorrectionValidity { - /// Do not use signal - DoNotUseSignal = 0, + /// Correction validity + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum CorrectionValidity { + /// Do not use signal + DoNotUseSignal = 0, - /// Valid signal - ValidSignal = 1, -} + /// Valid signal + ValidSignal = 1, + } -impl std::fmt::Display for PackedOsrContentCorrectionValidity { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - PackedOsrContentCorrectionValidity::DoNotUseSignal => f.write_str("Do not use signal"), - PackedOsrContentCorrectionValidity::ValidSignal => f.write_str("Valid signal"), + impl std::fmt::Display for CorrectionValidity { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + CorrectionValidity::DoNotUseSignal => f.write_str("Do not use signal"), + CorrectionValidity::ValidSignal => f.write_str("Valid signal"), + } } } } -/// Satellite azimuth and elevation -/// -/// Satellite azimuth and elevation. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 WireFormat for SvAzEl { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sid) + WireFormat::len(&self.az) + WireFormat::len(&self.el) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sid, buf); - WireFormat::write(&self.az, buf); - WireFormat::write(&self.el, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - SvAzEl { - sid: WireFormat::parse_unchecked(buf), - az: WireFormat::parse_unchecked(buf), - el: WireFormat::parse_unchecked(buf), +pub mod sv_az_el { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Satellite azimuth and elevation + /// + /// Satellite azimuth and elevation. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 WireFormat for SvAzEl { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sid) + WireFormat::len(&self.az) + WireFormat::len(&self.el) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.az, buf); + WireFormat::write(&self.el, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + SvAzEl { + sid: WireFormat::parse_unchecked(buf), + az: WireFormat::parse_unchecked(buf), + el: WireFormat::parse_unchecked(buf), + } } } } diff --git a/rust/sbp/src/messages/orientation.rs b/rust/sbp/src/messages/orientation.rs index 5dad77076e..fbdb81fcaf 100644 --- a/rust/sbp/src/messages/orientation.rs +++ b/rust/sbp/src/messages/orientation.rs @@ -13,628 +13,652 @@ // with generate.py. Please do not hand edit! //****************************************************************************/ //! Orientation Messages +pub use msg_angular_rate::MsgAngularRate; +pub use msg_baseline_heading::MsgBaselineHeading; +pub use msg_orient_euler::MsgOrientEuler; +pub use msg_orient_quat::MsgOrientQuat; + +pub mod msg_angular_rate { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Vehicle Body Frame instantaneous angular rates + /// + /// This message reports the orientation rates in the vehicle body frame. The + /// values represent the measurements a strapped down gyroscope would make and + /// are not equivalent to the time derivative of the Euler angles. The + /// orientation and origin of the user frame is specified via device settings. + /// By convention, the vehicle x-axis is expected to be aligned with the + /// forward direction, while the vehicle y-axis is expected to be aligned with + /// the right direction, and the vehicle z-axis should be aligned with the + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgAngularRate { + /// 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 { + pub fn ins_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(InsNavigationMode::Invalid), + 1 => Some(InsNavigationMode::Valid), + _ => None, + } + } -use super::lib::*; - -/// Vehicle Body Frame instantaneous angular rates -/// -/// This message reports the orientation rates in the vehicle body frame. The -/// values represent the measurements a strapped down gyroscope would make and -/// are not equivalent to the time derivative of the Euler angles. The -/// orientation and origin of the user frame is specified via device settings. -/// By convention, the vehicle x-axis is expected to be aligned with the -/// forward direction, while the vehicle y-axis is expected to be aligned with -/// the right direction, and the vehicle z-axis should be aligned with the -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgAngularRate { - /// 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 { - pub fn ins_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgAngularRateInsNavigationMode::Invalid), - 1 => Some(MsgAngularRateInsNavigationMode::Valid), - _ => None, + pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { + set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 2, 0); } } - pub fn set_ins_navigation_mode( - &mut self, - ins_navigation_mode: MsgAngularRateInsNavigationMode, - ) { - set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgAngularRate { + const MESSAGE_TYPE: u16 = 546; + const MESSAGE_NAME: &'static str = "MSG_ANGULAR_RATE"; } -} - -impl ConcreteMessage for MsgAngularRate { - const MESSAGE_TYPE: u16 = 546; - const MESSAGE_NAME: &'static str = "MSG_ANGULAR_RATE"; -} -impl SbpMessage for MsgAngularRate { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgAngularRate { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgAngularRate { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgAngularRate(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgAngularRate { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgAngularRate(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgAngularRate { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.x) - + WireFormat::len(&self.y) - + WireFormat::len(&self.z) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgAngularRate { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.x) + + WireFormat::len(&self.y) + + WireFormat::len(&self.z) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// INS Navigation mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgAngularRateInsNavigationMode { - /// Invalid - Invalid = 0, + /// INS Navigation mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum InsNavigationMode { + /// Invalid + Invalid = 0, - /// Valid - Valid = 1, -} + /// Valid + Valid = 1, + } -impl std::fmt::Display for MsgAngularRateInsNavigationMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgAngularRateInsNavigationMode::Invalid => f.write_str("Invalid"), - MsgAngularRateInsNavigationMode::Valid => f.write_str("Valid"), + impl std::fmt::Display for InsNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + InsNavigationMode::Invalid => f.write_str("Invalid"), + InsNavigationMode::Valid => f.write_str("Valid"), + } } } } -/// Heading relative to True North -/// -/// This message reports the baseline heading pointing from the base station -/// 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). It is -/// intended that time-matched RTK mode is used when the base station is -/// moving. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgBaselineHeading { - /// 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, -} +pub mod msg_baseline_heading { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Heading relative to True North + /// + /// This message reports the baseline heading pointing from the base station + /// 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). It is + /// intended that time-matched RTK mode is used when the base station is + /// moving. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgBaselineHeading { + /// 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 { + pub fn fix_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(FixMode::Invalid), + 2 => Some(FixMode::DifferentialGnss), + 3 => Some(FixMode::FloatRtk), + 4 => Some(FixMode::FixedRtk), + _ => None, + } + } -impl MsgBaselineHeading { - pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgBaselineHeadingFixMode::Invalid), - 2 => Some(MsgBaselineHeadingFixMode::DifferentialGnss), - 3 => Some(MsgBaselineHeadingFixMode::FloatRtk), - 4 => Some(MsgBaselineHeadingFixMode::FixedRtk), - _ => None, + pub fn set_fix_mode(&mut self, fix_mode: FixMode) { + set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } } - pub fn set_fix_mode(&mut self, fix_mode: MsgBaselineHeadingFixMode) { - set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgBaselineHeading { + const MESSAGE_TYPE: u16 = 527; + const MESSAGE_NAME: &'static str = "MSG_BASELINE_HEADING"; } -} -impl ConcreteMessage for MsgBaselineHeading { - const MESSAGE_TYPE: u16 = 527; - const MESSAGE_NAME: &'static str = "MSG_BASELINE_HEADING"; -} - -impl SbpMessage for MsgBaselineHeading { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgBaselineHeading { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgBaselineHeading { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgBaselineHeading(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgBaselineHeading { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgBaselineHeading(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgBaselineHeading { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.heading) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgBaselineHeading { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.heading) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Fix mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgBaselineHeadingFixMode { - /// Invalid - Invalid = 0, + /// Fix mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FixMode { + /// Invalid + Invalid = 0, - /// Differential GNSS (DGNSS) - DifferentialGnss = 2, + /// Differential GNSS (DGNSS) + DifferentialGnss = 2, - /// Float RTK - FloatRtk = 3, + /// Float RTK + FloatRtk = 3, - /// Fixed RTK - FixedRtk = 4, -} + /// Fixed RTK + FixedRtk = 4, + } -impl std::fmt::Display for MsgBaselineHeadingFixMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgBaselineHeadingFixMode::Invalid => f.write_str("Invalid"), - MsgBaselineHeadingFixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), - MsgBaselineHeadingFixMode::FloatRtk => f.write_str("Float RTK"), - MsgBaselineHeadingFixMode::FixedRtk => f.write_str("Fixed RTK"), + impl std::fmt::Display for FixMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FixMode::Invalid => f.write_str("Invalid"), + FixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"), + FixMode::FloatRtk => f.write_str("Float RTK"), + FixMode::FixedRtk => f.write_str("Fixed RTK"), + } } } } -/// Euler angles -/// -/// This message reports the yaw, pitch, and roll angles of the vehicle body -/// frame. The rotations should applied intrinsically in the order yaw, pitch, -/// and roll in order to rotate the from a frame aligned with the local-level -/// NED frame to the vehicle body frame. 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgOrientEuler { - /// 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, -} +pub mod msg_orient_euler { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Euler angles + /// + /// This message reports the yaw, pitch, and roll angles of the vehicle body + /// frame. The rotations should applied intrinsically in the order yaw, pitch, + /// and roll in order to rotate the from a frame aligned with the local-level + /// NED frame to the vehicle body frame. 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgOrientEuler { + /// 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 { + pub fn ins_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(InsNavigationMode::Invalid), + 1 => Some(InsNavigationMode::Valid), + _ => None, + } + } -impl MsgOrientEuler { - pub fn ins_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgOrientEulerInsNavigationMode::Invalid), - 1 => Some(MsgOrientEulerInsNavigationMode::Valid), - _ => None, + pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { + set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 2, 0); } } - pub fn set_ins_navigation_mode( - &mut self, - ins_navigation_mode: MsgOrientEulerInsNavigationMode, - ) { - set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgOrientEuler { + const MESSAGE_TYPE: u16 = 545; + const MESSAGE_NAME: &'static str = "MSG_ORIENT_EULER"; } -} -impl ConcreteMessage for MsgOrientEuler { - const MESSAGE_TYPE: u16 = 545; - const MESSAGE_NAME: &'static str = "MSG_ORIENT_EULER"; -} - -impl SbpMessage for MsgOrientEuler { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgOrientEuler { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgOrientEuler { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgOrientEuler(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgOrientEuler { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgOrientEuler(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgOrientEuler { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.roll) - + WireFormat::len(&self.pitch) - + WireFormat::len(&self.yaw) - + WireFormat::len(&self.roll_accuracy) - + WireFormat::len(&self.pitch_accuracy) - + WireFormat::len(&self.yaw_accuracy) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgOrientEuler { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.roll) + + WireFormat::len(&self.pitch) + + WireFormat::len(&self.yaw) + + WireFormat::len(&self.roll_accuracy) + + WireFormat::len(&self.pitch_accuracy) + + WireFormat::len(&self.yaw_accuracy) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// INS Navigation mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgOrientEulerInsNavigationMode { - /// Invalid - Invalid = 0, + /// INS Navigation mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum InsNavigationMode { + /// Invalid + Invalid = 0, - /// Valid - Valid = 1, -} + /// Valid + Valid = 1, + } -impl std::fmt::Display for MsgOrientEulerInsNavigationMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgOrientEulerInsNavigationMode::Invalid => f.write_str("Invalid"), - MsgOrientEulerInsNavigationMode::Valid => f.write_str("Valid"), + impl std::fmt::Display for InsNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + InsNavigationMode::Invalid => f.write_str("Invalid"), + InsNavigationMode::Valid => f.write_str("Valid"), + } } } } -/// Quaternion 4 component vector -/// -/// This message reports the quaternion vector describing the vehicle body -/// frame's orientation with respect to a local-level NED frame. The -/// components of the vector should sum to a unit vector assuming that the LSB -/// of each component as a value of 2^-31. 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgOrientQuat { - /// 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, -} +pub mod msg_orient_quat { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Quaternion 4 component vector + /// + /// This message reports the quaternion vector describing the vehicle body + /// frame's orientation with respect to a local-level NED frame. The + /// components of the vector should sum to a unit vector assuming that the LSB + /// of each component as a value of 2^-31. 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgOrientQuat { + /// 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 { + pub fn ins_navigation_mode(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(InsNavigationMode::Invalid), + 1 => Some(InsNavigationMode::Valid), + _ => None, + } + } -impl MsgOrientQuat { - pub fn ins_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgOrientQuatInsNavigationMode::Invalid), - 1 => Some(MsgOrientQuatInsNavigationMode::Valid), - _ => None, + pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { + set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 2, 0); } } - pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: MsgOrientQuatInsNavigationMode) { - set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 2, 0); + impl ConcreteMessage for MsgOrientQuat { + const MESSAGE_TYPE: u16 = 544; + const MESSAGE_NAME: &'static str = "MSG_ORIENT_QUAT"; } -} -impl ConcreteMessage for MsgOrientQuat { - const MESSAGE_TYPE: u16 = 544; - const MESSAGE_NAME: &'static str = "MSG_ORIENT_QUAT"; -} - -impl SbpMessage for MsgOrientQuat { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgOrientQuat { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgOrientQuat { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgOrientQuat(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgOrientQuat { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgOrientQuat(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgOrientQuat { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.w) - + WireFormat::len(&self.x) - + WireFormat::len(&self.y) - + WireFormat::len(&self.z) - + WireFormat::len(&self.w_accuracy) - + WireFormat::len(&self.x_accuracy) - + WireFormat::len(&self.y_accuracy) - + WireFormat::len(&self.z_accuracy) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgOrientQuat { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.w) + + WireFormat::len(&self.x) + + WireFormat::len(&self.y) + + WireFormat::len(&self.z) + + WireFormat::len(&self.w_accuracy) + + WireFormat::len(&self.x_accuracy) + + WireFormat::len(&self.y_accuracy) + + WireFormat::len(&self.z_accuracy) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// INS Navigation mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgOrientQuatInsNavigationMode { - /// Invalid - Invalid = 0, + /// INS Navigation mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum InsNavigationMode { + /// Invalid + Invalid = 0, - /// Valid - Valid = 1, -} + /// Valid + Valid = 1, + } -impl std::fmt::Display for MsgOrientQuatInsNavigationMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgOrientQuatInsNavigationMode::Invalid => f.write_str("Invalid"), - MsgOrientQuatInsNavigationMode::Valid => f.write_str("Valid"), + impl std::fmt::Display for InsNavigationMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + InsNavigationMode::Invalid => f.write_str("Invalid"), + InsNavigationMode::Valid => f.write_str("Valid"), + } } } } diff --git a/rust/sbp/src/messages/piksi.rs b/rust/sbp/src/messages/piksi.rs index cf187d48e7..0d95be3779 100644 --- a/rust/sbp/src/messages/piksi.rs +++ b/rust/sbp/src/messages/piksi.rs @@ -15,2570 +15,2824 @@ //! System health, configuration, and diagnostic messages specific to the //! Piksi L1 receiver, including a variety of legacy messages that may no //! longer be used. - -use super::gnss::*; - -use super::lib::*; - -/// Receiver-to-base station latency -/// -/// Statistics on the latency of observations received from the base station. -/// As observation packets are received their GPS time is compared to the -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 WireFormat for Latency { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.avg) - + WireFormat::len(&self.lmin) - + WireFormat::len(&self.lmax) - + WireFormat::len(&self.current) - } - fn write(&self, buf: &mut B) { - 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 B) -> Self { - Latency { - avg: WireFormat::parse_unchecked(buf), - lmin: WireFormat::parse_unchecked(buf), - lmax: WireFormat::parse_unchecked(buf), - current: WireFormat::parse_unchecked(buf), +pub use latency::Latency; +pub use msg_almanac::MsgAlmanac; +pub use msg_cell_modem_status::MsgCellModemStatus; +pub use msg_command_output::MsgCommandOutput; +pub use msg_command_req::MsgCommandReq; +pub use msg_command_resp::MsgCommandResp; +pub use msg_cw_results::MsgCwResults; +pub use msg_cw_start::MsgCwStart; +pub use msg_device_monitor::MsgDeviceMonitor; +pub use msg_front_end_gain::MsgFrontEndGain; +pub use msg_iar_state::MsgIarState; +pub use msg_init_base_dep::MsgInitBaseDep; +pub use msg_mask_satellite::MsgMaskSatellite; +pub use msg_mask_satellite_dep::MsgMaskSatelliteDep; +pub use msg_network_bandwidth_usage::MsgNetworkBandwidthUsage; +pub use msg_network_state_req::MsgNetworkStateReq; +pub use msg_network_state_resp::MsgNetworkStateResp; +pub use msg_reset::MsgReset; +pub use msg_reset_dep::MsgResetDep; +pub use msg_reset_filters::MsgResetFilters; +pub use msg_set_time::MsgSetTime; +pub use msg_specan::MsgSpecan; +pub use msg_specan_dep::MsgSpecanDep; +pub use msg_thread_state::MsgThreadState; +pub use msg_uart_state::MsgUartState; +pub use msg_uart_state_depa::MsgUartStateDepa; +pub use network_usage::NetworkUsage; +pub use period::Period; +pub use uart_channel::UARTChannel; + +pub mod latency { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Receiver-to-base station latency + /// + /// Statistics on the latency of observations received from the base station. + /// As observation packets are received their GPS time is compared to the + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 WireFormat for Latency { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.avg) + + WireFormat::len(&self.lmin) + + WireFormat::len(&self.lmax) + + WireFormat::len(&self.current) + } + fn write(&self, buf: &mut B) { + 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 B) -> Self { + Latency { + avg: WireFormat::parse_unchecked(buf), + lmin: WireFormat::parse_unchecked(buf), + lmax: WireFormat::parse_unchecked(buf), + current: WireFormat::parse_unchecked(buf), + } } } } -/// Legacy message to load satellite almanac (host => Piksi) -/// -/// This is a legacy message for sending and loading a satellite alamanac onto -/// the Piksi's flash memory from the host. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgAlmanac { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, -} +pub mod msg_almanac { + #![allow(unused_imports)] -impl ConcreteMessage for MsgAlmanac { - const MESSAGE_TYPE: u16 = 105; - const MESSAGE_NAME: &'static str = "MSG_ALMANAC"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgAlmanac { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME + /// Legacy message to load satellite almanac (host => Piksi) + /// + /// This is a legacy message for sending and loading a satellite alamanac onto + /// the Piksi's flash memory from the host. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgAlmanac { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgAlmanac { + const MESSAGE_TYPE: u16 = 105; + const MESSAGE_NAME: &'static str = "MSG_ALMANAC"; } -} -impl TryFrom for MsgAlmanac { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgAlmanac(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgAlmanac { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgAlmanac { - const MIN_LEN: usize = 0; - fn len(&self) -> usize { - 0 - } - fn write(&self, _buf: &mut B) {} - fn parse_unchecked(_buf: &mut B) -> Self { - MsgAlmanac { sender_id: None } + impl TryFrom for MsgAlmanac { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgAlmanac(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } -} - -/// Cell modem information update message -/// -/// If a cell modem is present on a piksi device, this message will be send -/// periodically to update the host on the status of the modem and its various -/// parameters. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgCellModemStatus { - /// 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 ConcreteMessage for MsgCellModemStatus { - const MESSAGE_TYPE: u16 = 190; - const MESSAGE_NAME: &'static str = "MSG_CELL_MODEM_STATUS"; -} - -impl SbpMessage for MsgCellModemStatus { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl WireFormat for MsgAlmanac { + const MIN_LEN: usize = 0; + fn len(&self) -> usize { + 0 + } + fn write(&self, _buf: &mut B) {} + fn parse_unchecked(_buf: &mut B) -> Self { + MsgAlmanac { sender_id: None } + } } } -impl TryFrom for MsgCellModemStatus { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgCellModemStatus(m) => Ok(m), - _ => Err(TryFromSbpError), +pub mod msg_cell_modem_status { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Cell modem information update message + /// + /// If a cell modem is present on a piksi device, this message will be send + /// periodically to update the host on the status of the modem and its various + /// parameters. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgCellModemStatus { + /// 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 ConcreteMessage for MsgCellModemStatus { + const MESSAGE_TYPE: u16 = 190; + const MESSAGE_NAME: &'static str = "MSG_CELL_MODEM_STATUS"; + } + + impl SbpMessage for MsgCellModemStatus { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgCellModemStatus { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.signal_strength) - + WireFormat::len(&self.signal_error_rate) - + WireFormat::len(&self.reserved) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.signal_strength, buf); - WireFormat::write(&self.signal_error_rate, buf); - WireFormat::write(&self.reserved, buf); + impl TryFrom for MsgCellModemStatus { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgCellModemStatus(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgCellModemStatus { - sender_id: None, - signal_strength: WireFormat::parse_unchecked(buf), - signal_error_rate: WireFormat::parse_unchecked(buf), - reserved: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgCellModemStatus { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.signal_strength) + + WireFormat::len(&self.signal_error_rate) + + WireFormat::len(&self.reserved) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.signal_strength, buf); + WireFormat::write(&self.signal_error_rate, buf); + WireFormat::write(&self.reserved, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgCellModemStatus { + sender_id: None, + signal_strength: WireFormat::parse_unchecked(buf), + signal_error_rate: WireFormat::parse_unchecked(buf), + reserved: WireFormat::parse_unchecked(buf), + } } } } -/// Command output -/// -/// Returns the standard output and standard error of the command requested by -/// MSG_COMMAND_REQ. The sequence number can be used to filter for filtering -/// the correct command. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgCommandOutput { - /// 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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "line")))] - pub line: SbpString, Unterminated>, -} +pub mod msg_command_output { + #![allow(unused_imports)] -impl ConcreteMessage for MsgCommandOutput { - const MESSAGE_TYPE: u16 = 188; - const MESSAGE_NAME: &'static str = "MSG_COMMAND_OUTPUT"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgCommandOutput { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE + /// Command output + /// + /// Returns the standard output and standard error of the command requested by + /// MSG_COMMAND_REQ. The sequence number can be used to filter for filtering + /// the correct command. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgCommandOutput { + /// 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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "line")))] + pub line: SbpString, Unterminated>, } - fn sender_id(&self) -> Option { - self.sender_id - } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgCommandOutput { + const MESSAGE_TYPE: u16 = 188; + const MESSAGE_NAME: &'static str = "MSG_COMMAND_OUTPUT"; } -} -impl TryFrom for MsgCommandOutput { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgCommandOutput(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgCommandOutput { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgCommandOutput { - const MIN_LEN: usize = - ::MIN_LEN + , Unterminated> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sequence) + WireFormat::len(&self.line) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sequence, buf); - WireFormat::write(&self.line, buf); + impl TryFrom for MsgCommandOutput { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgCommandOutput(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgCommandOutput { - sender_id: None, - sequence: WireFormat::parse_unchecked(buf), - line: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgCommandOutput { + const MIN_LEN: usize = ::MIN_LEN + + , Unterminated> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sequence) + WireFormat::len(&self.line) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sequence, buf); + WireFormat::write(&self.line, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgCommandOutput { + sender_id: None, + sequence: WireFormat::parse_unchecked(buf), + line: WireFormat::parse_unchecked(buf), + } } } } -/// Execute a command (host => device) -/// -/// Request the recipient to execute an command. Output will be sent in -/// MSG_LOG messages, and the exit code will be returned with -/// MSG_COMMAND_RESP. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgCommandReq { - /// 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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "command")))] - pub command: SbpString, NullTerminated>, -} +pub mod msg_command_req { + #![allow(unused_imports)] -impl ConcreteMessage for MsgCommandReq { - const MESSAGE_TYPE: u16 = 184; - const MESSAGE_NAME: &'static str = "MSG_COMMAND_REQ"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgCommandReq { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + /// Execute a command (host => device) + /// + /// Request the recipient to execute an command. Output will be sent in + /// MSG_LOG messages, and the exit code will be returned with + /// MSG_COMMAND_RESP. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgCommandReq { + /// 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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "command")))] + pub command: SbpString, NullTerminated>, } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgCommandReq { + const MESSAGE_TYPE: u16 = 184; + const MESSAGE_NAME: &'static str = "MSG_COMMAND_REQ"; } -} -impl TryFrom for MsgCommandReq { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgCommandReq(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgCommandReq { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgCommandReq { - const MIN_LEN: usize = - ::MIN_LEN + , NullTerminated> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sequence) + WireFormat::len(&self.command) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sequence, buf); - WireFormat::write(&self.command, buf); + impl TryFrom for MsgCommandReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgCommandReq(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgCommandReq { - sender_id: None, - sequence: WireFormat::parse_unchecked(buf), - command: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgCommandReq { + const MIN_LEN: usize = ::MIN_LEN + + , NullTerminated> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sequence) + WireFormat::len(&self.command) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sequence, buf); + WireFormat::write(&self.command, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgCommandReq { + sender_id: None, + sequence: WireFormat::parse_unchecked(buf), + command: WireFormat::parse_unchecked(buf), + } } } } -/// Exit code from executed command (device => host) -/// -/// The response to MSG_COMMAND_REQ with the return code of the command. A -/// return code of zero indicates success. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgCommandResp { - /// 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, -} +pub mod msg_command_resp { + #![allow(unused_imports)] -impl ConcreteMessage for MsgCommandResp { - const MESSAGE_TYPE: u16 = 185; - const MESSAGE_NAME: &'static str = "MSG_COMMAND_RESP"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgCommandResp { - 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); + /// Exit code from executed command (device => host) + /// + /// The response to MSG_COMMAND_REQ with the return code of the command. A + /// return code of zero indicates success. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgCommandResp { + /// 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, } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgCommandResp { + const MESSAGE_TYPE: u16 = 185; + const MESSAGE_NAME: &'static str = "MSG_COMMAND_RESP"; } -} -impl TryFrom for MsgCommandResp { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgCommandResp(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgCommandResp { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgCommandResp { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sequence) + WireFormat::len(&self.code) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sequence, buf); - WireFormat::write(&self.code, buf); + impl TryFrom for MsgCommandResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgCommandResp(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgCommandResp { - sender_id: None, - sequence: WireFormat::parse_unchecked(buf), - code: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgCommandResp { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sequence) + WireFormat::len(&self.code) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sequence, buf); + WireFormat::write(&self.code, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgCommandResp { + sender_id: None, + sequence: WireFormat::parse_unchecked(buf), + code: WireFormat::parse_unchecked(buf), + } } } } -/// Legacy message for CW interference channel (Piksi => host) -/// -/// This is an unused legacy message for result reporting from the CW -/// interference channel on the SwiftNAP. This message will be removed in a -/// future release. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgCwResults { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, -} +pub mod msg_cw_results { + #![allow(unused_imports)] -impl ConcreteMessage for MsgCwResults { - const MESSAGE_TYPE: u16 = 192; - const MESSAGE_NAME: &'static str = "MSG_CW_RESULTS"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgCwResults { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME + /// Legacy message for CW interference channel (Piksi => host) + /// + /// This is an unused legacy message for result reporting from the CW + /// interference channel on the SwiftNAP. This message will be removed in a + /// future release. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgCwResults { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgCwResults { + const MESSAGE_TYPE: u16 = 192; + const MESSAGE_NAME: &'static str = "MSG_CW_RESULTS"; } -} -impl TryFrom for MsgCwResults { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgCwResults(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgCwResults { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgCwResults { - const MIN_LEN: usize = 0; - fn len(&self) -> usize { - 0 + impl TryFrom for MsgCwResults { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgCwResults(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn write(&self, _buf: &mut B) {} - fn parse_unchecked(_buf: &mut B) -> Self { - MsgCwResults { sender_id: None } + + impl WireFormat for MsgCwResults { + const MIN_LEN: usize = 0; + fn len(&self) -> usize { + 0 + } + fn write(&self, _buf: &mut B) {} + fn parse_unchecked(_buf: &mut B) -> Self { + MsgCwResults { sender_id: None } + } } } -/// Legacy message for CW interference channel (host => Piksi) -/// -/// This is an unused legacy message from the host for starting the CW -/// interference channel on the SwiftNAP. This message will be removed in a -/// future release. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgCwStart { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, -} +pub mod msg_cw_start { + #![allow(unused_imports)] -impl ConcreteMessage for MsgCwStart { - const MESSAGE_TYPE: u16 = 193; - const MESSAGE_NAME: &'static str = "MSG_CW_START"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgCwStart { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + /// Legacy message for CW interference channel (host => Piksi) + /// + /// This is an unused legacy message from the host for starting the CW + /// interference channel on the SwiftNAP. This message will be removed in a + /// future release. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgCwStart { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgCwStart { + const MESSAGE_TYPE: u16 = 193; + const MESSAGE_NAME: &'static str = "MSG_CW_START"; } -} -impl TryFrom for MsgCwStart { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgCwStart(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgCwStart { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgCwStart { - const MIN_LEN: usize = 0; - fn len(&self) -> usize { - 0 - } - fn write(&self, _buf: &mut B) {} - fn parse_unchecked(_buf: &mut B) -> Self { - MsgCwStart { sender_id: None } + impl TryFrom for MsgCwStart { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgCwStart(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } -} -/// Device temperature and voltage levels -/// -/// This message contains temperature and voltage level measurements from the -/// processor's monitoring system and the RF frontend die temperature if -/// available. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgDeviceMonitor { - /// 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 ConcreteMessage for MsgDeviceMonitor { - const MESSAGE_TYPE: u16 = 181; - const MESSAGE_NAME: &'static str = "MSG_DEVICE_MONITOR"; -} - -impl SbpMessage for MsgDeviceMonitor { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl WireFormat for MsgCwStart { + const MIN_LEN: usize = 0; + fn len(&self) -> usize { + 0 + } + fn write(&self, _buf: &mut B) {} + fn parse_unchecked(_buf: &mut B) -> Self { + MsgCwStart { sender_id: None } + } } } -impl TryFrom for MsgDeviceMonitor { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgDeviceMonitor(m) => Ok(m), - _ => Err(TryFromSbpError), +pub mod msg_device_monitor { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Device temperature and voltage levels + /// + /// This message contains temperature and voltage level measurements from the + /// processor's monitoring system and the RF frontend die temperature if + /// available. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgDeviceMonitor { + /// 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 ConcreteMessage for MsgDeviceMonitor { + const MESSAGE_TYPE: u16 = 181; + const MESSAGE_NAME: &'static str = "MSG_DEVICE_MONITOR"; + } + + impl SbpMessage for MsgDeviceMonitor { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgDeviceMonitor { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.dev_vin) - + WireFormat::len(&self.cpu_vint) - + WireFormat::len(&self.cpu_vaux) - + WireFormat::len(&self.cpu_temperature) - + WireFormat::len(&self.fe_temperature) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl TryFrom for MsgDeviceMonitor { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgDeviceMonitor(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} - -/// RF AGC status -/// -/// This message describes the gain of each channel in the receiver frontend. -/// Each gain is encoded as a non-dimensional percentage relative to the -/// maximum range possible for the gain stage of the frontend. By convention, -/// each gain array has 8 entries and the index of the array corresponding to -/// the index of the rf channel in the frontend. A gain of 127 percent encodes -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgFrontEndGain { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, - /// RF gain for each frontend channel - #[cfg_attr(feature = "serde", serde(rename(serialize = "rf_gain")))] - pub rf_gain: [i8; 8], - /// Intermediate frequency gain for each frontend channel - #[cfg_attr(feature = "serde", serde(rename(serialize = "if_gain")))] - pub if_gain: [i8; 8], -} -impl ConcreteMessage for MsgFrontEndGain { - const MESSAGE_TYPE: u16 = 191; - const MESSAGE_NAME: &'static str = "MSG_FRONT_END_GAIN"; -} - -impl SbpMessage for MsgFrontEndGain { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl WireFormat for MsgDeviceMonitor { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.dev_vin) + + WireFormat::len(&self.cpu_vint) + + WireFormat::len(&self.cpu_vaux) + + WireFormat::len(&self.cpu_temperature) + + WireFormat::len(&self.fe_temperature) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } + } } } -impl TryFrom for MsgFrontEndGain { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgFrontEndGain(m) => Ok(m), - _ => Err(TryFromSbpError), +pub mod msg_front_end_gain { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// RF AGC status + /// + /// This message describes the gain of each channel in the receiver frontend. + /// Each gain is encoded as a non-dimensional percentage relative to the + /// maximum range possible for the gain stage of the frontend. By convention, + /// each gain array has 8 entries and the index of the array corresponding to + /// the index of the rf channel in the frontend. A gain of 127 percent encodes + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgFrontEndGain { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + /// RF gain for each frontend channel + #[cfg_attr(feature = "serde", serde(rename(serialize = "rf_gain")))] + pub rf_gain: [i8; 8], + /// Intermediate frequency gain for each frontend channel + #[cfg_attr(feature = "serde", serde(rename(serialize = "if_gain")))] + pub if_gain: [i8; 8], + } + + impl ConcreteMessage for MsgFrontEndGain { + const MESSAGE_TYPE: u16 = 191; + const MESSAGE_NAME: &'static str = "MSG_FRONT_END_GAIN"; + } + + impl SbpMessage for MsgFrontEndGain { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgFrontEndGain { - const MIN_LEN: usize = <[i8; 8] as WireFormat>::MIN_LEN + <[i8; 8] as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.rf_gain) + WireFormat::len(&self.if_gain) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.rf_gain, buf); - WireFormat::write(&self.if_gain, buf); + impl TryFrom for MsgFrontEndGain { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgFrontEndGain(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgFrontEndGain { - sender_id: None, - rf_gain: WireFormat::parse_unchecked(buf), - if_gain: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgFrontEndGain { + const MIN_LEN: usize = <[i8; 8] as WireFormat>::MIN_LEN + <[i8; 8] as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.rf_gain) + WireFormat::len(&self.if_gain) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.rf_gain, buf); + WireFormat::write(&self.if_gain, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgFrontEndGain { + sender_id: None, + rf_gain: WireFormat::parse_unchecked(buf), + if_gain: WireFormat::parse_unchecked(buf), + } } } } -/// State of the Integer Ambiguity Resolution (IAR) process -/// -/// This message reports the state of the Integer Ambiguity Resolution (IAR) -/// process, which resolves unknown integer ambiguities from double- -/// differenced carrier-phase measurements from satellite observations. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgIarState { - /// 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, -} +pub mod msg_iar_state { + #![allow(unused_imports)] -impl ConcreteMessage for MsgIarState { - const MESSAGE_TYPE: u16 = 25; - const MESSAGE_NAME: &'static str = "MSG_IAR_STATE"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgIarState { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME + /// State of the Integer Ambiguity Resolution (IAR) process + /// + /// This message reports the state of the Integer Ambiguity Resolution (IAR) + /// process, which resolves unknown integer ambiguities from double- + /// differenced carrier-phase measurements from satellite observations. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgIarState { + /// 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, } - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgIarState { + const MESSAGE_TYPE: u16 = 25; + const MESSAGE_NAME: &'static str = "MSG_IAR_STATE"; } -} -impl TryFrom for MsgIarState { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgIarState(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgIarState { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgIarState { - const MIN_LEN: usize = ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.num_hyps) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.num_hyps, buf); + impl TryFrom for MsgIarState { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgIarState(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgIarState { - sender_id: None, - num_hyps: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgIarState { + const MIN_LEN: usize = ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.num_hyps) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.num_hyps, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgIarState { + sender_id: None, + num_hyps: WireFormat::parse_unchecked(buf), + } } } } -/// Deprecated -/// -/// Deprecated -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgInitBaseDep { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, -} +pub mod msg_init_base_dep { + #![allow(unused_imports)] -impl ConcreteMessage for MsgInitBaseDep { - const MESSAGE_TYPE: u16 = 35; - const MESSAGE_NAME: &'static str = "MSG_INIT_BASE_DEP"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgInitBaseDep { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE + /// Deprecated + /// + /// Deprecated + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgInitBaseDep { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgInitBaseDep { + const MESSAGE_TYPE: u16 = 35; + const MESSAGE_NAME: &'static str = "MSG_INIT_BASE_DEP"; } -} -impl TryFrom for MsgInitBaseDep { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgInitBaseDep(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgInitBaseDep { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgInitBaseDep { - const MIN_LEN: usize = 0; - fn len(&self) -> usize { - 0 + impl TryFrom for MsgInitBaseDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgInitBaseDep(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn write(&self, _buf: &mut B) {} - fn parse_unchecked(_buf: &mut B) -> Self { - MsgInitBaseDep { sender_id: None } + + impl WireFormat for MsgInitBaseDep { + const MIN_LEN: usize = 0; + fn len(&self) -> usize { + 0 + } + fn write(&self, _buf: &mut B) {} + fn parse_unchecked(_buf: &mut B) -> Self { + MsgInitBaseDep { sender_id: None } + } } } -/// Mask a satellite from use in Piksi subsystems -/// -/// This message allows setting a mask to prevent a particular satellite from -/// being used in various Piksi subsystems. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgMaskSatellite { - /// 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, -} +pub mod msg_mask_satellite { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Mask a satellite from use in Piksi subsystems + /// + /// This message allows setting a mask to prevent a particular satellite from + /// being used in various Piksi subsystems. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgMaskSatellite { + /// 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 { + pub fn tracking_channels(&self) -> Option { + match get_bit_range!(self.mask, u8, u8, 1, 0) { + 0 => Some(TrackingChannels::Enabled), + 1 => Some(TrackingChannels::DropThisPrnIfCurrentlyTracking), + _ => None, + } + } -impl MsgMaskSatellite { - pub fn tracking_channels(&self) -> Option { - match get_bit_range!(self.mask, u8, u8, 1, 0) { - 0 => Some(MsgMaskSatelliteTrackingChannels::Enabled), - 1 => Some(MsgMaskSatelliteTrackingChannels::DropThisPrnIfCurrentlyTracking), - _ => None, + pub fn set_tracking_channels(&mut self, tracking_channels: TrackingChannels) { + set_bit_range!(&mut self.mask, tracking_channels, u8, u8, 1, 0); } - } - pub fn set_tracking_channels(&mut self, tracking_channels: MsgMaskSatelliteTrackingChannels) { - set_bit_range!(&mut self.mask, tracking_channels, u8, u8, 1, 0); - } + pub fn acquisition_channel(&self) -> Option { + match get_bit_range!(self.mask, u8, u8, 0, 0) { + 0 => Some(AcquisitionChannel::Enabled), + 1 => Some(AcquisitionChannel::SkipThisSatelliteOnFutureAcquisitions), + _ => None, + } + } - pub fn acquisition_channel(&self) -> Option { - match get_bit_range!(self.mask, u8, u8, 0, 0) { - 0 => Some(MsgMaskSatelliteAcquisitionChannel::Enabled), - 1 => Some(MsgMaskSatelliteAcquisitionChannel::SkipThisSatelliteOnFutureAcquisitions), - _ => None, + pub fn set_acquisition_channel(&mut self, acquisition_channel: AcquisitionChannel) { + set_bit_range!(&mut self.mask, acquisition_channel, u8, u8, 0, 0); } } - pub fn set_acquisition_channel( - &mut self, - acquisition_channel: MsgMaskSatelliteAcquisitionChannel, - ) { - set_bit_range!(&mut self.mask, acquisition_channel, u8, u8, 0, 0); + impl ConcreteMessage for MsgMaskSatellite { + const MESSAGE_TYPE: u16 = 43; + const MESSAGE_NAME: &'static str = "MSG_MASK_SATELLITE"; } -} - -impl ConcreteMessage for MsgMaskSatellite { - const MESSAGE_TYPE: u16 = 43; - const MESSAGE_NAME: &'static str = "MSG_MASK_SATELLITE"; -} -impl SbpMessage for MsgMaskSatellite { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgMaskSatellite { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgMaskSatellite { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgMaskSatellite(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgMaskSatellite { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgMaskSatellite(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgMaskSatellite { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.mask) + WireFormat::len(&self.sid) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.mask, buf); - WireFormat::write(&self.sid, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgMaskSatellite { - sender_id: None, - mask: WireFormat::parse_unchecked(buf), - sid: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgMaskSatellite { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.mask) + WireFormat::len(&self.sid) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.mask, buf); + WireFormat::write(&self.sid, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgMaskSatellite { + sender_id: None, + mask: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + } } } -} -/// Tracking channels -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgMaskSatelliteTrackingChannels { - /// Enabled - Enabled = 0, + /// Tracking channels + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TrackingChannels { + /// Enabled + Enabled = 0, - /// Drop this PRN if currently tracking - DropThisPrnIfCurrentlyTracking = 1, -} + /// Drop this PRN if currently tracking + DropThisPrnIfCurrentlyTracking = 1, + } -impl std::fmt::Display for MsgMaskSatelliteTrackingChannels { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgMaskSatelliteTrackingChannels::Enabled => f.write_str("Enabled"), - MsgMaskSatelliteTrackingChannels::DropThisPrnIfCurrentlyTracking => { - f.write_str("Drop this PRN if currently tracking") + impl std::fmt::Display for TrackingChannels { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TrackingChannels::Enabled => f.write_str("Enabled"), + TrackingChannels::DropThisPrnIfCurrentlyTracking => { + f.write_str("Drop this PRN if currently tracking") + } } } } -} -/// Acquisition channel -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgMaskSatelliteAcquisitionChannel { - /// Enabled - Enabled = 0, + /// Acquisition channel + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum AcquisitionChannel { + /// Enabled + Enabled = 0, - /// Skip this satellite on future acquisitions - SkipThisSatelliteOnFutureAcquisitions = 1, -} + /// Skip this satellite on future acquisitions + SkipThisSatelliteOnFutureAcquisitions = 1, + } -impl std::fmt::Display for MsgMaskSatelliteAcquisitionChannel { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgMaskSatelliteAcquisitionChannel::Enabled => f.write_str("Enabled"), - MsgMaskSatelliteAcquisitionChannel::SkipThisSatelliteOnFutureAcquisitions => { - f.write_str("Skip this satellite on future acquisitions") + impl std::fmt::Display for AcquisitionChannel { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + AcquisitionChannel::Enabled => f.write_str("Enabled"), + AcquisitionChannel::SkipThisSatelliteOnFutureAcquisitions => { + f.write_str("Skip this satellite on future acquisitions") + } } } } } -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgMaskSatelliteDep { - /// 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, -} +pub mod msg_mask_satellite_dep { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Deprecated + /// + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgMaskSatelliteDep { + /// 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 { + pub fn tracking_channels(&self) -> Option { + match get_bit_range!(self.mask, u8, u8, 1, 0) { + 0 => Some(TrackingChannels::Enabled), + 1 => Some(TrackingChannels::DropThisPrnIfCurrentlyTracking), + _ => None, + } + } -impl MsgMaskSatelliteDep { - pub fn tracking_channels(&self) -> Option { - match get_bit_range!(self.mask, u8, u8, 1, 0) { - 0 => Some(MsgMaskSatelliteDepTrackingChannels::Enabled), - 1 => Some(MsgMaskSatelliteDepTrackingChannels::DropThisPrnIfCurrentlyTracking), - _ => None, + pub fn set_tracking_channels(&mut self, tracking_channels: TrackingChannels) { + set_bit_range!(&mut self.mask, tracking_channels, u8, u8, 1, 0); } - } - pub fn set_tracking_channels( - &mut self, - tracking_channels: MsgMaskSatelliteDepTrackingChannels, - ) { - set_bit_range!(&mut self.mask, tracking_channels, u8, u8, 1, 0); - } + pub fn acquisition_channel(&self) -> Option { + match get_bit_range!(self.mask, u8, u8, 0, 0) { + 0 => Some(AcquisitionChannel::Enabled), + 1 => Some(AcquisitionChannel::SkipThisSatelliteOnFutureAcquisitions), + _ => None, + } + } - pub fn acquisition_channel(&self) -> Option { - match get_bit_range!(self.mask, u8, u8, 0, 0) { - 0 => Some(MsgMaskSatelliteDepAcquisitionChannel::Enabled), - 1 => Some(MsgMaskSatelliteDepAcquisitionChannel::SkipThisSatelliteOnFutureAcquisitions), - _ => None, + pub fn set_acquisition_channel(&mut self, acquisition_channel: AcquisitionChannel) { + set_bit_range!(&mut self.mask, acquisition_channel, u8, u8, 0, 0); } } - pub fn set_acquisition_channel( - &mut self, - acquisition_channel: MsgMaskSatelliteDepAcquisitionChannel, - ) { - set_bit_range!(&mut self.mask, acquisition_channel, u8, u8, 0, 0); + impl ConcreteMessage for MsgMaskSatelliteDep { + const MESSAGE_TYPE: u16 = 27; + const MESSAGE_NAME: &'static str = "MSG_MASK_SATELLITE_DEP"; } -} -impl ConcreteMessage for MsgMaskSatelliteDep { - const MESSAGE_TYPE: u16 = 27; - const MESSAGE_NAME: &'static str = "MSG_MASK_SATELLITE_DEP"; -} - -impl SbpMessage for MsgMaskSatelliteDep { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgMaskSatelliteDep { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgMaskSatelliteDep { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgMaskSatelliteDep(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgMaskSatelliteDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgMaskSatelliteDep(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgMaskSatelliteDep { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.mask) + WireFormat::len(&self.sid) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.mask, buf); - WireFormat::write(&self.sid, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgMaskSatelliteDep { - sender_id: None, - mask: WireFormat::parse_unchecked(buf), - sid: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgMaskSatelliteDep { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.mask) + WireFormat::len(&self.sid) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.mask, buf); + WireFormat::write(&self.sid, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgMaskSatelliteDep { + sender_id: None, + mask: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + } } } -} -/// Tracking channels -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgMaskSatelliteDepTrackingChannels { - /// Enabled - Enabled = 0, + /// Tracking channels + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TrackingChannels { + /// Enabled + Enabled = 0, - /// Drop this PRN if currently tracking - DropThisPrnIfCurrentlyTracking = 1, -} + /// Drop this PRN if currently tracking + DropThisPrnIfCurrentlyTracking = 1, + } -impl std::fmt::Display for MsgMaskSatelliteDepTrackingChannels { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgMaskSatelliteDepTrackingChannels::Enabled => f.write_str("Enabled"), - MsgMaskSatelliteDepTrackingChannels::DropThisPrnIfCurrentlyTracking => { - f.write_str("Drop this PRN if currently tracking") + impl std::fmt::Display for TrackingChannels { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TrackingChannels::Enabled => f.write_str("Enabled"), + TrackingChannels::DropThisPrnIfCurrentlyTracking => { + f.write_str("Drop this PRN if currently tracking") + } } } } -} -/// Acquisition channel -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgMaskSatelliteDepAcquisitionChannel { - /// Enabled - Enabled = 0, + /// Acquisition channel + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum AcquisitionChannel { + /// Enabled + Enabled = 0, - /// Skip this satellite on future acquisitions - SkipThisSatelliteOnFutureAcquisitions = 1, -} + /// Skip this satellite on future acquisitions + SkipThisSatelliteOnFutureAcquisitions = 1, + } -impl std::fmt::Display for MsgMaskSatelliteDepAcquisitionChannel { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgMaskSatelliteDepAcquisitionChannel::Enabled => f.write_str("Enabled"), - MsgMaskSatelliteDepAcquisitionChannel::SkipThisSatelliteOnFutureAcquisitions => { - f.write_str("Skip this satellite on future acquisitions") + impl std::fmt::Display for AcquisitionChannel { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + AcquisitionChannel::Enabled => f.write_str("Enabled"), + AcquisitionChannel::SkipThisSatelliteOnFutureAcquisitions => { + f.write_str("Skip this satellite on future acquisitions") + } } } } } -/// Bandwidth usage reporting message -/// -/// The bandwidth usage, a list of usage by interface. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgNetworkBandwidthUsage { - /// 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, -} +pub mod msg_network_bandwidth_usage { + #![allow(unused_imports)] -impl ConcreteMessage for MsgNetworkBandwidthUsage { - const MESSAGE_TYPE: u16 = 189; - const MESSAGE_NAME: &'static str = "MSG_NETWORK_BANDWIDTH_USAGE"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgNetworkBandwidthUsage { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + /// Bandwidth usage reporting message + /// + /// The bandwidth usage, a list of usage by interface. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgNetworkBandwidthUsage { + /// 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, } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgNetworkBandwidthUsage { + const MESSAGE_TYPE: u16 = 189; + const MESSAGE_NAME: &'static str = "MSG_NETWORK_BANDWIDTH_USAGE"; } -} -impl TryFrom for MsgNetworkBandwidthUsage { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgNetworkBandwidthUsage(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgNetworkBandwidthUsage { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgNetworkBandwidthUsage { - const MIN_LEN: usize = as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.interfaces) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.interfaces, buf); + impl TryFrom for MsgNetworkBandwidthUsage { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgNetworkBandwidthUsage(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgNetworkBandwidthUsage { - sender_id: None, - interfaces: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgNetworkBandwidthUsage { + const MIN_LEN: usize = as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.interfaces) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.interfaces, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgNetworkBandwidthUsage { + sender_id: None, + interfaces: WireFormat::parse_unchecked(buf), + } } } } -/// Request state of Piksi network interfaces -/// -/// Request state of Piksi network interfaces. Output will be sent in -/// MSG_NETWORK_STATE_RESP messages. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgNetworkStateReq { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, -} +pub mod msg_network_state_req { + #![allow(unused_imports)] -impl ConcreteMessage for MsgNetworkStateReq { - const MESSAGE_TYPE: u16 = 186; - const MESSAGE_NAME: &'static str = "MSG_NETWORK_STATE_REQ"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgNetworkStateReq { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME + /// Request state of Piksi network interfaces + /// + /// Request state of Piksi network interfaces. Output will be sent in + /// MSG_NETWORK_STATE_RESP messages. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgNetworkStateReq { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgNetworkStateReq { + const MESSAGE_TYPE: u16 = 186; + const MESSAGE_NAME: &'static str = "MSG_NETWORK_STATE_REQ"; } -} -impl TryFrom for MsgNetworkStateReq { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgNetworkStateReq(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgNetworkStateReq { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgNetworkStateReq { - const MIN_LEN: usize = 0; - fn len(&self) -> usize { - 0 + impl TryFrom for MsgNetworkStateReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgNetworkStateReq(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn write(&self, _buf: &mut B) {} - fn parse_unchecked(_buf: &mut B) -> Self { - MsgNetworkStateReq { sender_id: None } + + impl WireFormat for MsgNetworkStateReq { + const MIN_LEN: usize = 0; + fn len(&self) -> usize { + 0 + } + fn write(&self, _buf: &mut B) {} + fn parse_unchecked(_buf: &mut B) -> Self { + MsgNetworkStateReq { sender_id: None } + } } } -/// State of network interface -/// -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgNetworkStateResp { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, - /// IPv4 address (all zero when unavailable) - #[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) - #[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 - #[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, -} +pub mod msg_network_state_resp { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// State of network interface + /// + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgNetworkStateResp { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + /// IPv4 address (all zero when unavailable) + #[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) + #[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 + #[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 { + pub fn iff_multicast_supports_multicast(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 15, 0) + } -impl MsgNetworkStateResp { - pub fn iff_multicast_supports_multicast(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 15, 0) - } + pub fn set_iff_multicast_supports_multicast( + &mut self, + iff_multicast_supports_multicast: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_multicast_supports_multicast, + u32, + u8, + 15, + 0 + ); + } - pub fn set_iff_multicast_supports_multicast(&mut self, iff_multicast_supports_multicast: u8) { - set_bit_range!( - &mut self.flags, - iff_multicast_supports_multicast, - u32, - u8, - 15, - 0 - ); - } + pub fn iff_link2_per_link_layer_defined_bit(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 14, 0) + } - pub fn iff_link2_per_link_layer_defined_bit(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 14, 0) - } + pub fn set_iff_link2_per_link_layer_defined_bit( + &mut self, + iff_link2_per_link_layer_defined_bit: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_link2_per_link_layer_defined_bit, + u32, + u8, + 14, + 0 + ); + } - pub fn set_iff_link2_per_link_layer_defined_bit( - &mut self, - iff_link2_per_link_layer_defined_bit: u8, - ) { - set_bit_range!( - &mut self.flags, - iff_link2_per_link_layer_defined_bit, - u32, - u8, - 14, - 0 - ); - } + pub fn iff_link1_per_link_layer_defined_bit(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 13, 0) + } - pub fn iff_link1_per_link_layer_defined_bit(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 13, 0) - } + pub fn set_iff_link1_per_link_layer_defined_bit( + &mut self, + iff_link1_per_link_layer_defined_bit: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_link1_per_link_layer_defined_bit, + u32, + u8, + 13, + 0 + ); + } - pub fn set_iff_link1_per_link_layer_defined_bit( - &mut self, - iff_link1_per_link_layer_defined_bit: u8, - ) { - set_bit_range!( - &mut self.flags, - iff_link1_per_link_layer_defined_bit, - u32, - u8, - 13, - 0 - ); - } + pub fn iff_link0_per_link_layer_defined_bit(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 12, 0) + } - pub fn iff_link0_per_link_layer_defined_bit(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 12, 0) - } + pub fn set_iff_link0_per_link_layer_defined_bit( + &mut self, + iff_link0_per_link_layer_defined_bit: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_link0_per_link_layer_defined_bit, + u32, + u8, + 12, + 0 + ); + } - pub fn set_iff_link0_per_link_layer_defined_bit( - &mut self, - iff_link0_per_link_layer_defined_bit: u8, - ) { - set_bit_range!( - &mut self.flags, - iff_link0_per_link_layer_defined_bit, - u32, - u8, - 12, - 0 - ); - } + pub fn iff_simplex_cant_hear_own_transmissions(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 11, 0) + } - pub fn iff_simplex_cant_hear_own_transmissions(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 11, 0) - } + pub fn set_iff_simplex_cant_hear_own_transmissions( + &mut self, + iff_simplex_cant_hear_own_transmissions: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_simplex_cant_hear_own_transmissions, + u32, + u8, + 11, + 0 + ); + } - pub fn set_iff_simplex_cant_hear_own_transmissions( - &mut self, - iff_simplex_cant_hear_own_transmissions: u8, - ) { - set_bit_range!( - &mut self.flags, - iff_simplex_cant_hear_own_transmissions, - u32, - u8, - 11, - 0 - ); - } + pub fn iff_oactive_transmission_in_progress(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 10, 0) + } - pub fn iff_oactive_transmission_in_progress(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 10, 0) - } + pub fn set_iff_oactive_transmission_in_progress( + &mut self, + iff_oactive_transmission_in_progress: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_oactive_transmission_in_progress, + u32, + u8, + 10, + 0 + ); + } - pub fn set_iff_oactive_transmission_in_progress( - &mut self, - iff_oactive_transmission_in_progress: u8, - ) { - set_bit_range!( - &mut self.flags, - iff_oactive_transmission_in_progress, - u32, - u8, - 10, - 0 - ); - } + pub fn iff_allmulti_receive_all_multicast_packets(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 9, 0) + } - pub fn iff_allmulti_receive_all_multicast_packets(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 9, 0) - } + pub fn set_iff_allmulti_receive_all_multicast_packets( + &mut self, + iff_allmulti_receive_all_multicast_packets: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_allmulti_receive_all_multicast_packets, + u32, + u8, + 9, + 0 + ); + } - pub fn set_iff_allmulti_receive_all_multicast_packets( - &mut self, - iff_allmulti_receive_all_multicast_packets: u8, - ) { - set_bit_range!( - &mut self.flags, - iff_allmulti_receive_all_multicast_packets, - u32, - u8, - 9, - 0 - ); - } + pub fn iff_promisc_receive_all_packets(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 8, 0) + } - pub fn iff_promisc_receive_all_packets(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 8, 0) - } + pub fn set_iff_promisc_receive_all_packets(&mut self, iff_promisc_receive_all_packets: u8) { + set_bit_range!( + &mut self.flags, + iff_promisc_receive_all_packets, + u32, + u8, + 8, + 0 + ); + } - pub fn set_iff_promisc_receive_all_packets(&mut self, iff_promisc_receive_all_packets: u8) { - set_bit_range!( - &mut self.flags, - iff_promisc_receive_all_packets, - u32, - u8, - 8, - 0 - ); - } + pub fn iff_noarp_no_address_resolution_protocol(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 7, 0) + } - pub fn iff_noarp_no_address_resolution_protocol(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 7, 0) - } + pub fn set_iff_noarp_no_address_resolution_protocol( + &mut self, + iff_noarp_no_address_resolution_protocol: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_noarp_no_address_resolution_protocol, + u32, + u8, + 7, + 0 + ); + } - pub fn set_iff_noarp_no_address_resolution_protocol( - &mut self, - iff_noarp_no_address_resolution_protocol: u8, - ) { - set_bit_range!( - &mut self.flags, - iff_noarp_no_address_resolution_protocol, - u32, - u8, - 7, - 0 - ); - } + pub fn iff_running_resources_allocated(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 6, 0) + } - pub fn iff_running_resources_allocated(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 6, 0) - } + pub fn set_iff_running_resources_allocated(&mut self, iff_running_resources_allocated: u8) { + set_bit_range!( + &mut self.flags, + iff_running_resources_allocated, + u32, + u8, + 6, + 0 + ); + } - pub fn set_iff_running_resources_allocated(&mut self, iff_running_resources_allocated: u8) { - set_bit_range!( - &mut self.flags, - iff_running_resources_allocated, - u32, - u8, - 6, - 0 - ); - } + pub fn iff_notrailers_avoid_use_of_trailers(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 5, 0) + } - pub fn iff_notrailers_avoid_use_of_trailers(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 5, 0) - } + pub fn set_iff_notrailers_avoid_use_of_trailers( + &mut self, + iff_notrailers_avoid_use_of_trailers: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_notrailers_avoid_use_of_trailers, + u32, + u8, + 5, + 0 + ); + } - pub fn set_iff_notrailers_avoid_use_of_trailers( - &mut self, - iff_notrailers_avoid_use_of_trailers: u8, - ) { - set_bit_range!( - &mut self.flags, - iff_notrailers_avoid_use_of_trailers, - u32, - u8, - 5, - 0 - ); - } + pub fn iff_pointopoint_interface_is_pointtopoint_link(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 4, 0) + } - pub fn iff_pointopoint_interface_is_pointtopoint_link(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 4, 0) - } + pub fn set_iff_pointopoint_interface_is_pointtopoint_link( + &mut self, + iff_pointopoint_interface_is_pointtopoint_link: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_pointopoint_interface_is_pointtopoint_link, + u32, + u8, + 4, + 0 + ); + } - pub fn set_iff_pointopoint_interface_is_pointtopoint_link( - &mut self, - iff_pointopoint_interface_is_pointtopoint_link: u8, - ) { - set_bit_range!( - &mut self.flags, - iff_pointopoint_interface_is_pointtopoint_link, - u32, - u8, - 4, - 0 - ); - } + pub fn iff_loopback_is_a_loopback_net(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 3, 0) + } - pub fn iff_loopback_is_a_loopback_net(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 3, 0) - } + pub fn set_iff_loopback_is_a_loopback_net(&mut self, iff_loopback_is_a_loopback_net: u8) { + set_bit_range!( + &mut self.flags, + iff_loopback_is_a_loopback_net, + u32, + u8, + 3, + 0 + ); + } - pub fn set_iff_loopback_is_a_loopback_net(&mut self, iff_loopback_is_a_loopback_net: u8) { - set_bit_range!( - &mut self.flags, - iff_loopback_is_a_loopback_net, - u32, - u8, - 3, - 0 - ); - } + pub fn iff_debug_broadcast_address_valid(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 2, 0) + } - pub fn iff_debug_broadcast_address_valid(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 2, 0) - } + pub fn set_iff_debug_broadcast_address_valid( + &mut self, + iff_debug_broadcast_address_valid: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_debug_broadcast_address_valid, + u32, + u8, + 2, + 0 + ); + } - pub fn set_iff_debug_broadcast_address_valid(&mut self, iff_debug_broadcast_address_valid: u8) { - set_bit_range!( - &mut self.flags, - iff_debug_broadcast_address_valid, - u32, - u8, - 2, - 0 - ); - } + pub fn iff_broadcast_broadcast_address_valid(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 1, 0) + } - pub fn iff_broadcast_broadcast_address_valid(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 1, 0) - } + pub fn set_iff_broadcast_broadcast_address_valid( + &mut self, + iff_broadcast_broadcast_address_valid: u8, + ) { + set_bit_range!( + &mut self.flags, + iff_broadcast_broadcast_address_valid, + u32, + u8, + 1, + 0 + ); + } - pub fn set_iff_broadcast_broadcast_address_valid( - &mut self, - iff_broadcast_broadcast_address_valid: u8, - ) { - set_bit_range!( - &mut self.flags, - iff_broadcast_broadcast_address_valid, - u32, - u8, - 1, - 0 - ); - } + pub fn iff_up_interface_is_up(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 0, 0) + } - pub fn iff_up_interface_is_up(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 0, 0) + pub fn set_iff_up_interface_is_up(&mut self, iff_up_interface_is_up: u8) { + set_bit_range!(&mut self.flags, iff_up_interface_is_up, u32, u8, 0, 0); + } } - pub fn set_iff_up_interface_is_up(&mut self, iff_up_interface_is_up: u8) { - set_bit_range!(&mut self.flags, iff_up_interface_is_up, u32, u8, 0, 0); + impl ConcreteMessage for MsgNetworkStateResp { + const MESSAGE_TYPE: u16 = 187; + const MESSAGE_NAME: &'static str = "MSG_NETWORK_STATE_RESP"; } -} - -impl ConcreteMessage for MsgNetworkStateResp { - const MESSAGE_TYPE: u16 = 187; - const MESSAGE_NAME: &'static str = "MSG_NETWORK_STATE_RESP"; -} -impl SbpMessage for MsgNetworkStateResp { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgNetworkStateResp { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgNetworkStateResp { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgNetworkStateResp(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgNetworkStateResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgNetworkStateResp(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgNetworkStateResp { - const MIN_LEN: usize = <[u8; 4] as WireFormat>::MIN_LEN - + ::MIN_LEN - + <[u8; 16] as WireFormat>::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.ipv4_address) - + WireFormat::len(&self.ipv4_mask_size) - + WireFormat::len(&self.ipv6_address) - + WireFormat::len(&self.ipv6_mask_size) - + WireFormat::len(&self.rx_bytes) - + WireFormat::len(&self.tx_bytes) - + WireFormat::len(&self.interface_name) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgNetworkStateResp { + const MIN_LEN: usize = <[u8; 4] as WireFormat>::MIN_LEN + + ::MIN_LEN + + <[u8; 16] as WireFormat>::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.ipv4_address) + + WireFormat::len(&self.ipv4_mask_size) + + WireFormat::len(&self.ipv6_address) + + WireFormat::len(&self.ipv6_mask_size) + + WireFormat::len(&self.rx_bytes) + + WireFormat::len(&self.tx_bytes) + + WireFormat::len(&self.interface_name) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Reset the device (host => Piksi) -/// -/// This message from the host resets the Piksi back into the bootloader. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgReset { - /// 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, -} +pub mod msg_reset { + #![allow(unused_imports)] -impl MsgReset { - pub fn default_settings(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 0, 0) { - 0 => Some(MsgResetDefaultSettings::PreserveExistingSettings), - 1 => Some(MsgResetDefaultSettings::ResoreDefaultSettings), - _ => None, - } - } + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; - pub fn set_default_settings(&mut self, default_settings: MsgResetDefaultSettings) { - set_bit_range!(&mut self.flags, default_settings, u32, u8, 0, 0); + /// Reset the device (host => Piksi) + /// + /// This message from the host resets the Piksi back into the bootloader. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgReset { + /// 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 ConcreteMessage for MsgReset { - const MESSAGE_TYPE: u16 = 182; - const MESSAGE_NAME: &'static str = "MSG_RESET"; -} + impl MsgReset { + pub fn default_settings(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 0, 0) { + 0 => Some(DefaultSettings::PreserveExistingSettings), + 1 => Some(DefaultSettings::ResoreDefaultSettings), + _ => None, + } + } -impl SbpMessage for MsgReset { - 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); + pub fn set_default_settings(&mut self, default_settings: DefaultSettings) { + set_bit_range!(&mut self.flags, default_settings, u32, u8, 0, 0); + } } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgReset { + const MESSAGE_TYPE: u16 = 182; + const MESSAGE_NAME: &'static str = "MSG_RESET"; } -} -impl TryFrom for MsgReset { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgReset(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgReset { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgReset { - const MIN_LEN: usize = ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.flags, buf); + impl TryFrom for MsgReset { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgReset(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgReset { - sender_id: None, - flags: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgReset { + const MIN_LEN: usize = ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgReset { + sender_id: None, + flags: WireFormat::parse_unchecked(buf), + } } } -} -/// Default settings. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgResetDefaultSettings { - /// Preserve existing settings. - PreserveExistingSettings = 0, + /// Default settings. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum DefaultSettings { + /// Preserve existing settings. + PreserveExistingSettings = 0, - /// Resore default settings. - ResoreDefaultSettings = 1, -} + /// Resore default settings. + ResoreDefaultSettings = 1, + } -impl std::fmt::Display for MsgResetDefaultSettings { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgResetDefaultSettings::PreserveExistingSettings => { - f.write_str("Preserve existing settings.") - } - MsgResetDefaultSettings::ResoreDefaultSettings => { - f.write_str("Resore default settings.") + impl std::fmt::Display for DefaultSettings { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + DefaultSettings::PreserveExistingSettings => { + f.write_str("Preserve existing settings.") + } + DefaultSettings::ResoreDefaultSettings => f.write_str("Resore default settings."), } } } } -/// Reset the device (host => Piksi) -/// -/// This message from the host resets the Piksi back into the bootloader. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgResetDep { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, -} +pub mod msg_reset_dep { + #![allow(unused_imports)] -impl ConcreteMessage for MsgResetDep { - const MESSAGE_TYPE: u16 = 178; - const MESSAGE_NAME: &'static str = "MSG_RESET_DEP"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgResetDep { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE + /// Reset the device (host => Piksi) + /// + /// This message from the host resets the Piksi back into the bootloader. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgResetDep { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgResetDep { + const MESSAGE_TYPE: u16 = 178; + const MESSAGE_NAME: &'static str = "MSG_RESET_DEP"; } -} -impl TryFrom for MsgResetDep { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgResetDep(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgResetDep { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgResetDep { - const MIN_LEN: usize = 0; - fn len(&self) -> usize { - 0 + impl TryFrom for MsgResetDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgResetDep(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn write(&self, _buf: &mut B) {} - fn parse_unchecked(_buf: &mut B) -> Self { - MsgResetDep { sender_id: None } + + impl WireFormat for MsgResetDep { + const MIN_LEN: usize = 0; + fn len(&self) -> usize { + 0 + } + fn write(&self, _buf: &mut B) {} + fn parse_unchecked(_buf: &mut B) -> Self { + MsgResetDep { sender_id: None } + } } } -/// Reset IAR filters (host => Piksi) -/// -/// This message resets either the DGNSS Kalman filters or Integer Ambiguity -/// Resolution (IAR) process. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgResetFilters { - /// 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, -} +pub mod msg_reset_filters { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Reset IAR filters (host => Piksi) + /// + /// This message resets either the DGNSS Kalman filters or Integer Ambiguity + /// Resolution (IAR) process. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgResetFilters { + /// 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 { + pub fn filter_or_process_to_reset(&self) -> Option { + match get_bit_range!(self.filter, u8, u8, 1, 0) { + 0 => Some(FilterOrProcessToReset::DgnssFilter), + 1 => Some(FilterOrProcessToReset::IarProcess), + 2 => Some(FilterOrProcessToReset::InertialFilter), + _ => None, + } + } -impl MsgResetFilters { - pub fn filter_or_process_to_reset(&self) -> Option { - match get_bit_range!(self.filter, u8, u8, 1, 0) { - 0 => Some(MsgResetFiltersFilterOrProcessToReset::DgnssFilter), - 1 => Some(MsgResetFiltersFilterOrProcessToReset::IarProcess), - 2 => Some(MsgResetFiltersFilterOrProcessToReset::InertialFilter), - _ => None, + pub fn set_filter_or_process_to_reset( + &mut self, + filter_or_process_to_reset: FilterOrProcessToReset, + ) { + set_bit_range!(&mut self.filter, filter_or_process_to_reset, u8, u8, 1, 0); } } - pub fn set_filter_or_process_to_reset( - &mut self, - filter_or_process_to_reset: MsgResetFiltersFilterOrProcessToReset, - ) { - set_bit_range!(&mut self.filter, filter_or_process_to_reset, u8, u8, 1, 0); + impl ConcreteMessage for MsgResetFilters { + const MESSAGE_TYPE: u16 = 34; + const MESSAGE_NAME: &'static str = "MSG_RESET_FILTERS"; } -} - -impl ConcreteMessage for MsgResetFilters { - const MESSAGE_TYPE: u16 = 34; - const MESSAGE_NAME: &'static str = "MSG_RESET_FILTERS"; -} -impl SbpMessage for MsgResetFilters { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgResetFilters { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgResetFilters { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgResetFilters(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgResetFilters { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgResetFilters(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgResetFilters { - const MIN_LEN: usize = ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.filter) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.filter, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgResetFilters { - sender_id: None, - filter: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgResetFilters { + const MIN_LEN: usize = ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.filter) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.filter, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgResetFilters { + sender_id: None, + filter: WireFormat::parse_unchecked(buf), + } } } -} -/// Filter or process to reset -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgResetFiltersFilterOrProcessToReset { - /// DGNSS filter - DgnssFilter = 0, + /// Filter or process to reset + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FilterOrProcessToReset { + /// DGNSS filter + DgnssFilter = 0, - /// IAR process - IarProcess = 1, + /// IAR process + IarProcess = 1, - /// Inertial filter - InertialFilter = 2, -} + /// Inertial filter + InertialFilter = 2, + } -impl std::fmt::Display for MsgResetFiltersFilterOrProcessToReset { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgResetFiltersFilterOrProcessToReset::DgnssFilter => f.write_str("DGNSS filter"), - MsgResetFiltersFilterOrProcessToReset::IarProcess => f.write_str("IAR process"), - MsgResetFiltersFilterOrProcessToReset::InertialFilter => f.write_str("Inertial filter"), + impl std::fmt::Display for FilterOrProcessToReset { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FilterOrProcessToReset::DgnssFilter => f.write_str("DGNSS filter"), + FilterOrProcessToReset::IarProcess => f.write_str("IAR process"), + FilterOrProcessToReset::InertialFilter => f.write_str("Inertial filter"), + } } } } -/// Send GPS time from host (host => Piksi) -/// -/// This message sets up timing functionality using a coarse GPS time estimate -/// sent by the host. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSetTime { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, -} +pub mod msg_set_time { + #![allow(unused_imports)] -impl ConcreteMessage for MsgSetTime { - const MESSAGE_TYPE: u16 = 104; - const MESSAGE_NAME: &'static str = "MSG_SET_TIME"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgSetTime { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + /// Send GPS time from host (host => Piksi) + /// + /// This message sets up timing functionality using a coarse GPS time estimate + /// sent by the host. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSetTime { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgSetTime { + const MESSAGE_TYPE: u16 = 104; + const MESSAGE_NAME: &'static str = "MSG_SET_TIME"; } -} -impl TryFrom for MsgSetTime { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSetTime(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgSetTime { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgSetTime { - const MIN_LEN: usize = 0; - fn len(&self) -> usize { - 0 - } - fn write(&self, _buf: &mut B) {} - fn parse_unchecked(_buf: &mut B) -> Self { - MsgSetTime { sender_id: None } + impl TryFrom for MsgSetTime { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSetTime(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } -} - -/// Spectrum analyzer -/// -/// Spectrum analyzer packet. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSpecan { - /// 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 - #[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 ConcreteMessage for MsgSpecan { - const MESSAGE_TYPE: u16 = 81; - const MESSAGE_NAME: &'static str = "MSG_SPECAN"; -} - -impl SbpMessage for MsgSpecan { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl WireFormat for MsgSetTime { + const MIN_LEN: usize = 0; + fn len(&self) -> usize { + 0 + } + fn write(&self, _buf: &mut B) {} + fn parse_unchecked(_buf: &mut B) -> Self { + MsgSetTime { sender_id: None } + } } } -impl TryFrom for MsgSpecan { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSpecan(m) => Ok(m), - _ => Err(TryFromSbpError), +pub mod msg_specan { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Spectrum analyzer + /// + /// Spectrum analyzer packet. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSpecan { + /// 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 + #[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 ConcreteMessage for MsgSpecan { + const MESSAGE_TYPE: u16 = 81; + const MESSAGE_NAME: &'static str = "MSG_SPECAN"; + } + + impl SbpMessage for MsgSpecan { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgSpecan { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.channel_tag) - + WireFormat::len(&self.t) - + WireFormat::len(&self.freq_ref) - + WireFormat::len(&self.freq_step) - + WireFormat::len(&self.amplitude_ref) - + WireFormat::len(&self.amplitude_unit) - + WireFormat::len(&self.amplitude_value) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl TryFrom for MsgSpecan { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSpecan(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSpecanDep { - /// 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 - #[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 ConcreteMessage for MsgSpecanDep { - const MESSAGE_TYPE: u16 = 80; - const MESSAGE_NAME: &'static str = "MSG_SPECAN_DEP"; -} - -impl SbpMessage for MsgSpecanDep { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl WireFormat for MsgSpecan { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.channel_tag) + + WireFormat::len(&self.t) + + WireFormat::len(&self.freq_ref) + + WireFormat::len(&self.freq_step) + + WireFormat::len(&self.amplitude_ref) + + WireFormat::len(&self.amplitude_unit) + + WireFormat::len(&self.amplitude_value) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } + } } } -impl TryFrom for MsgSpecanDep { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSpecanDep(m) => Ok(m), - _ => Err(TryFromSbpError), +pub mod msg_specan_dep { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Deprecated + /// + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSpecanDep { + /// 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 + #[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 ConcreteMessage for MsgSpecanDep { + const MESSAGE_TYPE: u16 = 80; + const MESSAGE_NAME: &'static str = "MSG_SPECAN_DEP"; + } + + impl SbpMessage for MsgSpecanDep { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgSpecanDep { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.channel_tag) - + WireFormat::len(&self.t) - + WireFormat::len(&self.freq_ref) - + WireFormat::len(&self.freq_step) - + WireFormat::len(&self.amplitude_ref) - + WireFormat::len(&self.amplitude_unit) - + WireFormat::len(&self.amplitude_value) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl TryFrom for MsgSpecanDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSpecanDep(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} - -/// State of an RTOS thread -/// -/// The thread usage message from the device reports real-time operating -/// system (RTOS) thread usage statistics for the named thread. The reported -/// percentage values must be normalized. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgThreadState { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, - /// Thread name (NULL terminated) - #[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 ConcreteMessage for MsgThreadState { - const MESSAGE_TYPE: u16 = 23; - const MESSAGE_NAME: &'static str = "MSG_THREAD_STATE"; -} - -impl SbpMessage for MsgThreadState { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl WireFormat for MsgSpecanDep { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.channel_tag) + + WireFormat::len(&self.t) + + WireFormat::len(&self.freq_ref) + + WireFormat::len(&self.freq_step) + + WireFormat::len(&self.amplitude_ref) + + WireFormat::len(&self.amplitude_unit) + + WireFormat::len(&self.amplitude_value) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } + } } } -impl TryFrom for MsgThreadState { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgThreadState(m) => Ok(m), - _ => Err(TryFromSbpError), +pub mod msg_thread_state { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// State of an RTOS thread + /// + /// The thread usage message from the device reports real-time operating + /// system (RTOS) thread usage statistics for the named thread. The reported + /// percentage values must be normalized. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgThreadState { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + /// Thread name (NULL terminated) + #[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 ConcreteMessage for MsgThreadState { + const MESSAGE_TYPE: u16 = 23; + const MESSAGE_NAME: &'static str = "MSG_THREAD_STATE"; + } + + impl SbpMessage for MsgThreadState { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgThreadState { - const MIN_LEN: usize = as WireFormat>::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.name) + WireFormat::len(&self.cpu) + WireFormat::len(&self.stack_free) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.name, buf); - WireFormat::write(&self.cpu, buf); - WireFormat::write(&self.stack_free, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgThreadState { - sender_id: None, - name: WireFormat::parse_unchecked(buf), - cpu: WireFormat::parse_unchecked(buf), - stack_free: WireFormat::parse_unchecked(buf), + impl TryFrom for MsgThreadState { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgThreadState(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -/// State of the UART channels -/// -/// The UART message reports data latency and throughput of the UART channels -/// providing SBP I/O. On the default Piksi configuration, UARTs A and B are -/// used for telemetry radios, but can also be host access ports for embedded -/// hosts, or other interfaces in future. The reported percentage values must -/// be normalized. Observations latency and period can be used to assess the -/// health of the differential corrections link. Latency provides the -/// timeliness of received base observations while the period indicates their -/// likelihood of transmission. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgUartState { - /// 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 ConcreteMessage for MsgUartState { - const MESSAGE_TYPE: u16 = 29; - const MESSAGE_NAME: &'static str = "MSG_UART_STATE"; -} - -impl SbpMessage for MsgUartState { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl WireFormat for MsgThreadState { + const MIN_LEN: usize = as WireFormat>::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.name) + + WireFormat::len(&self.cpu) + + WireFormat::len(&self.stack_free) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.name, buf); + WireFormat::write(&self.cpu, buf); + WireFormat::write(&self.stack_free, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgThreadState { + sender_id: None, + name: WireFormat::parse_unchecked(buf), + cpu: WireFormat::parse_unchecked(buf), + stack_free: WireFormat::parse_unchecked(buf), + } + } } } -impl TryFrom for MsgUartState { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgUartState(m) => Ok(m), - _ => Err(TryFromSbpError), +pub mod msg_uart_state { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// State of the UART channels + /// + /// The UART message reports data latency and throughput of the UART channels + /// providing SBP I/O. On the default Piksi configuration, UARTs A and B are + /// used for telemetry radios, but can also be host access ports for embedded + /// hosts, or other interfaces in future. The reported percentage values must + /// be normalized. Observations latency and period can be used to assess the + /// health of the differential corrections link. Latency provides the + /// timeliness of received base observations while the period indicates their + /// likelihood of transmission. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgUartState { + /// 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 ConcreteMessage for MsgUartState { + const MESSAGE_TYPE: u16 = 29; + const MESSAGE_NAME: &'static str = "MSG_UART_STATE"; + } + + impl SbpMessage for MsgUartState { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgUartState { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.uart_a) - + WireFormat::len(&self.uart_b) - + WireFormat::len(&self.uart_ftdi) - + WireFormat::len(&self.latency) - + WireFormat::len(&self.obs_period) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl TryFrom for MsgUartState { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgUartState(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} - -/// Deprecated -/// -/// Deprecated -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgUartStateDepa { - /// 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 ConcreteMessage for MsgUartStateDepa { - const MESSAGE_TYPE: u16 = 24; - const MESSAGE_NAME: &'static str = "MSG_UART_STATE_DEPA"; -} -impl SbpMessage for MsgUartStateDepa { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl WireFormat for MsgUartState { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.uart_a) + + WireFormat::len(&self.uart_b) + + WireFormat::len(&self.uart_ftdi) + + WireFormat::len(&self.latency) + + WireFormat::len(&self.obs_period) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } + } } } -impl TryFrom for MsgUartStateDepa { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgUartStateDepa(m) => Ok(m), - _ => Err(TryFromSbpError), +pub mod msg_uart_state_depa { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Deprecated + /// + /// Deprecated + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgUartStateDepa { + /// 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 ConcreteMessage for MsgUartStateDepa { + const MESSAGE_TYPE: u16 = 24; + const MESSAGE_NAME: &'static str = "MSG_UART_STATE_DEPA"; + } + + impl SbpMessage for MsgUartStateDepa { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgUartStateDepa { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.uart_a) - + WireFormat::len(&self.uart_b) - + WireFormat::len(&self.uart_ftdi) - + WireFormat::len(&self.latency) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl TryFrom for MsgUartStateDepa { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgUartStateDepa(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} - -/// Bandwidth usage measurement for a single interface -/// -/// The bandwidth usage for each interface can be reported within this struct -/// and utilize multiple fields to fully specify the type of traffic that is -/// being tracked. As either the interval of collection or the collection time -/// may vary, both a timestamp and period field is provided, though may not -/// necessarily be populated with a value. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "interface_name")))] - pub interface_name: SbpString<[u8; 16], Unterminated>, -} -impl WireFormat for NetworkUsage { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.duration) - + WireFormat::len(&self.total_bytes) - + WireFormat::len(&self.rx_bytes) - + WireFormat::len(&self.tx_bytes) - + WireFormat::len(&self.interface_name) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgUartStateDepa { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.uart_a) + + WireFormat::len(&self.uart_b) + + WireFormat::len(&self.uart_ftdi) + + WireFormat::len(&self.latency) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// base station observation message receipt period -/// -/// Statistics on the period of observations received from the base station. -/// As complete observation sets are received, their time of reception is -/// compared with the prior set''s time of reception. This measurement -/// provides a proxy for link quality as incomplete or missing sets will -/// increase the period. Long periods can cause momentary RTK solution -/// outages. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 WireFormat for Period { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.avg) - + WireFormat::len(&self.pmin) - + WireFormat::len(&self.pmax) - + WireFormat::len(&self.current) - } - fn write(&self, buf: &mut B) { - 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 B) -> Self { - Period { - avg: WireFormat::parse_unchecked(buf), - pmin: WireFormat::parse_unchecked(buf), - pmax: WireFormat::parse_unchecked(buf), - current: WireFormat::parse_unchecked(buf), +pub mod network_usage { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Bandwidth usage measurement for a single interface + /// + /// The bandwidth usage for each interface can be reported within this struct + /// and utilize multiple fields to fully specify the type of traffic that is + /// being tracked. As either the interval of collection or the collection time + /// may vary, both a timestamp and period field is provided, though may not + /// necessarily be populated with a value. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "interface_name")))] + pub interface_name: SbpString<[u8; 16], Unterminated>, + } + + impl WireFormat for NetworkUsage { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.duration) + + WireFormat::len(&self.total_bytes) + + WireFormat::len(&self.rx_bytes) + + WireFormat::len(&self.tx_bytes) + + WireFormat::len(&self.interface_name) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// State of the UART channel -/// -/// Throughput, utilization, and error counts on the RX/TX buffers of this -/// UART channel. The reported percentage values must be normalized. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, +pub mod period { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// base station observation message receipt period + /// + /// Statistics on the period of observations received from the base station. + /// As complete observation sets are received, their time of reception is + /// compared with the prior set''s time of reception. This measurement + /// provides a proxy for link quality as incomplete or missing sets will + /// increase the period. Long periods can cause momentary RTK solution + /// outages. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 WireFormat for Period { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.avg) + + WireFormat::len(&self.pmin) + + WireFormat::len(&self.pmax) + + WireFormat::len(&self.current) + } + fn write(&self, buf: &mut B) { + 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 B) -> Self { + Period { + avg: WireFormat::parse_unchecked(buf), + pmin: WireFormat::parse_unchecked(buf), + pmax: WireFormat::parse_unchecked(buf), + current: WireFormat::parse_unchecked(buf), + } + } + } } -impl WireFormat for UARTChannel { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tx_throughput) - + WireFormat::len(&self.rx_throughput) - + WireFormat::len(&self.crc_error_count) - + WireFormat::len(&self.io_error_count) - + WireFormat::len(&self.tx_buffer_level) - + WireFormat::len(&self.rx_buffer_level) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), +pub mod uart_channel { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// State of the UART channel + /// + /// Throughput, utilization, and error counts on the RX/TX buffers of this + /// UART channel. The reported percentage values must be normalized. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 WireFormat for UARTChannel { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tx_throughput) + + WireFormat::len(&self.rx_throughput) + + WireFormat::len(&self.crc_error_count) + + WireFormat::len(&self.io_error_count) + + WireFormat::len(&self.tx_buffer_level) + + WireFormat::len(&self.rx_buffer_level) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } diff --git a/rust/sbp/src/messages/sbas.rs b/rust/sbp/src/messages/sbas.rs index 43357da973..7d40e0d49e 100644 --- a/rust/sbp/src/messages/sbas.rs +++ b/rust/sbp/src/messages/sbas.rs @@ -13,102 +13,107 @@ // with generate.py. Please do not hand edit! //****************************************************************************/ //! SBAS data +pub use msg_sbas_raw::MsgSbasRaw; -use super::gnss::*; +pub mod msg_sbas_raw { + #![allow(unused_imports)] -use super::lib::*; + use super::*; + use crate::messages::gnss::*; + use crate::messages::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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSbasRaw { - /// 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). - #[cfg_attr(feature = "serde", serde(rename(serialize = "data")))] - pub data: [u8; 27], -} - -impl ConcreteMessage for MsgSbasRaw { - const MESSAGE_TYPE: u16 = 30583; - const MESSAGE_NAME: &'static str = "MSG_SBAS_RAW"; -} - -impl SbpMessage for MsgSbasRaw { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSbasRaw { + /// 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). + #[cfg_attr(feature = "serde", serde(rename(serialize = "data")))] + pub data: [u8; 27], } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + + impl ConcreteMessage for MsgSbasRaw { + const MESSAGE_TYPE: u16 = 30583; + const MESSAGE_NAME: &'static str = "MSG_SBAS_RAW"; } -} -impl TryFrom for MsgSbasRaw { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSbasRaw(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgSbasRaw { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) } } -} -impl WireFormat for MsgSbasRaw { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + <[u8; 27] as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sid) - + WireFormat::len(&self.tow) - + WireFormat::len(&self.message_type) - + WireFormat::len(&self.data) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sid, buf); - WireFormat::write(&self.tow, buf); - WireFormat::write(&self.message_type, buf); - WireFormat::write(&self.data, buf); + impl TryFrom for MsgSbasRaw { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSbasRaw(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> 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), + + impl WireFormat for MsgSbasRaw { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + <[u8; 27] as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sid) + + WireFormat::len(&self.tow) + + WireFormat::len(&self.message_type) + + WireFormat::len(&self.data) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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 ce379fea7f..e78ef99b9a 100644 --- a/rust/sbp/src/messages/settings.rs +++ b/rust/sbp/src/messages/settings.rs @@ -38,812 +38,897 @@ //! , the open source python command line utility for reading, writing, and //! saving settings in the piksi_tools repository on github as a helpful //! reference and example. - -use super::lib::*; - -/// Finished reading settings (host <= device) -/// -/// The settings message for indicating end of the settings values. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSettingsReadByIndexDone { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, -} - -impl ConcreteMessage for MsgSettingsReadByIndexDone { - const MESSAGE_TYPE: u16 = 166; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_READ_BY_INDEX_DONE"; -} - -impl SbpMessage for MsgSettingsReadByIndexDone { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub use msg_settings_read_by_index_done::MsgSettingsReadByIndexDone; +pub use msg_settings_read_by_index_req::MsgSettingsReadByIndexReq; +pub use msg_settings_read_by_index_resp::MsgSettingsReadByIndexResp; +pub use msg_settings_read_req::MsgSettingsReadReq; +pub use msg_settings_read_resp::MsgSettingsReadResp; +pub use msg_settings_register::MsgSettingsRegister; +pub use msg_settings_register_resp::MsgSettingsRegisterResp; +pub use msg_settings_save::MsgSettingsSave; +pub use msg_settings_write::MsgSettingsWrite; +pub use msg_settings_write_resp::MsgSettingsWriteResp; + +pub mod msg_settings_read_by_index_done { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Finished reading settings (host <= device) + /// + /// The settings message for indicating end of the settings values. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSettingsReadByIndexDone { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + } + + impl ConcreteMessage for MsgSettingsReadByIndexDone { + const MESSAGE_TYPE: u16 = 166; + const MESSAGE_NAME: &'static str = "MSG_SETTINGS_READ_BY_INDEX_DONE"; + } + + impl SbpMessage for MsgSettingsReadByIndexDone { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgSettingsReadByIndexDone { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSettingsReadByIndexDone(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgSettingsReadByIndexDone { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSettingsReadByIndexDone(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgSettingsReadByIndexDone { - const MIN_LEN: usize = 0; - fn len(&self) -> usize { - 0 - } - fn write(&self, _buf: &mut B) {} - fn parse_unchecked(_buf: &mut B) -> Self { - MsgSettingsReadByIndexDone { sender_id: None } + impl WireFormat for MsgSettingsReadByIndexDone { + const MIN_LEN: usize = 0; + fn len(&self) -> usize { + 0 + } + fn write(&self, _buf: &mut B) {} + fn parse_unchecked(_buf: &mut B) -> Self { + MsgSettingsReadByIndexDone { sender_id: None } + } } } -/// Read setting by direct index (host => device) -/// -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSettingsReadByIndexReq { - /// 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, -} +pub mod msg_settings_read_by_index_req { + #![allow(unused_imports)] -impl ConcreteMessage for MsgSettingsReadByIndexReq { - const MESSAGE_TYPE: u16 = 162; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_READ_BY_INDEX_REQ"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgSettingsReadByIndexReq { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME + /// Read setting by direct index (host => device) + /// + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSettingsReadByIndexReq { + /// 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, } - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl 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 = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSettingsReadByIndexReq(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgSettingsReadByIndexReq { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgSettingsReadByIndexReq { - const MIN_LEN: usize = ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.index) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.index, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgSettingsReadByIndexReq { - sender_id: None, - index: WireFormat::parse_unchecked(buf), + impl TryFrom for MsgSettingsReadByIndexReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSettingsReadByIndexReq(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -/// Read setting by direct index (host <= device) -/// -/// The settings message that reports the value of a setting at an index. -/// -/// In the string field, it reports NULL-terminated and delimited string with -/// contents "SECTION_SETTING\0SETTING\0VALUE\0FORMAT_TYPE\0". where the '\0' -/// escape sequence denotes the NULL character and where quotation marks are -/// omitted. The FORMAT_TYPE field is optional and denotes possible string -/// values of the setting as a hint to the user. If included, the format type -/// portion of the string has the format "enum:value1,value2,value3". An -/// example string that could be sent from the device is -/// "simulator\0enabled\0True\0enum:True,False\0". -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSettingsReadByIndexResp { - /// 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" - #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] - pub setting: SbpString, Multipart>, -} - -impl ConcreteMessage for MsgSettingsReadByIndexResp { - const MESSAGE_TYPE: u16 = 167; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_READ_BY_INDEX_RESP"; -} - -impl SbpMessage for MsgSettingsReadByIndexResp { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl WireFormat for MsgSettingsReadByIndexReq { + const MIN_LEN: usize = ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.index) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.index, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgSettingsReadByIndexReq { + sender_id: None, + index: WireFormat::parse_unchecked(buf), + } + } } } -impl TryFrom for MsgSettingsReadByIndexResp { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSettingsReadByIndexResp(m) => Ok(m), - _ => Err(TryFromSbpError), +pub mod msg_settings_read_by_index_resp { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Read setting by direct index (host <= device) + /// + /// The settings message that reports the value of a setting at an index. + /// + /// In the string field, it reports NULL-terminated and delimited string with + /// contents "SECTION_SETTING\0SETTING\0VALUE\0FORMAT_TYPE\0". where the '\0' + /// escape sequence denotes the NULL character and where quotation marks are + /// omitted. The FORMAT_TYPE field is optional and denotes possible string + /// values of the setting as a hint to the user. If included, the format type + /// portion of the string has the format "enum:value1,value2,value3". An + /// example string that could be sent from the device is + /// "simulator\0enabled\0True\0enum:True,False\0". + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSettingsReadByIndexResp { + /// 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" + #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] + pub setting: SbpString, Multipart>, + } + + impl ConcreteMessage for MsgSettingsReadByIndexResp { + const MESSAGE_TYPE: u16 = 167; + const MESSAGE_NAME: &'static str = "MSG_SETTINGS_READ_BY_INDEX_RESP"; + } + + impl SbpMessage for MsgSettingsReadByIndexResp { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgSettingsReadByIndexResp { - const MIN_LEN: usize = - ::MIN_LEN + , Multipart> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.index) + WireFormat::len(&self.setting) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.index, buf); - WireFormat::write(&self.setting, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgSettingsReadByIndexResp { - sender_id: None, - index: WireFormat::parse_unchecked(buf), - setting: WireFormat::parse_unchecked(buf), + impl TryFrom for MsgSettingsReadByIndexResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSettingsReadByIndexResp(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -/// Read device configuration settings (host => device) -/// -/// The setting message that reads the device configuration. The string field -/// is a NULL-terminated and NULL-delimited string with contents -/// "SECTION_SETTING\0SETTING\0" where the '\0' escape sequence denotes the -/// NULL character and where quotation marks are omitted. An example string -/// that could be sent to a device is "solution\0soln_freq\0". A device will -/// only respond to this message when it is received from sender ID 0x42. A -/// device should respond with a MSG_SETTINGS_READ_RESP message (msg_id -/// 0x00A5). -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSettingsReadReq { - /// 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" - #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] - pub setting: SbpString, Multipart>, -} - -impl ConcreteMessage for MsgSettingsReadReq { - const MESSAGE_TYPE: u16 = 164; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_READ_REQ"; -} - -impl SbpMessage for MsgSettingsReadReq { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl WireFormat for MsgSettingsReadByIndexResp { + const MIN_LEN: usize = + ::MIN_LEN + , Multipart> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.index) + WireFormat::len(&self.setting) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.index, buf); + WireFormat::write(&self.setting, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgSettingsReadByIndexResp { + sender_id: None, + index: WireFormat::parse_unchecked(buf), + setting: WireFormat::parse_unchecked(buf), + } + } } } -impl TryFrom for MsgSettingsReadReq { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSettingsReadReq(m) => Ok(m), - _ => Err(TryFromSbpError), +pub mod msg_settings_read_req { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Read device configuration settings (host => device) + /// + /// The setting message that reads the device configuration. The string field + /// is a NULL-terminated and NULL-delimited string with contents + /// "SECTION_SETTING\0SETTING\0" where the '\0' escape sequence denotes the + /// NULL character and where quotation marks are omitted. An example string + /// that could be sent to a device is "solution\0soln_freq\0". A device will + /// only respond to this message when it is received from sender ID 0x42. A + /// device should respond with a MSG_SETTINGS_READ_RESP message (msg_id + /// 0x00A5). + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSettingsReadReq { + /// 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" + #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] + pub setting: SbpString, Multipart>, + } + + impl ConcreteMessage for MsgSettingsReadReq { + const MESSAGE_TYPE: u16 = 164; + const MESSAGE_NAME: &'static str = "MSG_SETTINGS_READ_REQ"; + } + + impl SbpMessage for MsgSettingsReadReq { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgSettingsReadReq { - const MIN_LEN: usize = , Multipart> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.setting) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.setting, buf); + impl TryFrom for MsgSettingsReadReq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSettingsReadReq(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgSettingsReadReq { - sender_id: None, - setting: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgSettingsReadReq { + const MIN_LEN: usize = , Multipart> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.setting) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.setting, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgSettingsReadReq { + sender_id: None, + setting: WireFormat::parse_unchecked(buf), + } } } } -/// Read device configuration settings (host <= device) -/// -/// The setting message with which the device responds after a -/// MSG_SETTING_READ_REQ is sent to device. The string field is a NULL- -/// terminated and NULL-delimited string with contents -/// "SECTION_SETTING\0SETTING\0VALUE\0" where the '\0' escape sequence denotes -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSettingsReadResp { - /// 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" - #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] - pub setting: SbpString, Multipart>, -} +pub mod msg_settings_read_resp { + #![allow(unused_imports)] -impl ConcreteMessage for MsgSettingsReadResp { - const MESSAGE_TYPE: u16 = 165; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_READ_RESP"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgSettingsReadResp { - 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); + /// Read device configuration settings (host <= device) + /// + /// The setting message with which the device responds after a + /// MSG_SETTING_READ_REQ is sent to device. The string field is a NULL- + /// terminated and NULL-delimited string with contents + /// "SECTION_SETTING\0SETTING\0VALUE\0" where the '\0' escape sequence denotes + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSettingsReadResp { + /// 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" + #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] + pub setting: SbpString, Multipart>, } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgSettingsReadResp { + const MESSAGE_TYPE: u16 = 165; + const MESSAGE_NAME: &'static str = "MSG_SETTINGS_READ_RESP"; } -} -impl TryFrom for MsgSettingsReadResp { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSettingsReadResp(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgSettingsReadResp { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgSettingsReadResp { - const MIN_LEN: usize = , Multipart> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.setting) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.setting, buf); + impl TryFrom for MsgSettingsReadResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSettingsReadResp(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgSettingsReadResp { - sender_id: None, - setting: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgSettingsReadResp { + const MIN_LEN: usize = , Multipart> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.setting) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.setting, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgSettingsReadResp { + sender_id: None, + setting: WireFormat::parse_unchecked(buf), + } } } } -/// Register setting and default value (device => host) -/// -/// This message registers the presence and default value of a setting with a -/// settings daemon. The host should reply with MSG_SETTINGS_WRITE for this -/// setting to set the initial value. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSettingsRegister { - /// 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". - #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] - pub setting: SbpString, Multipart>, -} +pub mod msg_settings_register { + #![allow(unused_imports)] -impl ConcreteMessage for MsgSettingsRegister { - const MESSAGE_TYPE: u16 = 174; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_REGISTER"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgSettingsRegister { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + /// Register setting and default value (device => host) + /// + /// This message registers the presence and default value of a setting with a + /// settings daemon. The host should reply with MSG_SETTINGS_WRITE for this + /// setting to set the initial value. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSettingsRegister { + /// 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". + #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] + pub setting: SbpString, Multipart>, } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgSettingsRegister { + const MESSAGE_TYPE: u16 = 174; + const MESSAGE_NAME: &'static str = "MSG_SETTINGS_REGISTER"; } -} -impl TryFrom for MsgSettingsRegister { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSettingsRegister(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgSettingsRegister { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgSettingsRegister { - const MIN_LEN: usize = , Multipart> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.setting) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.setting, buf); + impl TryFrom for MsgSettingsRegister { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSettingsRegister(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgSettingsRegister { - sender_id: None, - setting: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgSettingsRegister { + const MIN_LEN: usize = , Multipart> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.setting) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.setting, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgSettingsRegister { + sender_id: None, + setting: WireFormat::parse_unchecked(buf), + } } } } -/// Register setting and default value (device <= host) -/// -/// This message responds to setting registration with the effective value. -/// The effective value shall differ from the given default value if setting -/// was already registered or is available in the permanent setting storage -/// and had a different value. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSettingsRegisterResp { - /// 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. - #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] - pub setting: SbpString, Multipart>, -} +pub mod msg_settings_register_resp { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Register setting and default value (device <= host) + /// + /// This message responds to setting registration with the effective value. + /// The effective value shall differ from the given default value if setting + /// was already registered or is available in the permanent setting storage + /// and had a different value. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSettingsRegisterResp { + /// 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. + #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] + pub setting: SbpString, Multipart>, + } + + impl MsgSettingsRegisterResp { + pub fn register_status(&self) -> Option { + match get_bit_range!(self.status, u8, u8, 1, 0) { + 0 => Some(RegisterStatus::AcceptedRequestedDefaultValueReturned), + 1 => Some( + RegisterStatus::AcceptedSettingFoundInPermanentStorageValueFromStorageReturned, + ), + 2 => Some(RegisterStatus::RejectedSettingAlreadyRegisteredValueFromMemoryReturned), + 3 => Some(RegisterStatus::RejectedMalformedMessage), + _ => None, + } + } -impl MsgSettingsRegisterResp { - pub fn register_status(&self) -> Option { - match get_bit_range!( self.status, u8, u8, 1, 0 ) { - 0 => Some( MsgSettingsRegisterRespRegisterStatus :: AcceptedRequestedDefaultValueReturned ), - 1 => Some( MsgSettingsRegisterRespRegisterStatus :: AcceptedSettingFoundInPermanentStorageValueFromStorageReturned ), - 2 => Some( MsgSettingsRegisterRespRegisterStatus :: RejectedSettingAlreadyRegisteredValueFromMemoryReturned ), - 3 => Some( MsgSettingsRegisterRespRegisterStatus :: RejectedMalformedMessage ), - _ => None, + pub fn set_register_status(&mut self, register_status: RegisterStatus) { + set_bit_range!(&mut self.status, register_status, u8, u8, 1, 0); } } - pub fn set_register_status(&mut self, register_status: MsgSettingsRegisterRespRegisterStatus) { - set_bit_range!(&mut self.status, register_status, u8, u8, 1, 0); + impl ConcreteMessage for MsgSettingsRegisterResp { + const MESSAGE_TYPE: u16 = 431; + const MESSAGE_NAME: &'static str = "MSG_SETTINGS_REGISTER_RESP"; } -} - -impl ConcreteMessage for MsgSettingsRegisterResp { - const MESSAGE_TYPE: u16 = 431; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_REGISTER_RESP"; -} -impl SbpMessage for MsgSettingsRegisterResp { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgSettingsRegisterResp { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgSettingsRegisterResp { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSettingsRegisterResp(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgSettingsRegisterResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSettingsRegisterResp(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgSettingsRegisterResp { - const MIN_LEN: usize = - ::MIN_LEN + , Multipart> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.status) + WireFormat::len(&self.setting) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.status, buf); - WireFormat::write(&self.setting, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgSettingsRegisterResp { - sender_id: None, - status: WireFormat::parse_unchecked(buf), - setting: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgSettingsRegisterResp { + const MIN_LEN: usize = + ::MIN_LEN + , Multipart> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.status) + WireFormat::len(&self.setting) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.status, buf); + WireFormat::write(&self.setting, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgSettingsRegisterResp { + sender_id: None, + status: WireFormat::parse_unchecked(buf), + setting: WireFormat::parse_unchecked(buf), + } } } -} - -/// Register status -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgSettingsRegisterRespRegisterStatus { - /// Accepted; requested default value returned - AcceptedRequestedDefaultValueReturned = 0, - - /// Accepted; setting found in permanent storage, value from storage - /// returned - AcceptedSettingFoundInPermanentStorageValueFromStorageReturned = 1, - - /// Rejected; setting already registered, value from memory returned - RejectedSettingAlreadyRegisteredValueFromMemoryReturned = 2, - /// Rejected; malformed message - RejectedMalformedMessage = 3, -} - -impl std::fmt::Display for MsgSettingsRegisterRespRegisterStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgSettingsRegisterRespRegisterStatus::AcceptedRequestedDefaultValueReturned => f.write_str("Accepted; requested default value returned"), - MsgSettingsRegisterRespRegisterStatus::AcceptedSettingFoundInPermanentStorageValueFromStorageReturned => f.write_str("Accepted; setting found in permanent storage, value from storage returned"), - MsgSettingsRegisterRespRegisterStatus::RejectedSettingAlreadyRegisteredValueFromMemoryReturned => f.write_str("Rejected; setting already registered, value from memory returned"), - MsgSettingsRegisterRespRegisterStatus::RejectedMalformedMessage => f.write_str("Rejected; malformed message"), + /// Register status + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum RegisterStatus { + /// Accepted; requested default value returned + AcceptedRequestedDefaultValueReturned = 0, + + /// Accepted; setting found in permanent storage, value from storage + /// returned + AcceptedSettingFoundInPermanentStorageValueFromStorageReturned = 1, + + /// Rejected; setting already registered, value from memory returned + RejectedSettingAlreadyRegisteredValueFromMemoryReturned = 2, + + /// Rejected; malformed message + RejectedMalformedMessage = 3, + } + + impl std::fmt::Display for RegisterStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + RegisterStatus::AcceptedRequestedDefaultValueReturned => { + f.write_str("Accepted; requested default value returned") + } + RegisterStatus::AcceptedSettingFoundInPermanentStorageValueFromStorageReturned => f + .write_str( + "Accepted; setting found in permanent storage, value from storage returned", + ), + RegisterStatus::RejectedSettingAlreadyRegisteredValueFromMemoryReturned => { + f.write_str("Rejected; setting already registered, value from memory returned") + } + RegisterStatus::RejectedMalformedMessage => { + f.write_str("Rejected; malformed message") + } + } } } } -/// Save settings to flash (host => device) -/// -/// The save settings message persists the device's current settings -/// configuration to its onboard flash memory file system. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSettingsSave { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, -} +pub mod msg_settings_save { + #![allow(unused_imports)] -impl ConcreteMessage for MsgSettingsSave { - const MESSAGE_TYPE: u16 = 161; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_SAVE"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgSettingsSave { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE + /// Save settings to flash (host => device) + /// + /// The save settings message persists the device's current settings + /// configuration to its onboard flash memory file system. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSettingsSave { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgSettingsSave { + const MESSAGE_TYPE: u16 = 161; + const MESSAGE_NAME: &'static str = "MSG_SETTINGS_SAVE"; } -} -impl TryFrom for MsgSettingsSave { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSettingsSave(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgSettingsSave { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgSettingsSave { - const MIN_LEN: usize = 0; - fn len(&self) -> usize { - 0 + impl TryFrom for MsgSettingsSave { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSettingsSave(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn write(&self, _buf: &mut B) {} - fn parse_unchecked(_buf: &mut B) -> Self { - MsgSettingsSave { sender_id: None } + + impl WireFormat for MsgSettingsSave { + const MIN_LEN: usize = 0; + fn len(&self) -> usize { + 0 + } + fn write(&self, _buf: &mut B) {} + fn parse_unchecked(_buf: &mut B) -> Self { + MsgSettingsSave { sender_id: None } + } } } -/// Write device configuration settings (host => device) -/// -/// The setting message writes the device configuration for a particular -/// setting via A NULL-terminated and NULL-delimited string with contents -/// "SECTION_SETTING\0SETTING\0VALUE\0" where the '\0' escape sequence denotes -/// the NULL character and where quotation marks are omitted. A device will -/// only process to this message when it is received from sender ID 0x42. An -/// example string that could be sent to a device is -/// "solution\0soln_freq\010\0". -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSettingsWrite { - /// 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" - #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] - pub setting: SbpString, Multipart>, -} +pub mod msg_settings_write { + #![allow(unused_imports)] -impl ConcreteMessage for MsgSettingsWrite { - const MESSAGE_TYPE: u16 = 160; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_WRITE"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgSettingsWrite { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE + /// Write device configuration settings (host => device) + /// + /// The setting message writes the device configuration for a particular + /// setting via A NULL-terminated and NULL-delimited string with contents + /// "SECTION_SETTING\0SETTING\0VALUE\0" where the '\0' escape sequence denotes + /// the NULL character and where quotation marks are omitted. A device will + /// only process to this message when it is received from sender ID 0x42. An + /// example string that could be sent to a device is + /// "solution\0soln_freq\010\0". + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSettingsWrite { + /// 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" + #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] + pub setting: SbpString, Multipart>, } - fn sender_id(&self) -> Option { - self.sender_id - } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgSettingsWrite { + const MESSAGE_TYPE: u16 = 160; + const MESSAGE_NAME: &'static str = "MSG_SETTINGS_WRITE"; } -} -impl TryFrom for MsgSettingsWrite { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSettingsWrite(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgSettingsWrite { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgSettingsWrite { - const MIN_LEN: usize = , Multipart> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.setting) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.setting, buf); + impl TryFrom for MsgSettingsWrite { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSettingsWrite(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgSettingsWrite { - sender_id: None, - setting: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgSettingsWrite { + const MIN_LEN: usize = , Multipart> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.setting) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.setting, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgSettingsWrite { + sender_id: None, + setting: WireFormat::parse_unchecked(buf), + } } } } -/// Acknowledgement with status of MSG_SETTINGS_WRITE -/// -/// Return the status of a write request with the new value of the setting. -/// If the requested value is rejected, the current value will be returned. -/// The string field is a NULL-terminated and NULL-delimited string with -/// contents "SECTION_SETTING\0SETTING\0VALUE\0" where the '\0' escape -/// sequence denotes 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSettingsWriteResp { - /// 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" - #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] - pub setting: SbpString, Multipart>, -} +pub mod msg_settings_write_resp { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Acknowledgement with status of MSG_SETTINGS_WRITE + /// + /// Return the status of a write request with the new value of the setting. + /// If the requested value is rejected, the current value will be returned. + /// The string field is a NULL-terminated and NULL-delimited string with + /// contents "SECTION_SETTING\0SETTING\0VALUE\0" where the '\0' escape + /// sequence denotes 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSettingsWriteResp { + /// 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" + #[cfg_attr(feature = "serde", serde(rename(serialize = "setting")))] + pub setting: SbpString, Multipart>, + } + + impl MsgSettingsWriteResp { + pub fn write_status(&self) -> Option { + match get_bit_range!(self.status, u8, u8, 1, 0) { + 0 => Some(WriteStatus::AcceptedValueUpdated), + 1 => Some(WriteStatus::RejectedValueUnparsableOrOutOfRange), + 2 => Some(WriteStatus::RejectedRequestedSettingDoesNotExist), + 3 => Some(WriteStatus::RejectedSettingNameCouldNotBeParsed), + 4 => Some(WriteStatus::RejectedSettingIsReadOnly), + 5 => Some(WriteStatus::RejectedModificationIsTemporarilyDisabled), + 6 => Some(WriteStatus::RejectedUnspecifiedError), + _ => None, + } + } -impl MsgSettingsWriteResp { - pub fn write_status(&self) -> Option { - match get_bit_range!(self.status, u8, u8, 1, 0) { - 0 => Some(MsgSettingsWriteRespWriteStatus::AcceptedValueUpdated), - 1 => Some(MsgSettingsWriteRespWriteStatus::RejectedValueUnparsableOrOutOfRange), - 2 => Some(MsgSettingsWriteRespWriteStatus::RejectedRequestedSettingDoesNotExist), - 3 => Some(MsgSettingsWriteRespWriteStatus::RejectedSettingNameCouldNotBeParsed), - 4 => Some(MsgSettingsWriteRespWriteStatus::RejectedSettingIsReadOnly), - 5 => Some(MsgSettingsWriteRespWriteStatus::RejectedModificationIsTemporarilyDisabled), - 6 => Some(MsgSettingsWriteRespWriteStatus::RejectedUnspecifiedError), - _ => None, + pub fn set_write_status(&mut self, write_status: WriteStatus) { + set_bit_range!(&mut self.status, write_status, u8, u8, 1, 0); } } - pub fn set_write_status(&mut self, write_status: MsgSettingsWriteRespWriteStatus) { - set_bit_range!(&mut self.status, write_status, u8, u8, 1, 0); + impl ConcreteMessage for MsgSettingsWriteResp { + const MESSAGE_TYPE: u16 = 175; + const MESSAGE_NAME: &'static str = "MSG_SETTINGS_WRITE_RESP"; } -} -impl ConcreteMessage for MsgSettingsWriteResp { - const MESSAGE_TYPE: u16 = 175; - const MESSAGE_NAME: &'static str = "MSG_SETTINGS_WRITE_RESP"; -} - -impl SbpMessage for MsgSettingsWriteResp { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgSettingsWriteResp { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgSettingsWriteResp { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSettingsWriteResp(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgSettingsWriteResp { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSettingsWriteResp(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgSettingsWriteResp { - const MIN_LEN: usize = - ::MIN_LEN + , Multipart> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.status) + WireFormat::len(&self.setting) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.status, buf); - WireFormat::write(&self.setting, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgSettingsWriteResp { - sender_id: None, - status: WireFormat::parse_unchecked(buf), - setting: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgSettingsWriteResp { + const MIN_LEN: usize = + ::MIN_LEN + , Multipart> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.status) + WireFormat::len(&self.setting) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.status, buf); + WireFormat::write(&self.setting, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgSettingsWriteResp { + sender_id: None, + status: WireFormat::parse_unchecked(buf), + setting: WireFormat::parse_unchecked(buf), + } } } -} - -/// Write status -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgSettingsWriteRespWriteStatus { - /// Accepted; value updated - AcceptedValueUpdated = 0, - /// Rejected; value unparsable or out-of-range - RejectedValueUnparsableOrOutOfRange = 1, - - /// Rejected; requested setting does not exist - RejectedRequestedSettingDoesNotExist = 2, - - /// Rejected; setting name could not be parsed - RejectedSettingNameCouldNotBeParsed = 3, - - /// Rejected; setting is read only - RejectedSettingIsReadOnly = 4, - - /// Rejected; modification is temporarily disabled - RejectedModificationIsTemporarilyDisabled = 5, - - /// Rejected; unspecified error - RejectedUnspecifiedError = 6, -} - -impl std::fmt::Display for MsgSettingsWriteRespWriteStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgSettingsWriteRespWriteStatus::AcceptedValueUpdated => { - f.write_str("Accepted; value updated") - } - MsgSettingsWriteRespWriteStatus::RejectedValueUnparsableOrOutOfRange => { - f.write_str("Rejected; value unparsable or out-of-range") - } - MsgSettingsWriteRespWriteStatus::RejectedRequestedSettingDoesNotExist => { - f.write_str("Rejected; requested setting does not exist") - } - MsgSettingsWriteRespWriteStatus::RejectedSettingNameCouldNotBeParsed => { - f.write_str("Rejected; setting name could not be parsed") - } - MsgSettingsWriteRespWriteStatus::RejectedSettingIsReadOnly => { - f.write_str("Rejected; setting is read only") - } - MsgSettingsWriteRespWriteStatus::RejectedModificationIsTemporarilyDisabled => { - f.write_str("Rejected; modification is temporarily disabled") - } - MsgSettingsWriteRespWriteStatus::RejectedUnspecifiedError => { - f.write_str("Rejected; unspecified error") + /// Write status + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum WriteStatus { + /// Accepted; value updated + AcceptedValueUpdated = 0, + + /// Rejected; value unparsable or out-of-range + RejectedValueUnparsableOrOutOfRange = 1, + + /// Rejected; requested setting does not exist + RejectedRequestedSettingDoesNotExist = 2, + + /// Rejected; setting name could not be parsed + RejectedSettingNameCouldNotBeParsed = 3, + + /// Rejected; setting is read only + RejectedSettingIsReadOnly = 4, + + /// Rejected; modification is temporarily disabled + RejectedModificationIsTemporarilyDisabled = 5, + + /// Rejected; unspecified error + RejectedUnspecifiedError = 6, + } + + impl std::fmt::Display for WriteStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + WriteStatus::AcceptedValueUpdated => f.write_str("Accepted; value updated"), + WriteStatus::RejectedValueUnparsableOrOutOfRange => { + f.write_str("Rejected; value unparsable or out-of-range") + } + WriteStatus::RejectedRequestedSettingDoesNotExist => { + f.write_str("Rejected; requested setting does not exist") + } + WriteStatus::RejectedSettingNameCouldNotBeParsed => { + f.write_str("Rejected; setting name could not be parsed") + } + WriteStatus::RejectedSettingIsReadOnly => { + f.write_str("Rejected; setting is read only") + } + WriteStatus::RejectedModificationIsTemporarilyDisabled => { + f.write_str("Rejected; modification is temporarily disabled") + } + WriteStatus::RejectedUnspecifiedError => f.write_str("Rejected; unspecified error"), } } } diff --git a/rust/sbp/src/messages/solution_meta.rs b/rust/sbp/src/messages/solution_meta.rs index d785fb6337..599a2c698d 100644 --- a/rust/sbp/src/messages/solution_meta.rs +++ b/rust/sbp/src/messages/solution_meta.rs @@ -14,901 +14,923 @@ //****************************************************************************/ //! Standardized Metadata messages for Fuzed Solution from Swift Navigation //! devices. +pub use gnss_input_type::GnssInputType; +pub use imu_input_type::ImuInputType; +pub use msg_soln_meta::MsgSolnMeta; +pub use msg_soln_meta_dep_a::MsgSolnMetaDepA; +pub use odo_input_type::OdoInputType; +pub use solution_input_type::SolutionInputType; + +pub mod gnss_input_type { + #![allow(unused_imports)] + + use super::*; + use crate::messages::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. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn type_of_gnss_measurement(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 1, 0) { + 0 => Some(TypeOfGnssMeasurement::GnssPosition), + 1 => Some(TypeOfGnssMeasurement::GnssVelocityDoppler), + 2 => Some(TypeOfGnssMeasurement::GnssVelocityDisplacement), + _ => None, + } + } -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. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 { - pub fn type_of_gnss_measurement(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 1, 0) { - 0 => Some(GnssInputTypeTypeOfGnssMeasurement::GnssPosition), - 1 => Some(GnssInputTypeTypeOfGnssMeasurement::GnssVelocityDoppler), - 2 => Some(GnssInputTypeTypeOfGnssMeasurement::GnssVelocityDisplacement), - _ => None, + pub fn set_type_of_gnss_measurement( + &mut self, + type_of_gnss_measurement: TypeOfGnssMeasurement, + ) { + set_bit_range!(&mut self.flags, type_of_gnss_measurement, u8, u8, 1, 0); } } - pub fn set_type_of_gnss_measurement( - &mut self, - type_of_gnss_measurement: GnssInputTypeTypeOfGnssMeasurement, - ) { - set_bit_range!(&mut self.flags, type_of_gnss_measurement, u8, u8, 1, 0); - } -} - -impl WireFormat for GnssInputType { - const MIN_LEN: usize = ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.flags, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - GnssInputType { - flags: WireFormat::parse_unchecked(buf), + impl WireFormat for GnssInputType { + const MIN_LEN: usize = ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + GnssInputType { + flags: WireFormat::parse_unchecked(buf), + } } } -} -/// Type of GNSS measurement -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum GnssInputTypeTypeOfGnssMeasurement { - /// GNSS Position - GnssPosition = 0, + /// Type of GNSS measurement + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TypeOfGnssMeasurement { + /// GNSS Position + GnssPosition = 0, - /// GNSS Velocity Doppler - GnssVelocityDoppler = 1, + /// GNSS Velocity Doppler + GnssVelocityDoppler = 1, - /// GNSS Velocity Displacement - GnssVelocityDisplacement = 2, -} + /// GNSS Velocity Displacement + GnssVelocityDisplacement = 2, + } -impl std::fmt::Display for GnssInputTypeTypeOfGnssMeasurement { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - GnssInputTypeTypeOfGnssMeasurement::GnssPosition => f.write_str("GNSS Position"), - GnssInputTypeTypeOfGnssMeasurement::GnssVelocityDoppler => { - f.write_str("GNSS Velocity Doppler") - } - GnssInputTypeTypeOfGnssMeasurement::GnssVelocityDisplacement => { - f.write_str("GNSS Velocity Displacement") + impl std::fmt::Display for TypeOfGnssMeasurement { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TypeOfGnssMeasurement::GnssPosition => f.write_str("GNSS Position"), + TypeOfGnssMeasurement::GnssVelocityDoppler => f.write_str("GNSS Velocity Doppler"), + TypeOfGnssMeasurement::GnssVelocityDisplacement => { + f.write_str("GNSS Velocity Displacement") + } } } } } -/// Provides detail about the IMU sensor, its timestamping mode, and its quality for input to the fuzed solution - -/// -/// Metadata around the IMU sensors involved in the fuzed solution. Accessible -/// through sol_in\[N\].flags in a MSG_SOLN_META. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct ImuInputType { - /// Instrument time, grade, and architecture for a sensor. - #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] - pub flags: u8, -} +pub mod imu_input_type { + #![allow(unused_imports)] -impl ImuInputType { - pub fn time_status(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 4) { - 0 => Some(ImuInputTypeTimeStatus::ReferenceEpochIsStartOfCurrentGpsWeek), - 1 => Some(ImuInputTypeTimeStatus::ReferenceEpochIsTimeOfSystemStartup), - 2 => Some(ImuInputTypeTimeStatus::ReferenceEpochIsUnknown), - 3 => Some(ImuInputTypeTimeStatus::ReferenceEpochIsLastPps), - _ => None, - } - } + use super::*; + use crate::messages::lib::*; + + /// Provides detail about the IMU sensor, its timestamping mode, and its quality for input to the fuzed solution - pub fn set_time_status(&mut self, time_status: ImuInputTypeTimeStatus) { - set_bit_range!(&mut self.flags, time_status, u8, u8, 5, 4); + /// + /// Metadata around the IMU sensors involved in the fuzed solution. Accessible + /// through sol_in\[N\].flags in a MSG_SOLN_META. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct ImuInputType { + /// Instrument time, grade, and architecture for a sensor. + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] + pub flags: u8, } - pub fn imu_grade(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 2) { - 0 => Some(ImuInputTypeImuGrade::ConsumerGrade), - 1 => Some(ImuInputTypeImuGrade::TacticalGrade), - 2 => Some(ImuInputTypeImuGrade::IntermediateGrade), - 3 => Some(ImuInputTypeImuGrade::SuperiorGrade), - _ => None, + impl ImuInputType { + pub fn time_status(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 4) { + 0 => Some(TimeStatus::ReferenceEpochIsStartOfCurrentGpsWeek), + 1 => Some(TimeStatus::ReferenceEpochIsTimeOfSystemStartup), + 2 => Some(TimeStatus::ReferenceEpochIsUnknown), + 3 => Some(TimeStatus::ReferenceEpochIsLastPps), + _ => None, + } } - } - pub fn set_imu_grade(&mut self, imu_grade: ImuInputTypeImuGrade) { - set_bit_range!(&mut self.flags, imu_grade, u8, u8, 3, 2); - } + pub fn set_time_status(&mut self, time_status: TimeStatus) { + set_bit_range!(&mut self.flags, time_status, u8, u8, 5, 4); + } - pub fn imu_architecture(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 1, 0) { - 0 => Some(ImuInputTypeImuArchitecture::_6AxisMems), - 1 => Some(ImuInputTypeImuArchitecture::OtherType), - _ => None, + pub fn imu_grade(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 2) { + 0 => Some(ImuGrade::ConsumerGrade), + 1 => Some(ImuGrade::TacticalGrade), + 2 => Some(ImuGrade::IntermediateGrade), + 3 => Some(ImuGrade::SuperiorGrade), + _ => None, + } } - } - pub fn set_imu_architecture(&mut self, imu_architecture: ImuInputTypeImuArchitecture) { - set_bit_range!(&mut self.flags, imu_architecture, u8, u8, 1, 0); - } -} + pub fn set_imu_grade(&mut self, imu_grade: ImuGrade) { + set_bit_range!(&mut self.flags, imu_grade, u8, u8, 3, 2); + } -impl WireFormat for ImuInputType { - const MIN_LEN: usize = ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.flags, buf); + pub fn imu_architecture(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 1, 0) { + 0 => Some(ImuArchitecture::_6AxisMems), + 1 => Some(ImuArchitecture::OtherType), + _ => None, + } + } + + pub fn set_imu_architecture(&mut self, imu_architecture: ImuArchitecture) { + set_bit_range!(&mut self.flags, imu_architecture, u8, u8, 1, 0); + } } - fn parse_unchecked(buf: &mut B) -> Self { - ImuInputType { - flags: WireFormat::parse_unchecked(buf), + + impl WireFormat for ImuInputType { + const MIN_LEN: usize = ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + ImuInputType { + flags: WireFormat::parse_unchecked(buf), + } } } -} -/// Time status -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum ImuInputTypeTimeStatus { - /// Reference epoch is start of current GPS week - ReferenceEpochIsStartOfCurrentGpsWeek = 0, + /// Time status + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TimeStatus { + /// Reference epoch is start of current GPS week + ReferenceEpochIsStartOfCurrentGpsWeek = 0, - /// Reference epoch is time of system startup - ReferenceEpochIsTimeOfSystemStartup = 1, + /// Reference epoch is time of system startup + ReferenceEpochIsTimeOfSystemStartup = 1, - /// Reference epoch is unknown - ReferenceEpochIsUnknown = 2, + /// Reference epoch is unknown + ReferenceEpochIsUnknown = 2, - /// Reference epoch is last PPS - ReferenceEpochIsLastPps = 3, -} + /// Reference epoch is last PPS + ReferenceEpochIsLastPps = 3, + } -impl std::fmt::Display for ImuInputTypeTimeStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - ImuInputTypeTimeStatus::ReferenceEpochIsStartOfCurrentGpsWeek => { - f.write_str("Reference epoch is start of current GPS week") - } - ImuInputTypeTimeStatus::ReferenceEpochIsTimeOfSystemStartup => { - f.write_str("Reference epoch is time of system startup") - } - ImuInputTypeTimeStatus::ReferenceEpochIsUnknown => { - f.write_str("Reference epoch is unknown") - } - ImuInputTypeTimeStatus::ReferenceEpochIsLastPps => { - f.write_str("Reference epoch is last PPS") + impl std::fmt::Display for TimeStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TimeStatus::ReferenceEpochIsStartOfCurrentGpsWeek => { + f.write_str("Reference epoch is start of current GPS week") + } + TimeStatus::ReferenceEpochIsTimeOfSystemStartup => { + f.write_str("Reference epoch is time of system startup") + } + TimeStatus::ReferenceEpochIsUnknown => f.write_str("Reference epoch is unknown"), + TimeStatus::ReferenceEpochIsLastPps => f.write_str("Reference epoch is last PPS"), } } } -} -/// IMU Grade -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum ImuInputTypeImuGrade { - /// Consumer Grade - ConsumerGrade = 0, + /// IMU Grade + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum ImuGrade { + /// Consumer Grade + ConsumerGrade = 0, - /// Tactical grade - TacticalGrade = 1, + /// Tactical grade + TacticalGrade = 1, - /// Intermediate Grade - IntermediateGrade = 2, + /// Intermediate Grade + IntermediateGrade = 2, - /// Superior (Marine / Aviation) Grade - SuperiorGrade = 3, -} + /// Superior (Marine / Aviation) Grade + SuperiorGrade = 3, + } -impl std::fmt::Display for ImuInputTypeImuGrade { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - ImuInputTypeImuGrade::ConsumerGrade => f.write_str("Consumer Grade"), - ImuInputTypeImuGrade::TacticalGrade => f.write_str("Tactical grade"), - ImuInputTypeImuGrade::IntermediateGrade => f.write_str("Intermediate Grade"), - ImuInputTypeImuGrade::SuperiorGrade => { - f.write_str("Superior (Marine / Aviation) Grade") + impl std::fmt::Display for ImuGrade { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ImuGrade::ConsumerGrade => f.write_str("Consumer Grade"), + ImuGrade::TacticalGrade => f.write_str("Tactical grade"), + ImuGrade::IntermediateGrade => f.write_str("Intermediate Grade"), + ImuGrade::SuperiorGrade => f.write_str("Superior (Marine / Aviation) Grade"), } } } -} -/// IMU architecture -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum ImuInputTypeImuArchitecture { - /// 6-axis MEMS - _6AxisMems = 0, + /// IMU architecture + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum ImuArchitecture { + /// 6-axis MEMS + _6AxisMems = 0, - /// Other type - OtherType = 1, -} + /// Other type + OtherType = 1, + } -impl std::fmt::Display for ImuInputTypeImuArchitecture { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - ImuInputTypeImuArchitecture::_6AxisMems => f.write_str("6-axis MEMS"), - ImuInputTypeImuArchitecture::OtherType => f.write_str("Other type"), + impl std::fmt::Display for ImuArchitecture { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ImuArchitecture::_6AxisMems => f.write_str("6-axis MEMS"), + ImuArchitecture::OtherType => f.write_str("Other type"), + } } } } -/// Solution Sensors Metadata -/// -/// This message contains all metadata about the sensors received and/or used -/// in computing the sensorfusion solution. It focuses primarily, but not -/// only, on GNSS metadata. Regarding the age of the last received valid GNSS -/// solution, the highest two bits are time status, indicating whether age -/// gnss can or can not be used to retrieve time of measurement (noted TOM, -/// also known as time of validity) If it can, subtract 'age gnss' from 'tow' -/// in navigation messages to get TOM. Can be used before alignment is -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSolnMeta { - /// 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, -} +pub mod msg_soln_meta { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Solution Sensors Metadata + /// + /// This message contains all metadata about the sensors received and/or used + /// in computing the sensorfusion solution. It focuses primarily, but not + /// only, on GNSS metadata. Regarding the age of the last received valid GNSS + /// solution, the highest two bits are time status, indicating whether age + /// gnss can or can not be used to retrieve time of measurement (noted TOM, + /// also known as time of validity) If it can, subtract 'age gnss' from 'tow' + /// in navigation messages to get TOM. Can be used before alignment is + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSolnMeta { + /// 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 { + pub fn time_status(&self) -> Option { + match get_bit_range!(self.age_gnss, u32, u8, 31, 30) { + 0 => Some(TimeStatus::AgeCanNotBeUsedToRetrieveTom), + 1 => Some(TimeStatus::AgeCanBeUsedToRetrieveTom), + _ => None, + } + } -impl MsgSolnMeta { - pub fn time_status(&self) -> Option { - match get_bit_range!(self.age_gnss, u32, u8, 31, 30) { - 0 => Some(MsgSolnMetaTimeStatus::AgeCanNotBeUsedToRetrieveTom), - 1 => Some(MsgSolnMetaTimeStatus::AgeCanBeUsedToRetrieveTom), - _ => None, + pub fn set_time_status(&mut self, time_status: TimeStatus) { + set_bit_range!(&mut self.age_gnss, time_status, u32, u8, 31, 30); } - } - pub fn set_time_status(&mut self, time_status: MsgSolnMetaTimeStatus) { - set_bit_range!(&mut self.age_gnss, time_status, u32, u8, 31, 30); - } + pub fn age_of_the_last_received_valid_gnss_solution(&self) -> u32 { + get_bit_range!(self.age_gnss, u32, u32, 29, 0) + } - pub fn age_of_the_last_received_valid_gnss_solution(&self) -> u32 { - get_bit_range!(self.age_gnss, u32, u32, 29, 0) + pub fn set_age_of_the_last_received_valid_gnss_solution( + &mut self, + age_of_the_last_received_valid_gnss_solution: u32, + ) { + set_bit_range!( + &mut self.age_gnss, + age_of_the_last_received_valid_gnss_solution, + u32, + u32, + 29, + 0 + ); + } } - pub fn set_age_of_the_last_received_valid_gnss_solution( - &mut self, - age_of_the_last_received_valid_gnss_solution: u32, - ) { - set_bit_range!( - &mut self.age_gnss, - age_of_the_last_received_valid_gnss_solution, - u32, - u32, - 29, - 0 - ); + impl ConcreteMessage for MsgSolnMeta { + const MESSAGE_TYPE: u16 = 65294; + const MESSAGE_NAME: &'static str = "MSG_SOLN_META"; } -} -impl ConcreteMessage for MsgSolnMeta { - const MESSAGE_TYPE: u16 = 65294; - const MESSAGE_NAME: &'static str = "MSG_SOLN_META"; -} - -impl SbpMessage for MsgSolnMeta { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgSolnMeta { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgSolnMeta { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSolnMeta(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgSolnMeta { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSolnMeta(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgSolnMeta { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.pdop) - + WireFormat::len(&self.hdop) - + WireFormat::len(&self.vdop) - + WireFormat::len(&self.age_corrections) - + WireFormat::len(&self.age_gnss) - + WireFormat::len(&self.sol_in) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgSolnMeta { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.pdop) + + WireFormat::len(&self.hdop) + + WireFormat::len(&self.vdop) + + WireFormat::len(&self.age_corrections) + + WireFormat::len(&self.age_gnss) + + WireFormat::len(&self.sol_in) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Time status -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgSolnMetaTimeStatus { - /// Age can not be used to retrieve TOM - AgeCanNotBeUsedToRetrieveTom = 0, + /// Time status + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TimeStatus { + /// Age can not be used to retrieve TOM + AgeCanNotBeUsedToRetrieveTom = 0, - /// Age can be used to retrieve TOM - AgeCanBeUsedToRetrieveTom = 1, -} + /// Age can be used to retrieve TOM + AgeCanBeUsedToRetrieveTom = 1, + } -impl std::fmt::Display for MsgSolnMetaTimeStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgSolnMetaTimeStatus::AgeCanNotBeUsedToRetrieveTom => { - f.write_str("Age can not be used to retrieve TOM") - } - MsgSolnMetaTimeStatus::AgeCanBeUsedToRetrieveTom => { - f.write_str("Age can be used to retrieve TOM") + impl std::fmt::Display for TimeStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TimeStatus::AgeCanNotBeUsedToRetrieveTom => { + f.write_str("Age can not be used to retrieve TOM") + } + TimeStatus::AgeCanBeUsedToRetrieveTom => { + f.write_str("Age can be used to retrieve TOM") + } } } } } -/// Deprecated -/// -/// Deprecated. -/// -/// This message contains all metadata about the sensors received and/or used -/// in computing the Fuzed Solution. It focuses primarily, but not only, on -/// GNSS metadata. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSolnMetaDepA { - /// 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, -} +pub mod msg_soln_meta_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Deprecated + /// + /// Deprecated. + /// + /// This message contains all metadata about the sensors received and/or used + /// in computing the Fuzed Solution. It focuses primarily, but not only, on + /// GNSS metadata. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSolnMetaDepA { + /// 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 { + pub fn alignment_status(&self) -> Option { + match get_bit_range!(self.alignment_status, u8, u8, 2, 0) { + 0 => Some(AlignmentStatus::UnknownReasonOrAlreadyAligned), + 1 => Some(AlignmentStatus::SeedValuesLoadedAndAlignmentInProgress), + 2 => Some(AlignmentStatus::NoSeedValuesAndAlignmentInProgress), + 3 => Some(AlignmentStatus::SeedValuesLoadedButNoGnssMeasurements), + 4 => Some(AlignmentStatus::NoSeedValuesNorGnssMeasurements), + _ => None, + } + } -impl MsgSolnMetaDepA { - pub fn alignment_status(&self) -> Option { - match get_bit_range!(self.alignment_status, u8, u8, 2, 0) { - 0 => Some(MsgSolnMetaDepAAlignmentStatus::UnknownReasonOrAlreadyAligned), - 1 => Some(MsgSolnMetaDepAAlignmentStatus::SeedValuesLoadedAndAlignmentInProgress), - 2 => Some(MsgSolnMetaDepAAlignmentStatus::NoSeedValuesAndAlignmentInProgress), - 3 => Some(MsgSolnMetaDepAAlignmentStatus::SeedValuesLoadedButNoGnssMeasurements), - 4 => Some(MsgSolnMetaDepAAlignmentStatus::NoSeedValuesNorGnssMeasurements), - _ => None, + pub fn set_alignment_status(&mut self, alignment_status: AlignmentStatus) { + set_bit_range!(&mut self.alignment_status, alignment_status, u8, u8, 2, 0); } } - pub fn set_alignment_status(&mut self, alignment_status: MsgSolnMetaDepAAlignmentStatus) { - set_bit_range!(&mut self.alignment_status, alignment_status, u8, u8, 2, 0); + impl ConcreteMessage for MsgSolnMetaDepA { + const MESSAGE_TYPE: u16 = 65295; + const MESSAGE_NAME: &'static str = "MSG_SOLN_META_DEP_A"; } -} - -impl ConcreteMessage for MsgSolnMetaDepA { - const MESSAGE_TYPE: u16 = 65295; - const MESSAGE_NAME: &'static str = "MSG_SOLN_META_DEP_A"; -} -impl SbpMessage for MsgSolnMetaDepA { - 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); + impl SbpMessage for MsgSolnMetaDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl TryFrom for MsgSolnMetaDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSolnMetaDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } -} -impl TryFrom for MsgSolnMetaDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSolnMetaDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl WireFormat for MsgSolnMetaDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.pdop) + + WireFormat::len(&self.hdop) + + WireFormat::len(&self.vdop) + + WireFormat::len(&self.n_sats) + + WireFormat::len(&self.age_corrections) + + WireFormat::len(&self.alignment_status) + + WireFormat::len(&self.last_used_gnss_pos_tow) + + WireFormat::len(&self.last_used_gnss_vel_tow) + + WireFormat::len(&self.sol_in) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -impl WireFormat for MsgSolnMetaDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.pdop) - + WireFormat::len(&self.hdop) - + WireFormat::len(&self.vdop) - + WireFormat::len(&self.n_sats) - + WireFormat::len(&self.age_corrections) - + WireFormat::len(&self.alignment_status) - + WireFormat::len(&self.last_used_gnss_pos_tow) - + WireFormat::len(&self.last_used_gnss_vel_tow) - + WireFormat::len(&self.sol_in) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + /// Alignment status + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum AlignmentStatus { + /// Unknown reason or already aligned + UnknownReasonOrAlreadyAligned = 0, + + /// Seed values loaded and Alignment in progress + SeedValuesLoadedAndAlignmentInProgress = 1, + + /// No seed values and Alignment in progress + NoSeedValuesAndAlignmentInProgress = 2, + + /// Seed values loaded but no GNSS measurements + SeedValuesLoadedButNoGnssMeasurements = 3, + + /// No seed values nor GNSS measurements + NoSeedValuesNorGnssMeasurements = 4, + } + + impl std::fmt::Display for AlignmentStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + AlignmentStatus::UnknownReasonOrAlreadyAligned => { + f.write_str("Unknown reason or already aligned") + } + AlignmentStatus::SeedValuesLoadedAndAlignmentInProgress => { + f.write_str("Seed values loaded and Alignment in progress") + } + AlignmentStatus::NoSeedValuesAndAlignmentInProgress => { + f.write_str("No seed values and Alignment in progress") + } + AlignmentStatus::SeedValuesLoadedButNoGnssMeasurements => { + f.write_str("Seed values loaded but no GNSS measurements") + } + AlignmentStatus::NoSeedValuesNorGnssMeasurements => { + f.write_str("No seed values nor GNSS measurements") + } + } } } } -/// Alignment status -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgSolnMetaDepAAlignmentStatus { - /// Unknown reason or already aligned - UnknownReasonOrAlreadyAligned = 0, +pub mod odo_input_type { + #![allow(unused_imports)] - /// Seed values loaded and Alignment in progress - SeedValuesLoadedAndAlignmentInProgress = 1, + use super::*; + use crate::messages::lib::*; - /// No seed values and Alignment in progress - NoSeedValuesAndAlignmentInProgress = 2, + /// Provides detail about the Odometry sensor, its timestamping mode, and its quality for input to the fuzed solution - /// Seed values loaded but no GNSS measurements - SeedValuesLoadedButNoGnssMeasurements = 3, - - /// No seed values nor GNSS measurements - NoSeedValuesNorGnssMeasurements = 4, -} + /// + /// Metadata around the Odometry sensors involved in the fuzed solution. + /// Accessible through sol_in\[N\].flags in a MSG_SOLN_META. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct OdoInputType { + /// Instrument ODO rate, grade, and quality. + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] + pub flags: u8, + } -impl std::fmt::Display for MsgSolnMetaDepAAlignmentStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgSolnMetaDepAAlignmentStatus::UnknownReasonOrAlreadyAligned => { - f.write_str("Unknown reason or already aligned") - } - MsgSolnMetaDepAAlignmentStatus::SeedValuesLoadedAndAlignmentInProgress => { - f.write_str("Seed values loaded and Alignment in progress") - } - MsgSolnMetaDepAAlignmentStatus::NoSeedValuesAndAlignmentInProgress => { - f.write_str("No seed values and Alignment in progress") - } - MsgSolnMetaDepAAlignmentStatus::SeedValuesLoadedButNoGnssMeasurements => { - f.write_str("Seed values loaded but no GNSS measurements") - } - MsgSolnMetaDepAAlignmentStatus::NoSeedValuesNorGnssMeasurements => { - f.write_str("No seed values nor GNSS measurements") + impl OdoInputType { + pub fn rate(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 5, 4) { + 0 => Some(Rate::FixedIncomingRate), + 1 => Some(Rate::TriggeredByMinimumDistanceOrSpeed), + _ => None, } } - } -} - -/// Provides detail about the Odometry sensor, its timestamping mode, and its quality for input to the fuzed solution - -/// -/// Metadata around the Odometry sensors involved in the fuzed solution. -/// Accessible through sol_in\[N\].flags in a MSG_SOLN_META. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct OdoInputType { - /// Instrument ODO rate, grade, and quality. - #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] - pub flags: u8, -} -impl OdoInputType { - pub fn rate(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 4) { - 0 => Some(OdoInputTypeRate::FixedIncomingRate), - 1 => Some(OdoInputTypeRate::TriggeredByMinimumDistanceOrSpeed), - _ => None, + pub fn set_rate(&mut self, rate: Rate) { + set_bit_range!(&mut self.flags, rate, u8, u8, 5, 4); } - } - pub fn set_rate(&mut self, rate: OdoInputTypeRate) { - set_bit_range!(&mut self.flags, rate, u8, u8, 5, 4); - } - - pub fn odometer_grade(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 2) { - 0 => Some(OdoInputTypeOdometerGrade::LowGrade), - 1 => Some(OdoInputTypeOdometerGrade::MediumGrade), - 2 => Some(OdoInputTypeOdometerGrade::SuperiorGrade), - _ => None, + pub fn odometer_grade(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 2) { + 0 => Some(OdometerGrade::LowGrade), + 1 => Some(OdometerGrade::MediumGrade), + 2 => Some(OdometerGrade::SuperiorGrade), + _ => None, + } } - } - pub fn set_odometer_grade(&mut self, odometer_grade: OdoInputTypeOdometerGrade) { - set_bit_range!(&mut self.flags, odometer_grade, u8, u8, 3, 2); - } + pub fn set_odometer_grade(&mut self, odometer_grade: OdometerGrade) { + set_bit_range!(&mut self.flags, odometer_grade, u8, u8, 3, 2); + } - pub fn odometer_class(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 1, 0) { - 0 => Some(OdoInputTypeOdometerClass::SingleOrAveragedTicks), - 1 => Some(OdoInputTypeOdometerClass::SingleOrAveragedSpeed), - 2 => Some(OdoInputTypeOdometerClass::MultiDimensionalTicks), - 3 => Some(OdoInputTypeOdometerClass::MultiDimensionalSpeed), - _ => None, + pub fn odometer_class(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 1, 0) { + 0 => Some(OdometerClass::SingleOrAveragedTicks), + 1 => Some(OdometerClass::SingleOrAveragedSpeed), + 2 => Some(OdometerClass::MultiDimensionalTicks), + 3 => Some(OdometerClass::MultiDimensionalSpeed), + _ => None, + } } - } - pub fn set_odometer_class(&mut self, odometer_class: OdoInputTypeOdometerClass) { - set_bit_range!(&mut self.flags, odometer_class, u8, u8, 1, 0); + pub fn set_odometer_class(&mut self, odometer_class: OdometerClass) { + set_bit_range!(&mut self.flags, odometer_class, u8, u8, 1, 0); + } } -} -impl WireFormat for OdoInputType { - const MIN_LEN: usize = ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.flags, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - OdoInputType { - flags: WireFormat::parse_unchecked(buf), + impl WireFormat for OdoInputType { + const MIN_LEN: usize = ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + OdoInputType { + flags: WireFormat::parse_unchecked(buf), + } } } -} -/// Rate -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum OdoInputTypeRate { - /// Fixed incoming rate - FixedIncomingRate = 0, + /// Rate + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum Rate { + /// Fixed incoming rate + FixedIncomingRate = 0, - /// Triggered by minimum distance or speed - TriggeredByMinimumDistanceOrSpeed = 1, -} + /// Triggered by minimum distance or speed + TriggeredByMinimumDistanceOrSpeed = 1, + } -impl std::fmt::Display for OdoInputTypeRate { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - OdoInputTypeRate::FixedIncomingRate => f.write_str("Fixed incoming rate"), - OdoInputTypeRate::TriggeredByMinimumDistanceOrSpeed => { - f.write_str("Triggered by minimum distance or speed") + impl std::fmt::Display for Rate { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Rate::FixedIncomingRate => f.write_str("Fixed incoming rate"), + Rate::TriggeredByMinimumDistanceOrSpeed => { + f.write_str("Triggered by minimum distance or speed") + } } } } -} -/// Odometer grade -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum OdoInputTypeOdometerGrade { - /// Low Grade (e.g. quantized CAN) - LowGrade = 0, + /// Odometer grade + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum OdometerGrade { + /// Low Grade (e.g. quantized CAN) + LowGrade = 0, - /// Medium Grade - MediumGrade = 1, + /// Medium Grade + MediumGrade = 1, - /// Superior Grade - SuperiorGrade = 2, -} + /// Superior Grade + SuperiorGrade = 2, + } -impl std::fmt::Display for OdoInputTypeOdometerGrade { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - OdoInputTypeOdometerGrade::LowGrade => f.write_str("Low Grade (e.g. quantized CAN)"), - OdoInputTypeOdometerGrade::MediumGrade => f.write_str("Medium Grade"), - OdoInputTypeOdometerGrade::SuperiorGrade => f.write_str("Superior Grade"), + impl std::fmt::Display for OdometerGrade { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + OdometerGrade::LowGrade => f.write_str("Low Grade (e.g. quantized CAN)"), + OdometerGrade::MediumGrade => f.write_str("Medium Grade"), + OdometerGrade::SuperiorGrade => f.write_str("Superior Grade"), + } } } -} -/// Odometer class -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum OdoInputTypeOdometerClass { - /// Single or averaged ticks - SingleOrAveragedTicks = 0, + /// Odometer class + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum OdometerClass { + /// Single or averaged ticks + SingleOrAveragedTicks = 0, - /// Single or averaged speed - SingleOrAveragedSpeed = 1, + /// Single or averaged speed + SingleOrAveragedSpeed = 1, - /// Multi-dimensional ticks - MultiDimensionalTicks = 2, + /// Multi-dimensional ticks + MultiDimensionalTicks = 2, - /// Multi-dimensional speed - MultiDimensionalSpeed = 3, -} + /// Multi-dimensional speed + MultiDimensionalSpeed = 3, + } -impl std::fmt::Display for OdoInputTypeOdometerClass { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - OdoInputTypeOdometerClass::SingleOrAveragedTicks => { - f.write_str("Single or averaged ticks") - } - OdoInputTypeOdometerClass::SingleOrAveragedSpeed => { - f.write_str("Single or averaged speed") - } - OdoInputTypeOdometerClass::MultiDimensionalTicks => { - f.write_str("Multi-dimensional ticks") - } - OdoInputTypeOdometerClass::MultiDimensionalSpeed => { - f.write_str("Multi-dimensional speed") + impl std::fmt::Display for OdometerClass { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + OdometerClass::SingleOrAveragedTicks => f.write_str("Single or averaged ticks"), + OdometerClass::SingleOrAveragedSpeed => f.write_str("Single or averaged speed"), + OdometerClass::MultiDimensionalTicks => f.write_str("Multi-dimensional ticks"), + OdometerClass::MultiDimensionalSpeed => f.write_str("Multi-dimensional speed"), } } } } -/// Flags for a given solution input type -/// -/// Metadata describing which sensors were involved in the solution. The -/// structure is fixed no matter what the actual sensor type is. The -/// sensor_type field tells you which sensor we are talking about. It also -/// tells you whether the sensor data was actually used or not. The flags -/// field, always a u8, contains the sensor-specific data. The content of -/// flags, for each sensor type, is described in the relevant structures in -/// this section. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 { - pub fn sensor_usage(&self) -> Option { - match get_bit_range!(self.sensor_type, u8, u8, 4, 3) { - 0 => Some(SolutionInputTypeSensorUsage::Unknown), - 1 => Some(SolutionInputTypeSensorUsage::ReceivedAndUsed), - 2 => Some(SolutionInputTypeSensorUsage::ReceivedButNotUsed), - _ => None, +pub mod solution_input_type { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Flags for a given solution input type + /// + /// Metadata describing which sensors were involved in the solution. The + /// structure is fixed no matter what the actual sensor type is. The + /// sensor_type field tells you which sensor we are talking about. It also + /// tells you whether the sensor data was actually used or not. The flags + /// field, always a u8, contains the sensor-specific data. The content of + /// flags, for each sensor type, is described in the relevant structures in + /// this section. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn sensor_usage(&self) -> Option { + match get_bit_range!(self.sensor_type, u8, u8, 4, 3) { + 0 => Some(SensorUsage::Unknown), + 1 => Some(SensorUsage::ReceivedAndUsed), + 2 => Some(SensorUsage::ReceivedButNotUsed), + _ => None, + } } - } - pub fn set_sensor_usage(&mut self, sensor_usage: SolutionInputTypeSensorUsage) { - set_bit_range!(&mut self.sensor_type, sensor_usage, u8, u8, 4, 3); - } + pub fn set_sensor_usage(&mut self, sensor_usage: SensorUsage) { + set_bit_range!(&mut self.sensor_type, sensor_usage, u8, u8, 4, 3); + } - pub fn sensor_type(&self) -> Option { - match get_bit_range!(self.sensor_type, u8, u8, 2, 0) { - 0 => Some(SolutionInputTypeSensorType::Invalid), - 1 => Some(SolutionInputTypeSensorType::GnssPosition), - 2 => Some(SolutionInputTypeSensorType::GnssVelocityDisplacement), - 3 => Some(SolutionInputTypeSensorType::GnssVelocityDoppler), - 4 => Some(SolutionInputTypeSensorType::OdometryTicks), - 5 => Some(SolutionInputTypeSensorType::OdometrySpeed), - 6 => Some(SolutionInputTypeSensorType::ImuSensor), - _ => None, + pub fn sensor_type(&self) -> Option { + match get_bit_range!(self.sensor_type, u8, u8, 2, 0) { + 0 => Some(SensorType::Invalid), + 1 => Some(SensorType::GnssPosition), + 2 => Some(SensorType::GnssVelocityDisplacement), + 3 => Some(SensorType::GnssVelocityDoppler), + 4 => Some(SensorType::OdometryTicks), + 5 => Some(SensorType::OdometrySpeed), + 6 => Some(SensorType::ImuSensor), + _ => None, + } } - } - pub fn set_sensor_type(&mut self, sensor_type: SolutionInputTypeSensorType) { - set_bit_range!(&mut self.sensor_type, sensor_type, u8, u8, 2, 0); + pub fn set_sensor_type(&mut self, sensor_type: SensorType) { + set_bit_range!(&mut self.sensor_type, sensor_type, u8, u8, 2, 0); + } } -} -impl WireFormat for SolutionInputType { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sensor_type) + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sensor_type, buf); - WireFormat::write(&self.flags, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - SolutionInputType { - sensor_type: WireFormat::parse_unchecked(buf), - flags: WireFormat::parse_unchecked(buf), + impl WireFormat for SolutionInputType { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sensor_type) + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sensor_type, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + SolutionInputType { + sensor_type: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } -} -/// Sensor Usage -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum SolutionInputTypeSensorUsage { - /// Unknown - Unknown = 0, + /// Sensor Usage + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum SensorUsage { + /// Unknown + Unknown = 0, - /// Received and used - ReceivedAndUsed = 1, + /// Received and used + ReceivedAndUsed = 1, - /// Received but not used - ReceivedButNotUsed = 2, -} + /// Received but not used + ReceivedButNotUsed = 2, + } -impl std::fmt::Display for SolutionInputTypeSensorUsage { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - SolutionInputTypeSensorUsage::Unknown => f.write_str("Unknown"), - SolutionInputTypeSensorUsage::ReceivedAndUsed => f.write_str("Received and used"), - SolutionInputTypeSensorUsage::ReceivedButNotUsed => { - f.write_str("Received but not used") + impl std::fmt::Display for SensorUsage { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SensorUsage::Unknown => f.write_str("Unknown"), + SensorUsage::ReceivedAndUsed => f.write_str("Received and used"), + SensorUsage::ReceivedButNotUsed => f.write_str("Received but not used"), } } } -} -/// Sensor Type -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum SolutionInputTypeSensorType { - /// Invalid - Invalid = 0, + /// Sensor Type + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum SensorType { + /// Invalid + Invalid = 0, - /// GNSS Position (see GNSSInputType) - GnssPosition = 1, + /// GNSS Position (see GNSSInputType) + GnssPosition = 1, - /// GNSS Velocity Displacement (see GNSSInputType) - GnssVelocityDisplacement = 2, + /// GNSS Velocity Displacement (see GNSSInputType) + GnssVelocityDisplacement = 2, - /// GNSS Velocity Doppler (see GNSSInputType) - GnssVelocityDoppler = 3, + /// GNSS Velocity Doppler (see GNSSInputType) + GnssVelocityDoppler = 3, - /// Odometry Ticks (see OdoInputType) - OdometryTicks = 4, + /// Odometry Ticks (see OdoInputType) + OdometryTicks = 4, - /// Odometry Speed (see OdoInputType) - OdometrySpeed = 5, + /// Odometry Speed (see OdoInputType) + OdometrySpeed = 5, - /// IMU Sensor (see IMUInputType) - ImuSensor = 6, -} + /// IMU Sensor (see IMUInputType) + ImuSensor = 6, + } -impl std::fmt::Display for SolutionInputTypeSensorType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - SolutionInputTypeSensorType::Invalid => f.write_str("Invalid"), - SolutionInputTypeSensorType::GnssPosition => { - f.write_str("GNSS Position (see GNSSInputType)") - } - SolutionInputTypeSensorType::GnssVelocityDisplacement => { - f.write_str("GNSS Velocity Displacement (see GNSSInputType)") - } - SolutionInputTypeSensorType::GnssVelocityDoppler => { - f.write_str("GNSS Velocity Doppler (see GNSSInputType)") - } - SolutionInputTypeSensorType::OdometryTicks => { - f.write_str("Odometry Ticks (see OdoInputType)") - } - SolutionInputTypeSensorType::OdometrySpeed => { - f.write_str("Odometry Speed (see OdoInputType)") + impl std::fmt::Display for SensorType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SensorType::Invalid => f.write_str("Invalid"), + SensorType::GnssPosition => f.write_str("GNSS Position (see GNSSInputType)"), + SensorType::GnssVelocityDisplacement => { + f.write_str("GNSS Velocity Displacement (see GNSSInputType)") + } + SensorType::GnssVelocityDoppler => { + f.write_str("GNSS Velocity Doppler (see GNSSInputType)") + } + SensorType::OdometryTicks => f.write_str("Odometry Ticks (see OdoInputType)"), + SensorType::OdometrySpeed => f.write_str("Odometry Speed (see OdoInputType)"), + SensorType::ImuSensor => f.write_str("IMU Sensor (see IMUInputType)"), } - SolutionInputTypeSensorType::ImuSensor => f.write_str("IMU Sensor (see IMUInputType)"), } } } diff --git a/rust/sbp/src/messages/ssr.rs b/rust/sbp/src/messages/ssr.rs index edd5d61ec5..a514141ef0 100644 --- a/rust/sbp/src/messages/ssr.rs +++ b/rust/sbp/src/messages/ssr.rs @@ -13,2037 +13,2256 @@ // with generate.py. Please do not hand edit! //****************************************************************************/ //! Precise State Space Representation (SSR) corrections format - -use super::gnss::*; - -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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 WireFormat for CodeBiasesContent { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.code) + WireFormat::len(&self.value) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.code, buf); - WireFormat::write(&self.value, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - CodeBiasesContent { - code: WireFormat::parse_unchecked(buf), - value: WireFormat::parse_unchecked(buf), +pub use code_biases_content::CodeBiasesContent; +pub use grid_definition_header_dep_a::GridDefinitionHeaderDepA; +pub use gridded_correction_header::GriddedCorrectionHeader; +pub use gridded_correction_header_dep_a::GriddedCorrectionHeaderDepA; +pub use msg_ssr_code_biases::MsgSsrCodeBiases; +pub use msg_ssr_grid_definition_dep_a::MsgSsrGridDefinitionDepA; +pub use msg_ssr_gridded_correction::MsgSsrGriddedCorrection; +pub use msg_ssr_gridded_correction_dep_a::MsgSsrGriddedCorrectionDepA; +pub use msg_ssr_gridded_correction_no_std_dep_a::MsgSsrGriddedCorrectionNoStdDepA; +pub use msg_ssr_orbit_clock::MsgSsrOrbitClock; +pub use msg_ssr_orbit_clock_dep_a::MsgSsrOrbitClockDepA; +pub use msg_ssr_phase_biases::MsgSsrPhaseBiases; +pub use msg_ssr_satellite_apc::MsgSsrSatelliteApc; +pub use msg_ssr_stec_correction::MsgSsrStecCorrection; +pub use msg_ssr_stec_correction_dep_a::MsgSsrStecCorrectionDepA; +pub use msg_ssr_tile_definition::MsgSsrTileDefinition; +pub use phase_biases_content::PhaseBiasesContent; +pub use satellite_apc::SatelliteAPC; +pub use stec_header::STECHeader; +pub use stec_header_dep_a::STECHeaderDepA; +pub use stec_residual::STECResidual; +pub use stec_residual_no_std::STECResidualNoStd; +pub use stec_sat_element::STECSatElement; +pub use tropospheric_delay_correction::TroposphericDelayCorrection; +pub use tropospheric_delay_correction_no_std::TroposphericDelayCorrectionNoStd; + +pub mod code_biases_content { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 WireFormat for CodeBiasesContent { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.code) + WireFormat::len(&self.value) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.code, buf); + WireFormat::write(&self.value, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + CodeBiasesContent { + code: WireFormat::parse_unchecked(buf), + value: WireFormat::parse_unchecked(buf), + } } } } -/// Defines the grid for MSG_SSR_GRIDDED_CORRECTION messages -/// -/// Defines the grid for MSG_SSR_GRIDDED_CORRECTION messages. Also includes an -/// RLE encoded validity list. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod grid_definition_header_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl WireFormat for GridDefinitionHeaderDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.region_size_inverse) - + WireFormat::len(&self.area_width) - + WireFormat::len(&self.lat_nw_corner_enc) - + WireFormat::len(&self.lon_nw_corner_enc) - + WireFormat::len(&self.num_msgs) - + WireFormat::len(&self.seq_num) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + /// Defines the grid for MSG_SSR_GRIDDED_CORRECTION messages + /// + /// Defines the grid for MSG_SSR_GRIDDED_CORRECTION messages. Also includes an + /// RLE encoded validity list. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 WireFormat for GridDefinitionHeaderDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.region_size_inverse) + + WireFormat::len(&self.area_width) + + WireFormat::len(&self.lat_nw_corner_enc) + + WireFormat::len(&self.lon_nw_corner_enc) + + WireFormat::len(&self.num_msgs) + + WireFormat::len(&self.seq_num) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Header for the MSG_SSR_GRIDDED_CORRECTION message -/// -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 - #[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, -} +pub mod gridded_correction_header { + #![allow(unused_imports)] -impl WireFormat for GriddedCorrectionHeader { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tile_set_id) - + WireFormat::len(&self.tile_id) - + WireFormat::len(&self.time) - + WireFormat::len(&self.num_msgs) - + WireFormat::len(&self.seq_num) - + WireFormat::len(&self.update_interval) - + WireFormat::len(&self.iod_atmo) - + WireFormat::len(&self.tropo_quality_indicator) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Header for the MSG_SSR_GRIDDED_CORRECTION message + /// + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 + #[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 WireFormat for GriddedCorrectionHeader { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tile_set_id) + + WireFormat::len(&self.tile_id) + + WireFormat::len(&self.time) + + WireFormat::len(&self.num_msgs) + + WireFormat::len(&self.seq_num) + + WireFormat::len(&self.update_interval) + + WireFormat::len(&self.iod_atmo) + + WireFormat::len(&self.tropo_quality_indicator) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Header for MSG_SSR_GRIDDED_CORRECTION_DEP -/// -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct GriddedCorrectionHeaderDepA { - /// GNSS reference time of the correction - #[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, -} +pub mod gridded_correction_header_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl WireFormat for GriddedCorrectionHeaderDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.time) - + WireFormat::len(&self.num_msgs) - + WireFormat::len(&self.seq_num) - + WireFormat::len(&self.update_interval) - + WireFormat::len(&self.iod_atmo) - + WireFormat::len(&self.tropo_quality_indicator) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + /// Header for MSG_SSR_GRIDDED_CORRECTION_DEP + /// + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct GriddedCorrectionHeaderDepA { + /// GNSS reference time of the correction + #[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 WireFormat for GriddedCorrectionHeaderDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.time) + + WireFormat::len(&self.num_msgs) + + WireFormat::len(&self.seq_num) + + WireFormat::len(&self.update_interval) + + WireFormat::len(&self.iod_atmo) + + WireFormat::len(&self.tropo_quality_indicator) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Precise code biases correction -/// -/// The precise code biases message is to be added to the pseudorange of the -/// corresponding signal to get corrected pseudorange. It is an equivalent to -/// the 1059 / 1065 RTCM message types. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSsrCodeBiases { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, - /// GNSS reference time of the correction - #[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, -} +pub mod msg_ssr_code_biases { + #![allow(unused_imports)] -impl ConcreteMessage for MsgSsrCodeBiases { - const MESSAGE_TYPE: u16 = 1505; - const MESSAGE_NAME: &'static str = "MSG_SSR_CODE_BIASES"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgSsrCodeBiases { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + /// Precise code biases correction + /// + /// The precise code biases message is to be added to the pseudorange of the + /// corresponding signal to get corrected pseudorange. It is an equivalent to + /// the 1059 / 1065 RTCM message types. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSsrCodeBiases { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + /// GNSS reference time of the correction + #[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 ConcreteMessage for MsgSsrCodeBiases { + const MESSAGE_TYPE: u16 = 1505; + const MESSAGE_NAME: &'static str = "MSG_SSR_CODE_BIASES"; + } + + impl SbpMessage for MsgSsrCodeBiases { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgSsrCodeBiases { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSsrCodeBiases(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgSsrCodeBiases { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSsrCodeBiases(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgSsrCodeBiases { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.time) - + WireFormat::len(&self.sid) - + WireFormat::len(&self.update_interval) - + WireFormat::len(&self.iod_ssr) - + WireFormat::len(&self.biases) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgSsrCodeBiases { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.time) + + WireFormat::len(&self.sid) + + WireFormat::len(&self.update_interval) + + WireFormat::len(&self.iod_ssr) + + WireFormat::len(&self.biases) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Gridded troposphere and STEC correction residuals -/// -/// STEC residuals are per space vehicle, troposphere is not. -/// -/// It is typically equivalent to the QZSS CLAS Sub Type 9 messages. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSsrGriddedCorrection { - /// 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, -} +pub mod msg_ssr_gridded_correction { + #![allow(unused_imports)] -impl ConcreteMessage for MsgSsrGriddedCorrection { - const MESSAGE_TYPE: u16 = 1532; - const MESSAGE_NAME: &'static str = "MSG_SSR_GRIDDED_CORRECTION"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgSsrGriddedCorrection { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + /// Gridded troposphere and STEC correction residuals + /// + /// STEC residuals are per space vehicle, troposphere is not. + /// + /// It is typically equivalent to the QZSS CLAS Sub Type 9 messages. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSsrGriddedCorrection { + /// 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 ConcreteMessage for MsgSsrGriddedCorrection { + const MESSAGE_TYPE: u16 = 1532; + const MESSAGE_NAME: &'static str = "MSG_SSR_GRIDDED_CORRECTION"; + } + + impl SbpMessage for MsgSsrGriddedCorrection { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgSsrGriddedCorrection { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSsrGriddedCorrection(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgSsrGriddedCorrection { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSsrGriddedCorrection(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgSsrGriddedCorrection { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.header) - + WireFormat::len(&self.index) - + WireFormat::len(&self.tropo_delay_correction) - + WireFormat::len(&self.stec_residuals) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgSsrGriddedCorrection { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.header) + + WireFormat::len(&self.index) + + WireFormat::len(&self.tropo_delay_correction) + + WireFormat::len(&self.stec_residuals) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Deprecated -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSsrGriddedCorrectionDepA { - /// 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 ConcreteMessage for MsgSsrGriddedCorrectionDepA { - const MESSAGE_TYPE: u16 = 1530; - const MESSAGE_NAME: &'static str = "MSG_SSR_GRIDDED_CORRECTION_DEP_A"; -} - -impl SbpMessage for MsgSsrGriddedCorrectionDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ssr_gridded_correction_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + /// Deprecated + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSsrGriddedCorrectionDepA { + /// 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 ConcreteMessage for MsgSsrGriddedCorrectionDepA { + const MESSAGE_TYPE: u16 = 1530; + const MESSAGE_NAME: &'static str = "MSG_SSR_GRIDDED_CORRECTION_DEP_A"; + } + + impl SbpMessage for MsgSsrGriddedCorrectionDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgSsrGriddedCorrectionDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSsrGriddedCorrectionDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgSsrGriddedCorrectionDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSsrGriddedCorrectionDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgSsrGriddedCorrectionDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.header) - + WireFormat::len(&self.index) - + WireFormat::len(&self.tropo_delay_correction) - + WireFormat::len(&self.stec_residuals) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgSsrGriddedCorrectionDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.header) + + WireFormat::len(&self.index) + + WireFormat::len(&self.tropo_delay_correction) + + WireFormat::len(&self.stec_residuals) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Deprecated -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSsrGriddedCorrectionNoStdDepA { - /// 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 ConcreteMessage for MsgSsrGriddedCorrectionNoStdDepA { - const MESSAGE_TYPE: u16 = 1520; - const MESSAGE_NAME: &'static str = "MSG_SSR_GRIDDED_CORRECTION_NO_STD_DEP_A"; -} - -impl SbpMessage for MsgSsrGriddedCorrectionNoStdDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ssr_gridded_correction_no_std_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + /// Deprecated + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSsrGriddedCorrectionNoStdDepA { + /// 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 ConcreteMessage for MsgSsrGriddedCorrectionNoStdDepA { + const MESSAGE_TYPE: u16 = 1520; + const MESSAGE_NAME: &'static str = "MSG_SSR_GRIDDED_CORRECTION_NO_STD_DEP_A"; + } + + impl SbpMessage for MsgSsrGriddedCorrectionNoStdDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgSsrGriddedCorrectionNoStdDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSsrGriddedCorrectionNoStdDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgSsrGriddedCorrectionNoStdDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSsrGriddedCorrectionNoStdDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgSsrGriddedCorrectionNoStdDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.header) - + WireFormat::len(&self.index) - + WireFormat::len(&self.tropo_delay_correction) - + WireFormat::len(&self.stec_residuals) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgSsrGriddedCorrectionNoStdDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.header) + + WireFormat::len(&self.index) + + WireFormat::len(&self.tropo_delay_correction) + + WireFormat::len(&self.stec_residuals) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Deprecated -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSsrGridDefinitionDepA { - /// 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 ConcreteMessage for MsgSsrGridDefinitionDepA { - const MESSAGE_TYPE: u16 = 1525; - const MESSAGE_NAME: &'static str = "MSG_SSR_GRID_DEFINITION_DEP_A"; -} +pub mod msg_ssr_grid_definition_dep_a { + #![allow(unused_imports)] -impl SbpMessage for MsgSsrGridDefinitionDepA { - 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); + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + /// Deprecated + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSsrGridDefinitionDepA { + /// 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, } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl 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 = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSsrGridDefinitionDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgSsrGridDefinitionDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgSsrGridDefinitionDepA { - const MIN_LEN: usize = - ::MIN_LEN + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.header) + WireFormat::len(&self.rle_list) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.header, buf); - WireFormat::write(&self.rle_list, buf); + impl TryFrom for MsgSsrGridDefinitionDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSsrGridDefinitionDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgSsrGridDefinitionDepA { - sender_id: None, - header: WireFormat::parse_unchecked(buf), - rle_list: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgSsrGridDefinitionDepA { + const MIN_LEN: usize = + ::MIN_LEN + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.header) + WireFormat::len(&self.rle_list) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.header, buf); + WireFormat::write(&self.rle_list, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgSsrGridDefinitionDepA { + sender_id: None, + header: WireFormat::parse_unchecked(buf), + rle_list: WireFormat::parse_unchecked(buf), + } } } } -/// Precise orbit and clock correction -/// -/// The precise orbit and clock correction message is to be applied as a delta -/// correction to broadcast ephemeris and is an equivalent to the 1060 /1066 -/// RTCM message types. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSsrOrbitClock { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, - /// GNSS reference time of the correction - #[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, -} +pub mod msg_ssr_orbit_clock { + #![allow(unused_imports)] -impl ConcreteMessage for MsgSsrOrbitClock { - const MESSAGE_TYPE: u16 = 1501; - const MESSAGE_NAME: &'static str = "MSG_SSR_ORBIT_CLOCK"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgSsrOrbitClock { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + /// Precise orbit and clock correction + /// + /// The precise orbit and clock correction message is to be applied as a delta + /// correction to broadcast ephemeris and is an equivalent to the 1060 /1066 + /// RTCM message types. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSsrOrbitClock { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + /// GNSS reference time of the correction + #[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 ConcreteMessage for MsgSsrOrbitClock { + const MESSAGE_TYPE: u16 = 1501; + const MESSAGE_NAME: &'static str = "MSG_SSR_ORBIT_CLOCK"; + } + + impl SbpMessage for MsgSsrOrbitClock { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgSsrOrbitClock { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSsrOrbitClock(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgSsrOrbitClock { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSsrOrbitClock(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgSsrOrbitClock { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.time) - + WireFormat::len(&self.sid) - + WireFormat::len(&self.update_interval) - + WireFormat::len(&self.iod_ssr) - + WireFormat::len(&self.iod) - + WireFormat::len(&self.radial) - + WireFormat::len(&self.along) - + WireFormat::len(&self.cross) - + WireFormat::len(&self.dot_radial) - + WireFormat::len(&self.dot_along) - + WireFormat::len(&self.dot_cross) - + WireFormat::len(&self.c0) - + WireFormat::len(&self.c1) - + WireFormat::len(&self.c2) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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 WireFormat for MsgSsrOrbitClock { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.time) + + WireFormat::len(&self.sid) + + WireFormat::len(&self.update_interval) + + WireFormat::len(&self.iod_ssr) + + WireFormat::len(&self.iod) + + WireFormat::len(&self.radial) + + WireFormat::len(&self.along) + + WireFormat::len(&self.cross) + + WireFormat::len(&self.dot_radial) + + WireFormat::len(&self.dot_along) + + WireFormat::len(&self.dot_cross) + + WireFormat::len(&self.c0) + + WireFormat::len(&self.c1) + + WireFormat::len(&self.c2) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Deprecated -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSsrOrbitClockDepA { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, - /// GNSS reference time of the correction - #[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 ConcreteMessage for MsgSsrOrbitClockDepA { - const MESSAGE_TYPE: u16 = 1500; - const MESSAGE_NAME: &'static str = "MSG_SSR_ORBIT_CLOCK_DEP_A"; -} - -impl SbpMessage for MsgSsrOrbitClockDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN +pub mod msg_ssr_orbit_clock_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + /// Deprecated + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSsrOrbitClockDepA { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + /// GNSS reference time of the correction + #[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 ConcreteMessage for MsgSsrOrbitClockDepA { + const MESSAGE_TYPE: u16 = 1500; + const MESSAGE_NAME: &'static str = "MSG_SSR_ORBIT_CLOCK_DEP_A"; + } + + impl SbpMessage for MsgSsrOrbitClockDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgSsrOrbitClockDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSsrOrbitClockDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgSsrOrbitClockDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSsrOrbitClockDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgSsrOrbitClockDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.time) - + WireFormat::len(&self.sid) - + WireFormat::len(&self.update_interval) - + WireFormat::len(&self.iod_ssr) - + WireFormat::len(&self.iod) - + WireFormat::len(&self.radial) - + WireFormat::len(&self.along) - + WireFormat::len(&self.cross) - + WireFormat::len(&self.dot_radial) - + WireFormat::len(&self.dot_along) - + WireFormat::len(&self.dot_cross) - + WireFormat::len(&self.c0) - + WireFormat::len(&self.c1) - + WireFormat::len(&self.c2) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgSsrOrbitClockDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.time) + + WireFormat::len(&self.sid) + + WireFormat::len(&self.update_interval) + + WireFormat::len(&self.iod_ssr) + + WireFormat::len(&self.iod) + + WireFormat::len(&self.radial) + + WireFormat::len(&self.along) + + WireFormat::len(&self.cross) + + WireFormat::len(&self.dot_radial) + + WireFormat::len(&self.dot_along) + + WireFormat::len(&self.dot_cross) + + WireFormat::len(&self.c0) + + WireFormat::len(&self.c1) + + WireFormat::len(&self.c2) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Precise phase biases correction -/// -/// The precise phase biases message contains the biases to be added to the -/// carrier phase of the corresponding signal to get corrected carrier phase -/// measurement, as well as the satellite yaw angle to be applied to compute -/// the phase wind-up correction. It is typically an equivalent to the 1265 -/// RTCM message types. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSsrPhaseBiases { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, - /// GNSS reference time of the correction - #[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, -} +pub mod msg_ssr_phase_biases { + #![allow(unused_imports)] -impl ConcreteMessage for MsgSsrPhaseBiases { - const MESSAGE_TYPE: u16 = 1510; - const MESSAGE_NAME: &'static str = "MSG_SSR_PHASE_BIASES"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgSsrPhaseBiases { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + /// Precise phase biases correction + /// + /// The precise phase biases message contains the biases to be added to the + /// carrier phase of the corresponding signal to get corrected carrier phase + /// measurement, as well as the satellite yaw angle to be applied to compute + /// the phase wind-up correction. It is typically an equivalent to the 1265 + /// RTCM message types. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSsrPhaseBiases { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + /// GNSS reference time of the correction + #[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 ConcreteMessage for MsgSsrPhaseBiases { + const MESSAGE_TYPE: u16 = 1510; + const MESSAGE_NAME: &'static str = "MSG_SSR_PHASE_BIASES"; + } + + impl SbpMessage for MsgSsrPhaseBiases { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgSsrPhaseBiases { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSsrPhaseBiases(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgSsrPhaseBiases { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSsrPhaseBiases(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgSsrPhaseBiases { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.time) - + WireFormat::len(&self.sid) - + WireFormat::len(&self.update_interval) - + WireFormat::len(&self.iod_ssr) - + WireFormat::len(&self.dispersive_bias) - + WireFormat::len(&self.mw_consistency) - + WireFormat::len(&self.yaw) - + WireFormat::len(&self.yaw_rate) - + WireFormat::len(&self.biases) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgSsrPhaseBiases { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.time) + + WireFormat::len(&self.sid) + + WireFormat::len(&self.update_interval) + + WireFormat::len(&self.iod_ssr) + + WireFormat::len(&self.dispersive_bias) + + WireFormat::len(&self.mw_consistency) + + WireFormat::len(&self.yaw) + + WireFormat::len(&self.yaw_rate) + + WireFormat::len(&self.biases) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Satellite antenna phase center corrections -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSsrSatelliteApc { - /// 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, -} +pub mod msg_ssr_satellite_apc { + #![allow(unused_imports)] -impl ConcreteMessage for MsgSsrSatelliteApc { - const MESSAGE_TYPE: u16 = 1540; - const MESSAGE_NAME: &'static str = "MSG_SSR_SATELLITE_APC"; -} - -impl SbpMessage for MsgSsrSatelliteApc { - 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); + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + /// Satellite antenna phase center corrections + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSsrSatelliteApc { + /// 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, } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgSsrSatelliteApc { + const MESSAGE_TYPE: u16 = 1540; + const MESSAGE_NAME: &'static str = "MSG_SSR_SATELLITE_APC"; } -} -impl TryFrom for MsgSsrSatelliteApc { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSsrSatelliteApc(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgSsrSatelliteApc { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgSsrSatelliteApc { - const MIN_LEN: usize = as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.apc) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.apc, buf); + impl TryFrom for MsgSsrSatelliteApc { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSsrSatelliteApc(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgSsrSatelliteApc { - sender_id: None, - apc: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgSsrSatelliteApc { + const MIN_LEN: usize = as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.apc) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.apc, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgSsrSatelliteApc { + sender_id: None, + apc: WireFormat::parse_unchecked(buf), + } } } } -/// STEC correction polynomial coefficients -/// -/// The Slant Total Electron Content per space vehicle, given as polynomial -/// approximation for a given tile. This should be combined with the -/// MSG_SSR_GRIDDED_CORRECTION message to get the state space representation -/// of the atmospheric delay. -/// -/// It is typically equivalent to the QZSS CLAS Sub Type 8 messages. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSsrStecCorrection { - /// 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, -} +pub mod msg_ssr_stec_correction { + #![allow(unused_imports)] -impl ConcreteMessage for MsgSsrStecCorrection { - const MESSAGE_TYPE: u16 = 1531; - const MESSAGE_NAME: &'static str = "MSG_SSR_STEC_CORRECTION"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgSsrStecCorrection { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + /// STEC correction polynomial coefficients + /// + /// The Slant Total Electron Content per space vehicle, given as polynomial + /// approximation for a given tile. This should be combined with the + /// MSG_SSR_GRIDDED_CORRECTION message to get the state space representation + /// of the atmospheric delay. + /// + /// It is typically equivalent to the QZSS CLAS Sub Type 8 messages. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSsrStecCorrection { + /// 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 ConcreteMessage for MsgSsrStecCorrection { + const MESSAGE_TYPE: u16 = 1531; + const MESSAGE_NAME: &'static str = "MSG_SSR_STEC_CORRECTION"; + } + + impl SbpMessage for MsgSsrStecCorrection { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgSsrStecCorrection { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSsrStecCorrection(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgSsrStecCorrection { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSsrStecCorrection(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgSsrStecCorrection { - const MIN_LEN: usize = - ::MIN_LEN + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.header) + WireFormat::len(&self.stec_sat_list) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.header, buf); - WireFormat::write(&self.stec_sat_list, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgSsrStecCorrection { - sender_id: None, - header: WireFormat::parse_unchecked(buf), - stec_sat_list: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgSsrStecCorrection { + const MIN_LEN: usize = + ::MIN_LEN + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.header) + WireFormat::len(&self.stec_sat_list) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.header, buf); + WireFormat::write(&self.stec_sat_list, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgSsrStecCorrection { + sender_id: None, + header: WireFormat::parse_unchecked(buf), + stec_sat_list: WireFormat::parse_unchecked(buf), + } } } } -/// Deprecated -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSsrStecCorrectionDepA { - /// 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 ConcreteMessage for MsgSsrStecCorrectionDepA { - const MESSAGE_TYPE: u16 = 1515; - const MESSAGE_NAME: &'static str = "MSG_SSR_STEC_CORRECTION_DEP_A"; -} +pub mod msg_ssr_stec_correction_dep_a { + #![allow(unused_imports)] -impl SbpMessage for MsgSsrStecCorrectionDepA { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + /// Deprecated + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSsrStecCorrectionDepA { + /// 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, } - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl 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 = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSsrStecCorrectionDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgSsrStecCorrectionDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgSsrStecCorrectionDepA { - const MIN_LEN: usize = - ::MIN_LEN + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.header) + WireFormat::len(&self.stec_sat_list) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.header, buf); - WireFormat::write(&self.stec_sat_list, buf); + impl TryFrom for MsgSsrStecCorrectionDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSsrStecCorrectionDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgSsrStecCorrectionDepA { - sender_id: None, - header: WireFormat::parse_unchecked(buf), - stec_sat_list: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgSsrStecCorrectionDepA { + const MIN_LEN: usize = + ::MIN_LEN + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.header) + WireFormat::len(&self.stec_sat_list) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.header, buf); + WireFormat::write(&self.stec_sat_list, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgSsrStecCorrectionDepA { + sender_id: None, + header: WireFormat::parse_unchecked(buf), + stec_sat_list: WireFormat::parse_unchecked(buf), + } } } } -/// Definition of a SSR atmospheric correction tile. - -/// -/// Provides the correction point coordinates for the atmospheric correction -/// values in the MSG_SSR_STEC_CORRECTION and MSG_SSR_GRIDDED_CORRECTION -/// messages. -/// -/// Based on ETSI TS 137 355 V16.1.0 (LTE Positioning Protocol) information -/// element GNSS-SSR-CorrectionPoints. SBP only supports gridded arrays of -/// correction points, not lists of points. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSsrTileDefinition { - /// 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 - /// 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 - /// 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. +pub mod msg_ssr_tile_definition { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Definition of a SSR atmospheric correction tile. + /// - /// If a specific bit is enabled (set to 1), the correction is not - /// available. Only the first rows * cols bits are used, the remainder are - /// set to 0. If there are more then 64 correction points the remaining - /// corrections are always available. + /// Provides the correction point coordinates for the atmospheric correction + /// values in the MSG_SSR_STEC_CORRECTION and MSG_SSR_GRIDDED_CORRECTION + /// messages. /// - /// Starting with the northwest corner of the array (top left on a north - /// oriented map) the correction points are enumerated with row precedence - - /// first row west to east, second row west to east, until last row west to - /// east - ending with the southeast corner of the array. + /// Based on ETSI TS 137 355 V16.1.0 (LTE Positioning Protocol) information + /// element GNSS-SSR-CorrectionPoints. SBP only supports gridded arrays of + /// correction points, not lists of points. /// - /// 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 ConcreteMessage for MsgSsrTileDefinition { - const MESSAGE_TYPE: u16 = 1526; - const MESSAGE_NAME: &'static str = "MSG_SSR_TILE_DEFINITION"; -} - -impl SbpMessage for MsgSsrTileDefinition { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSsrTileDefinition { + /// 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 + /// 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 + /// 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. + /// + /// If a specific bit is enabled (set to 1), the correction is not + /// available. Only the first rows * cols bits are used, the remainder are + /// set to 0. If there are more then 64 correction points the remaining + /// corrections are always available. + /// + /// Starting with the northwest corner of the array (top left on a north + /// oriented map) the correction points are enumerated with row precedence - + /// first row west to east, second row west to east, until last row west to + /// east - ending with the southeast corner of the array. + /// + /// 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 ConcreteMessage for MsgSsrTileDefinition { + const MESSAGE_TYPE: u16 = 1526; + const MESSAGE_NAME: &'static str = "MSG_SSR_TILE_DEFINITION"; + } + + impl SbpMessage for MsgSsrTileDefinition { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgSsrTileDefinition { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSsrTileDefinition(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgSsrTileDefinition { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSsrTileDefinition(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgSsrTileDefinition { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tile_set_id) - + WireFormat::len(&self.tile_id) - + WireFormat::len(&self.corner_nw_lat) - + WireFormat::len(&self.corner_nw_lon) - + WireFormat::len(&self.spacing_lat) - + WireFormat::len(&self.spacing_lon) - + WireFormat::len(&self.rows) - + WireFormat::len(&self.cols) - + WireFormat::len(&self.bitmask) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgSsrTileDefinition { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tile_set_id) + + WireFormat::len(&self.tile_id) + + WireFormat::len(&self.corner_nw_lat) + + WireFormat::len(&self.corner_nw_lon) + + WireFormat::len(&self.spacing_lat) + + WireFormat::len(&self.spacing_lon) + + WireFormat::len(&self.rows) + + WireFormat::len(&self.cols) + + WireFormat::len(&self.bitmask) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// SSR phase biases corrections for a particular satellite -/// -/// Phase biases are to be added to carrier phase measurements. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod phase_biases_content { + #![allow(unused_imports)] -impl WireFormat for PhaseBiasesContent { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.code) - + WireFormat::len(&self.integer_indicator) - + WireFormat::len(&self.widelane_integer_indicator) - + WireFormat::len(&self.discontinuity_counter) - + WireFormat::len(&self.bias) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// SSR phase biases corrections for a particular satellite + /// + /// Phase biases are to be added to carrier phase measurements. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 WireFormat for PhaseBiasesContent { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.code) + + WireFormat::len(&self.integer_indicator) + + WireFormat::len(&self.widelane_integer_indicator) + + WireFormat::len(&self.discontinuity_counter) + + WireFormat::len(&self.bias) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Header for the MSG_SSR_STEC_CORRECTION message -/// -/// A full set of STEC information will likely span multiple SBP messages, -/// since SBP message a limited to 255 bytes. The header is used to tie -/// multiple SBP messages into a sequence. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 - #[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, -} +pub mod stec_header { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl WireFormat for STECHeader { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tile_set_id) - + WireFormat::len(&self.tile_id) - + WireFormat::len(&self.time) - + WireFormat::len(&self.num_msgs) - + WireFormat::len(&self.seq_num) - + WireFormat::len(&self.update_interval) - + WireFormat::len(&self.iod_atmo) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + /// Header for the MSG_SSR_STEC_CORRECTION message + /// + /// A full set of STEC information will likely span multiple SBP messages, + /// since SBP message a limited to 255 bytes. The header is used to tie + /// multiple SBP messages into a sequence. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 + #[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 WireFormat for STECHeader { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tile_set_id) + + WireFormat::len(&self.tile_id) + + WireFormat::len(&self.time) + + WireFormat::len(&self.num_msgs) + + WireFormat::len(&self.seq_num) + + WireFormat::len(&self.update_interval) + + WireFormat::len(&self.iod_atmo) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// Header for MSG_SSR_STEC_CORRECTION_DEP message -/// -/// A full set of STEC information will likely span multiple SBP messages, -/// since SBP message a limited to 255 bytes. The header is used to tie -/// multiple SBP messages into a sequence. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct STECHeaderDepA { - /// GNSS reference time of the correction - #[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, -} +pub mod stec_header_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl WireFormat for STECHeaderDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.time) - + WireFormat::len(&self.num_msgs) - + WireFormat::len(&self.seq_num) - + WireFormat::len(&self.update_interval) - + WireFormat::len(&self.iod_atmo) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + /// Header for MSG_SSR_STEC_CORRECTION_DEP message + /// + /// A full set of STEC information will likely span multiple SBP messages, + /// since SBP message a limited to 255 bytes. The header is used to tie + /// multiple SBP messages into a sequence. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct STECHeaderDepA { + /// GNSS reference time of the correction + #[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 WireFormat for STECHeaderDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.time) + + WireFormat::len(&self.num_msgs) + + WireFormat::len(&self.seq_num) + + WireFormat::len(&self.update_interval) + + WireFormat::len(&self.iod_atmo) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// None -/// -/// STEC residual (mean and standard deviation) for the given satellite at the -/// grid point. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod stec_residual { + #![allow(unused_imports)] -impl WireFormat for STECResidual { - const MIN_LEN: usize = - ::MIN_LEN + ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sv_id) - + WireFormat::len(&self.residual) - + WireFormat::len(&self.stddev) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sv_id, buf); - WireFormat::write(&self.residual, buf); - WireFormat::write(&self.stddev, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - STECResidual { - sv_id: WireFormat::parse_unchecked(buf), - residual: WireFormat::parse_unchecked(buf), - stddev: WireFormat::parse_unchecked(buf), + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// None + /// + /// STEC residual (mean and standard deviation) for the given satellite at the + /// grid point. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 WireFormat for STECResidual { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sv_id) + + WireFormat::len(&self.residual) + + WireFormat::len(&self.stddev) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sv_id, buf); + WireFormat::write(&self.residual, buf); + WireFormat::write(&self.stddev, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + STECResidual { + sv_id: WireFormat::parse_unchecked(buf), + residual: WireFormat::parse_unchecked(buf), + stddev: WireFormat::parse_unchecked(buf), + } } } } -/// None -/// -/// STEC residual for the given satellite at the grid point. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod stec_residual_no_std { + #![allow(unused_imports)] -impl WireFormat for STECResidualNoStd { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sv_id) + WireFormat::len(&self.residual) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sv_id, buf); - WireFormat::write(&self.residual, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - STECResidualNoStd { - sv_id: WireFormat::parse_unchecked(buf), - residual: WireFormat::parse_unchecked(buf), + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// None + /// + /// STEC residual for the given satellite at the grid point. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 WireFormat for STECResidualNoStd { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sv_id) + WireFormat::len(&self.residual) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sv_id, buf); + WireFormat::write(&self.residual, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + STECResidualNoStd { + sv_id: WireFormat::parse_unchecked(buf), + residual: WireFormat::parse_unchecked(buf), + } } } } -/// None -/// -/// STEC polynomial for the given satellite. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "stec_coeff")))] - pub stec_coeff: [i16; 4], -} +pub mod stec_sat_element { + #![allow(unused_imports)] -impl WireFormat for STECSatElement { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + <[i16; 4] as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sv_id) - + WireFormat::len(&self.stec_quality_indicator) - + WireFormat::len(&self.stec_coeff) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sv_id, buf); - WireFormat::write(&self.stec_quality_indicator, buf); - WireFormat::write(&self.stec_coeff, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - STECSatElement { - sv_id: WireFormat::parse_unchecked(buf), - stec_quality_indicator: WireFormat::parse_unchecked(buf), - stec_coeff: WireFormat::parse_unchecked(buf), + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// None + /// + /// STEC polynomial for the given satellite. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "stec_coeff")))] + pub stec_coeff: [i16; 4], + } + + impl WireFormat for STECSatElement { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + <[i16; 4] as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sv_id) + + WireFormat::len(&self.stec_quality_indicator) + + WireFormat::len(&self.stec_coeff) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sv_id, buf); + WireFormat::write(&self.stec_quality_indicator, buf); + WireFormat::write(&self.stec_coeff, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + STECSatElement { + sv_id: WireFormat::parse_unchecked(buf), + stec_quality_indicator: WireFormat::parse_unchecked(buf), + stec_coeff: WireFormat::parse_unchecked(buf), + } } } } -/// Antenna phase center correction -/// -/// Contains phase center offset and elevation variation corrections for one -/// signal on a satellite. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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. - #[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. - #[cfg_attr(feature = "serde", serde(rename(serialize = "pcv")))] - pub pcv: [i8; 21], -} +pub mod satellite_apc { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Antenna phase center correction + /// + /// Contains phase center offset and elevation variation corrections for one + /// signal on a satellite. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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. + #[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. + #[cfg_attr(feature = "serde", serde(rename(serialize = "pcv")))] + pub pcv: [i8; 21], + } + + impl SatelliteAPC { + pub fn satellite_type(&self) -> Option { + match get_bit_range!(self.sat_info, u8, u8, 4, 0) { + 0 => Some(SatelliteType::UnknownType), + 1 => Some(SatelliteType::GpsI), + 2 => Some(SatelliteType::GpsIi), + 3 => Some(SatelliteType::GpsIia), + 4 => Some(SatelliteType::GpsIir), + 5 => Some(SatelliteType::GpsIif), + 6 => Some(SatelliteType::GpsIii), + 7 => Some(SatelliteType::GLONASS), + 8 => Some(SatelliteType::GlonassM), + 9 => Some(SatelliteType::GlonassK1), + 10 => Some(SatelliteType::GALILEO), + 11 => Some(SatelliteType::Beidou2G), + 12 => Some(SatelliteType::Beidou2I), + 13 => Some(SatelliteType::Beidou2M), + 14 => Some(SatelliteType::Beidou3MSecm), + 15 => Some(SatelliteType::Beidou3GSecm), + 16 => Some(SatelliteType::Beidou3MCast), + 17 => Some(SatelliteType::Beidou3GCast), + 18 => Some(SatelliteType::Beidou3ICast), + 19 => Some(SatelliteType::QZSS), + _ => None, + } + } -impl SatelliteAPC { - pub fn satellite_type(&self) -> Option { - match get_bit_range!(self.sat_info, u8, u8, 4, 0) { - 0 => Some(SatelliteAPCSatelliteType::UnknownType), - 1 => Some(SatelliteAPCSatelliteType::GpsI), - 2 => Some(SatelliteAPCSatelliteType::GpsIi), - 3 => Some(SatelliteAPCSatelliteType::GpsIia), - 4 => Some(SatelliteAPCSatelliteType::GpsIir), - 5 => Some(SatelliteAPCSatelliteType::GpsIif), - 6 => Some(SatelliteAPCSatelliteType::GpsIii), - 7 => Some(SatelliteAPCSatelliteType::GLONASS), - 8 => Some(SatelliteAPCSatelliteType::GlonassM), - 9 => Some(SatelliteAPCSatelliteType::GlonassK1), - 10 => Some(SatelliteAPCSatelliteType::GALILEO), - 11 => Some(SatelliteAPCSatelliteType::Beidou2G), - 12 => Some(SatelliteAPCSatelliteType::Beidou2I), - 13 => Some(SatelliteAPCSatelliteType::Beidou2M), - 14 => Some(SatelliteAPCSatelliteType::Beidou3MSecm), - 15 => Some(SatelliteAPCSatelliteType::Beidou3GSecm), - 16 => Some(SatelliteAPCSatelliteType::Beidou3MCast), - 17 => Some(SatelliteAPCSatelliteType::Beidou3GCast), - 18 => Some(SatelliteAPCSatelliteType::Beidou3ICast), - 19 => Some(SatelliteAPCSatelliteType::QZSS), - _ => None, - } - } - - pub fn set_satellite_type(&mut self, satellite_type: SatelliteAPCSatelliteType) { - set_bit_range!(&mut self.sat_info, satellite_type, u8, u8, 4, 0); + pub fn set_satellite_type(&mut self, satellite_type: SatelliteType) { + set_bit_range!(&mut self.sat_info, satellite_type, u8, u8, 4, 0); + } } -} -impl WireFormat for SatelliteAPC { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + <[i16; 3] as WireFormat>::MIN_LEN - + <[i8; 21] as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sid) - + WireFormat::len(&self.sat_info) - + WireFormat::len(&self.svn) - + WireFormat::len(&self.pco) - + WireFormat::len(&self.pcv) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for SatelliteAPC { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + <[i16; 3] as WireFormat>::MIN_LEN + + <[i8; 21] as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sid) + + WireFormat::len(&self.sat_info) + + WireFormat::len(&self.svn) + + WireFormat::len(&self.pco) + + WireFormat::len(&self.pcv) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Satellite Type -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum SatelliteAPCSatelliteType { - /// Unknown Type - UnknownType = 0, + /// Satellite Type + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum SatelliteType { + /// Unknown Type + UnknownType = 0, - /// GPS I - GpsI = 1, + /// GPS I + GpsI = 1, - /// GPS II - GpsIi = 2, + /// GPS II + GpsIi = 2, - /// GPS IIA - GpsIia = 3, + /// GPS IIA + GpsIia = 3, - /// GPS IIR - GpsIir = 4, + /// GPS IIR + GpsIir = 4, - /// GPS IIF - GpsIif = 5, + /// GPS IIF + GpsIif = 5, - /// GPS III - GpsIii = 6, + /// GPS III + GpsIii = 6, - /// GLONASS - GLONASS = 7, + /// GLONASS + GLONASS = 7, - /// GLONASS M - GlonassM = 8, + /// GLONASS M + GlonassM = 8, - /// GLONASS K1 - GlonassK1 = 9, + /// GLONASS K1 + GlonassK1 = 9, - /// GALILEO - GALILEO = 10, + /// GALILEO + GALILEO = 10, - /// BEIDOU 2G - Beidou2G = 11, + /// BEIDOU 2G + Beidou2G = 11, - /// BEIDOU 2I - Beidou2I = 12, + /// BEIDOU 2I + Beidou2I = 12, - /// BEIDOU 2M - Beidou2M = 13, + /// BEIDOU 2M + Beidou2M = 13, - /// BEIDOU 3M, SECM - Beidou3MSecm = 14, + /// BEIDOU 3M, SECM + Beidou3MSecm = 14, - /// BEIDOU 3G, SECM - Beidou3GSecm = 15, + /// BEIDOU 3G, SECM + Beidou3GSecm = 15, - /// BEIDOU 3M, CAST - Beidou3MCast = 16, + /// BEIDOU 3M, CAST + Beidou3MCast = 16, - /// BEIDOU 3G, CAST - Beidou3GCast = 17, + /// BEIDOU 3G, CAST + Beidou3GCast = 17, - /// BEIDOU 3I, CAST - Beidou3ICast = 18, + /// BEIDOU 3I, CAST + Beidou3ICast = 18, - /// QZSS - QZSS = 19, -} + /// QZSS + QZSS = 19, + } -impl std::fmt::Display for SatelliteAPCSatelliteType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - SatelliteAPCSatelliteType::UnknownType => f.write_str("Unknown Type"), - SatelliteAPCSatelliteType::GpsI => f.write_str("GPS I"), - SatelliteAPCSatelliteType::GpsIi => f.write_str("GPS II"), - SatelliteAPCSatelliteType::GpsIia => f.write_str("GPS IIA"), - SatelliteAPCSatelliteType::GpsIir => f.write_str("GPS IIR"), - SatelliteAPCSatelliteType::GpsIif => f.write_str("GPS IIF"), - SatelliteAPCSatelliteType::GpsIii => f.write_str("GPS III"), - SatelliteAPCSatelliteType::GLONASS => f.write_str("GLONASS"), - SatelliteAPCSatelliteType::GlonassM => f.write_str("GLONASS M"), - SatelliteAPCSatelliteType::GlonassK1 => f.write_str("GLONASS K1"), - SatelliteAPCSatelliteType::GALILEO => f.write_str("GALILEO"), - SatelliteAPCSatelliteType::Beidou2G => f.write_str("BEIDOU 2G"), - SatelliteAPCSatelliteType::Beidou2I => f.write_str("BEIDOU 2I"), - SatelliteAPCSatelliteType::Beidou2M => f.write_str("BEIDOU 2M"), - SatelliteAPCSatelliteType::Beidou3MSecm => f.write_str("BEIDOU 3M, SECM"), - SatelliteAPCSatelliteType::Beidou3GSecm => f.write_str("BEIDOU 3G, SECM"), - SatelliteAPCSatelliteType::Beidou3MCast => f.write_str("BEIDOU 3M, CAST"), - SatelliteAPCSatelliteType::Beidou3GCast => f.write_str("BEIDOU 3G, CAST"), - SatelliteAPCSatelliteType::Beidou3ICast => f.write_str("BEIDOU 3I, CAST"), - SatelliteAPCSatelliteType::QZSS => f.write_str("QZSS"), + impl std::fmt::Display for SatelliteType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SatelliteType::UnknownType => f.write_str("Unknown Type"), + SatelliteType::GpsI => f.write_str("GPS I"), + SatelliteType::GpsIi => f.write_str("GPS II"), + SatelliteType::GpsIia => f.write_str("GPS IIA"), + SatelliteType::GpsIir => f.write_str("GPS IIR"), + SatelliteType::GpsIif => f.write_str("GPS IIF"), + SatelliteType::GpsIii => f.write_str("GPS III"), + SatelliteType::GLONASS => f.write_str("GLONASS"), + SatelliteType::GlonassM => f.write_str("GLONASS M"), + SatelliteType::GlonassK1 => f.write_str("GLONASS K1"), + SatelliteType::GALILEO => f.write_str("GALILEO"), + SatelliteType::Beidou2G => f.write_str("BEIDOU 2G"), + SatelliteType::Beidou2I => f.write_str("BEIDOU 2I"), + SatelliteType::Beidou2M => f.write_str("BEIDOU 2M"), + SatelliteType::Beidou3MSecm => f.write_str("BEIDOU 3M, SECM"), + SatelliteType::Beidou3GSecm => f.write_str("BEIDOU 3G, SECM"), + SatelliteType::Beidou3MCast => f.write_str("BEIDOU 3M, CAST"), + SatelliteType::Beidou3GCast => f.write_str("BEIDOU 3G, CAST"), + SatelliteType::Beidou3ICast => f.write_str("BEIDOU 3I, CAST"), + SatelliteType::QZSS => f.write_str("QZSS"), + } } } } -/// None -/// -/// Troposphere vertical delays (mean and standard deviation) at the grid -/// point. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod tropospheric_delay_correction { + #![allow(unused_imports)] -impl WireFormat for TroposphericDelayCorrection { - const MIN_LEN: usize = - ::MIN_LEN + ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.hydro) + WireFormat::len(&self.wet) + WireFormat::len(&self.stddev) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.hydro, buf); - WireFormat::write(&self.wet, buf); - WireFormat::write(&self.stddev, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - TroposphericDelayCorrection { - hydro: WireFormat::parse_unchecked(buf), - wet: WireFormat::parse_unchecked(buf), - stddev: WireFormat::parse_unchecked(buf), + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// None + /// + /// Troposphere vertical delays (mean and standard deviation) at the grid + /// point. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 WireFormat for TroposphericDelayCorrection { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.hydro) + + WireFormat::len(&self.wet) + + WireFormat::len(&self.stddev) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.hydro, buf); + WireFormat::write(&self.wet, buf); + WireFormat::write(&self.stddev, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + TroposphericDelayCorrection { + hydro: WireFormat::parse_unchecked(buf), + wet: WireFormat::parse_unchecked(buf), + stddev: WireFormat::parse_unchecked(buf), + } } } } -/// None -/// -/// Troposphere vertical delays at the grid point. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod tropospheric_delay_correction_no_std { + #![allow(unused_imports)] -impl WireFormat for TroposphericDelayCorrectionNoStd { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.hydro) + WireFormat::len(&self.wet) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.hydro, buf); - WireFormat::write(&self.wet, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - TroposphericDelayCorrectionNoStd { - hydro: WireFormat::parse_unchecked(buf), - wet: WireFormat::parse_unchecked(buf), + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// None + /// + /// Troposphere vertical delays at the grid point. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 WireFormat for TroposphericDelayCorrectionNoStd { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.hydro) + WireFormat::len(&self.wet) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.hydro, buf); + WireFormat::write(&self.wet, buf); + } + fn parse_unchecked(buf: &mut B) -> 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 9f96478a08..3ab165666e 100644 --- a/rust/sbp/src/messages/system.rs +++ b/rust/sbp/src/messages/system.rs @@ -13,1547 +13,1618 @@ // with generate.py. Please do not hand edit! //****************************************************************************/ //! Standardized system messages from Swift Navigation devices. - -use super::lib::*; - -/// Experimental telemetry message -/// -/// The CSAC telemetry message has an implementation defined telemetry string -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgCsacTelemetry { - /// 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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "telemetry")))] - pub telemetry: SbpString, Unterminated>, -} - -impl ConcreteMessage for MsgCsacTelemetry { - const MESSAGE_TYPE: u16 = 65284; - const MESSAGE_NAME: &'static str = "MSG_CSAC_TELEMETRY"; -} - -impl SbpMessage for MsgCsacTelemetry { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } -} - -impl TryFrom for MsgCsacTelemetry { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgCsacTelemetry(m) => Ok(m), - _ => Err(TryFromSbpError), +pub use msg_csac_telemetry::MsgCsacTelemetry; +pub use msg_csac_telemetry_labels::MsgCsacTelemetryLabels; +pub use msg_dgnss_status::MsgDgnssStatus; +pub use msg_gnss_time_offset::MsgGnssTimeOffset; +pub use msg_group_meta::MsgGroupMeta; +pub use msg_heartbeat::MsgHeartbeat; +pub use msg_ins_status::MsgInsStatus; +pub use msg_ins_updates::MsgInsUpdates; +pub use msg_pps_time::MsgPpsTime; +pub use msg_startup::MsgStartup; +pub use msg_status_report::MsgStatusReport; +pub use sub_system_report::SubSystemReport; + +pub mod msg_csac_telemetry { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Experimental telemetry message + /// + /// The CSAC telemetry message has an implementation defined telemetry string + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgCsacTelemetry { + /// 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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "telemetry")))] + pub telemetry: SbpString, Unterminated>, + } + + impl ConcreteMessage for MsgCsacTelemetry { + const MESSAGE_TYPE: u16 = 65284; + const MESSAGE_NAME: &'static str = "MSG_CSAC_TELEMETRY"; + } + + impl SbpMessage for MsgCsacTelemetry { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + } + + impl TryFrom for MsgCsacTelemetry { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgCsacTelemetry(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgCsacTelemetry { - const MIN_LEN: usize = - ::MIN_LEN + , Unterminated> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.id) + WireFormat::len(&self.telemetry) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.id, buf); - WireFormat::write(&self.telemetry, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgCsacTelemetry { - sender_id: None, - id: WireFormat::parse_unchecked(buf), - telemetry: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgCsacTelemetry { + const MIN_LEN: usize = + ::MIN_LEN + , Unterminated> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.id) + WireFormat::len(&self.telemetry) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.id, buf); + WireFormat::write(&self.telemetry, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgCsacTelemetry { + sender_id: None, + id: WireFormat::parse_unchecked(buf), + telemetry: WireFormat::parse_unchecked(buf), + } } } } -/// Experimental telemetry message labels -/// -/// The CSAC telemetry message provides labels for each member of the string -/// produced by MSG_CSAC_TELEMETRY. It should be provided by a device at a -/// lower rate than the MSG_CSAC_TELEMETRY. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgCsacTelemetryLabels { - /// 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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "telemetry_labels")))] - pub telemetry_labels: SbpString, Unterminated>, -} +pub mod msg_csac_telemetry_labels { + #![allow(unused_imports)] -impl ConcreteMessage for MsgCsacTelemetryLabels { - const MESSAGE_TYPE: u16 = 65285; - const MESSAGE_NAME: &'static str = "MSG_CSAC_TELEMETRY_LABELS"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgCsacTelemetryLabels { - 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); + /// Experimental telemetry message labels + /// + /// The CSAC telemetry message provides labels for each member of the string + /// produced by MSG_CSAC_TELEMETRY. It should be provided by a device at a + /// lower rate than the MSG_CSAC_TELEMETRY. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgCsacTelemetryLabels { + /// 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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "telemetry_labels")))] + pub telemetry_labels: SbpString, Unterminated>, } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } -} -impl TryFrom for MsgCsacTelemetryLabels { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgCsacTelemetryLabels(m) => Ok(m), - _ => Err(TryFromSbpError), - } + impl ConcreteMessage for MsgCsacTelemetryLabels { + const MESSAGE_TYPE: u16 = 65285; + const MESSAGE_NAME: &'static str = "MSG_CSAC_TELEMETRY_LABELS"; } -} -impl WireFormat for MsgCsacTelemetryLabels { - const MIN_LEN: usize = - ::MIN_LEN + , Unterminated> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.id) + WireFormat::len(&self.telemetry_labels) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.id, buf); - WireFormat::write(&self.telemetry_labels, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgCsacTelemetryLabels { - sender_id: None, - id: WireFormat::parse_unchecked(buf), - telemetry_labels: WireFormat::parse_unchecked(buf), + impl SbpMessage for MsgCsacTelemetryLabels { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -/// Status of received corrections -/// -/// This message provides information about the receipt of Differential -/// corrections. It is expected to be sent with each receipt of a complete -/// corrections packet. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgDgnssStatus { - /// 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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "source")))] - pub source: SbpString, Unterminated>, -} - -impl MsgDgnssStatus { - pub fn differential_type(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 0) { - 0 => Some(MsgDgnssStatusDifferentialType::Invalid), - 1 => Some(MsgDgnssStatusDifferentialType::CodeDifference), - 2 => Some(MsgDgnssStatusDifferentialType::RTK), - _ => None, + impl TryFrom for MsgCsacTelemetryLabels { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgCsacTelemetryLabels(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } - pub fn set_differential_type(&mut self, differential_type: MsgDgnssStatusDifferentialType) { - set_bit_range!(&mut self.flags, differential_type, u8, u8, 3, 0); + impl WireFormat for MsgCsacTelemetryLabels { + const MIN_LEN: usize = + ::MIN_LEN + , Unterminated> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.id) + WireFormat::len(&self.telemetry_labels) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.id, buf); + WireFormat::write(&self.telemetry_labels, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgCsacTelemetryLabels { + sender_id: None, + id: WireFormat::parse_unchecked(buf), + telemetry_labels: WireFormat::parse_unchecked(buf), + } + } } } -impl ConcreteMessage for MsgDgnssStatus { - const MESSAGE_TYPE: u16 = 65282; - const MESSAGE_NAME: &'static str = "MSG_DGNSS_STATUS"; -} +pub mod msg_dgnss_status { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Status of received corrections + /// + /// This message provides information about the receipt of Differential + /// corrections. It is expected to be sent with each receipt of a complete + /// corrections packet. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgDgnssStatus { + /// 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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "source")))] + pub source: SbpString, Unterminated>, + } + + impl MsgDgnssStatus { + pub fn differential_type(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 0) { + 0 => Some(DifferentialType::Invalid), + 1 => Some(DifferentialType::CodeDifference), + 2 => Some(DifferentialType::RTK), + _ => None, + } + } -impl SbpMessage for MsgDgnssStatus { - 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); + pub fn set_differential_type(&mut self, differential_type: DifferentialType) { + set_bit_range!(&mut self.flags, differential_type, u8, u8, 3, 0); + } } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgDgnssStatus { + const MESSAGE_TYPE: u16 = 65282; + const MESSAGE_NAME: &'static str = "MSG_DGNSS_STATUS"; } -} -impl TryFrom for MsgDgnssStatus { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgDgnssStatus(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgDgnssStatus { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgDgnssStatus { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + , Unterminated> as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.flags) - + WireFormat::len(&self.latency) - + WireFormat::len(&self.num_signals) - + WireFormat::len(&self.source) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl TryFrom for MsgDgnssStatus { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgDgnssStatus(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} - -/// Differential type -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgDgnssStatusDifferentialType { - /// Invalid - Invalid = 0, - /// Code Difference - CodeDifference = 1, - - /// RTK - RTK = 2, -} - -impl std::fmt::Display for MsgDgnssStatusDifferentialType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgDgnssStatusDifferentialType::Invalid => f.write_str("Invalid"), - MsgDgnssStatusDifferentialType::CodeDifference => f.write_str("Code Difference"), - MsgDgnssStatusDifferentialType::RTK => f.write_str("RTK"), + impl WireFormat for MsgDgnssStatus { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + , Unterminated> as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.flags) + + WireFormat::len(&self.latency) + + WireFormat::len(&self.num_signals) + + WireFormat::len(&self.source) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Offset of the local time with respect to GNSS time -/// -/// The GNSS time offset message contains the information that is needed to -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgGnssTimeOffset { - /// 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 ConcreteMessage for MsgGnssTimeOffset { - const MESSAGE_TYPE: u16 = 65287; - const MESSAGE_NAME: &'static str = "MSG_GNSS_TIME_OFFSET"; -} + /// Differential type + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum DifferentialType { + /// Invalid + Invalid = 0, -impl SbpMessage for MsgGnssTimeOffset { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } -} + /// Code Difference + CodeDifference = 1, -impl TryFrom for MsgGnssTimeOffset { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgGnssTimeOffset(m) => Ok(m), - _ => Err(TryFromSbpError), - } + /// RTK + RTK = 2, } -} -impl WireFormat for MsgGnssTimeOffset { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.weeks) - + WireFormat::len(&self.milliseconds) - + WireFormat::len(&self.microseconds) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl std::fmt::Display for DifferentialType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + DifferentialType::Invalid => f.write_str("Invalid"), + DifferentialType::CodeDifference => f.write_str("Code Difference"), + DifferentialType::RTK => f.write_str("RTK"), + } } } } -/// Solution Group Metadata -/// -/// This leading message lists the time metadata of the Solution Group. It -/// also lists the atomic contents (i.e. types of messages included) of the -/// Solution Group. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgGroupMeta { - /// 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, -} +pub mod msg_gnss_time_offset { + #![allow(unused_imports)] -impl MsgGroupMeta { - pub fn solution_group_type(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 1, 0) { - 0 => Some(MsgGroupMetaSolutionGroupType::None), - 1 => Some(MsgGroupMetaSolutionGroupType::GnssOnly), - 2 => Some(MsgGroupMetaSolutionGroupType::GnssINS), - _ => None, - } - } + use super::*; + use crate::messages::lib::*; - pub fn set_solution_group_type(&mut self, solution_group_type: MsgGroupMetaSolutionGroupType) { - set_bit_range!(&mut self.flags, solution_group_type, u8, u8, 1, 0); + /// Offset of the local time with respect to GNSS time + /// + /// The GNSS time offset message contains the information that is needed to + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgGnssTimeOffset { + /// 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 ConcreteMessage for MsgGroupMeta { - const MESSAGE_TYPE: u16 = 65290; - const MESSAGE_NAME: &'static str = "MSG_GROUP_META"; -} -impl SbpMessage for MsgGroupMeta { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME + impl ConcreteMessage for MsgGnssTimeOffset { + const MESSAGE_TYPE: u16 = 65287; + const MESSAGE_NAME: &'static str = "MSG_GNSS_TIME_OFFSET"; } - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } -} -impl TryFrom for MsgGroupMeta { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgGroupMeta(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgGnssTimeOffset { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgGroupMeta { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.group_id) - + WireFormat::len(&self.flags) - + WireFormat::len(&self.n_group_msgs) - + WireFormat::len(&self.group_msgs) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl TryFrom for MsgGnssTimeOffset { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgGnssTimeOffset(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -/// Solution Group type -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgGroupMetaSolutionGroupType { - /// None (invalid) - None = 0, - - /// GNSS only - GnssOnly = 1, - - /// GNSS+INS (Fuzed) - GnssINS = 2, -} - -impl std::fmt::Display for MsgGroupMetaSolutionGroupType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgGroupMetaSolutionGroupType::None => f.write_str("None (invalid)"), - MsgGroupMetaSolutionGroupType::GnssOnly => f.write_str("GNSS only"), - MsgGroupMetaSolutionGroupType::GnssINS => f.write_str("GNSS+INS (Fuzed)"), + impl WireFormat for MsgGnssTimeOffset { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.weeks) + + WireFormat::len(&self.milliseconds) + + WireFormat::len(&self.microseconds) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } } -/// System heartbeat message -/// -/// The heartbeat message is sent periodically to inform the host or other -/// attached devices that the system is running. It is used to monitor system -/// malfunctions. It also contains status flags that indicate to the host the -/// status of the system and whether it is operating correctly. Currently, the -/// expected heartbeat interval is 1 sec. -/// -/// The system error flag is used to indicate that an error has occurred in -/// the system. To determine the source of the error, the remaining error -/// flags should be inspected. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgHeartbeat { - /// 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 { - pub fn external_antenna_present(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 31, 0) { - 0 => Some(MsgHeartbeatExternalAntennaPresent::NoExternalAntennaDetected), - 1 => Some(MsgHeartbeatExternalAntennaPresent::ExternalAntennaIsPresent), - _ => None, +pub mod msg_group_meta { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Solution Group Metadata + /// + /// This leading message lists the time metadata of the Solution Group. It + /// also lists the atomic contents (i.e. types of messages included) of the + /// Solution Group. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgGroupMeta { + /// 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 { + pub fn solution_group_type(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 1, 0) { + 0 => Some(SolutionGroupType::None), + 1 => Some(SolutionGroupType::GnssOnly), + 2 => Some(SolutionGroupType::GnssINS), + _ => None, + } } - } - pub fn set_external_antenna_present( - &mut self, - external_antenna_present: MsgHeartbeatExternalAntennaPresent, - ) { - set_bit_range!(&mut self.flags, external_antenna_present, u32, u8, 31, 0); - } - - pub fn external_antenna_short(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 30, 0) { - 0 => Some(MsgHeartbeatExternalAntennaShort::NoShortDetected), - 1 => Some(MsgHeartbeatExternalAntennaShort::ShortDetected), - _ => None, + pub fn set_solution_group_type(&mut self, solution_group_type: SolutionGroupType) { + set_bit_range!(&mut self.flags, solution_group_type, u8, u8, 1, 0); } } - pub fn set_external_antenna_short( - &mut self, - external_antenna_short: MsgHeartbeatExternalAntennaShort, - ) { - set_bit_range!(&mut self.flags, external_antenna_short, u32, u8, 30, 0); - } - - pub fn sbp_major_protocol_version_number(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 23, 16) - } - - pub fn set_sbp_major_protocol_version_number(&mut self, sbp_major_protocol_version_number: u8) { - set_bit_range!( - &mut self.flags, - sbp_major_protocol_version_number, - u32, - u8, - 23, - 16 - ); - } - - pub fn sbp_minor_protocol_version_number(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 15, 8) + impl ConcreteMessage for MsgGroupMeta { + const MESSAGE_TYPE: u16 = 65290; + const MESSAGE_NAME: &'static str = "MSG_GROUP_META"; } - pub fn set_sbp_minor_protocol_version_number(&mut self, sbp_minor_protocol_version_number: u8) { - set_bit_range!( - &mut self.flags, - sbp_minor_protocol_version_number, - u32, - u8, - 15, - 8 - ); - } - - pub fn swift_nap_error(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 2, 0) { - 0 => Some(MsgHeartbeatSwiftNapError::SystemHealthy), - 1 => Some(MsgHeartbeatSwiftNapError::AnErrorHasOccurredInTheSwiftNap), - _ => None, + impl SbpMessage for MsgGroupMeta { + fn message_name(&self) -> &'static str { + ::MESSAGE_NAME } - } - - pub fn set_swift_nap_error(&mut self, swift_nap_error: MsgHeartbeatSwiftNapError) { - set_bit_range!(&mut self.flags, swift_nap_error, u32, u8, 2, 0); - } - - pub fn io_error(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 1, 0) { - 0 => Some(MsgHeartbeatIoError::SystemHealthy), - 1 => Some(MsgHeartbeatIoError::AnIoErrorHasOccurred), - _ => None, + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } - pub fn set_io_error(&mut self, io_error: MsgHeartbeatIoError) { - set_bit_range!(&mut self.flags, io_error, u32, u8, 1, 0); + impl TryFrom for MsgGroupMeta { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgGroupMeta(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - pub fn system_error_flag(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 0, 0) { - 0 => Some(MsgHeartbeatSystemErrorFlag::SystemHealthy), - 1 => Some(MsgHeartbeatSystemErrorFlag::AnErrorHasOccurred), - _ => None, + impl WireFormat for MsgGroupMeta { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.group_id) + + WireFormat::len(&self.flags) + + WireFormat::len(&self.n_group_msgs) + + WireFormat::len(&self.group_msgs) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } - pub fn set_system_error_flag(&mut self, system_error_flag: MsgHeartbeatSystemErrorFlag) { - set_bit_range!(&mut self.flags, system_error_flag, u32, u8, 0, 0); - } -} + /// Solution Group type + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum SolutionGroupType { + /// None (invalid) + None = 0, -impl ConcreteMessage for MsgHeartbeat { - const MESSAGE_TYPE: u16 = 65535; - const MESSAGE_NAME: &'static str = "MSG_HEARTBEAT"; -} + /// GNSS only + GnssOnly = 1, -impl SbpMessage for MsgHeartbeat { - 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); + /// GNSS+INS (Fuzed) + GnssINS = 2, } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } -} -impl TryFrom for MsgHeartbeat { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgHeartbeat(m) => Ok(m), - _ => Err(TryFromSbpError), + impl std::fmt::Display for SolutionGroupType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SolutionGroupType::None => f.write_str("None (invalid)"), + SolutionGroupType::GnssOnly => f.write_str("GNSS only"), + SolutionGroupType::GnssINS => f.write_str("GNSS+INS (Fuzed)"), + } } } } -impl WireFormat for MsgHeartbeat { - const MIN_LEN: usize = ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.flags, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgHeartbeat { - sender_id: None, - flags: WireFormat::parse_unchecked(buf), +pub mod msg_heartbeat { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// System heartbeat message + /// + /// The heartbeat message is sent periodically to inform the host or other + /// attached devices that the system is running. It is used to monitor system + /// malfunctions. It also contains status flags that indicate to the host the + /// status of the system and whether it is operating correctly. Currently, the + /// expected heartbeat interval is 1 sec. + /// + /// The system error flag is used to indicate that an error has occurred in + /// the system. To determine the source of the error, the remaining error + /// flags should be inspected. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgHeartbeat { + /// 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 { + pub fn external_antenna_present(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 31, 0) { + 0 => Some(ExternalAntennaPresent::NoExternalAntennaDetected), + 1 => Some(ExternalAntennaPresent::ExternalAntennaIsPresent), + _ => None, + } } - } -} - -/// External antenna present -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgHeartbeatExternalAntennaPresent { - /// No external antenna detected - NoExternalAntennaDetected = 0, - /// External antenna is present - ExternalAntennaIsPresent = 1, -} + pub fn set_external_antenna_present( + &mut self, + external_antenna_present: ExternalAntennaPresent, + ) { + set_bit_range!(&mut self.flags, external_antenna_present, u32, u8, 31, 0); + } -impl std::fmt::Display for MsgHeartbeatExternalAntennaPresent { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgHeartbeatExternalAntennaPresent::NoExternalAntennaDetected => { - f.write_str("No external antenna detected") - } - MsgHeartbeatExternalAntennaPresent::ExternalAntennaIsPresent => { - f.write_str("External antenna is present") + pub fn external_antenna_short(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 30, 0) { + 0 => Some(ExternalAntennaShort::NoShortDetected), + 1 => Some(ExternalAntennaShort::ShortDetected), + _ => None, } } - } -} -/// External antenna short -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgHeartbeatExternalAntennaShort { - /// No short detected - NoShortDetected = 0, + pub fn set_external_antenna_short(&mut self, external_antenna_short: ExternalAntennaShort) { + set_bit_range!(&mut self.flags, external_antenna_short, u32, u8, 30, 0); + } - /// Short detected - ShortDetected = 1, -} + pub fn sbp_major_protocol_version_number(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 23, 16) + } -impl std::fmt::Display for MsgHeartbeatExternalAntennaShort { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgHeartbeatExternalAntennaShort::NoShortDetected => f.write_str("No short detected"), - MsgHeartbeatExternalAntennaShort::ShortDetected => f.write_str("Short detected"), + pub fn set_sbp_major_protocol_version_number( + &mut self, + sbp_major_protocol_version_number: u8, + ) { + set_bit_range!( + &mut self.flags, + sbp_major_protocol_version_number, + u32, + u8, + 23, + 16 + ); } - } -} -/// SwiftNAP Error -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgHeartbeatSwiftNapError { - /// System Healthy - SystemHealthy = 0, + pub fn sbp_minor_protocol_version_number(&self) -> u8 { + get_bit_range!(self.flags, u32, u8, 15, 8) + } - /// An error has occurred in the SwiftNAP - AnErrorHasOccurredInTheSwiftNap = 1, -} + pub fn set_sbp_minor_protocol_version_number( + &mut self, + sbp_minor_protocol_version_number: u8, + ) { + set_bit_range!( + &mut self.flags, + sbp_minor_protocol_version_number, + u32, + u8, + 15, + 8 + ); + } -impl std::fmt::Display for MsgHeartbeatSwiftNapError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgHeartbeatSwiftNapError::SystemHealthy => f.write_str("System Healthy"), - MsgHeartbeatSwiftNapError::AnErrorHasOccurredInTheSwiftNap => { - f.write_str("An error has occurred in the SwiftNAP") + pub fn swift_nap_error(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 2, 0) { + 0 => Some(SwiftNapError::SystemHealthy), + 1 => Some(SwiftNapError::AnErrorHasOccurredInTheSwiftNap), + _ => None, } } - } -} - -/// IO Error -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgHeartbeatIoError { - /// System Healthy - SystemHealthy = 0, - - /// An IO error has occurred - AnIoErrorHasOccurred = 1, -} -impl std::fmt::Display for MsgHeartbeatIoError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgHeartbeatIoError::SystemHealthy => f.write_str("System Healthy"), - MsgHeartbeatIoError::AnIoErrorHasOccurred => f.write_str("An IO error has occurred"), + pub fn set_swift_nap_error(&mut self, swift_nap_error: SwiftNapError) { + set_bit_range!(&mut self.flags, swift_nap_error, u32, u8, 2, 0); } - } -} - -/// System Error Flag -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgHeartbeatSystemErrorFlag { - /// System Healthy - SystemHealthy = 0, - /// An error has occurred - AnErrorHasOccurred = 1, -} + pub fn io_error(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 1, 0) { + 0 => Some(IoError::SystemHealthy), + 1 => Some(IoError::AnIoErrorHasOccurred), + _ => None, + } + } -impl std::fmt::Display for MsgHeartbeatSystemErrorFlag { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgHeartbeatSystemErrorFlag::SystemHealthy => f.write_str("System Healthy"), - MsgHeartbeatSystemErrorFlag::AnErrorHasOccurred => f.write_str("An error has occurred"), + pub fn set_io_error(&mut self, io_error: IoError) { + set_bit_range!(&mut self.flags, io_error, u32, u8, 1, 0); } - } -} -/// Inertial Navigation System status message -/// -/// The INS status message describes the state of the operation and -/// initialization of the inertial navigation system. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgInsStatus { - /// 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, -} + pub fn system_error_flag(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 0, 0) { + 0 => Some(SystemErrorFlag::SystemHealthy), + 1 => Some(SystemErrorFlag::AnErrorHasOccurred), + _ => None, + } + } -impl MsgInsStatus { - pub fn ins_type(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 31, 29) { - 0 => Some(MsgInsStatusInsType::SmoothposeLooselyCoupled), - 1 => Some(MsgInsStatusInsType::Starling), - _ => None, + pub fn set_system_error_flag(&mut self, system_error_flag: SystemErrorFlag) { + set_bit_range!(&mut self.flags, system_error_flag, u32, u8, 0, 0); } } - pub fn set_ins_type(&mut self, ins_type: MsgInsStatusInsType) { - set_bit_range!(&mut self.flags, ins_type, u32, u8, 31, 29); + impl ConcreteMessage for MsgHeartbeat { + const MESSAGE_TYPE: u16 = 65535; + const MESSAGE_NAME: &'static str = "MSG_HEARTBEAT"; } - pub fn motion_state(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 13, 11) { - 0 => Some(MsgInsStatusMotionState::UnknownOrInit), - 1 => Some(MsgInsStatusMotionState::ArbitraryMotion), - 2 => Some(MsgInsStatusMotionState::StraightMotion), - 3 => Some(MsgInsStatusMotionState::Stationary), - _ => None, + impl SbpMessage for MsgHeartbeat { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } - pub fn set_motion_state(&mut self, motion_state: MsgInsStatusMotionState) { - set_bit_range!(&mut self.flags, motion_state, u32, u8, 13, 11); + impl TryFrom for MsgHeartbeat { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgHeartbeat(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - pub fn odometry_synch(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 10, 0) { - 0 => Some(MsgInsStatusOdometrySynch::OdometryTimestampNominal), - 1 => Some(MsgInsStatusOdometrySynch::OdometryTimestampOutOfBounds), - _ => None, + impl WireFormat for MsgHeartbeat { + const MIN_LEN: usize = ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgHeartbeat { + sender_id: None, + flags: WireFormat::parse_unchecked(buf), + } } } - pub fn set_odometry_synch(&mut self, odometry_synch: MsgInsStatusOdometrySynch) { - set_bit_range!(&mut self.flags, odometry_synch, u32, u8, 10, 0); + /// External antenna present + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum ExternalAntennaPresent { + /// No external antenna detected + NoExternalAntennaDetected = 0, + + /// External antenna is present + ExternalAntennaIsPresent = 1, } - pub fn odometry_status(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 9, 8) { - 0 => Some(MsgInsStatusOdometryStatus::NoOdometry), - 1 => Some(MsgInsStatusOdometryStatus::OdometryReceivedWithinLastSecond), - 2 => Some(MsgInsStatusOdometryStatus::OdometryNotReceivedWithinLastSecond), - _ => None, + impl std::fmt::Display for ExternalAntennaPresent { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ExternalAntennaPresent::NoExternalAntennaDetected => { + f.write_str("No external antenna detected") + } + ExternalAntennaPresent::ExternalAntennaIsPresent => { + f.write_str("External antenna is present") + } + } } } - pub fn set_odometry_status(&mut self, odometry_status: MsgInsStatusOdometryStatus) { - set_bit_range!(&mut self.flags, odometry_status, u32, u8, 9, 8); + /// External antenna short + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum ExternalAntennaShort { + /// No short detected + NoShortDetected = 0, + + /// Short detected + ShortDetected = 1, } - pub fn ins_error(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 7, 4) { - 1 => Some(MsgInsStatusInsError::ImuDataError), - 2 => Some(MsgInsStatusInsError::InsLicenseError), - 3 => Some(MsgInsStatusInsError::ImuCalibrationDataError), - _ => None, + impl std::fmt::Display for ExternalAntennaShort { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ExternalAntennaShort::NoShortDetected => f.write_str("No short detected"), + ExternalAntennaShort::ShortDetected => f.write_str("Short detected"), + } } } - pub fn set_ins_error(&mut self, ins_error: MsgInsStatusInsError) { - set_bit_range!(&mut self.flags, ins_error, u32, u8, 7, 4); + /// SwiftNAP Error + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum SwiftNapError { + /// System Healthy + SystemHealthy = 0, + + /// An error has occurred in the SwiftNAP + AnErrorHasOccurredInTheSwiftNap = 1, } - pub fn gnss_fix(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 3, 0) { - 0 => Some(MsgInsStatusGnssFix::NoGnssFixAvailable), - 1 => Some(MsgInsStatusGnssFix::GnssFix), - _ => None, + impl std::fmt::Display for SwiftNapError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SwiftNapError::SystemHealthy => f.write_str("System Healthy"), + SwiftNapError::AnErrorHasOccurredInTheSwiftNap => { + f.write_str("An error has occurred in the SwiftNAP") + } + } } } - pub fn set_gnss_fix(&mut self, gnss_fix: MsgInsStatusGnssFix) { - set_bit_range!(&mut self.flags, gnss_fix, u32, u8, 3, 0); - } + /// IO Error + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum IoError { + /// System Healthy + SystemHealthy = 0, - pub fn mode(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 2, 0) { - 0 => Some(MsgInsStatusMode::AwaitingInitialization), - 1 => Some(MsgInsStatusMode::DynamicallyAligning), - 2 => Some(MsgInsStatusMode::Ready), - 3 => Some(MsgInsStatusMode::GnssOutageExceedsMaxDuration), - 4 => Some(MsgInsStatusMode::FastStartSeeding), - 5 => Some(MsgInsStatusMode::FastStartValidating), - 6 => Some(MsgInsStatusMode::ValidatingUnsafeFastStartSeed), - _ => None, - } + /// An IO error has occurred + AnIoErrorHasOccurred = 1, } - pub fn set_mode(&mut self, mode: MsgInsStatusMode) { - set_bit_range!(&mut self.flags, mode, u32, u8, 2, 0); + impl std::fmt::Display for IoError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + IoError::SystemHealthy => f.write_str("System Healthy"), + IoError::AnIoErrorHasOccurred => f.write_str("An IO error has occurred"), + } + } } -} -impl ConcreteMessage for MsgInsStatus { - const MESSAGE_TYPE: u16 = 65283; - const MESSAGE_NAME: &'static str = "MSG_INS_STATUS"; -} + /// System Error Flag + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum SystemErrorFlag { + /// System Healthy + SystemHealthy = 0, -impl SbpMessage for MsgInsStatus { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + /// An error has occurred + AnErrorHasOccurred = 1, } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } -} -impl TryFrom for MsgInsStatus { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgInsStatus(m) => Ok(m), - _ => Err(TryFromSbpError), + impl std::fmt::Display for SystemErrorFlag { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SystemErrorFlag::SystemHealthy => f.write_str("System Healthy"), + SystemErrorFlag::AnErrorHasOccurred => f.write_str("An error has occurred"), + } } } } -impl WireFormat for MsgInsStatus { - const MIN_LEN: usize = ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.flags, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgInsStatus { - sender_id: None, - flags: WireFormat::parse_unchecked(buf), - } - } -} +pub mod msg_ins_status { + #![allow(unused_imports)] -/// INS Type -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgInsStatusInsType { - /// Smoothpose Loosely Coupled - SmoothposeLooselyCoupled = 0, + use super::*; + use crate::messages::lib::*; - /// Starling - Starling = 1, -} + /// Inertial Navigation System status message + /// + /// The INS status message describes the state of the operation and + /// initialization of the inertial navigation system. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgInsStatus { + /// 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 std::fmt::Display for MsgInsStatusInsType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgInsStatusInsType::SmoothposeLooselyCoupled => { - f.write_str("Smoothpose Loosely Coupled") + impl MsgInsStatus { + pub fn ins_type(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 31, 29) { + 0 => Some(InsType::SmoothposeLooselyCoupled), + 1 => Some(InsType::Starling), + _ => None, } - MsgInsStatusInsType::Starling => f.write_str("Starling"), } - } -} -/// Motion State -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgInsStatusMotionState { - /// Unknown or Init - UnknownOrInit = 0, + pub fn set_ins_type(&mut self, ins_type: InsType) { + set_bit_range!(&mut self.flags, ins_type, u32, u8, 31, 29); + } - /// Arbitrary Motion - ArbitraryMotion = 1, + pub fn motion_state(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 13, 11) { + 0 => Some(MotionState::UnknownOrInit), + 1 => Some(MotionState::ArbitraryMotion), + 2 => Some(MotionState::StraightMotion), + 3 => Some(MotionState::Stationary), + _ => None, + } + } - /// Straight Motion - StraightMotion = 2, + pub fn set_motion_state(&mut self, motion_state: MotionState) { + set_bit_range!(&mut self.flags, motion_state, u32, u8, 13, 11); + } - /// Stationary - Stationary = 3, -} + pub fn odometry_synch(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 10, 0) { + 0 => Some(OdometrySynch::OdometryTimestampNominal), + 1 => Some(OdometrySynch::OdometryTimestampOutOfBounds), + _ => None, + } + } -impl std::fmt::Display for MsgInsStatusMotionState { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgInsStatusMotionState::UnknownOrInit => f.write_str("Unknown or Init"), - MsgInsStatusMotionState::ArbitraryMotion => f.write_str("Arbitrary Motion"), - MsgInsStatusMotionState::StraightMotion => f.write_str("Straight Motion"), - MsgInsStatusMotionState::Stationary => f.write_str("Stationary"), + pub fn set_odometry_synch(&mut self, odometry_synch: OdometrySynch) { + set_bit_range!(&mut self.flags, odometry_synch, u32, u8, 10, 0); } - } -} -/// Odometry Synch -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgInsStatusOdometrySynch { - /// Odometry timestamp nominal - OdometryTimestampNominal = 0, + pub fn odometry_status(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 9, 8) { + 0 => Some(OdometryStatus::NoOdometry), + 1 => Some(OdometryStatus::OdometryReceivedWithinLastSecond), + 2 => Some(OdometryStatus::OdometryNotReceivedWithinLastSecond), + _ => None, + } + } - /// Odometry timestamp out of bounds - OdometryTimestampOutOfBounds = 1, -} + pub fn set_odometry_status(&mut self, odometry_status: OdometryStatus) { + set_bit_range!(&mut self.flags, odometry_status, u32, u8, 9, 8); + } -impl std::fmt::Display for MsgInsStatusOdometrySynch { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgInsStatusOdometrySynch::OdometryTimestampNominal => { - f.write_str("Odometry timestamp nominal") - } - MsgInsStatusOdometrySynch::OdometryTimestampOutOfBounds => { - f.write_str("Odometry timestamp out of bounds") + pub fn ins_error(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 7, 4) { + 1 => Some(InsError::ImuDataError), + 2 => Some(InsError::InsLicenseError), + 3 => Some(InsError::ImuCalibrationDataError), + _ => None, } } - } -} -/// Odometry status -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgInsStatusOdometryStatus { - /// No Odometry - NoOdometry = 0, + pub fn set_ins_error(&mut self, ins_error: InsError) { + set_bit_range!(&mut self.flags, ins_error, u32, u8, 7, 4); + } - /// Odometry received within last second - OdometryReceivedWithinLastSecond = 1, + pub fn gnss_fix(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 3, 0) { + 0 => Some(GnssFix::NoGnssFixAvailable), + 1 => Some(GnssFix::GnssFix), + _ => None, + } + } - /// Odometry not received within last second - OdometryNotReceivedWithinLastSecond = 2, -} + pub fn set_gnss_fix(&mut self, gnss_fix: GnssFix) { + set_bit_range!(&mut self.flags, gnss_fix, u32, u8, 3, 0); + } -impl std::fmt::Display for MsgInsStatusOdometryStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgInsStatusOdometryStatus::NoOdometry => f.write_str("No Odometry"), - MsgInsStatusOdometryStatus::OdometryReceivedWithinLastSecond => { - f.write_str("Odometry received within last second") - } - MsgInsStatusOdometryStatus::OdometryNotReceivedWithinLastSecond => { - f.write_str("Odometry not received within last second") + pub fn mode(&self) -> Option { + match get_bit_range!(self.flags, u32, u8, 2, 0) { + 0 => Some(Mode::AwaitingInitialization), + 1 => Some(Mode::DynamicallyAligning), + 2 => Some(Mode::Ready), + 3 => Some(Mode::GnssOutageExceedsMaxDuration), + 4 => Some(Mode::FastStartSeeding), + 5 => Some(Mode::FastStartValidating), + 6 => Some(Mode::ValidatingUnsafeFastStartSeed), + _ => None, } } - } -} -/// INS Error -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgInsStatusInsError { - /// IMU Data Error - ImuDataError = 1, + pub fn set_mode(&mut self, mode: Mode) { + set_bit_range!(&mut self.flags, mode, u32, u8, 2, 0); + } + } - /// INS License Error - InsLicenseError = 2, + impl ConcreteMessage for MsgInsStatus { + const MESSAGE_TYPE: u16 = 65283; + const MESSAGE_NAME: &'static str = "MSG_INS_STATUS"; + } - /// IMU Calibration Data Error - ImuCalibrationDataError = 3, -} + impl SbpMessage for MsgInsStatus { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + } -impl std::fmt::Display for MsgInsStatusInsError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgInsStatusInsError::ImuDataError => f.write_str("IMU Data Error"), - MsgInsStatusInsError::InsLicenseError => f.write_str("INS License Error"), - MsgInsStatusInsError::ImuCalibrationDataError => { - f.write_str("IMU Calibration Data Error") + impl TryFrom for MsgInsStatus { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgInsStatus(m) => Ok(m), + _ => Err(TryFromSbpError), } } } -} - -/// GNSS Fix -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgInsStatusGnssFix { - /// No GNSS fix available - NoGnssFixAvailable = 0, - - /// GNSS fix - GnssFix = 1, -} -impl std::fmt::Display for MsgInsStatusGnssFix { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgInsStatusGnssFix::NoGnssFixAvailable => f.write_str("No GNSS fix available"), - MsgInsStatusGnssFix::GnssFix => f.write_str("GNSS fix"), + impl WireFormat for MsgInsStatus { + const MIN_LEN: usize = ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgInsStatus { + sender_id: None, + flags: WireFormat::parse_unchecked(buf), + } } } -} - -/// Mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgInsStatusMode { - /// Awaiting initialization - AwaitingInitialization = 0, - - /// Dynamically aligning - DynamicallyAligning = 1, - - /// Ready - Ready = 2, - /// GNSS Outage exceeds max duration - GnssOutageExceedsMaxDuration = 3, + /// INS Type + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum InsType { + /// Smoothpose Loosely Coupled + SmoothposeLooselyCoupled = 0, - /// FastStart seeding - FastStartSeeding = 4, - - /// FastStart validating - FastStartValidating = 5, - - /// Validating unsafe fast start seed - ValidatingUnsafeFastStartSeed = 6, -} + /// Starling + Starling = 1, + } -impl std::fmt::Display for MsgInsStatusMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgInsStatusMode::AwaitingInitialization => f.write_str("Awaiting initialization"), - MsgInsStatusMode::DynamicallyAligning => f.write_str("Dynamically aligning"), - MsgInsStatusMode::Ready => f.write_str("Ready"), - MsgInsStatusMode::GnssOutageExceedsMaxDuration => { - f.write_str("GNSS Outage exceeds max duration") - } - MsgInsStatusMode::FastStartSeeding => f.write_str("FastStart seeding"), - MsgInsStatusMode::FastStartValidating => f.write_str("FastStart validating"), - MsgInsStatusMode::ValidatingUnsafeFastStartSeed => { - f.write_str("Validating unsafe fast start seed") + impl std::fmt::Display for InsType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + InsType::SmoothposeLooselyCoupled => f.write_str("Smoothpose Loosely Coupled"), + InsType::Starling => f.write_str("Starling"), } } } -} -/// Inertial Navigation System update status message -/// -/// The INS update status message contains information about executed and -/// rejected INS updates. This message is expected to be extended in the -/// future as new types of measurements are being added. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgInsUpdates { - /// 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, -} + /// Motion State + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum MotionState { + /// Unknown or Init + UnknownOrInit = 0, -impl MsgInsUpdates { - pub fn number_of_attempted_gnss_position_updates_since_last_message(&self) -> u8 { - get_bit_range!(self.gnsspos, u8, u8, 7, 4) - } - - pub fn set_number_of_attempted_gnss_position_updates_since_last_message( - &mut self, - number_of_attempted_gnss_position_updates_since_last_message: u8, - ) { - set_bit_range!( - &mut self.gnsspos, - number_of_attempted_gnss_position_updates_since_last_message, - u8, - u8, - 7, - 4 - ); - } - - pub fn number_of_rejected_gnss_position_updates_since_last_message(&self) -> u8 { - get_bit_range!(self.gnsspos, u8, u8, 3, 0) - } - - pub fn set_number_of_rejected_gnss_position_updates_since_last_message( - &mut self, - number_of_rejected_gnss_position_updates_since_last_message: u8, - ) { - set_bit_range!( - &mut self.gnsspos, - number_of_rejected_gnss_position_updates_since_last_message, - u8, - u8, - 3, - 0 - ); - } - - pub fn number_of_attempted_gnss_velocity_updates_since_last_message(&self) -> u8 { - get_bit_range!(self.gnssvel, u8, u8, 7, 4) - } - - pub fn set_number_of_attempted_gnss_velocity_updates_since_last_message( - &mut self, - number_of_attempted_gnss_velocity_updates_since_last_message: u8, - ) { - set_bit_range!( - &mut self.gnssvel, - number_of_attempted_gnss_velocity_updates_since_last_message, - u8, - u8, - 7, - 4 - ); - } - - pub fn number_of_rejected_gnss_velocity_updates_since_last_message(&self) -> u8 { - get_bit_range!(self.gnssvel, u8, u8, 3, 0) - } - - pub fn set_number_of_rejected_gnss_velocity_updates_since_last_message( - &mut self, - number_of_rejected_gnss_velocity_updates_since_last_message: u8, - ) { - set_bit_range!( - &mut self.gnssvel, - number_of_rejected_gnss_velocity_updates_since_last_message, - u8, - u8, - 3, - 0 - ); - } - - pub fn number_of_attempted_wheeltick_updates_since_last_message(&self) -> u8 { - get_bit_range!(self.wheelticks, u8, u8, 7, 4) - } - - pub fn set_number_of_attempted_wheeltick_updates_since_last_message( - &mut self, - number_of_attempted_wheeltick_updates_since_last_message: u8, - ) { - set_bit_range!( - &mut self.wheelticks, - number_of_attempted_wheeltick_updates_since_last_message, - u8, - u8, - 7, - 4 - ); - } - - pub fn number_of_rejected_wheeltick_updates_since_last_message(&self) -> u8 { - get_bit_range!(self.wheelticks, u8, u8, 3, 0) - } - - pub fn set_number_of_rejected_wheeltick_updates_since_last_message( - &mut self, - number_of_rejected_wheeltick_updates_since_last_message: u8, - ) { - set_bit_range!( - &mut self.wheelticks, - number_of_rejected_wheeltick_updates_since_last_message, - u8, - u8, - 3, - 0 - ); - } - - pub fn number_of_attempted_speed_updates_since_last_message(&self) -> u8 { - get_bit_range!(self.speed, u8, u8, 7, 4) - } - - pub fn set_number_of_attempted_speed_updates_since_last_message( - &mut self, - number_of_attempted_speed_updates_since_last_message: u8, - ) { - set_bit_range!( - &mut self.speed, - number_of_attempted_speed_updates_since_last_message, - u8, - u8, - 7, - 4 - ); - } - - pub fn number_of_rejected_speed_updates_since_last_message(&self) -> u8 { - get_bit_range!(self.speed, u8, u8, 3, 0) - } - - pub fn set_number_of_rejected_speed_updates_since_last_message( - &mut self, - number_of_rejected_speed_updates_since_last_message: u8, - ) { - set_bit_range!( - &mut self.speed, - number_of_rejected_speed_updates_since_last_message, - u8, - u8, - 3, - 0 - ); - } - - pub fn number_of_attempted_nhc_updates_since_last_message(&self) -> u8 { - get_bit_range!(self.nhc, u8, u8, 7, 4) - } - - pub fn set_number_of_attempted_nhc_updates_since_last_message( - &mut self, - number_of_attempted_nhc_updates_since_last_message: u8, - ) { - set_bit_range!( - &mut self.nhc, - number_of_attempted_nhc_updates_since_last_message, - u8, - u8, - 7, - 4 - ); - } - - pub fn number_of_rejected_nhc_updates_since_last_message(&self) -> u8 { - get_bit_range!(self.nhc, u8, u8, 3, 0) - } - - pub fn set_number_of_rejected_nhc_updates_since_last_message( - &mut self, - number_of_rejected_nhc_updates_since_last_message: u8, - ) { - set_bit_range!( - &mut self.nhc, - number_of_rejected_nhc_updates_since_last_message, - u8, - u8, - 3, - 0 - ); - } - - pub fn number_of_attempted_zero_velocity_updates_since_last_message(&self) -> u8 { - get_bit_range!(self.zerovel, u8, u8, 7, 4) - } - - pub fn set_number_of_attempted_zero_velocity_updates_since_last_message( - &mut self, - number_of_attempted_zero_velocity_updates_since_last_message: u8, - ) { - set_bit_range!( - &mut self.zerovel, - number_of_attempted_zero_velocity_updates_since_last_message, - u8, - u8, - 7, - 4 - ); - } - - pub fn number_of_rejected_zero_velocity_updates_since_last_message(&self) -> u8 { - get_bit_range!(self.zerovel, u8, u8, 3, 0) - } - - pub fn set_number_of_rejected_zero_velocity_updates_since_last_message( - &mut self, - number_of_rejected_zero_velocity_updates_since_last_message: u8, - ) { - set_bit_range!( - &mut self.zerovel, - number_of_rejected_zero_velocity_updates_since_last_message, - u8, - u8, - 3, - 0 - ); - } -} + /// Arbitrary Motion + ArbitraryMotion = 1, -impl ConcreteMessage for MsgInsUpdates { - const MESSAGE_TYPE: u16 = 65286; - const MESSAGE_NAME: &'static str = "MSG_INS_UPDATES"; -} + /// Straight Motion + StraightMotion = 2, -impl SbpMessage for MsgInsUpdates { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE + /// Stationary + Stationary = 3, } - fn sender_id(&self) -> Option { - self.sender_id - } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl std::fmt::Display for MotionState { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + MotionState::UnknownOrInit => f.write_str("Unknown or Init"), + MotionState::ArbitraryMotion => f.write_str("Arbitrary Motion"), + MotionState::StraightMotion => f.write_str("Straight Motion"), + MotionState::Stationary => f.write_str("Stationary"), + } + } } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + + /// Odometry Synch + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum OdometrySynch { + /// Odometry timestamp nominal + OdometryTimestampNominal = 0, + + /// Odometry timestamp out of bounds + OdometryTimestampOutOfBounds = 1, } -} -impl TryFrom for MsgInsUpdates { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgInsUpdates(m) => Ok(m), - _ => Err(TryFromSbpError), + impl std::fmt::Display for OdometrySynch { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + OdometrySynch::OdometryTimestampNominal => { + f.write_str("Odometry timestamp nominal") + } + OdometrySynch::OdometryTimestampOutOfBounds => { + f.write_str("Odometry timestamp out of bounds") + } + } } } -} -impl WireFormat for MsgInsUpdates { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) - + WireFormat::len(&self.gnsspos) - + WireFormat::len(&self.gnssvel) - + WireFormat::len(&self.wheelticks) - + WireFormat::len(&self.speed) - + WireFormat::len(&self.nhc) - + WireFormat::len(&self.zerovel) - } - fn write(&self, buf: &mut B) { - 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); + /// Odometry status + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum OdometryStatus { + /// No Odometry + NoOdometry = 0, + + /// Odometry received within last second + OdometryReceivedWithinLastSecond = 1, + + /// Odometry not received within last second + OdometryNotReceivedWithinLastSecond = 2, } - fn parse_unchecked(buf: &mut B) -> 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), + + impl std::fmt::Display for OdometryStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + OdometryStatus::NoOdometry => f.write_str("No Odometry"), + OdometryStatus::OdometryReceivedWithinLastSecond => { + f.write_str("Odometry received within last second") + } + OdometryStatus::OdometryNotReceivedWithinLastSecond => { + f.write_str("Odometry not received within last second") + } + } } } -} -/// Local time at detection of PPS pulse -/// -/// The PPS time message contains the value of the sender's local time in -/// microseconds at the moment a pulse is detected on the PPS input. This is -/// to be used for syncronisation of sensor data sampled with a local -/// timestamp (e.g. IMU or wheeltick messages) where GNSS time is unknown to -/// the sender. -/// -/// The local time used to timestamp the PPS pulse must be generated by the -/// same clock which is used to timestamp the IMU/wheel sensor data and should -/// follow the same roll-over rules. A separate MSG_PPS_TIME message should -/// be sent for each source of sensor data which uses PPS-relative -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgPpsTime { - /// 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, -} + /// INS Error + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum InsError { + /// IMU Data Error + ImuDataError = 1, -impl MsgPpsTime { - pub fn reserved_set_to_zero(&self) -> u8 { - get_bit_range!(self.flags, u8, u8, 7, 2) - } + /// INS License Error + InsLicenseError = 2, - pub fn set_reserved_set_to_zero(&mut self, reserved_set_to_zero: u8) { - set_bit_range!(&mut self.flags, reserved_set_to_zero, u8, u8, 7, 2); + /// IMU Calibration Data Error + ImuCalibrationDataError = 3, } - pub fn time_uncertainty(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 1, 0) { - 0 => Some(MsgPpsTimeTimeUncertainty::Unknown), - 1 => Some(MsgPpsTimeTimeUncertainty::_10Milliseconds), - 2 => Some(MsgPpsTimeTimeUncertainty::_10Microseconds), - 3 => Some(MsgPpsTimeTimeUncertainty::_1Microseconds), - _ => None, + impl std::fmt::Display for InsError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + InsError::ImuDataError => f.write_str("IMU Data Error"), + InsError::InsLicenseError => f.write_str("INS License Error"), + InsError::ImuCalibrationDataError => f.write_str("IMU Calibration Data Error"), + } } } - pub fn set_time_uncertainty(&mut self, time_uncertainty: MsgPpsTimeTimeUncertainty) { - set_bit_range!(&mut self.flags, time_uncertainty, u8, u8, 1, 0); + /// GNSS Fix + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum GnssFix { + /// No GNSS fix available + NoGnssFixAvailable = 0, + + /// GNSS fix + GnssFix = 1, } -} -impl ConcreteMessage for MsgPpsTime { - const MESSAGE_TYPE: u16 = 65288; - const MESSAGE_NAME: &'static str = "MSG_PPS_TIME"; -} + impl std::fmt::Display for GnssFix { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + GnssFix::NoGnssFixAvailable => f.write_str("No GNSS fix available"), + GnssFix::GnssFix => f.write_str("GNSS fix"), + } + } + } -impl SbpMessage for MsgPpsTime { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME + /// Mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum Mode { + /// Awaiting initialization + AwaitingInitialization = 0, + + /// Dynamically aligning + DynamicallyAligning = 1, + + /// Ready + Ready = 2, + + /// GNSS Outage exceeds max duration + GnssOutageExceedsMaxDuration = 3, + + /// FastStart seeding + FastStartSeeding = 4, + + /// FastStart validating + FastStartValidating = 5, + + /// Validating unsafe fast start seed + ValidatingUnsafeFastStartSeed = 6, } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE + + impl std::fmt::Display for Mode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Mode::AwaitingInitialization => f.write_str("Awaiting initialization"), + Mode::DynamicallyAligning => f.write_str("Dynamically aligning"), + Mode::Ready => f.write_str("Ready"), + Mode::GnssOutageExceedsMaxDuration => { + f.write_str("GNSS Outage exceeds max duration") + } + Mode::FastStartSeeding => f.write_str("FastStart seeding"), + Mode::FastStartValidating => f.write_str("FastStart validating"), + Mode::ValidatingUnsafeFastStartSeed => { + f.write_str("Validating unsafe fast start seed") + } + } + } } - fn sender_id(&self) -> Option { - self.sender_id +} + +pub mod msg_ins_updates { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Inertial Navigation System update status message + /// + /// The INS update status message contains information about executed and + /// rejected INS updates. This message is expected to be extended in the + /// future as new types of measurements are being added. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgInsUpdates { + /// 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 { + pub fn number_of_attempted_gnss_position_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.gnsspos, u8, u8, 7, 4) + } + + pub fn set_number_of_attempted_gnss_position_updates_since_last_message( + &mut self, + number_of_attempted_gnss_position_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.gnsspos, + number_of_attempted_gnss_position_updates_since_last_message, + u8, + u8, + 7, + 4 + ); + } + + pub fn number_of_rejected_gnss_position_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.gnsspos, u8, u8, 3, 0) + } + + pub fn set_number_of_rejected_gnss_position_updates_since_last_message( + &mut self, + number_of_rejected_gnss_position_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.gnsspos, + number_of_rejected_gnss_position_updates_since_last_message, + u8, + u8, + 3, + 0 + ); + } + + pub fn number_of_attempted_gnss_velocity_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.gnssvel, u8, u8, 7, 4) + } + + pub fn set_number_of_attempted_gnss_velocity_updates_since_last_message( + &mut self, + number_of_attempted_gnss_velocity_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.gnssvel, + number_of_attempted_gnss_velocity_updates_since_last_message, + u8, + u8, + 7, + 4 + ); + } + + pub fn number_of_rejected_gnss_velocity_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.gnssvel, u8, u8, 3, 0) + } + + pub fn set_number_of_rejected_gnss_velocity_updates_since_last_message( + &mut self, + number_of_rejected_gnss_velocity_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.gnssvel, + number_of_rejected_gnss_velocity_updates_since_last_message, + u8, + u8, + 3, + 0 + ); + } + + pub fn number_of_attempted_wheeltick_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.wheelticks, u8, u8, 7, 4) + } + + pub fn set_number_of_attempted_wheeltick_updates_since_last_message( + &mut self, + number_of_attempted_wheeltick_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.wheelticks, + number_of_attempted_wheeltick_updates_since_last_message, + u8, + u8, + 7, + 4 + ); + } + + pub fn number_of_rejected_wheeltick_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.wheelticks, u8, u8, 3, 0) + } + + pub fn set_number_of_rejected_wheeltick_updates_since_last_message( + &mut self, + number_of_rejected_wheeltick_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.wheelticks, + number_of_rejected_wheeltick_updates_since_last_message, + u8, + u8, + 3, + 0 + ); + } + + pub fn number_of_attempted_speed_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.speed, u8, u8, 7, 4) + } + + pub fn set_number_of_attempted_speed_updates_since_last_message( + &mut self, + number_of_attempted_speed_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.speed, + number_of_attempted_speed_updates_since_last_message, + u8, + u8, + 7, + 4 + ); + } + + pub fn number_of_rejected_speed_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.speed, u8, u8, 3, 0) + } + + pub fn set_number_of_rejected_speed_updates_since_last_message( + &mut self, + number_of_rejected_speed_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.speed, + number_of_rejected_speed_updates_since_last_message, + u8, + u8, + 3, + 0 + ); + } + + pub fn number_of_attempted_nhc_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.nhc, u8, u8, 7, 4) + } + + pub fn set_number_of_attempted_nhc_updates_since_last_message( + &mut self, + number_of_attempted_nhc_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.nhc, + number_of_attempted_nhc_updates_since_last_message, + u8, + u8, + 7, + 4 + ); + } + + pub fn number_of_rejected_nhc_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.nhc, u8, u8, 3, 0) + } + + pub fn set_number_of_rejected_nhc_updates_since_last_message( + &mut self, + number_of_rejected_nhc_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.nhc, + number_of_rejected_nhc_updates_since_last_message, + u8, + u8, + 3, + 0 + ); + } + + pub fn number_of_attempted_zero_velocity_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.zerovel, u8, u8, 7, 4) + } + + pub fn set_number_of_attempted_zero_velocity_updates_since_last_message( + &mut self, + number_of_attempted_zero_velocity_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.zerovel, + number_of_attempted_zero_velocity_updates_since_last_message, + u8, + u8, + 7, + 4 + ); + } + + pub fn number_of_rejected_zero_velocity_updates_since_last_message(&self) -> u8 { + get_bit_range!(self.zerovel, u8, u8, 3, 0) + } + + pub fn set_number_of_rejected_zero_velocity_updates_since_last_message( + &mut self, + number_of_rejected_zero_velocity_updates_since_last_message: u8, + ) { + set_bit_range!( + &mut self.zerovel, + number_of_rejected_zero_velocity_updates_since_last_message, + u8, + u8, + 3, + 0 + ); + } + } + + impl ConcreteMessage for MsgInsUpdates { + const MESSAGE_TYPE: u16 = 65286; + const MESSAGE_NAME: &'static str = "MSG_INS_UPDATES"; } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); + + impl SbpMessage for MsgInsUpdates { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } + } + + impl TryFrom for MsgInsUpdates { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgInsUpdates(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl WireFormat for MsgInsUpdates { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.gnsspos) + + WireFormat::len(&self.gnssvel) + + WireFormat::len(&self.wheelticks) + + WireFormat::len(&self.speed) + + WireFormat::len(&self.nhc) + + WireFormat::len(&self.zerovel) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } + } } } -impl TryFrom for MsgPpsTime { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgPpsTime(m) => Ok(m), - _ => Err(TryFromSbpError), +pub mod msg_pps_time { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Local time at detection of PPS pulse + /// + /// The PPS time message contains the value of the sender's local time in + /// microseconds at the moment a pulse is detected on the PPS input. This is + /// to be used for syncronisation of sensor data sampled with a local + /// timestamp (e.g. IMU or wheeltick messages) where GNSS time is unknown to + /// the sender. + /// + /// The local time used to timestamp the PPS pulse must be generated by the + /// same clock which is used to timestamp the IMU/wheel sensor data and should + /// follow the same roll-over rules. A separate MSG_PPS_TIME message should + /// be sent for each source of sensor data which uses PPS-relative + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgPpsTime { + /// 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 { + pub fn reserved_set_to_zero(&self) -> u8 { + get_bit_range!(self.flags, u8, u8, 7, 2) + } + + pub fn set_reserved_set_to_zero(&mut self, reserved_set_to_zero: u8) { + set_bit_range!(&mut self.flags, reserved_set_to_zero, u8, u8, 7, 2); + } + + pub fn time_uncertainty(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 1, 0) { + 0 => Some(TimeUncertainty::Unknown), + 1 => Some(TimeUncertainty::_10Milliseconds), + 2 => Some(TimeUncertainty::_10Microseconds), + 3 => Some(TimeUncertainty::_1Microseconds), + _ => None, + } + } + + pub fn set_time_uncertainty(&mut self, time_uncertainty: TimeUncertainty) { + set_bit_range!(&mut self.flags, time_uncertainty, u8, u8, 1, 0); } } -} -impl WireFormat for MsgPpsTime { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.time) + WireFormat::len(&self.flags) + impl ConcreteMessage for MsgPpsTime { + const MESSAGE_TYPE: u16 = 65288; + const MESSAGE_NAME: &'static str = "MSG_PPS_TIME"; } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.time, buf); - WireFormat::write(&self.flags, buf); + + impl SbpMessage for MsgPpsTime { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgPpsTime { - sender_id: None, - time: WireFormat::parse_unchecked(buf), - flags: WireFormat::parse_unchecked(buf), + + impl TryFrom for MsgPpsTime { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgPpsTime(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } + } + + impl WireFormat for MsgPpsTime { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.time) + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.time, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgPpsTime { + sender_id: None, + time: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } -} /// Sensor state and update status data /// @@ -1671,465 +1742,490 @@ impl WireFormat for MsgSensorAidEvent { } } -/// System start-up message -/// -/// The system start-up message is sent once on system start-up. It notifies -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgStartup { - /// 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, -} +pub mod msg_startup { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// System start-up message + /// + /// The system start-up message is sent once on system start-up. It notifies + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgStartup { + /// 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 { + pub fn cause_of_startup(&self) -> Option { + match get_bit_range!(self.cause, u8, u8, 8, 0) { + 0 => Some(CauseOfStartup::PowerOn), + 1 => Some(CauseOfStartup::SoftwareReset), + 2 => Some(CauseOfStartup::WatchdogReset), + _ => None, + } + } -impl MsgStartup { - pub fn cause_of_startup(&self) -> Option { - match get_bit_range!(self.cause, u8, u8, 8, 0) { - 0 => Some(MsgStartupCauseOfStartup::PowerOn), - 1 => Some(MsgStartupCauseOfStartup::SoftwareReset), - 2 => Some(MsgStartupCauseOfStartup::WatchdogReset), - _ => None, + pub fn set_cause_of_startup(&mut self, cause_of_startup: CauseOfStartup) { + set_bit_range!(&mut self.cause, cause_of_startup, u8, u8, 8, 0); } - } - pub fn set_cause_of_startup(&mut self, cause_of_startup: MsgStartupCauseOfStartup) { - set_bit_range!(&mut self.cause, cause_of_startup, u8, u8, 8, 0); - } + pub fn startup_type(&self) -> Option { + match get_bit_range!(self.startup_type, u8, u8, 8, 0) { + 0 => Some(StartupType::ColdStart), + 1 => Some(StartupType::WarmStart), + 2 => Some(StartupType::HotStart), + _ => None, + } + } - pub fn startup_type(&self) -> Option { - match get_bit_range!(self.startup_type, u8, u8, 8, 0) { - 0 => Some(MsgStartupStartupType::ColdStart), - 1 => Some(MsgStartupStartupType::WarmStart), - 2 => Some(MsgStartupStartupType::HotStart), - _ => None, + pub fn set_startup_type(&mut self, startup_type: StartupType) { + set_bit_range!(&mut self.startup_type, startup_type, u8, u8, 8, 0); } } - pub fn set_startup_type(&mut self, startup_type: MsgStartupStartupType) { - set_bit_range!(&mut self.startup_type, startup_type, u8, u8, 8, 0); + impl ConcreteMessage for MsgStartup { + const MESSAGE_TYPE: u16 = 65280; + const MESSAGE_NAME: &'static str = "MSG_STARTUP"; } -} - -impl ConcreteMessage for MsgStartup { - const MESSAGE_TYPE: u16 = 65280; - const MESSAGE_NAME: &'static str = "MSG_STARTUP"; -} -impl SbpMessage for MsgStartup { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgStartup { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgStartup { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgStartup(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgStartup { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgStartup(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgStartup { - const MIN_LEN: usize = - ::MIN_LEN + ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.cause) - + WireFormat::len(&self.startup_type) - + WireFormat::len(&self.reserved) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.cause, buf); - WireFormat::write(&self.startup_type, buf); - WireFormat::write(&self.reserved, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgStartup { - sender_id: None, - cause: WireFormat::parse_unchecked(buf), - startup_type: WireFormat::parse_unchecked(buf), - reserved: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgStartup { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.cause) + + WireFormat::len(&self.startup_type) + + WireFormat::len(&self.reserved) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.cause, buf); + WireFormat::write(&self.startup_type, buf); + WireFormat::write(&self.reserved, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgStartup { + sender_id: None, + cause: WireFormat::parse_unchecked(buf), + startup_type: WireFormat::parse_unchecked(buf), + reserved: WireFormat::parse_unchecked(buf), + } } } -} -/// Cause of startup -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgStartupCauseOfStartup { - /// Power on - PowerOn = 0, + /// Cause of startup + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum CauseOfStartup { + /// Power on + PowerOn = 0, - /// Software reset - SoftwareReset = 1, + /// Software reset + SoftwareReset = 1, - /// Watchdog reset - WatchdogReset = 2, -} + /// Watchdog reset + WatchdogReset = 2, + } -impl std::fmt::Display for MsgStartupCauseOfStartup { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgStartupCauseOfStartup::PowerOn => f.write_str("Power on"), - MsgStartupCauseOfStartup::SoftwareReset => f.write_str("Software reset"), - MsgStartupCauseOfStartup::WatchdogReset => f.write_str("Watchdog reset"), + impl std::fmt::Display for CauseOfStartup { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + CauseOfStartup::PowerOn => f.write_str("Power on"), + CauseOfStartup::SoftwareReset => f.write_str("Software reset"), + CauseOfStartup::WatchdogReset => f.write_str("Watchdog reset"), + } } } -} -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgStartupStartupType { - /// Cold start - ColdStart = 0, + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum StartupType { + /// Cold start + ColdStart = 0, - /// Warm start - WarmStart = 1, + /// Warm start + WarmStart = 1, - /// Hot start - HotStart = 2, -} + /// Hot start + HotStart = 2, + } -impl std::fmt::Display for MsgStartupStartupType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgStartupStartupType::ColdStart => f.write_str("Cold start"), - MsgStartupStartupType::WarmStart => f.write_str("Warm start"), - MsgStartupStartupType::HotStart => f.write_str("Hot start"), + impl std::fmt::Display for StartupType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + StartupType::ColdStart => f.write_str("Cold start"), + StartupType::WarmStart => f.write_str("Warm start"), + StartupType::HotStart => f.write_str("Hot start"), + } } } } -/// Status report message -/// -/// The status report is sent periodically to inform the host or other -/// attached devices that the system is running. It is used to monitor system -/// malfunctions. It contains status reports that indicate to the host the -/// status of each sub-system and whether it is operating correctly. -/// -/// Interpretation of the subsystem specific status code is product dependent, -/// but if the generic status code is initializing, it should be ignored. -/// Refer to product documentation for details. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgStatusReport { - /// 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, -} +pub mod msg_status_report { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Status report message + /// + /// The status report is sent periodically to inform the host or other + /// attached devices that the system is running. It is used to monitor system + /// malfunctions. It contains status reports that indicate to the host the + /// status of each sub-system and whether it is operating correctly. + /// + /// Interpretation of the subsystem specific status code is product dependent, + /// but if the generic status code is initializing, it should be ignored. + /// Refer to product documentation for details. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgStatusReport { + /// 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 { + pub fn system(&self) -> Option { + match get_bit_range!(self.reporting_system, u16, u16, 15, 0) { + 0 => Some(System::Starling), + 1 => Some(System::PrecisionGnssModule), + _ => None, + } + } -impl MsgStatusReport { - pub fn system(&self) -> Option { - match get_bit_range!(self.reporting_system, u16, u16, 15, 0) { - 0 => Some(MsgStatusReportSystem::Starling), - 1 => Some(MsgStatusReportSystem::PrecisionGnssModule), - _ => None, + pub fn set_system(&mut self, system: System) { + set_bit_range!(&mut self.reporting_system, system, u16, u16, 15, 0); } - } - pub fn set_system(&mut self, system: MsgStatusReportSystem) { - set_bit_range!(&mut self.reporting_system, system, u16, u16, 15, 0); - } + pub fn sbp_major_protocol_version_number(&self) -> u8 { + get_bit_range!(self.sbp_version, u16, u8, 16, 8) + } - pub fn sbp_major_protocol_version_number(&self) -> u8 { - get_bit_range!(self.sbp_version, u16, u8, 16, 8) - } + pub fn set_sbp_major_protocol_version_number( + &mut self, + sbp_major_protocol_version_number: u8, + ) { + set_bit_range!( + &mut self.sbp_version, + sbp_major_protocol_version_number, + u16, + u8, + 16, + 8 + ); + } - pub fn set_sbp_major_protocol_version_number(&mut self, sbp_major_protocol_version_number: u8) { - set_bit_range!( - &mut self.sbp_version, - sbp_major_protocol_version_number, - u16, - u8, - 16, - 8 - ); - } + pub fn sbp_minor_protocol_version_number(&self) -> u8 { + get_bit_range!(self.sbp_version, u16, u8, 7, 0) + } - pub fn sbp_minor_protocol_version_number(&self) -> u8 { - get_bit_range!(self.sbp_version, u16, u8, 7, 0) + pub fn set_sbp_minor_protocol_version_number( + &mut self, + sbp_minor_protocol_version_number: u8, + ) { + set_bit_range!( + &mut self.sbp_version, + sbp_minor_protocol_version_number, + u16, + u8, + 7, + 0 + ); + } } - pub fn set_sbp_minor_protocol_version_number(&mut self, sbp_minor_protocol_version_number: u8) { - set_bit_range!( - &mut self.sbp_version, - sbp_minor_protocol_version_number, - u16, - u8, - 7, - 0 - ); + impl ConcreteMessage for MsgStatusReport { + const MESSAGE_TYPE: u16 = 65534; + const MESSAGE_NAME: &'static str = "MSG_STATUS_REPORT"; } -} -impl ConcreteMessage for MsgStatusReport { - const MESSAGE_TYPE: u16 = 65534; - const MESSAGE_NAME: &'static str = "MSG_STATUS_REPORT"; -} - -impl SbpMessage for MsgStatusReport { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgStatusReport { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgStatusReport { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgStatusReport(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgStatusReport { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgStatusReport(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgStatusReport { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.reporting_system) - + WireFormat::len(&self.sbp_version) - + WireFormat::len(&self.sequence) - + WireFormat::len(&self.uptime) - + WireFormat::len(&self.status) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgStatusReport { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.reporting_system) + + WireFormat::len(&self.sbp_version) + + WireFormat::len(&self.sequence) + + WireFormat::len(&self.uptime) + + WireFormat::len(&self.status) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// System -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgStatusReportSystem { - /// Starling - Starling = 0, + /// System + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum System { + /// Starling + Starling = 0, - /// Precision GNSS Module (PGM) - PrecisionGnssModule = 1, -} + /// Precision GNSS Module (PGM) + PrecisionGnssModule = 1, + } -impl std::fmt::Display for MsgStatusReportSystem { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgStatusReportSystem::Starling => f.write_str("Starling"), - MsgStatusReportSystem::PrecisionGnssModule => { - f.write_str("Precision GNSS Module (PGM)") + impl std::fmt::Display for System { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + System::Starling => f.write_str("Starling"), + System::PrecisionGnssModule => f.write_str("Precision GNSS Module (PGM)"), } } } } -/// Sub-system Status report -/// -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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 { - pub fn subsystem(&self) -> Option { - match get_bit_range!(self.component, u16, u16, 15, 0) { - 0 => Some(SubSystemReportSubsystem::PrimaryGnssAntenna), - 1 => Some(SubSystemReportSubsystem::MeasurementEngine), - 2 => Some(SubSystemReportSubsystem::CorrectionsClient), - 3 => Some(SubSystemReportSubsystem::DifferentialGnssEngine), - 4 => Some(SubSystemReportSubsystem::CAN), - 5 => Some(SubSystemReportSubsystem::WheelOdometry), - 6 => Some(SubSystemReportSubsystem::SensorFusionEngine), - _ => None, +pub mod sub_system_report { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Sub-system Status report + /// + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 { + pub fn subsystem(&self) -> Option { + match get_bit_range!(self.component, u16, u16, 15, 0) { + 0 => Some(Subsystem::PrimaryGnssAntenna), + 1 => Some(Subsystem::MeasurementEngine), + 2 => Some(Subsystem::CorrectionsClient), + 3 => Some(Subsystem::DifferentialGnssEngine), + 4 => Some(Subsystem::CAN), + 5 => Some(Subsystem::WheelOdometry), + 6 => Some(Subsystem::SensorFusionEngine), + _ => None, + } } - } - pub fn set_subsystem(&mut self, subsystem: SubSystemReportSubsystem) { - set_bit_range!(&mut self.component, subsystem, u16, u16, 15, 0); - } + pub fn set_subsystem(&mut self, subsystem: Subsystem) { + set_bit_range!(&mut self.component, subsystem, u16, u16, 15, 0); + } - pub fn generic(&self) -> Option { - match get_bit_range!(self.generic, u8, u8, 7, 0) { - 0 => Some(SubSystemReportGeneric::OKNominal), - 1 => Some(SubSystemReportGeneric::Initializing), - 2 => Some(SubSystemReportGeneric::Unknown), - 3 => Some(SubSystemReportGeneric::Degraded), - 4 => Some(SubSystemReportGeneric::Unusable), - _ => None, + pub fn generic(&self) -> Option { + match get_bit_range!(self.generic, u8, u8, 7, 0) { + 0 => Some(Generic::OKNominal), + 1 => Some(Generic::Initializing), + 2 => Some(Generic::Unknown), + 3 => Some(Generic::Degraded), + 4 => Some(Generic::Unusable), + _ => None, + } } - } - pub fn set_generic(&mut self, generic: SubSystemReportGeneric) { - set_bit_range!(&mut self.generic, generic, u8, u8, 7, 0); + pub fn set_generic(&mut self, generic: Generic) { + set_bit_range!(&mut self.generic, generic, u8, u8, 7, 0); + } } -} -impl WireFormat for SubSystemReport { - const MIN_LEN: usize = - ::MIN_LEN + ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.component) - + WireFormat::len(&self.generic) - + WireFormat::len(&self.specific) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.component, buf); - WireFormat::write(&self.generic, buf); - WireFormat::write(&self.specific, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - SubSystemReport { - component: WireFormat::parse_unchecked(buf), - generic: WireFormat::parse_unchecked(buf), - specific: WireFormat::parse_unchecked(buf), + impl WireFormat for SubSystemReport { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.component) + + WireFormat::len(&self.generic) + + WireFormat::len(&self.specific) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.component, buf); + WireFormat::write(&self.generic, buf); + WireFormat::write(&self.specific, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + SubSystemReport { + component: WireFormat::parse_unchecked(buf), + generic: WireFormat::parse_unchecked(buf), + specific: WireFormat::parse_unchecked(buf), + } } } -} -/// Subsystem -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum SubSystemReportSubsystem { - /// Primary GNSS Antenna - PrimaryGnssAntenna = 0, + /// Subsystem + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum Subsystem { + /// Primary GNSS Antenna + PrimaryGnssAntenna = 0, - /// Measurement Engine - MeasurementEngine = 1, + /// Measurement Engine + MeasurementEngine = 1, - /// Corrections Client - CorrectionsClient = 2, + /// Corrections Client + CorrectionsClient = 2, - /// Differential GNSS Engine - DifferentialGnssEngine = 3, + /// Differential GNSS Engine + DifferentialGnssEngine = 3, - /// CAN - CAN = 4, + /// CAN + CAN = 4, - /// Wheel Odometry - WheelOdometry = 5, + /// Wheel Odometry + WheelOdometry = 5, - /// Sensor Fusion Engine - SensorFusionEngine = 6, -} + /// Sensor Fusion Engine + SensorFusionEngine = 6, + } -impl std::fmt::Display for SubSystemReportSubsystem { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - SubSystemReportSubsystem::PrimaryGnssAntenna => f.write_str("Primary GNSS Antenna"), - SubSystemReportSubsystem::MeasurementEngine => f.write_str("Measurement Engine"), - SubSystemReportSubsystem::CorrectionsClient => f.write_str("Corrections Client"), - SubSystemReportSubsystem::DifferentialGnssEngine => { - f.write_str("Differential GNSS Engine") + impl std::fmt::Display for Subsystem { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Subsystem::PrimaryGnssAntenna => f.write_str("Primary GNSS Antenna"), + Subsystem::MeasurementEngine => f.write_str("Measurement Engine"), + Subsystem::CorrectionsClient => f.write_str("Corrections Client"), + Subsystem::DifferentialGnssEngine => f.write_str("Differential GNSS Engine"), + Subsystem::CAN => f.write_str("CAN"), + Subsystem::WheelOdometry => f.write_str("Wheel Odometry"), + Subsystem::SensorFusionEngine => f.write_str("Sensor Fusion Engine"), } - SubSystemReportSubsystem::CAN => f.write_str("CAN"), - SubSystemReportSubsystem::WheelOdometry => f.write_str("Wheel Odometry"), - SubSystemReportSubsystem::SensorFusionEngine => f.write_str("Sensor Fusion Engine"), } } -} -/// Generic -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum SubSystemReportGeneric { - /// OK/Nominal - OKNominal = 0, + /// Generic + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum Generic { + /// OK/Nominal + OKNominal = 0, - /// Initializing - Initializing = 1, + /// Initializing + Initializing = 1, - /// Unknown - Unknown = 2, + /// Unknown + Unknown = 2, - /// Degraded - Degraded = 3, + /// Degraded + Degraded = 3, - /// Unusable - Unusable = 4, -} + /// Unusable + Unusable = 4, + } -impl std::fmt::Display for SubSystemReportGeneric { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - SubSystemReportGeneric::OKNominal => f.write_str("OK/Nominal"), - SubSystemReportGeneric::Initializing => f.write_str("Initializing"), - SubSystemReportGeneric::Unknown => f.write_str("Unknown"), - SubSystemReportGeneric::Degraded => f.write_str("Degraded"), - SubSystemReportGeneric::Unusable => f.write_str("Unusable"), + impl std::fmt::Display for Generic { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Generic::OKNominal => f.write_str("OK/Nominal"), + Generic::Initializing => f.write_str("Initializing"), + Generic::Unknown => f.write_str("Unknown"), + Generic::Degraded => f.write_str("Degraded"), + Generic::Unusable => f.write_str("Unusable"), + } } } } diff --git a/rust/sbp/src/messages/tracking.rs b/rust/sbp/src/messages/tracking.rs index f398e41d06..f6229b84e1 100644 --- a/rust/sbp/src/messages/tracking.rs +++ b/rust/sbp/src/messages/tracking.rs @@ -13,2522 +13,2545 @@ // with generate.py. Please do not hand edit! //****************************************************************************/ //! Satellite code and carrier-phase tracking messages from the device. - -use super::gnss::*; - -use super::lib::*; - -/// Measurement Engine signal tracking channel states -/// -/// The tracking message returns a variable-length array of tracking channel -/// states. It reports status and carrier-to-noise density measurements for -/// all tracked satellites. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgMeasurementState { - /// 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 ConcreteMessage for MsgMeasurementState { - const MESSAGE_TYPE: u16 = 97; - const MESSAGE_NAME: &'static str = "MSG_MEASUREMENT_STATE"; -} - -impl SbpMessage for MsgMeasurementState { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } -} - -impl TryFrom for MsgMeasurementState { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgMeasurementState(m) => Ok(m), - _ => Err(TryFromSbpError), +pub use measurement_state::MeasurementState; +pub use msg_measurement_state::MsgMeasurementState; +pub use msg_tracking_iq::MsgTrackingIq; +pub use msg_tracking_iq_dep_a::MsgTrackingIqDepA; +pub use msg_tracking_iq_dep_b::MsgTrackingIqDepB; +pub use msg_tracking_state::MsgTrackingState; +pub use msg_tracking_state_dep_a::MsgTrackingStateDepA; +pub use msg_tracking_state_dep_b::MsgTrackingStateDepB; +pub use msg_tracking_state_detailed_dep::MsgTrackingStateDetailedDep; +pub use msg_tracking_state_detailed_dep_a::MsgTrackingStateDetailedDepA; +pub use tracking_channel_correlation::TrackingChannelCorrelation; +pub use tracking_channel_correlation_dep::TrackingChannelCorrelationDep; +pub use tracking_channel_state::TrackingChannelState; +pub use tracking_channel_state_dep_a::TrackingChannelStateDepA; +pub use tracking_channel_state_dep_b::TrackingChannelStateDepB; + +pub mod msg_measurement_state { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Measurement Engine signal tracking channel states + /// + /// The tracking message returns a variable-length array of tracking channel + /// states. It reports status and carrier-to-noise density measurements for + /// all tracked satellites. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgMeasurementState { + /// 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 ConcreteMessage for MsgMeasurementState { + const MESSAGE_TYPE: u16 = 97; + const MESSAGE_NAME: &'static str = "MSG_MEASUREMENT_STATE"; + } + + impl SbpMessage for MsgMeasurementState { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + } + + impl TryFrom for MsgMeasurementState { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgMeasurementState(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgMeasurementState { - const MIN_LEN: usize = as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.states) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.states, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgMeasurementState { - sender_id: None, - states: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgMeasurementState { + const MIN_LEN: usize = as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.states) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.states, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgMeasurementState { + sender_id: None, + states: WireFormat::parse_unchecked(buf), + } } } } -/// Tracking channel correlations -/// -/// When enabled, a tracking channel can output the correlations at each -/// update interval. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgTrackingIq { - /// 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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "corrs")))] - pub corrs: [TrackingChannelCorrelation; 3], -} +pub mod msg_tracking_iq { + #![allow(unused_imports)] -impl ConcreteMessage for MsgTrackingIq { - const MESSAGE_TYPE: u16 = 45; - const MESSAGE_NAME: &'static str = "MSG_TRACKING_IQ"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgTrackingIq { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + /// Tracking channel correlations + /// + /// When enabled, a tracking channel can output the correlations at each + /// update interval. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgTrackingIq { + /// 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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "corrs")))] + pub corrs: [TrackingChannelCorrelation; 3], } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } -} -impl TryFrom for MsgTrackingIq { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgTrackingIq(m) => Ok(m), - _ => Err(TryFromSbpError), - } + impl ConcreteMessage for MsgTrackingIq { + const MESSAGE_TYPE: u16 = 45; + const MESSAGE_NAME: &'static str = "MSG_TRACKING_IQ"; } -} -impl WireFormat for MsgTrackingIq { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + <[TrackingChannelCorrelation; 3] as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.channel) + WireFormat::len(&self.sid) + WireFormat::len(&self.corrs) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.channel, buf); - WireFormat::write(&self.sid, buf); - WireFormat::write(&self.corrs, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgTrackingIq { - sender_id: None, - channel: WireFormat::parse_unchecked(buf), - sid: WireFormat::parse_unchecked(buf), - corrs: WireFormat::parse_unchecked(buf), + impl SbpMessage for MsgTrackingIq { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} - -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgTrackingIqDepA { - /// 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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "corrs")))] - pub corrs: [TrackingChannelCorrelationDep; 3], -} -impl ConcreteMessage for MsgTrackingIqDepA { - const MESSAGE_TYPE: u16 = 28; - const MESSAGE_NAME: &'static str = "MSG_TRACKING_IQ_DEP_A"; -} - -impl SbpMessage for MsgTrackingIqDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } -} - -impl TryFrom for MsgTrackingIqDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgTrackingIqDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgTrackingIq { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgTrackingIq(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgTrackingIqDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + <[TrackingChannelCorrelationDep; 3] as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.channel) + WireFormat::len(&self.sid) + WireFormat::len(&self.corrs) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.channel, buf); - WireFormat::write(&self.sid, buf); - WireFormat::write(&self.corrs, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgTrackingIqDepA { - sender_id: None, - channel: WireFormat::parse_unchecked(buf), - sid: WireFormat::parse_unchecked(buf), - corrs: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgTrackingIq { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + <[TrackingChannelCorrelation; 3] as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.channel) + + WireFormat::len(&self.sid) + + WireFormat::len(&self.corrs) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.channel, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.corrs, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgTrackingIq { + sender_id: None, + channel: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + corrs: WireFormat::parse_unchecked(buf), + } } } } -/// Tracking channel correlations -/// -/// When enabled, a tracking channel can output the correlations at each -/// update interval. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgTrackingIqDepB { - /// 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 - #[cfg_attr(feature = "serde", serde(rename(serialize = "corrs")))] - pub corrs: [TrackingChannelCorrelationDep; 3], -} +pub mod msg_tracking_iq_dep_a { + #![allow(unused_imports)] -impl ConcreteMessage for MsgTrackingIqDepB { - const MESSAGE_TYPE: u16 = 44; - const MESSAGE_NAME: &'static str = "MSG_TRACKING_IQ_DEP_B"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgTrackingIqDepB { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE + /// Deprecated + /// + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgTrackingIqDepA { + /// 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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "corrs")))] + pub corrs: [TrackingChannelCorrelationDep; 3], } - fn sender_id(&self) -> Option { - self.sender_id - } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgTrackingIqDepA { + const MESSAGE_TYPE: u16 = 28; + const MESSAGE_NAME: &'static str = "MSG_TRACKING_IQ_DEP_A"; } -} -impl TryFrom for MsgTrackingIqDepB { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgTrackingIqDepB(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgTrackingIqDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgTrackingIqDepB { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + <[TrackingChannelCorrelationDep; 3] as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.channel) + WireFormat::len(&self.sid) + WireFormat::len(&self.corrs) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.channel, buf); - WireFormat::write(&self.sid, buf); - WireFormat::write(&self.corrs, buf); + impl TryFrom for MsgTrackingIqDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgTrackingIqDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgTrackingIqDepB { - sender_id: None, - channel: WireFormat::parse_unchecked(buf), - sid: WireFormat::parse_unchecked(buf), - corrs: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgTrackingIqDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + <[TrackingChannelCorrelationDep; 3] as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.channel) + + WireFormat::len(&self.sid) + + WireFormat::len(&self.corrs) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.channel, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.corrs, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgTrackingIqDepA { + sender_id: None, + channel: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + corrs: WireFormat::parse_unchecked(buf), + } } } } -/// Signal tracking channel states -/// -/// The tracking message returns a variable-length array of tracking channel -/// states. It reports status and carrier-to-noise density measurements for -/// all tracked satellites. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgTrackingState { - /// 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, -} +pub mod msg_tracking_iq_dep_b { + #![allow(unused_imports)] -impl ConcreteMessage for MsgTrackingState { - const MESSAGE_TYPE: u16 = 65; - const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgTrackingState { - 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); + /// Tracking channel correlations + /// + /// When enabled, a tracking channel can output the correlations at each + /// update interval. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgTrackingIqDepB { + /// 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 + #[cfg_attr(feature = "serde", serde(rename(serialize = "corrs")))] + pub corrs: [TrackingChannelCorrelationDep; 3], } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgTrackingIqDepB { + const MESSAGE_TYPE: u16 = 44; + const MESSAGE_NAME: &'static str = "MSG_TRACKING_IQ_DEP_B"; } -} -impl TryFrom for MsgTrackingState { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgTrackingState(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgTrackingIqDepB { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgTrackingState { - const MIN_LEN: usize = as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.states) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.states, buf); + impl TryFrom for MsgTrackingIqDepB { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgTrackingIqDepB(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgTrackingState { - sender_id: None, - states: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgTrackingIqDepB { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + <[TrackingChannelCorrelationDep; 3] as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.channel) + + WireFormat::len(&self.sid) + + WireFormat::len(&self.corrs) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.channel, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.corrs, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgTrackingIqDepB { + sender_id: None, + channel: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + corrs: WireFormat::parse_unchecked(buf), + } } } } -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgTrackingStateDepA { - /// 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, -} +pub mod msg_tracking_state { + #![allow(unused_imports)] -impl ConcreteMessage for MsgTrackingStateDepA { - const MESSAGE_TYPE: u16 = 22; - const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE_DEP_A"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgTrackingStateDepA { - 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); + /// Signal tracking channel states + /// + /// The tracking message returns a variable-length array of tracking channel + /// states. It reports status and carrier-to-noise density measurements for + /// all tracked satellites. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgTrackingState { + /// 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, } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgTrackingState { + const MESSAGE_TYPE: u16 = 65; + const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE"; } -} -impl TryFrom for MsgTrackingStateDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgTrackingStateDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgTrackingState { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgTrackingStateDepA { - const MIN_LEN: usize = as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.states) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.states, buf); + impl TryFrom for MsgTrackingState { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgTrackingState(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgTrackingStateDepA { - sender_id: None, - states: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgTrackingState { + const MIN_LEN: usize = as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.states) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.states, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgTrackingState { + sender_id: None, + states: WireFormat::parse_unchecked(buf), + } } } } -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgTrackingStateDepB { - /// 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, -} +pub mod msg_tracking_state_dep_a { + #![allow(unused_imports)] -impl ConcreteMessage for MsgTrackingStateDepB { - const MESSAGE_TYPE: u16 = 19; - const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE_DEP_B"; -} + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; -impl SbpMessage for MsgTrackingStateDepB { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE + /// Deprecated + /// + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgTrackingStateDepA { + /// 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, } - fn sender_id(&self) -> Option { - self.sender_id - } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgTrackingStateDepA { + const MESSAGE_TYPE: u16 = 22; + const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE_DEP_A"; } -} -impl TryFrom for MsgTrackingStateDepB { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgTrackingStateDepB(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgTrackingStateDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgTrackingStateDepB { - const MIN_LEN: usize = as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.states) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.states, buf); + impl TryFrom for MsgTrackingStateDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgTrackingStateDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgTrackingStateDepB { - sender_id: None, - states: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgTrackingStateDepA { + const MIN_LEN: usize = as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.states) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.states, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgTrackingStateDepA { + sender_id: None, + states: WireFormat::parse_unchecked(buf), + } } } } -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgTrackingStateDetailedDep { - /// 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. - #[cfg_attr(feature = "serde", serde(rename(serialize = "tot")))] - pub tot: GpsTimeDep, - /// Pseudorange observation. Valid only when pseudorange valid flag is set. - #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] - pub p: u32, - /// Pseudorange observation standard deviation. Valid only when pseudorange - /// valid flag is set. - #[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. - #[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, -} +pub mod msg_tracking_state_dep_b { + #![allow(unused_imports)] -impl MsgTrackingStateDetailedDep { - pub fn synchronization_status( - &self, - ) -> Option { - match get_bit_range!( self.sync_flags, u8, u8, 2, 0 ) { - 0 => Some( MsgTrackingStateDetailedDepSynchronizationStatus :: NoSynchronization ), - 1 => Some( MsgTrackingStateDetailedDepSynchronizationStatus :: BitSynchronization ), - 2 => Some( MsgTrackingStateDetailedDepSynchronizationStatus :: WordSynchronization ), - 3 => Some( MsgTrackingStateDetailedDepSynchronizationStatus :: SubFrameSynchronizationMessageSynchronization ), - _ => None, - } + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Deprecated + /// + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgTrackingStateDepB { + /// 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, } - pub fn set_synchronization_status( - &mut self, - synchronization_status: MsgTrackingStateDetailedDepSynchronizationStatus, - ) { - set_bit_range!(&mut self.sync_flags, synchronization_status, u8, u8, 2, 0); + impl ConcreteMessage for MsgTrackingStateDepB { + const MESSAGE_TYPE: u16 = 19; + const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE_DEP_B"; } - pub fn week_number_validity_status( - &self, - ) -> Option { - match get_bit_range!(self.tow_flags, u8, u8, 3, 0) { - 0 => Some(MsgTrackingStateDetailedDepWeekNumberValidityStatus::WeekNumberIsNotValid), - 1 => Some(MsgTrackingStateDetailedDepWeekNumberValidityStatus::WeekNumberIsValid), - _ => None, + impl SbpMessage for MsgTrackingStateDepB { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } - pub fn set_week_number_validity_status( - &mut self, - week_number_validity_status: MsgTrackingStateDetailedDepWeekNumberValidityStatus, - ) { - set_bit_range!( - &mut self.tow_flags, - week_number_validity_status, - u8, - u8, - 3, - 0 - ); + impl TryFrom for MsgTrackingStateDepB { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgTrackingStateDepB(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - pub fn tow_status(&self) -> Option { - match get_bit_range!(self.tow_flags, u8, u8, 2, 0) { - 0 => Some(MsgTrackingStateDetailedDepTowStatus::TowIsNotAvailable), - 1 => Some(MsgTrackingStateDetailedDepTowStatus::DecodedTowIsAvailable), - 2 => Some(MsgTrackingStateDetailedDepTowStatus::PropagatedTowIsAvailable), - _ => None, + impl WireFormat for MsgTrackingStateDepB { + const MIN_LEN: usize = as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.states) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.states, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgTrackingStateDepB { + sender_id: None, + states: WireFormat::parse_unchecked(buf), + } } } +} - pub fn set_tow_status(&mut self, tow_status: MsgTrackingStateDetailedDepTowStatus) { - set_bit_range!(&mut self.tow_flags, tow_status, u8, u8, 2, 0); - } +pub mod msg_tracking_state_detailed_dep { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Deprecated + /// + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgTrackingStateDetailedDep { + /// 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. + #[cfg_attr(feature = "serde", serde(rename(serialize = "tot")))] + pub tot: GpsTimeDep, + /// Pseudorange observation. Valid only when pseudorange valid flag is set. + #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] + pub p: u32, + /// Pseudorange observation standard deviation. Valid only when pseudorange + /// valid flag is set. + #[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. + #[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 { + pub fn synchronization_status(&self) -> Option { + match get_bit_range!(self.sync_flags, u8, u8, 2, 0) { + 0 => Some(SynchronizationStatus::NoSynchronization), + 1 => Some(SynchronizationStatus::BitSynchronization), + 2 => Some(SynchronizationStatus::WordSynchronization), + 3 => Some(SynchronizationStatus::SubFrameSynchronizationMessageSynchronization), + _ => None, + } + } - pub fn fll_status(&self) -> Option { - match get_bit_range!(self.track_flags, u8, u8, 4, 0) { - 0 => Some(MsgTrackingStateDetailedDepFllStatus::FllIsInactive), - 1 => Some(MsgTrackingStateDetailedDepFllStatus::FllIsActive), - _ => None, + pub fn set_synchronization_status( + &mut self, + synchronization_status: SynchronizationStatus, + ) { + set_bit_range!(&mut self.sync_flags, synchronization_status, u8, u8, 2, 0); } - } - pub fn set_fll_status(&mut self, fll_status: MsgTrackingStateDetailedDepFllStatus) { - set_bit_range!(&mut self.track_flags, fll_status, u8, u8, 4, 0); - } + pub fn week_number_validity_status(&self) -> Option { + match get_bit_range!(self.tow_flags, u8, u8, 3, 0) { + 0 => Some(WeekNumberValidityStatus::WeekNumberIsNotValid), + 1 => Some(WeekNumberValidityStatus::WeekNumberIsValid), + _ => None, + } + } - pub fn pll_status(&self) -> Option { - match get_bit_range!(self.track_flags, u8, u8, 3, 0) { - 0 => Some(MsgTrackingStateDetailedDepPllStatus::PllIsInactive), - 1 => Some(MsgTrackingStateDetailedDepPllStatus::PllIsActive), - _ => None, + pub fn set_week_number_validity_status( + &mut self, + week_number_validity_status: WeekNumberValidityStatus, + ) { + set_bit_range!( + &mut self.tow_flags, + week_number_validity_status, + u8, + u8, + 3, + 0 + ); + } + + pub fn tow_status(&self) -> Option { + match get_bit_range!(self.tow_flags, u8, u8, 2, 0) { + 0 => Some(TowStatus::TowIsNotAvailable), + 1 => Some(TowStatus::DecodedTowIsAvailable), + 2 => Some(TowStatus::PropagatedTowIsAvailable), + _ => None, + } } - } - pub fn set_pll_status(&mut self, pll_status: MsgTrackingStateDetailedDepPllStatus) { - set_bit_range!(&mut self.track_flags, pll_status, u8, u8, 3, 0); - } + pub fn set_tow_status(&mut self, tow_status: TowStatus) { + set_bit_range!(&mut self.tow_flags, tow_status, u8, u8, 2, 0); + } - pub fn tracking_loop_status(&self) -> Option { - match get_bit_range!(self.track_flags, u8, u8, 2, 0) { - 0 => Some(MsgTrackingStateDetailedDepTrackingLoopStatus::NoLocks), - 1 => Some(MsgTrackingStateDetailedDepTrackingLoopStatus::FlldllLock), - 2 => Some(MsgTrackingStateDetailedDepTrackingLoopStatus::PllOptimisticLock), - 3 => Some(MsgTrackingStateDetailedDepTrackingLoopStatus::PllPessimisticLock), - _ => None, + pub fn fll_status(&self) -> Option { + match get_bit_range!(self.track_flags, u8, u8, 4, 0) { + 0 => Some(FllStatus::FllIsInactive), + 1 => Some(FllStatus::FllIsActive), + _ => None, + } } - } - pub fn set_tracking_loop_status( - &mut self, - tracking_loop_status: MsgTrackingStateDetailedDepTrackingLoopStatus, - ) { - set_bit_range!(&mut self.track_flags, tracking_loop_status, u8, u8, 2, 0); - } + pub fn set_fll_status(&mut self, fll_status: FllStatus) { + set_bit_range!(&mut self.track_flags, fll_status, u8, u8, 4, 0); + } - pub fn almanac_availability_status( - &self, - ) -> Option { - match get_bit_range!(self.nav_flags, u8, u8, 4, 0) { - 0 => Some(MsgTrackingStateDetailedDepAlmanacAvailabilityStatus::AlmanacIsNotAvailable), - 1 => Some(MsgTrackingStateDetailedDepAlmanacAvailabilityStatus::AlmanacIsAvailable), - _ => None, + pub fn pll_status(&self) -> Option { + match get_bit_range!(self.track_flags, u8, u8, 3, 0) { + 0 => Some(PllStatus::PllIsInactive), + 1 => Some(PllStatus::PllIsActive), + _ => None, + } } - } - pub fn set_almanac_availability_status( - &mut self, - almanac_availability_status: MsgTrackingStateDetailedDepAlmanacAvailabilityStatus, - ) { - set_bit_range!( - &mut self.nav_flags, - almanac_availability_status, - u8, - u8, - 4, - 0 - ); - } + pub fn set_pll_status(&mut self, pll_status: PllStatus) { + set_bit_range!(&mut self.track_flags, pll_status, u8, u8, 3, 0); + } - pub fn ephemeris_availability_status( - &self, - ) -> Option { - match get_bit_range!(self.nav_flags, u8, u8, 3, 0) { - 0 => Some( - MsgTrackingStateDetailedDepEphemerisAvailabilityStatus::EphemerisIsNotAvailable, - ), - 1 => Some(MsgTrackingStateDetailedDepEphemerisAvailabilityStatus::EphemerisIsAvailable), - _ => None, + pub fn tracking_loop_status(&self) -> Option { + match get_bit_range!(self.track_flags, u8, u8, 2, 0) { + 0 => Some(TrackingLoopStatus::NoLocks), + 1 => Some(TrackingLoopStatus::FlldllLock), + 2 => Some(TrackingLoopStatus::PllOptimisticLock), + 3 => Some(TrackingLoopStatus::PllPessimisticLock), + _ => None, + } } - } - pub fn set_ephemeris_availability_status( - &mut self, - ephemeris_availability_status: MsgTrackingStateDetailedDepEphemerisAvailabilityStatus, - ) { - set_bit_range!( - &mut self.nav_flags, - ephemeris_availability_status, - u8, - u8, - 3, - 0 - ); - } + pub fn set_tracking_loop_status(&mut self, tracking_loop_status: TrackingLoopStatus) { + set_bit_range!(&mut self.track_flags, tracking_loop_status, u8, u8, 2, 0); + } - pub fn health_status(&self) -> Option { - match get_bit_range!(self.nav_flags, u8, u8, 2, 0) { - 0 => Some(MsgTrackingStateDetailedDepHealthStatus::HealthIsUnknown), - 1 => Some(MsgTrackingStateDetailedDepHealthStatus::SignalIsUnhealthy), - 2 => Some(MsgTrackingStateDetailedDepHealthStatus::SignalIsHealthy), - _ => None, + pub fn almanac_availability_status(&self) -> Option { + match get_bit_range!(self.nav_flags, u8, u8, 4, 0) { + 0 => Some(AlmanacAvailabilityStatus::AlmanacIsNotAvailable), + 1 => Some(AlmanacAvailabilityStatus::AlmanacIsAvailable), + _ => None, + } } - } - pub fn set_health_status(&mut self, health_status: MsgTrackingStateDetailedDepHealthStatus) { - set_bit_range!(&mut self.nav_flags, health_status, u8, u8, 2, 0); - } + pub fn set_almanac_availability_status( + &mut self, + almanac_availability_status: AlmanacAvailabilityStatus, + ) { + set_bit_range!( + &mut self.nav_flags, + almanac_availability_status, + u8, + u8, + 4, + 0 + ); + } + + pub fn ephemeris_availability_status(&self) -> Option { + match get_bit_range!(self.nav_flags, u8, u8, 3, 0) { + 0 => Some(EphemerisAvailabilityStatus::EphemerisIsNotAvailable), + 1 => Some(EphemerisAvailabilityStatus::EphemerisIsAvailable), + _ => None, + } + } - pub fn parameter_sets(&self) -> Option { - match get_bit_range!(self.pset_flags, u8, u8, 2, 0) { - 0 => Some(MsgTrackingStateDetailedDepParameterSets::_1MsIntegrationTime), - 1 => Some(MsgTrackingStateDetailedDepParameterSets::_5MsIntegrationTime), - 2 => Some(MsgTrackingStateDetailedDepParameterSets::_10MsIntegrationTime), - 3 => Some(MsgTrackingStateDetailedDepParameterSets::_20MsIntegrationTime), - _ => None, + pub fn set_ephemeris_availability_status( + &mut self, + ephemeris_availability_status: EphemerisAvailabilityStatus, + ) { + set_bit_range!( + &mut self.nav_flags, + ephemeris_availability_status, + u8, + u8, + 3, + 0 + ); + } + + pub fn health_status(&self) -> Option { + match get_bit_range!(self.nav_flags, u8, u8, 2, 0) { + 0 => Some(HealthStatus::HealthIsUnknown), + 1 => Some(HealthStatus::SignalIsUnhealthy), + 2 => Some(HealthStatus::SignalIsHealthy), + _ => None, + } } - } - pub fn set_parameter_sets(&mut self, parameter_sets: MsgTrackingStateDetailedDepParameterSets) { - set_bit_range!(&mut self.pset_flags, parameter_sets, u8, u8, 2, 0); - } + pub fn set_health_status(&mut self, health_status: HealthStatus) { + set_bit_range!(&mut self.nav_flags, health_status, u8, u8, 2, 0); + } - pub fn clock_validity_status(&self) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 5, 0) { - 0 => { - Some(MsgTrackingStateDetailedDepClockValidityStatus::ClockOffsetAndDriftIsNotValid) + pub fn parameter_sets(&self) -> Option { + match get_bit_range!(self.pset_flags, u8, u8, 2, 0) { + 0 => Some(ParameterSets::_1MsIntegrationTime), + 1 => Some(ParameterSets::_5MsIntegrationTime), + 2 => Some(ParameterSets::_10MsIntegrationTime), + 3 => Some(ParameterSets::_20MsIntegrationTime), + _ => None, } - 1 => Some(MsgTrackingStateDetailedDepClockValidityStatus::ClockOffsetAndDriftIsValid), - _ => None, } - } - pub fn set_clock_validity_status( - &mut self, - clock_validity_status: MsgTrackingStateDetailedDepClockValidityStatus, - ) { - set_bit_range!(&mut self.misc_flags, clock_validity_status, u8, u8, 5, 0); - } + pub fn set_parameter_sets(&mut self, parameter_sets: ParameterSets) { + set_bit_range!(&mut self.pset_flags, parameter_sets, u8, u8, 2, 0); + } - pub fn pseudorange_validity_status( - &self, - ) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 4, 0) { - 0 => Some(MsgTrackingStateDetailedDepPseudorangeValidityStatus::PseudorangeIsNotValid), - 1 => Some(MsgTrackingStateDetailedDepPseudorangeValidityStatus::PseudorangeIsValid), - _ => None, + pub fn clock_validity_status(&self) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 5, 0) { + 0 => Some(ClockValidityStatus::ClockOffsetAndDriftIsNotValid), + 1 => Some(ClockValidityStatus::ClockOffsetAndDriftIsValid), + _ => None, + } } - } - pub fn set_pseudorange_validity_status( - &mut self, - pseudorange_validity_status: MsgTrackingStateDetailedDepPseudorangeValidityStatus, - ) { - set_bit_range!( - &mut self.misc_flags, - pseudorange_validity_status, - u8, - u8, - 4, - 0 - ); - } + pub fn set_clock_validity_status(&mut self, clock_validity_status: ClockValidityStatus) { + set_bit_range!(&mut self.misc_flags, clock_validity_status, u8, u8, 5, 0); + } - pub fn acceleration_validity_status( - &self, - ) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 3, 0) { - 0 => { - Some(MsgTrackingStateDetailedDepAccelerationValidityStatus::AccelerationIsNotValid) + pub fn pseudorange_validity_status(&self) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 4, 0) { + 0 => Some(PseudorangeValidityStatus::PseudorangeIsNotValid), + 1 => Some(PseudorangeValidityStatus::PseudorangeIsValid), + _ => None, } - 1 => Some(MsgTrackingStateDetailedDepAccelerationValidityStatus::AccelerationIsValid), - _ => None, } - } - pub fn set_acceleration_validity_status( - &mut self, - acceleration_validity_status: MsgTrackingStateDetailedDepAccelerationValidityStatus, - ) { - set_bit_range!( - &mut self.misc_flags, - acceleration_validity_status, - u8, - u8, - 3, - 0 - ); - } + pub fn set_pseudorange_validity_status( + &mut self, + pseudorange_validity_status: PseudorangeValidityStatus, + ) { + set_bit_range!( + &mut self.misc_flags, + pseudorange_validity_status, + u8, + u8, + 4, + 0 + ); + } + + pub fn acceleration_validity_status(&self) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 3, 0) { + 0 => Some(AccelerationValidityStatus::AccelerationIsNotValid), + 1 => Some(AccelerationValidityStatus::AccelerationIsValid), + _ => None, + } + } - pub fn carrier_half_cycle_ambiguity_status( - &self, - ) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 2, 0) { - 0 => Some(MsgTrackingStateDetailedDepCarrierHalfCycleAmbiguityStatus::Unresolved), - 1 => Some(MsgTrackingStateDetailedDepCarrierHalfCycleAmbiguityStatus::Resolved), - _ => None, + pub fn set_acceleration_validity_status( + &mut self, + acceleration_validity_status: AccelerationValidityStatus, + ) { + set_bit_range!( + &mut self.misc_flags, + acceleration_validity_status, + u8, + u8, + 3, + 0 + ); + } + + pub fn carrier_half_cycle_ambiguity_status( + &self, + ) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 2, 0) { + 0 => Some(CarrierHalfCycleAmbiguityStatus::Unresolved), + 1 => Some(CarrierHalfCycleAmbiguityStatus::Resolved), + _ => None, + } } - } - pub fn set_carrier_half_cycle_ambiguity_status( - &mut self, - carrier_half_cycle_ambiguity_status: MsgTrackingStateDetailedDepCarrierHalfCycleAmbiguityStatus, - ) { - set_bit_range!( - &mut self.misc_flags, - carrier_half_cycle_ambiguity_status, - u8, - u8, - 2, - 0 - ); - } + pub fn set_carrier_half_cycle_ambiguity_status( + &mut self, + carrier_half_cycle_ambiguity_status: CarrierHalfCycleAmbiguityStatus, + ) { + set_bit_range!( + &mut self.misc_flags, + carrier_half_cycle_ambiguity_status, + u8, + u8, + 2, + 0 + ); + } + + pub fn tracking_channel_status(&self) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 1, 0) { + 0 => Some(TrackingChannelStatus::ReAcquisition), + 1 => Some(TrackingChannelStatus::Running), + _ => None, + } + } - pub fn tracking_channel_status( - &self, - ) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 1, 0) { - 0 => Some(MsgTrackingStateDetailedDepTrackingChannelStatus::ReAcquisition), - 1 => Some(MsgTrackingStateDetailedDepTrackingChannelStatus::Running), - _ => None, + pub fn set_tracking_channel_status( + &mut self, + tracking_channel_status: TrackingChannelStatus, + ) { + set_bit_range!(&mut self.misc_flags, tracking_channel_status, u8, u8, 1, 0); } } - pub fn set_tracking_channel_status( - &mut self, - tracking_channel_status: MsgTrackingStateDetailedDepTrackingChannelStatus, - ) { - set_bit_range!(&mut self.misc_flags, tracking_channel_status, u8, u8, 1, 0); + impl ConcreteMessage for MsgTrackingStateDetailedDep { + const MESSAGE_TYPE: u16 = 17; + const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE_DETAILED_DEP"; } -} - -impl ConcreteMessage for MsgTrackingStateDetailedDep { - const MESSAGE_TYPE: u16 = 17; - const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE_DETAILED_DEP"; -} -impl SbpMessage for MsgTrackingStateDetailedDep { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgTrackingStateDetailedDep { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgTrackingStateDetailedDep { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgTrackingStateDetailedDep(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgTrackingStateDetailedDep { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgTrackingStateDetailedDep(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgTrackingStateDetailedDep { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.recv_time) - + WireFormat::len(&self.tot) - + WireFormat::len(&self.p) - + WireFormat::len(&self.p_std) - + WireFormat::len(&self.l) - + WireFormat::len(&self.cn0) - + WireFormat::len(&self.lock) - + WireFormat::len(&self.sid) - + WireFormat::len(&self.doppler) - + WireFormat::len(&self.doppler_std) - + WireFormat::len(&self.uptime) - + WireFormat::len(&self.clock_offset) - + WireFormat::len(&self.clock_drift) - + WireFormat::len(&self.corr_spacing) - + WireFormat::len(&self.acceleration) - + WireFormat::len(&self.sync_flags) - + WireFormat::len(&self.tow_flags) - + WireFormat::len(&self.track_flags) - + WireFormat::len(&self.nav_flags) - + WireFormat::len(&self.pset_flags) - + WireFormat::len(&self.misc_flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgTrackingStateDetailedDep { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.recv_time) + + WireFormat::len(&self.tot) + + WireFormat::len(&self.p) + + WireFormat::len(&self.p_std) + + WireFormat::len(&self.l) + + WireFormat::len(&self.cn0) + + WireFormat::len(&self.lock) + + WireFormat::len(&self.sid) + + WireFormat::len(&self.doppler) + + WireFormat::len(&self.doppler_std) + + WireFormat::len(&self.uptime) + + WireFormat::len(&self.clock_offset) + + WireFormat::len(&self.clock_drift) + + WireFormat::len(&self.corr_spacing) + + WireFormat::len(&self.acceleration) + + WireFormat::len(&self.sync_flags) + + WireFormat::len(&self.tow_flags) + + WireFormat::len(&self.track_flags) + + WireFormat::len(&self.nav_flags) + + WireFormat::len(&self.pset_flags) + + WireFormat::len(&self.misc_flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Synchronization status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepSynchronizationStatus { - /// No synchronization - NoSynchronization = 0, + /// Synchronization status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum SynchronizationStatus { + /// No synchronization + NoSynchronization = 0, - /// Bit synchronization - BitSynchronization = 1, + /// Bit synchronization + BitSynchronization = 1, - /// Word synchronization (L1 C/A only) - WordSynchronization = 2, + /// Word synchronization (L1 C/A only) + WordSynchronization = 2, - /// Sub-frame synchronization (L1 C/A) / message synchronization (L2C) - SubFrameSynchronizationMessageSynchronization = 3, -} + /// Sub-frame synchronization (L1 C/A) / message synchronization (L2C) + SubFrameSynchronizationMessageSynchronization = 3, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepSynchronizationStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepSynchronizationStatus::NoSynchronization => f.write_str("No synchronization"), - MsgTrackingStateDetailedDepSynchronizationStatus::BitSynchronization => f.write_str("Bit synchronization"), - MsgTrackingStateDetailedDepSynchronizationStatus::WordSynchronization => f.write_str("Word synchronization (L1 C/A only)"), - MsgTrackingStateDetailedDepSynchronizationStatus::SubFrameSynchronizationMessageSynchronization => f.write_str("Sub-frame synchronization (L1 C/A) / message synchronization (L2C) -"), + impl std::fmt::Display for SynchronizationStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SynchronizationStatus::NoSynchronization => f.write_str("No synchronization"), + SynchronizationStatus::BitSynchronization => f.write_str("Bit synchronization"), + SynchronizationStatus::WordSynchronization => { + f.write_str("Word synchronization (L1 C/A only)") + } + SynchronizationStatus::SubFrameSynchronizationMessageSynchronization => f + .write_str( + "Sub-frame synchronization (L1 C/A) / message synchronization (L2C) +", + ), + } } } -} -/// Week number validity status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepWeekNumberValidityStatus { - /// Week number is not valid - WeekNumberIsNotValid = 0, + /// Week number validity status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum WeekNumberValidityStatus { + /// Week number is not valid + WeekNumberIsNotValid = 0, - /// Week number is valid - WeekNumberIsValid = 1, -} + /// Week number is valid + WeekNumberIsValid = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepWeekNumberValidityStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepWeekNumberValidityStatus::WeekNumberIsNotValid => { - f.write_str("Week number is not valid") - } - MsgTrackingStateDetailedDepWeekNumberValidityStatus::WeekNumberIsValid => { - f.write_str("Week number is valid") + impl std::fmt::Display for WeekNumberValidityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + WeekNumberValidityStatus::WeekNumberIsNotValid => { + f.write_str("Week number is not valid") + } + WeekNumberValidityStatus::WeekNumberIsValid => f.write_str("Week number is valid"), } } } -} -/// TOW status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepTowStatus { - /// TOW is not available - TowIsNotAvailable = 0, + /// TOW status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TowStatus { + /// TOW is not available + TowIsNotAvailable = 0, - /// Decoded TOW is available - DecodedTowIsAvailable = 1, + /// Decoded TOW is available + DecodedTowIsAvailable = 1, - /// Propagated TOW is available - PropagatedTowIsAvailable = 2, -} + /// Propagated TOW is available + PropagatedTowIsAvailable = 2, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepTowStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepTowStatus::TowIsNotAvailable => { - f.write_str("TOW is not available") - } - MsgTrackingStateDetailedDepTowStatus::DecodedTowIsAvailable => { - f.write_str("Decoded TOW is available") - } - MsgTrackingStateDetailedDepTowStatus::PropagatedTowIsAvailable => { - f.write_str("Propagated TOW is available") + impl std::fmt::Display for TowStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TowStatus::TowIsNotAvailable => f.write_str("TOW is not available"), + TowStatus::DecodedTowIsAvailable => f.write_str("Decoded TOW is available"), + TowStatus::PropagatedTowIsAvailable => f.write_str("Propagated TOW is available"), } } } -} -/// FLL status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepFllStatus { - /// FLL is inactive - FllIsInactive = 0, + /// FLL status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FllStatus { + /// FLL is inactive + FllIsInactive = 0, - /// FLL is active - FllIsActive = 1, -} + /// FLL is active + FllIsActive = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepFllStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepFllStatus::FllIsInactive => f.write_str("FLL is inactive"), - MsgTrackingStateDetailedDepFllStatus::FllIsActive => f.write_str("FLL is active"), + impl std::fmt::Display for FllStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FllStatus::FllIsInactive => f.write_str("FLL is inactive"), + FllStatus::FllIsActive => f.write_str("FLL is active"), + } } } -} -/// PLL status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepPllStatus { - /// PLL is inactive - PllIsInactive = 0, + /// PLL status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum PllStatus { + /// PLL is inactive + PllIsInactive = 0, - /// PLL is active - PllIsActive = 1, -} + /// PLL is active + PllIsActive = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepPllStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepPllStatus::PllIsInactive => f.write_str("PLL is inactive"), - MsgTrackingStateDetailedDepPllStatus::PllIsActive => f.write_str("PLL is active"), + impl std::fmt::Display for PllStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + PllStatus::PllIsInactive => f.write_str("PLL is inactive"), + PllStatus::PllIsActive => f.write_str("PLL is active"), + } } } -} -/// Tracking loop status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepTrackingLoopStatus { - /// No locks - NoLocks = 0, + /// Tracking loop status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TrackingLoopStatus { + /// No locks + NoLocks = 0, - /// FLL/DLL lock - FlldllLock = 1, + /// FLL/DLL lock + FlldllLock = 1, - /// PLL optimistic lock - PllOptimisticLock = 2, + /// PLL optimistic lock + PllOptimisticLock = 2, - /// PLL pessimistic lock - PllPessimisticLock = 3, -} + /// PLL pessimistic lock + PllPessimisticLock = 3, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepTrackingLoopStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepTrackingLoopStatus::NoLocks => f.write_str("No locks"), - MsgTrackingStateDetailedDepTrackingLoopStatus::FlldllLock => { - f.write_str("FLL/DLL lock") - } - MsgTrackingStateDetailedDepTrackingLoopStatus::PllOptimisticLock => { - f.write_str("PLL optimistic lock") - } - MsgTrackingStateDetailedDepTrackingLoopStatus::PllPessimisticLock => { - f.write_str("PLL pessimistic lock") + impl std::fmt::Display for TrackingLoopStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TrackingLoopStatus::NoLocks => f.write_str("No locks"), + TrackingLoopStatus::FlldllLock => f.write_str("FLL/DLL lock"), + TrackingLoopStatus::PllOptimisticLock => f.write_str("PLL optimistic lock"), + TrackingLoopStatus::PllPessimisticLock => f.write_str("PLL pessimistic lock"), } } } -} -/// Almanac availability status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepAlmanacAvailabilityStatus { - /// Almanac is not available - AlmanacIsNotAvailable = 0, + /// Almanac availability status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum AlmanacAvailabilityStatus { + /// Almanac is not available + AlmanacIsNotAvailable = 0, - /// Almanac is available - AlmanacIsAvailable = 1, -} + /// Almanac is available + AlmanacIsAvailable = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepAlmanacAvailabilityStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepAlmanacAvailabilityStatus::AlmanacIsNotAvailable => { - f.write_str("Almanac is not available") - } - MsgTrackingStateDetailedDepAlmanacAvailabilityStatus::AlmanacIsAvailable => { - f.write_str("Almanac is available") + impl std::fmt::Display for AlmanacAvailabilityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + AlmanacAvailabilityStatus::AlmanacIsNotAvailable => { + f.write_str("Almanac is not available") + } + AlmanacAvailabilityStatus::AlmanacIsAvailable => { + f.write_str("Almanac is available") + } } } } -} -/// Ephemeris availability status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepEphemerisAvailabilityStatus { - /// Ephemeris is not available - EphemerisIsNotAvailable = 0, + /// Ephemeris availability status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum EphemerisAvailabilityStatus { + /// Ephemeris is not available + EphemerisIsNotAvailable = 0, - /// Ephemeris is available - EphemerisIsAvailable = 1, -} + /// Ephemeris is available + EphemerisIsAvailable = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepEphemerisAvailabilityStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepEphemerisAvailabilityStatus::EphemerisIsNotAvailable => { - f.write_str("Ephemeris is not available") - } - MsgTrackingStateDetailedDepEphemerisAvailabilityStatus::EphemerisIsAvailable => { - f.write_str("Ephemeris is available") + impl std::fmt::Display for EphemerisAvailabilityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + EphemerisAvailabilityStatus::EphemerisIsNotAvailable => { + f.write_str("Ephemeris is not available") + } + EphemerisAvailabilityStatus::EphemerisIsAvailable => { + f.write_str("Ephemeris is available") + } } } } -} -/// Health status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepHealthStatus { - /// Health is unknown - HealthIsUnknown = 0, + /// Health status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum HealthStatus { + /// Health is unknown + HealthIsUnknown = 0, - /// Signal is unhealthy - SignalIsUnhealthy = 1, + /// Signal is unhealthy + SignalIsUnhealthy = 1, - /// Signal is healthy - SignalIsHealthy = 2, -} + /// Signal is healthy + SignalIsHealthy = 2, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepHealthStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepHealthStatus::HealthIsUnknown => { - f.write_str("Health is unknown") - } - MsgTrackingStateDetailedDepHealthStatus::SignalIsUnhealthy => { - f.write_str("Signal is unhealthy") - } - MsgTrackingStateDetailedDepHealthStatus::SignalIsHealthy => { - f.write_str("Signal is healthy") + impl std::fmt::Display for HealthStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + HealthStatus::HealthIsUnknown => f.write_str("Health is unknown"), + HealthStatus::SignalIsUnhealthy => f.write_str("Signal is unhealthy"), + HealthStatus::SignalIsHealthy => f.write_str("Signal is healthy"), } } } -} -/// Parameter sets. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepParameterSets { - /// 1 ms integration time - _1MsIntegrationTime = 0, + /// Parameter sets. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum ParameterSets { + /// 1 ms integration time + _1MsIntegrationTime = 0, - /// 5 ms integration time - _5MsIntegrationTime = 1, + /// 5 ms integration time + _5MsIntegrationTime = 1, - /// 10 ms integration time - _10MsIntegrationTime = 2, + /// 10 ms integration time + _10MsIntegrationTime = 2, - /// 20 ms integration time - _20MsIntegrationTime = 3, -} + /// 20 ms integration time + _20MsIntegrationTime = 3, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepParameterSets { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepParameterSets::_1MsIntegrationTime => { - f.write_str("1 ms integration time") - } - MsgTrackingStateDetailedDepParameterSets::_5MsIntegrationTime => { - f.write_str("5 ms integration time") - } - MsgTrackingStateDetailedDepParameterSets::_10MsIntegrationTime => { - f.write_str("10 ms integration time") - } - MsgTrackingStateDetailedDepParameterSets::_20MsIntegrationTime => { - f.write_str("20 ms integration time") + impl std::fmt::Display for ParameterSets { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ParameterSets::_1MsIntegrationTime => f.write_str("1 ms integration time"), + ParameterSets::_5MsIntegrationTime => f.write_str("5 ms integration time"), + ParameterSets::_10MsIntegrationTime => f.write_str("10 ms integration time"), + ParameterSets::_20MsIntegrationTime => f.write_str("20 ms integration time"), } } } -} -/// Clock validity status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepClockValidityStatus { - /// Clock offset and drift is not valid - ClockOffsetAndDriftIsNotValid = 0, + /// Clock validity status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum ClockValidityStatus { + /// Clock offset and drift is not valid + ClockOffsetAndDriftIsNotValid = 0, - /// Clock offset and drift is valid - ClockOffsetAndDriftIsValid = 1, -} + /// Clock offset and drift is valid + ClockOffsetAndDriftIsValid = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepClockValidityStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepClockValidityStatus::ClockOffsetAndDriftIsNotValid => { - f.write_str("Clock offset and drift is not valid") - } - MsgTrackingStateDetailedDepClockValidityStatus::ClockOffsetAndDriftIsValid => { - f.write_str("Clock offset and drift is valid") + impl std::fmt::Display for ClockValidityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ClockValidityStatus::ClockOffsetAndDriftIsNotValid => { + f.write_str("Clock offset and drift is not valid") + } + ClockValidityStatus::ClockOffsetAndDriftIsValid => { + f.write_str("Clock offset and drift is valid") + } } } } -} -/// Pseudorange validity status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepPseudorangeValidityStatus { - /// Pseudorange is not valid - PseudorangeIsNotValid = 0, + /// Pseudorange validity status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum PseudorangeValidityStatus { + /// Pseudorange is not valid + PseudorangeIsNotValid = 0, - /// Pseudorange is valid - PseudorangeIsValid = 1, -} + /// Pseudorange is valid + PseudorangeIsValid = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepPseudorangeValidityStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepPseudorangeValidityStatus::PseudorangeIsNotValid => { - f.write_str("Pseudorange is not valid") - } - MsgTrackingStateDetailedDepPseudorangeValidityStatus::PseudorangeIsValid => { - f.write_str("Pseudorange is valid") + impl std::fmt::Display for PseudorangeValidityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + PseudorangeValidityStatus::PseudorangeIsNotValid => { + f.write_str("Pseudorange is not valid") + } + PseudorangeValidityStatus::PseudorangeIsValid => { + f.write_str("Pseudorange is valid") + } } } } -} -/// Acceleration validity status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepAccelerationValidityStatus { - /// Acceleration is not valid - AccelerationIsNotValid = 0, + /// Acceleration validity status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum AccelerationValidityStatus { + /// Acceleration is not valid + AccelerationIsNotValid = 0, - /// Acceleration is valid - AccelerationIsValid = 1, -} + /// Acceleration is valid + AccelerationIsValid = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepAccelerationValidityStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepAccelerationValidityStatus::AccelerationIsNotValid => { - f.write_str("Acceleration is not valid") - } - MsgTrackingStateDetailedDepAccelerationValidityStatus::AccelerationIsValid => { - f.write_str("Acceleration is valid") + impl std::fmt::Display for AccelerationValidityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + AccelerationValidityStatus::AccelerationIsNotValid => { + f.write_str("Acceleration is not valid") + } + AccelerationValidityStatus::AccelerationIsValid => { + f.write_str("Acceleration is valid") + } } } } -} -/// Carrier half cycle ambiguity status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepCarrierHalfCycleAmbiguityStatus { - /// Unresolved - Unresolved = 0, + /// Carrier half cycle ambiguity status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum CarrierHalfCycleAmbiguityStatus { + /// Unresolved + Unresolved = 0, - /// Resolved - Resolved = 1, -} + /// Resolved + Resolved = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepCarrierHalfCycleAmbiguityStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepCarrierHalfCycleAmbiguityStatus::Unresolved => { - f.write_str("Unresolved") - } - MsgTrackingStateDetailedDepCarrierHalfCycleAmbiguityStatus::Resolved => { - f.write_str("Resolved") + impl std::fmt::Display for CarrierHalfCycleAmbiguityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + CarrierHalfCycleAmbiguityStatus::Unresolved => f.write_str("Unresolved"), + CarrierHalfCycleAmbiguityStatus::Resolved => f.write_str("Resolved"), } } } -} -/// Tracking channel status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepTrackingChannelStatus { - /// Re-acquisition - ReAcquisition = 0, + /// Tracking channel status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TrackingChannelStatus { + /// Re-acquisition + ReAcquisition = 0, - /// Running - Running = 1, -} + /// Running + Running = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepTrackingChannelStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepTrackingChannelStatus::ReAcquisition => { - f.write_str("Re-acquisition") + impl std::fmt::Display for TrackingChannelStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TrackingChannelStatus::ReAcquisition => f.write_str("Re-acquisition"), + TrackingChannelStatus::Running => f.write_str("Running"), } - MsgTrackingStateDetailedDepTrackingChannelStatus::Running => f.write_str("Running"), } } } -/// Detailed signal tracking channel states. DEPRECATED -/// -/// The tracking message returns a set tracking channel parameters for a -/// single tracking channel useful for debugging issues. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgTrackingStateDetailedDepA { - /// 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. - #[cfg_attr(feature = "serde", serde(rename(serialize = "tot")))] - pub tot: GpsTime, - /// Pseudorange observation. Valid only when pseudorange valid flag is set. - #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] - pub p: u32, - /// Pseudorange observation standard deviation. Valid only when pseudorange - /// valid flag is set. - #[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. - #[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 { - pub fn synchronization_status( - &self, - ) -> Option { - match get_bit_range!( self.sync_flags, u8, u8, 2, 0 ) { - 0 => Some( MsgTrackingStateDetailedDepASynchronizationStatus :: NoSynchronization ), - 1 => Some( MsgTrackingStateDetailedDepASynchronizationStatus :: BitSynchronization ), - 2 => Some( MsgTrackingStateDetailedDepASynchronizationStatus :: WordSynchronization ), - 3 => Some( MsgTrackingStateDetailedDepASynchronizationStatus :: SubFrameSynchronizationMessageSynchronization ), - _ => None, +pub mod msg_tracking_state_detailed_dep_a { + #![allow(unused_imports)] + + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Detailed signal tracking channel states. DEPRECATED + /// + /// The tracking message returns a set tracking channel parameters for a + /// single tracking channel useful for debugging issues. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgTrackingStateDetailedDepA { + /// 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. + #[cfg_attr(feature = "serde", serde(rename(serialize = "tot")))] + pub tot: GpsTime, + /// Pseudorange observation. Valid only when pseudorange valid flag is set. + #[cfg_attr(feature = "serde", serde(rename(serialize = "P")))] + pub p: u32, + /// Pseudorange observation standard deviation. Valid only when pseudorange + /// valid flag is set. + #[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. + #[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 { + pub fn synchronization_status(&self) -> Option { + match get_bit_range!(self.sync_flags, u8, u8, 2, 0) { + 0 => Some(SynchronizationStatus::NoSynchronization), + 1 => Some(SynchronizationStatus::BitSynchronization), + 2 => Some(SynchronizationStatus::WordSynchronization), + 3 => Some(SynchronizationStatus::SubFrameSynchronizationMessageSynchronization), + _ => None, + } } - } - pub fn set_synchronization_status( - &mut self, - synchronization_status: MsgTrackingStateDetailedDepASynchronizationStatus, - ) { - set_bit_range!(&mut self.sync_flags, synchronization_status, u8, u8, 2, 0); - } - - pub fn week_number_validity_status( - &self, - ) -> Option { - match get_bit_range!(self.tow_flags, u8, u8, 3, 0) { - 0 => Some(MsgTrackingStateDetailedDepAWeekNumberValidityStatus::WeekNumberIsNotValid), - 1 => Some(MsgTrackingStateDetailedDepAWeekNumberValidityStatus::WeekNumberIsValid), - _ => None, + pub fn set_synchronization_status( + &mut self, + synchronization_status: SynchronizationStatus, + ) { + set_bit_range!(&mut self.sync_flags, synchronization_status, u8, u8, 2, 0); } - } - pub fn set_week_number_validity_status( - &mut self, - week_number_validity_status: MsgTrackingStateDetailedDepAWeekNumberValidityStatus, - ) { - set_bit_range!( - &mut self.tow_flags, - week_number_validity_status, - u8, - u8, - 3, - 0 - ); - } - - pub fn tow_status(&self) -> Option { - match get_bit_range!(self.tow_flags, u8, u8, 2, 0) { - 0 => Some(MsgTrackingStateDetailedDepATowStatus::TowIsNotAvailable), - 1 => Some(MsgTrackingStateDetailedDepATowStatus::DecodedTowIsAvailable), - 2 => Some(MsgTrackingStateDetailedDepATowStatus::PropagatedTowIsAvailable), - _ => None, + pub fn week_number_validity_status(&self) -> Option { + match get_bit_range!(self.tow_flags, u8, u8, 3, 0) { + 0 => Some(WeekNumberValidityStatus::WeekNumberIsNotValid), + 1 => Some(WeekNumberValidityStatus::WeekNumberIsValid), + _ => None, + } } - } - pub fn set_tow_status(&mut self, tow_status: MsgTrackingStateDetailedDepATowStatus) { - set_bit_range!(&mut self.tow_flags, tow_status, u8, u8, 2, 0); - } - - pub fn fll_status(&self) -> Option { - match get_bit_range!(self.track_flags, u8, u8, 4, 0) { - 0 => Some(MsgTrackingStateDetailedDepAFllStatus::FllIsInactive), - 1 => Some(MsgTrackingStateDetailedDepAFllStatus::FllIsActive), - _ => None, + pub fn set_week_number_validity_status( + &mut self, + week_number_validity_status: WeekNumberValidityStatus, + ) { + set_bit_range!( + &mut self.tow_flags, + week_number_validity_status, + u8, + u8, + 3, + 0 + ); + } + + pub fn tow_status(&self) -> Option { + match get_bit_range!(self.tow_flags, u8, u8, 2, 0) { + 0 => Some(TowStatus::TowIsNotAvailable), + 1 => Some(TowStatus::DecodedTowIsAvailable), + 2 => Some(TowStatus::PropagatedTowIsAvailable), + _ => None, + } } - } - pub fn set_fll_status(&mut self, fll_status: MsgTrackingStateDetailedDepAFllStatus) { - set_bit_range!(&mut self.track_flags, fll_status, u8, u8, 4, 0); - } - - pub fn pll_status(&self) -> Option { - match get_bit_range!(self.track_flags, u8, u8, 3, 0) { - 0 => Some(MsgTrackingStateDetailedDepAPllStatus::PllIsInactive), - 1 => Some(MsgTrackingStateDetailedDepAPllStatus::PllIsActive), - _ => None, + pub fn set_tow_status(&mut self, tow_status: TowStatus) { + set_bit_range!(&mut self.tow_flags, tow_status, u8, u8, 2, 0); } - } - pub fn set_pll_status(&mut self, pll_status: MsgTrackingStateDetailedDepAPllStatus) { - set_bit_range!(&mut self.track_flags, pll_status, u8, u8, 3, 0); - } - - pub fn tracking_loop_status(&self) -> Option { - match get_bit_range!(self.track_flags, u8, u8, 2, 0) { - 0 => Some(MsgTrackingStateDetailedDepATrackingLoopStatus::NoLocks), - 1 => Some(MsgTrackingStateDetailedDepATrackingLoopStatus::FlldllLock), - 2 => Some(MsgTrackingStateDetailedDepATrackingLoopStatus::PllOptimisticLock), - 3 => Some(MsgTrackingStateDetailedDepATrackingLoopStatus::PllPessimisticLock), - _ => None, + pub fn fll_status(&self) -> Option { + match get_bit_range!(self.track_flags, u8, u8, 4, 0) { + 0 => Some(FllStatus::FllIsInactive), + 1 => Some(FllStatus::FllIsActive), + _ => None, + } } - } - pub fn set_tracking_loop_status( - &mut self, - tracking_loop_status: MsgTrackingStateDetailedDepATrackingLoopStatus, - ) { - set_bit_range!(&mut self.track_flags, tracking_loop_status, u8, u8, 2, 0); - } + pub fn set_fll_status(&mut self, fll_status: FllStatus) { + set_bit_range!(&mut self.track_flags, fll_status, u8, u8, 4, 0); + } - pub fn almanac_availability_status( - &self, - ) -> Option { - match get_bit_range!(self.nav_flags, u8, u8, 4, 0) { - 0 => Some(MsgTrackingStateDetailedDepAAlmanacAvailabilityStatus::AlmanacIsNotAvailable), - 1 => Some(MsgTrackingStateDetailedDepAAlmanacAvailabilityStatus::AlmanacIsAvailable), - _ => None, + pub fn pll_status(&self) -> Option { + match get_bit_range!(self.track_flags, u8, u8, 3, 0) { + 0 => Some(PllStatus::PllIsInactive), + 1 => Some(PllStatus::PllIsActive), + _ => None, + } } - } - pub fn set_almanac_availability_status( - &mut self, - almanac_availability_status: MsgTrackingStateDetailedDepAAlmanacAvailabilityStatus, - ) { - set_bit_range!( - &mut self.nav_flags, - almanac_availability_status, - u8, - u8, - 4, - 0 - ); - } + pub fn set_pll_status(&mut self, pll_status: PllStatus) { + set_bit_range!(&mut self.track_flags, pll_status, u8, u8, 3, 0); + } - pub fn ephemeris_availability_status( - &self, - ) -> Option { - match get_bit_range!(self.nav_flags, u8, u8, 3, 0) { - 0 => Some( - MsgTrackingStateDetailedDepAEphemerisAvailabilityStatus::EphemerisIsNotAvailable, - ), - 1 => { - Some(MsgTrackingStateDetailedDepAEphemerisAvailabilityStatus::EphemerisIsAvailable) + pub fn tracking_loop_status(&self) -> Option { + match get_bit_range!(self.track_flags, u8, u8, 2, 0) { + 0 => Some(TrackingLoopStatus::NoLocks), + 1 => Some(TrackingLoopStatus::FlldllLock), + 2 => Some(TrackingLoopStatus::PllOptimisticLock), + 3 => Some(TrackingLoopStatus::PllPessimisticLock), + _ => None, } - _ => None, } - } - pub fn set_ephemeris_availability_status( - &mut self, - ephemeris_availability_status: MsgTrackingStateDetailedDepAEphemerisAvailabilityStatus, - ) { - set_bit_range!( - &mut self.nav_flags, - ephemeris_availability_status, - u8, - u8, - 3, - 0 - ); - } + pub fn set_tracking_loop_status(&mut self, tracking_loop_status: TrackingLoopStatus) { + set_bit_range!(&mut self.track_flags, tracking_loop_status, u8, u8, 2, 0); + } - pub fn health_status(&self) -> Option { - match get_bit_range!(self.nav_flags, u8, u8, 2, 0) { - 0 => Some(MsgTrackingStateDetailedDepAHealthStatus::HealthIsUnknown), - 1 => Some(MsgTrackingStateDetailedDepAHealthStatus::SignalIsUnhealthy), - 2 => Some(MsgTrackingStateDetailedDepAHealthStatus::SignalIsHealthy), - _ => None, + pub fn almanac_availability_status(&self) -> Option { + match get_bit_range!(self.nav_flags, u8, u8, 4, 0) { + 0 => Some(AlmanacAvailabilityStatus::AlmanacIsNotAvailable), + 1 => Some(AlmanacAvailabilityStatus::AlmanacIsAvailable), + _ => None, + } } - } - pub fn set_health_status(&mut self, health_status: MsgTrackingStateDetailedDepAHealthStatus) { - set_bit_range!(&mut self.nav_flags, health_status, u8, u8, 2, 0); - } + pub fn set_almanac_availability_status( + &mut self, + almanac_availability_status: AlmanacAvailabilityStatus, + ) { + set_bit_range!( + &mut self.nav_flags, + almanac_availability_status, + u8, + u8, + 4, + 0 + ); + } + + pub fn ephemeris_availability_status(&self) -> Option { + match get_bit_range!(self.nav_flags, u8, u8, 3, 0) { + 0 => Some(EphemerisAvailabilityStatus::EphemerisIsNotAvailable), + 1 => Some(EphemerisAvailabilityStatus::EphemerisIsAvailable), + _ => None, + } + } - pub fn parameter_sets(&self) -> Option { - match get_bit_range!(self.pset_flags, u8, u8, 2, 0) { - 0 => Some(MsgTrackingStateDetailedDepAParameterSets::_1MsIntegrationTime), - 1 => Some(MsgTrackingStateDetailedDepAParameterSets::_5MsIntegrationTime), - 2 => Some(MsgTrackingStateDetailedDepAParameterSets::_10MsIntegrationTime), - 3 => Some(MsgTrackingStateDetailedDepAParameterSets::_20MsIntegrationTime), - _ => None, + pub fn set_ephemeris_availability_status( + &mut self, + ephemeris_availability_status: EphemerisAvailabilityStatus, + ) { + set_bit_range!( + &mut self.nav_flags, + ephemeris_availability_status, + u8, + u8, + 3, + 0 + ); + } + + pub fn health_status(&self) -> Option { + match get_bit_range!(self.nav_flags, u8, u8, 2, 0) { + 0 => Some(HealthStatus::HealthIsUnknown), + 1 => Some(HealthStatus::SignalIsUnhealthy), + 2 => Some(HealthStatus::SignalIsHealthy), + _ => None, + } } - } - pub fn set_parameter_sets( - &mut self, - parameter_sets: MsgTrackingStateDetailedDepAParameterSets, - ) { - set_bit_range!(&mut self.pset_flags, parameter_sets, u8, u8, 2, 0); - } + pub fn set_health_status(&mut self, health_status: HealthStatus) { + set_bit_range!(&mut self.nav_flags, health_status, u8, u8, 2, 0); + } - pub fn clock_validity_status(&self) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 5, 0) { - 0 => { - Some(MsgTrackingStateDetailedDepAClockValidityStatus::ClockOffsetAndDriftIsNotValid) + pub fn parameter_sets(&self) -> Option { + match get_bit_range!(self.pset_flags, u8, u8, 2, 0) { + 0 => Some(ParameterSets::_1MsIntegrationTime), + 1 => Some(ParameterSets::_5MsIntegrationTime), + 2 => Some(ParameterSets::_10MsIntegrationTime), + 3 => Some(ParameterSets::_20MsIntegrationTime), + _ => None, } - 1 => Some(MsgTrackingStateDetailedDepAClockValidityStatus::ClockOffsetAndDriftIsValid), - _ => None, } - } - pub fn set_clock_validity_status( - &mut self, - clock_validity_status: MsgTrackingStateDetailedDepAClockValidityStatus, - ) { - set_bit_range!(&mut self.misc_flags, clock_validity_status, u8, u8, 5, 0); - } + pub fn set_parameter_sets(&mut self, parameter_sets: ParameterSets) { + set_bit_range!(&mut self.pset_flags, parameter_sets, u8, u8, 2, 0); + } - pub fn pseudorange_validity_status( - &self, - ) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 4, 0) { - 0 => Some(MsgTrackingStateDetailedDepAPseudorangeValidityStatus::PseudorangeIsNotValid), - 1 => Some(MsgTrackingStateDetailedDepAPseudorangeValidityStatus::PseudorangeIsValid), - _ => None, + pub fn clock_validity_status(&self) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 5, 0) { + 0 => Some(ClockValidityStatus::ClockOffsetAndDriftIsNotValid), + 1 => Some(ClockValidityStatus::ClockOffsetAndDriftIsValid), + _ => None, + } } - } - pub fn set_pseudorange_validity_status( - &mut self, - pseudorange_validity_status: MsgTrackingStateDetailedDepAPseudorangeValidityStatus, - ) { - set_bit_range!( - &mut self.misc_flags, - pseudorange_validity_status, - u8, - u8, - 4, - 0 - ); - } + pub fn set_clock_validity_status(&mut self, clock_validity_status: ClockValidityStatus) { + set_bit_range!(&mut self.misc_flags, clock_validity_status, u8, u8, 5, 0); + } - pub fn acceleration_validity_status( - &self, - ) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 3, 0) { - 0 => { - Some(MsgTrackingStateDetailedDepAAccelerationValidityStatus::AccelerationIsNotValid) + pub fn pseudorange_validity_status(&self) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 4, 0) { + 0 => Some(PseudorangeValidityStatus::PseudorangeIsNotValid), + 1 => Some(PseudorangeValidityStatus::PseudorangeIsValid), + _ => None, } - 1 => Some(MsgTrackingStateDetailedDepAAccelerationValidityStatus::AccelerationIsValid), - _ => None, } - } - pub fn set_acceleration_validity_status( - &mut self, - acceleration_validity_status: MsgTrackingStateDetailedDepAAccelerationValidityStatus, - ) { - set_bit_range!( - &mut self.misc_flags, - acceleration_validity_status, - u8, - u8, - 3, - 0 - ); - } + pub fn set_pseudorange_validity_status( + &mut self, + pseudorange_validity_status: PseudorangeValidityStatus, + ) { + set_bit_range!( + &mut self.misc_flags, + pseudorange_validity_status, + u8, + u8, + 4, + 0 + ); + } + + pub fn acceleration_validity_status(&self) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 3, 0) { + 0 => Some(AccelerationValidityStatus::AccelerationIsNotValid), + 1 => Some(AccelerationValidityStatus::AccelerationIsValid), + _ => None, + } + } - pub fn carrier_half_cycle_ambiguity_status( - &self, - ) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 2, 0) { - 0 => Some(MsgTrackingStateDetailedDepACarrierHalfCycleAmbiguityStatus::Unresolved), - 1 => Some(MsgTrackingStateDetailedDepACarrierHalfCycleAmbiguityStatus::Resolved), - _ => None, + pub fn set_acceleration_validity_status( + &mut self, + acceleration_validity_status: AccelerationValidityStatus, + ) { + set_bit_range!( + &mut self.misc_flags, + acceleration_validity_status, + u8, + u8, + 3, + 0 + ); + } + + pub fn carrier_half_cycle_ambiguity_status( + &self, + ) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 2, 0) { + 0 => Some(CarrierHalfCycleAmbiguityStatus::Unresolved), + 1 => Some(CarrierHalfCycleAmbiguityStatus::Resolved), + _ => None, + } } - } - pub fn set_carrier_half_cycle_ambiguity_status( - &mut self, - carrier_half_cycle_ambiguity_status: MsgTrackingStateDetailedDepACarrierHalfCycleAmbiguityStatus, - ) { - set_bit_range!( - &mut self.misc_flags, - carrier_half_cycle_ambiguity_status, - u8, - u8, - 2, - 0 - ); - } + pub fn set_carrier_half_cycle_ambiguity_status( + &mut self, + carrier_half_cycle_ambiguity_status: CarrierHalfCycleAmbiguityStatus, + ) { + set_bit_range!( + &mut self.misc_flags, + carrier_half_cycle_ambiguity_status, + u8, + u8, + 2, + 0 + ); + } + + pub fn tracking_channel_status(&self) -> Option { + match get_bit_range!(self.misc_flags, u8, u8, 1, 0) { + 0 => Some(TrackingChannelStatus::ReAcquisition), + 1 => Some(TrackingChannelStatus::Running), + _ => None, + } + } - pub fn tracking_channel_status( - &self, - ) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 1, 0) { - 0 => Some(MsgTrackingStateDetailedDepATrackingChannelStatus::ReAcquisition), - 1 => Some(MsgTrackingStateDetailedDepATrackingChannelStatus::Running), - _ => None, + pub fn set_tracking_channel_status( + &mut self, + tracking_channel_status: TrackingChannelStatus, + ) { + set_bit_range!(&mut self.misc_flags, tracking_channel_status, u8, u8, 1, 0); } } - pub fn set_tracking_channel_status( - &mut self, - tracking_channel_status: MsgTrackingStateDetailedDepATrackingChannelStatus, - ) { - set_bit_range!(&mut self.misc_flags, tracking_channel_status, u8, u8, 1, 0); + impl ConcreteMessage for MsgTrackingStateDetailedDepA { + const MESSAGE_TYPE: u16 = 33; + const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE_DETAILED_DEP_A"; } -} - -impl ConcreteMessage for MsgTrackingStateDetailedDepA { - const MESSAGE_TYPE: u16 = 33; - const MESSAGE_NAME: &'static str = "MSG_TRACKING_STATE_DETAILED_DEP_A"; -} -impl SbpMessage for MsgTrackingStateDetailedDepA { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + impl SbpMessage for MsgTrackingStateDetailedDepA { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } -} -impl TryFrom for MsgTrackingStateDetailedDepA { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgTrackingStateDetailedDepA(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgTrackingStateDetailedDepA { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgTrackingStateDetailedDepA(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgTrackingStateDetailedDepA { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.recv_time) - + WireFormat::len(&self.tot) - + WireFormat::len(&self.p) - + WireFormat::len(&self.p_std) - + WireFormat::len(&self.l) - + WireFormat::len(&self.cn0) - + WireFormat::len(&self.lock) - + WireFormat::len(&self.sid) - + WireFormat::len(&self.doppler) - + WireFormat::len(&self.doppler_std) - + WireFormat::len(&self.uptime) - + WireFormat::len(&self.clock_offset) - + WireFormat::len(&self.clock_drift) - + WireFormat::len(&self.corr_spacing) - + WireFormat::len(&self.acceleration) - + WireFormat::len(&self.sync_flags) - + WireFormat::len(&self.tow_flags) - + WireFormat::len(&self.track_flags) - + WireFormat::len(&self.nav_flags) - + WireFormat::len(&self.pset_flags) - + WireFormat::len(&self.misc_flags) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgTrackingStateDetailedDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.recv_time) + + WireFormat::len(&self.tot) + + WireFormat::len(&self.p) + + WireFormat::len(&self.p_std) + + WireFormat::len(&self.l) + + WireFormat::len(&self.cn0) + + WireFormat::len(&self.lock) + + WireFormat::len(&self.sid) + + WireFormat::len(&self.doppler) + + WireFormat::len(&self.doppler_std) + + WireFormat::len(&self.uptime) + + WireFormat::len(&self.clock_offset) + + WireFormat::len(&self.clock_drift) + + WireFormat::len(&self.corr_spacing) + + WireFormat::len(&self.acceleration) + + WireFormat::len(&self.sync_flags) + + WireFormat::len(&self.tow_flags) + + WireFormat::len(&self.track_flags) + + WireFormat::len(&self.nav_flags) + + WireFormat::len(&self.pset_flags) + + WireFormat::len(&self.misc_flags) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Synchronization status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepASynchronizationStatus { - /// No synchronization - NoSynchronization = 0, + /// Synchronization status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum SynchronizationStatus { + /// No synchronization + NoSynchronization = 0, - /// Bit synchronization - BitSynchronization = 1, + /// Bit synchronization + BitSynchronization = 1, - /// Word synchronization (L1 C/A only) - WordSynchronization = 2, + /// Word synchronization (L1 C/A only) + WordSynchronization = 2, - /// Sub-frame synchronization (L1 C/A) / message synchronization (L2C) - SubFrameSynchronizationMessageSynchronization = 3, -} + /// Sub-frame synchronization (L1 C/A) / message synchronization (L2C) + SubFrameSynchronizationMessageSynchronization = 3, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepASynchronizationStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepASynchronizationStatus::NoSynchronization => f.write_str("No synchronization"), - MsgTrackingStateDetailedDepASynchronizationStatus::BitSynchronization => f.write_str("Bit synchronization"), - MsgTrackingStateDetailedDepASynchronizationStatus::WordSynchronization => f.write_str("Word synchronization (L1 C/A only)"), - MsgTrackingStateDetailedDepASynchronizationStatus::SubFrameSynchronizationMessageSynchronization => f.write_str("Sub-frame synchronization (L1 C/A) / message synchronization (L2C) -"), + impl std::fmt::Display for SynchronizationStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SynchronizationStatus::NoSynchronization => f.write_str("No synchronization"), + SynchronizationStatus::BitSynchronization => f.write_str("Bit synchronization"), + SynchronizationStatus::WordSynchronization => { + f.write_str("Word synchronization (L1 C/A only)") + } + SynchronizationStatus::SubFrameSynchronizationMessageSynchronization => f + .write_str( + "Sub-frame synchronization (L1 C/A) / message synchronization (L2C) +", + ), + } } } -} -/// Week number validity status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepAWeekNumberValidityStatus { - /// Week number is not valid - WeekNumberIsNotValid = 0, + /// Week number validity status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum WeekNumberValidityStatus { + /// Week number is not valid + WeekNumberIsNotValid = 0, - /// Week number is valid - WeekNumberIsValid = 1, -} + /// Week number is valid + WeekNumberIsValid = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepAWeekNumberValidityStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepAWeekNumberValidityStatus::WeekNumberIsNotValid => { - f.write_str("Week number is not valid") - } - MsgTrackingStateDetailedDepAWeekNumberValidityStatus::WeekNumberIsValid => { - f.write_str("Week number is valid") + impl std::fmt::Display for WeekNumberValidityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + WeekNumberValidityStatus::WeekNumberIsNotValid => { + f.write_str("Week number is not valid") + } + WeekNumberValidityStatus::WeekNumberIsValid => f.write_str("Week number is valid"), } } } -} -/// TOW status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepATowStatus { - /// TOW is not available - TowIsNotAvailable = 0, + /// TOW status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TowStatus { + /// TOW is not available + TowIsNotAvailable = 0, - /// Decoded TOW is available - DecodedTowIsAvailable = 1, + /// Decoded TOW is available + DecodedTowIsAvailable = 1, - /// Propagated TOW is available - PropagatedTowIsAvailable = 2, -} + /// Propagated TOW is available + PropagatedTowIsAvailable = 2, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepATowStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepATowStatus::TowIsNotAvailable => { - f.write_str("TOW is not available") - } - MsgTrackingStateDetailedDepATowStatus::DecodedTowIsAvailable => { - f.write_str("Decoded TOW is available") - } - MsgTrackingStateDetailedDepATowStatus::PropagatedTowIsAvailable => { - f.write_str("Propagated TOW is available") + impl std::fmt::Display for TowStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TowStatus::TowIsNotAvailable => f.write_str("TOW is not available"), + TowStatus::DecodedTowIsAvailable => f.write_str("Decoded TOW is available"), + TowStatus::PropagatedTowIsAvailable => f.write_str("Propagated TOW is available"), } } } -} -/// FLL status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepAFllStatus { - /// FLL is inactive - FllIsInactive = 0, + /// FLL status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum FllStatus { + /// FLL is inactive + FllIsInactive = 0, - /// FLL is active - FllIsActive = 1, -} + /// FLL is active + FllIsActive = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepAFllStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepAFllStatus::FllIsInactive => f.write_str("FLL is inactive"), - MsgTrackingStateDetailedDepAFllStatus::FllIsActive => f.write_str("FLL is active"), + impl std::fmt::Display for FllStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + FllStatus::FllIsInactive => f.write_str("FLL is inactive"), + FllStatus::FllIsActive => f.write_str("FLL is active"), + } } } -} -/// PLL status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepAPllStatus { - /// PLL is inactive - PllIsInactive = 0, + /// PLL status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum PllStatus { + /// PLL is inactive + PllIsInactive = 0, - /// PLL is active - PllIsActive = 1, -} + /// PLL is active + PllIsActive = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepAPllStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepAPllStatus::PllIsInactive => f.write_str("PLL is inactive"), - MsgTrackingStateDetailedDepAPllStatus::PllIsActive => f.write_str("PLL is active"), + impl std::fmt::Display for PllStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + PllStatus::PllIsInactive => f.write_str("PLL is inactive"), + PllStatus::PllIsActive => f.write_str("PLL is active"), + } } } -} -/// Tracking loop status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepATrackingLoopStatus { - /// No locks - NoLocks = 0, + /// Tracking loop status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TrackingLoopStatus { + /// No locks + NoLocks = 0, - /// FLL/DLL lock - FlldllLock = 1, + /// FLL/DLL lock + FlldllLock = 1, - /// PLL optimistic lock - PllOptimisticLock = 2, + /// PLL optimistic lock + PllOptimisticLock = 2, - /// PLL pessimistic lock - PllPessimisticLock = 3, -} + /// PLL pessimistic lock + PllPessimisticLock = 3, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepATrackingLoopStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepATrackingLoopStatus::NoLocks => f.write_str("No locks"), - MsgTrackingStateDetailedDepATrackingLoopStatus::FlldllLock => { - f.write_str("FLL/DLL lock") - } - MsgTrackingStateDetailedDepATrackingLoopStatus::PllOptimisticLock => { - f.write_str("PLL optimistic lock") - } - MsgTrackingStateDetailedDepATrackingLoopStatus::PllPessimisticLock => { - f.write_str("PLL pessimistic lock") + impl std::fmt::Display for TrackingLoopStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TrackingLoopStatus::NoLocks => f.write_str("No locks"), + TrackingLoopStatus::FlldllLock => f.write_str("FLL/DLL lock"), + TrackingLoopStatus::PllOptimisticLock => f.write_str("PLL optimistic lock"), + TrackingLoopStatus::PllPessimisticLock => f.write_str("PLL pessimistic lock"), } } } -} -/// Almanac availability status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepAAlmanacAvailabilityStatus { - /// Almanac is not available - AlmanacIsNotAvailable = 0, + /// Almanac availability status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum AlmanacAvailabilityStatus { + /// Almanac is not available + AlmanacIsNotAvailable = 0, - /// Almanac is available - AlmanacIsAvailable = 1, -} + /// Almanac is available + AlmanacIsAvailable = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepAAlmanacAvailabilityStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepAAlmanacAvailabilityStatus::AlmanacIsNotAvailable => { - f.write_str("Almanac is not available") - } - MsgTrackingStateDetailedDepAAlmanacAvailabilityStatus::AlmanacIsAvailable => { - f.write_str("Almanac is available") + impl std::fmt::Display for AlmanacAvailabilityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + AlmanacAvailabilityStatus::AlmanacIsNotAvailable => { + f.write_str("Almanac is not available") + } + AlmanacAvailabilityStatus::AlmanacIsAvailable => { + f.write_str("Almanac is available") + } } } } -} -/// Ephemeris availability status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepAEphemerisAvailabilityStatus { - /// Ephemeris is not available - EphemerisIsNotAvailable = 0, + /// Ephemeris availability status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum EphemerisAvailabilityStatus { + /// Ephemeris is not available + EphemerisIsNotAvailable = 0, - /// Ephemeris is available - EphemerisIsAvailable = 1, -} + /// Ephemeris is available + EphemerisIsAvailable = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepAEphemerisAvailabilityStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepAEphemerisAvailabilityStatus::EphemerisIsNotAvailable => { - f.write_str("Ephemeris is not available") - } - MsgTrackingStateDetailedDepAEphemerisAvailabilityStatus::EphemerisIsAvailable => { - f.write_str("Ephemeris is available") + impl std::fmt::Display for EphemerisAvailabilityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + EphemerisAvailabilityStatus::EphemerisIsNotAvailable => { + f.write_str("Ephemeris is not available") + } + EphemerisAvailabilityStatus::EphemerisIsAvailable => { + f.write_str("Ephemeris is available") + } } } } -} -/// Health status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepAHealthStatus { - /// Health is unknown - HealthIsUnknown = 0, + /// Health status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum HealthStatus { + /// Health is unknown + HealthIsUnknown = 0, - /// Signal is unhealthy - SignalIsUnhealthy = 1, + /// Signal is unhealthy + SignalIsUnhealthy = 1, - /// Signal is healthy - SignalIsHealthy = 2, -} + /// Signal is healthy + SignalIsHealthy = 2, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepAHealthStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepAHealthStatus::HealthIsUnknown => { - f.write_str("Health is unknown") - } - MsgTrackingStateDetailedDepAHealthStatus::SignalIsUnhealthy => { - f.write_str("Signal is unhealthy") - } - MsgTrackingStateDetailedDepAHealthStatus::SignalIsHealthy => { - f.write_str("Signal is healthy") + impl std::fmt::Display for HealthStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + HealthStatus::HealthIsUnknown => f.write_str("Health is unknown"), + HealthStatus::SignalIsUnhealthy => f.write_str("Signal is unhealthy"), + HealthStatus::SignalIsHealthy => f.write_str("Signal is healthy"), } } } -} -/// Parameter sets. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepAParameterSets { - /// 1 ms integration time - _1MsIntegrationTime = 0, + /// Parameter sets. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum ParameterSets { + /// 1 ms integration time + _1MsIntegrationTime = 0, - /// 5 ms integration time - _5MsIntegrationTime = 1, + /// 5 ms integration time + _5MsIntegrationTime = 1, - /// 10 ms integration time - _10MsIntegrationTime = 2, + /// 10 ms integration time + _10MsIntegrationTime = 2, - /// 20 ms integration time - _20MsIntegrationTime = 3, -} + /// 20 ms integration time + _20MsIntegrationTime = 3, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepAParameterSets { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepAParameterSets::_1MsIntegrationTime => { - f.write_str("1 ms integration time") - } - MsgTrackingStateDetailedDepAParameterSets::_5MsIntegrationTime => { - f.write_str("5 ms integration time") - } - MsgTrackingStateDetailedDepAParameterSets::_10MsIntegrationTime => { - f.write_str("10 ms integration time") - } - MsgTrackingStateDetailedDepAParameterSets::_20MsIntegrationTime => { - f.write_str("20 ms integration time") + impl std::fmt::Display for ParameterSets { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ParameterSets::_1MsIntegrationTime => f.write_str("1 ms integration time"), + ParameterSets::_5MsIntegrationTime => f.write_str("5 ms integration time"), + ParameterSets::_10MsIntegrationTime => f.write_str("10 ms integration time"), + ParameterSets::_20MsIntegrationTime => f.write_str("20 ms integration time"), } } } -} -/// Clock validity status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepAClockValidityStatus { - /// Clock offset and drift is not valid - ClockOffsetAndDriftIsNotValid = 0, + /// Clock validity status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum ClockValidityStatus { + /// Clock offset and drift is not valid + ClockOffsetAndDriftIsNotValid = 0, - /// Clock offset and drift is valid - ClockOffsetAndDriftIsValid = 1, -} + /// Clock offset and drift is valid + ClockOffsetAndDriftIsValid = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepAClockValidityStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepAClockValidityStatus::ClockOffsetAndDriftIsNotValid => { - f.write_str("Clock offset and drift is not valid") - } - MsgTrackingStateDetailedDepAClockValidityStatus::ClockOffsetAndDriftIsValid => { - f.write_str("Clock offset and drift is valid") + impl std::fmt::Display for ClockValidityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ClockValidityStatus::ClockOffsetAndDriftIsNotValid => { + f.write_str("Clock offset and drift is not valid") + } + ClockValidityStatus::ClockOffsetAndDriftIsValid => { + f.write_str("Clock offset and drift is valid") + } } } } -} -/// Pseudorange validity status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepAPseudorangeValidityStatus { - /// Pseudorange is not valid - PseudorangeIsNotValid = 0, + /// Pseudorange validity status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum PseudorangeValidityStatus { + /// Pseudorange is not valid + PseudorangeIsNotValid = 0, - /// Pseudorange is valid - PseudorangeIsValid = 1, -} + /// Pseudorange is valid + PseudorangeIsValid = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepAPseudorangeValidityStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepAPseudorangeValidityStatus::PseudorangeIsNotValid => { - f.write_str("Pseudorange is not valid") - } - MsgTrackingStateDetailedDepAPseudorangeValidityStatus::PseudorangeIsValid => { - f.write_str("Pseudorange is valid") + impl std::fmt::Display for PseudorangeValidityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + PseudorangeValidityStatus::PseudorangeIsNotValid => { + f.write_str("Pseudorange is not valid") + } + PseudorangeValidityStatus::PseudorangeIsValid => { + f.write_str("Pseudorange is valid") + } } } } -} -/// Acceleration validity status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepAAccelerationValidityStatus { - /// Acceleration is not valid - AccelerationIsNotValid = 0, + /// Acceleration validity status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum AccelerationValidityStatus { + /// Acceleration is not valid + AccelerationIsNotValid = 0, - /// Acceleration is valid - AccelerationIsValid = 1, -} + /// Acceleration is valid + AccelerationIsValid = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepAAccelerationValidityStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepAAccelerationValidityStatus::AccelerationIsNotValid => { - f.write_str("Acceleration is not valid") - } - MsgTrackingStateDetailedDepAAccelerationValidityStatus::AccelerationIsValid => { - f.write_str("Acceleration is valid") + impl std::fmt::Display for AccelerationValidityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + AccelerationValidityStatus::AccelerationIsNotValid => { + f.write_str("Acceleration is not valid") + } + AccelerationValidityStatus::AccelerationIsValid => { + f.write_str("Acceleration is valid") + } } } } -} -/// Carrier half cycle ambiguity status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepACarrierHalfCycleAmbiguityStatus { - /// Unresolved - Unresolved = 0, + /// Carrier half cycle ambiguity status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum CarrierHalfCycleAmbiguityStatus { + /// Unresolved + Unresolved = 0, - /// Resolved - Resolved = 1, -} + /// Resolved + Resolved = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepACarrierHalfCycleAmbiguityStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepACarrierHalfCycleAmbiguityStatus::Unresolved => { - f.write_str("Unresolved") - } - MsgTrackingStateDetailedDepACarrierHalfCycleAmbiguityStatus::Resolved => { - f.write_str("Resolved") + impl std::fmt::Display for CarrierHalfCycleAmbiguityStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + CarrierHalfCycleAmbiguityStatus::Unresolved => f.write_str("Unresolved"), + CarrierHalfCycleAmbiguityStatus::Resolved => f.write_str("Resolved"), } } } -} -/// Tracking channel status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgTrackingStateDetailedDepATrackingChannelStatus { - /// Re-acquisition - ReAcquisition = 0, + /// Tracking channel status. + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TrackingChannelStatus { + /// Re-acquisition + ReAcquisition = 0, - /// Running - Running = 1, -} + /// Running + Running = 1, + } -impl std::fmt::Display for MsgTrackingStateDetailedDepATrackingChannelStatus { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgTrackingStateDetailedDepATrackingChannelStatus::ReAcquisition => { - f.write_str("Re-acquisition") + impl std::fmt::Display for TrackingChannelStatus { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TrackingChannelStatus::ReAcquisition => f.write_str("Re-acquisition"), + TrackingChannelStatus::Running => f.write_str("Running"), } - MsgTrackingStateDetailedDepATrackingChannelStatus::Running => f.write_str("Running"), } } } -/// Measurement Engine signal tracking channel state -/// -/// 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 -/// 28). -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod measurement_state { + #![allow(unused_imports)] -impl WireFormat for MeasurementState { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.mesid) + WireFormat::len(&self.cn0) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.mesid, buf); - WireFormat::write(&self.cn0, buf); + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Measurement Engine signal tracking channel state + /// + /// 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 + /// 28). + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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, } - fn parse_unchecked(buf: &mut B) -> Self { - MeasurementState { - mesid: WireFormat::parse_unchecked(buf), - cn0: WireFormat::parse_unchecked(buf), + + impl WireFormat for MeasurementState { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.mesid) + WireFormat::len(&self.cn0) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.mesid, buf); + WireFormat::write(&self.cn0, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MeasurementState { + mesid: WireFormat::parse_unchecked(buf), + cn0: WireFormat::parse_unchecked(buf), + } } } } -/// Complex correlation structure -/// -/// Structure containing in-phase and quadrature correlation components. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct TrackingChannelCorrelation { - /// In-phase correlation - #[cfg_attr(feature = "serde", serde(rename(serialize = "I")))] - pub i: i16, - /// Quadrature correlation - #[cfg_attr(feature = "serde", serde(rename(serialize = "Q")))] - pub q: i16, -} +pub mod tracking_channel_correlation { + #![allow(unused_imports)] -impl WireFormat for TrackingChannelCorrelation { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.i) + WireFormat::len(&self.q) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.i, buf); - WireFormat::write(&self.q, buf); + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Complex correlation structure + /// + /// Structure containing in-phase and quadrature correlation components. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct TrackingChannelCorrelation { + /// In-phase correlation + #[cfg_attr(feature = "serde", serde(rename(serialize = "I")))] + pub i: i16, + /// Quadrature correlation + #[cfg_attr(feature = "serde", serde(rename(serialize = "Q")))] + pub q: i16, } - fn parse_unchecked(buf: &mut B) -> Self { - TrackingChannelCorrelation { - i: WireFormat::parse_unchecked(buf), - q: WireFormat::parse_unchecked(buf), + + impl WireFormat for TrackingChannelCorrelation { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.i) + WireFormat::len(&self.q) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.i, buf); + WireFormat::write(&self.q, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + TrackingChannelCorrelation { + i: WireFormat::parse_unchecked(buf), + q: WireFormat::parse_unchecked(buf), + } } } } -/// Complex correlation structure -/// -/// Structure containing in-phase and quadrature correlation components. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct TrackingChannelCorrelationDep { - /// In-phase correlation - #[cfg_attr(feature = "serde", serde(rename(serialize = "I")))] - pub i: i32, - /// Quadrature correlation - #[cfg_attr(feature = "serde", serde(rename(serialize = "Q")))] - pub q: i32, -} +pub mod tracking_channel_correlation_dep { + #![allow(unused_imports)] -impl WireFormat for TrackingChannelCorrelationDep { - const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.i) + WireFormat::len(&self.q) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.i, buf); - WireFormat::write(&self.q, buf); + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Complex correlation structure + /// + /// Structure containing in-phase and quadrature correlation components. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct TrackingChannelCorrelationDep { + /// In-phase correlation + #[cfg_attr(feature = "serde", serde(rename(serialize = "I")))] + pub i: i32, + /// Quadrature correlation + #[cfg_attr(feature = "serde", serde(rename(serialize = "Q")))] + pub q: i32, } - fn parse_unchecked(buf: &mut B) -> Self { - TrackingChannelCorrelationDep { - i: WireFormat::parse_unchecked(buf), - q: WireFormat::parse_unchecked(buf), + + impl WireFormat for TrackingChannelCorrelationDep { + const MIN_LEN: usize = ::MIN_LEN + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.i) + WireFormat::len(&self.q) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.i, buf); + WireFormat::write(&self.q, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + TrackingChannelCorrelationDep { + i: WireFormat::parse_unchecked(buf), + q: WireFormat::parse_unchecked(buf), + } } } } -/// Signal tracking channel state -/// -/// Tracking channel state for a specific satellite signal and measured signal -/// power. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod tracking_channel_state { + #![allow(unused_imports)] -impl WireFormat for TrackingChannelState { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.sid) + WireFormat::len(&self.fcn) + WireFormat::len(&self.cn0) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.sid, buf); - WireFormat::write(&self.fcn, buf); - WireFormat::write(&self.cn0, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - TrackingChannelState { - sid: WireFormat::parse_unchecked(buf), - fcn: WireFormat::parse_unchecked(buf), - cn0: WireFormat::parse_unchecked(buf), + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; + + /// Signal tracking channel state + /// + /// Tracking channel state for a specific satellite signal and measured signal + /// power. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 WireFormat for TrackingChannelState { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.sid) + WireFormat::len(&self.fcn) + WireFormat::len(&self.cn0) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.fcn, buf); + WireFormat::write(&self.cn0, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + TrackingChannelState { + sid: WireFormat::parse_unchecked(buf), + fcn: WireFormat::parse_unchecked(buf), + cn0: WireFormat::parse_unchecked(buf), + } } } } -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod tracking_channel_state_dep_a { + #![allow(unused_imports)] -impl TrackingChannelStateDepA { - pub fn tracking_mode(&self) -> Option { - match get_bit_range!(self.state, u8, u8, 1, 0) { - 0 => Some(TrackingChannelStateDepATrackingMode::Disabled), - 1 => Some(TrackingChannelStateDepATrackingMode::Running), - _ => None, - } - } + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; - pub fn set_tracking_mode(&mut self, tracking_mode: TrackingChannelStateDepATrackingMode) { - set_bit_range!(&mut self.state, tracking_mode, u8, u8, 1, 0); + /// Deprecated + /// + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 WireFormat for TrackingChannelStateDepA { - const MIN_LEN: usize = - ::MIN_LEN + ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.state) + WireFormat::len(&self.prn) + WireFormat::len(&self.cn0) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.state, buf); - WireFormat::write(&self.prn, buf); - WireFormat::write(&self.cn0, buf); + impl TrackingChannelStateDepA { + pub fn tracking_mode(&self) -> Option { + match get_bit_range!(self.state, u8, u8, 1, 0) { + 0 => Some(TrackingMode::Disabled), + 1 => Some(TrackingMode::Running), + _ => None, + } + } + + pub fn set_tracking_mode(&mut self, tracking_mode: TrackingMode) { + set_bit_range!(&mut self.state, tracking_mode, u8, u8, 1, 0); + } } - fn parse_unchecked(buf: &mut B) -> Self { - TrackingChannelStateDepA { - state: WireFormat::parse_unchecked(buf), - prn: WireFormat::parse_unchecked(buf), - cn0: WireFormat::parse_unchecked(buf), + + impl WireFormat for TrackingChannelStateDepA { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.state) + WireFormat::len(&self.prn) + WireFormat::len(&self.cn0) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.state, buf); + WireFormat::write(&self.prn, buf); + WireFormat::write(&self.cn0, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + TrackingChannelStateDepA { + state: WireFormat::parse_unchecked(buf), + prn: WireFormat::parse_unchecked(buf), + cn0: WireFormat::parse_unchecked(buf), + } } } -} -/// Tracking mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum TrackingChannelStateDepATrackingMode { - /// Disabled - Disabled = 0, + /// Tracking mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TrackingMode { + /// Disabled + Disabled = 0, - /// Running - Running = 1, -} + /// Running + Running = 1, + } -impl std::fmt::Display for TrackingChannelStateDepATrackingMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - TrackingChannelStateDepATrackingMode::Disabled => f.write_str("Disabled"), - TrackingChannelStateDepATrackingMode::Running => f.write_str("Running"), + impl std::fmt::Display for TrackingMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TrackingMode::Disabled => f.write_str("Disabled"), + TrackingMode::Running => f.write_str("Running"), + } } } } -/// Deprecated -/// -/// Deprecated. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -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, -} +pub mod tracking_channel_state_dep_b { + #![allow(unused_imports)] -impl TrackingChannelStateDepB { - pub fn tracking_mode(&self) -> Option { - match get_bit_range!(self.state, u8, u8, 1, 0) { - 0 => Some(TrackingChannelStateDepBTrackingMode::Disabled), - 1 => Some(TrackingChannelStateDepBTrackingMode::Running), - _ => None, - } - } + use super::*; + use crate::messages::gnss::*; + use crate::messages::lib::*; - pub fn set_tracking_mode(&mut self, tracking_mode: TrackingChannelStateDepBTrackingMode) { - set_bit_range!(&mut self.state, tracking_mode, u8, u8, 1, 0); + /// Deprecated + /// + /// Deprecated. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + 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 WireFormat for TrackingChannelStateDepB { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.state) + WireFormat::len(&self.sid) + WireFormat::len(&self.cn0) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.state, buf); - WireFormat::write(&self.sid, buf); - WireFormat::write(&self.cn0, buf); + impl TrackingChannelStateDepB { + pub fn tracking_mode(&self) -> Option { + match get_bit_range!(self.state, u8, u8, 1, 0) { + 0 => Some(TrackingMode::Disabled), + 1 => Some(TrackingMode::Running), + _ => None, + } + } + + pub fn set_tracking_mode(&mut self, tracking_mode: TrackingMode) { + set_bit_range!(&mut self.state, tracking_mode, u8, u8, 1, 0); + } } - fn parse_unchecked(buf: &mut B) -> Self { - TrackingChannelStateDepB { - state: WireFormat::parse_unchecked(buf), - sid: WireFormat::parse_unchecked(buf), - cn0: WireFormat::parse_unchecked(buf), + + impl WireFormat for TrackingChannelStateDepB { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.state) + WireFormat::len(&self.sid) + WireFormat::len(&self.cn0) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.state, buf); + WireFormat::write(&self.sid, buf); + WireFormat::write(&self.cn0, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + TrackingChannelStateDepB { + state: WireFormat::parse_unchecked(buf), + sid: WireFormat::parse_unchecked(buf), + cn0: WireFormat::parse_unchecked(buf), + } } } -} -/// Tracking mode -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum TrackingChannelStateDepBTrackingMode { - /// Disabled - Disabled = 0, + /// Tracking mode + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TrackingMode { + /// Disabled + Disabled = 0, - /// Running - Running = 1, -} + /// Running + Running = 1, + } -impl std::fmt::Display for TrackingChannelStateDepBTrackingMode { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - TrackingChannelStateDepBTrackingMode::Disabled => f.write_str("Disabled"), - TrackingChannelStateDepBTrackingMode::Running => f.write_str("Running"), + impl std::fmt::Display for TrackingMode { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TrackingMode::Disabled => f.write_str("Disabled"), + TrackingMode::Running => f.write_str("Running"), + } } } } diff --git a/rust/sbp/src/messages/user.rs b/rust/sbp/src/messages/user.rs index fb1c07506e..ee72a4ba8d 100644 --- a/rust/sbp/src/messages/user.rs +++ b/rust/sbp/src/messages/user.rs @@ -13,70 +13,76 @@ // with generate.py. Please do not hand edit! //****************************************************************************/ //! Messages reserved for use by the user. +pub use msg_user_data::MsgUserData; -use super::lib::*; +pub mod msg_user_data { + #![allow(unused_imports)] -/// User data -/// -/// This message can contain any application specific user data up to a -/// maximum length of 255 bytes per message. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgUserData { - /// 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 ConcreteMessage for MsgUserData { - const MESSAGE_TYPE: u16 = 2048; - const MESSAGE_NAME: &'static str = "MSG_USER_DATA"; -} + use super::*; + use crate::messages::lib::*; -impl SbpMessage for MsgUserData { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME - } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE - } - fn sender_id(&self) -> Option { - self.sender_id + /// User data + /// + /// This message can contain any application specific user data up to a + /// maximum length of 255 bytes per message. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgUserData { + /// 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, } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); - } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl ConcreteMessage for MsgUserData { + const MESSAGE_TYPE: u16 = 2048; + const MESSAGE_NAME: &'static str = "MSG_USER_DATA"; } -} -impl TryFrom for MsgUserData { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgUserData(m) => Ok(m), - _ => Err(TryFromSbpError), + impl SbpMessage for MsgUserData { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN } } -} -impl WireFormat for MsgUserData { - const MIN_LEN: usize = as WireFormat>::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.contents) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.contents, buf); + impl TryFrom for MsgUserData { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgUserData(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } - fn parse_unchecked(buf: &mut B) -> Self { - MsgUserData { - sender_id: None, - contents: WireFormat::parse_unchecked(buf), + + impl WireFormat for MsgUserData { + const MIN_LEN: usize = as WireFormat>::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.contents) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.contents, buf); + } + fn parse_unchecked(buf: &mut B) -> 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 13ee68f584..f9f0f803f3 100644 --- a/rust/sbp/src/messages/vehicle.rs +++ b/rust/sbp/src/messages/vehicle.rs @@ -13,419 +13,433 @@ // with generate.py. Please do not hand edit! //****************************************************************************/ //! Messages from a vehicle. +pub use msg_odometry::MsgOdometry; +pub use msg_wheeltick::MsgWheeltick; + +pub mod msg_odometry { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Vehicle forward (x-axis) velocity + /// + /// Message representing the x component of vehicle velocity in the user frame + /// at the odometry reference point(s) specified by the user. The offset for + /// the odometry reference point and the definition and origin of the user + /// frame are defined through the device settings interface. There are 4 + /// possible user-defined sources of this message which are labeled + /// arbitrarily source 0 through 3. If using "processor time" time tags, the + /// receiving end will expect a `MSG_GNSS_TIME_OFFSET` when a PVT fix becomes + /// available to synchronise odometry measurements with GNSS. Processor time + /// shall roll over to zero after one week. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgOdometry { + /// 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 { + pub fn vehicle_metadata(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 6, 5) { + 0 => Some(VehicleMetadata::Unavailable), + 1 => Some(VehicleMetadata::Forward), + 2 => Some(VehicleMetadata::Reverse), + 3 => Some(VehicleMetadata::Park), + _ => None, + } + } -use super::lib::*; - -/// Vehicle forward (x-axis) velocity -/// -/// Message representing the x component of vehicle velocity in the user frame -/// at the odometry reference point(s) specified by the user. The offset for -/// the odometry reference point and the definition and origin of the user -/// frame are defined through the device settings interface. There are 4 -/// possible user-defined sources of this message which are labeled -/// arbitrarily source 0 through 3. If using "processor time" time tags, the -/// receiving end will expect a `MSG_GNSS_TIME_OFFSET` when a PVT fix becomes -/// available to synchronise odometry measurements with GNSS. Processor time -/// shall roll over to zero after one week. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgOdometry { - /// 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 { - pub fn vehicle_metadata(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 6, 5) { - 0 => Some(MsgOdometryVehicleMetadata::Unavailable), - 1 => Some(MsgOdometryVehicleMetadata::Forward), - 2 => Some(MsgOdometryVehicleMetadata::Reverse), - 3 => Some(MsgOdometryVehicleMetadata::Park), - _ => None, + pub fn set_vehicle_metadata(&mut self, vehicle_metadata: VehicleMetadata) { + set_bit_range!(&mut self.flags, vehicle_metadata, u8, u8, 6, 5); } - } - pub fn set_vehicle_metadata(&mut self, vehicle_metadata: MsgOdometryVehicleMetadata) { - set_bit_range!(&mut self.flags, vehicle_metadata, u8, u8, 6, 5); - } + pub fn velocity_source(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 4, 3) { + 0 => Some(VelocitySource::Source0), + 1 => Some(VelocitySource::Source1), + 2 => Some(VelocitySource::Source2), + 3 => Some(VelocitySource::Source3), + _ => None, + } + } - pub fn velocity_source(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(MsgOdometryVelocitySource::Source0), - 1 => Some(MsgOdometryVelocitySource::Source1), - 2 => Some(MsgOdometryVelocitySource::Source2), - 3 => Some(MsgOdometryVelocitySource::Source3), - _ => None, + pub fn set_velocity_source(&mut self, velocity_source: VelocitySource) { + set_bit_range!(&mut self.flags, velocity_source, u8, u8, 4, 3); } - } - pub fn set_velocity_source(&mut self, velocity_source: MsgOdometryVelocitySource) { - set_bit_range!(&mut self.flags, velocity_source, u8, u8, 4, 3); - } + pub fn time_source(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 2, 0) { + 0 => Some(TimeSource::None), + 1 => Some(TimeSource::GpsSolution), + 2 => Some(TimeSource::ProcessorTime), + _ => None, + } + } - pub fn time_source(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(MsgOdometryTimeSource::None), - 1 => Some(MsgOdometryTimeSource::GpsSolution), - 2 => Some(MsgOdometryTimeSource::ProcessorTime), - _ => None, + pub fn set_time_source(&mut self, time_source: TimeSource) { + set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); } } - pub fn set_time_source(&mut self, time_source: MsgOdometryTimeSource) { - set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); + impl ConcreteMessage for MsgOdometry { + const MESSAGE_TYPE: u16 = 2307; + const MESSAGE_NAME: &'static str = "MSG_ODOMETRY"; } -} - -impl ConcreteMessage for MsgOdometry { - const MESSAGE_TYPE: u16 = 2307; - const MESSAGE_NAME: &'static str = "MSG_ODOMETRY"; -} -impl SbpMessage for MsgOdometry { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - fn gps_time(&self) -> Option> { - let tow_s = (self.tow as f64) / 1000.0; - 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(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgOdometry { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + fn gps_time(&self) -> Option> { + let tow_s = (self.tow as f64) / 1000.0; + 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(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgOdometry { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgOdometry(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgOdometry { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgOdometry(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgOdometry { - const MIN_LEN: usize = - ::MIN_LEN + ::MIN_LEN + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.tow) + WireFormat::len(&self.velocity) + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.tow, buf); - WireFormat::write(&self.velocity, buf); - WireFormat::write(&self.flags, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgOdometry { - sender_id: None, - tow: WireFormat::parse_unchecked(buf), - velocity: WireFormat::parse_unchecked(buf), - flags: WireFormat::parse_unchecked(buf), + impl WireFormat for MsgOdometry { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.tow) + + WireFormat::len(&self.velocity) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.tow, buf); + WireFormat::write(&self.velocity, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgOdometry { + sender_id: None, + tow: WireFormat::parse_unchecked(buf), + velocity: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } -} -/// Vehicle Metadata -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgOdometryVehicleMetadata { - /// Unavailable - Unavailable = 0, + /// Vehicle Metadata + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum VehicleMetadata { + /// Unavailable + Unavailable = 0, - /// Forward - Forward = 1, + /// Forward + Forward = 1, - /// Reverse - Reverse = 2, + /// Reverse + Reverse = 2, - /// Park - Park = 3, -} + /// Park + Park = 3, + } -impl std::fmt::Display for MsgOdometryVehicleMetadata { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgOdometryVehicleMetadata::Unavailable => f.write_str("Unavailable"), - MsgOdometryVehicleMetadata::Forward => f.write_str("Forward"), - MsgOdometryVehicleMetadata::Reverse => f.write_str("Reverse"), - MsgOdometryVehicleMetadata::Park => f.write_str("Park"), + impl std::fmt::Display for VehicleMetadata { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + VehicleMetadata::Unavailable => f.write_str("Unavailable"), + VehicleMetadata::Forward => f.write_str("Forward"), + VehicleMetadata::Reverse => f.write_str("Reverse"), + VehicleMetadata::Park => f.write_str("Park"), + } } } -} -/// Velocity Source -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgOdometryVelocitySource { - /// Source 0 - Source0 = 0, + /// Velocity Source + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum VelocitySource { + /// Source 0 + Source0 = 0, - /// Source 1 - Source1 = 1, + /// Source 1 + Source1 = 1, - /// Source 2 - Source2 = 2, + /// Source 2 + Source2 = 2, - /// Source 3 - Source3 = 3, -} + /// Source 3 + Source3 = 3, + } -impl std::fmt::Display for MsgOdometryVelocitySource { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgOdometryVelocitySource::Source0 => f.write_str("Source 0"), - MsgOdometryVelocitySource::Source1 => f.write_str("Source 1"), - MsgOdometryVelocitySource::Source2 => f.write_str("Source 2"), - MsgOdometryVelocitySource::Source3 => f.write_str("Source 3"), + impl std::fmt::Display for VelocitySource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + VelocitySource::Source0 => f.write_str("Source 0"), + VelocitySource::Source1 => f.write_str("Source 1"), + VelocitySource::Source2 => f.write_str("Source 2"), + VelocitySource::Source3 => f.write_str("Source 3"), + } } } -} -/// Time source -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgOdometryTimeSource { - /// None (invalid) - None = 0, + /// Time source + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum TimeSource { + /// None (invalid) + None = 0, - /// GPS Solution (ms in week) - GpsSolution = 1, + /// GPS Solution (ms in week) + GpsSolution = 1, - /// Processor Time - ProcessorTime = 2, -} + /// Processor Time + ProcessorTime = 2, + } -impl std::fmt::Display for MsgOdometryTimeSource { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgOdometryTimeSource::None => f.write_str("None (invalid)"), - MsgOdometryTimeSource::GpsSolution => f.write_str("GPS Solution (ms in week)"), - MsgOdometryTimeSource::ProcessorTime => f.write_str("Processor Time"), + impl std::fmt::Display for TimeSource { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TimeSource::None => f.write_str("None (invalid)"), + TimeSource::GpsSolution => f.write_str("GPS Solution (ms in week)"), + TimeSource::ProcessorTime => f.write_str("Processor Time"), + } } } } -/// Accumulated wheeltick count message -/// -/// Message containing the accumulated distance travelled by a wheel located -/// at an odometry reference point defined by the user. The offset for the -/// odometry reference point and the definition and origin of the user frame -/// are defined through the device settings interface. The source of this -/// message is identified by the source field, which is an integer ranging -/// from 0 to 255. The timestamp associated with this message should represent -/// the time when the accumulated tick count reached the value given by the -/// contents of this message as accurately as possible. If using "local CPU -/// time" time tags, the receiving end will expect a `MSG_GNSS_TIME_OFFSET` -/// 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 = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgWheeltick { - /// 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, -} +pub mod msg_wheeltick { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Accumulated wheeltick count message + /// + /// Message containing the accumulated distance travelled by a wheel located + /// at an odometry reference point defined by the user. The offset for the + /// odometry reference point and the definition and origin of the user frame + /// are defined through the device settings interface. The source of this + /// message is identified by the source field, which is an integer ranging + /// from 0 to 255. The timestamp associated with this message should represent + /// the time when the accumulated tick count reached the value given by the + /// contents of this message as accurately as possible. If using "local CPU + /// time" time tags, the receiving end will expect a `MSG_GNSS_TIME_OFFSET` + /// 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 = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgWheeltick { + /// 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 { + pub fn vehicle_metadata(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 3, 2) { + 0 => Some(VehicleMetadata::Unavailable), + 1 => Some(VehicleMetadata::Forward), + 2 => Some(VehicleMetadata::Reverse), + 3 => Some(VehicleMetadata::Park), + _ => None, + } + } -impl MsgWheeltick { - pub fn vehicle_metadata(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 2) { - 0 => Some(MsgWheeltickVehicleMetadata::Unavailable), - 1 => Some(MsgWheeltickVehicleMetadata::Forward), - 2 => Some(MsgWheeltickVehicleMetadata::Reverse), - 3 => Some(MsgWheeltickVehicleMetadata::Park), - _ => None, + pub fn set_vehicle_metadata(&mut self, vehicle_metadata: VehicleMetadata) { + set_bit_range!(&mut self.flags, vehicle_metadata, u8, u8, 3, 2); } - } - pub fn set_vehicle_metadata(&mut self, vehicle_metadata: MsgWheeltickVehicleMetadata) { - set_bit_range!(&mut self.flags, vehicle_metadata, u8, u8, 3, 2); - } + pub fn synchronization_type(&self) -> Option { + match get_bit_range!(self.flags, u8, u8, 1, 0) { + 0 => Some(SynchronizationType::MicrosecondsSinceLastPps), + 1 => Some(SynchronizationType::MicrosecondsInGpsWeek), + 2 => Some(SynchronizationType::LocalCpuTimeInNominalMicroseconds), + _ => None, + } + } - pub fn synchronization_type(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 1, 0) { - 0 => Some(MsgWheeltickSynchronizationType::MicrosecondsSinceLastPps), - 1 => Some(MsgWheeltickSynchronizationType::MicrosecondsInGpsWeek), - 2 => Some(MsgWheeltickSynchronizationType::LocalCpuTimeInNominalMicroseconds), - _ => None, + pub fn set_synchronization_type(&mut self, synchronization_type: SynchronizationType) { + set_bit_range!(&mut self.flags, synchronization_type, u8, u8, 1, 0); } } - pub fn set_synchronization_type( - &mut self, - synchronization_type: MsgWheeltickSynchronizationType, - ) { - set_bit_range!(&mut self.flags, synchronization_type, u8, u8, 1, 0); + impl ConcreteMessage for MsgWheeltick { + const MESSAGE_TYPE: u16 = 2308; + const MESSAGE_NAME: &'static str = "MSG_WHEELTICK"; } -} -impl ConcreteMessage for MsgWheeltick { - const MESSAGE_TYPE: u16 = 2308; - const MESSAGE_NAME: &'static str = "MSG_WHEELTICK"; -} - -impl SbpMessage for MsgWheeltick { - 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 encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN - } - #[cfg(feature = "swiftnav")] - 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 time::GpsTime::new(0, tow_s) { - Ok(gps_time) => gps_time.tow(), - Err(e) => return Some(Err(e.into())), - }; - Some(Ok(time::MessageTime::Rover(gps_time.into()))) + impl SbpMessage for MsgWheeltick { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } + #[cfg(feature = "swiftnav")] + 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 time::GpsTime::new(0, tow_s) { + Ok(gps_time) => gps_time.tow(), + Err(e) => return Some(Err(e.into())), + }; + Some(Ok(time::MessageTime::Rover(gps_time.into()))) + } } -} -impl TryFrom for MsgWheeltick { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgWheeltick(m) => Ok(m), - _ => Err(TryFromSbpError), + impl TryFrom for MsgWheeltick { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgWheeltick(m) => Ok(m), + _ => Err(TryFromSbpError), + } } } -} -impl WireFormat for MsgWheeltick { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.time) - + WireFormat::len(&self.flags) - + WireFormat::len(&self.source) - + WireFormat::len(&self.ticks) - } - fn write(&self, buf: &mut B) { - 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 B) -> 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), + impl WireFormat for MsgWheeltick { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.time) + + WireFormat::len(&self.flags) + + WireFormat::len(&self.source) + + WireFormat::len(&self.ticks) + } + fn write(&self, buf: &mut B) { + 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 B) -> 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), + } } } -} -/// Vehicle Metadata -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgWheeltickVehicleMetadata { - /// Unavailable - Unavailable = 0, + /// Vehicle Metadata + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum VehicleMetadata { + /// Unavailable + Unavailable = 0, - /// Forward - Forward = 1, + /// Forward + Forward = 1, - /// Reverse - Reverse = 2, + /// Reverse + Reverse = 2, - /// Park - Park = 3, -} + /// Park + Park = 3, + } -impl std::fmt::Display for MsgWheeltickVehicleMetadata { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgWheeltickVehicleMetadata::Unavailable => f.write_str("Unavailable"), - MsgWheeltickVehicleMetadata::Forward => f.write_str("Forward"), - MsgWheeltickVehicleMetadata::Reverse => f.write_str("Reverse"), - MsgWheeltickVehicleMetadata::Park => f.write_str("Park"), + impl std::fmt::Display for VehicleMetadata { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + VehicleMetadata::Unavailable => f.write_str("Unavailable"), + VehicleMetadata::Forward => f.write_str("Forward"), + VehicleMetadata::Reverse => f.write_str("Reverse"), + VehicleMetadata::Park => f.write_str("Park"), + } } } -} -/// Synchronization type -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum MsgWheeltickSynchronizationType { - /// microseconds since last PPS - MicrosecondsSinceLastPps = 0, + /// Synchronization type + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + pub enum SynchronizationType { + /// microseconds since last PPS + MicrosecondsSinceLastPps = 0, - /// microseconds in GPS week - MicrosecondsInGpsWeek = 1, + /// microseconds in GPS week + MicrosecondsInGpsWeek = 1, - /// local CPU time in nominal microseconds - LocalCpuTimeInNominalMicroseconds = 2, -} + /// local CPU time in nominal microseconds + LocalCpuTimeInNominalMicroseconds = 2, + } -impl std::fmt::Display for MsgWheeltickSynchronizationType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - MsgWheeltickSynchronizationType::MicrosecondsSinceLastPps => { - f.write_str("microseconds since last PPS") - } - MsgWheeltickSynchronizationType::MicrosecondsInGpsWeek => { - f.write_str("microseconds in GPS week") - } - MsgWheeltickSynchronizationType::LocalCpuTimeInNominalMicroseconds => { - f.write_str("local CPU time in nominal microseconds") + impl std::fmt::Display for SynchronizationType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SynchronizationType::MicrosecondsSinceLastPps => { + f.write_str("microseconds since last PPS") + } + SynchronizationType::MicrosecondsInGpsWeek => { + f.write_str("microseconds in GPS week") + } + SynchronizationType::LocalCpuTimeInNominalMicroseconds => { + f.write_str("local CPU time in nominal microseconds") + } } } } From 06952f4e72c50907c5dc9479b3fdf0ec4ba336c7 Mon Sep 17 00:00:00 2001 From: Steve Meyer Date: Thu, 6 Jan 2022 17:03:29 -0800 Subject: [PATCH 05/13] add TryFrom/Hash impls --- .../resources/rust/sbp_messages_mod.rs | 14 +- .../resources/rust/sbp_messages_template.rs | 21 +- rust/sbp/src/messages/ext_events.rs | 38 +- rust/sbp/src/messages/flash.rs | 103 +- rust/sbp/src/messages/gnss.rs | 68 +- rust/sbp/src/messages/imu.rs | 90 +- rust/sbp/src/messages/linux.rs | 57 +- rust/sbp/src/messages/logging.rs | 31 +- rust/sbp/src/messages/mod.rs | 14 +- rust/sbp/src/messages/navigation.rs | 1570 +++++++++++------ rust/sbp/src/messages/ndb.rs | 116 +- rust/sbp/src/messages/observation.rs | 190 +- rust/sbp/src/messages/orientation.rs | 80 +- rust/sbp/src/messages/piksi.rs | 116 +- rust/sbp/src/messages/settings.rs | 56 +- rust/sbp/src/messages/solution_meta.rs | 251 ++- rust/sbp/src/messages/ssr.rs | 55 +- rust/sbp/src/messages/system.rs | 430 +++-- rust/sbp/src/messages/tracking.rs | 680 ++++--- rust/sbp/src/messages/vehicle.rs | 111 +- 20 files changed, 2730 insertions(+), 1361 deletions(-) diff --git a/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs b/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs index 66cbbb30ab..fa3cb4d4b0 100644 --- a/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs +++ b/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs @@ -33,7 +33,7 @@ mod lib { pub use crate::time; pub use crate::wire_format::{PayloadParseError, WireFormat}; - pub use super::{ConcreteMessage, Sbp, SbpMessage, TryFromSbpError}; + pub use super::{ConcreteMessage, Sbp, SbpMessage, TryFromSbpError, TryFromIntError}; pub use bytes::{Buf, BufMut}; @@ -105,6 +105,18 @@ impl std::fmt::Display for TryFromSbpError { impl std::error::Error for TryFromSbpError {} +/// The error returned when using [TryFrom] to convert an invalid integer to a bitfield type. +#[derive(Debug, Clone)] +pub struct TryFromIntError; + +impl std::fmt::Display for TryFromIntError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "int does not match any bitfield values") + } +} + +impl std::error::Error for TryFromIntError {} + /// Represents any SBP message. #[cfg_attr(feature = "serde", derive(serde::Serialize), serde(untagged))] #[derive(Debug, Clone)] diff --git a/generator/sbpg/targets/resources/rust/sbp_messages_template.rs b/generator/sbpg/targets/resources/rust/sbp_messages_template.rs index cb4b22d297..76677bf1b9 100644 --- a/generator/sbpg/targets/resources/rust/sbp_messages_template.rs +++ b/generator/sbpg/targets/resources/rust/sbp_messages_template.rs @@ -67,12 +67,7 @@ impl (((m.msg_name))) { ((* if b.vals|length > 0 *)) pub fn (((b.field_name))) (&self) -> Option<(((b.type_name)))> { - match get_bit_range!( self.(((b.field))), (((f.type))), (((b.type))), (((b.msb))), (((b.lsb))) ) { - ((*- for v in b.vals *)) - (((v.value))) => Some( (((b.type_name))) :: (((v.name))) ), - ((*- endfor *)) - _ => None, - } + get_bit_range!( self.(((b.field))), (((f.type))), (((b.type))), (((b.msb))), (((b.lsb))) ).try_into().ok() } pub fn set_(((b.field_name))) (&mut self, (((b.field_name))): (((b.type_name)))) { @@ -177,7 +172,7 @@ impl WireFormat for (((m.msg_name))) { ((*- if b.desc *)) /// (((b.desc | commentify))) ((*- endif *)) -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum (((b.type_name))) { ((* for v in b.vals *)) /// (((v.desc | commentify(indent=2) ))) @@ -194,6 +189,18 @@ impl std::fmt::Display for (((b.type_name))) { } } } + +impl TryFrom<(((b.type)))> for (((b.type_name))) { + type Error = TryFromIntError; + fn try_from(i: (((b.type))) ) -> Result { + match i { + ((*- for v in b.vals *)) + (((v.value))) => Ok( (((b.type_name))) :: (((v.name))) ), + ((*- endfor *)) + _ => Err(TryFromIntError), + } + } +} ((* endif *)) ((* endfor *)) ((* endfor *)) diff --git a/rust/sbp/src/messages/ext_events.rs b/rust/sbp/src/messages/ext_events.rs index 9afa215cbf..42806d4d46 100644 --- a/rust/sbp/src/messages/ext_events.rs +++ b/rust/sbp/src/messages/ext_events.rs @@ -53,11 +53,7 @@ pub mod msg_ext_event { impl MsgExtEvent { pub fn time_quality(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 1, 0) { - 0 => Some(TimeQuality::UnknownDontHaveNavSolution), - 1 => Some(TimeQuality::Good), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() } pub fn set_time_quality(&mut self, time_quality: TimeQuality) { @@ -65,11 +61,7 @@ pub mod msg_ext_event { } pub fn new_level_of_pin(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 0, 0) { - 0 => Some(NewLevelOfPin::Low), - 1 => Some(NewLevelOfPin::High), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 0, 0).try_into().ok() } pub fn set_new_level_of_pin(&mut self, new_level_of_pin: NewLevelOfPin) { @@ -157,7 +149,7 @@ pub mod msg_ext_event { } /// Time quality - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TimeQuality { /// Unknown - don't have nav solution UnknownDontHaveNavSolution = 0, @@ -177,8 +169,19 @@ pub mod msg_ext_event { } } + impl TryFrom for TimeQuality { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TimeQuality::UnknownDontHaveNavSolution), + 1 => Ok(TimeQuality::Good), + _ => Err(TryFromIntError), + } + } + } + /// New level of pin - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum NewLevelOfPin { /// Low (falling edge) Low = 0, @@ -195,4 +198,15 @@ pub mod msg_ext_event { } } } + + impl TryFrom for NewLevelOfPin { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(NewLevelOfPin::Low), + 1 => Ok(NewLevelOfPin::High), + _ => Err(TryFromIntError), + } + } + } } diff --git a/rust/sbp/src/messages/flash.rs b/rust/sbp/src/messages/flash.rs index 43432e3760..c18bcac168 100644 --- a/rust/sbp/src/messages/flash.rs +++ b/rust/sbp/src/messages/flash.rs @@ -53,15 +53,7 @@ pub mod msg_flash_done { impl MsgFlashDone { pub fn response_code(&self) -> Option { - match get_bit_range!(self.response, u8, u8, 2, 0) { - 0 => Some(ResponseCode::FlashOk), - 1 => Some(ResponseCode::FlashInvalidFlash), - 2 => Some(ResponseCode::FlashInvalidLen), - 3 => Some(ResponseCode::FlashInvalidAddr), - 4 => Some(ResponseCode::FlashInvalidRange), - 5 => Some(ResponseCode::FlashInvalidSector), - _ => None, - } + get_bit_range!(self.response, u8, u8, 2, 0).try_into().ok() } pub fn set_response_code(&mut self, response_code: ResponseCode) { @@ -119,7 +111,7 @@ pub mod msg_flash_done { } /// Response code - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ResponseCode { /// FLASH_OK FlashOk = 0, @@ -152,6 +144,21 @@ pub mod msg_flash_done { } } } + + impl TryFrom for ResponseCode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(ResponseCode::FlashOk), + 1 => Ok(ResponseCode::FlashInvalidFlash), + 2 => Ok(ResponseCode::FlashInvalidLen), + 3 => Ok(ResponseCode::FlashInvalidAddr), + 4 => Ok(ResponseCode::FlashInvalidRange), + 5 => Ok(ResponseCode::FlashInvalidSector), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_flash_erase { @@ -183,11 +190,7 @@ pub mod msg_flash_erase { impl MsgFlashErase { pub fn flash_target_to_read(&self) -> Option { - match get_bit_range!(self.target, u8, u8, 0, 0) { - 0 => Some(FlashTargetToRead::FlashStm), - 1 => Some(FlashTargetToRead::FlashM25), - _ => None, - } + get_bit_range!(self.target, u8, u8, 0, 0).try_into().ok() } pub fn set_flash_target_to_read(&mut self, flash_target_to_read: FlashTargetToRead) { @@ -247,7 +250,7 @@ pub mod msg_flash_erase { } /// Flash target to read - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FlashTargetToRead { /// FLASH_STM FlashStm = 0, @@ -264,6 +267,17 @@ pub mod msg_flash_erase { } } } + + impl TryFrom for FlashTargetToRead { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FlashTargetToRead::FlashStm), + 1 => Ok(FlashTargetToRead::FlashM25), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_flash_program { @@ -302,11 +316,7 @@ pub mod msg_flash_program { impl MsgFlashProgram { pub fn flash_target_to_read(&self) -> Option { - match get_bit_range!(self.target, u8, u8, 0, 0) { - 0 => Some(FlashTargetToRead::FlashStm), - 1 => Some(FlashTargetToRead::FlashM25), - _ => None, - } + get_bit_range!(self.target, u8, u8, 0, 0).try_into().ok() } pub fn set_flash_target_to_read(&mut self, flash_target_to_read: FlashTargetToRead) { @@ -376,7 +386,7 @@ pub mod msg_flash_program { } /// Flash target to read - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FlashTargetToRead { /// FLASH_STM FlashStm = 0, @@ -393,6 +403,17 @@ pub mod msg_flash_program { } } } + + impl TryFrom for FlashTargetToRead { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FlashTargetToRead::FlashStm), + 1 => Ok(FlashTargetToRead::FlashM25), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_flash_read_req { @@ -429,11 +450,7 @@ pub mod msg_flash_read_req { impl MsgFlashReadReq { pub fn flash_target_to_read(&self) -> Option { - match get_bit_range!(self.target, u8, u8, 0, 0) { - 0 => Some(FlashTargetToRead::FlashStm), - 1 => Some(FlashTargetToRead::FlashM25), - _ => None, - } + get_bit_range!(self.target, u8, u8, 0, 0).try_into().ok() } pub fn set_flash_target_to_read(&mut self, flash_target_to_read: FlashTargetToRead) { @@ -499,7 +516,7 @@ pub mod msg_flash_read_req { } /// Flash target to read - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FlashTargetToRead { /// FLASH_STM FlashStm = 0, @@ -516,6 +533,17 @@ pub mod msg_flash_read_req { } } } + + impl TryFrom for FlashTargetToRead { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FlashTargetToRead::FlashStm), + 1 => Ok(FlashTargetToRead::FlashM25), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_flash_read_resp { @@ -552,11 +580,7 @@ pub mod msg_flash_read_resp { impl MsgFlashReadResp { pub fn flash_target_to_read(&self) -> Option { - match get_bit_range!(self.target, u8, u8, 0, 0) { - 0 => Some(FlashTargetToRead::FlashStm), - 1 => Some(FlashTargetToRead::FlashM25), - _ => None, - } + get_bit_range!(self.target, u8, u8, 0, 0).try_into().ok() } pub fn set_flash_target_to_read(&mut self, flash_target_to_read: FlashTargetToRead) { @@ -622,7 +646,7 @@ pub mod msg_flash_read_resp { } /// Flash target to read - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FlashTargetToRead { /// FLASH_STM FlashStm = 0, @@ -639,6 +663,17 @@ pub mod msg_flash_read_resp { } } } + + impl TryFrom for FlashTargetToRead { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FlashTargetToRead::FlashStm), + 1 => Ok(FlashTargetToRead::FlashM25), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_m25_flash_write_status { diff --git a/rust/sbp/src/messages/gnss.rs b/rust/sbp/src/messages/gnss.rs index 381e0d8af5..25657da5e0 100644 --- a/rust/sbp/src/messages/gnss.rs +++ b/rust/sbp/src/messages/gnss.rs @@ -218,21 +218,7 @@ pub mod gnss_signal { impl GnssSignal { pub fn code(&self) -> Option { - match get_bit_range!(self.code, u8, u8, 7, 0) { - 0 => Some(Code::GpsL1Ca), - 1 => Some(Code::GpsL2Cm), - 2 => Some(Code::SbasL1Ca), - 3 => Some(Code::GloL1Ca), - 4 => Some(Code::GloL2Ca), - 5 => Some(Code::GpsL1P), - 6 => Some(Code::GpsL2P), - 12 => Some(Code::Bds2B1), - 13 => Some(Code::Bds2B2), - 14 => Some(Code::GalE1B), - 20 => Some(Code::GalE7I), - 47 => Some(Code::Bds3B2A), - _ => None, - } + get_bit_range!(self.code, u8, u8, 7, 0).try_into().ok() } pub fn set_code(&mut self, code: Code) { @@ -257,7 +243,7 @@ pub mod gnss_signal { } } - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Code { /// GPS L1CA GpsL1Ca = 0, @@ -314,6 +300,27 @@ pub mod gnss_signal { } } } + + impl TryFrom for Code { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(Code::GpsL1Ca), + 1 => Ok(Code::GpsL2Cm), + 2 => Ok(Code::SbasL1Ca), + 3 => Ok(Code::GloL1Ca), + 4 => Ok(Code::GloL2Ca), + 5 => Ok(Code::GpsL1P), + 6 => Ok(Code::GpsL2P), + 12 => Ok(Code::Bds2B1), + 13 => Ok(Code::Bds2B2), + 14 => Ok(Code::GalE1B), + 20 => Ok(Code::GalE7I), + 47 => Ok(Code::Bds3B2A), + _ => Err(TryFromIntError), + } + } + } } pub mod gnss_signal_dep { @@ -345,16 +352,7 @@ pub mod gnss_signal_dep { impl GnssSignalDep { pub fn code(&self) -> Option { - match get_bit_range!(self.code, u8, u8, 7, 0) { - 0 => Some(Code::GpsL1Ca), - 1 => Some(Code::GpsL2Cm), - 2 => Some(Code::SbasL1Ca), - 3 => Some(Code::GloL1Ca), - 4 => Some(Code::GloL2Ca), - 5 => Some(Code::GpsL1P), - 6 => Some(Code::GpsL2P), - _ => None, - } + get_bit_range!(self.code, u8, u8, 7, 0).try_into().ok() } pub fn set_code(&mut self, code: Code) { @@ -385,7 +383,7 @@ pub mod gnss_signal_dep { } } - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Code { /// GPS L1CA GpsL1Ca = 0, @@ -422,6 +420,22 @@ pub mod gnss_signal_dep { } } } + + impl TryFrom for Code { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(Code::GpsL1Ca), + 1 => Ok(Code::GpsL2Cm), + 2 => Ok(Code::SbasL1Ca), + 3 => Ok(Code::GloL1Ca), + 4 => Ok(Code::GloL2Ca), + 5 => Ok(Code::GpsL1P), + 6 => Ok(Code::GpsL2P), + _ => Err(TryFromIntError), + } + } + } } pub mod sv_id { diff --git a/rust/sbp/src/messages/imu.rs b/rust/sbp/src/messages/imu.rs index 86b1788d3e..ca508d9856 100644 --- a/rust/sbp/src/messages/imu.rs +++ b/rust/sbp/src/messages/imu.rs @@ -47,11 +47,7 @@ pub mod msg_imu_aux { impl MsgImuAux { pub fn imu_type(&self) -> Option { - match get_bit_range!(self.imu_type, u8, u8, 7, 0) { - 0 => Some(ImuType::BoschBmi160), - 1 => Some(ImuType::StMicroelectronicsAsm330Llh), - _ => None, - } + get_bit_range!(self.imu_type, u8, u8, 7, 0).try_into().ok() } pub fn set_imu_type(&mut self, imu_type: ImuType) { @@ -59,14 +55,7 @@ pub mod msg_imu_aux { } pub fn gyroscope_range(&self) -> Option { - match get_bit_range!(self.imu_conf, u8, u8, 7, 4) { - 0 => Some(GyroscopeRange::_2000DegS), - 1 => Some(GyroscopeRange::_1000DegS), - 2 => Some(GyroscopeRange::_500DegS), - 3 => Some(GyroscopeRange::_250DegS), - 4 => Some(GyroscopeRange::_125DegS), - _ => None, - } + get_bit_range!(self.imu_conf, u8, u8, 7, 4).try_into().ok() } pub fn set_gyroscope_range(&mut self, gyroscope_range: GyroscopeRange) { @@ -74,13 +63,7 @@ pub mod msg_imu_aux { } pub fn accelerometer_range(&self) -> Option { - match get_bit_range!(self.imu_conf, u8, u8, 3, 0) { - 0 => Some(AccelerometerRange::_2G), - 1 => Some(AccelerometerRange::_4G), - 2 => Some(AccelerometerRange::_8G), - 3 => Some(AccelerometerRange::_16G), - _ => None, - } + get_bit_range!(self.imu_conf, u8, u8, 3, 0).try_into().ok() } pub fn set_accelerometer_range(&mut self, accelerometer_range: AccelerometerRange) { @@ -146,7 +129,7 @@ pub mod msg_imu_aux { } /// IMU Type - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ImuType { /// Bosch BMI160 BoschBmi160 = 0, @@ -166,8 +149,19 @@ pub mod msg_imu_aux { } } + impl TryFrom for ImuType { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(ImuType::BoschBmi160), + 1 => Ok(ImuType::StMicroelectronicsAsm330Llh), + _ => Err(TryFromIntError), + } + } + } + /// Gyroscope Range - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum GyroscopeRange { /// +/- 2000 deg / s _2000DegS = 0, @@ -197,8 +191,22 @@ pub mod msg_imu_aux { } } + impl TryFrom for GyroscopeRange { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(GyroscopeRange::_2000DegS), + 1 => Ok(GyroscopeRange::_1000DegS), + 2 => Ok(GyroscopeRange::_500DegS), + 3 => Ok(GyroscopeRange::_250DegS), + 4 => Ok(GyroscopeRange::_125DegS), + _ => Err(TryFromIntError), + } + } + } + /// Accelerometer Range - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum AccelerometerRange { /// +/- 2g _2G = 0, @@ -223,6 +231,19 @@ pub mod msg_imu_aux { } } } + + impl TryFrom for AccelerometerRange { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(AccelerometerRange::_2G), + 1 => Ok(AccelerometerRange::_4G), + 2 => Ok(AccelerometerRange::_8G), + 3 => Ok(AccelerometerRange::_16G), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_imu_raw { @@ -278,13 +299,7 @@ pub mod msg_imu_raw { impl MsgImuRaw { pub fn time_status(&self) -> Option { - match get_bit_range!(self.tow, u32, u8, 31, 30) { - 0 => Some(TimeStatus::ReferenceEpochIsStartOfCurrentGpsWeek), - 1 => Some(TimeStatus::ReferenceEpochIsTimeOfSystemStartup), - 2 => Some(TimeStatus::ReferenceEpochIsUnknown), - 3 => Some(TimeStatus::ReferenceEpochIsLastPps), - _ => None, - } + get_bit_range!(self.tow, u32, u8, 31, 30).try_into().ok() } pub fn set_time_status(&mut self, time_status: TimeStatus) { @@ -401,7 +416,7 @@ pub mod msg_imu_raw { } /// Time status - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TimeStatus { /// Reference epoch is start of current GPS week ReferenceEpochIsStartOfCurrentGpsWeek = 0, @@ -430,4 +445,17 @@ pub mod msg_imu_raw { } } } + + impl TryFrom for TimeStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TimeStatus::ReferenceEpochIsStartOfCurrentGpsWeek), + 1 => Ok(TimeStatus::ReferenceEpochIsTimeOfSystemStartup), + 2 => Ok(TimeStatus::ReferenceEpochIsUnknown), + 3 => Ok(TimeStatus::ReferenceEpochIsLastPps), + _ => Err(TryFromIntError), + } + } + } } diff --git a/rust/sbp/src/messages/linux.rs b/rust/sbp/src/messages/linux.rs index dc359f041b..88b2ee1f4c 100644 --- a/rust/sbp/src/messages/linux.rs +++ b/rust/sbp/src/messages/linux.rs @@ -67,11 +67,7 @@ pub mod msg_linux_cpu_state { impl MsgLinuxCpuState { pub fn timestamp_type(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(TimestampType::SystemTimeInSeconds), - 1 => Some(TimestampType::GpsTowInMilliseconds), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_timestamp_type(&mut self, timestamp_type: TimestampType) { @@ -153,7 +149,7 @@ pub mod msg_linux_cpu_state { } /// timestamp type - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TimestampType { /// System time in seconds SystemTimeInSeconds = 0, @@ -170,6 +166,17 @@ pub mod msg_linux_cpu_state { } } } + + impl TryFrom for TimestampType { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TimestampType::SystemTimeInSeconds), + 1 => Ok(TimestampType::GpsTowInMilliseconds), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_linux_cpu_state_dep_a { @@ -314,11 +321,7 @@ pub mod msg_linux_mem_state { impl MsgLinuxMemState { pub fn timestamp_type(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(TimestampType::SystemTimeInSeconds), - 1 => Some(TimestampType::GpsTowInMilliseconds), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_timestamp_type(&mut self, timestamp_type: TimestampType) { @@ -400,7 +403,7 @@ pub mod msg_linux_mem_state { } /// timestamp type - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TimestampType { /// System time in seconds SystemTimeInSeconds = 0, @@ -417,6 +420,17 @@ pub mod msg_linux_mem_state { } } } + + impl TryFrom for TimestampType { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TimestampType::SystemTimeInSeconds), + 1 => Ok(TimestampType::GpsTowInMilliseconds), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_linux_mem_state_dep_a { @@ -1068,11 +1082,7 @@ pub mod msg_linux_sys_state { impl MsgLinuxSysState { pub fn timestamp_type(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(TimestampType::SystemTimeInSeconds), - 1 => Some(TimestampType::GpsTowInMilliseconds), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_timestamp_type(&mut self, timestamp_type: TimestampType) { @@ -1158,7 +1168,7 @@ pub mod msg_linux_sys_state { } /// timestamp type - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TimestampType { /// System time in seconds SystemTimeInSeconds = 0, @@ -1175,6 +1185,17 @@ pub mod msg_linux_sys_state { } } } + + impl TryFrom for TimestampType { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TimestampType::SystemTimeInSeconds), + 1 => Ok(TimestampType::GpsTowInMilliseconds), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_linux_sys_state_dep_a { diff --git a/rust/sbp/src/messages/logging.rs b/rust/sbp/src/messages/logging.rs index 72b63f11e6..16d85a3251 100644 --- a/rust/sbp/src/messages/logging.rs +++ b/rust/sbp/src/messages/logging.rs @@ -137,17 +137,7 @@ pub mod msg_log { impl MsgLog { pub fn logging_level(&self) -> Option { - match get_bit_range!(self.level, u8, u8, 2, 0) { - 0 => Some(LoggingLevel::EMERG), - 1 => Some(LoggingLevel::ALERT), - 2 => Some(LoggingLevel::CRIT), - 3 => Some(LoggingLevel::ERROR), - 4 => Some(LoggingLevel::WARN), - 5 => Some(LoggingLevel::NOTICE), - 6 => Some(LoggingLevel::INFO), - 7 => Some(LoggingLevel::DEBUG), - _ => None, - } + get_bit_range!(self.level, u8, u8, 2, 0).try_into().ok() } pub fn set_logging_level(&mut self, logging_level: LoggingLevel) { @@ -208,7 +198,7 @@ pub mod msg_log { } /// Logging level - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum LoggingLevel { /// EMERG EMERG = 0, @@ -249,6 +239,23 @@ pub mod msg_log { } } } + + impl TryFrom for LoggingLevel { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(LoggingLevel::EMERG), + 1 => Ok(LoggingLevel::ALERT), + 2 => Ok(LoggingLevel::CRIT), + 3 => Ok(LoggingLevel::ERROR), + 4 => Ok(LoggingLevel::WARN), + 5 => Ok(LoggingLevel::NOTICE), + 6 => Ok(LoggingLevel::INFO), + 7 => Ok(LoggingLevel::DEBUG), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_print_dep { diff --git a/rust/sbp/src/messages/mod.rs b/rust/sbp/src/messages/mod.rs index e38da22d25..266382f59d 100644 --- a/rust/sbp/src/messages/mod.rs +++ b/rust/sbp/src/messages/mod.rs @@ -250,7 +250,7 @@ mod lib { pub use crate::time; pub use crate::wire_format::{PayloadParseError, WireFormat}; - pub use super::{ConcreteMessage, Sbp, SbpMessage, TryFromSbpError}; + pub use super::{ConcreteMessage, Sbp, SbpMessage, TryFromIntError, TryFromSbpError}; pub use bytes::{Buf, BufMut}; @@ -322,6 +322,18 @@ impl std::fmt::Display for TryFromSbpError { impl std::error::Error for TryFromSbpError {} +/// The error returned when using [TryFrom] to convert an invalid integer to a bitfield type. +#[derive(Debug, Clone)] +pub struct TryFromIntError; + +impl std::fmt::Display for TryFromIntError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "int does not match any bitfield values") + } +} + +impl std::error::Error for TryFromIntError {} + /// Represents any SBP message. #[cfg_attr(feature = "serde", derive(serde::Serialize), serde(untagged))] #[derive(Debug, Clone)] diff --git a/rust/sbp/src/messages/navigation.rs b/rust/sbp/src/messages/navigation.rs index 9e18ca2f95..53f39d201a 100644 --- a/rust/sbp/src/messages/navigation.rs +++ b/rust/sbp/src/messages/navigation.rs @@ -253,13 +253,7 @@ pub mod msg_baseline_ecef { impl MsgBaselineEcef { pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(FixMode::Invalid), - 2 => Some(FixMode::DifferentialGnss), - 3 => Some(FixMode::FloatRtk), - 4 => Some(FixMode::FixedRtk), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -350,7 +344,7 @@ pub mod msg_baseline_ecef { } /// Fix mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FixMode { /// Invalid Invalid = 0, @@ -375,6 +369,19 @@ pub mod msg_baseline_ecef { } } } + + impl TryFrom for FixMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FixMode::Invalid), + 2 => Ok(FixMode::DifferentialGnss), + 3 => Ok(FixMode::FloatRtk), + 4 => Ok(FixMode::FixedRtk), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_baseline_ecef_dep_a { @@ -421,11 +428,7 @@ pub mod msg_baseline_ecef_dep_a { impl MsgBaselineEcefDepA { pub fn raim_repair_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 0) { - 0 => Some(RaimRepairFlag::NoRepair), - 1 => Some(RaimRepairFlag::SolutionCameFromRaimRepair), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 0).try_into().ok() } pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { @@ -433,11 +436,7 @@ pub mod msg_baseline_ecef_dep_a { } pub fn raim_availability_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 0) { - 0 => Some(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), - 1 => Some(RaimAvailabilityFlag::RaimCheckWasAvailable), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 3, 0).try_into().ok() } pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { @@ -445,11 +444,7 @@ pub mod msg_baseline_ecef_dep_a { } pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(FixMode::FloatRtk), - 1 => Some(FixMode::FixedRtk), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -540,7 +535,7 @@ pub mod msg_baseline_ecef_dep_a { } /// RAIM repair flag - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum RaimRepairFlag { /// No repair NoRepair = 0, @@ -560,8 +555,19 @@ pub mod msg_baseline_ecef_dep_a { } } + impl TryFrom for RaimRepairFlag { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(RaimRepairFlag::NoRepair), + 1 => Ok(RaimRepairFlag::SolutionCameFromRaimRepair), + _ => Err(TryFromIntError), + } + } + } + /// RAIM availability flag - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum RaimAvailabilityFlag { /// RAIM check was explicitly disabled or unavailable RaimCheckWasExplicitlyDisabledOrUnavailable = 0, @@ -583,8 +589,19 @@ pub mod msg_baseline_ecef_dep_a { } } + impl TryFrom for RaimAvailabilityFlag { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), + 1 => Ok(RaimAvailabilityFlag::RaimCheckWasAvailable), + _ => Err(TryFromIntError), + } + } + } + /// Fix mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FixMode { /// Float RTK FloatRtk = 0, @@ -601,6 +618,17 @@ pub mod msg_baseline_ecef_dep_a { } } } + + impl TryFrom for FixMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FixMode::FloatRtk), + 1 => Ok(FixMode::FixedRtk), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_baseline_heading_dep_a { @@ -637,11 +665,7 @@ pub mod msg_baseline_heading_dep_a { impl MsgBaselineHeadingDepA { pub fn raim_repair_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 0) { - 0 => Some(RaimRepairFlag::NoRepair), - 1 => Some(RaimRepairFlag::SolutionCameFromRaimRepair), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 0).try_into().ok() } pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { @@ -649,11 +673,7 @@ pub mod msg_baseline_heading_dep_a { } pub fn raim_availability_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 0) { - 0 => Some(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), - 1 => Some(RaimAvailabilityFlag::RaimCheckWasAvailable), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 3, 0).try_into().ok() } pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { @@ -661,11 +681,7 @@ pub mod msg_baseline_heading_dep_a { } pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(FixMode::FloatRtk), - 1 => Some(FixMode::FixedRtk), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -744,7 +760,7 @@ pub mod msg_baseline_heading_dep_a { } /// RAIM repair flag - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum RaimRepairFlag { /// No repair NoRepair = 0, @@ -764,8 +780,19 @@ pub mod msg_baseline_heading_dep_a { } } + impl TryFrom for RaimRepairFlag { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(RaimRepairFlag::NoRepair), + 1 => Ok(RaimRepairFlag::SolutionCameFromRaimRepair), + _ => Err(TryFromIntError), + } + } + } + /// RAIM availability flag - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum RaimAvailabilityFlag { /// RAIM check was explicitly disabled or unavailable RaimCheckWasExplicitlyDisabledOrUnavailable = 0, @@ -787,8 +814,19 @@ pub mod msg_baseline_heading_dep_a { } } + impl TryFrom for RaimAvailabilityFlag { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), + 1 => Ok(RaimAvailabilityFlag::RaimCheckWasAvailable), + _ => Err(TryFromIntError), + } + } + } + /// Fix mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FixMode { /// Float RTK FloatRtk = 0, @@ -805,6 +843,17 @@ pub mod msg_baseline_heading_dep_a { } } } + + impl TryFrom for FixMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FixMode::FloatRtk), + 1 => Ok(FixMode::FixedRtk), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_baseline_ned { @@ -856,13 +905,7 @@ pub mod msg_baseline_ned { impl MsgBaselineNed { pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(FixMode::Invalid), - 2 => Some(FixMode::DifferentialGnss), - 3 => Some(FixMode::FloatRtk), - 4 => Some(FixMode::FixedRtk), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -957,7 +1000,7 @@ pub mod msg_baseline_ned { } /// Fix mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FixMode { /// Invalid Invalid = 0, @@ -982,6 +1025,19 @@ pub mod msg_baseline_ned { } } } + + impl TryFrom for FixMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FixMode::Invalid), + 2 => Ok(FixMode::DifferentialGnss), + 3 => Ok(FixMode::FloatRtk), + 4 => Ok(FixMode::FixedRtk), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_baseline_ned_dep_a { @@ -1033,11 +1089,7 @@ pub mod msg_baseline_ned_dep_a { impl MsgBaselineNedDepA { pub fn raim_repair_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 0) { - 0 => Some(RaimRepairFlag::NoRepair), - 1 => Some(RaimRepairFlag::SolutionCameFromRaimRepair), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 0).try_into().ok() } pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { @@ -1045,11 +1097,7 @@ pub mod msg_baseline_ned_dep_a { } pub fn raim_availability_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 0) { - 0 => Some(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), - 1 => Some(RaimAvailabilityFlag::RaimCheckWasAvailable), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 3, 0).try_into().ok() } pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { @@ -1057,11 +1105,7 @@ pub mod msg_baseline_ned_dep_a { } pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(FixMode::FloatRtk), - 1 => Some(FixMode::FixedRtk), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -1156,7 +1200,7 @@ pub mod msg_baseline_ned_dep_a { } /// RAIM repair flag - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum RaimRepairFlag { /// No repair NoRepair = 0, @@ -1176,8 +1220,19 @@ pub mod msg_baseline_ned_dep_a { } } + impl TryFrom for RaimRepairFlag { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(RaimRepairFlag::NoRepair), + 1 => Ok(RaimRepairFlag::SolutionCameFromRaimRepair), + _ => Err(TryFromIntError), + } + } + } + /// RAIM availability flag - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum RaimAvailabilityFlag { /// RAIM check was explicitly disabled or unavailable RaimCheckWasExplicitlyDisabledOrUnavailable = 0, @@ -1199,8 +1254,19 @@ pub mod msg_baseline_ned_dep_a { } } + impl TryFrom for RaimAvailabilityFlag { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), + 1 => Ok(RaimAvailabilityFlag::RaimCheckWasAvailable), + _ => Err(TryFromIntError), + } + } + } + /// Fix mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FixMode { /// Float RTK FloatRtk = 0, @@ -1217,6 +1283,17 @@ pub mod msg_baseline_ned_dep_a { } } } + + impl TryFrom for FixMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FixMode::FloatRtk), + 1 => Ok(FixMode::FixedRtk), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_dops { @@ -1271,16 +1348,7 @@ pub mod msg_dops { } pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(FixMode::Invalid), - 1 => Some(FixMode::SinglePointPosition), - 2 => Some(FixMode::DifferentialGnss), - 3 => Some(FixMode::FloatRtk), - 4 => Some(FixMode::FixedRtk), - 5 => Some(FixMode::Undefined), - 6 => Some(FixMode::SbasPosition), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -1371,7 +1439,7 @@ pub mod msg_dops { } /// Fix mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FixMode { /// Invalid Invalid = 0, @@ -1408,6 +1476,22 @@ pub mod msg_dops { } } } + + impl TryFrom for FixMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FixMode::Invalid), + 1 => Ok(FixMode::SinglePointPosition), + 2 => Ok(FixMode::DifferentialGnss), + 3 => Ok(FixMode::FloatRtk), + 4 => Ok(FixMode::FixedRtk), + 5 => Ok(FixMode::Undefined), + 6 => Ok(FixMode::SbasPosition), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_dops_dep_a { @@ -1569,12 +1653,7 @@ pub mod msg_gps_time { impl MsgGpsTime { pub fn time_source(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(TimeSource::None), - 1 => Some(TimeSource::GnssSolution), - 2 => Some(TimeSource::Propagated), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_time_source(&mut self, time_source: TimeSource) { @@ -1658,7 +1737,7 @@ pub mod msg_gps_time { } /// Time source - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TimeSource { /// None (invalid) None = 0, @@ -1679,6 +1758,18 @@ pub mod msg_gps_time { } } } + + impl TryFrom for TimeSource { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TimeSource::None), + 1 => Ok(TimeSource::GnssSolution), + 2 => Ok(TimeSource::Propagated), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_gps_time_dep_a { @@ -1841,12 +1932,7 @@ pub mod msg_gps_time_gnss { impl MsgGpsTimeGnss { pub fn time_source(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(TimeSource::None), - 1 => Some(TimeSource::GnssSolution), - 2 => Some(TimeSource::Propagated), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_time_source(&mut self, time_source: TimeSource) { @@ -1930,7 +2016,7 @@ pub mod msg_gps_time_gnss { } /// Time source - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TimeSource { /// None (invalid) None = 0, @@ -1951,6 +2037,18 @@ pub mod msg_gps_time_gnss { } } } + + impl TryFrom for TimeSource { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TimeSource::None), + 1 => Ok(TimeSource::GnssSolution), + 2 => Ok(TimeSource::Propagated), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_pos_ecef { @@ -2000,11 +2098,7 @@ pub mod msg_pos_ecef { impl MsgPosEcef { pub fn tow_type(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 5) { - 0 => Some(TowType::TimeOfMeasurement), - 1 => Some(TowType::Other), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 5, 5).try_into().ok() } pub fn set_tow_type(&mut self, tow_type: TowType) { @@ -2012,11 +2106,7 @@ pub mod msg_pos_ecef { } pub fn inertial_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(InertialNavigationMode::None), - 1 => Some(InertialNavigationMode::InsUsed), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() } pub fn set_inertial_navigation_mode( @@ -2027,16 +2117,7 @@ pub mod msg_pos_ecef { } pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(FixMode::Invalid), - 1 => Some(FixMode::SinglePointPosition), - 2 => Some(FixMode::DifferentialGnss), - 3 => Some(FixMode::FloatRtk), - 4 => Some(FixMode::FixedRtk), - 5 => Some(FixMode::DeadReckoning), - 6 => Some(FixMode::SbasPosition), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -2127,7 +2208,7 @@ pub mod msg_pos_ecef { } /// TOW type - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TowType { /// Time of Measurement TimeOfMeasurement = 0, @@ -2145,8 +2226,19 @@ pub mod msg_pos_ecef { } } + impl TryFrom for TowType { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TowType::TimeOfMeasurement), + 1 => Ok(TowType::Other), + _ => Err(TryFromIntError), + } + } + } + /// Inertial Navigation Mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InertialNavigationMode { /// None None = 0, @@ -2164,8 +2256,19 @@ pub mod msg_pos_ecef { } } + impl TryFrom for InertialNavigationMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(InertialNavigationMode::None), + 1 => Ok(InertialNavigationMode::InsUsed), + _ => Err(TryFromIntError), + } + } + } + /// Fix mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FixMode { /// Invalid Invalid = 0, @@ -2202,6 +2305,22 @@ pub mod msg_pos_ecef { } } } + + impl TryFrom for FixMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FixMode::Invalid), + 1 => Ok(FixMode::SinglePointPosition), + 2 => Ok(FixMode::DifferentialGnss), + 3 => Ok(FixMode::FloatRtk), + 4 => Ok(FixMode::FixedRtk), + 5 => Ok(FixMode::DeadReckoning), + 6 => Ok(FixMode::SbasPosition), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_pos_ecef_cov { @@ -2267,11 +2386,7 @@ pub mod msg_pos_ecef_cov { impl MsgPosEcefCov { pub fn type_of_reported_tow(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 5) { - 0 => Some(TypeOfReportedTow::TimeOfMeasurement), - 1 => Some(TypeOfReportedTow::Other), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 5, 5).try_into().ok() } pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { @@ -2279,11 +2394,7 @@ pub mod msg_pos_ecef_cov { } pub fn inertial_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(InertialNavigationMode::None), - 1 => Some(InertialNavigationMode::InsUsed), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() } pub fn set_inertial_navigation_mode( @@ -2294,16 +2405,7 @@ pub mod msg_pos_ecef_cov { } pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(FixMode::Invalid), - 1 => Some(FixMode::SinglePointPosition), - 2 => Some(FixMode::DifferentialGnss), - 3 => Some(FixMode::FloatRtk), - 4 => Some(FixMode::FixedRtk), - 5 => Some(FixMode::DeadReckoning), - 6 => Some(FixMode::SbasPosition), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -2414,7 +2516,7 @@ pub mod msg_pos_ecef_cov { } /// Type of reported TOW - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TypeOfReportedTow { /// Time of Measurement TimeOfMeasurement = 0, @@ -2432,8 +2534,19 @@ pub mod msg_pos_ecef_cov { } } + impl TryFrom for TypeOfReportedTow { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TypeOfReportedTow::TimeOfMeasurement), + 1 => Ok(TypeOfReportedTow::Other), + _ => Err(TryFromIntError), + } + } + } + /// Inertial Navigation Mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InertialNavigationMode { /// None None = 0, @@ -2451,8 +2564,19 @@ pub mod msg_pos_ecef_cov { } } + impl TryFrom for InertialNavigationMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(InertialNavigationMode::None), + 1 => Ok(InertialNavigationMode::InsUsed), + _ => Err(TryFromIntError), + } + } + } + /// Fix mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FixMode { /// Invalid Invalid = 0, @@ -2489,6 +2613,22 @@ pub mod msg_pos_ecef_cov { } } } + + impl TryFrom for FixMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FixMode::Invalid), + 1 => Ok(FixMode::SinglePointPosition), + 2 => Ok(FixMode::DifferentialGnss), + 3 => Ok(FixMode::FloatRtk), + 4 => Ok(FixMode::FixedRtk), + 5 => Ok(FixMode::DeadReckoning), + 6 => Ok(FixMode::SbasPosition), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_pos_ecef_cov_gnss { @@ -2554,15 +2694,7 @@ pub mod msg_pos_ecef_cov_gnss { impl MsgPosEcefCovGnss { pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(FixMode::Invalid), - 1 => Some(FixMode::SinglePointPosition), - 2 => Some(FixMode::DifferentialGnss), - 3 => Some(FixMode::FloatRtk), - 4 => Some(FixMode::FixedRtk), - 6 => Some(FixMode::SbasPosition), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -2673,7 +2805,7 @@ pub mod msg_pos_ecef_cov_gnss { } /// Fix mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FixMode { /// Invalid Invalid = 0, @@ -2706,6 +2838,21 @@ pub mod msg_pos_ecef_cov_gnss { } } } + + impl TryFrom for FixMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FixMode::Invalid), + 1 => Ok(FixMode::SinglePointPosition), + 2 => Ok(FixMode::DifferentialGnss), + 3 => Ok(FixMode::FloatRtk), + 4 => Ok(FixMode::FixedRtk), + 6 => Ok(FixMode::SbasPosition), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_pos_ecef_dep_a { @@ -2755,11 +2902,7 @@ pub mod msg_pos_ecef_dep_a { impl MsgPosEcefDepA { pub fn raim_repair_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 0) { - 0 => Some(RaimRepairFlag::NoRepair), - 1 => Some(RaimRepairFlag::SolutionCameFromRaimRepair), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 0).try_into().ok() } pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { @@ -2767,11 +2910,7 @@ pub mod msg_pos_ecef_dep_a { } pub fn raim_availability_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 0) { - 0 => Some(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), - 1 => Some(RaimAvailabilityFlag::RaimCheckWasAvailable), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 3, 0).try_into().ok() } pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { @@ -2779,12 +2918,7 @@ pub mod msg_pos_ecef_dep_a { } pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(FixMode::SinglePointPositioning), - 1 => Some(FixMode::FixedRtk), - 2 => Some(FixMode::FloatRtk), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -2875,7 +3009,7 @@ pub mod msg_pos_ecef_dep_a { } /// RAIM repair flag - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum RaimRepairFlag { /// No repair NoRepair = 0, @@ -2895,8 +3029,19 @@ pub mod msg_pos_ecef_dep_a { } } + impl TryFrom for RaimRepairFlag { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(RaimRepairFlag::NoRepair), + 1 => Ok(RaimRepairFlag::SolutionCameFromRaimRepair), + _ => Err(TryFromIntError), + } + } + } + /// RAIM availability flag - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum RaimAvailabilityFlag { /// RAIM check was explicitly disabled or unavailable RaimCheckWasExplicitlyDisabledOrUnavailable = 0, @@ -2918,8 +3063,19 @@ pub mod msg_pos_ecef_dep_a { } } + impl TryFrom for RaimAvailabilityFlag { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), + 1 => Ok(RaimAvailabilityFlag::RaimCheckWasAvailable), + _ => Err(TryFromIntError), + } + } + } + /// Fix mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FixMode { /// Single Point Positioning (SPP) SinglePointPositioning = 0, @@ -2940,6 +3096,18 @@ pub mod msg_pos_ecef_dep_a { } } } + + impl TryFrom for FixMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FixMode::SinglePointPositioning), + 1 => Ok(FixMode::FixedRtk), + 2 => Ok(FixMode::FloatRtk), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_pos_ecef_gnss { @@ -2989,15 +3157,7 @@ pub mod msg_pos_ecef_gnss { impl MsgPosEcefGnss { pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(FixMode::Invalid), - 1 => Some(FixMode::SinglePointPosition), - 2 => Some(FixMode::DifferentialGnss), - 3 => Some(FixMode::FloatRtk), - 4 => Some(FixMode::FixedRtk), - 6 => Some(FixMode::SbasPosition), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -3088,7 +3248,7 @@ pub mod msg_pos_ecef_gnss { } /// Fix mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FixMode { /// Invalid Invalid = 0, @@ -3121,6 +3281,21 @@ pub mod msg_pos_ecef_gnss { } } } + + impl TryFrom for FixMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FixMode::Invalid), + 1 => Ok(FixMode::SinglePointPosition), + 2 => Ok(FixMode::DifferentialGnss), + 3 => Ok(FixMode::FloatRtk), + 4 => Ok(FixMode::FixedRtk), + 6 => Ok(FixMode::SbasPosition), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_pos_llh { @@ -3173,11 +3348,7 @@ pub mod msg_pos_llh { impl MsgPosLlh { pub fn type_of_reported_tow(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 5) { - 0 => Some(TypeOfReportedTow::TimeOfMeasurement), - 1 => Some(TypeOfReportedTow::Other), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 5, 5).try_into().ok() } pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { @@ -3185,11 +3356,7 @@ pub mod msg_pos_llh { } pub fn inertial_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(InertialNavigationMode::None), - 1 => Some(InertialNavigationMode::InsUsed), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() } pub fn set_inertial_navigation_mode( @@ -3200,16 +3367,7 @@ pub mod msg_pos_llh { } pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(FixMode::Invalid), - 1 => Some(FixMode::SinglePointPosition), - 2 => Some(FixMode::DifferentialGnss), - 3 => Some(FixMode::FloatRtk), - 4 => Some(FixMode::FixedRtk), - 5 => Some(FixMode::DeadReckoning), - 6 => Some(FixMode::SbasPosition), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -3304,7 +3462,7 @@ pub mod msg_pos_llh { } /// Type of reported TOW - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TypeOfReportedTow { /// Time of Measurement TimeOfMeasurement = 0, @@ -3322,8 +3480,19 @@ pub mod msg_pos_llh { } } + impl TryFrom for TypeOfReportedTow { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TypeOfReportedTow::TimeOfMeasurement), + 1 => Ok(TypeOfReportedTow::Other), + _ => Err(TryFromIntError), + } + } + } + /// Inertial Navigation Mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InertialNavigationMode { /// None None = 0, @@ -3341,8 +3510,19 @@ pub mod msg_pos_llh { } } + impl TryFrom for InertialNavigationMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(InertialNavigationMode::None), + 1 => Ok(InertialNavigationMode::InsUsed), + _ => Err(TryFromIntError), + } + } + } + /// Fix mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FixMode { /// Invalid Invalid = 0, @@ -3379,6 +3559,22 @@ pub mod msg_pos_llh { } } } + + impl TryFrom for FixMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FixMode::Invalid), + 1 => Ok(FixMode::SinglePointPosition), + 2 => Ok(FixMode::DifferentialGnss), + 3 => Ok(FixMode::FloatRtk), + 4 => Ok(FixMode::FixedRtk), + 5 => Ok(FixMode::DeadReckoning), + 6 => Ok(FixMode::SbasPosition), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_pos_llh_acc { @@ -3457,12 +3653,9 @@ pub mod msg_pos_llh_acc { impl MsgPosLlhAcc { pub fn geoid_model(&self) -> Option { - match get_bit_range!(self.confidence_and_geoid, u8, u8, 6, 4) { - 0 => Some(GeoidModel::NoModel), - 1 => Some(GeoidModel::EGM96), - 2 => Some(GeoidModel::EGM2008), - _ => None, - } + get_bit_range!(self.confidence_and_geoid, u8, u8, 6, 4) + .try_into() + .ok() } pub fn set_geoid_model(&mut self, geoid_model: GeoidModel) { @@ -3470,12 +3663,9 @@ pub mod msg_pos_llh_acc { } pub fn confidence_level(&self) -> Option { - match get_bit_range!(self.confidence_and_geoid, u8, u8, 3, 0) { - 1 => Some(ConfidenceLevel::_3935), - 2 => Some(ConfidenceLevel::_6827), - 3 => Some(ConfidenceLevel::_9545), - _ => None, - } + get_bit_range!(self.confidence_and_geoid, u8, u8, 3, 0) + .try_into() + .ok() } pub fn set_confidence_level(&mut self, confidence_level: ConfidenceLevel) { @@ -3490,11 +3680,7 @@ pub mod msg_pos_llh_acc { } pub fn type_of_reported_tow(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 5) { - 0 => Some(TypeOfReportedTow::TimeOfMeasurement), - 1 => Some(TypeOfReportedTow::Other), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 5, 5).try_into().ok() } pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { @@ -3502,11 +3688,7 @@ pub mod msg_pos_llh_acc { } pub fn inertial_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(InertialNavigationMode::None), - 1 => Some(InertialNavigationMode::InsUsed), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() } pub fn set_inertial_navigation_mode( @@ -3517,16 +3699,7 @@ pub mod msg_pos_llh_acc { } pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(FixMode::Invalid), - 1 => Some(FixMode::SinglePointPosition), - 2 => Some(FixMode::DifferentialGnss), - 3 => Some(FixMode::FloatRtk), - 4 => Some(FixMode::FixedRtk), - 5 => Some(FixMode::DeadReckoning), - 6 => Some(FixMode::SbasPosition), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -3641,7 +3814,7 @@ pub mod msg_pos_llh_acc { } /// Geoid model - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum GeoidModel { /// No model NoModel = 0, @@ -3663,8 +3836,20 @@ pub mod msg_pos_llh_acc { } } + impl TryFrom for GeoidModel { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(GeoidModel::NoModel), + 1 => Ok(GeoidModel::EGM96), + 2 => Ok(GeoidModel::EGM2008), + _ => Err(TryFromIntError), + } + } + } + /// Confidence level - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ConfidenceLevel { /// 39.35% _3935 = 1, @@ -3686,8 +3871,20 @@ pub mod msg_pos_llh_acc { } } + impl TryFrom for ConfidenceLevel { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 1 => Ok(ConfidenceLevel::_3935), + 2 => Ok(ConfidenceLevel::_6827), + 3 => Ok(ConfidenceLevel::_9545), + _ => Err(TryFromIntError), + } + } + } + /// Type of reported TOW - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TypeOfReportedTow { /// Time of Measurement TimeOfMeasurement = 0, @@ -3705,8 +3902,19 @@ pub mod msg_pos_llh_acc { } } + impl TryFrom for TypeOfReportedTow { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TypeOfReportedTow::TimeOfMeasurement), + 1 => Ok(TypeOfReportedTow::Other), + _ => Err(TryFromIntError), + } + } + } + /// Inertial Navigation Mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InertialNavigationMode { /// None None = 0, @@ -3724,8 +3932,19 @@ pub mod msg_pos_llh_acc { } } + impl TryFrom for InertialNavigationMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(InertialNavigationMode::None), + 1 => Ok(InertialNavigationMode::InsUsed), + _ => Err(TryFromIntError), + } + } + } + /// Fix mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FixMode { /// Invalid Invalid = 0, @@ -3762,6 +3981,22 @@ pub mod msg_pos_llh_acc { } } } + + impl TryFrom for FixMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FixMode::Invalid), + 1 => Ok(FixMode::SinglePointPosition), + 2 => Ok(FixMode::DifferentialGnss), + 3 => Ok(FixMode::FloatRtk), + 4 => Ok(FixMode::FixedRtk), + 5 => Ok(FixMode::DeadReckoning), + 6 => Ok(FixMode::SbasPosition), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_pos_llh_cov { @@ -3827,11 +4062,7 @@ pub mod msg_pos_llh_cov { impl MsgPosLlhCov { pub fn type_of_reported_tow(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 5) { - 0 => Some(TypeOfReportedTow::TimeOfMeasurement), - 1 => Some(TypeOfReportedTow::Other), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 5, 5).try_into().ok() } pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { @@ -3839,11 +4070,7 @@ pub mod msg_pos_llh_cov { } pub fn inertial_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(InertialNavigationMode::None), - 1 => Some(InertialNavigationMode::InsUsed), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() } pub fn set_inertial_navigation_mode( @@ -3854,16 +4081,7 @@ pub mod msg_pos_llh_cov { } pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(FixMode::Invalid), - 1 => Some(FixMode::SinglePointPosition), - 2 => Some(FixMode::DifferentialGnss), - 3 => Some(FixMode::FloatRtk), - 4 => Some(FixMode::FixedRtk), - 5 => Some(FixMode::DeadReckoning), - 6 => Some(FixMode::SbasPosition), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -3974,7 +4192,7 @@ pub mod msg_pos_llh_cov { } /// Type of reported TOW - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TypeOfReportedTow { /// Time of Measurement TimeOfMeasurement = 0, @@ -3992,8 +4210,19 @@ pub mod msg_pos_llh_cov { } } + impl TryFrom for TypeOfReportedTow { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TypeOfReportedTow::TimeOfMeasurement), + 1 => Ok(TypeOfReportedTow::Other), + _ => Err(TryFromIntError), + } + } + } + /// Inertial Navigation Mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InertialNavigationMode { /// None None = 0, @@ -4011,8 +4240,19 @@ pub mod msg_pos_llh_cov { } } + impl TryFrom for InertialNavigationMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(InertialNavigationMode::None), + 1 => Ok(InertialNavigationMode::InsUsed), + _ => Err(TryFromIntError), + } + } + } + /// Fix mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FixMode { /// Invalid Invalid = 0, @@ -4049,6 +4289,22 @@ pub mod msg_pos_llh_cov { } } } + + impl TryFrom for FixMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FixMode::Invalid), + 1 => Ok(FixMode::SinglePointPosition), + 2 => Ok(FixMode::DifferentialGnss), + 3 => Ok(FixMode::FloatRtk), + 4 => Ok(FixMode::FixedRtk), + 5 => Ok(FixMode::DeadReckoning), + 6 => Ok(FixMode::SbasPosition), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_pos_llh_cov_gnss { @@ -4114,16 +4370,7 @@ pub mod msg_pos_llh_cov_gnss { impl MsgPosLlhCovGnss { pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(FixMode::Invalid), - 1 => Some(FixMode::SinglePointPosition), - 2 => Some(FixMode::DifferentialGnss), - 3 => Some(FixMode::FloatRtk), - 4 => Some(FixMode::FixedRtk), - 5 => Some(FixMode::DeadReckoning), - 6 => Some(FixMode::SbasPosition), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -4234,7 +4481,7 @@ pub mod msg_pos_llh_cov_gnss { } /// Fix mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FixMode { /// Invalid Invalid = 0, @@ -4271,6 +4518,22 @@ pub mod msg_pos_llh_cov_gnss { } } } + + impl TryFrom for FixMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FixMode::Invalid), + 1 => Ok(FixMode::SinglePointPosition), + 2 => Ok(FixMode::DifferentialGnss), + 3 => Ok(FixMode::FloatRtk), + 4 => Ok(FixMode::FixedRtk), + 5 => Ok(FixMode::DeadReckoning), + 6 => Ok(FixMode::SbasPosition), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_pos_llh_dep_a { @@ -4323,11 +4586,7 @@ pub mod msg_pos_llh_dep_a { impl MsgPosLlhDepA { pub fn raim_repair_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 0) { - 0 => Some(RaimRepairFlag::NoRepair), - 1 => Some(RaimRepairFlag::SolutionCameFromRaimRepair), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 5, 0).try_into().ok() } pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { @@ -4335,11 +4594,7 @@ pub mod msg_pos_llh_dep_a { } pub fn raim_availability_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 0) { - 0 => Some(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), - 1 => Some(RaimAvailabilityFlag::RaimCheckWasAvailable), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 0).try_into().ok() } pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { @@ -4347,11 +4602,7 @@ pub mod msg_pos_llh_dep_a { } pub fn height_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 0) { - 0 => Some(HeightMode::HeightAboveWgs84Ellipsoid), - 1 => Some(HeightMode::HeightAboveMeanSeaLevel), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 3, 0).try_into().ok() } pub fn set_height_mode(&mut self, height_mode: HeightMode) { @@ -4359,12 +4610,7 @@ pub mod msg_pos_llh_dep_a { } pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(FixMode::SinglePointPositioning), - 1 => Some(FixMode::FixedRtk), - 2 => Some(FixMode::FloatRtk), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -4459,7 +4705,7 @@ pub mod msg_pos_llh_dep_a { } /// RAIM repair flag - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum RaimRepairFlag { /// No repair NoRepair = 0, @@ -4479,8 +4725,19 @@ pub mod msg_pos_llh_dep_a { } } + impl TryFrom for RaimRepairFlag { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(RaimRepairFlag::NoRepair), + 1 => Ok(RaimRepairFlag::SolutionCameFromRaimRepair), + _ => Err(TryFromIntError), + } + } + } + /// RAIM availability flag - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum RaimAvailabilityFlag { /// RAIM check was explicitly disabled or unavailable RaimCheckWasExplicitlyDisabledOrUnavailable = 0, @@ -4502,8 +4759,19 @@ pub mod msg_pos_llh_dep_a { } } + impl TryFrom for RaimAvailabilityFlag { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), + 1 => Ok(RaimAvailabilityFlag::RaimCheckWasAvailable), + _ => Err(TryFromIntError), + } + } + } + /// Height Mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum HeightMode { /// Height above WGS84 ellipsoid HeightAboveWgs84Ellipsoid = 0, @@ -4523,8 +4791,19 @@ pub mod msg_pos_llh_dep_a { } } + impl TryFrom for HeightMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(HeightMode::HeightAboveWgs84Ellipsoid), + 1 => Ok(HeightMode::HeightAboveMeanSeaLevel), + _ => Err(TryFromIntError), + } + } + } + /// Fix mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FixMode { /// Single Point Positioning (SPP) SinglePointPositioning = 0, @@ -4545,6 +4824,18 @@ pub mod msg_pos_llh_dep_a { } } } + + impl TryFrom for FixMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FixMode::SinglePointPositioning), + 1 => Ok(FixMode::FixedRtk), + 2 => Ok(FixMode::FloatRtk), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_pos_llh_gnss { @@ -4597,15 +4888,7 @@ pub mod msg_pos_llh_gnss { impl MsgPosLlhGnss { pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(FixMode::Invalid), - 1 => Some(FixMode::SinglePointPosition), - 2 => Some(FixMode::DifferentialGnss), - 3 => Some(FixMode::FloatRtk), - 4 => Some(FixMode::FixedRtk), - 6 => Some(FixMode::SbasPosition), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -4700,7 +4983,7 @@ pub mod msg_pos_llh_gnss { } /// Fix mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FixMode { /// Invalid Invalid = 0, @@ -4733,6 +5016,21 @@ pub mod msg_pos_llh_gnss { } } } + + impl TryFrom for FixMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FixMode::Invalid), + 1 => Ok(FixMode::SinglePointPosition), + 2 => Ok(FixMode::DifferentialGnss), + 3 => Ok(FixMode::FloatRtk), + 4 => Ok(FixMode::FixedRtk), + 6 => Ok(FixMode::SbasPosition), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_protection_level { @@ -4837,16 +5135,7 @@ pub mod msg_protection_level { } pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 17, 15) { - 0 => Some(FixMode::Invalid), - 1 => Some(FixMode::SinglePointPosition), - 2 => Some(FixMode::DifferentialGnss), - 3 => Some(FixMode::FloatRtk), - 4 => Some(FixMode::FixedRtk), - 5 => Some(FixMode::DeadReckoning), - 6 => Some(FixMode::SbasPosition), - _ => None, - } + get_bit_range!(self.flags, u32, u8, 17, 15).try_into().ok() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -4854,11 +5143,7 @@ pub mod msg_protection_level { } pub fn inertial_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 19, 18) { - 0 => Some(InertialNavigationMode::None), - 1 => Some(InertialNavigationMode::InsUsed), - _ => None, - } + get_bit_range!(self.flags, u32, u8, 19, 18).try_into().ok() } pub fn set_inertial_navigation_mode( @@ -4869,11 +5154,7 @@ pub mod msg_protection_level { } pub fn time_status(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 20, 0) { - 0 => Some(TimeStatus::GnssTimeOfValidity), - 1 => Some(TimeStatus::Other), - _ => None, - } + get_bit_range!(self.flags, u32, u8, 20, 0).try_into().ok() } pub fn set_time_status(&mut self, time_status: TimeStatus) { @@ -5113,7 +5394,7 @@ pub mod msg_protection_level { } /// Fix mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FixMode { /// Invalid Invalid = 0, @@ -5151,8 +5432,24 @@ pub mod msg_protection_level { } } + impl TryFrom for FixMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FixMode::Invalid), + 1 => Ok(FixMode::SinglePointPosition), + 2 => Ok(FixMode::DifferentialGnss), + 3 => Ok(FixMode::FloatRtk), + 4 => Ok(FixMode::FixedRtk), + 5 => Ok(FixMode::DeadReckoning), + 6 => Ok(FixMode::SbasPosition), + _ => Err(TryFromIntError), + } + } + } + /// Inertial Navigation Mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InertialNavigationMode { /// None None = 0, @@ -5170,8 +5467,19 @@ pub mod msg_protection_level { } } + impl TryFrom for InertialNavigationMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(InertialNavigationMode::None), + 1 => Ok(InertialNavigationMode::InsUsed), + _ => Err(TryFromIntError), + } + } + } + /// Time status - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TimeStatus { /// GNSS time of validity GnssTimeOfValidity = 0, @@ -5188,6 +5496,17 @@ pub mod msg_protection_level { } } } + + impl TryFrom for TimeStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TimeStatus::GnssTimeOfValidity), + 1 => Ok(TimeStatus::Other), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_protection_level_dep_a { @@ -5233,13 +5552,7 @@ pub mod msg_protection_level_dep_a { impl MsgProtectionLevelDepA { pub fn target_integrity_risk_tir_level(&self) -> Option { - match get_bit_range!( self.flags, u8, u8, 2, 0 ) { - 0 => Some( TargetIntegrityRiskTirLevel :: SafeStateProtectionLevelShallNotBeUsedForSafetyCriticalApplication ), - 1 => Some( TargetIntegrityRiskTirLevel :: TirLevel1 ), - 2 => Some( TargetIntegrityRiskTirLevel :: TirLevel2 ), - 3 => Some( TargetIntegrityRiskTirLevel :: TirLevel3 ), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_target_integrity_risk_tir_level( @@ -5340,7 +5653,7 @@ pub mod msg_protection_level_dep_a { } /// Target Integrity Risk (TIR) Level - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TargetIntegrityRiskTirLevel { /// Safe state, protection level shall not be used for safety-critical /// application @@ -5366,6 +5679,19 @@ pub mod msg_protection_level_dep_a { } } } + + impl TryFrom for TargetIntegrityRiskTirLevel { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok( TargetIntegrityRiskTirLevel :: SafeStateProtectionLevelShallNotBeUsedForSafetyCriticalApplication ), + 1 => Ok( TargetIntegrityRiskTirLevel :: TirLevel1 ), + 2 => Ok( TargetIntegrityRiskTirLevel :: TirLevel2 ), + 3 => Ok( TargetIntegrityRiskTirLevel :: TirLevel3 ), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_utc_time { @@ -5417,12 +5743,7 @@ pub mod msg_utc_time { impl MsgUtcTime { pub fn utc_offset_source(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(UtcOffsetSource::FactoryDefault), - 1 => Some(UtcOffsetSource::NonVolatileMemory), - 2 => Some(UtcOffsetSource::DecodedThisSession), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() } pub fn set_utc_offset_source(&mut self, utc_offset_source: UtcOffsetSource) { @@ -5430,12 +5751,7 @@ pub mod msg_utc_time { } pub fn time_source(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(TimeSource::None), - 1 => Some(TimeSource::GnssSolution), - 2 => Some(TimeSource::Propagated), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_time_source(&mut self, time_source: TimeSource) { @@ -5534,7 +5850,7 @@ pub mod msg_utc_time { } /// UTC offset source - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum UtcOffsetSource { /// Factory Default FactoryDefault = 0, @@ -5556,8 +5872,20 @@ pub mod msg_utc_time { } } + impl TryFrom for UtcOffsetSource { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(UtcOffsetSource::FactoryDefault), + 1 => Ok(UtcOffsetSource::NonVolatileMemory), + 2 => Ok(UtcOffsetSource::DecodedThisSession), + _ => Err(TryFromIntError), + } + } + } + /// Time source - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TimeSource { /// None (invalid) None = 0, @@ -5578,6 +5906,18 @@ pub mod msg_utc_time { } } } + + impl TryFrom for TimeSource { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TimeSource::None), + 1 => Ok(TimeSource::GnssSolution), + 2 => Ok(TimeSource::Propagated), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_utc_time_gnss { @@ -5629,12 +5969,7 @@ pub mod msg_utc_time_gnss { impl MsgUtcTimeGnss { pub fn utc_offset_source(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(UtcOffsetSource::FactoryDefault), - 1 => Some(UtcOffsetSource::NonVolatileMemory), - 2 => Some(UtcOffsetSource::DecodedThisSession), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() } pub fn set_utc_offset_source(&mut self, utc_offset_source: UtcOffsetSource) { @@ -5642,12 +5977,7 @@ pub mod msg_utc_time_gnss { } pub fn time_source(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(TimeSource::None), - 1 => Some(TimeSource::GnssSolution), - 2 => Some(TimeSource::Propagated), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_time_source(&mut self, time_source: TimeSource) { @@ -5746,7 +6076,7 @@ pub mod msg_utc_time_gnss { } /// UTC offset source - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum UtcOffsetSource { /// Factory Default FactoryDefault = 0, @@ -5768,8 +6098,20 @@ pub mod msg_utc_time_gnss { } } + impl TryFrom for UtcOffsetSource { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(UtcOffsetSource::FactoryDefault), + 1 => Ok(UtcOffsetSource::NonVolatileMemory), + 2 => Ok(UtcOffsetSource::DecodedThisSession), + _ => Err(TryFromIntError), + } + } + } + /// Time source - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TimeSource { /// None (invalid) None = 0, @@ -5790,6 +6132,18 @@ pub mod msg_utc_time_gnss { } } } + + impl TryFrom for TimeSource { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TimeSource::None), + 1 => Ok(TimeSource::GnssSolution), + 2 => Ok(TimeSource::Propagated), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_vel_body { @@ -5856,11 +6210,7 @@ pub mod msg_vel_body { impl MsgVelBody { pub fn ins_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(InsNavigationMode::None), - 1 => Some(InsNavigationMode::InsUsed), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() } pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { @@ -5868,13 +6218,7 @@ pub mod msg_vel_body { } pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(VelocityMode::Invalid), - 1 => Some(VelocityMode::MeasuredDopplerDerived), - 2 => Some(VelocityMode::ComputedDopplerDerived), - 3 => Some(VelocityMode::DeadReckoning), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -5985,7 +6329,7 @@ pub mod msg_vel_body { } /// INS Navigation Mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InsNavigationMode { /// None None = 0, @@ -6003,8 +6347,19 @@ pub mod msg_vel_body { } } + impl TryFrom for InsNavigationMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(InsNavigationMode::None), + 1 => Ok(InsNavigationMode::InsUsed), + _ => Err(TryFromIntError), + } + } + } + /// Velocity mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum VelocityMode { /// Invalid Invalid = 0, @@ -6029,6 +6384,19 @@ pub mod msg_vel_body { } } } + + impl TryFrom for VelocityMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(VelocityMode::Invalid), + 1 => Ok(VelocityMode::MeasuredDopplerDerived), + 2 => Ok(VelocityMode::ComputedDopplerDerived), + 3 => Ok(VelocityMode::DeadReckoning), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_vel_cog { @@ -6097,11 +6465,7 @@ pub mod msg_vel_cog { } pub fn vertical_velocity_validity(&self) -> Option { - match get_bit_range!(self.flags, u16, u8, 8, 0) { - 0 => Some(VerticalVelocityValidity::Invalid), - 1 => Some(VerticalVelocityValidity::VerticalVelocityValid), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 5, 0).try_into().ok() } pub fn set_vertical_velocity_validity( @@ -6112,11 +6476,7 @@ pub mod msg_vel_cog { } pub fn sog_validity(&self) -> Option { - match get_bit_range!(self.flags, u16, u8, 7, 0) { - 0 => Some(SogValidity::Invalid), - 1 => Some(SogValidity::SogValid), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 0).try_into().ok() } pub fn set_sog_validity(&mut self, sog_validity: SogValidity) { @@ -6124,11 +6484,7 @@ pub mod msg_vel_cog { } pub fn cog_validity(&self) -> Option { - match get_bit_range!(self.flags, u16, u8, 6, 0) { - 0 => Some(CogValidity::Invalid), - 1 => Some(CogValidity::CogValid), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 3, 0).try_into().ok() } pub fn set_cog_validity(&mut self, cog_validity: CogValidity) { @@ -6148,11 +6504,7 @@ pub mod msg_vel_cog { } pub fn ins_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u16, u8, 4, 3) { - 0 => Some(InsNavigationMode::None), - 1 => Some(InsNavigationMode::InsUsed), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { @@ -6160,13 +6512,7 @@ pub mod msg_vel_cog { } pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u16, u8, 2, 0) { - 0 => Some(VelocityMode::Invalid), - 1 => Some(VelocityMode::MeasuredDopplerDerived), - 2 => Some(VelocityMode::ComputedDopplerDerived), - 3 => Some(VelocityMode::DeadReckoning), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -6280,7 +6626,7 @@ pub mod msg_vel_cog { } /// Vertical velocity validity - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum VerticalVelocityValidity { /// Invalid Invalid = 0, @@ -6300,8 +6646,19 @@ pub mod msg_vel_cog { } } + impl TryFrom for VerticalVelocityValidity { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(VerticalVelocityValidity::Invalid), + 1 => Ok(VerticalVelocityValidity::VerticalVelocityValid), + _ => Err(TryFromIntError), + } + } + } + /// SOG validity - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum SogValidity { /// Invalid Invalid = 0, @@ -6319,8 +6676,19 @@ pub mod msg_vel_cog { } } + impl TryFrom for SogValidity { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(SogValidity::Invalid), + 1 => Ok(SogValidity::SogValid), + _ => Err(TryFromIntError), + } + } + } + /// COG validity - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum CogValidity { /// Invalid Invalid = 0, @@ -6338,27 +6706,19 @@ pub mod msg_vel_cog { } } - /// Type of reported TOW - #[derive(Debug, Clone, Copy, PartialEq, Eq)] - pub enum TypeOfReportedTow { - /// Time of Measurement - TimeOfMeasurement = 0, - - /// Other - Other = 1, - } - - impl std::fmt::Display for TypeOfReportedTow { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - TypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), - TypeOfReportedTow::Other => f.write_str("Other"), + impl TryFrom for CogValidity { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(CogValidity::Invalid), + 1 => Ok(CogValidity::CogValid), + _ => Err(TryFromIntError), } } } /// INS Navigation Mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InsNavigationMode { /// None None = 0, @@ -6376,8 +6736,19 @@ pub mod msg_vel_cog { } } + impl TryFrom for InsNavigationMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(InsNavigationMode::None), + 1 => Ok(InsNavigationMode::InsUsed), + _ => Err(TryFromIntError), + } + } + } + /// Velocity mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum VelocityMode { /// Invalid Invalid = 0, @@ -6402,6 +6773,19 @@ pub mod msg_vel_cog { } } } + + impl TryFrom for VelocityMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(VelocityMode::Invalid), + 1 => Ok(VelocityMode::MeasuredDopplerDerived), + 2 => Ok(VelocityMode::ComputedDopplerDerived), + 3 => Ok(VelocityMode::DeadReckoning), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_vel_ecef { @@ -6447,11 +6831,7 @@ pub mod msg_vel_ecef { impl MsgVelEcef { pub fn type_of_reported_tow(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 5) { - 0 => Some(TypeOfReportedTow::TimeOfMeasurement), - 1 => Some(TypeOfReportedTow::Other), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 5, 5).try_into().ok() } pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { @@ -6459,11 +6839,7 @@ pub mod msg_vel_ecef { } pub fn ins_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(InsNavigationMode::None), - 1 => Some(InsNavigationMode::InsUsed), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() } pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { @@ -6471,13 +6847,7 @@ pub mod msg_vel_ecef { } pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(VelocityMode::Invalid), - 1 => Some(VelocityMode::MeasuredDopplerDerived), - 2 => Some(VelocityMode::ComputedDopplerDerived), - 3 => Some(VelocityMode::DeadReckoning), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -6568,7 +6938,7 @@ pub mod msg_vel_ecef { } /// Type of reported TOW - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TypeOfReportedTow { /// Time of Measurement TimeOfMeasurement = 0, @@ -6586,8 +6956,19 @@ pub mod msg_vel_ecef { } } + impl TryFrom for TypeOfReportedTow { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TypeOfReportedTow::TimeOfMeasurement), + 1 => Ok(TypeOfReportedTow::Other), + _ => Err(TryFromIntError), + } + } + } + /// INS Navigation Mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InsNavigationMode { /// None None = 0, @@ -6605,8 +6986,19 @@ pub mod msg_vel_ecef { } } + impl TryFrom for InsNavigationMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(InsNavigationMode::None), + 1 => Ok(InsNavigationMode::InsUsed), + _ => Err(TryFromIntError), + } + } + } + /// Velocity mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum VelocityMode { /// Invalid Invalid = 0, @@ -6631,6 +7023,19 @@ pub mod msg_vel_ecef { } } } + + impl TryFrom for VelocityMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(VelocityMode::Invalid), + 1 => Ok(VelocityMode::MeasuredDopplerDerived), + 2 => Ok(VelocityMode::ComputedDopplerDerived), + 3 => Ok(VelocityMode::DeadReckoning), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_vel_ecef_cov { @@ -6691,11 +7096,7 @@ pub mod msg_vel_ecef_cov { impl MsgVelEcefCov { pub fn type_of_reported_tow(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 5) { - 0 => Some(TypeOfReportedTow::TimeOfMeasurement), - 1 => Some(TypeOfReportedTow::Other), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 5, 5).try_into().ok() } pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { @@ -6703,11 +7104,7 @@ pub mod msg_vel_ecef_cov { } pub fn ins_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(InsNavigationMode::None), - 1 => Some(InsNavigationMode::InsUsed), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() } pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { @@ -6715,13 +7112,7 @@ pub mod msg_vel_ecef_cov { } pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(VelocityMode::Invalid), - 1 => Some(VelocityMode::MeasuredDopplerDerived), - 2 => Some(VelocityMode::ComputedDopplerDerived), - 3 => Some(VelocityMode::DeadReckoning), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -6832,7 +7223,7 @@ pub mod msg_vel_ecef_cov { } /// Type of reported TOW - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TypeOfReportedTow { /// Time of Measurement TimeOfMeasurement = 0, @@ -6850,8 +7241,19 @@ pub mod msg_vel_ecef_cov { } } + impl TryFrom for TypeOfReportedTow { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TypeOfReportedTow::TimeOfMeasurement), + 1 => Ok(TypeOfReportedTow::Other), + _ => Err(TryFromIntError), + } + } + } + /// INS Navigation Mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InsNavigationMode { /// None None = 0, @@ -6869,8 +7271,19 @@ pub mod msg_vel_ecef_cov { } } + impl TryFrom for InsNavigationMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(InsNavigationMode::None), + 1 => Ok(InsNavigationMode::InsUsed), + _ => Err(TryFromIntError), + } + } + } + /// Velocity mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum VelocityMode { /// Invalid Invalid = 0, @@ -6895,6 +7308,19 @@ pub mod msg_vel_ecef_cov { } } } + + impl TryFrom for VelocityMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(VelocityMode::Invalid), + 1 => Ok(VelocityMode::MeasuredDopplerDerived), + 2 => Ok(VelocityMode::ComputedDopplerDerived), + 3 => Ok(VelocityMode::DeadReckoning), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_vel_ecef_cov_gnss { @@ -6955,12 +7381,7 @@ pub mod msg_vel_ecef_cov_gnss { impl MsgVelEcefCovGnss { pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(VelocityMode::Invalid), - 1 => Some(VelocityMode::MeasuredDopplerDerived), - 2 => Some(VelocityMode::ComputedDopplerDerived), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -7071,7 +7492,7 @@ pub mod msg_vel_ecef_cov_gnss { } /// Velocity mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum VelocityMode { /// Invalid Invalid = 0, @@ -7092,6 +7513,18 @@ pub mod msg_vel_ecef_cov_gnss { } } } + + impl TryFrom for VelocityMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(VelocityMode::Invalid), + 1 => Ok(VelocityMode::MeasuredDopplerDerived), + 2 => Ok(VelocityMode::ComputedDopplerDerived), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_vel_ecef_dep_a { @@ -7261,12 +7694,7 @@ pub mod msg_vel_ecef_gnss { impl MsgVelEcefGnss { pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(VelocityMode::Invalid), - 1 => Some(VelocityMode::MeasuredDopplerDerived), - 2 => Some(VelocityMode::ComputedDopplerDerived), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -7357,7 +7785,7 @@ pub mod msg_vel_ecef_gnss { } /// Velocity mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum VelocityMode { /// Invalid Invalid = 0, @@ -7378,6 +7806,18 @@ pub mod msg_vel_ecef_gnss { } } } + + impl TryFrom for VelocityMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(VelocityMode::Invalid), + 1 => Ok(VelocityMode::MeasuredDopplerDerived), + 2 => Ok(VelocityMode::ComputedDopplerDerived), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_vel_ned { @@ -7427,11 +7867,7 @@ pub mod msg_vel_ned { impl MsgVelNed { pub fn type_of_reported_tow(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 5) { - 0 => Some(TypeOfReportedTow::TimeOfMeasurement), - 1 => Some(TypeOfReportedTow::Other), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 5, 5).try_into().ok() } pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { @@ -7439,11 +7875,7 @@ pub mod msg_vel_ned { } pub fn ins_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(InsNavigationMode::None), - 1 => Some(InsNavigationMode::InsUsed), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() } pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { @@ -7451,13 +7883,7 @@ pub mod msg_vel_ned { } pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(VelocityMode::Invalid), - 1 => Some(VelocityMode::MeasuredDopplerDerived), - 2 => Some(VelocityMode::ComputedDopplerDerived), - 3 => Some(VelocityMode::DeadReckoning), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -7552,7 +7978,7 @@ pub mod msg_vel_ned { } /// Type of reported TOW - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TypeOfReportedTow { /// Time of Measurement TimeOfMeasurement = 0, @@ -7570,8 +7996,19 @@ pub mod msg_vel_ned { } } + impl TryFrom for TypeOfReportedTow { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TypeOfReportedTow::TimeOfMeasurement), + 1 => Ok(TypeOfReportedTow::Other), + _ => Err(TryFromIntError), + } + } + } + /// INS Navigation Mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InsNavigationMode { /// None None = 0, @@ -7589,8 +8026,19 @@ pub mod msg_vel_ned { } } + impl TryFrom for InsNavigationMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(InsNavigationMode::None), + 1 => Ok(InsNavigationMode::InsUsed), + _ => Err(TryFromIntError), + } + } + } + /// Velocity mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum VelocityMode { /// Invalid Invalid = 0, @@ -7615,6 +8063,19 @@ pub mod msg_vel_ned { } } } + + impl TryFrom for VelocityMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(VelocityMode::Invalid), + 1 => Ok(VelocityMode::MeasuredDopplerDerived), + 2 => Ok(VelocityMode::ComputedDopplerDerived), + 3 => Ok(VelocityMode::DeadReckoning), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_vel_ned_cov { @@ -7678,11 +8139,7 @@ pub mod msg_vel_ned_cov { impl MsgVelNedCov { pub fn type_of_reported_tow(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 5) { - 0 => Some(TypeOfReportedTow::TimeOfMeasurement), - 1 => Some(TypeOfReportedTow::Other), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 5, 5).try_into().ok() } pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { @@ -7690,11 +8147,7 @@ pub mod msg_vel_ned_cov { } pub fn ins_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(InsNavigationMode::None), - 1 => Some(InsNavigationMode::InsUsed), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() } pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { @@ -7702,13 +8155,7 @@ pub mod msg_vel_ned_cov { } pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(VelocityMode::Invalid), - 1 => Some(VelocityMode::MeasuredDopplerDerived), - 2 => Some(VelocityMode::ComputedDopplerDerived), - 3 => Some(VelocityMode::DeadReckoning), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -7819,7 +8266,7 @@ pub mod msg_vel_ned_cov { } /// Type of reported TOW - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TypeOfReportedTow { /// Time of Measurement TimeOfMeasurement = 0, @@ -7837,8 +8284,19 @@ pub mod msg_vel_ned_cov { } } + impl TryFrom for TypeOfReportedTow { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TypeOfReportedTow::TimeOfMeasurement), + 1 => Ok(TypeOfReportedTow::Other), + _ => Err(TryFromIntError), + } + } + } + /// INS Navigation Mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InsNavigationMode { /// None None = 0, @@ -7856,8 +8314,19 @@ pub mod msg_vel_ned_cov { } } + impl TryFrom for InsNavigationMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(InsNavigationMode::None), + 1 => Ok(InsNavigationMode::InsUsed), + _ => Err(TryFromIntError), + } + } + } + /// Velocity mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum VelocityMode { /// Invalid Invalid = 0, @@ -7882,6 +8351,19 @@ pub mod msg_vel_ned_cov { } } } + + impl TryFrom for VelocityMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(VelocityMode::Invalid), + 1 => Ok(VelocityMode::MeasuredDopplerDerived), + 2 => Ok(VelocityMode::ComputedDopplerDerived), + 3 => Ok(VelocityMode::DeadReckoning), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_vel_ned_cov_gnss { @@ -7945,12 +8427,7 @@ pub mod msg_vel_ned_cov_gnss { impl MsgVelNedCovGnss { pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(VelocityMode::Invalid), - 1 => Some(VelocityMode::MeasuredDopplerDerived), - 2 => Some(VelocityMode::ComputedDopplerDerived), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -8061,7 +8538,7 @@ pub mod msg_vel_ned_cov_gnss { } /// Velocity mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum VelocityMode { /// Invalid Invalid = 0, @@ -8082,6 +8559,18 @@ pub mod msg_vel_ned_cov_gnss { } } } + + impl TryFrom for VelocityMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(VelocityMode::Invalid), + 1 => Ok(VelocityMode::MeasuredDopplerDerived), + 2 => Ok(VelocityMode::ComputedDopplerDerived), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_vel_ned_dep_a { @@ -8263,12 +8752,7 @@ pub mod msg_vel_ned_gnss { impl MsgVelNedGnss { pub fn velocity_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(VelocityMode::Invalid), - 1 => Some(VelocityMode::MeasuredDopplerDerived), - 2 => Some(VelocityMode::ComputedDopplerDerived), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -8363,7 +8847,7 @@ pub mod msg_vel_ned_gnss { } /// Velocity mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum VelocityMode { /// Invalid Invalid = 0, @@ -8384,4 +8868,16 @@ pub mod msg_vel_ned_gnss { } } } + + impl TryFrom for VelocityMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(VelocityMode::Invalid), + 1 => Ok(VelocityMode::MeasuredDopplerDerived), + 2 => Ok(VelocityMode::ComputedDopplerDerived), + _ => Err(TryFromIntError), + } + } + } } diff --git a/rust/sbp/src/messages/ndb.rs b/rust/sbp/src/messages/ndb.rs index 962a265fe2..7d9e1127c2 100644 --- a/rust/sbp/src/messages/ndb.rs +++ b/rust/sbp/src/messages/ndb.rs @@ -67,13 +67,7 @@ pub mod msg_ndb_event { impl MsgNdbEvent { pub fn event_type(&self) -> Option { - match get_bit_range!(self.event, u8, u8, 1, 0) { - 0 => Some(EventType::UNKNOWN), - 1 => Some(EventType::STORE), - 2 => Some(EventType::FETCH), - 3 => Some(EventType::ERASE), - _ => None, - } + get_bit_range!(self.event, u8, u8, 1, 0).try_into().ok() } pub fn set_event_type(&mut self, event_type: EventType) { @@ -81,16 +75,9 @@ pub mod msg_ndb_event { } pub fn event_object_type(&self) -> Option { - match get_bit_range!(self.object_type, u8, u8, 2, 0) { - 0 => Some(EventObjectType::UNKNOWN), - 1 => Some(EventObjectType::EPHEMERIS), - 2 => Some(EventObjectType::ALMANAC), - 3 => Some(EventObjectType::AlmanacWn), - 4 => Some(EventObjectType::IoNO), - 5 => Some(EventObjectType::L2CCap), - 6 => Some(EventObjectType::LGF), - _ => None, - } + get_bit_range!(self.object_type, u8, u8, 2, 0) + .try_into() + .ok() } pub fn set_event_object_type(&mut self, event_object_type: EventObjectType) { @@ -98,20 +85,7 @@ pub mod msg_ndb_event { } pub fn event_result(&self) -> Option { - match get_bit_range!(self.result, u8, u8, 3, 0) { - 0 => Some(EventResult::NdbErrNone), - 1 => Some(EventResult::NdbErrMissingIe), - 2 => Some(EventResult::NdbErrUnsupported), - 3 => Some(EventResult::NdbErrFileIo), - 4 => Some(EventResult::NdbErrInitDone), - 5 => Some(EventResult::NdbErrBadParam), - 6 => Some(EventResult::NdbErrUnreliableData), - 7 => Some(EventResult::NdbErrAlgorithmError), - 8 => Some(EventResult::NdbErrNoData), - 9 => Some(EventResult::NdbErrNoChange), - 10 => Some(EventResult::NdbErrOlderData), - _ => None, - } + get_bit_range!(self.result, u8, u8, 3, 0).try_into().ok() } pub fn set_event_result(&mut self, event_result: EventResult) { @@ -119,13 +93,9 @@ pub mod msg_ndb_event { } pub fn data_source(&self) -> Option { - match get_bit_range!(self.data_source, u8, u8, 1, 0) { - 0 => Some(DataSource::NdbDsUndefined), - 1 => Some(DataSource::NdbDsInit), - 2 => Some(DataSource::NdbDsReceiver), - 3 => Some(DataSource::NdbDsSbp), - _ => None, - } + get_bit_range!(self.data_source, u8, u8, 1, 0) + .try_into() + .ok() } pub fn set_data_source(&mut self, data_source: DataSource) { @@ -211,7 +181,7 @@ pub mod msg_ndb_event { } /// Event type. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum EventType { /// UNKNOWN UNKNOWN = 0, @@ -237,8 +207,21 @@ pub mod msg_ndb_event { } } + impl TryFrom for EventType { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(EventType::UNKNOWN), + 1 => Ok(EventType::STORE), + 2 => Ok(EventType::FETCH), + 3 => Ok(EventType::ERASE), + _ => Err(TryFromIntError), + } + } + } + /// Event object type. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum EventObjectType { /// UNKNOWN UNKNOWN = 0, @@ -276,8 +259,24 @@ pub mod msg_ndb_event { } } + impl TryFrom for EventObjectType { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(EventObjectType::UNKNOWN), + 1 => Ok(EventObjectType::EPHEMERIS), + 2 => Ok(EventObjectType::ALMANAC), + 3 => Ok(EventObjectType::AlmanacWn), + 4 => Ok(EventObjectType::IoNO), + 5 => Ok(EventObjectType::L2CCap), + 6 => Ok(EventObjectType::LGF), + _ => Err(TryFromIntError), + } + } + } + /// Event result. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum EventResult { /// NDB_ERR_NONE NdbErrNone = 0, @@ -331,8 +330,28 @@ pub mod msg_ndb_event { } } + impl TryFrom for EventResult { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(EventResult::NdbErrNone), + 1 => Ok(EventResult::NdbErrMissingIe), + 2 => Ok(EventResult::NdbErrUnsupported), + 3 => Ok(EventResult::NdbErrFileIo), + 4 => Ok(EventResult::NdbErrInitDone), + 5 => Ok(EventResult::NdbErrBadParam), + 6 => Ok(EventResult::NdbErrUnreliableData), + 7 => Ok(EventResult::NdbErrAlgorithmError), + 8 => Ok(EventResult::NdbErrNoData), + 9 => Ok(EventResult::NdbErrNoChange), + 10 => Ok(EventResult::NdbErrOlderData), + _ => Err(TryFromIntError), + } + } + } + /// Data source. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum DataSource { /// NDB_DS_UNDEFINED NdbDsUndefined = 0, @@ -357,4 +376,17 @@ pub mod msg_ndb_event { } } } + + impl TryFrom for DataSource { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(DataSource::NdbDsUndefined), + 1 => Ok(DataSource::NdbDsInit), + 2 => Ok(DataSource::NdbDsReceiver), + 3 => Ok(DataSource::NdbDsSbp), + _ => Err(TryFromIntError), + } + } + } } diff --git a/rust/sbp/src/messages/observation.rs b/rust/sbp/src/messages/observation.rs index d86c4fcf24..cd851fa118 100644 --- a/rust/sbp/src/messages/observation.rs +++ b/rust/sbp/src/messages/observation.rs @@ -6351,11 +6351,7 @@ pub mod packed_obs_content { impl PackedObsContent { pub fn raim_exclusion(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 7, 0) { - 0 => Some(RaimExclusion::NoExclusion), - 1 => Some(RaimExclusion::MeasurementWasExcludedBySppRaimUseWithCare), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 7, 0).try_into().ok() } pub fn set_raim_exclusion(&mut self, raim_exclusion: RaimExclusion) { @@ -6363,11 +6359,7 @@ pub mod packed_obs_content { } pub fn doppler_valid(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 0) { - 0 => Some(DopplerValid::InvalidDopplerMeasurement), - 1 => Some(DopplerValid::ValidDopplerMeasurement), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 3, 0).try_into().ok() } pub fn set_doppler_valid(&mut self, doppler_valid: DopplerValid) { @@ -6375,11 +6367,7 @@ pub mod packed_obs_content { } pub fn halfcycle_ambiguity(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(HalfCycleAmbiguity::HalfCyclePhaseAmbiguityUnresolved), - 1 => Some(HalfCycleAmbiguity::HalfCyclePhaseAmbiguityResolved), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_halfcycle_ambiguity(&mut self, halfcycle_ambiguity: HalfCycleAmbiguity) { @@ -6387,11 +6375,7 @@ pub mod packed_obs_content { } pub fn carrier_phase_valid(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 1, 0) { - 0 => Some(CarrierPhaseValid::InvalidCarrierPhaseMeasurement), - 1 => Some(CarrierPhaseValid::ValidCarrierPhaseMeasurement), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() } pub fn set_carrier_phase_valid(&mut self, carrier_phase_valid: CarrierPhaseValid) { @@ -6399,11 +6383,7 @@ pub mod packed_obs_content { } pub fn pseudorange_valid(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 0, 0) { - 0 => Some(PseudorangeValid::InvalidPseudorangeMeasurement), - 1 => Some(PseudorangeValid::ValidPseudorangeMeasurementAndCoarseTowDecoded), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 0, 0).try_into().ok() } pub fn set_pseudorange_valid(&mut self, pseudorange_valid: PseudorangeValid) { @@ -6451,7 +6431,7 @@ pub mod packed_obs_content { } /// RAIM exclusion - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum RaimExclusion { /// No exclusion NoExclusion = 0, @@ -6471,8 +6451,19 @@ pub mod packed_obs_content { } } + impl TryFrom for RaimExclusion { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(RaimExclusion::NoExclusion), + 1 => Ok(RaimExclusion::MeasurementWasExcludedBySppRaimUseWithCare), + _ => Err(TryFromIntError), + } + } + } + /// Doppler valid - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum DopplerValid { /// Invalid doppler measurement InvalidDopplerMeasurement = 0, @@ -6492,8 +6483,19 @@ pub mod packed_obs_content { } } + impl TryFrom for DopplerValid { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(DopplerValid::InvalidDopplerMeasurement), + 1 => Ok(DopplerValid::ValidDopplerMeasurement), + _ => Err(TryFromIntError), + } + } + } + /// Half-cycle ambiguity - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum HalfCycleAmbiguity { /// Half cycle phase ambiguity unresolved HalfCyclePhaseAmbiguityUnresolved = 0, @@ -6515,8 +6517,19 @@ pub mod packed_obs_content { } } + impl TryFrom for HalfCycleAmbiguity { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(HalfCycleAmbiguity::HalfCyclePhaseAmbiguityUnresolved), + 1 => Ok(HalfCycleAmbiguity::HalfCyclePhaseAmbiguityResolved), + _ => Err(TryFromIntError), + } + } + } + /// Carrier phase valid - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum CarrierPhaseValid { /// Invalid carrier phase measurement InvalidCarrierPhaseMeasurement = 0, @@ -6538,8 +6551,19 @@ pub mod packed_obs_content { } } + impl TryFrom for CarrierPhaseValid { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(CarrierPhaseValid::InvalidCarrierPhaseMeasurement), + 1 => Ok(CarrierPhaseValid::ValidCarrierPhaseMeasurement), + _ => Err(TryFromIntError), + } + } + } + /// Pseudorange valid - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum PseudorangeValid { /// Invalid pseudorange measurement InvalidPseudorangeMeasurement = 0, @@ -6560,6 +6584,17 @@ pub mod packed_obs_content { } } } + + impl TryFrom for PseudorangeValid { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(PseudorangeValid::InvalidPseudorangeMeasurement), + 1 => Ok(PseudorangeValid::ValidPseudorangeMeasurementAndCoarseTowDecoded), + _ => Err(TryFromIntError), + } + } + } } pub mod packed_obs_content_dep_a { @@ -6807,11 +6842,7 @@ pub mod packed_osr_content { impl PackedOsrContent { pub fn invalid_phase_corrections(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 0) { - 0 => Some(InvalidPhaseCorrections::ValidPhaseCorrections), - 1 => Some(InvalidPhaseCorrections::DoNotUsePhaseCorrections), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 0).try_into().ok() } pub fn set_invalid_phase_corrections( @@ -6822,11 +6853,7 @@ pub mod packed_osr_content { } pub fn invalid_code_corrections(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 0) { - 0 => Some(InvalidCodeCorrections::ValidCodeCorrections), - 1 => Some(InvalidCodeCorrections::DoNotUseCodeCorrections), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 3, 0).try_into().ok() } pub fn set_invalid_code_corrections( @@ -6837,11 +6864,7 @@ pub mod packed_osr_content { } pub fn full_fixing_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(FullFixingFlag::FullFixingUnavailable), - 1 => Some(FullFixingFlag::FullFixingAvailable), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_full_fixing_flag(&mut self, full_fixing_flag: FullFixingFlag) { @@ -6849,11 +6872,7 @@ pub mod packed_osr_content { } pub fn partial_fixing_flag(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 1, 0) { - 0 => Some(PartialFixingFlag::PartialFixingUnavailable), - 1 => Some(PartialFixingFlag::PartialFixingAvailable), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() } pub fn set_partial_fixing_flag(&mut self, partial_fixing_flag: PartialFixingFlag) { @@ -6861,11 +6880,7 @@ pub mod packed_osr_content { } pub fn correction_validity(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 0, 0) { - 0 => Some(CorrectionValidity::DoNotUseSignal), - 1 => Some(CorrectionValidity::ValidSignal), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 0, 0).try_into().ok() } pub fn set_correction_validity(&mut self, correction_validity: CorrectionValidity) { @@ -6917,7 +6932,7 @@ pub mod packed_osr_content { } /// Invalid phase corrections - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InvalidPhaseCorrections { /// Valid phase corrections ValidPhaseCorrections = 0, @@ -6939,8 +6954,19 @@ pub mod packed_osr_content { } } + impl TryFrom for InvalidPhaseCorrections { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(InvalidPhaseCorrections::ValidPhaseCorrections), + 1 => Ok(InvalidPhaseCorrections::DoNotUsePhaseCorrections), + _ => Err(TryFromIntError), + } + } + } + /// Invalid code corrections - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InvalidCodeCorrections { /// Valid code corrections ValidCodeCorrections = 0, @@ -6962,8 +6988,19 @@ pub mod packed_osr_content { } } + impl TryFrom for InvalidCodeCorrections { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(InvalidCodeCorrections::ValidCodeCorrections), + 1 => Ok(InvalidCodeCorrections::DoNotUseCodeCorrections), + _ => Err(TryFromIntError), + } + } + } + /// Full fixing flag - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FullFixingFlag { /// Full fixing unavailable FullFixingUnavailable = 0, @@ -6981,8 +7018,19 @@ pub mod packed_osr_content { } } + impl TryFrom for FullFixingFlag { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FullFixingFlag::FullFixingUnavailable), + 1 => Ok(FullFixingFlag::FullFixingAvailable), + _ => Err(TryFromIntError), + } + } + } + /// Partial fixing flag - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum PartialFixingFlag { /// Partial fixing unavailable PartialFixingUnavailable = 0, @@ -7004,8 +7052,19 @@ pub mod packed_osr_content { } } + impl TryFrom for PartialFixingFlag { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(PartialFixingFlag::PartialFixingUnavailable), + 1 => Ok(PartialFixingFlag::PartialFixingAvailable), + _ => Err(TryFromIntError), + } + } + } + /// Correction validity - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum CorrectionValidity { /// Do not use signal DoNotUseSignal = 0, @@ -7022,6 +7081,17 @@ pub mod packed_osr_content { } } } + + impl TryFrom for CorrectionValidity { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(CorrectionValidity::DoNotUseSignal), + 1 => Ok(CorrectionValidity::ValidSignal), + _ => Err(TryFromIntError), + } + } + } } pub mod sv_az_el { diff --git a/rust/sbp/src/messages/orientation.rs b/rust/sbp/src/messages/orientation.rs index fbdb81fcaf..c6be44ff21 100644 --- a/rust/sbp/src/messages/orientation.rs +++ b/rust/sbp/src/messages/orientation.rs @@ -61,11 +61,7 @@ pub mod msg_angular_rate { impl MsgAngularRate { pub fn ins_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(InsNavigationMode::Invalid), - 1 => Some(InsNavigationMode::Valid), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { @@ -148,7 +144,7 @@ pub mod msg_angular_rate { } /// INS Navigation mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InsNavigationMode { /// Invalid Invalid = 0, @@ -165,6 +161,17 @@ pub mod msg_angular_rate { } } } + + impl TryFrom for InsNavigationMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(InsNavigationMode::Invalid), + 1 => Ok(InsNavigationMode::Valid), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_baseline_heading { @@ -203,13 +210,7 @@ pub mod msg_baseline_heading { impl MsgBaselineHeading { pub fn fix_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(FixMode::Invalid), - 2 => Some(FixMode::DifferentialGnss), - 3 => Some(FixMode::FloatRtk), - 4 => Some(FixMode::FixedRtk), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -288,7 +289,7 @@ pub mod msg_baseline_heading { } /// Fix mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FixMode { /// Invalid Invalid = 0, @@ -313,6 +314,19 @@ pub mod msg_baseline_heading { } } } + + impl TryFrom for FixMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FixMode::Invalid), + 2 => Ok(FixMode::DifferentialGnss), + 3 => Ok(FixMode::FloatRtk), + 4 => Ok(FixMode::FixedRtk), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_orient_euler { @@ -364,11 +378,7 @@ pub mod msg_orient_euler { impl MsgOrientEuler { pub fn ins_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(InsNavigationMode::Invalid), - 1 => Some(InsNavigationMode::Valid), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { @@ -463,7 +473,7 @@ pub mod msg_orient_euler { } /// INS Navigation mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InsNavigationMode { /// Invalid Invalid = 0, @@ -480,6 +490,17 @@ pub mod msg_orient_euler { } } } + + impl TryFrom for InsNavigationMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(InsNavigationMode::Invalid), + 1 => Ok(InsNavigationMode::Valid), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_orient_quat { @@ -537,11 +558,7 @@ pub mod msg_orient_quat { impl MsgOrientQuat { pub fn ins_navigation_mode(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(InsNavigationMode::Invalid), - 1 => Some(InsNavigationMode::Valid), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { @@ -644,7 +661,7 @@ pub mod msg_orient_quat { } /// INS Navigation mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InsNavigationMode { /// Invalid Invalid = 0, @@ -661,4 +678,15 @@ pub mod msg_orient_quat { } } } + + impl TryFrom for InsNavigationMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(InsNavigationMode::Invalid), + 1 => Ok(InsNavigationMode::Valid), + _ => Err(TryFromIntError), + } + } + } } diff --git a/rust/sbp/src/messages/piksi.rs b/rust/sbp/src/messages/piksi.rs index 0d95be3779..1c5d7da8cd 100644 --- a/rust/sbp/src/messages/piksi.rs +++ b/rust/sbp/src/messages/piksi.rs @@ -978,11 +978,7 @@ pub mod msg_mask_satellite { impl MsgMaskSatellite { pub fn tracking_channels(&self) -> Option { - match get_bit_range!(self.mask, u8, u8, 1, 0) { - 0 => Some(TrackingChannels::Enabled), - 1 => Some(TrackingChannels::DropThisPrnIfCurrentlyTracking), - _ => None, - } + get_bit_range!(self.mask, u8, u8, 1, 0).try_into().ok() } pub fn set_tracking_channels(&mut self, tracking_channels: TrackingChannels) { @@ -990,11 +986,7 @@ pub mod msg_mask_satellite { } pub fn acquisition_channel(&self) -> Option { - match get_bit_range!(self.mask, u8, u8, 0, 0) { - 0 => Some(AcquisitionChannel::Enabled), - 1 => Some(AcquisitionChannel::SkipThisSatelliteOnFutureAcquisitions), - _ => None, - } + get_bit_range!(self.mask, u8, u8, 0, 0).try_into().ok() } pub fn set_acquisition_channel(&mut self, acquisition_channel: AcquisitionChannel) { @@ -1054,7 +1046,7 @@ pub mod msg_mask_satellite { } /// Tracking channels - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TrackingChannels { /// Enabled Enabled = 0, @@ -1074,8 +1066,19 @@ pub mod msg_mask_satellite { } } + impl TryFrom for TrackingChannels { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TrackingChannels::Enabled), + 1 => Ok(TrackingChannels::DropThisPrnIfCurrentlyTracking), + _ => Err(TryFromIntError), + } + } + } + /// Acquisition channel - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum AcquisitionChannel { /// Enabled Enabled = 0, @@ -1094,6 +1097,17 @@ pub mod msg_mask_satellite { } } } + + impl TryFrom for AcquisitionChannel { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(AcquisitionChannel::Enabled), + 1 => Ok(AcquisitionChannel::SkipThisSatelliteOnFutureAcquisitions), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_mask_satellite_dep { @@ -1123,11 +1137,7 @@ pub mod msg_mask_satellite_dep { impl MsgMaskSatelliteDep { pub fn tracking_channels(&self) -> Option { - match get_bit_range!(self.mask, u8, u8, 1, 0) { - 0 => Some(TrackingChannels::Enabled), - 1 => Some(TrackingChannels::DropThisPrnIfCurrentlyTracking), - _ => None, - } + get_bit_range!(self.mask, u8, u8, 1, 0).try_into().ok() } pub fn set_tracking_channels(&mut self, tracking_channels: TrackingChannels) { @@ -1135,11 +1145,7 @@ pub mod msg_mask_satellite_dep { } pub fn acquisition_channel(&self) -> Option { - match get_bit_range!(self.mask, u8, u8, 0, 0) { - 0 => Some(AcquisitionChannel::Enabled), - 1 => Some(AcquisitionChannel::SkipThisSatelliteOnFutureAcquisitions), - _ => None, - } + get_bit_range!(self.mask, u8, u8, 0, 0).try_into().ok() } pub fn set_acquisition_channel(&mut self, acquisition_channel: AcquisitionChannel) { @@ -1199,7 +1205,7 @@ pub mod msg_mask_satellite_dep { } /// Tracking channels - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TrackingChannels { /// Enabled Enabled = 0, @@ -1219,8 +1225,19 @@ pub mod msg_mask_satellite_dep { } } + impl TryFrom for TrackingChannels { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TrackingChannels::Enabled), + 1 => Ok(TrackingChannels::DropThisPrnIfCurrentlyTracking), + _ => Err(TryFromIntError), + } + } + } + /// Acquisition channel - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum AcquisitionChannel { /// Enabled Enabled = 0, @@ -1239,6 +1256,17 @@ pub mod msg_mask_satellite_dep { } } } + + impl TryFrom for AcquisitionChannel { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(AcquisitionChannel::Enabled), + 1 => Ok(AcquisitionChannel::SkipThisSatelliteOnFutureAcquisitions), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_network_bandwidth_usage { @@ -1795,11 +1823,7 @@ pub mod msg_reset { impl MsgReset { pub fn default_settings(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 0, 0) { - 0 => Some(DefaultSettings::PreserveExistingSettings), - 1 => Some(DefaultSettings::ResoreDefaultSettings), - _ => None, - } + get_bit_range!(self.flags, u32, u8, 0, 0).try_into().ok() } pub fn set_default_settings(&mut self, default_settings: DefaultSettings) { @@ -1857,7 +1881,7 @@ pub mod msg_reset { } /// Default settings. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum DefaultSettings { /// Preserve existing settings. PreserveExistingSettings = 0, @@ -1876,6 +1900,17 @@ pub mod msg_reset { } } } + + impl TryFrom for DefaultSettings { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(DefaultSettings::PreserveExistingSettings), + 1 => Ok(DefaultSettings::ResoreDefaultSettings), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_reset_dep { @@ -1967,12 +2002,7 @@ pub mod msg_reset_filters { impl MsgResetFilters { pub fn filter_or_process_to_reset(&self) -> Option { - match get_bit_range!(self.filter, u8, u8, 1, 0) { - 0 => Some(FilterOrProcessToReset::DgnssFilter), - 1 => Some(FilterOrProcessToReset::IarProcess), - 2 => Some(FilterOrProcessToReset::InertialFilter), - _ => None, - } + get_bit_range!(self.filter, u8, u8, 1, 0).try_into().ok() } pub fn set_filter_or_process_to_reset( @@ -2033,7 +2063,7 @@ pub mod msg_reset_filters { } /// Filter or process to reset - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FilterOrProcessToReset { /// DGNSS filter DgnssFilter = 0, @@ -2054,6 +2084,18 @@ pub mod msg_reset_filters { } } } + + impl TryFrom for FilterOrProcessToReset { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FilterOrProcessToReset::DgnssFilter), + 1 => Ok(FilterOrProcessToReset::IarProcess), + 2 => Ok(FilterOrProcessToReset::InertialFilter), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_set_time { diff --git a/rust/sbp/src/messages/settings.rs b/rust/sbp/src/messages/settings.rs index e78ef99b9a..f62816101b 100644 --- a/rust/sbp/src/messages/settings.rs +++ b/rust/sbp/src/messages/settings.rs @@ -534,15 +534,7 @@ pub mod msg_settings_register_resp { impl MsgSettingsRegisterResp { pub fn register_status(&self) -> Option { - match get_bit_range!(self.status, u8, u8, 1, 0) { - 0 => Some(RegisterStatus::AcceptedRequestedDefaultValueReturned), - 1 => Some( - RegisterStatus::AcceptedSettingFoundInPermanentStorageValueFromStorageReturned, - ), - 2 => Some(RegisterStatus::RejectedSettingAlreadyRegisteredValueFromMemoryReturned), - 3 => Some(RegisterStatus::RejectedMalformedMessage), - _ => None, - } + get_bit_range!(self.status, u8, u8, 1, 0).try_into().ok() } pub fn set_register_status(&mut self, register_status: RegisterStatus) { @@ -603,7 +595,7 @@ pub mod msg_settings_register_resp { } /// Register status - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum RegisterStatus { /// Accepted; requested default value returned AcceptedRequestedDefaultValueReturned = 0, @@ -638,6 +630,21 @@ pub mod msg_settings_register_resp { } } } + + impl TryFrom for RegisterStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(RegisterStatus::AcceptedRequestedDefaultValueReturned), + 1 => Ok( + RegisterStatus::AcceptedSettingFoundInPermanentStorageValueFromStorageReturned, + ), + 2 => Ok(RegisterStatus::RejectedSettingAlreadyRegisteredValueFromMemoryReturned), + 3 => Ok(RegisterStatus::RejectedMalformedMessage), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_settings_save { @@ -815,16 +822,7 @@ pub mod msg_settings_write_resp { impl MsgSettingsWriteResp { pub fn write_status(&self) -> Option { - match get_bit_range!(self.status, u8, u8, 1, 0) { - 0 => Some(WriteStatus::AcceptedValueUpdated), - 1 => Some(WriteStatus::RejectedValueUnparsableOrOutOfRange), - 2 => Some(WriteStatus::RejectedRequestedSettingDoesNotExist), - 3 => Some(WriteStatus::RejectedSettingNameCouldNotBeParsed), - 4 => Some(WriteStatus::RejectedSettingIsReadOnly), - 5 => Some(WriteStatus::RejectedModificationIsTemporarilyDisabled), - 6 => Some(WriteStatus::RejectedUnspecifiedError), - _ => None, - } + get_bit_range!(self.status, u8, u8, 1, 0).try_into().ok() } pub fn set_write_status(&mut self, write_status: WriteStatus) { @@ -885,7 +883,7 @@ pub mod msg_settings_write_resp { } /// Write status - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum WriteStatus { /// Accepted; value updated AcceptedValueUpdated = 0, @@ -932,4 +930,20 @@ pub mod msg_settings_write_resp { } } } + + impl TryFrom for WriteStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(WriteStatus::AcceptedValueUpdated), + 1 => Ok(WriteStatus::RejectedValueUnparsableOrOutOfRange), + 2 => Ok(WriteStatus::RejectedRequestedSettingDoesNotExist), + 3 => Ok(WriteStatus::RejectedSettingNameCouldNotBeParsed), + 4 => Ok(WriteStatus::RejectedSettingIsReadOnly), + 5 => Ok(WriteStatus::RejectedModificationIsTemporarilyDisabled), + 6 => Ok(WriteStatus::RejectedUnspecifiedError), + _ => Err(TryFromIntError), + } + } + } } diff --git a/rust/sbp/src/messages/solution_meta.rs b/rust/sbp/src/messages/solution_meta.rs index 599a2c698d..b52a8197a5 100644 --- a/rust/sbp/src/messages/solution_meta.rs +++ b/rust/sbp/src/messages/solution_meta.rs @@ -42,12 +42,7 @@ pub mod gnss_input_type { impl GnssInputType { pub fn type_of_gnss_measurement(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 1, 0) { - 0 => Some(TypeOfGnssMeasurement::GnssPosition), - 1 => Some(TypeOfGnssMeasurement::GnssVelocityDoppler), - 2 => Some(TypeOfGnssMeasurement::GnssVelocityDisplacement), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() } pub fn set_type_of_gnss_measurement( @@ -74,7 +69,7 @@ pub mod gnss_input_type { } /// Type of GNSS measurement - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TypeOfGnssMeasurement { /// GNSS Position GnssPosition = 0, @@ -97,6 +92,18 @@ pub mod gnss_input_type { } } } + + impl TryFrom for TypeOfGnssMeasurement { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TypeOfGnssMeasurement::GnssPosition), + 1 => Ok(TypeOfGnssMeasurement::GnssVelocityDoppler), + 2 => Ok(TypeOfGnssMeasurement::GnssVelocityDisplacement), + _ => Err(TryFromIntError), + } + } + } } pub mod imu_input_type { @@ -121,13 +128,7 @@ pub mod imu_input_type { impl ImuInputType { pub fn time_status(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 4) { - 0 => Some(TimeStatus::ReferenceEpochIsStartOfCurrentGpsWeek), - 1 => Some(TimeStatus::ReferenceEpochIsTimeOfSystemStartup), - 2 => Some(TimeStatus::ReferenceEpochIsUnknown), - 3 => Some(TimeStatus::ReferenceEpochIsLastPps), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 5, 4).try_into().ok() } pub fn set_time_status(&mut self, time_status: TimeStatus) { @@ -135,13 +136,7 @@ pub mod imu_input_type { } pub fn imu_grade(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 2) { - 0 => Some(ImuGrade::ConsumerGrade), - 1 => Some(ImuGrade::TacticalGrade), - 2 => Some(ImuGrade::IntermediateGrade), - 3 => Some(ImuGrade::SuperiorGrade), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 3, 2).try_into().ok() } pub fn set_imu_grade(&mut self, imu_grade: ImuGrade) { @@ -149,11 +144,7 @@ pub mod imu_input_type { } pub fn imu_architecture(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 1, 0) { - 0 => Some(ImuArchitecture::_6AxisMems), - 1 => Some(ImuArchitecture::OtherType), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() } pub fn set_imu_architecture(&mut self, imu_architecture: ImuArchitecture) { @@ -177,7 +168,7 @@ pub mod imu_input_type { } /// Time status - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TimeStatus { /// Reference epoch is start of current GPS week ReferenceEpochIsStartOfCurrentGpsWeek = 0, @@ -207,8 +198,21 @@ pub mod imu_input_type { } } + impl TryFrom for TimeStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TimeStatus::ReferenceEpochIsStartOfCurrentGpsWeek), + 1 => Ok(TimeStatus::ReferenceEpochIsTimeOfSystemStartup), + 2 => Ok(TimeStatus::ReferenceEpochIsUnknown), + 3 => Ok(TimeStatus::ReferenceEpochIsLastPps), + _ => Err(TryFromIntError), + } + } + } + /// IMU Grade - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ImuGrade { /// Consumer Grade ConsumerGrade = 0, @@ -234,8 +238,21 @@ pub mod imu_input_type { } } + impl TryFrom for ImuGrade { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(ImuGrade::ConsumerGrade), + 1 => Ok(ImuGrade::TacticalGrade), + 2 => Ok(ImuGrade::IntermediateGrade), + 3 => Ok(ImuGrade::SuperiorGrade), + _ => Err(TryFromIntError), + } + } + } + /// IMU architecture - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ImuArchitecture { /// 6-axis MEMS _6AxisMems = 0, @@ -252,6 +269,17 @@ pub mod imu_input_type { } } } + + impl TryFrom for ImuArchitecture { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(ImuArchitecture::_6AxisMems), + 1 => Ok(ImuArchitecture::OtherType), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_soln_meta { @@ -311,11 +339,9 @@ pub mod msg_soln_meta { impl MsgSolnMeta { pub fn time_status(&self) -> Option { - match get_bit_range!(self.age_gnss, u32, u8, 31, 30) { - 0 => Some(TimeStatus::AgeCanNotBeUsedToRetrieveTom), - 1 => Some(TimeStatus::AgeCanBeUsedToRetrieveTom), - _ => None, - } + get_bit_range!(self.age_gnss, u32, u8, 31, 30) + .try_into() + .ok() } pub fn set_time_status(&mut self, time_status: TimeStatus) { @@ -424,7 +450,7 @@ pub mod msg_soln_meta { } /// Time status - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TimeStatus { /// Age can not be used to retrieve TOM AgeCanNotBeUsedToRetrieveTom = 0, @@ -445,6 +471,17 @@ pub mod msg_soln_meta { } } } + + impl TryFrom for TimeStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TimeStatus::AgeCanNotBeUsedToRetrieveTom), + 1 => Ok(TimeStatus::AgeCanBeUsedToRetrieveTom), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_soln_meta_dep_a { @@ -506,14 +543,9 @@ pub mod msg_soln_meta_dep_a { impl MsgSolnMetaDepA { pub fn alignment_status(&self) -> Option { - match get_bit_range!(self.alignment_status, u8, u8, 2, 0) { - 0 => Some(AlignmentStatus::UnknownReasonOrAlreadyAligned), - 1 => Some(AlignmentStatus::SeedValuesLoadedAndAlignmentInProgress), - 2 => Some(AlignmentStatus::NoSeedValuesAndAlignmentInProgress), - 3 => Some(AlignmentStatus::SeedValuesLoadedButNoGnssMeasurements), - 4 => Some(AlignmentStatus::NoSeedValuesNorGnssMeasurements), - _ => None, - } + get_bit_range!(self.alignment_status, u8, u8, 2, 0) + .try_into() + .ok() } pub fn set_alignment_status(&mut self, alignment_status: AlignmentStatus) { @@ -603,7 +635,7 @@ pub mod msg_soln_meta_dep_a { } /// Alignment status - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum AlignmentStatus { /// Unknown reason or already aligned UnknownReasonOrAlreadyAligned = 0, @@ -642,6 +674,20 @@ pub mod msg_soln_meta_dep_a { } } } + + impl TryFrom for AlignmentStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(AlignmentStatus::UnknownReasonOrAlreadyAligned), + 1 => Ok(AlignmentStatus::SeedValuesLoadedAndAlignmentInProgress), + 2 => Ok(AlignmentStatus::NoSeedValuesAndAlignmentInProgress), + 3 => Ok(AlignmentStatus::SeedValuesLoadedButNoGnssMeasurements), + 4 => Ok(AlignmentStatus::NoSeedValuesNorGnssMeasurements), + _ => Err(TryFromIntError), + } + } + } } pub mod odo_input_type { @@ -666,11 +712,7 @@ pub mod odo_input_type { impl OdoInputType { pub fn rate(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 5, 4) { - 0 => Some(Rate::FixedIncomingRate), - 1 => Some(Rate::TriggeredByMinimumDistanceOrSpeed), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 5, 4).try_into().ok() } pub fn set_rate(&mut self, rate: Rate) { @@ -678,12 +720,7 @@ pub mod odo_input_type { } pub fn odometer_grade(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 2) { - 0 => Some(OdometerGrade::LowGrade), - 1 => Some(OdometerGrade::MediumGrade), - 2 => Some(OdometerGrade::SuperiorGrade), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 3, 2).try_into().ok() } pub fn set_odometer_grade(&mut self, odometer_grade: OdometerGrade) { @@ -691,13 +728,7 @@ pub mod odo_input_type { } pub fn odometer_class(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 1, 0) { - 0 => Some(OdometerClass::SingleOrAveragedTicks), - 1 => Some(OdometerClass::SingleOrAveragedSpeed), - 2 => Some(OdometerClass::MultiDimensionalTicks), - 3 => Some(OdometerClass::MultiDimensionalSpeed), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() } pub fn set_odometer_class(&mut self, odometer_class: OdometerClass) { @@ -721,7 +752,7 @@ pub mod odo_input_type { } /// Rate - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Rate { /// Fixed incoming rate FixedIncomingRate = 0, @@ -741,8 +772,19 @@ pub mod odo_input_type { } } + impl TryFrom for Rate { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(Rate::FixedIncomingRate), + 1 => Ok(Rate::TriggeredByMinimumDistanceOrSpeed), + _ => Err(TryFromIntError), + } + } + } + /// Odometer grade - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum OdometerGrade { /// Low Grade (e.g. quantized CAN) LowGrade = 0, @@ -764,8 +806,20 @@ pub mod odo_input_type { } } + impl TryFrom for OdometerGrade { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(OdometerGrade::LowGrade), + 1 => Ok(OdometerGrade::MediumGrade), + 2 => Ok(OdometerGrade::SuperiorGrade), + _ => Err(TryFromIntError), + } + } + } + /// Odometer class - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum OdometerClass { /// Single or averaged ticks SingleOrAveragedTicks = 0, @@ -790,6 +844,19 @@ pub mod odo_input_type { } } } + + impl TryFrom for OdometerClass { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(OdometerClass::SingleOrAveragedTicks), + 1 => Ok(OdometerClass::SingleOrAveragedSpeed), + 2 => Ok(OdometerClass::MultiDimensionalTicks), + 3 => Ok(OdometerClass::MultiDimensionalSpeed), + _ => Err(TryFromIntError), + } + } + } } pub mod solution_input_type { @@ -821,12 +888,9 @@ pub mod solution_input_type { impl SolutionInputType { pub fn sensor_usage(&self) -> Option { - match get_bit_range!(self.sensor_type, u8, u8, 4, 3) { - 0 => Some(SensorUsage::Unknown), - 1 => Some(SensorUsage::ReceivedAndUsed), - 2 => Some(SensorUsage::ReceivedButNotUsed), - _ => None, - } + get_bit_range!(self.sensor_type, u8, u8, 4, 3) + .try_into() + .ok() } pub fn set_sensor_usage(&mut self, sensor_usage: SensorUsage) { @@ -834,16 +898,9 @@ pub mod solution_input_type { } pub fn sensor_type(&self) -> Option { - match get_bit_range!(self.sensor_type, u8, u8, 2, 0) { - 0 => Some(SensorType::Invalid), - 1 => Some(SensorType::GnssPosition), - 2 => Some(SensorType::GnssVelocityDisplacement), - 3 => Some(SensorType::GnssVelocityDoppler), - 4 => Some(SensorType::OdometryTicks), - 5 => Some(SensorType::OdometrySpeed), - 6 => Some(SensorType::ImuSensor), - _ => None, - } + get_bit_range!(self.sensor_type, u8, u8, 2, 0) + .try_into() + .ok() } pub fn set_sensor_type(&mut self, sensor_type: SensorType) { @@ -869,7 +926,7 @@ pub mod solution_input_type { } /// Sensor Usage - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum SensorUsage { /// Unknown Unknown = 0, @@ -891,8 +948,20 @@ pub mod solution_input_type { } } + impl TryFrom for SensorUsage { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(SensorUsage::Unknown), + 1 => Ok(SensorUsage::ReceivedAndUsed), + 2 => Ok(SensorUsage::ReceivedButNotUsed), + _ => Err(TryFromIntError), + } + } + } + /// Sensor Type - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum SensorType { /// Invalid Invalid = 0, @@ -933,4 +1002,20 @@ pub mod solution_input_type { } } } + + impl TryFrom for SensorType { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(SensorType::Invalid), + 1 => Ok(SensorType::GnssPosition), + 2 => Ok(SensorType::GnssVelocityDisplacement), + 3 => Ok(SensorType::GnssVelocityDoppler), + 4 => Ok(SensorType::OdometryTicks), + 5 => Ok(SensorType::OdometrySpeed), + 6 => Ok(SensorType::ImuSensor), + _ => Err(TryFromIntError), + } + } + } } diff --git a/rust/sbp/src/messages/ssr.rs b/rust/sbp/src/messages/ssr.rs index a514141ef0..3c3ed2ccdb 100644 --- a/rust/sbp/src/messages/ssr.rs +++ b/rust/sbp/src/messages/ssr.rs @@ -2024,29 +2024,7 @@ pub mod satellite_apc { impl SatelliteAPC { pub fn satellite_type(&self) -> Option { - match get_bit_range!(self.sat_info, u8, u8, 4, 0) { - 0 => Some(SatelliteType::UnknownType), - 1 => Some(SatelliteType::GpsI), - 2 => Some(SatelliteType::GpsIi), - 3 => Some(SatelliteType::GpsIia), - 4 => Some(SatelliteType::GpsIir), - 5 => Some(SatelliteType::GpsIif), - 6 => Some(SatelliteType::GpsIii), - 7 => Some(SatelliteType::GLONASS), - 8 => Some(SatelliteType::GlonassM), - 9 => Some(SatelliteType::GlonassK1), - 10 => Some(SatelliteType::GALILEO), - 11 => Some(SatelliteType::Beidou2G), - 12 => Some(SatelliteType::Beidou2I), - 13 => Some(SatelliteType::Beidou2M), - 14 => Some(SatelliteType::Beidou3MSecm), - 15 => Some(SatelliteType::Beidou3GSecm), - 16 => Some(SatelliteType::Beidou3MCast), - 17 => Some(SatelliteType::Beidou3GCast), - 18 => Some(SatelliteType::Beidou3ICast), - 19 => Some(SatelliteType::QZSS), - _ => None, - } + get_bit_range!(self.sat_info, u8, u8, 4, 0).try_into().ok() } pub fn set_satellite_type(&mut self, satellite_type: SatelliteType) { @@ -2086,7 +2064,7 @@ pub mod satellite_apc { } /// Satellite Type - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum SatelliteType { /// Unknown Type UnknownType = 0, @@ -2175,6 +2153,35 @@ pub mod satellite_apc { } } } + + impl TryFrom for SatelliteType { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(SatelliteType::UnknownType), + 1 => Ok(SatelliteType::GpsI), + 2 => Ok(SatelliteType::GpsIi), + 3 => Ok(SatelliteType::GpsIia), + 4 => Ok(SatelliteType::GpsIir), + 5 => Ok(SatelliteType::GpsIif), + 6 => Ok(SatelliteType::GpsIii), + 7 => Ok(SatelliteType::GLONASS), + 8 => Ok(SatelliteType::GlonassM), + 9 => Ok(SatelliteType::GlonassK1), + 10 => Ok(SatelliteType::GALILEO), + 11 => Ok(SatelliteType::Beidou2G), + 12 => Ok(SatelliteType::Beidou2I), + 13 => Ok(SatelliteType::Beidou2M), + 14 => Ok(SatelliteType::Beidou3MSecm), + 15 => Ok(SatelliteType::Beidou3GSecm), + 16 => Ok(SatelliteType::Beidou3MCast), + 17 => Ok(SatelliteType::Beidou3GCast), + 18 => Ok(SatelliteType::Beidou3ICast), + 19 => Ok(SatelliteType::QZSS), + _ => Err(TryFromIntError), + } + } + } } pub mod tropospheric_delay_correction { diff --git a/rust/sbp/src/messages/system.rs b/rust/sbp/src/messages/system.rs index 3ab165666e..f8d1239608 100644 --- a/rust/sbp/src/messages/system.rs +++ b/rust/sbp/src/messages/system.rs @@ -220,12 +220,7 @@ pub mod msg_dgnss_status { impl MsgDgnssStatus { pub fn differential_type(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 0) { - 0 => Some(DifferentialType::Invalid), - 1 => Some(DifferentialType::CodeDifference), - 2 => Some(DifferentialType::RTK), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 3, 0).try_into().ok() } pub fn set_differential_type(&mut self, differential_type: DifferentialType) { @@ -295,7 +290,7 @@ pub mod msg_dgnss_status { } /// Differential type - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum DifferentialType { /// Invalid Invalid = 0, @@ -316,6 +311,18 @@ pub mod msg_dgnss_status { } } } + + impl TryFrom for DifferentialType { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(DifferentialType::Invalid), + 1 => Ok(DifferentialType::CodeDifference), + 2 => Ok(DifferentialType::RTK), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_gnss_time_offset { @@ -447,12 +454,7 @@ pub mod msg_group_meta { impl MsgGroupMeta { pub fn solution_group_type(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 1, 0) { - 0 => Some(SolutionGroupType::None), - 1 => Some(SolutionGroupType::GnssOnly), - 2 => Some(SolutionGroupType::GnssINS), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() } pub fn set_solution_group_type(&mut self, solution_group_type: SolutionGroupType) { @@ -522,7 +524,7 @@ pub mod msg_group_meta { } /// Solution Group type - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum SolutionGroupType { /// None (invalid) None = 0, @@ -543,6 +545,18 @@ pub mod msg_group_meta { } } } + + impl TryFrom for SolutionGroupType { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(SolutionGroupType::None), + 1 => Ok(SolutionGroupType::GnssOnly), + 2 => Ok(SolutionGroupType::GnssINS), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_heartbeat { @@ -576,11 +590,7 @@ pub mod msg_heartbeat { impl MsgHeartbeat { pub fn external_antenna_present(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 31, 0) { - 0 => Some(ExternalAntennaPresent::NoExternalAntennaDetected), - 1 => Some(ExternalAntennaPresent::ExternalAntennaIsPresent), - _ => None, - } + get_bit_range!(self.flags, u32, u8, 31, 0).try_into().ok() } pub fn set_external_antenna_present( @@ -591,11 +601,7 @@ pub mod msg_heartbeat { } pub fn external_antenna_short(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 30, 0) { - 0 => Some(ExternalAntennaShort::NoShortDetected), - 1 => Some(ExternalAntennaShort::ShortDetected), - _ => None, - } + get_bit_range!(self.flags, u32, u8, 30, 0).try_into().ok() } pub fn set_external_antenna_short(&mut self, external_antenna_short: ExternalAntennaShort) { @@ -639,11 +645,7 @@ pub mod msg_heartbeat { } pub fn swift_nap_error(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 2, 0) { - 0 => Some(SwiftNapError::SystemHealthy), - 1 => Some(SwiftNapError::AnErrorHasOccurredInTheSwiftNap), - _ => None, - } + get_bit_range!(self.flags, u32, u8, 2, 0).try_into().ok() } pub fn set_swift_nap_error(&mut self, swift_nap_error: SwiftNapError) { @@ -651,11 +653,7 @@ pub mod msg_heartbeat { } pub fn io_error(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 1, 0) { - 0 => Some(IoError::SystemHealthy), - 1 => Some(IoError::AnIoErrorHasOccurred), - _ => None, - } + get_bit_range!(self.flags, u32, u8, 1, 0).try_into().ok() } pub fn set_io_error(&mut self, io_error: IoError) { @@ -663,11 +661,7 @@ pub mod msg_heartbeat { } pub fn system_error_flag(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 0, 0) { - 0 => Some(SystemErrorFlag::SystemHealthy), - 1 => Some(SystemErrorFlag::AnErrorHasOccurred), - _ => None, - } + get_bit_range!(self.flags, u32, u8, 0, 0).try_into().ok() } pub fn set_system_error_flag(&mut self, system_error_flag: SystemErrorFlag) { @@ -725,7 +719,7 @@ pub mod msg_heartbeat { } /// External antenna present - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ExternalAntennaPresent { /// No external antenna detected NoExternalAntennaDetected = 0, @@ -747,8 +741,19 @@ pub mod msg_heartbeat { } } + impl TryFrom for ExternalAntennaPresent { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(ExternalAntennaPresent::NoExternalAntennaDetected), + 1 => Ok(ExternalAntennaPresent::ExternalAntennaIsPresent), + _ => Err(TryFromIntError), + } + } + } + /// External antenna short - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ExternalAntennaShort { /// No short detected NoShortDetected = 0, @@ -766,8 +771,19 @@ pub mod msg_heartbeat { } } + impl TryFrom for ExternalAntennaShort { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(ExternalAntennaShort::NoShortDetected), + 1 => Ok(ExternalAntennaShort::ShortDetected), + _ => Err(TryFromIntError), + } + } + } + /// SwiftNAP Error - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum SwiftNapError { /// System Healthy SystemHealthy = 0, @@ -787,8 +803,19 @@ pub mod msg_heartbeat { } } + impl TryFrom for SwiftNapError { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(SwiftNapError::SystemHealthy), + 1 => Ok(SwiftNapError::AnErrorHasOccurredInTheSwiftNap), + _ => Err(TryFromIntError), + } + } + } + /// IO Error - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum IoError { /// System Healthy SystemHealthy = 0, @@ -806,8 +833,19 @@ pub mod msg_heartbeat { } } + impl TryFrom for IoError { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(IoError::SystemHealthy), + 1 => Ok(IoError::AnIoErrorHasOccurred), + _ => Err(TryFromIntError), + } + } + } + /// System Error Flag - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum SystemErrorFlag { /// System Healthy SystemHealthy = 0, @@ -824,6 +862,17 @@ pub mod msg_heartbeat { } } } + + impl TryFrom for SystemErrorFlag { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(SystemErrorFlag::SystemHealthy), + 1 => Ok(SystemErrorFlag::AnErrorHasOccurred), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_ins_status { @@ -850,11 +899,7 @@ pub mod msg_ins_status { impl MsgInsStatus { pub fn ins_type(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 31, 29) { - 0 => Some(InsType::SmoothposeLooselyCoupled), - 1 => Some(InsType::Starling), - _ => None, - } + get_bit_range!(self.flags, u32, u8, 31, 29).try_into().ok() } pub fn set_ins_type(&mut self, ins_type: InsType) { @@ -862,13 +907,7 @@ pub mod msg_ins_status { } pub fn motion_state(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 13, 11) { - 0 => Some(MotionState::UnknownOrInit), - 1 => Some(MotionState::ArbitraryMotion), - 2 => Some(MotionState::StraightMotion), - 3 => Some(MotionState::Stationary), - _ => None, - } + get_bit_range!(self.flags, u32, u8, 13, 11).try_into().ok() } pub fn set_motion_state(&mut self, motion_state: MotionState) { @@ -876,11 +915,7 @@ pub mod msg_ins_status { } pub fn odometry_synch(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 10, 0) { - 0 => Some(OdometrySynch::OdometryTimestampNominal), - 1 => Some(OdometrySynch::OdometryTimestampOutOfBounds), - _ => None, - } + get_bit_range!(self.flags, u32, u8, 10, 0).try_into().ok() } pub fn set_odometry_synch(&mut self, odometry_synch: OdometrySynch) { @@ -888,12 +923,7 @@ pub mod msg_ins_status { } pub fn odometry_status(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 9, 8) { - 0 => Some(OdometryStatus::NoOdometry), - 1 => Some(OdometryStatus::OdometryReceivedWithinLastSecond), - 2 => Some(OdometryStatus::OdometryNotReceivedWithinLastSecond), - _ => None, - } + get_bit_range!(self.flags, u32, u8, 9, 8).try_into().ok() } pub fn set_odometry_status(&mut self, odometry_status: OdometryStatus) { @@ -901,12 +931,7 @@ pub mod msg_ins_status { } pub fn ins_error(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 7, 4) { - 1 => Some(InsError::ImuDataError), - 2 => Some(InsError::InsLicenseError), - 3 => Some(InsError::ImuCalibrationDataError), - _ => None, - } + get_bit_range!(self.flags, u32, u8, 7, 4).try_into().ok() } pub fn set_ins_error(&mut self, ins_error: InsError) { @@ -914,11 +939,7 @@ pub mod msg_ins_status { } pub fn gnss_fix(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 3, 0) { - 0 => Some(GnssFix::NoGnssFixAvailable), - 1 => Some(GnssFix::GnssFix), - _ => None, - } + get_bit_range!(self.flags, u32, u8, 3, 0).try_into().ok() } pub fn set_gnss_fix(&mut self, gnss_fix: GnssFix) { @@ -926,16 +947,7 @@ pub mod msg_ins_status { } pub fn mode(&self) -> Option { - match get_bit_range!(self.flags, u32, u8, 2, 0) { - 0 => Some(Mode::AwaitingInitialization), - 1 => Some(Mode::DynamicallyAligning), - 2 => Some(Mode::Ready), - 3 => Some(Mode::GnssOutageExceedsMaxDuration), - 4 => Some(Mode::FastStartSeeding), - 5 => Some(Mode::FastStartValidating), - 6 => Some(Mode::ValidatingUnsafeFastStartSeed), - _ => None, - } + get_bit_range!(self.flags, u32, u8, 2, 0).try_into().ok() } pub fn set_mode(&mut self, mode: Mode) { @@ -993,7 +1005,7 @@ pub mod msg_ins_status { } /// INS Type - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InsType { /// Smoothpose Loosely Coupled SmoothposeLooselyCoupled = 0, @@ -1011,8 +1023,19 @@ pub mod msg_ins_status { } } + impl TryFrom for InsType { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(InsType::SmoothposeLooselyCoupled), + 1 => Ok(InsType::Starling), + _ => Err(TryFromIntError), + } + } + } + /// Motion State - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum MotionState { /// Unknown or Init UnknownOrInit = 0, @@ -1038,8 +1061,21 @@ pub mod msg_ins_status { } } + impl TryFrom for MotionState { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(MotionState::UnknownOrInit), + 1 => Ok(MotionState::ArbitraryMotion), + 2 => Ok(MotionState::StraightMotion), + 3 => Ok(MotionState::Stationary), + _ => Err(TryFromIntError), + } + } + } + /// Odometry Synch - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum OdometrySynch { /// Odometry timestamp nominal OdometryTimestampNominal = 0, @@ -1061,8 +1097,19 @@ pub mod msg_ins_status { } } + impl TryFrom for OdometrySynch { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(OdometrySynch::OdometryTimestampNominal), + 1 => Ok(OdometrySynch::OdometryTimestampOutOfBounds), + _ => Err(TryFromIntError), + } + } + } + /// Odometry status - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum OdometryStatus { /// No Odometry NoOdometry = 0, @@ -1088,8 +1135,20 @@ pub mod msg_ins_status { } } + impl TryFrom for OdometryStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(OdometryStatus::NoOdometry), + 1 => Ok(OdometryStatus::OdometryReceivedWithinLastSecond), + 2 => Ok(OdometryStatus::OdometryNotReceivedWithinLastSecond), + _ => Err(TryFromIntError), + } + } + } + /// INS Error - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InsError { /// IMU Data Error ImuDataError = 1, @@ -1111,8 +1170,20 @@ pub mod msg_ins_status { } } + impl TryFrom for InsError { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 1 => Ok(InsError::ImuDataError), + 2 => Ok(InsError::InsLicenseError), + 3 => Ok(InsError::ImuCalibrationDataError), + _ => Err(TryFromIntError), + } + } + } + /// GNSS Fix - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum GnssFix { /// No GNSS fix available NoGnssFixAvailable = 0, @@ -1130,8 +1201,19 @@ pub mod msg_ins_status { } } + impl TryFrom for GnssFix { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(GnssFix::NoGnssFixAvailable), + 1 => Ok(GnssFix::GnssFix), + _ => Err(TryFromIntError), + } + } + } + /// Mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Mode { /// Awaiting initialization AwaitingInitialization = 0, @@ -1172,6 +1254,22 @@ pub mod msg_ins_status { } } } + + impl TryFrom for Mode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(Mode::AwaitingInitialization), + 1 => Ok(Mode::DynamicallyAligning), + 2 => Ok(Mode::Ready), + 3 => Ok(Mode::GnssOutageExceedsMaxDuration), + 4 => Ok(Mode::FastStartSeeding), + 5 => Ok(Mode::FastStartValidating), + 6 => Ok(Mode::ValidatingUnsafeFastStartSeed), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_ins_updates { @@ -1561,13 +1659,7 @@ pub mod msg_pps_time { } pub fn time_uncertainty(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 1, 0) { - 0 => Some(TimeUncertainty::Unknown), - 1 => Some(TimeUncertainty::_10Milliseconds), - 2 => Some(TimeUncertainty::_10Microseconds), - 3 => Some(TimeUncertainty::_1Microseconds), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() } pub fn set_time_uncertainty(&mut self, time_uncertainty: TimeUncertainty) { @@ -1740,6 +1832,19 @@ impl WireFormat for MsgSensorAidEvent { flags: WireFormat::parse_unchecked(buf), } } + + impl TryFrom for TimeUncertainty { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TimeUncertainty::Unknown), + 1 => Ok(TimeUncertainty::_10Milliseconds), + 2 => Ok(TimeUncertainty::_10Microseconds), + 3 => Ok(TimeUncertainty::_1Microseconds), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_startup { @@ -1773,12 +1878,7 @@ pub mod msg_startup { impl MsgStartup { pub fn cause_of_startup(&self) -> Option { - match get_bit_range!(self.cause, u8, u8, 8, 0) { - 0 => Some(CauseOfStartup::PowerOn), - 1 => Some(CauseOfStartup::SoftwareReset), - 2 => Some(CauseOfStartup::WatchdogReset), - _ => None, - } + get_bit_range!(self.cause, u8, u8, 8, 0).try_into().ok() } pub fn set_cause_of_startup(&mut self, cause_of_startup: CauseOfStartup) { @@ -1786,12 +1886,9 @@ pub mod msg_startup { } pub fn startup_type(&self) -> Option { - match get_bit_range!(self.startup_type, u8, u8, 8, 0) { - 0 => Some(StartupType::ColdStart), - 1 => Some(StartupType::WarmStart), - 2 => Some(StartupType::HotStart), - _ => None, - } + get_bit_range!(self.startup_type, u8, u8, 8, 0) + .try_into() + .ok() } pub fn set_startup_type(&mut self, startup_type: StartupType) { @@ -1857,7 +1954,7 @@ pub mod msg_startup { } /// Cause of startup - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum CauseOfStartup { /// Power on PowerOn = 0, @@ -1879,7 +1976,19 @@ pub mod msg_startup { } } - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + impl TryFrom for CauseOfStartup { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(CauseOfStartup::PowerOn), + 1 => Ok(CauseOfStartup::SoftwareReset), + 2 => Ok(CauseOfStartup::WatchdogReset), + _ => Err(TryFromIntError), + } + } + } + + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum StartupType { /// Cold start ColdStart = 0, @@ -1900,6 +2009,18 @@ pub mod msg_startup { } } } + + impl TryFrom for StartupType { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(StartupType::ColdStart), + 1 => Ok(StartupType::WarmStart), + 2 => Ok(StartupType::HotStart), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_status_report { @@ -1944,11 +2065,9 @@ pub mod msg_status_report { impl MsgStatusReport { pub fn system(&self) -> Option { - match get_bit_range!(self.reporting_system, u16, u16, 15, 0) { - 0 => Some(System::Starling), - 1 => Some(System::PrecisionGnssModule), - _ => None, - } + get_bit_range!(self.reporting_system, u16, u16, 15, 0) + .try_into() + .ok() } pub fn set_system(&mut self, system: System) { @@ -2058,7 +2177,7 @@ pub mod msg_status_report { } /// System - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum System { /// Starling Starling = 0, @@ -2075,6 +2194,17 @@ pub mod msg_status_report { } } } + + impl TryFrom for System { + type Error = TryFromIntError; + fn try_from(i: u16) -> Result { + match i { + 0 => Ok(System::Starling), + 1 => Ok(System::PrecisionGnssModule), + _ => Err(TryFromIntError), + } + } + } } pub mod sub_system_report { @@ -2104,16 +2234,9 @@ pub mod sub_system_report { impl SubSystemReport { pub fn subsystem(&self) -> Option { - match get_bit_range!(self.component, u16, u16, 15, 0) { - 0 => Some(Subsystem::PrimaryGnssAntenna), - 1 => Some(Subsystem::MeasurementEngine), - 2 => Some(Subsystem::CorrectionsClient), - 3 => Some(Subsystem::DifferentialGnssEngine), - 4 => Some(Subsystem::CAN), - 5 => Some(Subsystem::WheelOdometry), - 6 => Some(Subsystem::SensorFusionEngine), - _ => None, - } + get_bit_range!(self.component, u16, u16, 15, 0) + .try_into() + .ok() } pub fn set_subsystem(&mut self, subsystem: Subsystem) { @@ -2121,14 +2244,7 @@ pub mod sub_system_report { } pub fn generic(&self) -> Option { - match get_bit_range!(self.generic, u8, u8, 7, 0) { - 0 => Some(Generic::OKNominal), - 1 => Some(Generic::Initializing), - 2 => Some(Generic::Unknown), - 3 => Some(Generic::Degraded), - 4 => Some(Generic::Unusable), - _ => None, - } + get_bit_range!(self.generic, u8, u8, 7, 0).try_into().ok() } pub fn set_generic(&mut self, generic: Generic) { @@ -2160,7 +2276,7 @@ pub mod sub_system_report { } /// Subsystem - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Subsystem { /// Primary GNSS Antenna PrimaryGnssAntenna = 0, @@ -2198,8 +2314,24 @@ pub mod sub_system_report { } } + impl TryFrom for Subsystem { + type Error = TryFromIntError; + fn try_from(i: u16) -> Result { + match i { + 0 => Ok(Subsystem::PrimaryGnssAntenna), + 1 => Ok(Subsystem::MeasurementEngine), + 2 => Ok(Subsystem::CorrectionsClient), + 3 => Ok(Subsystem::DifferentialGnssEngine), + 4 => Ok(Subsystem::CAN), + 5 => Ok(Subsystem::WheelOdometry), + 6 => Ok(Subsystem::SensorFusionEngine), + _ => Err(TryFromIntError), + } + } + } + /// Generic - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Generic { /// OK/Nominal OKNominal = 0, @@ -2228,4 +2360,18 @@ pub mod sub_system_report { } } } + + impl TryFrom for Generic { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(Generic::OKNominal), + 1 => Ok(Generic::Initializing), + 2 => Ok(Generic::Unknown), + 3 => Ok(Generic::Degraded), + 4 => Ok(Generic::Unusable), + _ => Err(TryFromIntError), + } + } + } } diff --git a/rust/sbp/src/messages/tracking.rs b/rust/sbp/src/messages/tracking.rs index f6229b84e1..f6bb10f8f0 100644 --- a/rust/sbp/src/messages/tracking.rs +++ b/rust/sbp/src/messages/tracking.rs @@ -671,13 +671,9 @@ pub mod msg_tracking_state_detailed_dep { impl MsgTrackingStateDetailedDep { pub fn synchronization_status(&self) -> Option { - match get_bit_range!(self.sync_flags, u8, u8, 2, 0) { - 0 => Some(SynchronizationStatus::NoSynchronization), - 1 => Some(SynchronizationStatus::BitSynchronization), - 2 => Some(SynchronizationStatus::WordSynchronization), - 3 => Some(SynchronizationStatus::SubFrameSynchronizationMessageSynchronization), - _ => None, - } + get_bit_range!(self.sync_flags, u8, u8, 2, 0) + .try_into() + .ok() } pub fn set_synchronization_status( @@ -688,11 +684,7 @@ pub mod msg_tracking_state_detailed_dep { } pub fn week_number_validity_status(&self) -> Option { - match get_bit_range!(self.tow_flags, u8, u8, 3, 0) { - 0 => Some(WeekNumberValidityStatus::WeekNumberIsNotValid), - 1 => Some(WeekNumberValidityStatus::WeekNumberIsValid), - _ => None, - } + get_bit_range!(self.tow_flags, u8, u8, 3, 0).try_into().ok() } pub fn set_week_number_validity_status( @@ -710,12 +702,7 @@ pub mod msg_tracking_state_detailed_dep { } pub fn tow_status(&self) -> Option { - match get_bit_range!(self.tow_flags, u8, u8, 2, 0) { - 0 => Some(TowStatus::TowIsNotAvailable), - 1 => Some(TowStatus::DecodedTowIsAvailable), - 2 => Some(TowStatus::PropagatedTowIsAvailable), - _ => None, - } + get_bit_range!(self.tow_flags, u8, u8, 2, 0).try_into().ok() } pub fn set_tow_status(&mut self, tow_status: TowStatus) { @@ -723,11 +710,9 @@ pub mod msg_tracking_state_detailed_dep { } pub fn fll_status(&self) -> Option { - match get_bit_range!(self.track_flags, u8, u8, 4, 0) { - 0 => Some(FllStatus::FllIsInactive), - 1 => Some(FllStatus::FllIsActive), - _ => None, - } + get_bit_range!(self.track_flags, u8, u8, 4, 0) + .try_into() + .ok() } pub fn set_fll_status(&mut self, fll_status: FllStatus) { @@ -735,11 +720,9 @@ pub mod msg_tracking_state_detailed_dep { } pub fn pll_status(&self) -> Option { - match get_bit_range!(self.track_flags, u8, u8, 3, 0) { - 0 => Some(PllStatus::PllIsInactive), - 1 => Some(PllStatus::PllIsActive), - _ => None, - } + get_bit_range!(self.track_flags, u8, u8, 3, 0) + .try_into() + .ok() } pub fn set_pll_status(&mut self, pll_status: PllStatus) { @@ -747,13 +730,9 @@ pub mod msg_tracking_state_detailed_dep { } pub fn tracking_loop_status(&self) -> Option { - match get_bit_range!(self.track_flags, u8, u8, 2, 0) { - 0 => Some(TrackingLoopStatus::NoLocks), - 1 => Some(TrackingLoopStatus::FlldllLock), - 2 => Some(TrackingLoopStatus::PllOptimisticLock), - 3 => Some(TrackingLoopStatus::PllPessimisticLock), - _ => None, - } + get_bit_range!(self.track_flags, u8, u8, 2, 0) + .try_into() + .ok() } pub fn set_tracking_loop_status(&mut self, tracking_loop_status: TrackingLoopStatus) { @@ -761,11 +740,7 @@ pub mod msg_tracking_state_detailed_dep { } pub fn almanac_availability_status(&self) -> Option { - match get_bit_range!(self.nav_flags, u8, u8, 4, 0) { - 0 => Some(AlmanacAvailabilityStatus::AlmanacIsNotAvailable), - 1 => Some(AlmanacAvailabilityStatus::AlmanacIsAvailable), - _ => None, - } + get_bit_range!(self.nav_flags, u8, u8, 4, 0).try_into().ok() } pub fn set_almanac_availability_status( @@ -783,11 +758,7 @@ pub mod msg_tracking_state_detailed_dep { } pub fn ephemeris_availability_status(&self) -> Option { - match get_bit_range!(self.nav_flags, u8, u8, 3, 0) { - 0 => Some(EphemerisAvailabilityStatus::EphemerisIsNotAvailable), - 1 => Some(EphemerisAvailabilityStatus::EphemerisIsAvailable), - _ => None, - } + get_bit_range!(self.nav_flags, u8, u8, 3, 0).try_into().ok() } pub fn set_ephemeris_availability_status( @@ -805,12 +776,7 @@ pub mod msg_tracking_state_detailed_dep { } pub fn health_status(&self) -> Option { - match get_bit_range!(self.nav_flags, u8, u8, 2, 0) { - 0 => Some(HealthStatus::HealthIsUnknown), - 1 => Some(HealthStatus::SignalIsUnhealthy), - 2 => Some(HealthStatus::SignalIsHealthy), - _ => None, - } + get_bit_range!(self.nav_flags, u8, u8, 2, 0).try_into().ok() } pub fn set_health_status(&mut self, health_status: HealthStatus) { @@ -818,13 +784,9 @@ pub mod msg_tracking_state_detailed_dep { } pub fn parameter_sets(&self) -> Option { - match get_bit_range!(self.pset_flags, u8, u8, 2, 0) { - 0 => Some(ParameterSets::_1MsIntegrationTime), - 1 => Some(ParameterSets::_5MsIntegrationTime), - 2 => Some(ParameterSets::_10MsIntegrationTime), - 3 => Some(ParameterSets::_20MsIntegrationTime), - _ => None, - } + get_bit_range!(self.pset_flags, u8, u8, 2, 0) + .try_into() + .ok() } pub fn set_parameter_sets(&mut self, parameter_sets: ParameterSets) { @@ -832,11 +794,9 @@ pub mod msg_tracking_state_detailed_dep { } pub fn clock_validity_status(&self) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 5, 0) { - 0 => Some(ClockValidityStatus::ClockOffsetAndDriftIsNotValid), - 1 => Some(ClockValidityStatus::ClockOffsetAndDriftIsValid), - _ => None, - } + get_bit_range!(self.misc_flags, u8, u8, 5, 0) + .try_into() + .ok() } pub fn set_clock_validity_status(&mut self, clock_validity_status: ClockValidityStatus) { @@ -844,11 +804,9 @@ pub mod msg_tracking_state_detailed_dep { } pub fn pseudorange_validity_status(&self) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 4, 0) { - 0 => Some(PseudorangeValidityStatus::PseudorangeIsNotValid), - 1 => Some(PseudorangeValidityStatus::PseudorangeIsValid), - _ => None, - } + get_bit_range!(self.misc_flags, u8, u8, 4, 0) + .try_into() + .ok() } pub fn set_pseudorange_validity_status( @@ -866,11 +824,9 @@ pub mod msg_tracking_state_detailed_dep { } pub fn acceleration_validity_status(&self) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 3, 0) { - 0 => Some(AccelerationValidityStatus::AccelerationIsNotValid), - 1 => Some(AccelerationValidityStatus::AccelerationIsValid), - _ => None, - } + get_bit_range!(self.misc_flags, u8, u8, 3, 0) + .try_into() + .ok() } pub fn set_acceleration_validity_status( @@ -890,11 +846,9 @@ pub mod msg_tracking_state_detailed_dep { pub fn carrier_half_cycle_ambiguity_status( &self, ) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 2, 0) { - 0 => Some(CarrierHalfCycleAmbiguityStatus::Unresolved), - 1 => Some(CarrierHalfCycleAmbiguityStatus::Resolved), - _ => None, - } + get_bit_range!(self.misc_flags, u8, u8, 2, 0) + .try_into() + .ok() } pub fn set_carrier_half_cycle_ambiguity_status( @@ -912,11 +866,9 @@ pub mod msg_tracking_state_detailed_dep { } pub fn tracking_channel_status(&self) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 1, 0) { - 0 => Some(TrackingChannelStatus::ReAcquisition), - 1 => Some(TrackingChannelStatus::Running), - _ => None, - } + get_bit_range!(self.misc_flags, u8, u8, 1, 0) + .try_into() + .ok() } pub fn set_tracking_channel_status( @@ -1057,7 +1009,7 @@ pub mod msg_tracking_state_detailed_dep { } /// Synchronization status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum SynchronizationStatus { /// No synchronization NoSynchronization = 0, @@ -1089,8 +1041,21 @@ pub mod msg_tracking_state_detailed_dep { } } + impl TryFrom for SynchronizationStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(SynchronizationStatus::NoSynchronization), + 1 => Ok(SynchronizationStatus::BitSynchronization), + 2 => Ok(SynchronizationStatus::WordSynchronization), + 3 => Ok(SynchronizationStatus::SubFrameSynchronizationMessageSynchronization), + _ => Err(TryFromIntError), + } + } + } + /// Week number validity status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum WeekNumberValidityStatus { /// Week number is not valid WeekNumberIsNotValid = 0, @@ -1110,8 +1075,19 @@ pub mod msg_tracking_state_detailed_dep { } } + impl TryFrom for WeekNumberValidityStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(WeekNumberValidityStatus::WeekNumberIsNotValid), + 1 => Ok(WeekNumberValidityStatus::WeekNumberIsValid), + _ => Err(TryFromIntError), + } + } + } + /// TOW status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TowStatus { /// TOW is not available TowIsNotAvailable = 0, @@ -1133,8 +1109,20 @@ pub mod msg_tracking_state_detailed_dep { } } + impl TryFrom for TowStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TowStatus::TowIsNotAvailable), + 1 => Ok(TowStatus::DecodedTowIsAvailable), + 2 => Ok(TowStatus::PropagatedTowIsAvailable), + _ => Err(TryFromIntError), + } + } + } + /// FLL status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FllStatus { /// FLL is inactive FllIsInactive = 0, @@ -1152,8 +1140,19 @@ pub mod msg_tracking_state_detailed_dep { } } + impl TryFrom for FllStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FllStatus::FllIsInactive), + 1 => Ok(FllStatus::FllIsActive), + _ => Err(TryFromIntError), + } + } + } + /// PLL status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum PllStatus { /// PLL is inactive PllIsInactive = 0, @@ -1171,8 +1170,19 @@ pub mod msg_tracking_state_detailed_dep { } } + impl TryFrom for PllStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(PllStatus::PllIsInactive), + 1 => Ok(PllStatus::PllIsActive), + _ => Err(TryFromIntError), + } + } + } + /// Tracking loop status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TrackingLoopStatus { /// No locks NoLocks = 0, @@ -1198,8 +1208,21 @@ pub mod msg_tracking_state_detailed_dep { } } + impl TryFrom for TrackingLoopStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TrackingLoopStatus::NoLocks), + 1 => Ok(TrackingLoopStatus::FlldllLock), + 2 => Ok(TrackingLoopStatus::PllOptimisticLock), + 3 => Ok(TrackingLoopStatus::PllPessimisticLock), + _ => Err(TryFromIntError), + } + } + } + /// Almanac availability status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum AlmanacAvailabilityStatus { /// Almanac is not available AlmanacIsNotAvailable = 0, @@ -1221,8 +1244,19 @@ pub mod msg_tracking_state_detailed_dep { } } + impl TryFrom for AlmanacAvailabilityStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(AlmanacAvailabilityStatus::AlmanacIsNotAvailable), + 1 => Ok(AlmanacAvailabilityStatus::AlmanacIsAvailable), + _ => Err(TryFromIntError), + } + } + } + /// Ephemeris availability status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum EphemerisAvailabilityStatus { /// Ephemeris is not available EphemerisIsNotAvailable = 0, @@ -1244,8 +1278,19 @@ pub mod msg_tracking_state_detailed_dep { } } + impl TryFrom for EphemerisAvailabilityStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(EphemerisAvailabilityStatus::EphemerisIsNotAvailable), + 1 => Ok(EphemerisAvailabilityStatus::EphemerisIsAvailable), + _ => Err(TryFromIntError), + } + } + } + /// Health status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum HealthStatus { /// Health is unknown HealthIsUnknown = 0, @@ -1267,8 +1312,20 @@ pub mod msg_tracking_state_detailed_dep { } } + impl TryFrom for HealthStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(HealthStatus::HealthIsUnknown), + 1 => Ok(HealthStatus::SignalIsUnhealthy), + 2 => Ok(HealthStatus::SignalIsHealthy), + _ => Err(TryFromIntError), + } + } + } + /// Parameter sets. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ParameterSets { /// 1 ms integration time _1MsIntegrationTime = 0, @@ -1294,8 +1351,21 @@ pub mod msg_tracking_state_detailed_dep { } } + impl TryFrom for ParameterSets { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(ParameterSets::_1MsIntegrationTime), + 1 => Ok(ParameterSets::_5MsIntegrationTime), + 2 => Ok(ParameterSets::_10MsIntegrationTime), + 3 => Ok(ParameterSets::_20MsIntegrationTime), + _ => Err(TryFromIntError), + } + } + } + /// Clock validity status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ClockValidityStatus { /// Clock offset and drift is not valid ClockOffsetAndDriftIsNotValid = 0, @@ -1317,8 +1387,19 @@ pub mod msg_tracking_state_detailed_dep { } } + impl TryFrom for ClockValidityStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(ClockValidityStatus::ClockOffsetAndDriftIsNotValid), + 1 => Ok(ClockValidityStatus::ClockOffsetAndDriftIsValid), + _ => Err(TryFromIntError), + } + } + } + /// Pseudorange validity status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum PseudorangeValidityStatus { /// Pseudorange is not valid PseudorangeIsNotValid = 0, @@ -1340,8 +1421,19 @@ pub mod msg_tracking_state_detailed_dep { } } + impl TryFrom for PseudorangeValidityStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(PseudorangeValidityStatus::PseudorangeIsNotValid), + 1 => Ok(PseudorangeValidityStatus::PseudorangeIsValid), + _ => Err(TryFromIntError), + } + } + } + /// Acceleration validity status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum AccelerationValidityStatus { /// Acceleration is not valid AccelerationIsNotValid = 0, @@ -1363,8 +1455,19 @@ pub mod msg_tracking_state_detailed_dep { } } + impl TryFrom for AccelerationValidityStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(AccelerationValidityStatus::AccelerationIsNotValid), + 1 => Ok(AccelerationValidityStatus::AccelerationIsValid), + _ => Err(TryFromIntError), + } + } + } + /// Carrier half cycle ambiguity status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum CarrierHalfCycleAmbiguityStatus { /// Unresolved Unresolved = 0, @@ -1382,8 +1485,19 @@ pub mod msg_tracking_state_detailed_dep { } } + impl TryFrom for CarrierHalfCycleAmbiguityStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(CarrierHalfCycleAmbiguityStatus::Unresolved), + 1 => Ok(CarrierHalfCycleAmbiguityStatus::Resolved), + _ => Err(TryFromIntError), + } + } + } + /// Tracking channel status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TrackingChannelStatus { /// Re-acquisition ReAcquisition = 0, @@ -1400,6 +1514,17 @@ pub mod msg_tracking_state_detailed_dep { } } } + + impl TryFrom for TrackingChannelStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TrackingChannelStatus::ReAcquisition), + 1 => Ok(TrackingChannelStatus::Running), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_tracking_state_detailed_dep_a { @@ -1493,13 +1618,9 @@ pub mod msg_tracking_state_detailed_dep_a { impl MsgTrackingStateDetailedDepA { pub fn synchronization_status(&self) -> Option { - match get_bit_range!(self.sync_flags, u8, u8, 2, 0) { - 0 => Some(SynchronizationStatus::NoSynchronization), - 1 => Some(SynchronizationStatus::BitSynchronization), - 2 => Some(SynchronizationStatus::WordSynchronization), - 3 => Some(SynchronizationStatus::SubFrameSynchronizationMessageSynchronization), - _ => None, - } + get_bit_range!(self.sync_flags, u8, u8, 2, 0) + .try_into() + .ok() } pub fn set_synchronization_status( @@ -1510,11 +1631,7 @@ pub mod msg_tracking_state_detailed_dep_a { } pub fn week_number_validity_status(&self) -> Option { - match get_bit_range!(self.tow_flags, u8, u8, 3, 0) { - 0 => Some(WeekNumberValidityStatus::WeekNumberIsNotValid), - 1 => Some(WeekNumberValidityStatus::WeekNumberIsValid), - _ => None, - } + get_bit_range!(self.tow_flags, u8, u8, 3, 0).try_into().ok() } pub fn set_week_number_validity_status( @@ -1532,12 +1649,7 @@ pub mod msg_tracking_state_detailed_dep_a { } pub fn tow_status(&self) -> Option { - match get_bit_range!(self.tow_flags, u8, u8, 2, 0) { - 0 => Some(TowStatus::TowIsNotAvailable), - 1 => Some(TowStatus::DecodedTowIsAvailable), - 2 => Some(TowStatus::PropagatedTowIsAvailable), - _ => None, - } + get_bit_range!(self.tow_flags, u8, u8, 2, 0).try_into().ok() } pub fn set_tow_status(&mut self, tow_status: TowStatus) { @@ -1545,11 +1657,9 @@ pub mod msg_tracking_state_detailed_dep_a { } pub fn fll_status(&self) -> Option { - match get_bit_range!(self.track_flags, u8, u8, 4, 0) { - 0 => Some(FllStatus::FllIsInactive), - 1 => Some(FllStatus::FllIsActive), - _ => None, - } + get_bit_range!(self.track_flags, u8, u8, 4, 0) + .try_into() + .ok() } pub fn set_fll_status(&mut self, fll_status: FllStatus) { @@ -1557,11 +1667,9 @@ pub mod msg_tracking_state_detailed_dep_a { } pub fn pll_status(&self) -> Option { - match get_bit_range!(self.track_flags, u8, u8, 3, 0) { - 0 => Some(PllStatus::PllIsInactive), - 1 => Some(PllStatus::PllIsActive), - _ => None, - } + get_bit_range!(self.track_flags, u8, u8, 3, 0) + .try_into() + .ok() } pub fn set_pll_status(&mut self, pll_status: PllStatus) { @@ -1569,13 +1677,9 @@ pub mod msg_tracking_state_detailed_dep_a { } pub fn tracking_loop_status(&self) -> Option { - match get_bit_range!(self.track_flags, u8, u8, 2, 0) { - 0 => Some(TrackingLoopStatus::NoLocks), - 1 => Some(TrackingLoopStatus::FlldllLock), - 2 => Some(TrackingLoopStatus::PllOptimisticLock), - 3 => Some(TrackingLoopStatus::PllPessimisticLock), - _ => None, - } + get_bit_range!(self.track_flags, u8, u8, 2, 0) + .try_into() + .ok() } pub fn set_tracking_loop_status(&mut self, tracking_loop_status: TrackingLoopStatus) { @@ -1583,11 +1687,7 @@ pub mod msg_tracking_state_detailed_dep_a { } pub fn almanac_availability_status(&self) -> Option { - match get_bit_range!(self.nav_flags, u8, u8, 4, 0) { - 0 => Some(AlmanacAvailabilityStatus::AlmanacIsNotAvailable), - 1 => Some(AlmanacAvailabilityStatus::AlmanacIsAvailable), - _ => None, - } + get_bit_range!(self.nav_flags, u8, u8, 4, 0).try_into().ok() } pub fn set_almanac_availability_status( @@ -1605,11 +1705,7 @@ pub mod msg_tracking_state_detailed_dep_a { } pub fn ephemeris_availability_status(&self) -> Option { - match get_bit_range!(self.nav_flags, u8, u8, 3, 0) { - 0 => Some(EphemerisAvailabilityStatus::EphemerisIsNotAvailable), - 1 => Some(EphemerisAvailabilityStatus::EphemerisIsAvailable), - _ => None, - } + get_bit_range!(self.nav_flags, u8, u8, 3, 0).try_into().ok() } pub fn set_ephemeris_availability_status( @@ -1627,12 +1723,7 @@ pub mod msg_tracking_state_detailed_dep_a { } pub fn health_status(&self) -> Option { - match get_bit_range!(self.nav_flags, u8, u8, 2, 0) { - 0 => Some(HealthStatus::HealthIsUnknown), - 1 => Some(HealthStatus::SignalIsUnhealthy), - 2 => Some(HealthStatus::SignalIsHealthy), - _ => None, - } + get_bit_range!(self.nav_flags, u8, u8, 2, 0).try_into().ok() } pub fn set_health_status(&mut self, health_status: HealthStatus) { @@ -1640,13 +1731,9 @@ pub mod msg_tracking_state_detailed_dep_a { } pub fn parameter_sets(&self) -> Option { - match get_bit_range!(self.pset_flags, u8, u8, 2, 0) { - 0 => Some(ParameterSets::_1MsIntegrationTime), - 1 => Some(ParameterSets::_5MsIntegrationTime), - 2 => Some(ParameterSets::_10MsIntegrationTime), - 3 => Some(ParameterSets::_20MsIntegrationTime), - _ => None, - } + get_bit_range!(self.pset_flags, u8, u8, 2, 0) + .try_into() + .ok() } pub fn set_parameter_sets(&mut self, parameter_sets: ParameterSets) { @@ -1654,11 +1741,9 @@ pub mod msg_tracking_state_detailed_dep_a { } pub fn clock_validity_status(&self) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 5, 0) { - 0 => Some(ClockValidityStatus::ClockOffsetAndDriftIsNotValid), - 1 => Some(ClockValidityStatus::ClockOffsetAndDriftIsValid), - _ => None, - } + get_bit_range!(self.misc_flags, u8, u8, 5, 0) + .try_into() + .ok() } pub fn set_clock_validity_status(&mut self, clock_validity_status: ClockValidityStatus) { @@ -1666,11 +1751,9 @@ pub mod msg_tracking_state_detailed_dep_a { } pub fn pseudorange_validity_status(&self) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 4, 0) { - 0 => Some(PseudorangeValidityStatus::PseudorangeIsNotValid), - 1 => Some(PseudorangeValidityStatus::PseudorangeIsValid), - _ => None, - } + get_bit_range!(self.misc_flags, u8, u8, 4, 0) + .try_into() + .ok() } pub fn set_pseudorange_validity_status( @@ -1688,11 +1771,9 @@ pub mod msg_tracking_state_detailed_dep_a { } pub fn acceleration_validity_status(&self) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 3, 0) { - 0 => Some(AccelerationValidityStatus::AccelerationIsNotValid), - 1 => Some(AccelerationValidityStatus::AccelerationIsValid), - _ => None, - } + get_bit_range!(self.misc_flags, u8, u8, 3, 0) + .try_into() + .ok() } pub fn set_acceleration_validity_status( @@ -1712,11 +1793,9 @@ pub mod msg_tracking_state_detailed_dep_a { pub fn carrier_half_cycle_ambiguity_status( &self, ) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 2, 0) { - 0 => Some(CarrierHalfCycleAmbiguityStatus::Unresolved), - 1 => Some(CarrierHalfCycleAmbiguityStatus::Resolved), - _ => None, - } + get_bit_range!(self.misc_flags, u8, u8, 2, 0) + .try_into() + .ok() } pub fn set_carrier_half_cycle_ambiguity_status( @@ -1734,11 +1813,9 @@ pub mod msg_tracking_state_detailed_dep_a { } pub fn tracking_channel_status(&self) -> Option { - match get_bit_range!(self.misc_flags, u8, u8, 1, 0) { - 0 => Some(TrackingChannelStatus::ReAcquisition), - 1 => Some(TrackingChannelStatus::Running), - _ => None, - } + get_bit_range!(self.misc_flags, u8, u8, 1, 0) + .try_into() + .ok() } pub fn set_tracking_channel_status( @@ -1879,7 +1956,7 @@ pub mod msg_tracking_state_detailed_dep_a { } /// Synchronization status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum SynchronizationStatus { /// No synchronization NoSynchronization = 0, @@ -1911,8 +1988,21 @@ pub mod msg_tracking_state_detailed_dep_a { } } + impl TryFrom for SynchronizationStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(SynchronizationStatus::NoSynchronization), + 1 => Ok(SynchronizationStatus::BitSynchronization), + 2 => Ok(SynchronizationStatus::WordSynchronization), + 3 => Ok(SynchronizationStatus::SubFrameSynchronizationMessageSynchronization), + _ => Err(TryFromIntError), + } + } + } + /// Week number validity status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum WeekNumberValidityStatus { /// Week number is not valid WeekNumberIsNotValid = 0, @@ -1932,8 +2022,19 @@ pub mod msg_tracking_state_detailed_dep_a { } } + impl TryFrom for WeekNumberValidityStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(WeekNumberValidityStatus::WeekNumberIsNotValid), + 1 => Ok(WeekNumberValidityStatus::WeekNumberIsValid), + _ => Err(TryFromIntError), + } + } + } + /// TOW status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TowStatus { /// TOW is not available TowIsNotAvailable = 0, @@ -1955,8 +2056,20 @@ pub mod msg_tracking_state_detailed_dep_a { } } + impl TryFrom for TowStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TowStatus::TowIsNotAvailable), + 1 => Ok(TowStatus::DecodedTowIsAvailable), + 2 => Ok(TowStatus::PropagatedTowIsAvailable), + _ => Err(TryFromIntError), + } + } + } + /// FLL status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum FllStatus { /// FLL is inactive FllIsInactive = 0, @@ -1974,8 +2087,19 @@ pub mod msg_tracking_state_detailed_dep_a { } } + impl TryFrom for FllStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(FllStatus::FllIsInactive), + 1 => Ok(FllStatus::FllIsActive), + _ => Err(TryFromIntError), + } + } + } + /// PLL status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum PllStatus { /// PLL is inactive PllIsInactive = 0, @@ -1993,8 +2117,19 @@ pub mod msg_tracking_state_detailed_dep_a { } } + impl TryFrom for PllStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(PllStatus::PllIsInactive), + 1 => Ok(PllStatus::PllIsActive), + _ => Err(TryFromIntError), + } + } + } + /// Tracking loop status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TrackingLoopStatus { /// No locks NoLocks = 0, @@ -2020,8 +2155,21 @@ pub mod msg_tracking_state_detailed_dep_a { } } + impl TryFrom for TrackingLoopStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TrackingLoopStatus::NoLocks), + 1 => Ok(TrackingLoopStatus::FlldllLock), + 2 => Ok(TrackingLoopStatus::PllOptimisticLock), + 3 => Ok(TrackingLoopStatus::PllPessimisticLock), + _ => Err(TryFromIntError), + } + } + } + /// Almanac availability status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum AlmanacAvailabilityStatus { /// Almanac is not available AlmanacIsNotAvailable = 0, @@ -2043,8 +2191,19 @@ pub mod msg_tracking_state_detailed_dep_a { } } + impl TryFrom for AlmanacAvailabilityStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(AlmanacAvailabilityStatus::AlmanacIsNotAvailable), + 1 => Ok(AlmanacAvailabilityStatus::AlmanacIsAvailable), + _ => Err(TryFromIntError), + } + } + } + /// Ephemeris availability status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum EphemerisAvailabilityStatus { /// Ephemeris is not available EphemerisIsNotAvailable = 0, @@ -2066,8 +2225,19 @@ pub mod msg_tracking_state_detailed_dep_a { } } + impl TryFrom for EphemerisAvailabilityStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(EphemerisAvailabilityStatus::EphemerisIsNotAvailable), + 1 => Ok(EphemerisAvailabilityStatus::EphemerisIsAvailable), + _ => Err(TryFromIntError), + } + } + } + /// Health status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum HealthStatus { /// Health is unknown HealthIsUnknown = 0, @@ -2089,8 +2259,20 @@ pub mod msg_tracking_state_detailed_dep_a { } } + impl TryFrom for HealthStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(HealthStatus::HealthIsUnknown), + 1 => Ok(HealthStatus::SignalIsUnhealthy), + 2 => Ok(HealthStatus::SignalIsHealthy), + _ => Err(TryFromIntError), + } + } + } + /// Parameter sets. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ParameterSets { /// 1 ms integration time _1MsIntegrationTime = 0, @@ -2116,8 +2298,21 @@ pub mod msg_tracking_state_detailed_dep_a { } } + impl TryFrom for ParameterSets { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(ParameterSets::_1MsIntegrationTime), + 1 => Ok(ParameterSets::_5MsIntegrationTime), + 2 => Ok(ParameterSets::_10MsIntegrationTime), + 3 => Ok(ParameterSets::_20MsIntegrationTime), + _ => Err(TryFromIntError), + } + } + } + /// Clock validity status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ClockValidityStatus { /// Clock offset and drift is not valid ClockOffsetAndDriftIsNotValid = 0, @@ -2139,8 +2334,19 @@ pub mod msg_tracking_state_detailed_dep_a { } } + impl TryFrom for ClockValidityStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(ClockValidityStatus::ClockOffsetAndDriftIsNotValid), + 1 => Ok(ClockValidityStatus::ClockOffsetAndDriftIsValid), + _ => Err(TryFromIntError), + } + } + } + /// Pseudorange validity status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum PseudorangeValidityStatus { /// Pseudorange is not valid PseudorangeIsNotValid = 0, @@ -2162,8 +2368,19 @@ pub mod msg_tracking_state_detailed_dep_a { } } + impl TryFrom for PseudorangeValidityStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(PseudorangeValidityStatus::PseudorangeIsNotValid), + 1 => Ok(PseudorangeValidityStatus::PseudorangeIsValid), + _ => Err(TryFromIntError), + } + } + } + /// Acceleration validity status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum AccelerationValidityStatus { /// Acceleration is not valid AccelerationIsNotValid = 0, @@ -2185,8 +2402,19 @@ pub mod msg_tracking_state_detailed_dep_a { } } + impl TryFrom for AccelerationValidityStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(AccelerationValidityStatus::AccelerationIsNotValid), + 1 => Ok(AccelerationValidityStatus::AccelerationIsValid), + _ => Err(TryFromIntError), + } + } + } + /// Carrier half cycle ambiguity status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum CarrierHalfCycleAmbiguityStatus { /// Unresolved Unresolved = 0, @@ -2204,8 +2432,19 @@ pub mod msg_tracking_state_detailed_dep_a { } } + impl TryFrom for CarrierHalfCycleAmbiguityStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(CarrierHalfCycleAmbiguityStatus::Unresolved), + 1 => Ok(CarrierHalfCycleAmbiguityStatus::Resolved), + _ => Err(TryFromIntError), + } + } + } + /// Tracking channel status. - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TrackingChannelStatus { /// Re-acquisition ReAcquisition = 0, @@ -2222,6 +2461,17 @@ pub mod msg_tracking_state_detailed_dep_a { } } } + + impl TryFrom for TrackingChannelStatus { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TrackingChannelStatus::ReAcquisition), + 1 => Ok(TrackingChannelStatus::Running), + _ => Err(TryFromIntError), + } + } + } } pub mod measurement_state { @@ -2423,11 +2673,7 @@ pub mod tracking_channel_state_dep_a { impl TrackingChannelStateDepA { pub fn tracking_mode(&self) -> Option { - match get_bit_range!(self.state, u8, u8, 1, 0) { - 0 => Some(TrackingMode::Disabled), - 1 => Some(TrackingMode::Running), - _ => None, - } + get_bit_range!(self.state, u8, u8, 1, 0).try_into().ok() } pub fn set_tracking_mode(&mut self, tracking_mode: TrackingMode) { @@ -2457,7 +2703,7 @@ pub mod tracking_channel_state_dep_a { } /// Tracking mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TrackingMode { /// Disabled Disabled = 0, @@ -2474,6 +2720,17 @@ pub mod tracking_channel_state_dep_a { } } } + + impl TryFrom for TrackingMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TrackingMode::Disabled), + 1 => Ok(TrackingMode::Running), + _ => Err(TryFromIntError), + } + } + } } pub mod tracking_channel_state_dep_b { @@ -2503,11 +2760,7 @@ pub mod tracking_channel_state_dep_b { impl TrackingChannelStateDepB { pub fn tracking_mode(&self) -> Option { - match get_bit_range!(self.state, u8, u8, 1, 0) { - 0 => Some(TrackingMode::Disabled), - 1 => Some(TrackingMode::Running), - _ => None, - } + get_bit_range!(self.state, u8, u8, 1, 0).try_into().ok() } pub fn set_tracking_mode(&mut self, tracking_mode: TrackingMode) { @@ -2537,7 +2790,7 @@ pub mod tracking_channel_state_dep_b { } /// Tracking mode - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TrackingMode { /// Disabled Disabled = 0, @@ -2554,4 +2807,15 @@ pub mod tracking_channel_state_dep_b { } } } + + impl TryFrom for TrackingMode { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TrackingMode::Disabled), + 1 => Ok(TrackingMode::Running), + _ => Err(TryFromIntError), + } + } + } } diff --git a/rust/sbp/src/messages/vehicle.rs b/rust/sbp/src/messages/vehicle.rs index f9f0f803f3..3e9dedd638 100644 --- a/rust/sbp/src/messages/vehicle.rs +++ b/rust/sbp/src/messages/vehicle.rs @@ -55,13 +55,7 @@ pub mod msg_odometry { impl MsgOdometry { pub fn vehicle_metadata(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 6, 5) { - 0 => Some(VehicleMetadata::Unavailable), - 1 => Some(VehicleMetadata::Forward), - 2 => Some(VehicleMetadata::Reverse), - 3 => Some(VehicleMetadata::Park), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 6, 5).try_into().ok() } pub fn set_vehicle_metadata(&mut self, vehicle_metadata: VehicleMetadata) { @@ -69,13 +63,7 @@ pub mod msg_odometry { } pub fn velocity_source(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 4, 3) { - 0 => Some(VelocitySource::Source0), - 1 => Some(VelocitySource::Source1), - 2 => Some(VelocitySource::Source2), - 3 => Some(VelocitySource::Source3), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() } pub fn set_velocity_source(&mut self, velocity_source: VelocitySource) { @@ -83,12 +71,7 @@ pub mod msg_odometry { } pub fn time_source(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 2, 0) { - 0 => Some(TimeSource::None), - 1 => Some(TimeSource::GpsSolution), - 2 => Some(TimeSource::ProcessorTime), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() } pub fn set_time_source(&mut self, time_source: TimeSource) { @@ -163,7 +146,7 @@ pub mod msg_odometry { } /// Vehicle Metadata - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum VehicleMetadata { /// Unavailable Unavailable = 0, @@ -189,8 +172,21 @@ pub mod msg_odometry { } } + impl TryFrom for VehicleMetadata { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(VehicleMetadata::Unavailable), + 1 => Ok(VehicleMetadata::Forward), + 2 => Ok(VehicleMetadata::Reverse), + 3 => Ok(VehicleMetadata::Park), + _ => Err(TryFromIntError), + } + } + } + /// Velocity Source - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum VelocitySource { /// Source 0 Source0 = 0, @@ -216,8 +212,21 @@ pub mod msg_odometry { } } + impl TryFrom for VelocitySource { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(VelocitySource::Source0), + 1 => Ok(VelocitySource::Source1), + 2 => Ok(VelocitySource::Source2), + 3 => Ok(VelocitySource::Source3), + _ => Err(TryFromIntError), + } + } + } + /// Time source - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum TimeSource { /// None (invalid) None = 0, @@ -238,6 +247,18 @@ pub mod msg_odometry { } } } + + impl TryFrom for TimeSource { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TimeSource::None), + 1 => Ok(TimeSource::GpsSolution), + 2 => Ok(TimeSource::ProcessorTime), + _ => Err(TryFromIntError), + } + } + } } pub mod msg_wheeltick { @@ -287,13 +308,7 @@ pub mod msg_wheeltick { impl MsgWheeltick { pub fn vehicle_metadata(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 3, 2) { - 0 => Some(VehicleMetadata::Unavailable), - 1 => Some(VehicleMetadata::Forward), - 2 => Some(VehicleMetadata::Reverse), - 3 => Some(VehicleMetadata::Park), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 3, 2).try_into().ok() } pub fn set_vehicle_metadata(&mut self, vehicle_metadata: VehicleMetadata) { @@ -301,12 +316,7 @@ pub mod msg_wheeltick { } pub fn synchronization_type(&self) -> Option { - match get_bit_range!(self.flags, u8, u8, 1, 0) { - 0 => Some(SynchronizationType::MicrosecondsSinceLastPps), - 1 => Some(SynchronizationType::MicrosecondsInGpsWeek), - 2 => Some(SynchronizationType::LocalCpuTimeInNominalMicroseconds), - _ => None, - } + get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() } pub fn set_synchronization_type(&mut self, synchronization_type: SynchronizationType) { @@ -389,7 +399,7 @@ pub mod msg_wheeltick { } /// Vehicle Metadata - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum VehicleMetadata { /// Unavailable Unavailable = 0, @@ -415,8 +425,21 @@ pub mod msg_wheeltick { } } + impl TryFrom for VehicleMetadata { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(VehicleMetadata::Unavailable), + 1 => Ok(VehicleMetadata::Forward), + 2 => Ok(VehicleMetadata::Reverse), + 3 => Ok(VehicleMetadata::Park), + _ => Err(TryFromIntError), + } + } + } + /// Synchronization type - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum SynchronizationType { /// microseconds since last PPS MicrosecondsSinceLastPps = 0, @@ -443,4 +466,16 @@ pub mod msg_wheeltick { } } } + + impl TryFrom for SynchronizationType { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(SynchronizationType::MicrosecondsSinceLastPps), + 1 => Ok(SynchronizationType::MicrosecondsInGpsWeek), + 2 => Ok(SynchronizationType::LocalCpuTimeInNominalMicroseconds), + _ => Err(TryFromIntError), + } + } + } } From 0e9b68e933ff605788e1924708b3bc6c84ab1027 Mon Sep 17 00:00:00 2001 From: Steve Meyer Date: Sun, 9 Jan 2022 13:50:02 -0800 Subject: [PATCH 06/13] run make rust --- rust/sbp/src/messages/navigation.rs | 65 ++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/rust/sbp/src/messages/navigation.rs b/rust/sbp/src/messages/navigation.rs index 53f39d201a..93d731e210 100644 --- a/rust/sbp/src/messages/navigation.rs +++ b/rust/sbp/src/messages/navigation.rs @@ -6453,11 +6453,7 @@ pub mod msg_vel_cog { impl MsgVelCog { pub fn cog_frozen(&self) -> Option { - match get_bit_range!(self.flags, u16, u8, 9, 0) { - 0 => Some(CogFrozen::NotFrozen), - 1 => Some(CogFrozen::Frozen), - _ => None, - } + get_bit_range!(self.flags, u16, u8, 9, 0).try_into().ok() } pub fn set_cog_frozen(&mut self, cog_frozen: CogFrozen) { @@ -6465,7 +6461,7 @@ pub mod msg_vel_cog { } pub fn vertical_velocity_validity(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 5, 0).try_into().ok() + get_bit_range!(self.flags, u16, u8, 8, 0).try_into().ok() } pub fn set_vertical_velocity_validity( @@ -6476,7 +6472,7 @@ pub mod msg_vel_cog { } pub fn sog_validity(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 0).try_into().ok() + get_bit_range!(self.flags, u16, u8, 7, 0).try_into().ok() } pub fn set_sog_validity(&mut self, sog_validity: SogValidity) { @@ -6484,7 +6480,7 @@ pub mod msg_vel_cog { } pub fn cog_validity(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 3, 0).try_into().ok() + get_bit_range!(self.flags, u16, u8, 6, 0).try_into().ok() } pub fn set_cog_validity(&mut self, cog_validity: CogValidity) { @@ -6492,11 +6488,7 @@ pub mod msg_vel_cog { } pub fn type_of_reported_tow(&self) -> Option { - match get_bit_range!(self.flags, u16, u8, 5, 0) { - 0 => Some(TypeOfReportedTow::TimeOfMeasurement), - 1 => Some(TypeOfReportedTow::Other), - _ => None, - } + get_bit_range!(self.flags, u16, u8, 5, 0).try_into().ok() } pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { @@ -6504,7 +6496,7 @@ pub mod msg_vel_cog { } pub fn ins_navigation_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + get_bit_range!(self.flags, u16, u8, 4, 3).try_into().ok() } pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { @@ -6512,7 +6504,7 @@ pub mod msg_vel_cog { } pub fn velocity_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() + get_bit_range!(self.flags, u16, u8, 2, 0).try_into().ok() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -6607,7 +6599,7 @@ pub mod msg_vel_cog { } /// COG frozen - #[derive(Debug, Clone, Copy, PartialEq, Eq)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum CogFrozen { /// Not frozen NotFrozen = 0, @@ -6625,6 +6617,17 @@ pub mod msg_vel_cog { } } + impl TryFrom for CogFrozen { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(CogFrozen::NotFrozen), + 1 => Ok(CogFrozen::Frozen), + _ => Err(TryFromIntError), + } + } + } + /// Vertical velocity validity #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum VerticalVelocityValidity { @@ -6717,6 +6720,36 @@ pub mod msg_vel_cog { } } + /// Type of reported TOW + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] + pub enum TypeOfReportedTow { + /// Time of Measurement + TimeOfMeasurement = 0, + + /// Other + Other = 1, + } + + impl std::fmt::Display for TypeOfReportedTow { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TypeOfReportedTow::TimeOfMeasurement => f.write_str("Time of Measurement"), + TypeOfReportedTow::Other => f.write_str("Other"), + } + } + } + + impl TryFrom for TypeOfReportedTow { + type Error = TryFromIntError; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TypeOfReportedTow::TimeOfMeasurement), + 1 => Ok(TypeOfReportedTow::Other), + _ => Err(TryFromIntError), + } + } + } + /// INS Navigation Mode #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InsNavigationMode { From 436dae81d31073561e87860c1b5a4210305a41d7 Mon Sep 17 00:00:00 2001 From: Steve Meyer Date: Wed, 12 Jan 2022 11:16:08 -0800 Subject: [PATCH 07/13] return orginal bitfield value if it is unknown --- .../resources/rust/sbp_messages_mod.rs | 14 +- .../resources/rust/sbp_messages_template.rs | 8 +- rust/sbp/src/messages/ext_events.rs | 16 +- rust/sbp/src/messages/flash.rs | 40 +- rust/sbp/src/messages/gnss.rs | 16 +- rust/sbp/src/messages/imu.rs | 32 +- rust/sbp/src/messages/linux.rs | 24 +- rust/sbp/src/messages/logging.rs | 8 +- rust/sbp/src/messages/mod.rs | 14 +- rust/sbp/src/messages/navigation.rs | 604 +++++++++--------- rust/sbp/src/messages/ndb.rs | 36 +- rust/sbp/src/messages/observation.rs | 80 +-- rust/sbp/src/messages/orientation.rs | 32 +- rust/sbp/src/messages/piksi.rs | 48 +- rust/sbp/src/messages/settings.rs | 16 +- rust/sbp/src/messages/solution_meta.rs | 96 ++- rust/sbp/src/messages/ssr.rs | 8 +- rust/sbp/src/messages/system.rs | 166 +++-- rust/sbp/src/messages/tracking.rs | 296 ++++----- rust/sbp/src/messages/vehicle.rs | 40 +- 20 files changed, 754 insertions(+), 840 deletions(-) diff --git a/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs b/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs index fa3cb4d4b0..66cbbb30ab 100644 --- a/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs +++ b/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs @@ -33,7 +33,7 @@ mod lib { pub use crate::time; pub use crate::wire_format::{PayloadParseError, WireFormat}; - pub use super::{ConcreteMessage, Sbp, SbpMessage, TryFromSbpError, TryFromIntError}; + pub use super::{ConcreteMessage, Sbp, SbpMessage, TryFromSbpError}; pub use bytes::{Buf, BufMut}; @@ -105,18 +105,6 @@ impl std::fmt::Display for TryFromSbpError { impl std::error::Error for TryFromSbpError {} -/// The error returned when using [TryFrom] to convert an invalid integer to a bitfield type. -#[derive(Debug, Clone)] -pub struct TryFromIntError; - -impl std::fmt::Display for TryFromIntError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "int does not match any bitfield values") - } -} - -impl std::error::Error for TryFromIntError {} - /// Represents any SBP message. #[cfg_attr(feature = "serde", derive(serde::Serialize), serde(untagged))] #[derive(Debug, Clone)] diff --git a/generator/sbpg/targets/resources/rust/sbp_messages_template.rs b/generator/sbpg/targets/resources/rust/sbp_messages_template.rs index 76677bf1b9..c18ef15b81 100644 --- a/generator/sbpg/targets/resources/rust/sbp_messages_template.rs +++ b/generator/sbpg/targets/resources/rust/sbp_messages_template.rs @@ -66,8 +66,8 @@ impl (((m.msg_name))) { ((* for b in f.bitfield *)) ((* if b.vals|length > 0 *)) - pub fn (((b.field_name))) (&self) -> Option<(((b.type_name)))> { - get_bit_range!( self.(((b.field))), (((f.type))), (((b.type))), (((b.msb))), (((b.lsb))) ).try_into().ok() + pub fn (((b.field_name))) (&self) -> Result<(((b.type_name))), (((b.type)))> { + get_bit_range!( self.(((b.field))), (((f.type))), (((b.type))), (((b.msb))), (((b.lsb))) ).try_into() } pub fn set_(((b.field_name))) (&mut self, (((b.field_name))): (((b.type_name)))) { @@ -191,13 +191,13 @@ impl std::fmt::Display for (((b.type_name))) { } impl TryFrom<(((b.type)))> for (((b.type_name))) { - type Error = TryFromIntError; + type Error = (((b.type))); fn try_from(i: (((b.type))) ) -> Result { match i { ((*- for v in b.vals *)) (((v.value))) => Ok( (((b.type_name))) :: (((v.name))) ), ((*- endfor *)) - _ => Err(TryFromIntError), + i => Err(i), } } } diff --git a/rust/sbp/src/messages/ext_events.rs b/rust/sbp/src/messages/ext_events.rs index 42806d4d46..673bc08681 100644 --- a/rust/sbp/src/messages/ext_events.rs +++ b/rust/sbp/src/messages/ext_events.rs @@ -52,16 +52,16 @@ pub mod msg_ext_event { } impl MsgExtEvent { - pub fn time_quality(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() + pub fn time_quality(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 1, 0).try_into() } pub fn set_time_quality(&mut self, time_quality: TimeQuality) { set_bit_range!(&mut self.flags, time_quality, u8, u8, 1, 0); } - pub fn new_level_of_pin(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 0, 0).try_into().ok() + pub fn new_level_of_pin(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 0, 0).try_into() } pub fn set_new_level_of_pin(&mut self, new_level_of_pin: NewLevelOfPin) { @@ -170,12 +170,12 @@ pub mod msg_ext_event { } impl TryFrom for TimeQuality { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TimeQuality::UnknownDontHaveNavSolution), 1 => Ok(TimeQuality::Good), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -200,12 +200,12 @@ pub mod msg_ext_event { } impl TryFrom for NewLevelOfPin { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(NewLevelOfPin::Low), 1 => Ok(NewLevelOfPin::High), - _ => Err(TryFromIntError), + i => Err(i), } } } diff --git a/rust/sbp/src/messages/flash.rs b/rust/sbp/src/messages/flash.rs index c18bcac168..8eef2e44ff 100644 --- a/rust/sbp/src/messages/flash.rs +++ b/rust/sbp/src/messages/flash.rs @@ -52,8 +52,8 @@ pub mod msg_flash_done { } impl MsgFlashDone { - pub fn response_code(&self) -> Option { - get_bit_range!(self.response, u8, u8, 2, 0).try_into().ok() + pub fn response_code(&self) -> Result { + get_bit_range!(self.response, u8, u8, 2, 0).try_into() } pub fn set_response_code(&mut self, response_code: ResponseCode) { @@ -146,7 +146,7 @@ pub mod msg_flash_done { } impl TryFrom for ResponseCode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(ResponseCode::FlashOk), @@ -155,7 +155,7 @@ pub mod msg_flash_done { 3 => Ok(ResponseCode::FlashInvalidAddr), 4 => Ok(ResponseCode::FlashInvalidRange), 5 => Ok(ResponseCode::FlashInvalidSector), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -189,8 +189,8 @@ pub mod msg_flash_erase { } impl MsgFlashErase { - pub fn flash_target_to_read(&self) -> Option { - get_bit_range!(self.target, u8, u8, 0, 0).try_into().ok() + pub fn flash_target_to_read(&self) -> Result { + get_bit_range!(self.target, u8, u8, 0, 0).try_into() } pub fn set_flash_target_to_read(&mut self, flash_target_to_read: FlashTargetToRead) { @@ -269,12 +269,12 @@ pub mod msg_flash_erase { } impl TryFrom for FlashTargetToRead { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FlashTargetToRead::FlashStm), 1 => Ok(FlashTargetToRead::FlashM25), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -315,8 +315,8 @@ pub mod msg_flash_program { } impl MsgFlashProgram { - pub fn flash_target_to_read(&self) -> Option { - get_bit_range!(self.target, u8, u8, 0, 0).try_into().ok() + pub fn flash_target_to_read(&self) -> Result { + get_bit_range!(self.target, u8, u8, 0, 0).try_into() } pub fn set_flash_target_to_read(&mut self, flash_target_to_read: FlashTargetToRead) { @@ -405,12 +405,12 @@ pub mod msg_flash_program { } impl TryFrom for FlashTargetToRead { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FlashTargetToRead::FlashStm), 1 => Ok(FlashTargetToRead::FlashM25), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -449,8 +449,8 @@ pub mod msg_flash_read_req { } impl MsgFlashReadReq { - pub fn flash_target_to_read(&self) -> Option { - get_bit_range!(self.target, u8, u8, 0, 0).try_into().ok() + pub fn flash_target_to_read(&self) -> Result { + get_bit_range!(self.target, u8, u8, 0, 0).try_into() } pub fn set_flash_target_to_read(&mut self, flash_target_to_read: FlashTargetToRead) { @@ -535,12 +535,12 @@ pub mod msg_flash_read_req { } impl TryFrom for FlashTargetToRead { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FlashTargetToRead::FlashStm), 1 => Ok(FlashTargetToRead::FlashM25), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -579,8 +579,8 @@ pub mod msg_flash_read_resp { } impl MsgFlashReadResp { - pub fn flash_target_to_read(&self) -> Option { - get_bit_range!(self.target, u8, u8, 0, 0).try_into().ok() + pub fn flash_target_to_read(&self) -> Result { + get_bit_range!(self.target, u8, u8, 0, 0).try_into() } pub fn set_flash_target_to_read(&mut self, flash_target_to_read: FlashTargetToRead) { @@ -665,12 +665,12 @@ pub mod msg_flash_read_resp { } impl TryFrom for FlashTargetToRead { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FlashTargetToRead::FlashStm), 1 => Ok(FlashTargetToRead::FlashM25), - _ => Err(TryFromIntError), + i => Err(i), } } } diff --git a/rust/sbp/src/messages/gnss.rs b/rust/sbp/src/messages/gnss.rs index 25657da5e0..74c9d2f7c4 100644 --- a/rust/sbp/src/messages/gnss.rs +++ b/rust/sbp/src/messages/gnss.rs @@ -217,8 +217,8 @@ pub mod gnss_signal { } impl GnssSignal { - pub fn code(&self) -> Option { - get_bit_range!(self.code, u8, u8, 7, 0).try_into().ok() + pub fn code(&self) -> Result { + get_bit_range!(self.code, u8, u8, 7, 0).try_into() } pub fn set_code(&mut self, code: Code) { @@ -302,7 +302,7 @@ pub mod gnss_signal { } impl TryFrom for Code { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(Code::GpsL1Ca), @@ -317,7 +317,7 @@ pub mod gnss_signal { 14 => Ok(Code::GalE1B), 20 => Ok(Code::GalE7I), 47 => Ok(Code::Bds3B2A), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -351,8 +351,8 @@ pub mod gnss_signal_dep { } impl GnssSignalDep { - pub fn code(&self) -> Option { - get_bit_range!(self.code, u8, u8, 7, 0).try_into().ok() + pub fn code(&self) -> Result { + get_bit_range!(self.code, u8, u8, 7, 0).try_into() } pub fn set_code(&mut self, code: Code) { @@ -422,7 +422,7 @@ pub mod gnss_signal_dep { } impl TryFrom for Code { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(Code::GpsL1Ca), @@ -432,7 +432,7 @@ pub mod gnss_signal_dep { 4 => Ok(Code::GloL2Ca), 5 => Ok(Code::GpsL1P), 6 => Ok(Code::GpsL2P), - _ => Err(TryFromIntError), + i => Err(i), } } } diff --git a/rust/sbp/src/messages/imu.rs b/rust/sbp/src/messages/imu.rs index ca508d9856..b0a6843ea1 100644 --- a/rust/sbp/src/messages/imu.rs +++ b/rust/sbp/src/messages/imu.rs @@ -46,24 +46,24 @@ pub mod msg_imu_aux { } impl MsgImuAux { - pub fn imu_type(&self) -> Option { - get_bit_range!(self.imu_type, u8, u8, 7, 0).try_into().ok() + pub fn imu_type(&self) -> Result { + get_bit_range!(self.imu_type, u8, u8, 7, 0).try_into() } pub fn set_imu_type(&mut self, imu_type: ImuType) { set_bit_range!(&mut self.imu_type, imu_type, u8, u8, 7, 0); } - pub fn gyroscope_range(&self) -> Option { - get_bit_range!(self.imu_conf, u8, u8, 7, 4).try_into().ok() + pub fn gyroscope_range(&self) -> Result { + get_bit_range!(self.imu_conf, u8, u8, 7, 4).try_into() } pub fn set_gyroscope_range(&mut self, gyroscope_range: GyroscopeRange) { set_bit_range!(&mut self.imu_conf, gyroscope_range, u8, u8, 7, 4); } - pub fn accelerometer_range(&self) -> Option { - get_bit_range!(self.imu_conf, u8, u8, 3, 0).try_into().ok() + pub fn accelerometer_range(&self) -> Result { + get_bit_range!(self.imu_conf, u8, u8, 3, 0).try_into() } pub fn set_accelerometer_range(&mut self, accelerometer_range: AccelerometerRange) { @@ -150,12 +150,12 @@ pub mod msg_imu_aux { } impl TryFrom for ImuType { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(ImuType::BoschBmi160), 1 => Ok(ImuType::StMicroelectronicsAsm330Llh), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -192,7 +192,7 @@ pub mod msg_imu_aux { } impl TryFrom for GyroscopeRange { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(GyroscopeRange::_2000DegS), @@ -200,7 +200,7 @@ pub mod msg_imu_aux { 2 => Ok(GyroscopeRange::_500DegS), 3 => Ok(GyroscopeRange::_250DegS), 4 => Ok(GyroscopeRange::_125DegS), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -233,14 +233,14 @@ pub mod msg_imu_aux { } impl TryFrom for AccelerometerRange { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(AccelerometerRange::_2G), 1 => Ok(AccelerometerRange::_4G), 2 => Ok(AccelerometerRange::_8G), 3 => Ok(AccelerometerRange::_16G), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -298,8 +298,8 @@ pub mod msg_imu_raw { } impl MsgImuRaw { - pub fn time_status(&self) -> Option { - get_bit_range!(self.tow, u32, u8, 31, 30).try_into().ok() + pub fn time_status(&self) -> Result { + get_bit_range!(self.tow, u32, u8, 31, 30).try_into() } pub fn set_time_status(&mut self, time_status: TimeStatus) { @@ -447,14 +447,14 @@ pub mod msg_imu_raw { } impl TryFrom for TimeStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TimeStatus::ReferenceEpochIsStartOfCurrentGpsWeek), 1 => Ok(TimeStatus::ReferenceEpochIsTimeOfSystemStartup), 2 => Ok(TimeStatus::ReferenceEpochIsUnknown), 3 => Ok(TimeStatus::ReferenceEpochIsLastPps), - _ => Err(TryFromIntError), + i => Err(i), } } } diff --git a/rust/sbp/src/messages/linux.rs b/rust/sbp/src/messages/linux.rs index 88b2ee1f4c..a914015c6d 100644 --- a/rust/sbp/src/messages/linux.rs +++ b/rust/sbp/src/messages/linux.rs @@ -66,8 +66,8 @@ pub mod msg_linux_cpu_state { } impl MsgLinuxCpuState { - pub fn timestamp_type(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn timestamp_type(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_timestamp_type(&mut self, timestamp_type: TimestampType) { @@ -168,12 +168,12 @@ pub mod msg_linux_cpu_state { } impl TryFrom for TimestampType { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TimestampType::SystemTimeInSeconds), 1 => Ok(TimestampType::GpsTowInMilliseconds), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -320,8 +320,8 @@ pub mod msg_linux_mem_state { } impl MsgLinuxMemState { - pub fn timestamp_type(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn timestamp_type(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_timestamp_type(&mut self, timestamp_type: TimestampType) { @@ -422,12 +422,12 @@ pub mod msg_linux_mem_state { } impl TryFrom for TimestampType { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TimestampType::SystemTimeInSeconds), 1 => Ok(TimestampType::GpsTowInMilliseconds), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1081,8 +1081,8 @@ pub mod msg_linux_sys_state { } impl MsgLinuxSysState { - pub fn timestamp_type(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn timestamp_type(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_timestamp_type(&mut self, timestamp_type: TimestampType) { @@ -1187,12 +1187,12 @@ pub mod msg_linux_sys_state { } impl TryFrom for TimestampType { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TimestampType::SystemTimeInSeconds), 1 => Ok(TimestampType::GpsTowInMilliseconds), - _ => Err(TryFromIntError), + i => Err(i), } } } diff --git a/rust/sbp/src/messages/logging.rs b/rust/sbp/src/messages/logging.rs index 16d85a3251..8757735289 100644 --- a/rust/sbp/src/messages/logging.rs +++ b/rust/sbp/src/messages/logging.rs @@ -136,8 +136,8 @@ pub mod msg_log { } impl MsgLog { - pub fn logging_level(&self) -> Option { - get_bit_range!(self.level, u8, u8, 2, 0).try_into().ok() + pub fn logging_level(&self) -> Result { + get_bit_range!(self.level, u8, u8, 2, 0).try_into() } pub fn set_logging_level(&mut self, logging_level: LoggingLevel) { @@ -241,7 +241,7 @@ pub mod msg_log { } impl TryFrom for LoggingLevel { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(LoggingLevel::EMERG), @@ -252,7 +252,7 @@ pub mod msg_log { 5 => Ok(LoggingLevel::NOTICE), 6 => Ok(LoggingLevel::INFO), 7 => Ok(LoggingLevel::DEBUG), - _ => Err(TryFromIntError), + i => Err(i), } } } diff --git a/rust/sbp/src/messages/mod.rs b/rust/sbp/src/messages/mod.rs index 266382f59d..e38da22d25 100644 --- a/rust/sbp/src/messages/mod.rs +++ b/rust/sbp/src/messages/mod.rs @@ -250,7 +250,7 @@ mod lib { pub use crate::time; pub use crate::wire_format::{PayloadParseError, WireFormat}; - pub use super::{ConcreteMessage, Sbp, SbpMessage, TryFromIntError, TryFromSbpError}; + pub use super::{ConcreteMessage, Sbp, SbpMessage, TryFromSbpError}; pub use bytes::{Buf, BufMut}; @@ -322,18 +322,6 @@ impl std::fmt::Display for TryFromSbpError { impl std::error::Error for TryFromSbpError {} -/// The error returned when using [TryFrom] to convert an invalid integer to a bitfield type. -#[derive(Debug, Clone)] -pub struct TryFromIntError; - -impl std::fmt::Display for TryFromIntError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "int does not match any bitfield values") - } -} - -impl std::error::Error for TryFromIntError {} - /// Represents any SBP message. #[cfg_attr(feature = "serde", derive(serde::Serialize), serde(untagged))] #[derive(Debug, Clone)] diff --git a/rust/sbp/src/messages/navigation.rs b/rust/sbp/src/messages/navigation.rs index 93d731e210..bb260dd3a4 100644 --- a/rust/sbp/src/messages/navigation.rs +++ b/rust/sbp/src/messages/navigation.rs @@ -252,8 +252,8 @@ pub mod msg_baseline_ecef { } impl MsgBaselineEcef { - pub fn fix_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn fix_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -371,14 +371,14 @@ pub mod msg_baseline_ecef { } impl TryFrom for FixMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FixMode::Invalid), 2 => Ok(FixMode::DifferentialGnss), 3 => Ok(FixMode::FloatRtk), 4 => Ok(FixMode::FixedRtk), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -427,24 +427,24 @@ pub mod msg_baseline_ecef_dep_a { } impl MsgBaselineEcefDepA { - pub fn raim_repair_flag(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 0).try_into().ok() + pub fn raim_repair_flag(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 4, 0).try_into() } pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); } - pub fn raim_availability_flag(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 3, 0).try_into().ok() + pub fn raim_availability_flag(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 3, 0).try_into() } pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); } - pub fn fix_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn fix_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -556,12 +556,12 @@ pub mod msg_baseline_ecef_dep_a { } impl TryFrom for RaimRepairFlag { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(RaimRepairFlag::NoRepair), 1 => Ok(RaimRepairFlag::SolutionCameFromRaimRepair), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -590,12 +590,12 @@ pub mod msg_baseline_ecef_dep_a { } impl TryFrom for RaimAvailabilityFlag { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), 1 => Ok(RaimAvailabilityFlag::RaimCheckWasAvailable), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -620,12 +620,12 @@ pub mod msg_baseline_ecef_dep_a { } impl TryFrom for FixMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FixMode::FloatRtk), 1 => Ok(FixMode::FixedRtk), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -664,24 +664,24 @@ pub mod msg_baseline_heading_dep_a { } impl MsgBaselineHeadingDepA { - pub fn raim_repair_flag(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 0).try_into().ok() + pub fn raim_repair_flag(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 4, 0).try_into() } pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); } - pub fn raim_availability_flag(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 3, 0).try_into().ok() + pub fn raim_availability_flag(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 3, 0).try_into() } pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); } - pub fn fix_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn fix_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -781,12 +781,12 @@ pub mod msg_baseline_heading_dep_a { } impl TryFrom for RaimRepairFlag { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(RaimRepairFlag::NoRepair), 1 => Ok(RaimRepairFlag::SolutionCameFromRaimRepair), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -815,12 +815,12 @@ pub mod msg_baseline_heading_dep_a { } impl TryFrom for RaimAvailabilityFlag { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), 1 => Ok(RaimAvailabilityFlag::RaimCheckWasAvailable), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -845,12 +845,12 @@ pub mod msg_baseline_heading_dep_a { } impl TryFrom for FixMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FixMode::FloatRtk), 1 => Ok(FixMode::FixedRtk), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -904,8 +904,8 @@ pub mod msg_baseline_ned { } impl MsgBaselineNed { - pub fn fix_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn fix_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -1027,14 +1027,14 @@ pub mod msg_baseline_ned { } impl TryFrom for FixMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FixMode::Invalid), 2 => Ok(FixMode::DifferentialGnss), 3 => Ok(FixMode::FloatRtk), 4 => Ok(FixMode::FixedRtk), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1088,24 +1088,24 @@ pub mod msg_baseline_ned_dep_a { } impl MsgBaselineNedDepA { - pub fn raim_repair_flag(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 0).try_into().ok() + pub fn raim_repair_flag(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 4, 0).try_into() } pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); } - pub fn raim_availability_flag(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 3, 0).try_into().ok() + pub fn raim_availability_flag(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 3, 0).try_into() } pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); } - pub fn fix_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn fix_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -1221,12 +1221,12 @@ pub mod msg_baseline_ned_dep_a { } impl TryFrom for RaimRepairFlag { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(RaimRepairFlag::NoRepair), 1 => Ok(RaimRepairFlag::SolutionCameFromRaimRepair), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1255,12 +1255,12 @@ pub mod msg_baseline_ned_dep_a { } impl TryFrom for RaimAvailabilityFlag { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), 1 => Ok(RaimAvailabilityFlag::RaimCheckWasAvailable), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1285,12 +1285,12 @@ pub mod msg_baseline_ned_dep_a { } impl TryFrom for FixMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FixMode::FloatRtk), 1 => Ok(FixMode::FixedRtk), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1347,8 +1347,8 @@ pub mod msg_dops { set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 7, 0); } - pub fn fix_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn fix_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -1478,7 +1478,7 @@ pub mod msg_dops { } impl TryFrom for FixMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FixMode::Invalid), @@ -1488,7 +1488,7 @@ pub mod msg_dops { 4 => Ok(FixMode::FixedRtk), 5 => Ok(FixMode::Undefined), 6 => Ok(FixMode::SbasPosition), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1652,8 +1652,8 @@ pub mod msg_gps_time { } impl MsgGpsTime { - pub fn time_source(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn time_source(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_time_source(&mut self, time_source: TimeSource) { @@ -1760,13 +1760,13 @@ pub mod msg_gps_time { } impl TryFrom for TimeSource { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TimeSource::None), 1 => Ok(TimeSource::GnssSolution), 2 => Ok(TimeSource::Propagated), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1931,8 +1931,8 @@ pub mod msg_gps_time_gnss { } impl MsgGpsTimeGnss { - pub fn time_source(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn time_source(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_time_source(&mut self, time_source: TimeSource) { @@ -2039,13 +2039,13 @@ pub mod msg_gps_time_gnss { } impl TryFrom for TimeSource { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TimeSource::None), 1 => Ok(TimeSource::GnssSolution), 2 => Ok(TimeSource::Propagated), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2097,16 +2097,16 @@ pub mod msg_pos_ecef { } impl MsgPosEcef { - pub fn tow_type(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 5, 5).try_into().ok() + pub fn tow_type(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 5, 5).try_into() } pub fn set_tow_type(&mut self, tow_type: TowType) { set_bit_range!(&mut self.flags, tow_type, u8, u8, 5, 5); } - pub fn inertial_navigation_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() + pub fn inertial_navigation_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } pub fn set_inertial_navigation_mode( @@ -2116,8 +2116,8 @@ pub mod msg_pos_ecef { set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); } - pub fn fix_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn fix_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -2227,12 +2227,12 @@ pub mod msg_pos_ecef { } impl TryFrom for TowType { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TowType::TimeOfMeasurement), 1 => Ok(TowType::Other), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2257,12 +2257,12 @@ pub mod msg_pos_ecef { } impl TryFrom for InertialNavigationMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(InertialNavigationMode::None), 1 => Ok(InertialNavigationMode::InsUsed), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2307,7 +2307,7 @@ pub mod msg_pos_ecef { } impl TryFrom for FixMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FixMode::Invalid), @@ -2317,7 +2317,7 @@ pub mod msg_pos_ecef { 4 => Ok(FixMode::FixedRtk), 5 => Ok(FixMode::DeadReckoning), 6 => Ok(FixMode::SbasPosition), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2385,16 +2385,16 @@ pub mod msg_pos_ecef_cov { } impl MsgPosEcefCov { - pub fn type_of_reported_tow(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 5, 5).try_into().ok() + pub fn type_of_reported_tow(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 5, 5).try_into() } pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } - pub fn inertial_navigation_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() + pub fn inertial_navigation_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } pub fn set_inertial_navigation_mode( @@ -2404,8 +2404,8 @@ pub mod msg_pos_ecef_cov { set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); } - pub fn fix_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn fix_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -2535,12 +2535,12 @@ pub mod msg_pos_ecef_cov { } impl TryFrom for TypeOfReportedTow { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TypeOfReportedTow::TimeOfMeasurement), 1 => Ok(TypeOfReportedTow::Other), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2565,12 +2565,12 @@ pub mod msg_pos_ecef_cov { } impl TryFrom for InertialNavigationMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(InertialNavigationMode::None), 1 => Ok(InertialNavigationMode::InsUsed), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2615,7 +2615,7 @@ pub mod msg_pos_ecef_cov { } impl TryFrom for FixMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FixMode::Invalid), @@ -2625,7 +2625,7 @@ pub mod msg_pos_ecef_cov { 4 => Ok(FixMode::FixedRtk), 5 => Ok(FixMode::DeadReckoning), 6 => Ok(FixMode::SbasPosition), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2693,8 +2693,8 @@ pub mod msg_pos_ecef_cov_gnss { } impl MsgPosEcefCovGnss { - pub fn fix_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn fix_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -2840,7 +2840,7 @@ pub mod msg_pos_ecef_cov_gnss { } impl TryFrom for FixMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FixMode::Invalid), @@ -2849,7 +2849,7 @@ pub mod msg_pos_ecef_cov_gnss { 3 => Ok(FixMode::FloatRtk), 4 => Ok(FixMode::FixedRtk), 6 => Ok(FixMode::SbasPosition), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2901,24 +2901,24 @@ pub mod msg_pos_ecef_dep_a { } impl MsgPosEcefDepA { - pub fn raim_repair_flag(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 0).try_into().ok() + pub fn raim_repair_flag(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 4, 0).try_into() } pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); } - pub fn raim_availability_flag(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 3, 0).try_into().ok() + pub fn raim_availability_flag(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 3, 0).try_into() } pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); } - pub fn fix_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn fix_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -3030,12 +3030,12 @@ pub mod msg_pos_ecef_dep_a { } impl TryFrom for RaimRepairFlag { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(RaimRepairFlag::NoRepair), 1 => Ok(RaimRepairFlag::SolutionCameFromRaimRepair), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -3064,12 +3064,12 @@ pub mod msg_pos_ecef_dep_a { } impl TryFrom for RaimAvailabilityFlag { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), 1 => Ok(RaimAvailabilityFlag::RaimCheckWasAvailable), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -3098,13 +3098,13 @@ pub mod msg_pos_ecef_dep_a { } impl TryFrom for FixMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FixMode::SinglePointPositioning), 1 => Ok(FixMode::FixedRtk), 2 => Ok(FixMode::FloatRtk), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -3156,8 +3156,8 @@ pub mod msg_pos_ecef_gnss { } impl MsgPosEcefGnss { - pub fn fix_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn fix_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -3283,7 +3283,7 @@ pub mod msg_pos_ecef_gnss { } impl TryFrom for FixMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FixMode::Invalid), @@ -3292,7 +3292,7 @@ pub mod msg_pos_ecef_gnss { 3 => Ok(FixMode::FloatRtk), 4 => Ok(FixMode::FixedRtk), 6 => Ok(FixMode::SbasPosition), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -3347,16 +3347,16 @@ pub mod msg_pos_llh { } impl MsgPosLlh { - pub fn type_of_reported_tow(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 5, 5).try_into().ok() + pub fn type_of_reported_tow(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 5, 5).try_into() } pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } - pub fn inertial_navigation_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() + pub fn inertial_navigation_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } pub fn set_inertial_navigation_mode( @@ -3366,8 +3366,8 @@ pub mod msg_pos_llh { set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); } - pub fn fix_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn fix_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -3481,12 +3481,12 @@ pub mod msg_pos_llh { } impl TryFrom for TypeOfReportedTow { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TypeOfReportedTow::TimeOfMeasurement), 1 => Ok(TypeOfReportedTow::Other), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -3511,12 +3511,12 @@ pub mod msg_pos_llh { } impl TryFrom for InertialNavigationMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(InertialNavigationMode::None), 1 => Ok(InertialNavigationMode::InsUsed), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -3561,7 +3561,7 @@ pub mod msg_pos_llh { } impl TryFrom for FixMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FixMode::Invalid), @@ -3571,7 +3571,7 @@ pub mod msg_pos_llh { 4 => Ok(FixMode::FixedRtk), 5 => Ok(FixMode::DeadReckoning), 6 => Ok(FixMode::SbasPosition), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -3652,20 +3652,16 @@ pub mod msg_pos_llh_acc { } impl MsgPosLlhAcc { - pub fn geoid_model(&self) -> Option { - get_bit_range!(self.confidence_and_geoid, u8, u8, 6, 4) - .try_into() - .ok() + pub fn geoid_model(&self) -> Result { + get_bit_range!(self.confidence_and_geoid, u8, u8, 6, 4).try_into() } pub fn set_geoid_model(&mut self, geoid_model: GeoidModel) { set_bit_range!(&mut self.confidence_and_geoid, geoid_model, u8, u8, 6, 4); } - pub fn confidence_level(&self) -> Option { - get_bit_range!(self.confidence_and_geoid, u8, u8, 3, 0) - .try_into() - .ok() + pub fn confidence_level(&self) -> Result { + get_bit_range!(self.confidence_and_geoid, u8, u8, 3, 0).try_into() } pub fn set_confidence_level(&mut self, confidence_level: ConfidenceLevel) { @@ -3679,16 +3675,16 @@ pub mod msg_pos_llh_acc { ); } - pub fn type_of_reported_tow(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 5, 5).try_into().ok() + pub fn type_of_reported_tow(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 5, 5).try_into() } pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } - pub fn inertial_navigation_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() + pub fn inertial_navigation_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } pub fn set_inertial_navigation_mode( @@ -3698,8 +3694,8 @@ pub mod msg_pos_llh_acc { set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); } - pub fn fix_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn fix_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -3837,13 +3833,13 @@ pub mod msg_pos_llh_acc { } impl TryFrom for GeoidModel { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(GeoidModel::NoModel), 1 => Ok(GeoidModel::EGM96), 2 => Ok(GeoidModel::EGM2008), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -3872,13 +3868,13 @@ pub mod msg_pos_llh_acc { } impl TryFrom for ConfidenceLevel { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 1 => Ok(ConfidenceLevel::_3935), 2 => Ok(ConfidenceLevel::_6827), 3 => Ok(ConfidenceLevel::_9545), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -3903,12 +3899,12 @@ pub mod msg_pos_llh_acc { } impl TryFrom for TypeOfReportedTow { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TypeOfReportedTow::TimeOfMeasurement), 1 => Ok(TypeOfReportedTow::Other), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -3933,12 +3929,12 @@ pub mod msg_pos_llh_acc { } impl TryFrom for InertialNavigationMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(InertialNavigationMode::None), 1 => Ok(InertialNavigationMode::InsUsed), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -3983,7 +3979,7 @@ pub mod msg_pos_llh_acc { } impl TryFrom for FixMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FixMode::Invalid), @@ -3993,7 +3989,7 @@ pub mod msg_pos_llh_acc { 4 => Ok(FixMode::FixedRtk), 5 => Ok(FixMode::DeadReckoning), 6 => Ok(FixMode::SbasPosition), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -4061,16 +4057,16 @@ pub mod msg_pos_llh_cov { } impl MsgPosLlhCov { - pub fn type_of_reported_tow(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 5, 5).try_into().ok() + pub fn type_of_reported_tow(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 5, 5).try_into() } pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } - pub fn inertial_navigation_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() + pub fn inertial_navigation_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } pub fn set_inertial_navigation_mode( @@ -4080,8 +4076,8 @@ pub mod msg_pos_llh_cov { set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); } - pub fn fix_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn fix_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -4211,12 +4207,12 @@ pub mod msg_pos_llh_cov { } impl TryFrom for TypeOfReportedTow { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TypeOfReportedTow::TimeOfMeasurement), 1 => Ok(TypeOfReportedTow::Other), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -4241,12 +4237,12 @@ pub mod msg_pos_llh_cov { } impl TryFrom for InertialNavigationMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(InertialNavigationMode::None), 1 => Ok(InertialNavigationMode::InsUsed), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -4291,7 +4287,7 @@ pub mod msg_pos_llh_cov { } impl TryFrom for FixMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FixMode::Invalid), @@ -4301,7 +4297,7 @@ pub mod msg_pos_llh_cov { 4 => Ok(FixMode::FixedRtk), 5 => Ok(FixMode::DeadReckoning), 6 => Ok(FixMode::SbasPosition), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -4369,8 +4365,8 @@ pub mod msg_pos_llh_cov_gnss { } impl MsgPosLlhCovGnss { - pub fn fix_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn fix_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -4520,7 +4516,7 @@ pub mod msg_pos_llh_cov_gnss { } impl TryFrom for FixMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FixMode::Invalid), @@ -4530,7 +4526,7 @@ pub mod msg_pos_llh_cov_gnss { 4 => Ok(FixMode::FixedRtk), 5 => Ok(FixMode::DeadReckoning), 6 => Ok(FixMode::SbasPosition), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -4585,32 +4581,32 @@ pub mod msg_pos_llh_dep_a { } impl MsgPosLlhDepA { - pub fn raim_repair_flag(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 5, 0).try_into().ok() + pub fn raim_repair_flag(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 5, 0).try_into() } pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 5, 0); } - pub fn raim_availability_flag(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 0).try_into().ok() + pub fn raim_availability_flag(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 4, 0).try_into() } pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 4, 0); } - pub fn height_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 3, 0).try_into().ok() + pub fn height_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 3, 0).try_into() } pub fn set_height_mode(&mut self, height_mode: HeightMode) { set_bit_range!(&mut self.flags, height_mode, u8, u8, 3, 0); } - pub fn fix_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn fix_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -4726,12 +4722,12 @@ pub mod msg_pos_llh_dep_a { } impl TryFrom for RaimRepairFlag { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(RaimRepairFlag::NoRepair), 1 => Ok(RaimRepairFlag::SolutionCameFromRaimRepair), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -4760,12 +4756,12 @@ pub mod msg_pos_llh_dep_a { } impl TryFrom for RaimAvailabilityFlag { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(RaimAvailabilityFlag::RaimCheckWasExplicitlyDisabledOrUnavailable), 1 => Ok(RaimAvailabilityFlag::RaimCheckWasAvailable), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -4792,12 +4788,12 @@ pub mod msg_pos_llh_dep_a { } impl TryFrom for HeightMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(HeightMode::HeightAboveWgs84Ellipsoid), 1 => Ok(HeightMode::HeightAboveMeanSeaLevel), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -4826,13 +4822,13 @@ pub mod msg_pos_llh_dep_a { } impl TryFrom for FixMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FixMode::SinglePointPositioning), 1 => Ok(FixMode::FixedRtk), 2 => Ok(FixMode::FloatRtk), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -4887,8 +4883,8 @@ pub mod msg_pos_llh_gnss { } impl MsgPosLlhGnss { - pub fn fix_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn fix_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -5018,7 +5014,7 @@ pub mod msg_pos_llh_gnss { } impl TryFrom for FixMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FixMode::Invalid), @@ -5027,7 +5023,7 @@ pub mod msg_pos_llh_gnss { 3 => Ok(FixMode::FloatRtk), 4 => Ok(FixMode::FixedRtk), 6 => Ok(FixMode::SbasPosition), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -5134,16 +5130,16 @@ pub mod msg_protection_level { ); } - pub fn fix_mode(&self) -> Option { - get_bit_range!(self.flags, u32, u8, 17, 15).try_into().ok() + pub fn fix_mode(&self) -> Result { + get_bit_range!(self.flags, u32, u8, 17, 15).try_into() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u32, u8, 17, 15); } - pub fn inertial_navigation_mode(&self) -> Option { - get_bit_range!(self.flags, u32, u8, 19, 18).try_into().ok() + pub fn inertial_navigation_mode(&self) -> Result { + get_bit_range!(self.flags, u32, u8, 19, 18).try_into() } pub fn set_inertial_navigation_mode( @@ -5153,8 +5149,8 @@ pub mod msg_protection_level { set_bit_range!(&mut self.flags, inertial_navigation_mode, u32, u8, 19, 18); } - pub fn time_status(&self) -> Option { - get_bit_range!(self.flags, u32, u8, 20, 0).try_into().ok() + pub fn time_status(&self) -> Result { + get_bit_range!(self.flags, u32, u8, 20, 0).try_into() } pub fn set_time_status(&mut self, time_status: TimeStatus) { @@ -5433,7 +5429,7 @@ pub mod msg_protection_level { } impl TryFrom for FixMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FixMode::Invalid), @@ -5443,7 +5439,7 @@ pub mod msg_protection_level { 4 => Ok(FixMode::FixedRtk), 5 => Ok(FixMode::DeadReckoning), 6 => Ok(FixMode::SbasPosition), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -5468,12 +5464,12 @@ pub mod msg_protection_level { } impl TryFrom for InertialNavigationMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(InertialNavigationMode::None), 1 => Ok(InertialNavigationMode::InsUsed), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -5498,12 +5494,12 @@ pub mod msg_protection_level { } impl TryFrom for TimeStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TimeStatus::GnssTimeOfValidity), 1 => Ok(TimeStatus::Other), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -5551,8 +5547,8 @@ pub mod msg_protection_level_dep_a { } impl MsgProtectionLevelDepA { - pub fn target_integrity_risk_tir_level(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn target_integrity_risk_tir_level(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_target_integrity_risk_tir_level( @@ -5681,14 +5677,14 @@ pub mod msg_protection_level_dep_a { } impl TryFrom for TargetIntegrityRiskTirLevel { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok( TargetIntegrityRiskTirLevel :: SafeStateProtectionLevelShallNotBeUsedForSafetyCriticalApplication ), 1 => Ok( TargetIntegrityRiskTirLevel :: TirLevel1 ), 2 => Ok( TargetIntegrityRiskTirLevel :: TirLevel2 ), 3 => Ok( TargetIntegrityRiskTirLevel :: TirLevel3 ), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -5742,16 +5738,16 @@ pub mod msg_utc_time { } impl MsgUtcTime { - pub fn utc_offset_source(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() + pub fn utc_offset_source(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } pub fn set_utc_offset_source(&mut self, utc_offset_source: UtcOffsetSource) { set_bit_range!(&mut self.flags, utc_offset_source, u8, u8, 4, 3); } - pub fn time_source(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn time_source(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_time_source(&mut self, time_source: TimeSource) { @@ -5873,13 +5869,13 @@ pub mod msg_utc_time { } impl TryFrom for UtcOffsetSource { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(UtcOffsetSource::FactoryDefault), 1 => Ok(UtcOffsetSource::NonVolatileMemory), 2 => Ok(UtcOffsetSource::DecodedThisSession), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -5908,13 +5904,13 @@ pub mod msg_utc_time { } impl TryFrom for TimeSource { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TimeSource::None), 1 => Ok(TimeSource::GnssSolution), 2 => Ok(TimeSource::Propagated), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -5968,16 +5964,16 @@ pub mod msg_utc_time_gnss { } impl MsgUtcTimeGnss { - pub fn utc_offset_source(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() + pub fn utc_offset_source(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } pub fn set_utc_offset_source(&mut self, utc_offset_source: UtcOffsetSource) { set_bit_range!(&mut self.flags, utc_offset_source, u8, u8, 4, 3); } - pub fn time_source(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn time_source(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_time_source(&mut self, time_source: TimeSource) { @@ -6099,13 +6095,13 @@ pub mod msg_utc_time_gnss { } impl TryFrom for UtcOffsetSource { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(UtcOffsetSource::FactoryDefault), 1 => Ok(UtcOffsetSource::NonVolatileMemory), 2 => Ok(UtcOffsetSource::DecodedThisSession), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -6134,13 +6130,13 @@ pub mod msg_utc_time_gnss { } impl TryFrom for TimeSource { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TimeSource::None), 1 => Ok(TimeSource::GnssSolution), 2 => Ok(TimeSource::Propagated), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -6209,16 +6205,16 @@ pub mod msg_vel_body { } impl MsgVelBody { - pub fn ins_navigation_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() + pub fn ins_navigation_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); } - pub fn velocity_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn velocity_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -6348,12 +6344,12 @@ pub mod msg_vel_body { } impl TryFrom for InsNavigationMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(InsNavigationMode::None), 1 => Ok(InsNavigationMode::InsUsed), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -6386,14 +6382,14 @@ pub mod msg_vel_body { } impl TryFrom for VelocityMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(VelocityMode::Invalid), 1 => Ok(VelocityMode::MeasuredDopplerDerived), 2 => Ok(VelocityMode::ComputedDopplerDerived), 3 => Ok(VelocityMode::DeadReckoning), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -6452,16 +6448,16 @@ pub mod msg_vel_cog { } impl MsgVelCog { - pub fn cog_frozen(&self) -> Option { - get_bit_range!(self.flags, u16, u8, 9, 0).try_into().ok() + pub fn cog_frozen(&self) -> Result { + get_bit_range!(self.flags, u16, u8, 9, 0).try_into() } pub fn set_cog_frozen(&mut self, cog_frozen: CogFrozen) { set_bit_range!(&mut self.flags, cog_frozen, u16, u8, 9, 0); } - pub fn vertical_velocity_validity(&self) -> Option { - get_bit_range!(self.flags, u16, u8, 8, 0).try_into().ok() + pub fn vertical_velocity_validity(&self) -> Result { + get_bit_range!(self.flags, u16, u8, 8, 0).try_into() } pub fn set_vertical_velocity_validity( @@ -6471,40 +6467,40 @@ pub mod msg_vel_cog { set_bit_range!(&mut self.flags, vertical_velocity_validity, u16, u8, 8, 0); } - pub fn sog_validity(&self) -> Option { - get_bit_range!(self.flags, u16, u8, 7, 0).try_into().ok() + pub fn sog_validity(&self) -> Result { + get_bit_range!(self.flags, u16, u8, 7, 0).try_into() } pub fn set_sog_validity(&mut self, sog_validity: SogValidity) { set_bit_range!(&mut self.flags, sog_validity, u16, u8, 7, 0); } - pub fn cog_validity(&self) -> Option { - get_bit_range!(self.flags, u16, u8, 6, 0).try_into().ok() + pub fn cog_validity(&self) -> Result { + get_bit_range!(self.flags, u16, u8, 6, 0).try_into() } pub fn set_cog_validity(&mut self, cog_validity: CogValidity) { set_bit_range!(&mut self.flags, cog_validity, u16, u8, 6, 0); } - pub fn type_of_reported_tow(&self) -> Option { - get_bit_range!(self.flags, u16, u8, 5, 0).try_into().ok() + pub fn type_of_reported_tow(&self) -> Result { + get_bit_range!(self.flags, u16, u8, 5, 0).try_into() } pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { set_bit_range!(&mut self.flags, type_of_reported_tow, u16, u8, 5, 0); } - pub fn ins_navigation_mode(&self) -> Option { - get_bit_range!(self.flags, u16, u8, 4, 3).try_into().ok() + pub fn ins_navigation_mode(&self) -> Result { + get_bit_range!(self.flags, u16, u8, 4, 3).try_into() } pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { set_bit_range!(&mut self.flags, ins_navigation_mode, u16, u8, 4, 3); } - pub fn velocity_mode(&self) -> Option { - get_bit_range!(self.flags, u16, u8, 2, 0).try_into().ok() + pub fn velocity_mode(&self) -> Result { + get_bit_range!(self.flags, u16, u8, 2, 0).try_into() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -6618,12 +6614,12 @@ pub mod msg_vel_cog { } impl TryFrom for CogFrozen { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(CogFrozen::NotFrozen), 1 => Ok(CogFrozen::Frozen), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -6650,12 +6646,12 @@ pub mod msg_vel_cog { } impl TryFrom for VerticalVelocityValidity { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(VerticalVelocityValidity::Invalid), 1 => Ok(VerticalVelocityValidity::VerticalVelocityValid), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -6680,12 +6676,12 @@ pub mod msg_vel_cog { } impl TryFrom for SogValidity { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(SogValidity::Invalid), 1 => Ok(SogValidity::SogValid), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -6710,12 +6706,12 @@ pub mod msg_vel_cog { } impl TryFrom for CogValidity { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(CogValidity::Invalid), 1 => Ok(CogValidity::CogValid), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -6740,12 +6736,12 @@ pub mod msg_vel_cog { } impl TryFrom for TypeOfReportedTow { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TypeOfReportedTow::TimeOfMeasurement), 1 => Ok(TypeOfReportedTow::Other), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -6770,12 +6766,12 @@ pub mod msg_vel_cog { } impl TryFrom for InsNavigationMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(InsNavigationMode::None), 1 => Ok(InsNavigationMode::InsUsed), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -6808,14 +6804,14 @@ pub mod msg_vel_cog { } impl TryFrom for VelocityMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(VelocityMode::Invalid), 1 => Ok(VelocityMode::MeasuredDopplerDerived), 2 => Ok(VelocityMode::ComputedDopplerDerived), 3 => Ok(VelocityMode::DeadReckoning), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -6863,24 +6859,24 @@ pub mod msg_vel_ecef { } impl MsgVelEcef { - pub fn type_of_reported_tow(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 5, 5).try_into().ok() + pub fn type_of_reported_tow(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 5, 5).try_into() } pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } - pub fn ins_navigation_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() + pub fn ins_navigation_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); } - pub fn velocity_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn velocity_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -6990,12 +6986,12 @@ pub mod msg_vel_ecef { } impl TryFrom for TypeOfReportedTow { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TypeOfReportedTow::TimeOfMeasurement), 1 => Ok(TypeOfReportedTow::Other), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -7020,12 +7016,12 @@ pub mod msg_vel_ecef { } impl TryFrom for InsNavigationMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(InsNavigationMode::None), 1 => Ok(InsNavigationMode::InsUsed), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -7058,14 +7054,14 @@ pub mod msg_vel_ecef { } impl TryFrom for VelocityMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(VelocityMode::Invalid), 1 => Ok(VelocityMode::MeasuredDopplerDerived), 2 => Ok(VelocityMode::ComputedDopplerDerived), 3 => Ok(VelocityMode::DeadReckoning), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -7128,24 +7124,24 @@ pub mod msg_vel_ecef_cov { } impl MsgVelEcefCov { - pub fn type_of_reported_tow(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 5, 5).try_into().ok() + pub fn type_of_reported_tow(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 5, 5).try_into() } pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } - pub fn ins_navigation_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() + pub fn ins_navigation_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); } - pub fn velocity_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn velocity_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -7275,12 +7271,12 @@ pub mod msg_vel_ecef_cov { } impl TryFrom for TypeOfReportedTow { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TypeOfReportedTow::TimeOfMeasurement), 1 => Ok(TypeOfReportedTow::Other), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -7305,12 +7301,12 @@ pub mod msg_vel_ecef_cov { } impl TryFrom for InsNavigationMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(InsNavigationMode::None), 1 => Ok(InsNavigationMode::InsUsed), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -7343,14 +7339,14 @@ pub mod msg_vel_ecef_cov { } impl TryFrom for VelocityMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(VelocityMode::Invalid), 1 => Ok(VelocityMode::MeasuredDopplerDerived), 2 => Ok(VelocityMode::ComputedDopplerDerived), 3 => Ok(VelocityMode::DeadReckoning), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -7413,8 +7409,8 @@ pub mod msg_vel_ecef_cov_gnss { } impl MsgVelEcefCovGnss { - pub fn velocity_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn velocity_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -7548,13 +7544,13 @@ pub mod msg_vel_ecef_cov_gnss { } impl TryFrom for VelocityMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(VelocityMode::Invalid), 1 => Ok(VelocityMode::MeasuredDopplerDerived), 2 => Ok(VelocityMode::ComputedDopplerDerived), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -7726,8 +7722,8 @@ pub mod msg_vel_ecef_gnss { } impl MsgVelEcefGnss { - pub fn velocity_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn velocity_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -7841,13 +7837,13 @@ pub mod msg_vel_ecef_gnss { } impl TryFrom for VelocityMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(VelocityMode::Invalid), 1 => Ok(VelocityMode::MeasuredDopplerDerived), 2 => Ok(VelocityMode::ComputedDopplerDerived), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -7899,24 +7895,24 @@ pub mod msg_vel_ned { } impl MsgVelNed { - pub fn type_of_reported_tow(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 5, 5).try_into().ok() + pub fn type_of_reported_tow(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 5, 5).try_into() } pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } - pub fn ins_navigation_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() + pub fn ins_navigation_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); } - pub fn velocity_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn velocity_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -8030,12 +8026,12 @@ pub mod msg_vel_ned { } impl TryFrom for TypeOfReportedTow { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TypeOfReportedTow::TimeOfMeasurement), 1 => Ok(TypeOfReportedTow::Other), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -8060,12 +8056,12 @@ pub mod msg_vel_ned { } impl TryFrom for InsNavigationMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(InsNavigationMode::None), 1 => Ok(InsNavigationMode::InsUsed), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -8098,14 +8094,14 @@ pub mod msg_vel_ned { } impl TryFrom for VelocityMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(VelocityMode::Invalid), 1 => Ok(VelocityMode::MeasuredDopplerDerived), 2 => Ok(VelocityMode::ComputedDopplerDerived), 3 => Ok(VelocityMode::DeadReckoning), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -8171,24 +8167,24 @@ pub mod msg_vel_ned_cov { } impl MsgVelNedCov { - pub fn type_of_reported_tow(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 5, 5).try_into().ok() + pub fn type_of_reported_tow(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 5, 5).try_into() } pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } - pub fn ins_navigation_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() + pub fn ins_navigation_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); } - pub fn velocity_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn velocity_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -8318,12 +8314,12 @@ pub mod msg_vel_ned_cov { } impl TryFrom for TypeOfReportedTow { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TypeOfReportedTow::TimeOfMeasurement), 1 => Ok(TypeOfReportedTow::Other), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -8348,12 +8344,12 @@ pub mod msg_vel_ned_cov { } impl TryFrom for InsNavigationMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(InsNavigationMode::None), 1 => Ok(InsNavigationMode::InsUsed), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -8386,14 +8382,14 @@ pub mod msg_vel_ned_cov { } impl TryFrom for VelocityMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(VelocityMode::Invalid), 1 => Ok(VelocityMode::MeasuredDopplerDerived), 2 => Ok(VelocityMode::ComputedDopplerDerived), 3 => Ok(VelocityMode::DeadReckoning), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -8459,8 +8455,8 @@ pub mod msg_vel_ned_cov_gnss { } impl MsgVelNedCovGnss { - pub fn velocity_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn velocity_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -8594,13 +8590,13 @@ pub mod msg_vel_ned_cov_gnss { } impl TryFrom for VelocityMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(VelocityMode::Invalid), 1 => Ok(VelocityMode::MeasuredDopplerDerived), 2 => Ok(VelocityMode::ComputedDopplerDerived), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -8784,8 +8780,8 @@ pub mod msg_vel_ned_gnss { } impl MsgVelNedGnss { - pub fn velocity_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn velocity_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { @@ -8903,13 +8899,13 @@ pub mod msg_vel_ned_gnss { } impl TryFrom for VelocityMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(VelocityMode::Invalid), 1 => Ok(VelocityMode::MeasuredDopplerDerived), 2 => Ok(VelocityMode::ComputedDopplerDerived), - _ => Err(TryFromIntError), + i => Err(i), } } } diff --git a/rust/sbp/src/messages/ndb.rs b/rust/sbp/src/messages/ndb.rs index 7d9e1127c2..ab88f11f65 100644 --- a/rust/sbp/src/messages/ndb.rs +++ b/rust/sbp/src/messages/ndb.rs @@ -66,36 +66,32 @@ pub mod msg_ndb_event { } impl MsgNdbEvent { - pub fn event_type(&self) -> Option { - get_bit_range!(self.event, u8, u8, 1, 0).try_into().ok() + pub fn event_type(&self) -> Result { + get_bit_range!(self.event, u8, u8, 1, 0).try_into() } pub fn set_event_type(&mut self, event_type: EventType) { set_bit_range!(&mut self.event, event_type, u8, u8, 1, 0); } - pub fn event_object_type(&self) -> Option { - get_bit_range!(self.object_type, u8, u8, 2, 0) - .try_into() - .ok() + pub fn event_object_type(&self) -> Result { + get_bit_range!(self.object_type, u8, u8, 2, 0).try_into() } pub fn set_event_object_type(&mut self, event_object_type: EventObjectType) { set_bit_range!(&mut self.object_type, event_object_type, u8, u8, 2, 0); } - pub fn event_result(&self) -> Option { - get_bit_range!(self.result, u8, u8, 3, 0).try_into().ok() + pub fn event_result(&self) -> Result { + get_bit_range!(self.result, u8, u8, 3, 0).try_into() } pub fn set_event_result(&mut self, event_result: EventResult) { set_bit_range!(&mut self.result, event_result, u8, u8, 3, 0); } - pub fn data_source(&self) -> Option { - get_bit_range!(self.data_source, u8, u8, 1, 0) - .try_into() - .ok() + pub fn data_source(&self) -> Result { + get_bit_range!(self.data_source, u8, u8, 1, 0).try_into() } pub fn set_data_source(&mut self, data_source: DataSource) { @@ -208,14 +204,14 @@ pub mod msg_ndb_event { } impl TryFrom for EventType { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(EventType::UNKNOWN), 1 => Ok(EventType::STORE), 2 => Ok(EventType::FETCH), 3 => Ok(EventType::ERASE), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -260,7 +256,7 @@ pub mod msg_ndb_event { } impl TryFrom for EventObjectType { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(EventObjectType::UNKNOWN), @@ -270,7 +266,7 @@ pub mod msg_ndb_event { 4 => Ok(EventObjectType::IoNO), 5 => Ok(EventObjectType::L2CCap), 6 => Ok(EventObjectType::LGF), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -331,7 +327,7 @@ pub mod msg_ndb_event { } impl TryFrom for EventResult { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(EventResult::NdbErrNone), @@ -345,7 +341,7 @@ pub mod msg_ndb_event { 8 => Ok(EventResult::NdbErrNoData), 9 => Ok(EventResult::NdbErrNoChange), 10 => Ok(EventResult::NdbErrOlderData), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -378,14 +374,14 @@ pub mod msg_ndb_event { } impl TryFrom for DataSource { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(DataSource::NdbDsUndefined), 1 => Ok(DataSource::NdbDsInit), 2 => Ok(DataSource::NdbDsReceiver), 3 => Ok(DataSource::NdbDsSbp), - _ => Err(TryFromIntError), + i => Err(i), } } } diff --git a/rust/sbp/src/messages/observation.rs b/rust/sbp/src/messages/observation.rs index cd851fa118..c82d9c9f8c 100644 --- a/rust/sbp/src/messages/observation.rs +++ b/rust/sbp/src/messages/observation.rs @@ -6350,40 +6350,40 @@ pub mod packed_obs_content { } impl PackedObsContent { - pub fn raim_exclusion(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 7, 0).try_into().ok() + pub fn raim_exclusion(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 7, 0).try_into() } pub fn set_raim_exclusion(&mut self, raim_exclusion: RaimExclusion) { set_bit_range!(&mut self.flags, raim_exclusion, u8, u8, 7, 0); } - pub fn doppler_valid(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 3, 0).try_into().ok() + pub fn doppler_valid(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 3, 0).try_into() } pub fn set_doppler_valid(&mut self, doppler_valid: DopplerValid) { set_bit_range!(&mut self.flags, doppler_valid, u8, u8, 3, 0); } - pub fn halfcycle_ambiguity(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn halfcycle_ambiguity(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_halfcycle_ambiguity(&mut self, halfcycle_ambiguity: HalfCycleAmbiguity) { set_bit_range!(&mut self.flags, halfcycle_ambiguity, u8, u8, 2, 0); } - pub fn carrier_phase_valid(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() + pub fn carrier_phase_valid(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 1, 0).try_into() } pub fn set_carrier_phase_valid(&mut self, carrier_phase_valid: CarrierPhaseValid) { set_bit_range!(&mut self.flags, carrier_phase_valid, u8, u8, 1, 0); } - pub fn pseudorange_valid(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 0, 0).try_into().ok() + pub fn pseudorange_valid(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 0, 0).try_into() } pub fn set_pseudorange_valid(&mut self, pseudorange_valid: PseudorangeValid) { @@ -6452,12 +6452,12 @@ pub mod packed_obs_content { } impl TryFrom for RaimExclusion { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(RaimExclusion::NoExclusion), 1 => Ok(RaimExclusion::MeasurementWasExcludedBySppRaimUseWithCare), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -6484,12 +6484,12 @@ pub mod packed_obs_content { } impl TryFrom for DopplerValid { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(DopplerValid::InvalidDopplerMeasurement), 1 => Ok(DopplerValid::ValidDopplerMeasurement), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -6518,12 +6518,12 @@ pub mod packed_obs_content { } impl TryFrom for HalfCycleAmbiguity { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(HalfCycleAmbiguity::HalfCyclePhaseAmbiguityUnresolved), 1 => Ok(HalfCycleAmbiguity::HalfCyclePhaseAmbiguityResolved), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -6552,12 +6552,12 @@ pub mod packed_obs_content { } impl TryFrom for CarrierPhaseValid { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(CarrierPhaseValid::InvalidCarrierPhaseMeasurement), 1 => Ok(CarrierPhaseValid::ValidCarrierPhaseMeasurement), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -6586,12 +6586,12 @@ pub mod packed_obs_content { } impl TryFrom for PseudorangeValid { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(PseudorangeValid::InvalidPseudorangeMeasurement), 1 => Ok(PseudorangeValid::ValidPseudorangeMeasurementAndCoarseTowDecoded), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -6841,8 +6841,8 @@ pub mod packed_osr_content { } impl PackedOsrContent { - pub fn invalid_phase_corrections(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 0).try_into().ok() + pub fn invalid_phase_corrections(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 4, 0).try_into() } pub fn set_invalid_phase_corrections( @@ -6852,8 +6852,8 @@ pub mod packed_osr_content { set_bit_range!(&mut self.flags, invalid_phase_corrections, u8, u8, 4, 0); } - pub fn invalid_code_corrections(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 3, 0).try_into().ok() + pub fn invalid_code_corrections(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 3, 0).try_into() } pub fn set_invalid_code_corrections( @@ -6863,24 +6863,24 @@ pub mod packed_osr_content { set_bit_range!(&mut self.flags, invalid_code_corrections, u8, u8, 3, 0); } - pub fn full_fixing_flag(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn full_fixing_flag(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_full_fixing_flag(&mut self, full_fixing_flag: FullFixingFlag) { set_bit_range!(&mut self.flags, full_fixing_flag, u8, u8, 2, 0); } - pub fn partial_fixing_flag(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() + pub fn partial_fixing_flag(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 1, 0).try_into() } pub fn set_partial_fixing_flag(&mut self, partial_fixing_flag: PartialFixingFlag) { set_bit_range!(&mut self.flags, partial_fixing_flag, u8, u8, 1, 0); } - pub fn correction_validity(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 0, 0).try_into().ok() + pub fn correction_validity(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 0, 0).try_into() } pub fn set_correction_validity(&mut self, correction_validity: CorrectionValidity) { @@ -6955,12 +6955,12 @@ pub mod packed_osr_content { } impl TryFrom for InvalidPhaseCorrections { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(InvalidPhaseCorrections::ValidPhaseCorrections), 1 => Ok(InvalidPhaseCorrections::DoNotUsePhaseCorrections), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -6989,12 +6989,12 @@ pub mod packed_osr_content { } impl TryFrom for InvalidCodeCorrections { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(InvalidCodeCorrections::ValidCodeCorrections), 1 => Ok(InvalidCodeCorrections::DoNotUseCodeCorrections), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -7019,12 +7019,12 @@ pub mod packed_osr_content { } impl TryFrom for FullFixingFlag { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FullFixingFlag::FullFixingUnavailable), 1 => Ok(FullFixingFlag::FullFixingAvailable), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -7053,12 +7053,12 @@ pub mod packed_osr_content { } impl TryFrom for PartialFixingFlag { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(PartialFixingFlag::PartialFixingUnavailable), 1 => Ok(PartialFixingFlag::PartialFixingAvailable), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -7083,12 +7083,12 @@ pub mod packed_osr_content { } impl TryFrom for CorrectionValidity { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(CorrectionValidity::DoNotUseSignal), 1 => Ok(CorrectionValidity::ValidSignal), - _ => Err(TryFromIntError), + i => Err(i), } } } diff --git a/rust/sbp/src/messages/orientation.rs b/rust/sbp/src/messages/orientation.rs index c6be44ff21..9c640486b9 100644 --- a/rust/sbp/src/messages/orientation.rs +++ b/rust/sbp/src/messages/orientation.rs @@ -60,8 +60,8 @@ pub mod msg_angular_rate { } impl MsgAngularRate { - pub fn ins_navigation_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn ins_navigation_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { @@ -163,12 +163,12 @@ pub mod msg_angular_rate { } impl TryFrom for InsNavigationMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(InsNavigationMode::Invalid), 1 => Ok(InsNavigationMode::Valid), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -209,8 +209,8 @@ pub mod msg_baseline_heading { } impl MsgBaselineHeading { - pub fn fix_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn fix_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_fix_mode(&mut self, fix_mode: FixMode) { @@ -316,14 +316,14 @@ pub mod msg_baseline_heading { } impl TryFrom for FixMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FixMode::Invalid), 2 => Ok(FixMode::DifferentialGnss), 3 => Ok(FixMode::FloatRtk), 4 => Ok(FixMode::FixedRtk), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -377,8 +377,8 @@ pub mod msg_orient_euler { } impl MsgOrientEuler { - pub fn ins_navigation_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn ins_navigation_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { @@ -492,12 +492,12 @@ pub mod msg_orient_euler { } impl TryFrom for InsNavigationMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(InsNavigationMode::Invalid), 1 => Ok(InsNavigationMode::Valid), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -557,8 +557,8 @@ pub mod msg_orient_quat { } impl MsgOrientQuat { - pub fn ins_navigation_mode(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn ins_navigation_mode(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { @@ -680,12 +680,12 @@ pub mod msg_orient_quat { } impl TryFrom for InsNavigationMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(InsNavigationMode::Invalid), 1 => Ok(InsNavigationMode::Valid), - _ => Err(TryFromIntError), + i => Err(i), } } } diff --git a/rust/sbp/src/messages/piksi.rs b/rust/sbp/src/messages/piksi.rs index 1c5d7da8cd..f074f3ae3f 100644 --- a/rust/sbp/src/messages/piksi.rs +++ b/rust/sbp/src/messages/piksi.rs @@ -977,16 +977,16 @@ pub mod msg_mask_satellite { } impl MsgMaskSatellite { - pub fn tracking_channels(&self) -> Option { - get_bit_range!(self.mask, u8, u8, 1, 0).try_into().ok() + pub fn tracking_channels(&self) -> Result { + get_bit_range!(self.mask, u8, u8, 1, 0).try_into() } pub fn set_tracking_channels(&mut self, tracking_channels: TrackingChannels) { set_bit_range!(&mut self.mask, tracking_channels, u8, u8, 1, 0); } - pub fn acquisition_channel(&self) -> Option { - get_bit_range!(self.mask, u8, u8, 0, 0).try_into().ok() + pub fn acquisition_channel(&self) -> Result { + get_bit_range!(self.mask, u8, u8, 0, 0).try_into() } pub fn set_acquisition_channel(&mut self, acquisition_channel: AcquisitionChannel) { @@ -1067,12 +1067,12 @@ pub mod msg_mask_satellite { } impl TryFrom for TrackingChannels { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TrackingChannels::Enabled), 1 => Ok(TrackingChannels::DropThisPrnIfCurrentlyTracking), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1099,12 +1099,12 @@ pub mod msg_mask_satellite { } impl TryFrom for AcquisitionChannel { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(AcquisitionChannel::Enabled), 1 => Ok(AcquisitionChannel::SkipThisSatelliteOnFutureAcquisitions), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1136,16 +1136,16 @@ pub mod msg_mask_satellite_dep { } impl MsgMaskSatelliteDep { - pub fn tracking_channels(&self) -> Option { - get_bit_range!(self.mask, u8, u8, 1, 0).try_into().ok() + pub fn tracking_channels(&self) -> Result { + get_bit_range!(self.mask, u8, u8, 1, 0).try_into() } pub fn set_tracking_channels(&mut self, tracking_channels: TrackingChannels) { set_bit_range!(&mut self.mask, tracking_channels, u8, u8, 1, 0); } - pub fn acquisition_channel(&self) -> Option { - get_bit_range!(self.mask, u8, u8, 0, 0).try_into().ok() + pub fn acquisition_channel(&self) -> Result { + get_bit_range!(self.mask, u8, u8, 0, 0).try_into() } pub fn set_acquisition_channel(&mut self, acquisition_channel: AcquisitionChannel) { @@ -1226,12 +1226,12 @@ pub mod msg_mask_satellite_dep { } impl TryFrom for TrackingChannels { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TrackingChannels::Enabled), 1 => Ok(TrackingChannels::DropThisPrnIfCurrentlyTracking), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1258,12 +1258,12 @@ pub mod msg_mask_satellite_dep { } impl TryFrom for AcquisitionChannel { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(AcquisitionChannel::Enabled), 1 => Ok(AcquisitionChannel::SkipThisSatelliteOnFutureAcquisitions), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1822,8 +1822,8 @@ pub mod msg_reset { } impl MsgReset { - pub fn default_settings(&self) -> Option { - get_bit_range!(self.flags, u32, u8, 0, 0).try_into().ok() + pub fn default_settings(&self) -> Result { + get_bit_range!(self.flags, u32, u8, 0, 0).try_into() } pub fn set_default_settings(&mut self, default_settings: DefaultSettings) { @@ -1902,12 +1902,12 @@ pub mod msg_reset { } impl TryFrom for DefaultSettings { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(DefaultSettings::PreserveExistingSettings), 1 => Ok(DefaultSettings::ResoreDefaultSettings), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2001,8 +2001,8 @@ pub mod msg_reset_filters { } impl MsgResetFilters { - pub fn filter_or_process_to_reset(&self) -> Option { - get_bit_range!(self.filter, u8, u8, 1, 0).try_into().ok() + pub fn filter_or_process_to_reset(&self) -> Result { + get_bit_range!(self.filter, u8, u8, 1, 0).try_into() } pub fn set_filter_or_process_to_reset( @@ -2086,13 +2086,13 @@ pub mod msg_reset_filters { } impl TryFrom for FilterOrProcessToReset { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FilterOrProcessToReset::DgnssFilter), 1 => Ok(FilterOrProcessToReset::IarProcess), 2 => Ok(FilterOrProcessToReset::InertialFilter), - _ => Err(TryFromIntError), + i => Err(i), } } } diff --git a/rust/sbp/src/messages/settings.rs b/rust/sbp/src/messages/settings.rs index f62816101b..ea97e6b985 100644 --- a/rust/sbp/src/messages/settings.rs +++ b/rust/sbp/src/messages/settings.rs @@ -533,8 +533,8 @@ pub mod msg_settings_register_resp { } impl MsgSettingsRegisterResp { - pub fn register_status(&self) -> Option { - get_bit_range!(self.status, u8, u8, 1, 0).try_into().ok() + pub fn register_status(&self) -> Result { + get_bit_range!(self.status, u8, u8, 1, 0).try_into() } pub fn set_register_status(&mut self, register_status: RegisterStatus) { @@ -632,7 +632,7 @@ pub mod msg_settings_register_resp { } impl TryFrom for RegisterStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(RegisterStatus::AcceptedRequestedDefaultValueReturned), @@ -641,7 +641,7 @@ pub mod msg_settings_register_resp { ), 2 => Ok(RegisterStatus::RejectedSettingAlreadyRegisteredValueFromMemoryReturned), 3 => Ok(RegisterStatus::RejectedMalformedMessage), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -821,8 +821,8 @@ pub mod msg_settings_write_resp { } impl MsgSettingsWriteResp { - pub fn write_status(&self) -> Option { - get_bit_range!(self.status, u8, u8, 1, 0).try_into().ok() + pub fn write_status(&self) -> Result { + get_bit_range!(self.status, u8, u8, 1, 0).try_into() } pub fn set_write_status(&mut self, write_status: WriteStatus) { @@ -932,7 +932,7 @@ pub mod msg_settings_write_resp { } impl TryFrom for WriteStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(WriteStatus::AcceptedValueUpdated), @@ -942,7 +942,7 @@ pub mod msg_settings_write_resp { 4 => Ok(WriteStatus::RejectedSettingIsReadOnly), 5 => Ok(WriteStatus::RejectedModificationIsTemporarilyDisabled), 6 => Ok(WriteStatus::RejectedUnspecifiedError), - _ => Err(TryFromIntError), + i => Err(i), } } } diff --git a/rust/sbp/src/messages/solution_meta.rs b/rust/sbp/src/messages/solution_meta.rs index b52a8197a5..96085f99fe 100644 --- a/rust/sbp/src/messages/solution_meta.rs +++ b/rust/sbp/src/messages/solution_meta.rs @@ -41,8 +41,8 @@ pub mod gnss_input_type { } impl GnssInputType { - pub fn type_of_gnss_measurement(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() + pub fn type_of_gnss_measurement(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 1, 0).try_into() } pub fn set_type_of_gnss_measurement( @@ -94,13 +94,13 @@ pub mod gnss_input_type { } impl TryFrom for TypeOfGnssMeasurement { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TypeOfGnssMeasurement::GnssPosition), 1 => Ok(TypeOfGnssMeasurement::GnssVelocityDoppler), 2 => Ok(TypeOfGnssMeasurement::GnssVelocityDisplacement), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -127,24 +127,24 @@ pub mod imu_input_type { } impl ImuInputType { - pub fn time_status(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 5, 4).try_into().ok() + pub fn time_status(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 5, 4).try_into() } pub fn set_time_status(&mut self, time_status: TimeStatus) { set_bit_range!(&mut self.flags, time_status, u8, u8, 5, 4); } - pub fn imu_grade(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 3, 2).try_into().ok() + pub fn imu_grade(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 3, 2).try_into() } pub fn set_imu_grade(&mut self, imu_grade: ImuGrade) { set_bit_range!(&mut self.flags, imu_grade, u8, u8, 3, 2); } - pub fn imu_architecture(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() + pub fn imu_architecture(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 1, 0).try_into() } pub fn set_imu_architecture(&mut self, imu_architecture: ImuArchitecture) { @@ -199,14 +199,14 @@ pub mod imu_input_type { } impl TryFrom for TimeStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TimeStatus::ReferenceEpochIsStartOfCurrentGpsWeek), 1 => Ok(TimeStatus::ReferenceEpochIsTimeOfSystemStartup), 2 => Ok(TimeStatus::ReferenceEpochIsUnknown), 3 => Ok(TimeStatus::ReferenceEpochIsLastPps), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -239,14 +239,14 @@ pub mod imu_input_type { } impl TryFrom for ImuGrade { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(ImuGrade::ConsumerGrade), 1 => Ok(ImuGrade::TacticalGrade), 2 => Ok(ImuGrade::IntermediateGrade), 3 => Ok(ImuGrade::SuperiorGrade), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -271,12 +271,12 @@ pub mod imu_input_type { } impl TryFrom for ImuArchitecture { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(ImuArchitecture::_6AxisMems), 1 => Ok(ImuArchitecture::OtherType), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -338,10 +338,8 @@ pub mod msg_soln_meta { } impl MsgSolnMeta { - pub fn time_status(&self) -> Option { - get_bit_range!(self.age_gnss, u32, u8, 31, 30) - .try_into() - .ok() + pub fn time_status(&self) -> Result { + get_bit_range!(self.age_gnss, u32, u8, 31, 30).try_into() } pub fn set_time_status(&mut self, time_status: TimeStatus) { @@ -473,12 +471,12 @@ pub mod msg_soln_meta { } impl TryFrom for TimeStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TimeStatus::AgeCanNotBeUsedToRetrieveTom), 1 => Ok(TimeStatus::AgeCanBeUsedToRetrieveTom), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -542,10 +540,8 @@ pub mod msg_soln_meta_dep_a { } impl MsgSolnMetaDepA { - pub fn alignment_status(&self) -> Option { - get_bit_range!(self.alignment_status, u8, u8, 2, 0) - .try_into() - .ok() + pub fn alignment_status(&self) -> Result { + get_bit_range!(self.alignment_status, u8, u8, 2, 0).try_into() } pub fn set_alignment_status(&mut self, alignment_status: AlignmentStatus) { @@ -676,7 +672,7 @@ pub mod msg_soln_meta_dep_a { } impl TryFrom for AlignmentStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(AlignmentStatus::UnknownReasonOrAlreadyAligned), @@ -684,7 +680,7 @@ pub mod msg_soln_meta_dep_a { 2 => Ok(AlignmentStatus::NoSeedValuesAndAlignmentInProgress), 3 => Ok(AlignmentStatus::SeedValuesLoadedButNoGnssMeasurements), 4 => Ok(AlignmentStatus::NoSeedValuesNorGnssMeasurements), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -711,24 +707,24 @@ pub mod odo_input_type { } impl OdoInputType { - pub fn rate(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 5, 4).try_into().ok() + pub fn rate(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 5, 4).try_into() } pub fn set_rate(&mut self, rate: Rate) { set_bit_range!(&mut self.flags, rate, u8, u8, 5, 4); } - pub fn odometer_grade(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 3, 2).try_into().ok() + pub fn odometer_grade(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 3, 2).try_into() } pub fn set_odometer_grade(&mut self, odometer_grade: OdometerGrade) { set_bit_range!(&mut self.flags, odometer_grade, u8, u8, 3, 2); } - pub fn odometer_class(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() + pub fn odometer_class(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 1, 0).try_into() } pub fn set_odometer_class(&mut self, odometer_class: OdometerClass) { @@ -773,12 +769,12 @@ pub mod odo_input_type { } impl TryFrom for Rate { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(Rate::FixedIncomingRate), 1 => Ok(Rate::TriggeredByMinimumDistanceOrSpeed), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -807,13 +803,13 @@ pub mod odo_input_type { } impl TryFrom for OdometerGrade { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(OdometerGrade::LowGrade), 1 => Ok(OdometerGrade::MediumGrade), 2 => Ok(OdometerGrade::SuperiorGrade), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -846,14 +842,14 @@ pub mod odo_input_type { } impl TryFrom for OdometerClass { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(OdometerClass::SingleOrAveragedTicks), 1 => Ok(OdometerClass::SingleOrAveragedSpeed), 2 => Ok(OdometerClass::MultiDimensionalTicks), 3 => Ok(OdometerClass::MultiDimensionalSpeed), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -887,20 +883,16 @@ pub mod solution_input_type { } impl SolutionInputType { - pub fn sensor_usage(&self) -> Option { - get_bit_range!(self.sensor_type, u8, u8, 4, 3) - .try_into() - .ok() + pub fn sensor_usage(&self) -> Result { + get_bit_range!(self.sensor_type, u8, u8, 4, 3).try_into() } pub fn set_sensor_usage(&mut self, sensor_usage: SensorUsage) { set_bit_range!(&mut self.sensor_type, sensor_usage, u8, u8, 4, 3); } - pub fn sensor_type(&self) -> Option { - get_bit_range!(self.sensor_type, u8, u8, 2, 0) - .try_into() - .ok() + pub fn sensor_type(&self) -> Result { + get_bit_range!(self.sensor_type, u8, u8, 2, 0).try_into() } pub fn set_sensor_type(&mut self, sensor_type: SensorType) { @@ -949,13 +941,13 @@ pub mod solution_input_type { } impl TryFrom for SensorUsage { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(SensorUsage::Unknown), 1 => Ok(SensorUsage::ReceivedAndUsed), 2 => Ok(SensorUsage::ReceivedButNotUsed), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1004,7 +996,7 @@ pub mod solution_input_type { } impl TryFrom for SensorType { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(SensorType::Invalid), @@ -1014,7 +1006,7 @@ pub mod solution_input_type { 4 => Ok(SensorType::OdometryTicks), 5 => Ok(SensorType::OdometrySpeed), 6 => Ok(SensorType::ImuSensor), - _ => Err(TryFromIntError), + i => Err(i), } } } diff --git a/rust/sbp/src/messages/ssr.rs b/rust/sbp/src/messages/ssr.rs index 3c3ed2ccdb..bbb7ca0ecb 100644 --- a/rust/sbp/src/messages/ssr.rs +++ b/rust/sbp/src/messages/ssr.rs @@ -2023,8 +2023,8 @@ pub mod satellite_apc { } impl SatelliteAPC { - pub fn satellite_type(&self) -> Option { - get_bit_range!(self.sat_info, u8, u8, 4, 0).try_into().ok() + pub fn satellite_type(&self) -> Result { + get_bit_range!(self.sat_info, u8, u8, 4, 0).try_into() } pub fn set_satellite_type(&mut self, satellite_type: SatelliteType) { @@ -2155,7 +2155,7 @@ pub mod satellite_apc { } impl TryFrom for SatelliteType { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(SatelliteType::UnknownType), @@ -2178,7 +2178,7 @@ pub mod satellite_apc { 17 => Ok(SatelliteType::Beidou3GCast), 18 => Ok(SatelliteType::Beidou3ICast), 19 => Ok(SatelliteType::QZSS), - _ => Err(TryFromIntError), + i => Err(i), } } } diff --git a/rust/sbp/src/messages/system.rs b/rust/sbp/src/messages/system.rs index f8d1239608..ce0cf3e461 100644 --- a/rust/sbp/src/messages/system.rs +++ b/rust/sbp/src/messages/system.rs @@ -219,8 +219,8 @@ pub mod msg_dgnss_status { } impl MsgDgnssStatus { - pub fn differential_type(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 3, 0).try_into().ok() + pub fn differential_type(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 3, 0).try_into() } pub fn set_differential_type(&mut self, differential_type: DifferentialType) { @@ -313,13 +313,13 @@ pub mod msg_dgnss_status { } impl TryFrom for DifferentialType { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(DifferentialType::Invalid), 1 => Ok(DifferentialType::CodeDifference), 2 => Ok(DifferentialType::RTK), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -453,8 +453,8 @@ pub mod msg_group_meta { } impl MsgGroupMeta { - pub fn solution_group_type(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() + pub fn solution_group_type(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 1, 0).try_into() } pub fn set_solution_group_type(&mut self, solution_group_type: SolutionGroupType) { @@ -547,13 +547,13 @@ pub mod msg_group_meta { } impl TryFrom for SolutionGroupType { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(SolutionGroupType::None), 1 => Ok(SolutionGroupType::GnssOnly), 2 => Ok(SolutionGroupType::GnssINS), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -589,8 +589,8 @@ pub mod msg_heartbeat { } impl MsgHeartbeat { - pub fn external_antenna_present(&self) -> Option { - get_bit_range!(self.flags, u32, u8, 31, 0).try_into().ok() + pub fn external_antenna_present(&self) -> Result { + get_bit_range!(self.flags, u32, u8, 31, 0).try_into() } pub fn set_external_antenna_present( @@ -600,8 +600,8 @@ pub mod msg_heartbeat { set_bit_range!(&mut self.flags, external_antenna_present, u32, u8, 31, 0); } - pub fn external_antenna_short(&self) -> Option { - get_bit_range!(self.flags, u32, u8, 30, 0).try_into().ok() + pub fn external_antenna_short(&self) -> Result { + get_bit_range!(self.flags, u32, u8, 30, 0).try_into() } pub fn set_external_antenna_short(&mut self, external_antenna_short: ExternalAntennaShort) { @@ -644,24 +644,24 @@ pub mod msg_heartbeat { ); } - pub fn swift_nap_error(&self) -> Option { - get_bit_range!(self.flags, u32, u8, 2, 0).try_into().ok() + pub fn swift_nap_error(&self) -> Result { + get_bit_range!(self.flags, u32, u8, 2, 0).try_into() } pub fn set_swift_nap_error(&mut self, swift_nap_error: SwiftNapError) { set_bit_range!(&mut self.flags, swift_nap_error, u32, u8, 2, 0); } - pub fn io_error(&self) -> Option { - get_bit_range!(self.flags, u32, u8, 1, 0).try_into().ok() + pub fn io_error(&self) -> Result { + get_bit_range!(self.flags, u32, u8, 1, 0).try_into() } pub fn set_io_error(&mut self, io_error: IoError) { set_bit_range!(&mut self.flags, io_error, u32, u8, 1, 0); } - pub fn system_error_flag(&self) -> Option { - get_bit_range!(self.flags, u32, u8, 0, 0).try_into().ok() + pub fn system_error_flag(&self) -> Result { + get_bit_range!(self.flags, u32, u8, 0, 0).try_into() } pub fn set_system_error_flag(&mut self, system_error_flag: SystemErrorFlag) { @@ -742,12 +742,12 @@ pub mod msg_heartbeat { } impl TryFrom for ExternalAntennaPresent { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(ExternalAntennaPresent::NoExternalAntennaDetected), 1 => Ok(ExternalAntennaPresent::ExternalAntennaIsPresent), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -772,12 +772,12 @@ pub mod msg_heartbeat { } impl TryFrom for ExternalAntennaShort { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(ExternalAntennaShort::NoShortDetected), 1 => Ok(ExternalAntennaShort::ShortDetected), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -804,12 +804,12 @@ pub mod msg_heartbeat { } impl TryFrom for SwiftNapError { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(SwiftNapError::SystemHealthy), 1 => Ok(SwiftNapError::AnErrorHasOccurredInTheSwiftNap), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -834,12 +834,12 @@ pub mod msg_heartbeat { } impl TryFrom for IoError { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(IoError::SystemHealthy), 1 => Ok(IoError::AnIoErrorHasOccurred), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -864,12 +864,12 @@ pub mod msg_heartbeat { } impl TryFrom for SystemErrorFlag { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(SystemErrorFlag::SystemHealthy), 1 => Ok(SystemErrorFlag::AnErrorHasOccurred), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -898,56 +898,56 @@ pub mod msg_ins_status { } impl MsgInsStatus { - pub fn ins_type(&self) -> Option { - get_bit_range!(self.flags, u32, u8, 31, 29).try_into().ok() + pub fn ins_type(&self) -> Result { + get_bit_range!(self.flags, u32, u8, 31, 29).try_into() } pub fn set_ins_type(&mut self, ins_type: InsType) { set_bit_range!(&mut self.flags, ins_type, u32, u8, 31, 29); } - pub fn motion_state(&self) -> Option { - get_bit_range!(self.flags, u32, u8, 13, 11).try_into().ok() + pub fn motion_state(&self) -> Result { + get_bit_range!(self.flags, u32, u8, 13, 11).try_into() } pub fn set_motion_state(&mut self, motion_state: MotionState) { set_bit_range!(&mut self.flags, motion_state, u32, u8, 13, 11); } - pub fn odometry_synch(&self) -> Option { - get_bit_range!(self.flags, u32, u8, 10, 0).try_into().ok() + pub fn odometry_synch(&self) -> Result { + get_bit_range!(self.flags, u32, u8, 10, 0).try_into() } pub fn set_odometry_synch(&mut self, odometry_synch: OdometrySynch) { set_bit_range!(&mut self.flags, odometry_synch, u32, u8, 10, 0); } - pub fn odometry_status(&self) -> Option { - get_bit_range!(self.flags, u32, u8, 9, 8).try_into().ok() + pub fn odometry_status(&self) -> Result { + get_bit_range!(self.flags, u32, u8, 9, 8).try_into() } pub fn set_odometry_status(&mut self, odometry_status: OdometryStatus) { set_bit_range!(&mut self.flags, odometry_status, u32, u8, 9, 8); } - pub fn ins_error(&self) -> Option { - get_bit_range!(self.flags, u32, u8, 7, 4).try_into().ok() + pub fn ins_error(&self) -> Result { + get_bit_range!(self.flags, u32, u8, 7, 4).try_into() } pub fn set_ins_error(&mut self, ins_error: InsError) { set_bit_range!(&mut self.flags, ins_error, u32, u8, 7, 4); } - pub fn gnss_fix(&self) -> Option { - get_bit_range!(self.flags, u32, u8, 3, 0).try_into().ok() + pub fn gnss_fix(&self) -> Result { + get_bit_range!(self.flags, u32, u8, 3, 0).try_into() } pub fn set_gnss_fix(&mut self, gnss_fix: GnssFix) { set_bit_range!(&mut self.flags, gnss_fix, u32, u8, 3, 0); } - pub fn mode(&self) -> Option { - get_bit_range!(self.flags, u32, u8, 2, 0).try_into().ok() + pub fn mode(&self) -> Result { + get_bit_range!(self.flags, u32, u8, 2, 0).try_into() } pub fn set_mode(&mut self, mode: Mode) { @@ -1024,12 +1024,12 @@ pub mod msg_ins_status { } impl TryFrom for InsType { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(InsType::SmoothposeLooselyCoupled), 1 => Ok(InsType::Starling), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1062,14 +1062,14 @@ pub mod msg_ins_status { } impl TryFrom for MotionState { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(MotionState::UnknownOrInit), 1 => Ok(MotionState::ArbitraryMotion), 2 => Ok(MotionState::StraightMotion), 3 => Ok(MotionState::Stationary), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1098,12 +1098,12 @@ pub mod msg_ins_status { } impl TryFrom for OdometrySynch { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(OdometrySynch::OdometryTimestampNominal), 1 => Ok(OdometrySynch::OdometryTimestampOutOfBounds), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1136,13 +1136,13 @@ pub mod msg_ins_status { } impl TryFrom for OdometryStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(OdometryStatus::NoOdometry), 1 => Ok(OdometryStatus::OdometryReceivedWithinLastSecond), 2 => Ok(OdometryStatus::OdometryNotReceivedWithinLastSecond), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1171,13 +1171,13 @@ pub mod msg_ins_status { } impl TryFrom for InsError { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 1 => Ok(InsError::ImuDataError), 2 => Ok(InsError::InsLicenseError), 3 => Ok(InsError::ImuCalibrationDataError), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1202,12 +1202,12 @@ pub mod msg_ins_status { } impl TryFrom for GnssFix { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(GnssFix::NoGnssFixAvailable), 1 => Ok(GnssFix::GnssFix), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1256,7 +1256,7 @@ pub mod msg_ins_status { } impl TryFrom for Mode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(Mode::AwaitingInitialization), @@ -1266,7 +1266,7 @@ pub mod msg_ins_status { 4 => Ok(Mode::FastStartSeeding), 5 => Ok(Mode::FastStartValidating), 6 => Ok(Mode::ValidatingUnsafeFastStartSeed), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1658,8 +1658,8 @@ pub mod msg_pps_time { set_bit_range!(&mut self.flags, reserved_set_to_zero, u8, u8, 7, 2); } - pub fn time_uncertainty(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() + pub fn time_uncertainty(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 1, 0).try_into() } pub fn set_time_uncertainty(&mut self, time_uncertainty: TimeUncertainty) { @@ -1834,14 +1834,14 @@ impl WireFormat for MsgSensorAidEvent { } impl TryFrom for TimeUncertainty { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TimeUncertainty::Unknown), 1 => Ok(TimeUncertainty::_10Milliseconds), 2 => Ok(TimeUncertainty::_10Microseconds), 3 => Ok(TimeUncertainty::_1Microseconds), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1877,18 +1877,16 @@ pub mod msg_startup { } impl MsgStartup { - pub fn cause_of_startup(&self) -> Option { - get_bit_range!(self.cause, u8, u8, 8, 0).try_into().ok() + pub fn cause_of_startup(&self) -> Result { + get_bit_range!(self.cause, u8, u8, 8, 0).try_into() } pub fn set_cause_of_startup(&mut self, cause_of_startup: CauseOfStartup) { set_bit_range!(&mut self.cause, cause_of_startup, u8, u8, 8, 0); } - pub fn startup_type(&self) -> Option { - get_bit_range!(self.startup_type, u8, u8, 8, 0) - .try_into() - .ok() + pub fn startup_type(&self) -> Result { + get_bit_range!(self.startup_type, u8, u8, 8, 0).try_into() } pub fn set_startup_type(&mut self, startup_type: StartupType) { @@ -1977,13 +1975,13 @@ pub mod msg_startup { } impl TryFrom for CauseOfStartup { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(CauseOfStartup::PowerOn), 1 => Ok(CauseOfStartup::SoftwareReset), 2 => Ok(CauseOfStartup::WatchdogReset), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2011,13 +2009,13 @@ pub mod msg_startup { } impl TryFrom for StartupType { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(StartupType::ColdStart), 1 => Ok(StartupType::WarmStart), 2 => Ok(StartupType::HotStart), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2064,10 +2062,8 @@ pub mod msg_status_report { } impl MsgStatusReport { - pub fn system(&self) -> Option { - get_bit_range!(self.reporting_system, u16, u16, 15, 0) - .try_into() - .ok() + pub fn system(&self) -> Result { + get_bit_range!(self.reporting_system, u16, u16, 15, 0).try_into() } pub fn set_system(&mut self, system: System) { @@ -2196,12 +2192,12 @@ pub mod msg_status_report { } impl TryFrom for System { - type Error = TryFromIntError; + type Error = u16; fn try_from(i: u16) -> Result { match i { 0 => Ok(System::Starling), 1 => Ok(System::PrecisionGnssModule), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2233,18 +2229,16 @@ pub mod sub_system_report { } impl SubSystemReport { - pub fn subsystem(&self) -> Option { - get_bit_range!(self.component, u16, u16, 15, 0) - .try_into() - .ok() + pub fn subsystem(&self) -> Result { + get_bit_range!(self.component, u16, u16, 15, 0).try_into() } pub fn set_subsystem(&mut self, subsystem: Subsystem) { set_bit_range!(&mut self.component, subsystem, u16, u16, 15, 0); } - pub fn generic(&self) -> Option { - get_bit_range!(self.generic, u8, u8, 7, 0).try_into().ok() + pub fn generic(&self) -> Result { + get_bit_range!(self.generic, u8, u8, 7, 0).try_into() } pub fn set_generic(&mut self, generic: Generic) { @@ -2315,7 +2309,7 @@ pub mod sub_system_report { } impl TryFrom for Subsystem { - type Error = TryFromIntError; + type Error = u16; fn try_from(i: u16) -> Result { match i { 0 => Ok(Subsystem::PrimaryGnssAntenna), @@ -2325,7 +2319,7 @@ pub mod sub_system_report { 4 => Ok(Subsystem::CAN), 5 => Ok(Subsystem::WheelOdometry), 6 => Ok(Subsystem::SensorFusionEngine), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2362,7 +2356,7 @@ pub mod sub_system_report { } impl TryFrom for Generic { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(Generic::OKNominal), @@ -2370,7 +2364,7 @@ pub mod sub_system_report { 2 => Ok(Generic::Unknown), 3 => Ok(Generic::Degraded), 4 => Ok(Generic::Unusable), - _ => Err(TryFromIntError), + i => Err(i), } } } diff --git a/rust/sbp/src/messages/tracking.rs b/rust/sbp/src/messages/tracking.rs index f6bb10f8f0..9649e8395a 100644 --- a/rust/sbp/src/messages/tracking.rs +++ b/rust/sbp/src/messages/tracking.rs @@ -670,10 +670,8 @@ pub mod msg_tracking_state_detailed_dep { } impl MsgTrackingStateDetailedDep { - pub fn synchronization_status(&self) -> Option { - get_bit_range!(self.sync_flags, u8, u8, 2, 0) - .try_into() - .ok() + pub fn synchronization_status(&self) -> Result { + get_bit_range!(self.sync_flags, u8, u8, 2, 0).try_into() } pub fn set_synchronization_status( @@ -683,8 +681,8 @@ pub mod msg_tracking_state_detailed_dep { set_bit_range!(&mut self.sync_flags, synchronization_status, u8, u8, 2, 0); } - pub fn week_number_validity_status(&self) -> Option { - get_bit_range!(self.tow_flags, u8, u8, 3, 0).try_into().ok() + pub fn week_number_validity_status(&self) -> Result { + get_bit_range!(self.tow_flags, u8, u8, 3, 0).try_into() } pub fn set_week_number_validity_status( @@ -701,46 +699,40 @@ pub mod msg_tracking_state_detailed_dep { ); } - pub fn tow_status(&self) -> Option { - get_bit_range!(self.tow_flags, u8, u8, 2, 0).try_into().ok() + pub fn tow_status(&self) -> Result { + get_bit_range!(self.tow_flags, u8, u8, 2, 0).try_into() } pub fn set_tow_status(&mut self, tow_status: TowStatus) { set_bit_range!(&mut self.tow_flags, tow_status, u8, u8, 2, 0); } - pub fn fll_status(&self) -> Option { - get_bit_range!(self.track_flags, u8, u8, 4, 0) - .try_into() - .ok() + pub fn fll_status(&self) -> Result { + get_bit_range!(self.track_flags, u8, u8, 4, 0).try_into() } pub fn set_fll_status(&mut self, fll_status: FllStatus) { set_bit_range!(&mut self.track_flags, fll_status, u8, u8, 4, 0); } - pub fn pll_status(&self) -> Option { - get_bit_range!(self.track_flags, u8, u8, 3, 0) - .try_into() - .ok() + pub fn pll_status(&self) -> Result { + get_bit_range!(self.track_flags, u8, u8, 3, 0).try_into() } pub fn set_pll_status(&mut self, pll_status: PllStatus) { set_bit_range!(&mut self.track_flags, pll_status, u8, u8, 3, 0); } - pub fn tracking_loop_status(&self) -> Option { - get_bit_range!(self.track_flags, u8, u8, 2, 0) - .try_into() - .ok() + pub fn tracking_loop_status(&self) -> Result { + get_bit_range!(self.track_flags, u8, u8, 2, 0).try_into() } pub fn set_tracking_loop_status(&mut self, tracking_loop_status: TrackingLoopStatus) { set_bit_range!(&mut self.track_flags, tracking_loop_status, u8, u8, 2, 0); } - pub fn almanac_availability_status(&self) -> Option { - get_bit_range!(self.nav_flags, u8, u8, 4, 0).try_into().ok() + pub fn almanac_availability_status(&self) -> Result { + get_bit_range!(self.nav_flags, u8, u8, 4, 0).try_into() } pub fn set_almanac_availability_status( @@ -757,8 +749,8 @@ pub mod msg_tracking_state_detailed_dep { ); } - pub fn ephemeris_availability_status(&self) -> Option { - get_bit_range!(self.nav_flags, u8, u8, 3, 0).try_into().ok() + pub fn ephemeris_availability_status(&self) -> Result { + get_bit_range!(self.nav_flags, u8, u8, 3, 0).try_into() } pub fn set_ephemeris_availability_status( @@ -775,38 +767,32 @@ pub mod msg_tracking_state_detailed_dep { ); } - pub fn health_status(&self) -> Option { - get_bit_range!(self.nav_flags, u8, u8, 2, 0).try_into().ok() + pub fn health_status(&self) -> Result { + get_bit_range!(self.nav_flags, u8, u8, 2, 0).try_into() } pub fn set_health_status(&mut self, health_status: HealthStatus) { set_bit_range!(&mut self.nav_flags, health_status, u8, u8, 2, 0); } - pub fn parameter_sets(&self) -> Option { - get_bit_range!(self.pset_flags, u8, u8, 2, 0) - .try_into() - .ok() + pub fn parameter_sets(&self) -> Result { + get_bit_range!(self.pset_flags, u8, u8, 2, 0).try_into() } pub fn set_parameter_sets(&mut self, parameter_sets: ParameterSets) { set_bit_range!(&mut self.pset_flags, parameter_sets, u8, u8, 2, 0); } - pub fn clock_validity_status(&self) -> Option { - get_bit_range!(self.misc_flags, u8, u8, 5, 0) - .try_into() - .ok() + pub fn clock_validity_status(&self) -> Result { + get_bit_range!(self.misc_flags, u8, u8, 5, 0).try_into() } pub fn set_clock_validity_status(&mut self, clock_validity_status: ClockValidityStatus) { set_bit_range!(&mut self.misc_flags, clock_validity_status, u8, u8, 5, 0); } - pub fn pseudorange_validity_status(&self) -> Option { - get_bit_range!(self.misc_flags, u8, u8, 4, 0) - .try_into() - .ok() + pub fn pseudorange_validity_status(&self) -> Result { + get_bit_range!(self.misc_flags, u8, u8, 4, 0).try_into() } pub fn set_pseudorange_validity_status( @@ -823,10 +809,8 @@ pub mod msg_tracking_state_detailed_dep { ); } - pub fn acceleration_validity_status(&self) -> Option { - get_bit_range!(self.misc_flags, u8, u8, 3, 0) - .try_into() - .ok() + pub fn acceleration_validity_status(&self) -> Result { + get_bit_range!(self.misc_flags, u8, u8, 3, 0).try_into() } pub fn set_acceleration_validity_status( @@ -845,10 +829,8 @@ pub mod msg_tracking_state_detailed_dep { pub fn carrier_half_cycle_ambiguity_status( &self, - ) -> Option { - get_bit_range!(self.misc_flags, u8, u8, 2, 0) - .try_into() - .ok() + ) -> Result { + get_bit_range!(self.misc_flags, u8, u8, 2, 0).try_into() } pub fn set_carrier_half_cycle_ambiguity_status( @@ -865,10 +847,8 @@ pub mod msg_tracking_state_detailed_dep { ); } - pub fn tracking_channel_status(&self) -> Option { - get_bit_range!(self.misc_flags, u8, u8, 1, 0) - .try_into() - .ok() + pub fn tracking_channel_status(&self) -> Result { + get_bit_range!(self.misc_flags, u8, u8, 1, 0).try_into() } pub fn set_tracking_channel_status( @@ -1042,14 +1022,14 @@ pub mod msg_tracking_state_detailed_dep { } impl TryFrom for SynchronizationStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(SynchronizationStatus::NoSynchronization), 1 => Ok(SynchronizationStatus::BitSynchronization), 2 => Ok(SynchronizationStatus::WordSynchronization), 3 => Ok(SynchronizationStatus::SubFrameSynchronizationMessageSynchronization), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1076,12 +1056,12 @@ pub mod msg_tracking_state_detailed_dep { } impl TryFrom for WeekNumberValidityStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(WeekNumberValidityStatus::WeekNumberIsNotValid), 1 => Ok(WeekNumberValidityStatus::WeekNumberIsValid), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1110,13 +1090,13 @@ pub mod msg_tracking_state_detailed_dep { } impl TryFrom for TowStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TowStatus::TowIsNotAvailable), 1 => Ok(TowStatus::DecodedTowIsAvailable), 2 => Ok(TowStatus::PropagatedTowIsAvailable), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1141,12 +1121,12 @@ pub mod msg_tracking_state_detailed_dep { } impl TryFrom for FllStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FllStatus::FllIsInactive), 1 => Ok(FllStatus::FllIsActive), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1171,12 +1151,12 @@ pub mod msg_tracking_state_detailed_dep { } impl TryFrom for PllStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(PllStatus::PllIsInactive), 1 => Ok(PllStatus::PllIsActive), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1209,14 +1189,14 @@ pub mod msg_tracking_state_detailed_dep { } impl TryFrom for TrackingLoopStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TrackingLoopStatus::NoLocks), 1 => Ok(TrackingLoopStatus::FlldllLock), 2 => Ok(TrackingLoopStatus::PllOptimisticLock), 3 => Ok(TrackingLoopStatus::PllPessimisticLock), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1245,12 +1225,12 @@ pub mod msg_tracking_state_detailed_dep { } impl TryFrom for AlmanacAvailabilityStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(AlmanacAvailabilityStatus::AlmanacIsNotAvailable), 1 => Ok(AlmanacAvailabilityStatus::AlmanacIsAvailable), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1279,12 +1259,12 @@ pub mod msg_tracking_state_detailed_dep { } impl TryFrom for EphemerisAvailabilityStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(EphemerisAvailabilityStatus::EphemerisIsNotAvailable), 1 => Ok(EphemerisAvailabilityStatus::EphemerisIsAvailable), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1313,13 +1293,13 @@ pub mod msg_tracking_state_detailed_dep { } impl TryFrom for HealthStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(HealthStatus::HealthIsUnknown), 1 => Ok(HealthStatus::SignalIsUnhealthy), 2 => Ok(HealthStatus::SignalIsHealthy), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1352,14 +1332,14 @@ pub mod msg_tracking_state_detailed_dep { } impl TryFrom for ParameterSets { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(ParameterSets::_1MsIntegrationTime), 1 => Ok(ParameterSets::_5MsIntegrationTime), 2 => Ok(ParameterSets::_10MsIntegrationTime), 3 => Ok(ParameterSets::_20MsIntegrationTime), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1388,12 +1368,12 @@ pub mod msg_tracking_state_detailed_dep { } impl TryFrom for ClockValidityStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(ClockValidityStatus::ClockOffsetAndDriftIsNotValid), 1 => Ok(ClockValidityStatus::ClockOffsetAndDriftIsValid), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1422,12 +1402,12 @@ pub mod msg_tracking_state_detailed_dep { } impl TryFrom for PseudorangeValidityStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(PseudorangeValidityStatus::PseudorangeIsNotValid), 1 => Ok(PseudorangeValidityStatus::PseudorangeIsValid), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1456,12 +1436,12 @@ pub mod msg_tracking_state_detailed_dep { } impl TryFrom for AccelerationValidityStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(AccelerationValidityStatus::AccelerationIsNotValid), 1 => Ok(AccelerationValidityStatus::AccelerationIsValid), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1486,12 +1466,12 @@ pub mod msg_tracking_state_detailed_dep { } impl TryFrom for CarrierHalfCycleAmbiguityStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(CarrierHalfCycleAmbiguityStatus::Unresolved), 1 => Ok(CarrierHalfCycleAmbiguityStatus::Resolved), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1516,12 +1496,12 @@ pub mod msg_tracking_state_detailed_dep { } impl TryFrom for TrackingChannelStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TrackingChannelStatus::ReAcquisition), 1 => Ok(TrackingChannelStatus::Running), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -1617,10 +1597,8 @@ pub mod msg_tracking_state_detailed_dep_a { } impl MsgTrackingStateDetailedDepA { - pub fn synchronization_status(&self) -> Option { - get_bit_range!(self.sync_flags, u8, u8, 2, 0) - .try_into() - .ok() + pub fn synchronization_status(&self) -> Result { + get_bit_range!(self.sync_flags, u8, u8, 2, 0).try_into() } pub fn set_synchronization_status( @@ -1630,8 +1608,8 @@ pub mod msg_tracking_state_detailed_dep_a { set_bit_range!(&mut self.sync_flags, synchronization_status, u8, u8, 2, 0); } - pub fn week_number_validity_status(&self) -> Option { - get_bit_range!(self.tow_flags, u8, u8, 3, 0).try_into().ok() + pub fn week_number_validity_status(&self) -> Result { + get_bit_range!(self.tow_flags, u8, u8, 3, 0).try_into() } pub fn set_week_number_validity_status( @@ -1648,46 +1626,40 @@ pub mod msg_tracking_state_detailed_dep_a { ); } - pub fn tow_status(&self) -> Option { - get_bit_range!(self.tow_flags, u8, u8, 2, 0).try_into().ok() + pub fn tow_status(&self) -> Result { + get_bit_range!(self.tow_flags, u8, u8, 2, 0).try_into() } pub fn set_tow_status(&mut self, tow_status: TowStatus) { set_bit_range!(&mut self.tow_flags, tow_status, u8, u8, 2, 0); } - pub fn fll_status(&self) -> Option { - get_bit_range!(self.track_flags, u8, u8, 4, 0) - .try_into() - .ok() + pub fn fll_status(&self) -> Result { + get_bit_range!(self.track_flags, u8, u8, 4, 0).try_into() } pub fn set_fll_status(&mut self, fll_status: FllStatus) { set_bit_range!(&mut self.track_flags, fll_status, u8, u8, 4, 0); } - pub fn pll_status(&self) -> Option { - get_bit_range!(self.track_flags, u8, u8, 3, 0) - .try_into() - .ok() + pub fn pll_status(&self) -> Result { + get_bit_range!(self.track_flags, u8, u8, 3, 0).try_into() } pub fn set_pll_status(&mut self, pll_status: PllStatus) { set_bit_range!(&mut self.track_flags, pll_status, u8, u8, 3, 0); } - pub fn tracking_loop_status(&self) -> Option { - get_bit_range!(self.track_flags, u8, u8, 2, 0) - .try_into() - .ok() + pub fn tracking_loop_status(&self) -> Result { + get_bit_range!(self.track_flags, u8, u8, 2, 0).try_into() } pub fn set_tracking_loop_status(&mut self, tracking_loop_status: TrackingLoopStatus) { set_bit_range!(&mut self.track_flags, tracking_loop_status, u8, u8, 2, 0); } - pub fn almanac_availability_status(&self) -> Option { - get_bit_range!(self.nav_flags, u8, u8, 4, 0).try_into().ok() + pub fn almanac_availability_status(&self) -> Result { + get_bit_range!(self.nav_flags, u8, u8, 4, 0).try_into() } pub fn set_almanac_availability_status( @@ -1704,8 +1676,8 @@ pub mod msg_tracking_state_detailed_dep_a { ); } - pub fn ephemeris_availability_status(&self) -> Option { - get_bit_range!(self.nav_flags, u8, u8, 3, 0).try_into().ok() + pub fn ephemeris_availability_status(&self) -> Result { + get_bit_range!(self.nav_flags, u8, u8, 3, 0).try_into() } pub fn set_ephemeris_availability_status( @@ -1722,38 +1694,32 @@ pub mod msg_tracking_state_detailed_dep_a { ); } - pub fn health_status(&self) -> Option { - get_bit_range!(self.nav_flags, u8, u8, 2, 0).try_into().ok() + pub fn health_status(&self) -> Result { + get_bit_range!(self.nav_flags, u8, u8, 2, 0).try_into() } pub fn set_health_status(&mut self, health_status: HealthStatus) { set_bit_range!(&mut self.nav_flags, health_status, u8, u8, 2, 0); } - pub fn parameter_sets(&self) -> Option { - get_bit_range!(self.pset_flags, u8, u8, 2, 0) - .try_into() - .ok() + pub fn parameter_sets(&self) -> Result { + get_bit_range!(self.pset_flags, u8, u8, 2, 0).try_into() } pub fn set_parameter_sets(&mut self, parameter_sets: ParameterSets) { set_bit_range!(&mut self.pset_flags, parameter_sets, u8, u8, 2, 0); } - pub fn clock_validity_status(&self) -> Option { - get_bit_range!(self.misc_flags, u8, u8, 5, 0) - .try_into() - .ok() + pub fn clock_validity_status(&self) -> Result { + get_bit_range!(self.misc_flags, u8, u8, 5, 0).try_into() } pub fn set_clock_validity_status(&mut self, clock_validity_status: ClockValidityStatus) { set_bit_range!(&mut self.misc_flags, clock_validity_status, u8, u8, 5, 0); } - pub fn pseudorange_validity_status(&self) -> Option { - get_bit_range!(self.misc_flags, u8, u8, 4, 0) - .try_into() - .ok() + pub fn pseudorange_validity_status(&self) -> Result { + get_bit_range!(self.misc_flags, u8, u8, 4, 0).try_into() } pub fn set_pseudorange_validity_status( @@ -1770,10 +1736,8 @@ pub mod msg_tracking_state_detailed_dep_a { ); } - pub fn acceleration_validity_status(&self) -> Option { - get_bit_range!(self.misc_flags, u8, u8, 3, 0) - .try_into() - .ok() + pub fn acceleration_validity_status(&self) -> Result { + get_bit_range!(self.misc_flags, u8, u8, 3, 0).try_into() } pub fn set_acceleration_validity_status( @@ -1792,10 +1756,8 @@ pub mod msg_tracking_state_detailed_dep_a { pub fn carrier_half_cycle_ambiguity_status( &self, - ) -> Option { - get_bit_range!(self.misc_flags, u8, u8, 2, 0) - .try_into() - .ok() + ) -> Result { + get_bit_range!(self.misc_flags, u8, u8, 2, 0).try_into() } pub fn set_carrier_half_cycle_ambiguity_status( @@ -1812,10 +1774,8 @@ pub mod msg_tracking_state_detailed_dep_a { ); } - pub fn tracking_channel_status(&self) -> Option { - get_bit_range!(self.misc_flags, u8, u8, 1, 0) - .try_into() - .ok() + pub fn tracking_channel_status(&self) -> Result { + get_bit_range!(self.misc_flags, u8, u8, 1, 0).try_into() } pub fn set_tracking_channel_status( @@ -1989,14 +1949,14 @@ pub mod msg_tracking_state_detailed_dep_a { } impl TryFrom for SynchronizationStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(SynchronizationStatus::NoSynchronization), 1 => Ok(SynchronizationStatus::BitSynchronization), 2 => Ok(SynchronizationStatus::WordSynchronization), 3 => Ok(SynchronizationStatus::SubFrameSynchronizationMessageSynchronization), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2023,12 +1983,12 @@ pub mod msg_tracking_state_detailed_dep_a { } impl TryFrom for WeekNumberValidityStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(WeekNumberValidityStatus::WeekNumberIsNotValid), 1 => Ok(WeekNumberValidityStatus::WeekNumberIsValid), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2057,13 +2017,13 @@ pub mod msg_tracking_state_detailed_dep_a { } impl TryFrom for TowStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TowStatus::TowIsNotAvailable), 1 => Ok(TowStatus::DecodedTowIsAvailable), 2 => Ok(TowStatus::PropagatedTowIsAvailable), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2088,12 +2048,12 @@ pub mod msg_tracking_state_detailed_dep_a { } impl TryFrom for FllStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(FllStatus::FllIsInactive), 1 => Ok(FllStatus::FllIsActive), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2118,12 +2078,12 @@ pub mod msg_tracking_state_detailed_dep_a { } impl TryFrom for PllStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(PllStatus::PllIsInactive), 1 => Ok(PllStatus::PllIsActive), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2156,14 +2116,14 @@ pub mod msg_tracking_state_detailed_dep_a { } impl TryFrom for TrackingLoopStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TrackingLoopStatus::NoLocks), 1 => Ok(TrackingLoopStatus::FlldllLock), 2 => Ok(TrackingLoopStatus::PllOptimisticLock), 3 => Ok(TrackingLoopStatus::PllPessimisticLock), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2192,12 +2152,12 @@ pub mod msg_tracking_state_detailed_dep_a { } impl TryFrom for AlmanacAvailabilityStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(AlmanacAvailabilityStatus::AlmanacIsNotAvailable), 1 => Ok(AlmanacAvailabilityStatus::AlmanacIsAvailable), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2226,12 +2186,12 @@ pub mod msg_tracking_state_detailed_dep_a { } impl TryFrom for EphemerisAvailabilityStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(EphemerisAvailabilityStatus::EphemerisIsNotAvailable), 1 => Ok(EphemerisAvailabilityStatus::EphemerisIsAvailable), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2260,13 +2220,13 @@ pub mod msg_tracking_state_detailed_dep_a { } impl TryFrom for HealthStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(HealthStatus::HealthIsUnknown), 1 => Ok(HealthStatus::SignalIsUnhealthy), 2 => Ok(HealthStatus::SignalIsHealthy), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2299,14 +2259,14 @@ pub mod msg_tracking_state_detailed_dep_a { } impl TryFrom for ParameterSets { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(ParameterSets::_1MsIntegrationTime), 1 => Ok(ParameterSets::_5MsIntegrationTime), 2 => Ok(ParameterSets::_10MsIntegrationTime), 3 => Ok(ParameterSets::_20MsIntegrationTime), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2335,12 +2295,12 @@ pub mod msg_tracking_state_detailed_dep_a { } impl TryFrom for ClockValidityStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(ClockValidityStatus::ClockOffsetAndDriftIsNotValid), 1 => Ok(ClockValidityStatus::ClockOffsetAndDriftIsValid), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2369,12 +2329,12 @@ pub mod msg_tracking_state_detailed_dep_a { } impl TryFrom for PseudorangeValidityStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(PseudorangeValidityStatus::PseudorangeIsNotValid), 1 => Ok(PseudorangeValidityStatus::PseudorangeIsValid), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2403,12 +2363,12 @@ pub mod msg_tracking_state_detailed_dep_a { } impl TryFrom for AccelerationValidityStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(AccelerationValidityStatus::AccelerationIsNotValid), 1 => Ok(AccelerationValidityStatus::AccelerationIsValid), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2433,12 +2393,12 @@ pub mod msg_tracking_state_detailed_dep_a { } impl TryFrom for CarrierHalfCycleAmbiguityStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(CarrierHalfCycleAmbiguityStatus::Unresolved), 1 => Ok(CarrierHalfCycleAmbiguityStatus::Resolved), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2463,12 +2423,12 @@ pub mod msg_tracking_state_detailed_dep_a { } impl TryFrom for TrackingChannelStatus { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TrackingChannelStatus::ReAcquisition), 1 => Ok(TrackingChannelStatus::Running), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2672,8 +2632,8 @@ pub mod tracking_channel_state_dep_a { } impl TrackingChannelStateDepA { - pub fn tracking_mode(&self) -> Option { - get_bit_range!(self.state, u8, u8, 1, 0).try_into().ok() + pub fn tracking_mode(&self) -> Result { + get_bit_range!(self.state, u8, u8, 1, 0).try_into() } pub fn set_tracking_mode(&mut self, tracking_mode: TrackingMode) { @@ -2722,12 +2682,12 @@ pub mod tracking_channel_state_dep_a { } impl TryFrom for TrackingMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TrackingMode::Disabled), 1 => Ok(TrackingMode::Running), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -2759,8 +2719,8 @@ pub mod tracking_channel_state_dep_b { } impl TrackingChannelStateDepB { - pub fn tracking_mode(&self) -> Option { - get_bit_range!(self.state, u8, u8, 1, 0).try_into().ok() + pub fn tracking_mode(&self) -> Result { + get_bit_range!(self.state, u8, u8, 1, 0).try_into() } pub fn set_tracking_mode(&mut self, tracking_mode: TrackingMode) { @@ -2809,12 +2769,12 @@ pub mod tracking_channel_state_dep_b { } impl TryFrom for TrackingMode { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TrackingMode::Disabled), 1 => Ok(TrackingMode::Running), - _ => Err(TryFromIntError), + i => Err(i), } } } diff --git a/rust/sbp/src/messages/vehicle.rs b/rust/sbp/src/messages/vehicle.rs index 3e9dedd638..463b4d99f7 100644 --- a/rust/sbp/src/messages/vehicle.rs +++ b/rust/sbp/src/messages/vehicle.rs @@ -54,24 +54,24 @@ pub mod msg_odometry { } impl MsgOdometry { - pub fn vehicle_metadata(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 6, 5).try_into().ok() + pub fn vehicle_metadata(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 6, 5).try_into() } pub fn set_vehicle_metadata(&mut self, vehicle_metadata: VehicleMetadata) { set_bit_range!(&mut self.flags, vehicle_metadata, u8, u8, 6, 5); } - pub fn velocity_source(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 4, 3).try_into().ok() + pub fn velocity_source(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } pub fn set_velocity_source(&mut self, velocity_source: VelocitySource) { set_bit_range!(&mut self.flags, velocity_source, u8, u8, 4, 3); } - pub fn time_source(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into().ok() + pub fn time_source(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } pub fn set_time_source(&mut self, time_source: TimeSource) { @@ -173,14 +173,14 @@ pub mod msg_odometry { } impl TryFrom for VehicleMetadata { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(VehicleMetadata::Unavailable), 1 => Ok(VehicleMetadata::Forward), 2 => Ok(VehicleMetadata::Reverse), 3 => Ok(VehicleMetadata::Park), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -213,14 +213,14 @@ pub mod msg_odometry { } impl TryFrom for VelocitySource { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(VelocitySource::Source0), 1 => Ok(VelocitySource::Source1), 2 => Ok(VelocitySource::Source2), 3 => Ok(VelocitySource::Source3), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -249,13 +249,13 @@ pub mod msg_odometry { } impl TryFrom for TimeSource { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(TimeSource::None), 1 => Ok(TimeSource::GpsSolution), 2 => Ok(TimeSource::ProcessorTime), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -307,16 +307,16 @@ pub mod msg_wheeltick { } impl MsgWheeltick { - pub fn vehicle_metadata(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 3, 2).try_into().ok() + pub fn vehicle_metadata(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 3, 2).try_into() } pub fn set_vehicle_metadata(&mut self, vehicle_metadata: VehicleMetadata) { set_bit_range!(&mut self.flags, vehicle_metadata, u8, u8, 3, 2); } - pub fn synchronization_type(&self) -> Option { - get_bit_range!(self.flags, u8, u8, 1, 0).try_into().ok() + pub fn synchronization_type(&self) -> Result { + get_bit_range!(self.flags, u8, u8, 1, 0).try_into() } pub fn set_synchronization_type(&mut self, synchronization_type: SynchronizationType) { @@ -426,14 +426,14 @@ pub mod msg_wheeltick { } impl TryFrom for VehicleMetadata { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(VehicleMetadata::Unavailable), 1 => Ok(VehicleMetadata::Forward), 2 => Ok(VehicleMetadata::Reverse), 3 => Ok(VehicleMetadata::Park), - _ => Err(TryFromIntError), + i => Err(i), } } } @@ -468,13 +468,13 @@ pub mod msg_wheeltick { } impl TryFrom for SynchronizationType { - type Error = TryFromIntError; + type Error = u8; fn try_from(i: u8) -> Result { match i { 0 => Ok(SynchronizationType::MicrosecondsSinceLastPps), 1 => Ok(SynchronizationType::MicrosecondsInGpsWeek), 2 => Ok(SynchronizationType::LocalCpuTimeInNominalMicroseconds), - _ => Err(TryFromIntError), + i => Err(i), } } } From 1ebbb9bfbf7df110c04b1f8f9d07ef93ddbf63dc Mon Sep 17 00:00:00 2001 From: Steve Meyer Date: Thu, 20 Jan 2022 17:40:35 -0800 Subject: [PATCH 08/13] bool getter/setter --- .../resources/rust/sbp_messages_template.rs | 34 +- generator/sbpg/targets/rust.py | 15 +- rust/sbp/src/messages/bootload.rs | 4 + rust/sbp/src/messages/ext_events.rs | 16 +- rust/sbp/src/messages/flash.rs | 30 + rust/sbp/src/messages/gnss.rs | 12 + rust/sbp/src/messages/imu.rs | 26 + rust/sbp/src/messages/linux.rs | 18 + rust/sbp/src/messages/logging.rs | 6 + rust/sbp/src/messages/navigation.rs | 640 +++++++++++++++--- rust/sbp/src/messages/ndb.rs | 24 + rust/sbp/src/messages/observation.rs | 92 ++- rust/sbp/src/messages/orientation.rs | 24 + rust/sbp/src/messages/piksi.rs | 315 ++++----- rust/sbp/src/messages/settings.rs | 12 + rust/sbp/src/messages/solution_meta.rs | 68 ++ rust/sbp/src/messages/ssr.rs | 6 + rust/sbp/src/messages/system.rs | 178 ++++- rust/sbp/src/messages/tracking.rs | 264 +++++++- rust/sbp/src/messages/vehicle.rs | 30 + 20 files changed, 1481 insertions(+), 333 deletions(-) diff --git a/generator/sbpg/targets/resources/rust/sbp_messages_template.rs b/generator/sbpg/targets/resources/rust/sbp_messages_template.rs index c18ef15b81..3cbd72f324 100644 --- a/generator/sbpg/targets/resources/rust/sbp_messages_template.rs +++ b/generator/sbpg/targets/resources/rust/sbp_messages_template.rs @@ -66,20 +66,38 @@ impl (((m.msg_name))) { ((* for b in f.bitfield *)) ((* if b.vals|length > 0 *)) - pub fn (((b.field_name))) (&self) -> Result<(((b.type_name))), (((b.type)))> { + /// Gets the [(((b.type_name)))][self::(((b.type_name)))] stored in the `(((b.field)))` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `(((b.type_name)))` variant. + /// Otherwise the value of the bitrange is returned as an `Err((( '(' )))(((b.type)))((( ')' )))`. This may be because of a malformed message, + /// or because new variants of `(((b.type_name)))` were added. + pub fn (((b.bitrange_name))) (&self) -> Result<(((b.type_name))), (((b.type)))> { get_bit_range!( self.(((b.field))), (((f.type))), (((b.type))), (((b.msb))), (((b.lsb))) ).try_into() } - pub fn set_(((b.field_name))) (&mut self, (((b.field_name))): (((b.type_name)))) { - set_bit_range!(&mut self.(((b.field))), (((b.field_name))), (((f.type))), (((b.type))), (((b.msb))), (((b.lsb))) ); + /// Set the bitrange corresponding to the [(((b.type_name)))][(((b.type_name)))] of the `(((b.field)))` bitfield. + pub fn set_(((b.bitrange_name))) (&mut self, (((b.bitrange_name))): (((b.type_name)))) { + set_bit_range!(&mut self.(((b.field))), (((b.bitrange_name))), (((f.type))), (((b.type))), (((b.msb))), (((b.lsb))) ); + } +((* elif b.type == "bool" *)) + /// Gets the `(((b.bitrange_name)))` flag. + pub fn (((b.bitrange_name))) (&self) -> bool { + ( ( self.(((b.field))) >> (((b.msb))) ) & 1) == 1 + } + + /// Sets the `(((b.bitrange_name)))` flag. + pub fn set_(((b.bitrange_name))) (&mut self, (((b.bitrange_name))): (((b.type)))) { + self.(((b.field))) ^= ( !( (((b.bitrange_name))) as (((f.type))) ) ) & (1 << (((b.msb))) ) } ((* else *)) - pub fn (((b.field_name))) (&self) -> (((b.type))) { + /// Gets the `(((b.bitrange_name)))` stored in `(((b.field)))`. + pub fn (((b.bitrange_name))) (&self) -> (((b.type))) { get_bit_range!( self.(((b.field))), (((f.type))), (((b.type))), (((b.msb))), (((b.lsb))) ) } - pub fn set_(((b.field_name))) (&mut self, (((b.field_name))): (((b.type)))) { - set_bit_range!(&mut self.(((b.field))), (((b.field_name))), (((f.type))), (((b.type))), (((b.msb))), (((b.lsb))) ); + /// Sets the `(((b.bitrange_name)))` bitrange of `(((b.field)))`. + pub fn set_(((b.bitrange_name))) (&mut self, (((b.bitrange_name))): (((b.type)))) { + set_bit_range!(&mut self.(((b.field))), (((b.bitrange_name))), (((f.type))), (((b.type))), (((b.msb))), (((b.lsb))) ); } ((* endif *)) @@ -167,7 +185,9 @@ impl WireFormat for (((m.msg_name))) { ((* if m.has_bitfield *)) ((* for f in m.fields *)) + ((* for b in f.bitfield *)) + ((* if b.vals|length > 0 *)) ((*- if b.desc *)) /// (((b.desc | commentify))) @@ -202,7 +222,9 @@ impl TryFrom<(((b.type)))> for (((b.type_name))) { } } ((* endif *)) + ((* endfor *)) + ((* endfor *)) ((* endif *)) diff --git a/generator/sbpg/targets/rust.py b/generator/sbpg/targets/rust.py index 12fd53fd6f..e9ea9b6889 100644 --- a/generator/sbpg/targets/rust.py +++ b/generator/sbpg/targets/rust.py @@ -295,12 +295,14 @@ def get_bitfield(field): field_name = snake_case(field.identifier) field_name = re.sub("__", "_", field_name) bitrange = item.get("range").split(":") + is_bool = False if len(bitrange) == 1: - msb = bitrange[0] - lsb = 0 + msb = int(bitrange[0]) + lsb = msb + is_bool = len(vals) == 0 else: - msb = bitrange[1] - lsb = bitrange[0] + msb = int(bitrange[1]) + lsb = int(bitrange[0]) items.append( { "desc": item.get("desc"), @@ -308,8 +310,8 @@ def get_bitfield(field): "msb": msb, "lsb": lsb, "type_name": type_name, - "type": calc_item_size(item, field), - "field_name": field_name, + "type": "bool" if is_bool else calc_item_size(item, field), + "bitrange_name": field_name, "vals": vals, } ) @@ -326,6 +328,7 @@ def __init__(self, msg, package_specs, field): self.field_name = snake_case(self.identifier) self.type = type_map(field) self.has_gps_time = False + self.msg = msg for pkg in package_specs: for m in pkg.definitions: if m.identifier == self.type_id and any( diff --git a/rust/sbp/src/messages/bootload.rs b/rust/sbp/src/messages/bootload.rs index ac91cf0ade..6d91a7d0da 100644 --- a/rust/sbp/src/messages/bootload.rs +++ b/rust/sbp/src/messages/bootload.rs @@ -188,10 +188,12 @@ pub mod msg_bootloader_handshake_resp { } impl MsgBootloaderHandshakeResp { + /// Gets the `sbp_major_protocol_version_number` stored in `flags`. pub fn sbp_major_protocol_version_number(&self) -> u8 { get_bit_range!(self.flags, u32, u8, 15, 8) } + /// Sets the `sbp_major_protocol_version_number` bitrange of `flags`. pub fn set_sbp_major_protocol_version_number( &mut self, sbp_major_protocol_version_number: u8, @@ -206,10 +208,12 @@ pub mod msg_bootloader_handshake_resp { ); } + /// Gets the `sbp_minor_protocol_version_number` stored in `flags`. pub fn sbp_minor_protocol_version_number(&self) -> u8 { get_bit_range!(self.flags, u32, u8, 7, 0) } + /// Sets the `sbp_minor_protocol_version_number` bitrange of `flags`. pub fn set_sbp_minor_protocol_version_number( &mut self, sbp_minor_protocol_version_number: u8, diff --git a/rust/sbp/src/messages/ext_events.rs b/rust/sbp/src/messages/ext_events.rs index 673bc08681..a1647aeba7 100644 --- a/rust/sbp/src/messages/ext_events.rs +++ b/rust/sbp/src/messages/ext_events.rs @@ -52,18 +52,30 @@ pub mod msg_ext_event { } impl MsgExtEvent { + /// Gets the [TimeQuality][self::TimeQuality] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TimeQuality` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TimeQuality` were added. pub fn time_quality(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 1, 0).try_into() + get_bit_range!(self.flags, u8, u8, 1, 1).try_into() } + /// Set the bitrange corresponding to the [TimeQuality][TimeQuality] of the `flags` bitfield. pub fn set_time_quality(&mut self, time_quality: TimeQuality) { - set_bit_range!(&mut self.flags, time_quality, u8, u8, 1, 0); + set_bit_range!(&mut self.flags, time_quality, u8, u8, 1, 1); } + /// Gets the [NewLevelOfPin][self::NewLevelOfPin] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `NewLevelOfPin` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `NewLevelOfPin` were added. pub fn new_level_of_pin(&self) -> Result { get_bit_range!(self.flags, u8, u8, 0, 0).try_into() } + /// Set the bitrange corresponding to the [NewLevelOfPin][NewLevelOfPin] of the `flags` bitfield. pub fn set_new_level_of_pin(&mut self, new_level_of_pin: NewLevelOfPin) { set_bit_range!(&mut self.flags, new_level_of_pin, u8, u8, 0, 0); } diff --git a/rust/sbp/src/messages/flash.rs b/rust/sbp/src/messages/flash.rs index 8eef2e44ff..021681519d 100644 --- a/rust/sbp/src/messages/flash.rs +++ b/rust/sbp/src/messages/flash.rs @@ -52,10 +52,16 @@ pub mod msg_flash_done { } impl MsgFlashDone { + /// Gets the [ResponseCode][self::ResponseCode] stored in the `response` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `ResponseCode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `ResponseCode` were added. pub fn response_code(&self) -> Result { get_bit_range!(self.response, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [ResponseCode][ResponseCode] of the `response` bitfield. pub fn set_response_code(&mut self, response_code: ResponseCode) { set_bit_range!(&mut self.response, response_code, u8, u8, 2, 0); } @@ -189,10 +195,16 @@ pub mod msg_flash_erase { } impl MsgFlashErase { + /// Gets the [FlashTargetToRead][self::FlashTargetToRead] stored in the `target` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FlashTargetToRead` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FlashTargetToRead` were added. pub fn flash_target_to_read(&self) -> Result { get_bit_range!(self.target, u8, u8, 0, 0).try_into() } + /// Set the bitrange corresponding to the [FlashTargetToRead][FlashTargetToRead] of the `target` bitfield. pub fn set_flash_target_to_read(&mut self, flash_target_to_read: FlashTargetToRead) { set_bit_range!(&mut self.target, flash_target_to_read, u8, u8, 0, 0); } @@ -315,10 +327,16 @@ pub mod msg_flash_program { } impl MsgFlashProgram { + /// Gets the [FlashTargetToRead][self::FlashTargetToRead] stored in the `target` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FlashTargetToRead` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FlashTargetToRead` were added. pub fn flash_target_to_read(&self) -> Result { get_bit_range!(self.target, u8, u8, 0, 0).try_into() } + /// Set the bitrange corresponding to the [FlashTargetToRead][FlashTargetToRead] of the `target` bitfield. pub fn set_flash_target_to_read(&mut self, flash_target_to_read: FlashTargetToRead) { set_bit_range!(&mut self.target, flash_target_to_read, u8, u8, 0, 0); } @@ -449,10 +467,16 @@ pub mod msg_flash_read_req { } impl MsgFlashReadReq { + /// Gets the [FlashTargetToRead][self::FlashTargetToRead] stored in the `target` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FlashTargetToRead` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FlashTargetToRead` were added. pub fn flash_target_to_read(&self) -> Result { get_bit_range!(self.target, u8, u8, 0, 0).try_into() } + /// Set the bitrange corresponding to the [FlashTargetToRead][FlashTargetToRead] of the `target` bitfield. pub fn set_flash_target_to_read(&mut self, flash_target_to_read: FlashTargetToRead) { set_bit_range!(&mut self.target, flash_target_to_read, u8, u8, 0, 0); } @@ -579,10 +603,16 @@ pub mod msg_flash_read_resp { } impl MsgFlashReadResp { + /// Gets the [FlashTargetToRead][self::FlashTargetToRead] stored in the `target` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FlashTargetToRead` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FlashTargetToRead` were added. pub fn flash_target_to_read(&self) -> Result { get_bit_range!(self.target, u8, u8, 0, 0).try_into() } + /// Set the bitrange corresponding to the [FlashTargetToRead][FlashTargetToRead] of the `target` bitfield. pub fn set_flash_target_to_read(&mut self, flash_target_to_read: FlashTargetToRead) { set_bit_range!(&mut self.target, flash_target_to_read, u8, u8, 0, 0); } diff --git a/rust/sbp/src/messages/gnss.rs b/rust/sbp/src/messages/gnss.rs index 74c9d2f7c4..6ffc561345 100644 --- a/rust/sbp/src/messages/gnss.rs +++ b/rust/sbp/src/messages/gnss.rs @@ -217,10 +217,16 @@ pub mod gnss_signal { } impl GnssSignal { + /// Gets the [Code][self::Code] stored in the `code` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `Code` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `Code` were added. pub fn code(&self) -> Result { get_bit_range!(self.code, u8, u8, 7, 0).try_into() } + /// Set the bitrange corresponding to the [Code][Code] of the `code` bitfield. pub fn set_code(&mut self, code: Code) { set_bit_range!(&mut self.code, code, u8, u8, 7, 0); } @@ -351,10 +357,16 @@ pub mod gnss_signal_dep { } impl GnssSignalDep { + /// Gets the [Code][self::Code] stored in the `code` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `Code` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `Code` were added. pub fn code(&self) -> Result { get_bit_range!(self.code, u8, u8, 7, 0).try_into() } + /// Set the bitrange corresponding to the [Code][Code] of the `code` bitfield. pub fn set_code(&mut self, code: Code) { set_bit_range!(&mut self.code, code, u8, u8, 7, 0); } diff --git a/rust/sbp/src/messages/imu.rs b/rust/sbp/src/messages/imu.rs index b0a6843ea1..b442d2680a 100644 --- a/rust/sbp/src/messages/imu.rs +++ b/rust/sbp/src/messages/imu.rs @@ -46,26 +46,44 @@ pub mod msg_imu_aux { } impl MsgImuAux { + /// Gets the [ImuType][self::ImuType] stored in the `imu_type` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `ImuType` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `ImuType` were added. pub fn imu_type(&self) -> Result { get_bit_range!(self.imu_type, u8, u8, 7, 0).try_into() } + /// Set the bitrange corresponding to the [ImuType][ImuType] of the `imu_type` bitfield. pub fn set_imu_type(&mut self, imu_type: ImuType) { set_bit_range!(&mut self.imu_type, imu_type, u8, u8, 7, 0); } + /// Gets the [GyroscopeRange][self::GyroscopeRange] stored in the `imu_conf` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `GyroscopeRange` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `GyroscopeRange` were added. pub fn gyroscope_range(&self) -> Result { get_bit_range!(self.imu_conf, u8, u8, 7, 4).try_into() } + /// Set the bitrange corresponding to the [GyroscopeRange][GyroscopeRange] of the `imu_conf` bitfield. pub fn set_gyroscope_range(&mut self, gyroscope_range: GyroscopeRange) { set_bit_range!(&mut self.imu_conf, gyroscope_range, u8, u8, 7, 4); } + /// Gets the [AccelerometerRange][self::AccelerometerRange] stored in the `imu_conf` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `AccelerometerRange` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `AccelerometerRange` were added. pub fn accelerometer_range(&self) -> Result { get_bit_range!(self.imu_conf, u8, u8, 3, 0).try_into() } + /// Set the bitrange corresponding to the [AccelerometerRange][AccelerometerRange] of the `imu_conf` bitfield. pub fn set_accelerometer_range(&mut self, accelerometer_range: AccelerometerRange) { set_bit_range!(&mut self.imu_conf, accelerometer_range, u8, u8, 3, 0); } @@ -298,18 +316,26 @@ pub mod msg_imu_raw { } impl MsgImuRaw { + /// Gets the [TimeStatus][self::TimeStatus] stored in the `tow` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TimeStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TimeStatus` were added. pub fn time_status(&self) -> Result { get_bit_range!(self.tow, u32, u8, 31, 30).try_into() } + /// Set the bitrange corresponding to the [TimeStatus][TimeStatus] of the `tow` bitfield. pub fn set_time_status(&mut self, time_status: TimeStatus) { set_bit_range!(&mut self.tow, time_status, u32, u8, 31, 30); } + /// Gets the `time_since_reference_epoch_in_milliseconds` stored in `tow`. pub fn time_since_reference_epoch_in_milliseconds(&self) -> u32 { get_bit_range!(self.tow, u32, u32, 29, 0) } + /// Sets the `time_since_reference_epoch_in_milliseconds` bitrange of `tow`. pub fn set_time_since_reference_epoch_in_milliseconds( &mut self, time_since_reference_epoch_in_milliseconds: u32, diff --git a/rust/sbp/src/messages/linux.rs b/rust/sbp/src/messages/linux.rs index a914015c6d..1e0cbbc20d 100644 --- a/rust/sbp/src/messages/linux.rs +++ b/rust/sbp/src/messages/linux.rs @@ -66,10 +66,16 @@ pub mod msg_linux_cpu_state { } impl MsgLinuxCpuState { + /// Gets the [TimestampType][self::TimestampType] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TimestampType` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TimestampType` were added. pub fn timestamp_type(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [TimestampType][TimestampType] of the `flags` bitfield. pub fn set_timestamp_type(&mut self, timestamp_type: TimestampType) { set_bit_range!(&mut self.flags, timestamp_type, u8, u8, 2, 0); } @@ -320,10 +326,16 @@ pub mod msg_linux_mem_state { } impl MsgLinuxMemState { + /// Gets the [TimestampType][self::TimestampType] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TimestampType` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TimestampType` were added. pub fn timestamp_type(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [TimestampType][TimestampType] of the `flags` bitfield. pub fn set_timestamp_type(&mut self, timestamp_type: TimestampType) { set_bit_range!(&mut self.flags, timestamp_type, u8, u8, 2, 0); } @@ -1081,10 +1093,16 @@ pub mod msg_linux_sys_state { } impl MsgLinuxSysState { + /// Gets the [TimestampType][self::TimestampType] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TimestampType` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TimestampType` were added. pub fn timestamp_type(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [TimestampType][TimestampType] of the `flags` bitfield. pub fn set_timestamp_type(&mut self, timestamp_type: TimestampType) { set_bit_range!(&mut self.flags, timestamp_type, u8, u8, 2, 0); } diff --git a/rust/sbp/src/messages/logging.rs b/rust/sbp/src/messages/logging.rs index 8757735289..829c1cf07c 100644 --- a/rust/sbp/src/messages/logging.rs +++ b/rust/sbp/src/messages/logging.rs @@ -136,10 +136,16 @@ pub mod msg_log { } impl MsgLog { + /// Gets the [LoggingLevel][self::LoggingLevel] stored in the `level` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `LoggingLevel` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `LoggingLevel` were added. pub fn logging_level(&self) -> Result { get_bit_range!(self.level, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [LoggingLevel][LoggingLevel] of the `level` bitfield. pub fn set_logging_level(&mut self, logging_level: LoggingLevel) { set_bit_range!(&mut self.level, logging_level, u8, u8, 2, 0); } diff --git a/rust/sbp/src/messages/navigation.rs b/rust/sbp/src/messages/navigation.rs index bb260dd3a4..222db5c4ca 100644 --- a/rust/sbp/src/messages/navigation.rs +++ b/rust/sbp/src/messages/navigation.rs @@ -252,10 +252,16 @@ pub mod msg_baseline_ecef { } impl MsgBaselineEcef { + /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FixMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FixMode` were added. pub fn fix_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield. pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } @@ -427,26 +433,44 @@ pub mod msg_baseline_ecef_dep_a { } impl MsgBaselineEcefDepA { + /// Gets the [RaimRepairFlag][self::RaimRepairFlag] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `RaimRepairFlag` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `RaimRepairFlag` were added. pub fn raim_repair_flag(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 4, 0).try_into() + get_bit_range!(self.flags, u8, u8, 4, 4).try_into() } + /// Set the bitrange corresponding to the [RaimRepairFlag][RaimRepairFlag] of the `flags` bitfield. pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { - set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); + set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 4); } + /// Gets the [RaimAvailabilityFlag][self::RaimAvailabilityFlag] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `RaimAvailabilityFlag` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `RaimAvailabilityFlag` were added. pub fn raim_availability_flag(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 3, 0).try_into() + get_bit_range!(self.flags, u8, u8, 3, 3).try_into() } + /// Set the bitrange corresponding to the [RaimAvailabilityFlag][RaimAvailabilityFlag] of the `flags` bitfield. pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { - set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); + set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 3); } + /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FixMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FixMode` were added. pub fn fix_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield. pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } @@ -664,26 +688,44 @@ pub mod msg_baseline_heading_dep_a { } impl MsgBaselineHeadingDepA { + /// Gets the [RaimRepairFlag][self::RaimRepairFlag] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `RaimRepairFlag` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `RaimRepairFlag` were added. pub fn raim_repair_flag(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 4, 0).try_into() + get_bit_range!(self.flags, u8, u8, 4, 4).try_into() } + /// Set the bitrange corresponding to the [RaimRepairFlag][RaimRepairFlag] of the `flags` bitfield. pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { - set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); + set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 4); } + /// Gets the [RaimAvailabilityFlag][self::RaimAvailabilityFlag] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `RaimAvailabilityFlag` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `RaimAvailabilityFlag` were added. pub fn raim_availability_flag(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 3, 0).try_into() + get_bit_range!(self.flags, u8, u8, 3, 3).try_into() } + /// Set the bitrange corresponding to the [RaimAvailabilityFlag][RaimAvailabilityFlag] of the `flags` bitfield. pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { - set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); + set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 3); } + /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FixMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FixMode` were added. pub fn fix_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield. pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } @@ -904,10 +946,16 @@ pub mod msg_baseline_ned { } impl MsgBaselineNed { + /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FixMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FixMode` were added. pub fn fix_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield. pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } @@ -1088,26 +1136,44 @@ pub mod msg_baseline_ned_dep_a { } impl MsgBaselineNedDepA { + /// Gets the [RaimRepairFlag][self::RaimRepairFlag] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `RaimRepairFlag` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `RaimRepairFlag` were added. pub fn raim_repair_flag(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 4, 0).try_into() + get_bit_range!(self.flags, u8, u8, 4, 4).try_into() } + /// Set the bitrange corresponding to the [RaimRepairFlag][RaimRepairFlag] of the `flags` bitfield. pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { - set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); + set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 4); } + /// Gets the [RaimAvailabilityFlag][self::RaimAvailabilityFlag] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `RaimAvailabilityFlag` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `RaimAvailabilityFlag` were added. pub fn raim_availability_flag(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 3, 0).try_into() + get_bit_range!(self.flags, u8, u8, 3, 3).try_into() } + /// Set the bitrange corresponding to the [RaimAvailabilityFlag][RaimAvailabilityFlag] of the `flags` bitfield. pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { - set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); + set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 3); } + /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FixMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FixMode` were added. pub fn fix_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield. pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } @@ -1339,18 +1405,26 @@ pub mod msg_dops { } impl MsgDops { - pub fn raim_repair_flag(&self) -> u8 { - get_bit_range!(self.flags, u8, u8, 7, 0) + /// Gets the `raim_repair_flag` flag. + pub fn raim_repair_flag(&self) -> bool { + ((self.flags >> 7) & 1) == 1 } - pub fn set_raim_repair_flag(&mut self, raim_repair_flag: u8) { - set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 7, 0); + /// Sets the `raim_repair_flag` flag. + pub fn set_raim_repair_flag(&mut self, raim_repair_flag: bool) { + self.flags ^= (!(raim_repair_flag as u8)) & (1 << 7) } + /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FixMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FixMode` were added. pub fn fix_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield. pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } @@ -1652,10 +1726,16 @@ pub mod msg_gps_time { } impl MsgGpsTime { + /// Gets the [TimeSource][self::TimeSource] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TimeSource` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TimeSource` were added. pub fn time_source(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [TimeSource][TimeSource] of the `flags` bitfield. pub fn set_time_source(&mut self, time_source: TimeSource) { set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); } @@ -1931,10 +2011,16 @@ pub mod msg_gps_time_gnss { } impl MsgGpsTimeGnss { + /// Gets the [TimeSource][self::TimeSource] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TimeSource` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TimeSource` were added. pub fn time_source(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [TimeSource][TimeSource] of the `flags` bitfield. pub fn set_time_source(&mut self, time_source: TimeSource) { set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); } @@ -2097,18 +2183,30 @@ pub mod msg_pos_ecef { } impl MsgPosEcef { + /// Gets the [TowType][self::TowType] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TowType` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TowType` were added. pub fn tow_type(&self) -> Result { get_bit_range!(self.flags, u8, u8, 5, 5).try_into() } + /// Set the bitrange corresponding to the [TowType][TowType] of the `flags` bitfield. pub fn set_tow_type(&mut self, tow_type: TowType) { set_bit_range!(&mut self.flags, tow_type, u8, u8, 5, 5); } + /// Gets the [InertialNavigationMode][self::InertialNavigationMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `InertialNavigationMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `InertialNavigationMode` were added. pub fn inertial_navigation_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } + /// Set the bitrange corresponding to the [InertialNavigationMode][InertialNavigationMode] of the `flags` bitfield. pub fn set_inertial_navigation_mode( &mut self, inertial_navigation_mode: InertialNavigationMode, @@ -2116,10 +2214,16 @@ pub mod msg_pos_ecef { set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); } + /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FixMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FixMode` were added. pub fn fix_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield. pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } @@ -2385,18 +2489,30 @@ pub mod msg_pos_ecef_cov { } impl MsgPosEcefCov { + /// Gets the [TypeOfReportedTow][self::TypeOfReportedTow] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TypeOfReportedTow` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TypeOfReportedTow` were added. pub fn type_of_reported_tow(&self) -> Result { get_bit_range!(self.flags, u8, u8, 5, 5).try_into() } + /// Set the bitrange corresponding to the [TypeOfReportedTow][TypeOfReportedTow] of the `flags` bitfield. pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } + /// Gets the [InertialNavigationMode][self::InertialNavigationMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `InertialNavigationMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `InertialNavigationMode` were added. pub fn inertial_navigation_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } + /// Set the bitrange corresponding to the [InertialNavigationMode][InertialNavigationMode] of the `flags` bitfield. pub fn set_inertial_navigation_mode( &mut self, inertial_navigation_mode: InertialNavigationMode, @@ -2404,10 +2520,16 @@ pub mod msg_pos_ecef_cov { set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); } + /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FixMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FixMode` were added. pub fn fix_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield. pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } @@ -2693,10 +2815,16 @@ pub mod msg_pos_ecef_cov_gnss { } impl MsgPosEcefCovGnss { + /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FixMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FixMode` were added. pub fn fix_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield. pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } @@ -2901,26 +3029,44 @@ pub mod msg_pos_ecef_dep_a { } impl MsgPosEcefDepA { + /// Gets the [RaimRepairFlag][self::RaimRepairFlag] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `RaimRepairFlag` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `RaimRepairFlag` were added. pub fn raim_repair_flag(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 4, 0).try_into() + get_bit_range!(self.flags, u8, u8, 4, 4).try_into() } + /// Set the bitrange corresponding to the [RaimRepairFlag][RaimRepairFlag] of the `flags` bitfield. pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { - set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 0); + set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 4, 4); } + /// Gets the [RaimAvailabilityFlag][self::RaimAvailabilityFlag] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `RaimAvailabilityFlag` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `RaimAvailabilityFlag` were added. pub fn raim_availability_flag(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 3, 0).try_into() + get_bit_range!(self.flags, u8, u8, 3, 3).try_into() } + /// Set the bitrange corresponding to the [RaimAvailabilityFlag][RaimAvailabilityFlag] of the `flags` bitfield. pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { - set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 0); + set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 3, 3); } + /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FixMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FixMode` were added. pub fn fix_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield. pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } @@ -3156,10 +3302,16 @@ pub mod msg_pos_ecef_gnss { } impl MsgPosEcefGnss { + /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FixMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FixMode` were added. pub fn fix_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield. pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } @@ -3347,18 +3499,30 @@ pub mod msg_pos_llh { } impl MsgPosLlh { + /// Gets the [TypeOfReportedTow][self::TypeOfReportedTow] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TypeOfReportedTow` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TypeOfReportedTow` were added. pub fn type_of_reported_tow(&self) -> Result { get_bit_range!(self.flags, u8, u8, 5, 5).try_into() } + /// Set the bitrange corresponding to the [TypeOfReportedTow][TypeOfReportedTow] of the `flags` bitfield. pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } + /// Gets the [InertialNavigationMode][self::InertialNavigationMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `InertialNavigationMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `InertialNavigationMode` were added. pub fn inertial_navigation_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } + /// Set the bitrange corresponding to the [InertialNavigationMode][InertialNavigationMode] of the `flags` bitfield. pub fn set_inertial_navigation_mode( &mut self, inertial_navigation_mode: InertialNavigationMode, @@ -3366,10 +3530,16 @@ pub mod msg_pos_llh { set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); } + /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FixMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FixMode` were added. pub fn fix_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield. pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } @@ -3652,18 +3822,30 @@ pub mod msg_pos_llh_acc { } impl MsgPosLlhAcc { + /// Gets the [GeoidModel][self::GeoidModel] stored in the `confidence_and_geoid` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `GeoidModel` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `GeoidModel` were added. pub fn geoid_model(&self) -> Result { get_bit_range!(self.confidence_and_geoid, u8, u8, 6, 4).try_into() } + /// Set the bitrange corresponding to the [GeoidModel][GeoidModel] of the `confidence_and_geoid` bitfield. pub fn set_geoid_model(&mut self, geoid_model: GeoidModel) { set_bit_range!(&mut self.confidence_and_geoid, geoid_model, u8, u8, 6, 4); } + /// Gets the [ConfidenceLevel][self::ConfidenceLevel] stored in the `confidence_and_geoid` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `ConfidenceLevel` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `ConfidenceLevel` were added. pub fn confidence_level(&self) -> Result { get_bit_range!(self.confidence_and_geoid, u8, u8, 3, 0).try_into() } + /// Set the bitrange corresponding to the [ConfidenceLevel][ConfidenceLevel] of the `confidence_and_geoid` bitfield. pub fn set_confidence_level(&mut self, confidence_level: ConfidenceLevel) { set_bit_range!( &mut self.confidence_and_geoid, @@ -3675,18 +3857,30 @@ pub mod msg_pos_llh_acc { ); } + /// Gets the [TypeOfReportedTow][self::TypeOfReportedTow] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TypeOfReportedTow` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TypeOfReportedTow` were added. pub fn type_of_reported_tow(&self) -> Result { get_bit_range!(self.flags, u8, u8, 5, 5).try_into() } + /// Set the bitrange corresponding to the [TypeOfReportedTow][TypeOfReportedTow] of the `flags` bitfield. pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } + /// Gets the [InertialNavigationMode][self::InertialNavigationMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `InertialNavigationMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `InertialNavigationMode` were added. pub fn inertial_navigation_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } + /// Set the bitrange corresponding to the [InertialNavigationMode][InertialNavigationMode] of the `flags` bitfield. pub fn set_inertial_navigation_mode( &mut self, inertial_navigation_mode: InertialNavigationMode, @@ -3694,10 +3888,16 @@ pub mod msg_pos_llh_acc { set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); } + /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FixMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FixMode` were added. pub fn fix_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield. pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } @@ -4057,18 +4257,30 @@ pub mod msg_pos_llh_cov { } impl MsgPosLlhCov { + /// Gets the [TypeOfReportedTow][self::TypeOfReportedTow] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TypeOfReportedTow` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TypeOfReportedTow` were added. pub fn type_of_reported_tow(&self) -> Result { get_bit_range!(self.flags, u8, u8, 5, 5).try_into() } + /// Set the bitrange corresponding to the [TypeOfReportedTow][TypeOfReportedTow] of the `flags` bitfield. pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } + /// Gets the [InertialNavigationMode][self::InertialNavigationMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `InertialNavigationMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `InertialNavigationMode` were added. pub fn inertial_navigation_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } + /// Set the bitrange corresponding to the [InertialNavigationMode][InertialNavigationMode] of the `flags` bitfield. pub fn set_inertial_navigation_mode( &mut self, inertial_navigation_mode: InertialNavigationMode, @@ -4076,10 +4288,16 @@ pub mod msg_pos_llh_cov { set_bit_range!(&mut self.flags, inertial_navigation_mode, u8, u8, 4, 3); } + /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FixMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FixMode` were added. pub fn fix_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield. pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } @@ -4365,10 +4583,16 @@ pub mod msg_pos_llh_cov_gnss { } impl MsgPosLlhCovGnss { + /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FixMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FixMode` were added. pub fn fix_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield. pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } @@ -4581,34 +4805,58 @@ pub mod msg_pos_llh_dep_a { } impl MsgPosLlhDepA { + /// Gets the [RaimRepairFlag][self::RaimRepairFlag] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `RaimRepairFlag` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `RaimRepairFlag` were added. pub fn raim_repair_flag(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 5, 0).try_into() + get_bit_range!(self.flags, u8, u8, 5, 5).try_into() } + /// Set the bitrange corresponding to the [RaimRepairFlag][RaimRepairFlag] of the `flags` bitfield. pub fn set_raim_repair_flag(&mut self, raim_repair_flag: RaimRepairFlag) { - set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 5, 0); + set_bit_range!(&mut self.flags, raim_repair_flag, u8, u8, 5, 5); } + /// Gets the [RaimAvailabilityFlag][self::RaimAvailabilityFlag] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `RaimAvailabilityFlag` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `RaimAvailabilityFlag` were added. pub fn raim_availability_flag(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 4, 0).try_into() + get_bit_range!(self.flags, u8, u8, 4, 4).try_into() } + /// Set the bitrange corresponding to the [RaimAvailabilityFlag][RaimAvailabilityFlag] of the `flags` bitfield. pub fn set_raim_availability_flag(&mut self, raim_availability_flag: RaimAvailabilityFlag) { - set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 4, 0); + set_bit_range!(&mut self.flags, raim_availability_flag, u8, u8, 4, 4); } + /// Gets the [HeightMode][self::HeightMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `HeightMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `HeightMode` were added. pub fn height_mode(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 3, 0).try_into() + get_bit_range!(self.flags, u8, u8, 3, 3).try_into() } + /// Set the bitrange corresponding to the [HeightMode][HeightMode] of the `flags` bitfield. pub fn set_height_mode(&mut self, height_mode: HeightMode) { - set_bit_range!(&mut self.flags, height_mode, u8, u8, 3, 0); + set_bit_range!(&mut self.flags, height_mode, u8, u8, 3, 3); } + /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FixMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FixMode` were added. pub fn fix_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield. pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } @@ -4883,10 +5131,16 @@ pub mod msg_pos_llh_gnss { } impl MsgPosLlhGnss { + /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FixMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FixMode` were added. pub fn fix_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield. pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } @@ -5115,10 +5369,12 @@ pub mod msg_protection_level { } impl MsgProtectionLevel { + /// Gets the `target_integrity_risk_tir_level` stored in `flags`. pub fn target_integrity_risk_tir_level(&self) -> u8 { get_bit_range!(self.flags, u32, u8, 2, 0) } + /// Sets the `target_integrity_risk_tir_level` bitrange of `flags`. pub fn set_target_integrity_risk_tir_level(&mut self, target_integrity_risk_tir_level: u8) { set_bit_range!( &mut self.flags, @@ -5130,18 +5386,30 @@ pub mod msg_protection_level { ); } + /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FixMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FixMode` were added. pub fn fix_mode(&self) -> Result { get_bit_range!(self.flags, u32, u8, 17, 15).try_into() } + /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield. pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u32, u8, 17, 15); } + /// Gets the [InertialNavigationMode][self::InertialNavigationMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `InertialNavigationMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `InertialNavigationMode` were added. pub fn inertial_navigation_mode(&self) -> Result { get_bit_range!(self.flags, u32, u8, 19, 18).try_into() } + /// Set the bitrange corresponding to the [InertialNavigationMode][InertialNavigationMode] of the `flags` bitfield. pub fn set_inertial_navigation_mode( &mut self, inertial_navigation_mode: InertialNavigationMode, @@ -5149,100 +5417,128 @@ pub mod msg_protection_level { set_bit_range!(&mut self.flags, inertial_navigation_mode, u32, u8, 19, 18); } + /// Gets the [TimeStatus][self::TimeStatus] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TimeStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TimeStatus` were added. pub fn time_status(&self) -> Result { - get_bit_range!(self.flags, u32, u8, 20, 0).try_into() + get_bit_range!(self.flags, u32, u8, 20, 20).try_into() } + /// Set the bitrange corresponding to the [TimeStatus][TimeStatus] of the `flags` bitfield. pub fn set_time_status(&mut self, time_status: TimeStatus) { - set_bit_range!(&mut self.flags, time_status, u32, u8, 20, 0); + set_bit_range!(&mut self.flags, time_status, u32, u8, 20, 20); } - pub fn velocity_valid(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 21, 0) + /// Gets the `velocity_valid` flag. + pub fn velocity_valid(&self) -> bool { + ((self.flags >> 21) & 1) == 1 } - pub fn set_velocity_valid(&mut self, velocity_valid: u8) { - set_bit_range!(&mut self.flags, velocity_valid, u32, u8, 21, 0); + /// Sets the `velocity_valid` flag. + pub fn set_velocity_valid(&mut self, velocity_valid: bool) { + self.flags ^= (!(velocity_valid as u32)) & (1 << 21) } - pub fn attitude_valid(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 22, 0) + /// Gets the `attitude_valid` flag. + pub fn attitude_valid(&self) -> bool { + ((self.flags >> 22) & 1) == 1 } - pub fn set_attitude_valid(&mut self, attitude_valid: u8) { - set_bit_range!(&mut self.flags, attitude_valid, u32, u8, 22, 0); + /// Sets the `attitude_valid` flag. + pub fn set_attitude_valid(&mut self, attitude_valid: bool) { + self.flags ^= (!(attitude_valid as u32)) & (1 << 22) } - pub fn safe_state_hpl(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 23, 0) + /// Gets the `safe_state_hpl` flag. + pub fn safe_state_hpl(&self) -> bool { + ((self.flags >> 23) & 1) == 1 } - pub fn set_safe_state_hpl(&mut self, safe_state_hpl: u8) { - set_bit_range!(&mut self.flags, safe_state_hpl, u32, u8, 23, 0); + /// Sets the `safe_state_hpl` flag. + pub fn set_safe_state_hpl(&mut self, safe_state_hpl: bool) { + self.flags ^= (!(safe_state_hpl as u32)) & (1 << 23) } - pub fn safe_state_vpl(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 24, 0) + /// Gets the `safe_state_vpl` flag. + pub fn safe_state_vpl(&self) -> bool { + ((self.flags >> 24) & 1) == 1 } - pub fn set_safe_state_vpl(&mut self, safe_state_vpl: u8) { - set_bit_range!(&mut self.flags, safe_state_vpl, u32, u8, 24, 0); + /// Sets the `safe_state_vpl` flag. + pub fn set_safe_state_vpl(&mut self, safe_state_vpl: bool) { + self.flags ^= (!(safe_state_vpl as u32)) & (1 << 24) } - pub fn safe_state_atpl(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 25, 0) + /// Gets the `safe_state_atpl` flag. + pub fn safe_state_atpl(&self) -> bool { + ((self.flags >> 25) & 1) == 1 } - pub fn set_safe_state_atpl(&mut self, safe_state_atpl: u8) { - set_bit_range!(&mut self.flags, safe_state_atpl, u32, u8, 25, 0); + /// Sets the `safe_state_atpl` flag. + pub fn set_safe_state_atpl(&mut self, safe_state_atpl: bool) { + self.flags ^= (!(safe_state_atpl as u32)) & (1 << 25) } - pub fn safe_state_ctpl(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 26, 0) + /// Gets the `safe_state_ctpl` flag. + pub fn safe_state_ctpl(&self) -> bool { + ((self.flags >> 26) & 1) == 1 } - pub fn set_safe_state_ctpl(&mut self, safe_state_ctpl: u8) { - set_bit_range!(&mut self.flags, safe_state_ctpl, u32, u8, 26, 0); + /// Sets the `safe_state_ctpl` flag. + pub fn set_safe_state_ctpl(&mut self, safe_state_ctpl: bool) { + self.flags ^= (!(safe_state_ctpl as u32)) & (1 << 26) } - pub fn safe_state_hvpl(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 27, 0) + /// Gets the `safe_state_hvpl` flag. + pub fn safe_state_hvpl(&self) -> bool { + ((self.flags >> 27) & 1) == 1 } - pub fn set_safe_state_hvpl(&mut self, safe_state_hvpl: u8) { - set_bit_range!(&mut self.flags, safe_state_hvpl, u32, u8, 27, 0); + /// Sets the `safe_state_hvpl` flag. + pub fn set_safe_state_hvpl(&mut self, safe_state_hvpl: bool) { + self.flags ^= (!(safe_state_hvpl as u32)) & (1 << 27) } - pub fn safe_state_vvpl(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 28, 0) + /// Gets the `safe_state_vvpl` flag. + pub fn safe_state_vvpl(&self) -> bool { + ((self.flags >> 28) & 1) == 1 } - pub fn set_safe_state_vvpl(&mut self, safe_state_vvpl: u8) { - set_bit_range!(&mut self.flags, safe_state_vvpl, u32, u8, 28, 0); + /// Sets the `safe_state_vvpl` flag. + pub fn set_safe_state_vvpl(&mut self, safe_state_vvpl: bool) { + self.flags ^= (!(safe_state_vvpl as u32)) & (1 << 28) } - pub fn safe_state_hopl(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 29, 0) + /// Gets the `safe_state_hopl` flag. + pub fn safe_state_hopl(&self) -> bool { + ((self.flags >> 29) & 1) == 1 } - pub fn set_safe_state_hopl(&mut self, safe_state_hopl: u8) { - set_bit_range!(&mut self.flags, safe_state_hopl, u32, u8, 29, 0); + /// Sets the `safe_state_hopl` flag. + pub fn set_safe_state_hopl(&mut self, safe_state_hopl: bool) { + self.flags ^= (!(safe_state_hopl as u32)) & (1 << 29) } - pub fn safe_state_popl(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 30, 0) + /// Gets the `safe_state_popl` flag. + pub fn safe_state_popl(&self) -> bool { + ((self.flags >> 30) & 1) == 1 } - pub fn set_safe_state_popl(&mut self, safe_state_popl: u8) { - set_bit_range!(&mut self.flags, safe_state_popl, u32, u8, 30, 0); + /// Sets the `safe_state_popl` flag. + pub fn set_safe_state_popl(&mut self, safe_state_popl: bool) { + self.flags ^= (!(safe_state_popl as u32)) & (1 << 30) } - pub fn safe_state_ropl(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 31, 0) + /// Gets the `safe_state_ropl` flag. + pub fn safe_state_ropl(&self) -> bool { + ((self.flags >> 31) & 1) == 1 } - pub fn set_safe_state_ropl(&mut self, safe_state_ropl: u8) { - set_bit_range!(&mut self.flags, safe_state_ropl, u32, u8, 31, 0); + /// Sets the `safe_state_ropl` flag. + pub fn set_safe_state_ropl(&mut self, safe_state_ropl: bool) { + self.flags ^= (!(safe_state_ropl as u32)) & (1 << 31) } } @@ -5547,10 +5843,16 @@ pub mod msg_protection_level_dep_a { } impl MsgProtectionLevelDepA { + /// Gets the [TargetIntegrityRiskTirLevel][self::TargetIntegrityRiskTirLevel] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TargetIntegrityRiskTirLevel` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TargetIntegrityRiskTirLevel` were added. pub fn target_integrity_risk_tir_level(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [TargetIntegrityRiskTirLevel][TargetIntegrityRiskTirLevel] of the `flags` bitfield. pub fn set_target_integrity_risk_tir_level( &mut self, target_integrity_risk_tir_level: TargetIntegrityRiskTirLevel, @@ -5738,18 +6040,30 @@ pub mod msg_utc_time { } impl MsgUtcTime { + /// Gets the [UtcOffsetSource][self::UtcOffsetSource] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `UtcOffsetSource` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `UtcOffsetSource` were added. pub fn utc_offset_source(&self) -> Result { get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } + /// Set the bitrange corresponding to the [UtcOffsetSource][UtcOffsetSource] of the `flags` bitfield. pub fn set_utc_offset_source(&mut self, utc_offset_source: UtcOffsetSource) { set_bit_range!(&mut self.flags, utc_offset_source, u8, u8, 4, 3); } + /// Gets the [TimeSource][self::TimeSource] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TimeSource` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TimeSource` were added. pub fn time_source(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [TimeSource][TimeSource] of the `flags` bitfield. pub fn set_time_source(&mut self, time_source: TimeSource) { set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); } @@ -5964,18 +6278,30 @@ pub mod msg_utc_time_gnss { } impl MsgUtcTimeGnss { + /// Gets the [UtcOffsetSource][self::UtcOffsetSource] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `UtcOffsetSource` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `UtcOffsetSource` were added. pub fn utc_offset_source(&self) -> Result { get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } + /// Set the bitrange corresponding to the [UtcOffsetSource][UtcOffsetSource] of the `flags` bitfield. pub fn set_utc_offset_source(&mut self, utc_offset_source: UtcOffsetSource) { set_bit_range!(&mut self.flags, utc_offset_source, u8, u8, 4, 3); } + /// Gets the [TimeSource][self::TimeSource] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TimeSource` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TimeSource` were added. pub fn time_source(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [TimeSource][TimeSource] of the `flags` bitfield. pub fn set_time_source(&mut self, time_source: TimeSource) { set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); } @@ -6205,18 +6531,30 @@ pub mod msg_vel_body { } impl MsgVelBody { + /// Gets the [InsNavigationMode][self::InsNavigationMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `InsNavigationMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `InsNavigationMode` were added. pub fn ins_navigation_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } + /// Set the bitrange corresponding to the [InsNavigationMode][InsNavigationMode] of the `flags` bitfield. pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); } + /// Gets the [VelocityMode][self::VelocityMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `VelocityMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `VelocityMode` were added. pub fn velocity_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [VelocityMode][VelocityMode] of the `flags` bitfield. pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); } @@ -6448,61 +6786,103 @@ pub mod msg_vel_cog { } impl MsgVelCog { + /// Gets the [CogFrozen][self::CogFrozen] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `CogFrozen` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `CogFrozen` were added. pub fn cog_frozen(&self) -> Result { - get_bit_range!(self.flags, u16, u8, 9, 0).try_into() + get_bit_range!(self.flags, u16, u8, 9, 9).try_into() } + /// Set the bitrange corresponding to the [CogFrozen][CogFrozen] of the `flags` bitfield. pub fn set_cog_frozen(&mut self, cog_frozen: CogFrozen) { - set_bit_range!(&mut self.flags, cog_frozen, u16, u8, 9, 0); + set_bit_range!(&mut self.flags, cog_frozen, u16, u8, 9, 9); } + /// Gets the [VerticalVelocityValidity][self::VerticalVelocityValidity] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `VerticalVelocityValidity` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `VerticalVelocityValidity` were added. pub fn vertical_velocity_validity(&self) -> Result { - get_bit_range!(self.flags, u16, u8, 8, 0).try_into() + get_bit_range!(self.flags, u16, u8, 8, 8).try_into() } + /// Set the bitrange corresponding to the [VerticalVelocityValidity][VerticalVelocityValidity] of the `flags` bitfield. pub fn set_vertical_velocity_validity( &mut self, vertical_velocity_validity: VerticalVelocityValidity, ) { - set_bit_range!(&mut self.flags, vertical_velocity_validity, u16, u8, 8, 0); + set_bit_range!(&mut self.flags, vertical_velocity_validity, u16, u8, 8, 8); } + /// Gets the [SogValidity][self::SogValidity] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `SogValidity` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `SogValidity` were added. pub fn sog_validity(&self) -> Result { - get_bit_range!(self.flags, u16, u8, 7, 0).try_into() + get_bit_range!(self.flags, u16, u8, 7, 7).try_into() } + /// Set the bitrange corresponding to the [SogValidity][SogValidity] of the `flags` bitfield. pub fn set_sog_validity(&mut self, sog_validity: SogValidity) { - set_bit_range!(&mut self.flags, sog_validity, u16, u8, 7, 0); + set_bit_range!(&mut self.flags, sog_validity, u16, u8, 7, 7); } + /// Gets the [CogValidity][self::CogValidity] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `CogValidity` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `CogValidity` were added. pub fn cog_validity(&self) -> Result { - get_bit_range!(self.flags, u16, u8, 6, 0).try_into() + get_bit_range!(self.flags, u16, u8, 6, 6).try_into() } + /// Set the bitrange corresponding to the [CogValidity][CogValidity] of the `flags` bitfield. pub fn set_cog_validity(&mut self, cog_validity: CogValidity) { - set_bit_range!(&mut self.flags, cog_validity, u16, u8, 6, 0); + set_bit_range!(&mut self.flags, cog_validity, u16, u8, 6, 6); } + /// Gets the [TypeOfReportedTow][self::TypeOfReportedTow] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TypeOfReportedTow` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TypeOfReportedTow` were added. pub fn type_of_reported_tow(&self) -> Result { - get_bit_range!(self.flags, u16, u8, 5, 0).try_into() + get_bit_range!(self.flags, u16, u8, 5, 5).try_into() } + /// Set the bitrange corresponding to the [TypeOfReportedTow][TypeOfReportedTow] of the `flags` bitfield. pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { - set_bit_range!(&mut self.flags, type_of_reported_tow, u16, u8, 5, 0); + set_bit_range!(&mut self.flags, type_of_reported_tow, u16, u8, 5, 5); } + /// Gets the [InsNavigationMode][self::InsNavigationMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `InsNavigationMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `InsNavigationMode` were added. pub fn ins_navigation_mode(&self) -> Result { get_bit_range!(self.flags, u16, u8, 4, 3).try_into() } + /// Set the bitrange corresponding to the [InsNavigationMode][InsNavigationMode] of the `flags` bitfield. pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { set_bit_range!(&mut self.flags, ins_navigation_mode, u16, u8, 4, 3); } + /// Gets the [VelocityMode][self::VelocityMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `VelocityMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `VelocityMode` were added. pub fn velocity_mode(&self) -> Result { get_bit_range!(self.flags, u16, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [VelocityMode][VelocityMode] of the `flags` bitfield. pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { set_bit_range!(&mut self.flags, velocity_mode, u16, u8, 2, 0); } @@ -6859,26 +7239,44 @@ pub mod msg_vel_ecef { } impl MsgVelEcef { + /// Gets the [TypeOfReportedTow][self::TypeOfReportedTow] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TypeOfReportedTow` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TypeOfReportedTow` were added. pub fn type_of_reported_tow(&self) -> Result { get_bit_range!(self.flags, u8, u8, 5, 5).try_into() } + /// Set the bitrange corresponding to the [TypeOfReportedTow][TypeOfReportedTow] of the `flags` bitfield. pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } + /// Gets the [InsNavigationMode][self::InsNavigationMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `InsNavigationMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `InsNavigationMode` were added. pub fn ins_navigation_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } + /// Set the bitrange corresponding to the [InsNavigationMode][InsNavigationMode] of the `flags` bitfield. pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); } + /// Gets the [VelocityMode][self::VelocityMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `VelocityMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `VelocityMode` were added. pub fn velocity_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [VelocityMode][VelocityMode] of the `flags` bitfield. pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); } @@ -7124,26 +7522,44 @@ pub mod msg_vel_ecef_cov { } impl MsgVelEcefCov { + /// Gets the [TypeOfReportedTow][self::TypeOfReportedTow] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TypeOfReportedTow` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TypeOfReportedTow` were added. pub fn type_of_reported_tow(&self) -> Result { get_bit_range!(self.flags, u8, u8, 5, 5).try_into() } + /// Set the bitrange corresponding to the [TypeOfReportedTow][TypeOfReportedTow] of the `flags` bitfield. pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } + /// Gets the [InsNavigationMode][self::InsNavigationMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `InsNavigationMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `InsNavigationMode` were added. pub fn ins_navigation_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } + /// Set the bitrange corresponding to the [InsNavigationMode][InsNavigationMode] of the `flags` bitfield. pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); } + /// Gets the [VelocityMode][self::VelocityMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `VelocityMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `VelocityMode` were added. pub fn velocity_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [VelocityMode][VelocityMode] of the `flags` bitfield. pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); } @@ -7409,10 +7825,16 @@ pub mod msg_vel_ecef_cov_gnss { } impl MsgVelEcefCovGnss { + /// Gets the [VelocityMode][self::VelocityMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `VelocityMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `VelocityMode` were added. pub fn velocity_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [VelocityMode][VelocityMode] of the `flags` bitfield. pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); } @@ -7722,10 +8144,16 @@ pub mod msg_vel_ecef_gnss { } impl MsgVelEcefGnss { + /// Gets the [VelocityMode][self::VelocityMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `VelocityMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `VelocityMode` were added. pub fn velocity_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [VelocityMode][VelocityMode] of the `flags` bitfield. pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); } @@ -7895,26 +8323,44 @@ pub mod msg_vel_ned { } impl MsgVelNed { + /// Gets the [TypeOfReportedTow][self::TypeOfReportedTow] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TypeOfReportedTow` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TypeOfReportedTow` were added. pub fn type_of_reported_tow(&self) -> Result { get_bit_range!(self.flags, u8, u8, 5, 5).try_into() } + /// Set the bitrange corresponding to the [TypeOfReportedTow][TypeOfReportedTow] of the `flags` bitfield. pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } + /// Gets the [InsNavigationMode][self::InsNavigationMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `InsNavigationMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `InsNavigationMode` were added. pub fn ins_navigation_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } + /// Set the bitrange corresponding to the [InsNavigationMode][InsNavigationMode] of the `flags` bitfield. pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); } + /// Gets the [VelocityMode][self::VelocityMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `VelocityMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `VelocityMode` were added. pub fn velocity_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [VelocityMode][VelocityMode] of the `flags` bitfield. pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); } @@ -8167,26 +8613,44 @@ pub mod msg_vel_ned_cov { } impl MsgVelNedCov { + /// Gets the [TypeOfReportedTow][self::TypeOfReportedTow] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TypeOfReportedTow` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TypeOfReportedTow` were added. pub fn type_of_reported_tow(&self) -> Result { get_bit_range!(self.flags, u8, u8, 5, 5).try_into() } + /// Set the bitrange corresponding to the [TypeOfReportedTow][TypeOfReportedTow] of the `flags` bitfield. pub fn set_type_of_reported_tow(&mut self, type_of_reported_tow: TypeOfReportedTow) { set_bit_range!(&mut self.flags, type_of_reported_tow, u8, u8, 5, 5); } + /// Gets the [InsNavigationMode][self::InsNavigationMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `InsNavigationMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `InsNavigationMode` were added. pub fn ins_navigation_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } + /// Set the bitrange corresponding to the [InsNavigationMode][InsNavigationMode] of the `flags` bitfield. pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 4, 3); } + /// Gets the [VelocityMode][self::VelocityMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `VelocityMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `VelocityMode` were added. pub fn velocity_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [VelocityMode][VelocityMode] of the `flags` bitfield. pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); } @@ -8455,10 +8919,16 @@ pub mod msg_vel_ned_cov_gnss { } impl MsgVelNedCovGnss { + /// Gets the [VelocityMode][self::VelocityMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `VelocityMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `VelocityMode` were added. pub fn velocity_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [VelocityMode][VelocityMode] of the `flags` bitfield. pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); } @@ -8780,10 +9250,16 @@ pub mod msg_vel_ned_gnss { } impl MsgVelNedGnss { + /// Gets the [VelocityMode][self::VelocityMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `VelocityMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `VelocityMode` were added. pub fn velocity_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [VelocityMode][VelocityMode] of the `flags` bitfield. pub fn set_velocity_mode(&mut self, velocity_mode: VelocityMode) { set_bit_range!(&mut self.flags, velocity_mode, u8, u8, 2, 0); } diff --git a/rust/sbp/src/messages/ndb.rs b/rust/sbp/src/messages/ndb.rs index ab88f11f65..dd61324f30 100644 --- a/rust/sbp/src/messages/ndb.rs +++ b/rust/sbp/src/messages/ndb.rs @@ -66,34 +66,58 @@ pub mod msg_ndb_event { } impl MsgNdbEvent { + /// Gets the [EventType][self::EventType] stored in the `event` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `EventType` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `EventType` were added. pub fn event_type(&self) -> Result { get_bit_range!(self.event, u8, u8, 1, 0).try_into() } + /// Set the bitrange corresponding to the [EventType][EventType] of the `event` bitfield. pub fn set_event_type(&mut self, event_type: EventType) { set_bit_range!(&mut self.event, event_type, u8, u8, 1, 0); } + /// Gets the [EventObjectType][self::EventObjectType] stored in the `object_type` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `EventObjectType` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `EventObjectType` were added. pub fn event_object_type(&self) -> Result { get_bit_range!(self.object_type, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [EventObjectType][EventObjectType] of the `object_type` bitfield. pub fn set_event_object_type(&mut self, event_object_type: EventObjectType) { set_bit_range!(&mut self.object_type, event_object_type, u8, u8, 2, 0); } + /// Gets the [EventResult][self::EventResult] stored in the `result` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `EventResult` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `EventResult` were added. pub fn event_result(&self) -> Result { get_bit_range!(self.result, u8, u8, 3, 0).try_into() } + /// Set the bitrange corresponding to the [EventResult][EventResult] of the `result` bitfield. pub fn set_event_result(&mut self, event_result: EventResult) { set_bit_range!(&mut self.result, event_result, u8, u8, 3, 0); } + /// Gets the [DataSource][self::DataSource] stored in the `data_source` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `DataSource` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `DataSource` were added. pub fn data_source(&self) -> Result { get_bit_range!(self.data_source, u8, u8, 1, 0).try_into() } + /// Set the bitrange corresponding to the [DataSource][DataSource] of the `data_source` bitfield. pub fn set_data_source(&mut self, data_source: DataSource) { set_bit_range!(&mut self.data_source, data_source, u8, u8, 1, 0); } diff --git a/rust/sbp/src/messages/observation.rs b/rust/sbp/src/messages/observation.rs index c82d9c9f8c..739654829a 100644 --- a/rust/sbp/src/messages/observation.rs +++ b/rust/sbp/src/messages/observation.rs @@ -6350,42 +6350,72 @@ pub mod packed_obs_content { } impl PackedObsContent { + /// Gets the [RaimExclusion][self::RaimExclusion] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `RaimExclusion` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `RaimExclusion` were added. pub fn raim_exclusion(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 7, 0).try_into() + get_bit_range!(self.flags, u8, u8, 7, 7).try_into() } + /// Set the bitrange corresponding to the [RaimExclusion][RaimExclusion] of the `flags` bitfield. pub fn set_raim_exclusion(&mut self, raim_exclusion: RaimExclusion) { - set_bit_range!(&mut self.flags, raim_exclusion, u8, u8, 7, 0); + set_bit_range!(&mut self.flags, raim_exclusion, u8, u8, 7, 7); } + /// Gets the [DopplerValid][self::DopplerValid] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `DopplerValid` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `DopplerValid` were added. pub fn doppler_valid(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 3, 0).try_into() + get_bit_range!(self.flags, u8, u8, 3, 3).try_into() } + /// Set the bitrange corresponding to the [DopplerValid][DopplerValid] of the `flags` bitfield. pub fn set_doppler_valid(&mut self, doppler_valid: DopplerValid) { - set_bit_range!(&mut self.flags, doppler_valid, u8, u8, 3, 0); + set_bit_range!(&mut self.flags, doppler_valid, u8, u8, 3, 3); } + /// Gets the [HalfCycleAmbiguity][self::HalfCycleAmbiguity] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `HalfCycleAmbiguity` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `HalfCycleAmbiguity` were added. pub fn halfcycle_ambiguity(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into() + get_bit_range!(self.flags, u8, u8, 2, 2).try_into() } + /// Set the bitrange corresponding to the [HalfCycleAmbiguity][HalfCycleAmbiguity] of the `flags` bitfield. pub fn set_halfcycle_ambiguity(&mut self, halfcycle_ambiguity: HalfCycleAmbiguity) { - set_bit_range!(&mut self.flags, halfcycle_ambiguity, u8, u8, 2, 0); + set_bit_range!(&mut self.flags, halfcycle_ambiguity, u8, u8, 2, 2); } + /// Gets the [CarrierPhaseValid][self::CarrierPhaseValid] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `CarrierPhaseValid` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `CarrierPhaseValid` were added. pub fn carrier_phase_valid(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 1, 0).try_into() + get_bit_range!(self.flags, u8, u8, 1, 1).try_into() } + /// Set the bitrange corresponding to the [CarrierPhaseValid][CarrierPhaseValid] of the `flags` bitfield. pub fn set_carrier_phase_valid(&mut self, carrier_phase_valid: CarrierPhaseValid) { - set_bit_range!(&mut self.flags, carrier_phase_valid, u8, u8, 1, 0); + set_bit_range!(&mut self.flags, carrier_phase_valid, u8, u8, 1, 1); } + /// Gets the [PseudorangeValid][self::PseudorangeValid] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `PseudorangeValid` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `PseudorangeValid` were added. pub fn pseudorange_valid(&self) -> Result { get_bit_range!(self.flags, u8, u8, 0, 0).try_into() } + /// Set the bitrange corresponding to the [PseudorangeValid][PseudorangeValid] of the `flags` bitfield. pub fn set_pseudorange_valid(&mut self, pseudorange_valid: PseudorangeValid) { set_bit_range!(&mut self.flags, pseudorange_valid, u8, u8, 0, 0); } @@ -6841,48 +6871,78 @@ pub mod packed_osr_content { } impl PackedOsrContent { + /// Gets the [InvalidPhaseCorrections][self::InvalidPhaseCorrections] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `InvalidPhaseCorrections` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `InvalidPhaseCorrections` were added. pub fn invalid_phase_corrections(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 4, 0).try_into() + get_bit_range!(self.flags, u8, u8, 4, 4).try_into() } + /// Set the bitrange corresponding to the [InvalidPhaseCorrections][InvalidPhaseCorrections] of the `flags` bitfield. pub fn set_invalid_phase_corrections( &mut self, invalid_phase_corrections: InvalidPhaseCorrections, ) { - set_bit_range!(&mut self.flags, invalid_phase_corrections, u8, u8, 4, 0); + set_bit_range!(&mut self.flags, invalid_phase_corrections, u8, u8, 4, 4); } + /// Gets the [InvalidCodeCorrections][self::InvalidCodeCorrections] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `InvalidCodeCorrections` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `InvalidCodeCorrections` were added. pub fn invalid_code_corrections(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 3, 0).try_into() + get_bit_range!(self.flags, u8, u8, 3, 3).try_into() } + /// Set the bitrange corresponding to the [InvalidCodeCorrections][InvalidCodeCorrections] of the `flags` bitfield. pub fn set_invalid_code_corrections( &mut self, invalid_code_corrections: InvalidCodeCorrections, ) { - set_bit_range!(&mut self.flags, invalid_code_corrections, u8, u8, 3, 0); + set_bit_range!(&mut self.flags, invalid_code_corrections, u8, u8, 3, 3); } + /// Gets the [FullFixingFlag][self::FullFixingFlag] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FullFixingFlag` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FullFixingFlag` were added. pub fn full_fixing_flag(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 2, 0).try_into() + get_bit_range!(self.flags, u8, u8, 2, 2).try_into() } + /// Set the bitrange corresponding to the [FullFixingFlag][FullFixingFlag] of the `flags` bitfield. pub fn set_full_fixing_flag(&mut self, full_fixing_flag: FullFixingFlag) { - set_bit_range!(&mut self.flags, full_fixing_flag, u8, u8, 2, 0); + set_bit_range!(&mut self.flags, full_fixing_flag, u8, u8, 2, 2); } + /// Gets the [PartialFixingFlag][self::PartialFixingFlag] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `PartialFixingFlag` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `PartialFixingFlag` were added. pub fn partial_fixing_flag(&self) -> Result { - get_bit_range!(self.flags, u8, u8, 1, 0).try_into() + get_bit_range!(self.flags, u8, u8, 1, 1).try_into() } + /// Set the bitrange corresponding to the [PartialFixingFlag][PartialFixingFlag] of the `flags` bitfield. pub fn set_partial_fixing_flag(&mut self, partial_fixing_flag: PartialFixingFlag) { - set_bit_range!(&mut self.flags, partial_fixing_flag, u8, u8, 1, 0); + set_bit_range!(&mut self.flags, partial_fixing_flag, u8, u8, 1, 1); } + /// Gets the [CorrectionValidity][self::CorrectionValidity] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `CorrectionValidity` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `CorrectionValidity` were added. pub fn correction_validity(&self) -> Result { get_bit_range!(self.flags, u8, u8, 0, 0).try_into() } + /// Set the bitrange corresponding to the [CorrectionValidity][CorrectionValidity] of the `flags` bitfield. pub fn set_correction_validity(&mut self, correction_validity: CorrectionValidity) { set_bit_range!(&mut self.flags, correction_validity, u8, u8, 0, 0); } diff --git a/rust/sbp/src/messages/orientation.rs b/rust/sbp/src/messages/orientation.rs index 9c640486b9..e4637b71cb 100644 --- a/rust/sbp/src/messages/orientation.rs +++ b/rust/sbp/src/messages/orientation.rs @@ -60,10 +60,16 @@ pub mod msg_angular_rate { } impl MsgAngularRate { + /// Gets the [InsNavigationMode][self::InsNavigationMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `InsNavigationMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `InsNavigationMode` were added. pub fn ins_navigation_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [InsNavigationMode][InsNavigationMode] of the `flags` bitfield. pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 2, 0); } @@ -209,10 +215,16 @@ pub mod msg_baseline_heading { } impl MsgBaselineHeading { + /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FixMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FixMode` were added. pub fn fix_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield. pub fn set_fix_mode(&mut self, fix_mode: FixMode) { set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0); } @@ -377,10 +389,16 @@ pub mod msg_orient_euler { } impl MsgOrientEuler { + /// Gets the [InsNavigationMode][self::InsNavigationMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `InsNavigationMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `InsNavigationMode` were added. pub fn ins_navigation_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [InsNavigationMode][InsNavigationMode] of the `flags` bitfield. pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 2, 0); } @@ -557,10 +575,16 @@ pub mod msg_orient_quat { } impl MsgOrientQuat { + /// Gets the [InsNavigationMode][self::InsNavigationMode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `InsNavigationMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `InsNavigationMode` were added. pub fn ins_navigation_mode(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [InsNavigationMode][InsNavigationMode] of the `flags` bitfield. pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) { set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 2, 0); } diff --git a/rust/sbp/src/messages/piksi.rs b/rust/sbp/src/messages/piksi.rs index f074f3ae3f..b4294f4ea5 100644 --- a/rust/sbp/src/messages/piksi.rs +++ b/rust/sbp/src/messages/piksi.rs @@ -977,18 +977,30 @@ pub mod msg_mask_satellite { } impl MsgMaskSatellite { + /// Gets the [TrackingChannels][self::TrackingChannels] stored in the `mask` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TrackingChannels` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TrackingChannels` were added. pub fn tracking_channels(&self) -> Result { - get_bit_range!(self.mask, u8, u8, 1, 0).try_into() + get_bit_range!(self.mask, u8, u8, 1, 1).try_into() } + /// Set the bitrange corresponding to the [TrackingChannels][TrackingChannels] of the `mask` bitfield. pub fn set_tracking_channels(&mut self, tracking_channels: TrackingChannels) { - set_bit_range!(&mut self.mask, tracking_channels, u8, u8, 1, 0); + set_bit_range!(&mut self.mask, tracking_channels, u8, u8, 1, 1); } + /// Gets the [AcquisitionChannel][self::AcquisitionChannel] stored in the `mask` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `AcquisitionChannel` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `AcquisitionChannel` were added. pub fn acquisition_channel(&self) -> Result { get_bit_range!(self.mask, u8, u8, 0, 0).try_into() } + /// Set the bitrange corresponding to the [AcquisitionChannel][AcquisitionChannel] of the `mask` bitfield. pub fn set_acquisition_channel(&mut self, acquisition_channel: AcquisitionChannel) { set_bit_range!(&mut self.mask, acquisition_channel, u8, u8, 0, 0); } @@ -1136,18 +1148,30 @@ pub mod msg_mask_satellite_dep { } impl MsgMaskSatelliteDep { + /// Gets the [TrackingChannels][self::TrackingChannels] stored in the `mask` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TrackingChannels` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TrackingChannels` were added. pub fn tracking_channels(&self) -> Result { - get_bit_range!(self.mask, u8, u8, 1, 0).try_into() + get_bit_range!(self.mask, u8, u8, 1, 1).try_into() } + /// Set the bitrange corresponding to the [TrackingChannels][TrackingChannels] of the `mask` bitfield. pub fn set_tracking_channels(&mut self, tracking_channels: TrackingChannels) { - set_bit_range!(&mut self.mask, tracking_channels, u8, u8, 1, 0); + set_bit_range!(&mut self.mask, tracking_channels, u8, u8, 1, 1); } + /// Gets the [AcquisitionChannel][self::AcquisitionChannel] stored in the `mask` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `AcquisitionChannel` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `AcquisitionChannel` were added. pub fn acquisition_channel(&self) -> Result { get_bit_range!(self.mask, u8, u8, 0, 0).try_into() } + /// Set the bitrange corresponding to the [AcquisitionChannel][AcquisitionChannel] of the `mask` bitfield. pub fn set_acquisition_channel(&mut self, acquisition_channel: AcquisitionChannel) { set_bit_range!(&mut self.mask, acquisition_channel, u8, u8, 0, 0); } @@ -1451,273 +1475,206 @@ pub mod msg_network_state_resp { } impl MsgNetworkStateResp { - pub fn iff_multicast_supports_multicast(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 15, 0) + /// Gets the `iff_multicast_supports_multicast` flag. + pub fn iff_multicast_supports_multicast(&self) -> bool { + ((self.flags >> 15) & 1) == 1 } + /// Sets the `iff_multicast_supports_multicast` flag. pub fn set_iff_multicast_supports_multicast( &mut self, - iff_multicast_supports_multicast: u8, + iff_multicast_supports_multicast: bool, ) { - set_bit_range!( - &mut self.flags, - iff_multicast_supports_multicast, - u32, - u8, - 15, - 0 - ); + self.flags ^= (!(iff_multicast_supports_multicast as u32)) & (1 << 15) } - pub fn iff_link2_per_link_layer_defined_bit(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 14, 0) + /// Gets the `iff_link2_per_link_layer_defined_bit` flag. + pub fn iff_link2_per_link_layer_defined_bit(&self) -> bool { + ((self.flags >> 14) & 1) == 1 } + /// Sets the `iff_link2_per_link_layer_defined_bit` flag. pub fn set_iff_link2_per_link_layer_defined_bit( &mut self, - iff_link2_per_link_layer_defined_bit: u8, + iff_link2_per_link_layer_defined_bit: bool, ) { - set_bit_range!( - &mut self.flags, - iff_link2_per_link_layer_defined_bit, - u32, - u8, - 14, - 0 - ); + self.flags ^= (!(iff_link2_per_link_layer_defined_bit as u32)) & (1 << 14) } - pub fn iff_link1_per_link_layer_defined_bit(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 13, 0) + /// Gets the `iff_link1_per_link_layer_defined_bit` flag. + pub fn iff_link1_per_link_layer_defined_bit(&self) -> bool { + ((self.flags >> 13) & 1) == 1 } + /// Sets the `iff_link1_per_link_layer_defined_bit` flag. pub fn set_iff_link1_per_link_layer_defined_bit( &mut self, - iff_link1_per_link_layer_defined_bit: u8, + iff_link1_per_link_layer_defined_bit: bool, ) { - set_bit_range!( - &mut self.flags, - iff_link1_per_link_layer_defined_bit, - u32, - u8, - 13, - 0 - ); + self.flags ^= (!(iff_link1_per_link_layer_defined_bit as u32)) & (1 << 13) } - pub fn iff_link0_per_link_layer_defined_bit(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 12, 0) + /// Gets the `iff_link0_per_link_layer_defined_bit` flag. + pub fn iff_link0_per_link_layer_defined_bit(&self) -> bool { + ((self.flags >> 12) & 1) == 1 } + /// Sets the `iff_link0_per_link_layer_defined_bit` flag. pub fn set_iff_link0_per_link_layer_defined_bit( &mut self, - iff_link0_per_link_layer_defined_bit: u8, + iff_link0_per_link_layer_defined_bit: bool, ) { - set_bit_range!( - &mut self.flags, - iff_link0_per_link_layer_defined_bit, - u32, - u8, - 12, - 0 - ); + self.flags ^= (!(iff_link0_per_link_layer_defined_bit as u32)) & (1 << 12) } - pub fn iff_simplex_cant_hear_own_transmissions(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 11, 0) + /// Gets the `iff_simplex_cant_hear_own_transmissions` flag. + pub fn iff_simplex_cant_hear_own_transmissions(&self) -> bool { + ((self.flags >> 11) & 1) == 1 } + /// Sets the `iff_simplex_cant_hear_own_transmissions` flag. pub fn set_iff_simplex_cant_hear_own_transmissions( &mut self, - iff_simplex_cant_hear_own_transmissions: u8, + iff_simplex_cant_hear_own_transmissions: bool, ) { - set_bit_range!( - &mut self.flags, - iff_simplex_cant_hear_own_transmissions, - u32, - u8, - 11, - 0 - ); + self.flags ^= (!(iff_simplex_cant_hear_own_transmissions as u32)) & (1 << 11) } - pub fn iff_oactive_transmission_in_progress(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 10, 0) + /// Gets the `iff_oactive_transmission_in_progress` flag. + pub fn iff_oactive_transmission_in_progress(&self) -> bool { + ((self.flags >> 10) & 1) == 1 } + /// Sets the `iff_oactive_transmission_in_progress` flag. pub fn set_iff_oactive_transmission_in_progress( &mut self, - iff_oactive_transmission_in_progress: u8, + iff_oactive_transmission_in_progress: bool, ) { - set_bit_range!( - &mut self.flags, - iff_oactive_transmission_in_progress, - u32, - u8, - 10, - 0 - ); + self.flags ^= (!(iff_oactive_transmission_in_progress as u32)) & (1 << 10) } - pub fn iff_allmulti_receive_all_multicast_packets(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 9, 0) + /// Gets the `iff_allmulti_receive_all_multicast_packets` flag. + pub fn iff_allmulti_receive_all_multicast_packets(&self) -> bool { + ((self.flags >> 9) & 1) == 1 } + /// Sets the `iff_allmulti_receive_all_multicast_packets` flag. pub fn set_iff_allmulti_receive_all_multicast_packets( &mut self, - iff_allmulti_receive_all_multicast_packets: u8, + iff_allmulti_receive_all_multicast_packets: bool, ) { - set_bit_range!( - &mut self.flags, - iff_allmulti_receive_all_multicast_packets, - u32, - u8, - 9, - 0 - ); + self.flags ^= (!(iff_allmulti_receive_all_multicast_packets as u32)) & (1 << 9) } - pub fn iff_promisc_receive_all_packets(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 8, 0) + /// Gets the `iff_promisc_receive_all_packets` flag. + pub fn iff_promisc_receive_all_packets(&self) -> bool { + ((self.flags >> 8) & 1) == 1 } - pub fn set_iff_promisc_receive_all_packets(&mut self, iff_promisc_receive_all_packets: u8) { - set_bit_range!( - &mut self.flags, - iff_promisc_receive_all_packets, - u32, - u8, - 8, - 0 - ); + /// Sets the `iff_promisc_receive_all_packets` flag. + pub fn set_iff_promisc_receive_all_packets( + &mut self, + iff_promisc_receive_all_packets: bool, + ) { + self.flags ^= (!(iff_promisc_receive_all_packets as u32)) & (1 << 8) } - pub fn iff_noarp_no_address_resolution_protocol(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 7, 0) + /// Gets the `iff_noarp_no_address_resolution_protocol` flag. + pub fn iff_noarp_no_address_resolution_protocol(&self) -> bool { + ((self.flags >> 7) & 1) == 1 } + /// Sets the `iff_noarp_no_address_resolution_protocol` flag. pub fn set_iff_noarp_no_address_resolution_protocol( &mut self, - iff_noarp_no_address_resolution_protocol: u8, + iff_noarp_no_address_resolution_protocol: bool, ) { - set_bit_range!( - &mut self.flags, - iff_noarp_no_address_resolution_protocol, - u32, - u8, - 7, - 0 - ); + self.flags ^= (!(iff_noarp_no_address_resolution_protocol as u32)) & (1 << 7) } - pub fn iff_running_resources_allocated(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 6, 0) + /// Gets the `iff_running_resources_allocated` flag. + pub fn iff_running_resources_allocated(&self) -> bool { + ((self.flags >> 6) & 1) == 1 } - pub fn set_iff_running_resources_allocated(&mut self, iff_running_resources_allocated: u8) { - set_bit_range!( - &mut self.flags, - iff_running_resources_allocated, - u32, - u8, - 6, - 0 - ); + /// Sets the `iff_running_resources_allocated` flag. + pub fn set_iff_running_resources_allocated( + &mut self, + iff_running_resources_allocated: bool, + ) { + self.flags ^= (!(iff_running_resources_allocated as u32)) & (1 << 6) } - pub fn iff_notrailers_avoid_use_of_trailers(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 5, 0) + /// Gets the `iff_notrailers_avoid_use_of_trailers` flag. + pub fn iff_notrailers_avoid_use_of_trailers(&self) -> bool { + ((self.flags >> 5) & 1) == 1 } + /// Sets the `iff_notrailers_avoid_use_of_trailers` flag. pub fn set_iff_notrailers_avoid_use_of_trailers( &mut self, - iff_notrailers_avoid_use_of_trailers: u8, + iff_notrailers_avoid_use_of_trailers: bool, ) { - set_bit_range!( - &mut self.flags, - iff_notrailers_avoid_use_of_trailers, - u32, - u8, - 5, - 0 - ); + self.flags ^= (!(iff_notrailers_avoid_use_of_trailers as u32)) & (1 << 5) } - pub fn iff_pointopoint_interface_is_pointtopoint_link(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 4, 0) + /// Gets the `iff_pointopoint_interface_is_pointtopoint_link` flag. + pub fn iff_pointopoint_interface_is_pointtopoint_link(&self) -> bool { + ((self.flags >> 4) & 1) == 1 } + /// Sets the `iff_pointopoint_interface_is_pointtopoint_link` flag. pub fn set_iff_pointopoint_interface_is_pointtopoint_link( &mut self, - iff_pointopoint_interface_is_pointtopoint_link: u8, + iff_pointopoint_interface_is_pointtopoint_link: bool, ) { - set_bit_range!( - &mut self.flags, - iff_pointopoint_interface_is_pointtopoint_link, - u32, - u8, - 4, - 0 - ); + self.flags ^= (!(iff_pointopoint_interface_is_pointtopoint_link as u32)) & (1 << 4) } - pub fn iff_loopback_is_a_loopback_net(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 3, 0) + /// Gets the `iff_loopback_is_a_loopback_net` flag. + pub fn iff_loopback_is_a_loopback_net(&self) -> bool { + ((self.flags >> 3) & 1) == 1 } - pub fn set_iff_loopback_is_a_loopback_net(&mut self, iff_loopback_is_a_loopback_net: u8) { - set_bit_range!( - &mut self.flags, - iff_loopback_is_a_loopback_net, - u32, - u8, - 3, - 0 - ); + /// Sets the `iff_loopback_is_a_loopback_net` flag. + pub fn set_iff_loopback_is_a_loopback_net(&mut self, iff_loopback_is_a_loopback_net: bool) { + self.flags ^= (!(iff_loopback_is_a_loopback_net as u32)) & (1 << 3) } - pub fn iff_debug_broadcast_address_valid(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 2, 0) + /// Gets the `iff_debug_broadcast_address_valid` flag. + pub fn iff_debug_broadcast_address_valid(&self) -> bool { + ((self.flags >> 2) & 1) == 1 } + /// Sets the `iff_debug_broadcast_address_valid` flag. pub fn set_iff_debug_broadcast_address_valid( &mut self, - iff_debug_broadcast_address_valid: u8, + iff_debug_broadcast_address_valid: bool, ) { - set_bit_range!( - &mut self.flags, - iff_debug_broadcast_address_valid, - u32, - u8, - 2, - 0 - ); + self.flags ^= (!(iff_debug_broadcast_address_valid as u32)) & (1 << 2) } - pub fn iff_broadcast_broadcast_address_valid(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 1, 0) + /// Gets the `iff_broadcast_broadcast_address_valid` flag. + pub fn iff_broadcast_broadcast_address_valid(&self) -> bool { + ((self.flags >> 1) & 1) == 1 } + /// Sets the `iff_broadcast_broadcast_address_valid` flag. pub fn set_iff_broadcast_broadcast_address_valid( &mut self, - iff_broadcast_broadcast_address_valid: u8, + iff_broadcast_broadcast_address_valid: bool, ) { - set_bit_range!( - &mut self.flags, - iff_broadcast_broadcast_address_valid, - u32, - u8, - 1, - 0 - ); + self.flags ^= (!(iff_broadcast_broadcast_address_valid as u32)) & (1 << 1) } - pub fn iff_up_interface_is_up(&self) -> u8 { - get_bit_range!(self.flags, u32, u8, 0, 0) + /// Gets the `iff_up_interface_is_up` flag. + pub fn iff_up_interface_is_up(&self) -> bool { + ((self.flags >> 0) & 1) == 1 } - pub fn set_iff_up_interface_is_up(&mut self, iff_up_interface_is_up: u8) { - set_bit_range!(&mut self.flags, iff_up_interface_is_up, u32, u8, 0, 0); + /// Sets the `iff_up_interface_is_up` flag. + pub fn set_iff_up_interface_is_up(&mut self, iff_up_interface_is_up: bool) { + self.flags ^= (!(iff_up_interface_is_up as u32)) & (1 << 0) } } @@ -1822,10 +1779,16 @@ pub mod msg_reset { } impl MsgReset { + /// Gets the [DefaultSettings][self::DefaultSettings] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `DefaultSettings` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `DefaultSettings` were added. pub fn default_settings(&self) -> Result { get_bit_range!(self.flags, u32, u8, 0, 0).try_into() } + /// Set the bitrange corresponding to the [DefaultSettings][DefaultSettings] of the `flags` bitfield. pub fn set_default_settings(&mut self, default_settings: DefaultSettings) { set_bit_range!(&mut self.flags, default_settings, u32, u8, 0, 0); } @@ -2001,10 +1964,16 @@ pub mod msg_reset_filters { } impl MsgResetFilters { + /// Gets the [FilterOrProcessToReset][self::FilterOrProcessToReset] stored in the `filter` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FilterOrProcessToReset` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FilterOrProcessToReset` were added. pub fn filter_or_process_to_reset(&self) -> Result { get_bit_range!(self.filter, u8, u8, 1, 0).try_into() } + /// Set the bitrange corresponding to the [FilterOrProcessToReset][FilterOrProcessToReset] of the `filter` bitfield. pub fn set_filter_or_process_to_reset( &mut self, filter_or_process_to_reset: FilterOrProcessToReset, diff --git a/rust/sbp/src/messages/settings.rs b/rust/sbp/src/messages/settings.rs index ea97e6b985..190b0fe857 100644 --- a/rust/sbp/src/messages/settings.rs +++ b/rust/sbp/src/messages/settings.rs @@ -533,10 +533,16 @@ pub mod msg_settings_register_resp { } impl MsgSettingsRegisterResp { + /// Gets the [RegisterStatus][self::RegisterStatus] stored in the `status` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `RegisterStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `RegisterStatus` were added. pub fn register_status(&self) -> Result { get_bit_range!(self.status, u8, u8, 1, 0).try_into() } + /// Set the bitrange corresponding to the [RegisterStatus][RegisterStatus] of the `status` bitfield. pub fn set_register_status(&mut self, register_status: RegisterStatus) { set_bit_range!(&mut self.status, register_status, u8, u8, 1, 0); } @@ -821,10 +827,16 @@ pub mod msg_settings_write_resp { } impl MsgSettingsWriteResp { + /// Gets the [WriteStatus][self::WriteStatus] stored in the `status` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `WriteStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `WriteStatus` were added. pub fn write_status(&self) -> Result { get_bit_range!(self.status, u8, u8, 1, 0).try_into() } + /// Set the bitrange corresponding to the [WriteStatus][WriteStatus] of the `status` bitfield. pub fn set_write_status(&mut self, write_status: WriteStatus) { set_bit_range!(&mut self.status, write_status, u8, u8, 1, 0); } diff --git a/rust/sbp/src/messages/solution_meta.rs b/rust/sbp/src/messages/solution_meta.rs index 96085f99fe..02a6810888 100644 --- a/rust/sbp/src/messages/solution_meta.rs +++ b/rust/sbp/src/messages/solution_meta.rs @@ -41,10 +41,16 @@ pub mod gnss_input_type { } impl GnssInputType { + /// Gets the [TypeOfGnssMeasurement][self::TypeOfGnssMeasurement] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TypeOfGnssMeasurement` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TypeOfGnssMeasurement` were added. pub fn type_of_gnss_measurement(&self) -> Result { get_bit_range!(self.flags, u8, u8, 1, 0).try_into() } + /// Set the bitrange corresponding to the [TypeOfGnssMeasurement][TypeOfGnssMeasurement] of the `flags` bitfield. pub fn set_type_of_gnss_measurement( &mut self, type_of_gnss_measurement: TypeOfGnssMeasurement, @@ -127,26 +133,44 @@ pub mod imu_input_type { } impl ImuInputType { + /// Gets the [TimeStatus][self::TimeStatus] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TimeStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TimeStatus` were added. pub fn time_status(&self) -> Result { get_bit_range!(self.flags, u8, u8, 5, 4).try_into() } + /// Set the bitrange corresponding to the [TimeStatus][TimeStatus] of the `flags` bitfield. pub fn set_time_status(&mut self, time_status: TimeStatus) { set_bit_range!(&mut self.flags, time_status, u8, u8, 5, 4); } + /// Gets the [ImuGrade][self::ImuGrade] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `ImuGrade` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `ImuGrade` were added. pub fn imu_grade(&self) -> Result { get_bit_range!(self.flags, u8, u8, 3, 2).try_into() } + /// Set the bitrange corresponding to the [ImuGrade][ImuGrade] of the `flags` bitfield. pub fn set_imu_grade(&mut self, imu_grade: ImuGrade) { set_bit_range!(&mut self.flags, imu_grade, u8, u8, 3, 2); } + /// Gets the [ImuArchitecture][self::ImuArchitecture] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `ImuArchitecture` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `ImuArchitecture` were added. pub fn imu_architecture(&self) -> Result { get_bit_range!(self.flags, u8, u8, 1, 0).try_into() } + /// Set the bitrange corresponding to the [ImuArchitecture][ImuArchitecture] of the `flags` bitfield. pub fn set_imu_architecture(&mut self, imu_architecture: ImuArchitecture) { set_bit_range!(&mut self.flags, imu_architecture, u8, u8, 1, 0); } @@ -338,18 +362,26 @@ pub mod msg_soln_meta { } impl MsgSolnMeta { + /// Gets the [TimeStatus][self::TimeStatus] stored in the `age_gnss` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TimeStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TimeStatus` were added. pub fn time_status(&self) -> Result { get_bit_range!(self.age_gnss, u32, u8, 31, 30).try_into() } + /// Set the bitrange corresponding to the [TimeStatus][TimeStatus] of the `age_gnss` bitfield. pub fn set_time_status(&mut self, time_status: TimeStatus) { set_bit_range!(&mut self.age_gnss, time_status, u32, u8, 31, 30); } + /// Gets the `age_of_the_last_received_valid_gnss_solution` stored in `age_gnss`. pub fn age_of_the_last_received_valid_gnss_solution(&self) -> u32 { get_bit_range!(self.age_gnss, u32, u32, 29, 0) } + /// Sets the `age_of_the_last_received_valid_gnss_solution` bitrange of `age_gnss`. pub fn set_age_of_the_last_received_valid_gnss_solution( &mut self, age_of_the_last_received_valid_gnss_solution: u32, @@ -540,10 +572,16 @@ pub mod msg_soln_meta_dep_a { } impl MsgSolnMetaDepA { + /// Gets the [AlignmentStatus][self::AlignmentStatus] stored in the `alignment_status` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `AlignmentStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `AlignmentStatus` were added. pub fn alignment_status(&self) -> Result { get_bit_range!(self.alignment_status, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [AlignmentStatus][AlignmentStatus] of the `alignment_status` bitfield. pub fn set_alignment_status(&mut self, alignment_status: AlignmentStatus) { set_bit_range!(&mut self.alignment_status, alignment_status, u8, u8, 2, 0); } @@ -707,26 +745,44 @@ pub mod odo_input_type { } impl OdoInputType { + /// Gets the [Rate][self::Rate] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `Rate` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `Rate` were added. pub fn rate(&self) -> Result { get_bit_range!(self.flags, u8, u8, 5, 4).try_into() } + /// Set the bitrange corresponding to the [Rate][Rate] of the `flags` bitfield. pub fn set_rate(&mut self, rate: Rate) { set_bit_range!(&mut self.flags, rate, u8, u8, 5, 4); } + /// Gets the [OdometerGrade][self::OdometerGrade] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `OdometerGrade` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `OdometerGrade` were added. pub fn odometer_grade(&self) -> Result { get_bit_range!(self.flags, u8, u8, 3, 2).try_into() } + /// Set the bitrange corresponding to the [OdometerGrade][OdometerGrade] of the `flags` bitfield. pub fn set_odometer_grade(&mut self, odometer_grade: OdometerGrade) { set_bit_range!(&mut self.flags, odometer_grade, u8, u8, 3, 2); } + /// Gets the [OdometerClass][self::OdometerClass] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `OdometerClass` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `OdometerClass` were added. pub fn odometer_class(&self) -> Result { get_bit_range!(self.flags, u8, u8, 1, 0).try_into() } + /// Set the bitrange corresponding to the [OdometerClass][OdometerClass] of the `flags` bitfield. pub fn set_odometer_class(&mut self, odometer_class: OdometerClass) { set_bit_range!(&mut self.flags, odometer_class, u8, u8, 1, 0); } @@ -883,18 +939,30 @@ pub mod solution_input_type { } impl SolutionInputType { + /// Gets the [SensorUsage][self::SensorUsage] stored in the `sensor_type` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `SensorUsage` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `SensorUsage` were added. pub fn sensor_usage(&self) -> Result { get_bit_range!(self.sensor_type, u8, u8, 4, 3).try_into() } + /// Set the bitrange corresponding to the [SensorUsage][SensorUsage] of the `sensor_type` bitfield. pub fn set_sensor_usage(&mut self, sensor_usage: SensorUsage) { set_bit_range!(&mut self.sensor_type, sensor_usage, u8, u8, 4, 3); } + /// Gets the [SensorType][self::SensorType] stored in the `sensor_type` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `SensorType` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `SensorType` were added. pub fn sensor_type(&self) -> Result { get_bit_range!(self.sensor_type, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [SensorType][SensorType] of the `sensor_type` bitfield. pub fn set_sensor_type(&mut self, sensor_type: SensorType) { set_bit_range!(&mut self.sensor_type, sensor_type, u8, u8, 2, 0); } diff --git a/rust/sbp/src/messages/ssr.rs b/rust/sbp/src/messages/ssr.rs index bbb7ca0ecb..7999b09fce 100644 --- a/rust/sbp/src/messages/ssr.rs +++ b/rust/sbp/src/messages/ssr.rs @@ -2023,10 +2023,16 @@ pub mod satellite_apc { } impl SatelliteAPC { + /// Gets the [SatelliteType][self::SatelliteType] stored in the `sat_info` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `SatelliteType` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `SatelliteType` were added. pub fn satellite_type(&self) -> Result { get_bit_range!(self.sat_info, u8, u8, 4, 0).try_into() } + /// Set the bitrange corresponding to the [SatelliteType][SatelliteType] of the `sat_info` bitfield. pub fn set_satellite_type(&mut self, satellite_type: SatelliteType) { set_bit_range!(&mut self.sat_info, satellite_type, u8, u8, 4, 0); } diff --git a/rust/sbp/src/messages/system.rs b/rust/sbp/src/messages/system.rs index ce0cf3e461..568a18e565 100644 --- a/rust/sbp/src/messages/system.rs +++ b/rust/sbp/src/messages/system.rs @@ -219,10 +219,16 @@ pub mod msg_dgnss_status { } impl MsgDgnssStatus { + /// Gets the [DifferentialType][self::DifferentialType] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `DifferentialType` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `DifferentialType` were added. pub fn differential_type(&self) -> Result { get_bit_range!(self.flags, u8, u8, 3, 0).try_into() } + /// Set the bitrange corresponding to the [DifferentialType][DifferentialType] of the `flags` bitfield. pub fn set_differential_type(&mut self, differential_type: DifferentialType) { set_bit_range!(&mut self.flags, differential_type, u8, u8, 3, 0); } @@ -453,10 +459,16 @@ pub mod msg_group_meta { } impl MsgGroupMeta { + /// Gets the [SolutionGroupType][self::SolutionGroupType] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `SolutionGroupType` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `SolutionGroupType` were added. pub fn solution_group_type(&self) -> Result { get_bit_range!(self.flags, u8, u8, 1, 0).try_into() } + /// Set the bitrange corresponding to the [SolutionGroupType][SolutionGroupType] of the `flags` bitfield. pub fn set_solution_group_type(&mut self, solution_group_type: SolutionGroupType) { set_bit_range!(&mut self.flags, solution_group_type, u8, u8, 1, 0); } @@ -589,29 +601,43 @@ pub mod msg_heartbeat { } impl MsgHeartbeat { + /// Gets the [ExternalAntennaPresent][self::ExternalAntennaPresent] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `ExternalAntennaPresent` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `ExternalAntennaPresent` were added. pub fn external_antenna_present(&self) -> Result { - get_bit_range!(self.flags, u32, u8, 31, 0).try_into() + get_bit_range!(self.flags, u32, u8, 31, 31).try_into() } + /// Set the bitrange corresponding to the [ExternalAntennaPresent][ExternalAntennaPresent] of the `flags` bitfield. pub fn set_external_antenna_present( &mut self, external_antenna_present: ExternalAntennaPresent, ) { - set_bit_range!(&mut self.flags, external_antenna_present, u32, u8, 31, 0); + set_bit_range!(&mut self.flags, external_antenna_present, u32, u8, 31, 31); } + /// Gets the [ExternalAntennaShort][self::ExternalAntennaShort] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `ExternalAntennaShort` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `ExternalAntennaShort` were added. pub fn external_antenna_short(&self) -> Result { - get_bit_range!(self.flags, u32, u8, 30, 0).try_into() + get_bit_range!(self.flags, u32, u8, 30, 30).try_into() } + /// Set the bitrange corresponding to the [ExternalAntennaShort][ExternalAntennaShort] of the `flags` bitfield. pub fn set_external_antenna_short(&mut self, external_antenna_short: ExternalAntennaShort) { - set_bit_range!(&mut self.flags, external_antenna_short, u32, u8, 30, 0); + set_bit_range!(&mut self.flags, external_antenna_short, u32, u8, 30, 30); } + /// Gets the `sbp_major_protocol_version_number` stored in `flags`. pub fn sbp_major_protocol_version_number(&self) -> u8 { get_bit_range!(self.flags, u32, u8, 23, 16) } + /// Sets the `sbp_major_protocol_version_number` bitrange of `flags`. pub fn set_sbp_major_protocol_version_number( &mut self, sbp_major_protocol_version_number: u8, @@ -626,10 +652,12 @@ pub mod msg_heartbeat { ); } + /// Gets the `sbp_minor_protocol_version_number` stored in `flags`. pub fn sbp_minor_protocol_version_number(&self) -> u8 { get_bit_range!(self.flags, u32, u8, 15, 8) } + /// Sets the `sbp_minor_protocol_version_number` bitrange of `flags`. pub fn set_sbp_minor_protocol_version_number( &mut self, sbp_minor_protocol_version_number: u8, @@ -644,26 +672,44 @@ pub mod msg_heartbeat { ); } + /// Gets the [SwiftNapError][self::SwiftNapError] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `SwiftNapError` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `SwiftNapError` were added. pub fn swift_nap_error(&self) -> Result { - get_bit_range!(self.flags, u32, u8, 2, 0).try_into() + get_bit_range!(self.flags, u32, u8, 2, 2).try_into() } + /// Set the bitrange corresponding to the [SwiftNapError][SwiftNapError] of the `flags` bitfield. pub fn set_swift_nap_error(&mut self, swift_nap_error: SwiftNapError) { - set_bit_range!(&mut self.flags, swift_nap_error, u32, u8, 2, 0); + set_bit_range!(&mut self.flags, swift_nap_error, u32, u8, 2, 2); } + /// Gets the [IoError][self::IoError] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `IoError` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `IoError` were added. pub fn io_error(&self) -> Result { - get_bit_range!(self.flags, u32, u8, 1, 0).try_into() + get_bit_range!(self.flags, u32, u8, 1, 1).try_into() } + /// Set the bitrange corresponding to the [IoError][IoError] of the `flags` bitfield. pub fn set_io_error(&mut self, io_error: IoError) { - set_bit_range!(&mut self.flags, io_error, u32, u8, 1, 0); + set_bit_range!(&mut self.flags, io_error, u32, u8, 1, 1); } + /// Gets the [SystemErrorFlag][self::SystemErrorFlag] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `SystemErrorFlag` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `SystemErrorFlag` were added. pub fn system_error_flag(&self) -> Result { get_bit_range!(self.flags, u32, u8, 0, 0).try_into() } + /// Set the bitrange corresponding to the [SystemErrorFlag][SystemErrorFlag] of the `flags` bitfield. pub fn set_system_error_flag(&mut self, system_error_flag: SystemErrorFlag) { set_bit_range!(&mut self.flags, system_error_flag, u32, u8, 0, 0); } @@ -898,58 +944,100 @@ pub mod msg_ins_status { } impl MsgInsStatus { + /// Gets the [InsType][self::InsType] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `InsType` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `InsType` were added. pub fn ins_type(&self) -> Result { get_bit_range!(self.flags, u32, u8, 31, 29).try_into() } + /// Set the bitrange corresponding to the [InsType][InsType] of the `flags` bitfield. pub fn set_ins_type(&mut self, ins_type: InsType) { set_bit_range!(&mut self.flags, ins_type, u32, u8, 31, 29); } + /// Gets the [MotionState][self::MotionState] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `MotionState` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `MotionState` were added. pub fn motion_state(&self) -> Result { get_bit_range!(self.flags, u32, u8, 13, 11).try_into() } + /// Set the bitrange corresponding to the [MotionState][MotionState] of the `flags` bitfield. pub fn set_motion_state(&mut self, motion_state: MotionState) { set_bit_range!(&mut self.flags, motion_state, u32, u8, 13, 11); } + /// Gets the [OdometrySynch][self::OdometrySynch] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `OdometrySynch` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `OdometrySynch` were added. pub fn odometry_synch(&self) -> Result { - get_bit_range!(self.flags, u32, u8, 10, 0).try_into() + get_bit_range!(self.flags, u32, u8, 10, 10).try_into() } + /// Set the bitrange corresponding to the [OdometrySynch][OdometrySynch] of the `flags` bitfield. pub fn set_odometry_synch(&mut self, odometry_synch: OdometrySynch) { - set_bit_range!(&mut self.flags, odometry_synch, u32, u8, 10, 0); + set_bit_range!(&mut self.flags, odometry_synch, u32, u8, 10, 10); } + /// Gets the [OdometryStatus][self::OdometryStatus] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `OdometryStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `OdometryStatus` were added. pub fn odometry_status(&self) -> Result { get_bit_range!(self.flags, u32, u8, 9, 8).try_into() } + /// Set the bitrange corresponding to the [OdometryStatus][OdometryStatus] of the `flags` bitfield. pub fn set_odometry_status(&mut self, odometry_status: OdometryStatus) { set_bit_range!(&mut self.flags, odometry_status, u32, u8, 9, 8); } + /// Gets the [InsError][self::InsError] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `InsError` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `InsError` were added. pub fn ins_error(&self) -> Result { get_bit_range!(self.flags, u32, u8, 7, 4).try_into() } + /// Set the bitrange corresponding to the [InsError][InsError] of the `flags` bitfield. pub fn set_ins_error(&mut self, ins_error: InsError) { set_bit_range!(&mut self.flags, ins_error, u32, u8, 7, 4); } + /// Gets the [GnssFix][self::GnssFix] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `GnssFix` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `GnssFix` were added. pub fn gnss_fix(&self) -> Result { - get_bit_range!(self.flags, u32, u8, 3, 0).try_into() + get_bit_range!(self.flags, u32, u8, 3, 3).try_into() } + /// Set the bitrange corresponding to the [GnssFix][GnssFix] of the `flags` bitfield. pub fn set_gnss_fix(&mut self, gnss_fix: GnssFix) { - set_bit_range!(&mut self.flags, gnss_fix, u32, u8, 3, 0); + set_bit_range!(&mut self.flags, gnss_fix, u32, u8, 3, 3); } + /// Gets the [Mode][self::Mode] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `Mode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `Mode` were added. pub fn mode(&self) -> Result { get_bit_range!(self.flags, u32, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [Mode][Mode] of the `flags` bitfield. pub fn set_mode(&mut self, mode: Mode) { set_bit_range!(&mut self.flags, mode, u32, u8, 2, 0); } @@ -1314,10 +1402,12 @@ pub mod msg_ins_updates { } impl MsgInsUpdates { + /// Gets the `number_of_attempted_gnss_position_updates_since_last_message` stored in `gnsspos`. pub fn number_of_attempted_gnss_position_updates_since_last_message(&self) -> u8 { get_bit_range!(self.gnsspos, u8, u8, 7, 4) } + /// Sets the `number_of_attempted_gnss_position_updates_since_last_message` bitrange of `gnsspos`. pub fn set_number_of_attempted_gnss_position_updates_since_last_message( &mut self, number_of_attempted_gnss_position_updates_since_last_message: u8, @@ -1332,10 +1422,12 @@ pub mod msg_ins_updates { ); } + /// Gets the `number_of_rejected_gnss_position_updates_since_last_message` stored in `gnsspos`. pub fn number_of_rejected_gnss_position_updates_since_last_message(&self) -> u8 { get_bit_range!(self.gnsspos, u8, u8, 3, 0) } + /// Sets the `number_of_rejected_gnss_position_updates_since_last_message` bitrange of `gnsspos`. pub fn set_number_of_rejected_gnss_position_updates_since_last_message( &mut self, number_of_rejected_gnss_position_updates_since_last_message: u8, @@ -1350,10 +1442,12 @@ pub mod msg_ins_updates { ); } + /// Gets the `number_of_attempted_gnss_velocity_updates_since_last_message` stored in `gnssvel`. pub fn number_of_attempted_gnss_velocity_updates_since_last_message(&self) -> u8 { get_bit_range!(self.gnssvel, u8, u8, 7, 4) } + /// Sets the `number_of_attempted_gnss_velocity_updates_since_last_message` bitrange of `gnssvel`. pub fn set_number_of_attempted_gnss_velocity_updates_since_last_message( &mut self, number_of_attempted_gnss_velocity_updates_since_last_message: u8, @@ -1368,10 +1462,12 @@ pub mod msg_ins_updates { ); } + /// Gets the `number_of_rejected_gnss_velocity_updates_since_last_message` stored in `gnssvel`. pub fn number_of_rejected_gnss_velocity_updates_since_last_message(&self) -> u8 { get_bit_range!(self.gnssvel, u8, u8, 3, 0) } + /// Sets the `number_of_rejected_gnss_velocity_updates_since_last_message` bitrange of `gnssvel`. pub fn set_number_of_rejected_gnss_velocity_updates_since_last_message( &mut self, number_of_rejected_gnss_velocity_updates_since_last_message: u8, @@ -1386,10 +1482,12 @@ pub mod msg_ins_updates { ); } + /// Gets the `number_of_attempted_wheeltick_updates_since_last_message` stored in `wheelticks`. pub fn number_of_attempted_wheeltick_updates_since_last_message(&self) -> u8 { get_bit_range!(self.wheelticks, u8, u8, 7, 4) } + /// Sets the `number_of_attempted_wheeltick_updates_since_last_message` bitrange of `wheelticks`. pub fn set_number_of_attempted_wheeltick_updates_since_last_message( &mut self, number_of_attempted_wheeltick_updates_since_last_message: u8, @@ -1404,10 +1502,12 @@ pub mod msg_ins_updates { ); } + /// Gets the `number_of_rejected_wheeltick_updates_since_last_message` stored in `wheelticks`. pub fn number_of_rejected_wheeltick_updates_since_last_message(&self) -> u8 { get_bit_range!(self.wheelticks, u8, u8, 3, 0) } + /// Sets the `number_of_rejected_wheeltick_updates_since_last_message` bitrange of `wheelticks`. pub fn set_number_of_rejected_wheeltick_updates_since_last_message( &mut self, number_of_rejected_wheeltick_updates_since_last_message: u8, @@ -1422,10 +1522,12 @@ pub mod msg_ins_updates { ); } + /// Gets the `number_of_attempted_speed_updates_since_last_message` stored in `speed`. pub fn number_of_attempted_speed_updates_since_last_message(&self) -> u8 { get_bit_range!(self.speed, u8, u8, 7, 4) } + /// Sets the `number_of_attempted_speed_updates_since_last_message` bitrange of `speed`. pub fn set_number_of_attempted_speed_updates_since_last_message( &mut self, number_of_attempted_speed_updates_since_last_message: u8, @@ -1440,10 +1542,12 @@ pub mod msg_ins_updates { ); } + /// Gets the `number_of_rejected_speed_updates_since_last_message` stored in `speed`. pub fn number_of_rejected_speed_updates_since_last_message(&self) -> u8 { get_bit_range!(self.speed, u8, u8, 3, 0) } + /// Sets the `number_of_rejected_speed_updates_since_last_message` bitrange of `speed`. pub fn set_number_of_rejected_speed_updates_since_last_message( &mut self, number_of_rejected_speed_updates_since_last_message: u8, @@ -1458,10 +1562,12 @@ pub mod msg_ins_updates { ); } + /// Gets the `number_of_attempted_nhc_updates_since_last_message` stored in `nhc`. pub fn number_of_attempted_nhc_updates_since_last_message(&self) -> u8 { get_bit_range!(self.nhc, u8, u8, 7, 4) } + /// Sets the `number_of_attempted_nhc_updates_since_last_message` bitrange of `nhc`. pub fn set_number_of_attempted_nhc_updates_since_last_message( &mut self, number_of_attempted_nhc_updates_since_last_message: u8, @@ -1476,10 +1582,12 @@ pub mod msg_ins_updates { ); } + /// Gets the `number_of_rejected_nhc_updates_since_last_message` stored in `nhc`. pub fn number_of_rejected_nhc_updates_since_last_message(&self) -> u8 { get_bit_range!(self.nhc, u8, u8, 3, 0) } + /// Sets the `number_of_rejected_nhc_updates_since_last_message` bitrange of `nhc`. pub fn set_number_of_rejected_nhc_updates_since_last_message( &mut self, number_of_rejected_nhc_updates_since_last_message: u8, @@ -1494,10 +1602,12 @@ pub mod msg_ins_updates { ); } + /// Gets the `number_of_attempted_zero_velocity_updates_since_last_message` stored in `zerovel`. pub fn number_of_attempted_zero_velocity_updates_since_last_message(&self) -> u8 { get_bit_range!(self.zerovel, u8, u8, 7, 4) } + /// Sets the `number_of_attempted_zero_velocity_updates_since_last_message` bitrange of `zerovel`. pub fn set_number_of_attempted_zero_velocity_updates_since_last_message( &mut self, number_of_attempted_zero_velocity_updates_since_last_message: u8, @@ -1512,10 +1622,12 @@ pub mod msg_ins_updates { ); } + /// Gets the `number_of_rejected_zero_velocity_updates_since_last_message` stored in `zerovel`. pub fn number_of_rejected_zero_velocity_updates_since_last_message(&self) -> u8 { get_bit_range!(self.zerovel, u8, u8, 3, 0) } + /// Sets the `number_of_rejected_zero_velocity_updates_since_last_message` bitrange of `zerovel`. pub fn set_number_of_rejected_zero_velocity_updates_since_last_message( &mut self, number_of_rejected_zero_velocity_updates_since_last_message: u8, @@ -1650,18 +1762,26 @@ pub mod msg_pps_time { } impl MsgPpsTime { + /// Gets the `reserved_set_to_zero` stored in `flags`. pub fn reserved_set_to_zero(&self) -> u8 { get_bit_range!(self.flags, u8, u8, 7, 2) } + /// Sets the `reserved_set_to_zero` bitrange of `flags`. pub fn set_reserved_set_to_zero(&mut self, reserved_set_to_zero: u8) { set_bit_range!(&mut self.flags, reserved_set_to_zero, u8, u8, 7, 2); } + /// Gets the [TimeUncertainty][self::TimeUncertainty] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TimeUncertainty` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TimeUncertainty` were added. pub fn time_uncertainty(&self) -> Result { get_bit_range!(self.flags, u8, u8, 1, 0).try_into() } + /// Set the bitrange corresponding to the [TimeUncertainty][TimeUncertainty] of the `flags` bitfield. pub fn set_time_uncertainty(&mut self, time_uncertainty: TimeUncertainty) { set_bit_range!(&mut self.flags, time_uncertainty, u8, u8, 1, 0); } @@ -1877,18 +1997,30 @@ pub mod msg_startup { } impl MsgStartup { + /// Gets the [CauseOfStartup][self::CauseOfStartup] stored in the `cause` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `CauseOfStartup` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `CauseOfStartup` were added. pub fn cause_of_startup(&self) -> Result { get_bit_range!(self.cause, u8, u8, 8, 0).try_into() } + /// Set the bitrange corresponding to the [CauseOfStartup][CauseOfStartup] of the `cause` bitfield. pub fn set_cause_of_startup(&mut self, cause_of_startup: CauseOfStartup) { set_bit_range!(&mut self.cause, cause_of_startup, u8, u8, 8, 0); } + /// Gets the [StartupType][self::StartupType] stored in the `startup_type` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `StartupType` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `StartupType` were added. pub fn startup_type(&self) -> Result { get_bit_range!(self.startup_type, u8, u8, 8, 0).try_into() } + /// Set the bitrange corresponding to the [StartupType][StartupType] of the `startup_type` bitfield. pub fn set_startup_type(&mut self, startup_type: StartupType) { set_bit_range!(&mut self.startup_type, startup_type, u8, u8, 8, 0); } @@ -2062,18 +2194,26 @@ pub mod msg_status_report { } impl MsgStatusReport { + /// Gets the [System][self::System] stored in the `reporting_system` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `System` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u16)`. This may be because of a malformed message, + /// or because new variants of `System` were added. pub fn system(&self) -> Result { get_bit_range!(self.reporting_system, u16, u16, 15, 0).try_into() } + /// Set the bitrange corresponding to the [System][System] of the `reporting_system` bitfield. pub fn set_system(&mut self, system: System) { set_bit_range!(&mut self.reporting_system, system, u16, u16, 15, 0); } + /// Gets the `sbp_major_protocol_version_number` stored in `sbp_version`. pub fn sbp_major_protocol_version_number(&self) -> u8 { get_bit_range!(self.sbp_version, u16, u8, 16, 8) } + /// Sets the `sbp_major_protocol_version_number` bitrange of `sbp_version`. pub fn set_sbp_major_protocol_version_number( &mut self, sbp_major_protocol_version_number: u8, @@ -2088,10 +2228,12 @@ pub mod msg_status_report { ); } + /// Gets the `sbp_minor_protocol_version_number` stored in `sbp_version`. pub fn sbp_minor_protocol_version_number(&self) -> u8 { get_bit_range!(self.sbp_version, u16, u8, 7, 0) } + /// Sets the `sbp_minor_protocol_version_number` bitrange of `sbp_version`. pub fn set_sbp_minor_protocol_version_number( &mut self, sbp_minor_protocol_version_number: u8, @@ -2229,18 +2371,30 @@ pub mod sub_system_report { } impl SubSystemReport { + /// Gets the [Subsystem][self::Subsystem] stored in the `component` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `Subsystem` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u16)`. This may be because of a malformed message, + /// or because new variants of `Subsystem` were added. pub fn subsystem(&self) -> Result { get_bit_range!(self.component, u16, u16, 15, 0).try_into() } + /// Set the bitrange corresponding to the [Subsystem][Subsystem] of the `component` bitfield. pub fn set_subsystem(&mut self, subsystem: Subsystem) { set_bit_range!(&mut self.component, subsystem, u16, u16, 15, 0); } + /// Gets the [Generic][self::Generic] stored in the `generic` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `Generic` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `Generic` were added. pub fn generic(&self) -> Result { get_bit_range!(self.generic, u8, u8, 7, 0).try_into() } + /// Set the bitrange corresponding to the [Generic][Generic] of the `generic` bitfield. pub fn set_generic(&mut self, generic: Generic) { set_bit_range!(&mut self.generic, generic, u8, u8, 7, 0); } diff --git a/rust/sbp/src/messages/tracking.rs b/rust/sbp/src/messages/tracking.rs index 9649e8395a..fc242a5700 100644 --- a/rust/sbp/src/messages/tracking.rs +++ b/rust/sbp/src/messages/tracking.rs @@ -670,10 +670,16 @@ pub mod msg_tracking_state_detailed_dep { } impl MsgTrackingStateDetailedDep { + /// Gets the [SynchronizationStatus][self::SynchronizationStatus] stored in the `sync_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `SynchronizationStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `SynchronizationStatus` were added. pub fn synchronization_status(&self) -> Result { get_bit_range!(self.sync_flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [SynchronizationStatus][SynchronizationStatus] of the `sync_flags` bitfield. pub fn set_synchronization_status( &mut self, synchronization_status: SynchronizationStatus, @@ -681,10 +687,16 @@ pub mod msg_tracking_state_detailed_dep { set_bit_range!(&mut self.sync_flags, synchronization_status, u8, u8, 2, 0); } + /// Gets the [WeekNumberValidityStatus][self::WeekNumberValidityStatus] stored in the `tow_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `WeekNumberValidityStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `WeekNumberValidityStatus` were added. pub fn week_number_validity_status(&self) -> Result { - get_bit_range!(self.tow_flags, u8, u8, 3, 0).try_into() + get_bit_range!(self.tow_flags, u8, u8, 3, 3).try_into() } + /// Set the bitrange corresponding to the [WeekNumberValidityStatus][WeekNumberValidityStatus] of the `tow_flags` bitfield. pub fn set_week_number_validity_status( &mut self, week_number_validity_status: WeekNumberValidityStatus, @@ -695,46 +707,76 @@ pub mod msg_tracking_state_detailed_dep { u8, u8, 3, - 0 + 3 ); } + /// Gets the [TowStatus][self::TowStatus] stored in the `tow_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TowStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TowStatus` were added. pub fn tow_status(&self) -> Result { get_bit_range!(self.tow_flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [TowStatus][TowStatus] of the `tow_flags` bitfield. pub fn set_tow_status(&mut self, tow_status: TowStatus) { set_bit_range!(&mut self.tow_flags, tow_status, u8, u8, 2, 0); } + /// Gets the [FllStatus][self::FllStatus] stored in the `track_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FllStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FllStatus` were added. pub fn fll_status(&self) -> Result { - get_bit_range!(self.track_flags, u8, u8, 4, 0).try_into() + get_bit_range!(self.track_flags, u8, u8, 4, 4).try_into() } + /// Set the bitrange corresponding to the [FllStatus][FllStatus] of the `track_flags` bitfield. pub fn set_fll_status(&mut self, fll_status: FllStatus) { - set_bit_range!(&mut self.track_flags, fll_status, u8, u8, 4, 0); + set_bit_range!(&mut self.track_flags, fll_status, u8, u8, 4, 4); } + /// Gets the [PllStatus][self::PllStatus] stored in the `track_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `PllStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `PllStatus` were added. pub fn pll_status(&self) -> Result { - get_bit_range!(self.track_flags, u8, u8, 3, 0).try_into() + get_bit_range!(self.track_flags, u8, u8, 3, 3).try_into() } + /// Set the bitrange corresponding to the [PllStatus][PllStatus] of the `track_flags` bitfield. pub fn set_pll_status(&mut self, pll_status: PllStatus) { - set_bit_range!(&mut self.track_flags, pll_status, u8, u8, 3, 0); + set_bit_range!(&mut self.track_flags, pll_status, u8, u8, 3, 3); } + /// Gets the [TrackingLoopStatus][self::TrackingLoopStatus] stored in the `track_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TrackingLoopStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TrackingLoopStatus` were added. pub fn tracking_loop_status(&self) -> Result { get_bit_range!(self.track_flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [TrackingLoopStatus][TrackingLoopStatus] of the `track_flags` bitfield. pub fn set_tracking_loop_status(&mut self, tracking_loop_status: TrackingLoopStatus) { set_bit_range!(&mut self.track_flags, tracking_loop_status, u8, u8, 2, 0); } + /// Gets the [AlmanacAvailabilityStatus][self::AlmanacAvailabilityStatus] stored in the `nav_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `AlmanacAvailabilityStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `AlmanacAvailabilityStatus` were added. pub fn almanac_availability_status(&self) -> Result { - get_bit_range!(self.nav_flags, u8, u8, 4, 0).try_into() + get_bit_range!(self.nav_flags, u8, u8, 4, 4).try_into() } + /// Set the bitrange corresponding to the [AlmanacAvailabilityStatus][AlmanacAvailabilityStatus] of the `nav_flags` bitfield. pub fn set_almanac_availability_status( &mut self, almanac_availability_status: AlmanacAvailabilityStatus, @@ -745,14 +787,20 @@ pub mod msg_tracking_state_detailed_dep { u8, u8, 4, - 0 + 4 ); } + /// Gets the [EphemerisAvailabilityStatus][self::EphemerisAvailabilityStatus] stored in the `nav_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `EphemerisAvailabilityStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `EphemerisAvailabilityStatus` were added. pub fn ephemeris_availability_status(&self) -> Result { - get_bit_range!(self.nav_flags, u8, u8, 3, 0).try_into() + get_bit_range!(self.nav_flags, u8, u8, 3, 3).try_into() } + /// Set the bitrange corresponding to the [EphemerisAvailabilityStatus][EphemerisAvailabilityStatus] of the `nav_flags` bitfield. pub fn set_ephemeris_availability_status( &mut self, ephemeris_availability_status: EphemerisAvailabilityStatus, @@ -763,38 +811,62 @@ pub mod msg_tracking_state_detailed_dep { u8, u8, 3, - 0 + 3 ); } + /// Gets the [HealthStatus][self::HealthStatus] stored in the `nav_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `HealthStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `HealthStatus` were added. pub fn health_status(&self) -> Result { get_bit_range!(self.nav_flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [HealthStatus][HealthStatus] of the `nav_flags` bitfield. pub fn set_health_status(&mut self, health_status: HealthStatus) { set_bit_range!(&mut self.nav_flags, health_status, u8, u8, 2, 0); } + /// Gets the [ParameterSets][self::ParameterSets] stored in the `pset_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `ParameterSets` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `ParameterSets` were added. pub fn parameter_sets(&self) -> Result { get_bit_range!(self.pset_flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [ParameterSets][ParameterSets] of the `pset_flags` bitfield. pub fn set_parameter_sets(&mut self, parameter_sets: ParameterSets) { set_bit_range!(&mut self.pset_flags, parameter_sets, u8, u8, 2, 0); } + /// Gets the [ClockValidityStatus][self::ClockValidityStatus] stored in the `misc_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `ClockValidityStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `ClockValidityStatus` were added. pub fn clock_validity_status(&self) -> Result { - get_bit_range!(self.misc_flags, u8, u8, 5, 0).try_into() + get_bit_range!(self.misc_flags, u8, u8, 5, 5).try_into() } + /// Set the bitrange corresponding to the [ClockValidityStatus][ClockValidityStatus] of the `misc_flags` bitfield. pub fn set_clock_validity_status(&mut self, clock_validity_status: ClockValidityStatus) { - set_bit_range!(&mut self.misc_flags, clock_validity_status, u8, u8, 5, 0); + set_bit_range!(&mut self.misc_flags, clock_validity_status, u8, u8, 5, 5); } + /// Gets the [PseudorangeValidityStatus][self::PseudorangeValidityStatus] stored in the `misc_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `PseudorangeValidityStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `PseudorangeValidityStatus` were added. pub fn pseudorange_validity_status(&self) -> Result { - get_bit_range!(self.misc_flags, u8, u8, 4, 0).try_into() + get_bit_range!(self.misc_flags, u8, u8, 4, 4).try_into() } + /// Set the bitrange corresponding to the [PseudorangeValidityStatus][PseudorangeValidityStatus] of the `misc_flags` bitfield. pub fn set_pseudorange_validity_status( &mut self, pseudorange_validity_status: PseudorangeValidityStatus, @@ -805,14 +877,20 @@ pub mod msg_tracking_state_detailed_dep { u8, u8, 4, - 0 + 4 ); } + /// Gets the [AccelerationValidityStatus][self::AccelerationValidityStatus] stored in the `misc_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `AccelerationValidityStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `AccelerationValidityStatus` were added. pub fn acceleration_validity_status(&self) -> Result { - get_bit_range!(self.misc_flags, u8, u8, 3, 0).try_into() + get_bit_range!(self.misc_flags, u8, u8, 3, 3).try_into() } + /// Set the bitrange corresponding to the [AccelerationValidityStatus][AccelerationValidityStatus] of the `misc_flags` bitfield. pub fn set_acceleration_validity_status( &mut self, acceleration_validity_status: AccelerationValidityStatus, @@ -823,16 +901,22 @@ pub mod msg_tracking_state_detailed_dep { u8, u8, 3, - 0 + 3 ); } + /// Gets the [CarrierHalfCycleAmbiguityStatus][self::CarrierHalfCycleAmbiguityStatus] stored in the `misc_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `CarrierHalfCycleAmbiguityStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `CarrierHalfCycleAmbiguityStatus` were added. pub fn carrier_half_cycle_ambiguity_status( &self, ) -> Result { - get_bit_range!(self.misc_flags, u8, u8, 2, 0).try_into() + get_bit_range!(self.misc_flags, u8, u8, 2, 2).try_into() } + /// Set the bitrange corresponding to the [CarrierHalfCycleAmbiguityStatus][CarrierHalfCycleAmbiguityStatus] of the `misc_flags` bitfield. pub fn set_carrier_half_cycle_ambiguity_status( &mut self, carrier_half_cycle_ambiguity_status: CarrierHalfCycleAmbiguityStatus, @@ -843,14 +927,20 @@ pub mod msg_tracking_state_detailed_dep { u8, u8, 2, - 0 + 2 ); } + /// Gets the [TrackingChannelStatus][self::TrackingChannelStatus] stored in the `misc_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TrackingChannelStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TrackingChannelStatus` were added. pub fn tracking_channel_status(&self) -> Result { get_bit_range!(self.misc_flags, u8, u8, 1, 0).try_into() } + /// Set the bitrange corresponding to the [TrackingChannelStatus][TrackingChannelStatus] of the `misc_flags` bitfield. pub fn set_tracking_channel_status( &mut self, tracking_channel_status: TrackingChannelStatus, @@ -1597,10 +1687,16 @@ pub mod msg_tracking_state_detailed_dep_a { } impl MsgTrackingStateDetailedDepA { + /// Gets the [SynchronizationStatus][self::SynchronizationStatus] stored in the `sync_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `SynchronizationStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `SynchronizationStatus` were added. pub fn synchronization_status(&self) -> Result { get_bit_range!(self.sync_flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [SynchronizationStatus][SynchronizationStatus] of the `sync_flags` bitfield. pub fn set_synchronization_status( &mut self, synchronization_status: SynchronizationStatus, @@ -1608,10 +1704,16 @@ pub mod msg_tracking_state_detailed_dep_a { set_bit_range!(&mut self.sync_flags, synchronization_status, u8, u8, 2, 0); } + /// Gets the [WeekNumberValidityStatus][self::WeekNumberValidityStatus] stored in the `tow_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `WeekNumberValidityStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `WeekNumberValidityStatus` were added. pub fn week_number_validity_status(&self) -> Result { - get_bit_range!(self.tow_flags, u8, u8, 3, 0).try_into() + get_bit_range!(self.tow_flags, u8, u8, 3, 3).try_into() } + /// Set the bitrange corresponding to the [WeekNumberValidityStatus][WeekNumberValidityStatus] of the `tow_flags` bitfield. pub fn set_week_number_validity_status( &mut self, week_number_validity_status: WeekNumberValidityStatus, @@ -1622,46 +1724,76 @@ pub mod msg_tracking_state_detailed_dep_a { u8, u8, 3, - 0 + 3 ); } + /// Gets the [TowStatus][self::TowStatus] stored in the `tow_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TowStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TowStatus` were added. pub fn tow_status(&self) -> Result { get_bit_range!(self.tow_flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [TowStatus][TowStatus] of the `tow_flags` bitfield. pub fn set_tow_status(&mut self, tow_status: TowStatus) { set_bit_range!(&mut self.tow_flags, tow_status, u8, u8, 2, 0); } + /// Gets the [FllStatus][self::FllStatus] stored in the `track_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `FllStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `FllStatus` were added. pub fn fll_status(&self) -> Result { - get_bit_range!(self.track_flags, u8, u8, 4, 0).try_into() + get_bit_range!(self.track_flags, u8, u8, 4, 4).try_into() } + /// Set the bitrange corresponding to the [FllStatus][FllStatus] of the `track_flags` bitfield. pub fn set_fll_status(&mut self, fll_status: FllStatus) { - set_bit_range!(&mut self.track_flags, fll_status, u8, u8, 4, 0); + set_bit_range!(&mut self.track_flags, fll_status, u8, u8, 4, 4); } + /// Gets the [PllStatus][self::PllStatus] stored in the `track_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `PllStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `PllStatus` were added. pub fn pll_status(&self) -> Result { - get_bit_range!(self.track_flags, u8, u8, 3, 0).try_into() + get_bit_range!(self.track_flags, u8, u8, 3, 3).try_into() } + /// Set the bitrange corresponding to the [PllStatus][PllStatus] of the `track_flags` bitfield. pub fn set_pll_status(&mut self, pll_status: PllStatus) { - set_bit_range!(&mut self.track_flags, pll_status, u8, u8, 3, 0); + set_bit_range!(&mut self.track_flags, pll_status, u8, u8, 3, 3); } + /// Gets the [TrackingLoopStatus][self::TrackingLoopStatus] stored in the `track_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TrackingLoopStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TrackingLoopStatus` were added. pub fn tracking_loop_status(&self) -> Result { get_bit_range!(self.track_flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [TrackingLoopStatus][TrackingLoopStatus] of the `track_flags` bitfield. pub fn set_tracking_loop_status(&mut self, tracking_loop_status: TrackingLoopStatus) { set_bit_range!(&mut self.track_flags, tracking_loop_status, u8, u8, 2, 0); } + /// Gets the [AlmanacAvailabilityStatus][self::AlmanacAvailabilityStatus] stored in the `nav_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `AlmanacAvailabilityStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `AlmanacAvailabilityStatus` were added. pub fn almanac_availability_status(&self) -> Result { - get_bit_range!(self.nav_flags, u8, u8, 4, 0).try_into() + get_bit_range!(self.nav_flags, u8, u8, 4, 4).try_into() } + /// Set the bitrange corresponding to the [AlmanacAvailabilityStatus][AlmanacAvailabilityStatus] of the `nav_flags` bitfield. pub fn set_almanac_availability_status( &mut self, almanac_availability_status: AlmanacAvailabilityStatus, @@ -1672,14 +1804,20 @@ pub mod msg_tracking_state_detailed_dep_a { u8, u8, 4, - 0 + 4 ); } + /// Gets the [EphemerisAvailabilityStatus][self::EphemerisAvailabilityStatus] stored in the `nav_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `EphemerisAvailabilityStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `EphemerisAvailabilityStatus` were added. pub fn ephemeris_availability_status(&self) -> Result { - get_bit_range!(self.nav_flags, u8, u8, 3, 0).try_into() + get_bit_range!(self.nav_flags, u8, u8, 3, 3).try_into() } + /// Set the bitrange corresponding to the [EphemerisAvailabilityStatus][EphemerisAvailabilityStatus] of the `nav_flags` bitfield. pub fn set_ephemeris_availability_status( &mut self, ephemeris_availability_status: EphemerisAvailabilityStatus, @@ -1690,38 +1828,62 @@ pub mod msg_tracking_state_detailed_dep_a { u8, u8, 3, - 0 + 3 ); } + /// Gets the [HealthStatus][self::HealthStatus] stored in the `nav_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `HealthStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `HealthStatus` were added. pub fn health_status(&self) -> Result { get_bit_range!(self.nav_flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [HealthStatus][HealthStatus] of the `nav_flags` bitfield. pub fn set_health_status(&mut self, health_status: HealthStatus) { set_bit_range!(&mut self.nav_flags, health_status, u8, u8, 2, 0); } + /// Gets the [ParameterSets][self::ParameterSets] stored in the `pset_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `ParameterSets` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `ParameterSets` were added. pub fn parameter_sets(&self) -> Result { get_bit_range!(self.pset_flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [ParameterSets][ParameterSets] of the `pset_flags` bitfield. pub fn set_parameter_sets(&mut self, parameter_sets: ParameterSets) { set_bit_range!(&mut self.pset_flags, parameter_sets, u8, u8, 2, 0); } + /// Gets the [ClockValidityStatus][self::ClockValidityStatus] stored in the `misc_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `ClockValidityStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `ClockValidityStatus` were added. pub fn clock_validity_status(&self) -> Result { - get_bit_range!(self.misc_flags, u8, u8, 5, 0).try_into() + get_bit_range!(self.misc_flags, u8, u8, 5, 5).try_into() } + /// Set the bitrange corresponding to the [ClockValidityStatus][ClockValidityStatus] of the `misc_flags` bitfield. pub fn set_clock_validity_status(&mut self, clock_validity_status: ClockValidityStatus) { - set_bit_range!(&mut self.misc_flags, clock_validity_status, u8, u8, 5, 0); + set_bit_range!(&mut self.misc_flags, clock_validity_status, u8, u8, 5, 5); } + /// Gets the [PseudorangeValidityStatus][self::PseudorangeValidityStatus] stored in the `misc_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `PseudorangeValidityStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `PseudorangeValidityStatus` were added. pub fn pseudorange_validity_status(&self) -> Result { - get_bit_range!(self.misc_flags, u8, u8, 4, 0).try_into() + get_bit_range!(self.misc_flags, u8, u8, 4, 4).try_into() } + /// Set the bitrange corresponding to the [PseudorangeValidityStatus][PseudorangeValidityStatus] of the `misc_flags` bitfield. pub fn set_pseudorange_validity_status( &mut self, pseudorange_validity_status: PseudorangeValidityStatus, @@ -1732,14 +1894,20 @@ pub mod msg_tracking_state_detailed_dep_a { u8, u8, 4, - 0 + 4 ); } + /// Gets the [AccelerationValidityStatus][self::AccelerationValidityStatus] stored in the `misc_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `AccelerationValidityStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `AccelerationValidityStatus` were added. pub fn acceleration_validity_status(&self) -> Result { - get_bit_range!(self.misc_flags, u8, u8, 3, 0).try_into() + get_bit_range!(self.misc_flags, u8, u8, 3, 3).try_into() } + /// Set the bitrange corresponding to the [AccelerationValidityStatus][AccelerationValidityStatus] of the `misc_flags` bitfield. pub fn set_acceleration_validity_status( &mut self, acceleration_validity_status: AccelerationValidityStatus, @@ -1750,16 +1918,22 @@ pub mod msg_tracking_state_detailed_dep_a { u8, u8, 3, - 0 + 3 ); } + /// Gets the [CarrierHalfCycleAmbiguityStatus][self::CarrierHalfCycleAmbiguityStatus] stored in the `misc_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `CarrierHalfCycleAmbiguityStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `CarrierHalfCycleAmbiguityStatus` were added. pub fn carrier_half_cycle_ambiguity_status( &self, ) -> Result { - get_bit_range!(self.misc_flags, u8, u8, 2, 0).try_into() + get_bit_range!(self.misc_flags, u8, u8, 2, 2).try_into() } + /// Set the bitrange corresponding to the [CarrierHalfCycleAmbiguityStatus][CarrierHalfCycleAmbiguityStatus] of the `misc_flags` bitfield. pub fn set_carrier_half_cycle_ambiguity_status( &mut self, carrier_half_cycle_ambiguity_status: CarrierHalfCycleAmbiguityStatus, @@ -1770,14 +1944,20 @@ pub mod msg_tracking_state_detailed_dep_a { u8, u8, 2, - 0 + 2 ); } + /// Gets the [TrackingChannelStatus][self::TrackingChannelStatus] stored in the `misc_flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TrackingChannelStatus` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TrackingChannelStatus` were added. pub fn tracking_channel_status(&self) -> Result { get_bit_range!(self.misc_flags, u8, u8, 1, 0).try_into() } + /// Set the bitrange corresponding to the [TrackingChannelStatus][TrackingChannelStatus] of the `misc_flags` bitfield. pub fn set_tracking_channel_status( &mut self, tracking_channel_status: TrackingChannelStatus, @@ -2632,10 +2812,16 @@ pub mod tracking_channel_state_dep_a { } impl TrackingChannelStateDepA { + /// Gets the [TrackingMode][self::TrackingMode] stored in the `state` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TrackingMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TrackingMode` were added. pub fn tracking_mode(&self) -> Result { get_bit_range!(self.state, u8, u8, 1, 0).try_into() } + /// Set the bitrange corresponding to the [TrackingMode][TrackingMode] of the `state` bitfield. pub fn set_tracking_mode(&mut self, tracking_mode: TrackingMode) { set_bit_range!(&mut self.state, tracking_mode, u8, u8, 1, 0); } @@ -2719,10 +2905,16 @@ pub mod tracking_channel_state_dep_b { } impl TrackingChannelStateDepB { + /// Gets the [TrackingMode][self::TrackingMode] stored in the `state` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TrackingMode` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TrackingMode` were added. pub fn tracking_mode(&self) -> Result { get_bit_range!(self.state, u8, u8, 1, 0).try_into() } + /// Set the bitrange corresponding to the [TrackingMode][TrackingMode] of the `state` bitfield. pub fn set_tracking_mode(&mut self, tracking_mode: TrackingMode) { set_bit_range!(&mut self.state, tracking_mode, u8, u8, 1, 0); } diff --git a/rust/sbp/src/messages/vehicle.rs b/rust/sbp/src/messages/vehicle.rs index 463b4d99f7..e1ebd14fb3 100644 --- a/rust/sbp/src/messages/vehicle.rs +++ b/rust/sbp/src/messages/vehicle.rs @@ -54,26 +54,44 @@ pub mod msg_odometry { } impl MsgOdometry { + /// Gets the [VehicleMetadata][self::VehicleMetadata] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `VehicleMetadata` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `VehicleMetadata` were added. pub fn vehicle_metadata(&self) -> Result { get_bit_range!(self.flags, u8, u8, 6, 5).try_into() } + /// Set the bitrange corresponding to the [VehicleMetadata][VehicleMetadata] of the `flags` bitfield. pub fn set_vehicle_metadata(&mut self, vehicle_metadata: VehicleMetadata) { set_bit_range!(&mut self.flags, vehicle_metadata, u8, u8, 6, 5); } + /// Gets the [VelocitySource][self::VelocitySource] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `VelocitySource` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `VelocitySource` were added. pub fn velocity_source(&self) -> Result { get_bit_range!(self.flags, u8, u8, 4, 3).try_into() } + /// Set the bitrange corresponding to the [VelocitySource][VelocitySource] of the `flags` bitfield. pub fn set_velocity_source(&mut self, velocity_source: VelocitySource) { set_bit_range!(&mut self.flags, velocity_source, u8, u8, 4, 3); } + /// Gets the [TimeSource][self::TimeSource] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TimeSource` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TimeSource` were added. pub fn time_source(&self) -> Result { get_bit_range!(self.flags, u8, u8, 2, 0).try_into() } + /// Set the bitrange corresponding to the [TimeSource][TimeSource] of the `flags` bitfield. pub fn set_time_source(&mut self, time_source: TimeSource) { set_bit_range!(&mut self.flags, time_source, u8, u8, 2, 0); } @@ -307,18 +325,30 @@ pub mod msg_wheeltick { } impl MsgWheeltick { + /// Gets the [VehicleMetadata][self::VehicleMetadata] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `VehicleMetadata` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `VehicleMetadata` were added. pub fn vehicle_metadata(&self) -> Result { get_bit_range!(self.flags, u8, u8, 3, 2).try_into() } + /// Set the bitrange corresponding to the [VehicleMetadata][VehicleMetadata] of the `flags` bitfield. pub fn set_vehicle_metadata(&mut self, vehicle_metadata: VehicleMetadata) { set_bit_range!(&mut self.flags, vehicle_metadata, u8, u8, 3, 2); } + /// Gets the [SynchronizationType][self::SynchronizationType] stored in the `flags` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `SynchronizationType` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `SynchronizationType` were added. pub fn synchronization_type(&self) -> Result { get_bit_range!(self.flags, u8, u8, 1, 0).try_into() } + /// Set the bitrange corresponding to the [SynchronizationType][SynchronizationType] of the `flags` bitfield. pub fn set_synchronization_type(&mut self, synchronization_type: SynchronizationType) { set_bit_range!(&mut self.flags, synchronization_type, u8, u8, 1, 0); } From a8709c4d42e80cfc938dea15a100b8b1c7df4a9a Mon Sep 17 00:00:00 2001 From: notoriaga Date: Thu, 3 Feb 2022 09:25:22 -0800 Subject: [PATCH 09/13] rebase --- rust/sbp/src/messages/mod.rs | 402 ++++++++++++++++---------------- rust/sbp/src/messages/system.rs | 321 ++++++++++++++++--------- 2 files changed, 417 insertions(+), 306 deletions(-) diff --git a/rust/sbp/src/messages/mod.rs b/rust/sbp/src/messages/mod.rs index e38da22d25..6d5256c73c 100644 --- a/rust/sbp/src/messages/mod.rs +++ b/rust/sbp/src/messages/mod.rs @@ -32,207 +32,207 @@ pub mod tracking; pub mod unknown; pub mod user; pub mod vehicle; -use self::acquisition::MsgAcqResult; -use self::acquisition::MsgAcqResultDepA; -use self::acquisition::MsgAcqResultDepB; -use self::acquisition::MsgAcqResultDepC; -use self::acquisition::MsgAcqSvProfile; -use self::acquisition::MsgAcqSvProfileDep; -use self::bootload::MsgBootloaderHandshakeDepA; -use self::bootload::MsgBootloaderHandshakeReq; -use self::bootload::MsgBootloaderHandshakeResp; -use self::bootload::MsgBootloaderJumpToApp; -use self::bootload::MsgNapDeviceDnaReq; -use self::bootload::MsgNapDeviceDnaResp; -use self::ext_events::MsgExtEvent; -use self::file_io::MsgFileioConfigReq; -use self::file_io::MsgFileioConfigResp; -use self::file_io::MsgFileioReadDirReq; -use self::file_io::MsgFileioReadDirResp; -use self::file_io::MsgFileioReadReq; -use self::file_io::MsgFileioReadResp; -use self::file_io::MsgFileioRemove; -use self::file_io::MsgFileioWriteReq; -use self::file_io::MsgFileioWriteResp; -use self::flash::MsgFlashDone; -use self::flash::MsgFlashErase; -use self::flash::MsgFlashProgram; -use self::flash::MsgFlashReadReq; -use self::flash::MsgFlashReadResp; -use self::flash::MsgM25FlashWriteStatus; -use self::flash::MsgStmFlashLockSector; -use self::flash::MsgStmFlashUnlockSector; -use self::flash::MsgStmUniqueIdReq; -use self::flash::MsgStmUniqueIdResp; -use self::imu::MsgImuAux; -use self::imu::MsgImuRaw; -use self::linux::MsgLinuxCpuState; -use self::linux::MsgLinuxCpuStateDepA; -use self::linux::MsgLinuxMemState; -use self::linux::MsgLinuxMemStateDepA; -use self::linux::MsgLinuxProcessFdCount; -use self::linux::MsgLinuxProcessFdSummary; -use self::linux::MsgLinuxProcessSocketCounts; -use self::linux::MsgLinuxProcessSocketQueues; -use self::linux::MsgLinuxSocketUsage; -use self::linux::MsgLinuxSysState; -use self::linux::MsgLinuxSysStateDepA; -use self::logging::MsgFwd; -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::MsgBaselineHeadingDepA; -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::MsgProtectionLevel; -use self::navigation::MsgProtectionLevelDepA; -use self::navigation::MsgUtcTime; -use self::navigation::MsgUtcTimeGnss; -use self::navigation::MsgVelBody; -use self::navigation::MsgVelCog; -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::MsgAlmanacGlo; -use self::observation::MsgAlmanacGloDep; -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::MsgEphemerisGal; -use self::observation::MsgEphemerisGalDepA; -use self::observation::MsgEphemerisGlo; -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; -use self::observation::MsgEphemerisSbasDepB; -use self::observation::MsgGloBiases; -use self::observation::MsgGnssCapb; -use self::observation::MsgGroupDelay; -use self::observation::MsgGroupDelayDepA; -use self::observation::MsgGroupDelayDepB; -use self::observation::MsgIono; -use self::observation::MsgObs; -use self::observation::MsgObsDepA; -use self::observation::MsgObsDepB; -use self::observation::MsgObsDepC; -use self::observation::MsgOsr; -use self::observation::MsgSvAzEl; -use self::observation::MsgSvConfigurationGpsDep; -use self::orientation::MsgAngularRate; -use self::orientation::MsgBaselineHeading; -use self::orientation::MsgOrientEuler; -use self::orientation::MsgOrientQuat; -use self::piksi::MsgAlmanac; -use self::piksi::MsgCellModemStatus; -use self::piksi::MsgCommandOutput; -use self::piksi::MsgCommandReq; -use self::piksi::MsgCommandResp; -use self::piksi::MsgCwResults; -use self::piksi::MsgCwStart; -use self::piksi::MsgDeviceMonitor; -use self::piksi::MsgFrontEndGain; -use self::piksi::MsgIarState; -use self::piksi::MsgInitBaseDep; -use self::piksi::MsgMaskSatellite; -use self::piksi::MsgMaskSatelliteDep; -use self::piksi::MsgNetworkBandwidthUsage; -use self::piksi::MsgNetworkStateReq; -use self::piksi::MsgNetworkStateResp; -use self::piksi::MsgReset; -use self::piksi::MsgResetDep; -use self::piksi::MsgResetFilters; -use self::piksi::MsgSetTime; -use self::piksi::MsgSpecan; -use self::piksi::MsgSpecanDep; -use self::piksi::MsgThreadState; -use self::piksi::MsgUartState; -use self::piksi::MsgUartStateDepa; -use self::sbas::MsgSbasRaw; -use self::settings::MsgSettingsReadByIndexDone; -use self::settings::MsgSettingsReadByIndexReq; -use self::settings::MsgSettingsReadByIndexResp; -use self::settings::MsgSettingsReadReq; -use self::settings::MsgSettingsReadResp; -use self::settings::MsgSettingsRegister; -use self::settings::MsgSettingsRegisterResp; -use self::settings::MsgSettingsSave; -use self::settings::MsgSettingsWrite; -use self::settings::MsgSettingsWriteResp; -use self::solution_meta::MsgSolnMeta; -use self::solution_meta::MsgSolnMetaDepA; -use self::ssr::MsgSsrCodeBiases; -use self::ssr::MsgSsrGridDefinitionDepA; -use self::ssr::MsgSsrGriddedCorrection; -use self::ssr::MsgSsrGriddedCorrectionDepA; -use self::ssr::MsgSsrGriddedCorrectionNoStdDepA; -use self::ssr::MsgSsrOrbitClock; -use self::ssr::MsgSsrOrbitClockDepA; -use self::ssr::MsgSsrPhaseBiases; -use self::ssr::MsgSsrSatelliteApc; -use self::ssr::MsgSsrStecCorrection; -use self::ssr::MsgSsrStecCorrectionDepA; -use self::ssr::MsgSsrTileDefinition; -use self::system::MsgCsacTelemetry; -use self::system::MsgCsacTelemetryLabels; -use self::system::MsgDgnssStatus; -use self::system::MsgGnssTimeOffset; -use self::system::MsgGroupMeta; -use self::system::MsgHeartbeat; -use self::system::MsgInsStatus; -use self::system::MsgInsUpdates; -use self::system::MsgPpsTime; -use self::system::MsgSensorAidEvent; -use self::system::MsgStartup; -use self::system::MsgStatusReport; -use self::tracking::MsgMeasurementState; -use self::tracking::MsgTrackingIq; -use self::tracking::MsgTrackingIqDepA; -use self::tracking::MsgTrackingIqDepB; -use self::tracking::MsgTrackingState; -use self::tracking::MsgTrackingStateDepA; -use self::tracking::MsgTrackingStateDepB; -use self::tracking::MsgTrackingStateDetailedDep; -use self::tracking::MsgTrackingStateDetailedDepA; +use self::acquisition::msg_acq_result::MsgAcqResult; +use self::acquisition::msg_acq_result_dep_a::MsgAcqResultDepA; +use self::acquisition::msg_acq_result_dep_b::MsgAcqResultDepB; +use self::acquisition::msg_acq_result_dep_c::MsgAcqResultDepC; +use self::acquisition::msg_acq_sv_profile::MsgAcqSvProfile; +use self::acquisition::msg_acq_sv_profile_dep::MsgAcqSvProfileDep; +use self::bootload::msg_bootloader_handshake_dep_a::MsgBootloaderHandshakeDepA; +use self::bootload::msg_bootloader_handshake_req::MsgBootloaderHandshakeReq; +use self::bootload::msg_bootloader_handshake_resp::MsgBootloaderHandshakeResp; +use self::bootload::msg_bootloader_jump_to_app::MsgBootloaderJumpToApp; +use self::bootload::msg_nap_device_dna_req::MsgNapDeviceDnaReq; +use self::bootload::msg_nap_device_dna_resp::MsgNapDeviceDnaResp; +use self::ext_events::msg_ext_event::MsgExtEvent; +use self::file_io::msg_fileio_config_req::MsgFileioConfigReq; +use self::file_io::msg_fileio_config_resp::MsgFileioConfigResp; +use self::file_io::msg_fileio_read_dir_req::MsgFileioReadDirReq; +use self::file_io::msg_fileio_read_dir_resp::MsgFileioReadDirResp; +use self::file_io::msg_fileio_read_req::MsgFileioReadReq; +use self::file_io::msg_fileio_read_resp::MsgFileioReadResp; +use self::file_io::msg_fileio_remove::MsgFileioRemove; +use self::file_io::msg_fileio_write_req::MsgFileioWriteReq; +use self::file_io::msg_fileio_write_resp::MsgFileioWriteResp; +use self::flash::msg_flash_done::MsgFlashDone; +use self::flash::msg_flash_erase::MsgFlashErase; +use self::flash::msg_flash_program::MsgFlashProgram; +use self::flash::msg_flash_read_req::MsgFlashReadReq; +use self::flash::msg_flash_read_resp::MsgFlashReadResp; +use self::flash::msg_m25_flash_write_status::MsgM25FlashWriteStatus; +use self::flash::msg_stm_flash_lock_sector::MsgStmFlashLockSector; +use self::flash::msg_stm_flash_unlock_sector::MsgStmFlashUnlockSector; +use self::flash::msg_stm_unique_id_req::MsgStmUniqueIdReq; +use self::flash::msg_stm_unique_id_resp::MsgStmUniqueIdResp; +use self::imu::msg_imu_aux::MsgImuAux; +use self::imu::msg_imu_raw::MsgImuRaw; +use self::linux::msg_linux_cpu_state::MsgLinuxCpuState; +use self::linux::msg_linux_cpu_state_dep_a::MsgLinuxCpuStateDepA; +use self::linux::msg_linux_mem_state::MsgLinuxMemState; +use self::linux::msg_linux_mem_state_dep_a::MsgLinuxMemStateDepA; +use self::linux::msg_linux_process_fd_count::MsgLinuxProcessFdCount; +use self::linux::msg_linux_process_fd_summary::MsgLinuxProcessFdSummary; +use self::linux::msg_linux_process_socket_counts::MsgLinuxProcessSocketCounts; +use self::linux::msg_linux_process_socket_queues::MsgLinuxProcessSocketQueues; +use self::linux::msg_linux_socket_usage::MsgLinuxSocketUsage; +use self::linux::msg_linux_sys_state::MsgLinuxSysState; +use self::linux::msg_linux_sys_state_dep_a::MsgLinuxSysStateDepA; +use self::logging::msg_fwd::MsgFwd; +use self::logging::msg_log::MsgLog; +use self::logging::msg_print_dep::MsgPrintDep; +use self::mag::msg_mag_raw::MsgMagRaw; +use self::navigation::msg_age_corrections::MsgAgeCorrections; +use self::navigation::msg_baseline_ecef::MsgBaselineEcef; +use self::navigation::msg_baseline_ecef_dep_a::MsgBaselineEcefDepA; +use self::navigation::msg_baseline_heading_dep_a::MsgBaselineHeadingDepA; +use self::navigation::msg_baseline_ned::MsgBaselineNed; +use self::navigation::msg_baseline_ned_dep_a::MsgBaselineNedDepA; +use self::navigation::msg_dops::MsgDops; +use self::navigation::msg_dops_dep_a::MsgDopsDepA; +use self::navigation::msg_gps_time::MsgGpsTime; +use self::navigation::msg_gps_time_dep_a::MsgGpsTimeDepA; +use self::navigation::msg_gps_time_gnss::MsgGpsTimeGnss; +use self::navigation::msg_pos_ecef::MsgPosEcef; +use self::navigation::msg_pos_ecef_cov::MsgPosEcefCov; +use self::navigation::msg_pos_ecef_cov_gnss::MsgPosEcefCovGnss; +use self::navigation::msg_pos_ecef_dep_a::MsgPosEcefDepA; +use self::navigation::msg_pos_ecef_gnss::MsgPosEcefGnss; +use self::navigation::msg_pos_llh::MsgPosLlh; +use self::navigation::msg_pos_llh_acc::MsgPosLlhAcc; +use self::navigation::msg_pos_llh_cov::MsgPosLlhCov; +use self::navigation::msg_pos_llh_cov_gnss::MsgPosLlhCovGnss; +use self::navigation::msg_pos_llh_dep_a::MsgPosLlhDepA; +use self::navigation::msg_pos_llh_gnss::MsgPosLlhGnss; +use self::navigation::msg_protection_level::MsgProtectionLevel; +use self::navigation::msg_protection_level_dep_a::MsgProtectionLevelDepA; +use self::navigation::msg_utc_time::MsgUtcTime; +use self::navigation::msg_utc_time_gnss::MsgUtcTimeGnss; +use self::navigation::msg_vel_body::MsgVelBody; +use self::navigation::msg_vel_cog::MsgVelCog; +use self::navigation::msg_vel_ecef::MsgVelEcef; +use self::navigation::msg_vel_ecef_cov::MsgVelEcefCov; +use self::navigation::msg_vel_ecef_cov_gnss::MsgVelEcefCovGnss; +use self::navigation::msg_vel_ecef_dep_a::MsgVelEcefDepA; +use self::navigation::msg_vel_ecef_gnss::MsgVelEcefGnss; +use self::navigation::msg_vel_ned::MsgVelNed; +use self::navigation::msg_vel_ned_cov::MsgVelNedCov; +use self::navigation::msg_vel_ned_cov_gnss::MsgVelNedCovGnss; +use self::navigation::msg_vel_ned_dep_a::MsgVelNedDepA; +use self::navigation::msg_vel_ned_gnss::MsgVelNedGnss; +use self::ndb::msg_ndb_event::MsgNdbEvent; +use self::observation::msg_almanac_glo::MsgAlmanacGlo; +use self::observation::msg_almanac_glo_dep::MsgAlmanacGloDep; +use self::observation::msg_almanac_gps::MsgAlmanacGps; +use self::observation::msg_almanac_gps_dep::MsgAlmanacGpsDep; +use self::observation::msg_base_pos_ecef::MsgBasePosEcef; +use self::observation::msg_base_pos_llh::MsgBasePosLlh; +use self::observation::msg_ephemeris_bds::MsgEphemerisBds; +use self::observation::msg_ephemeris_dep_a::MsgEphemerisDepA; +use self::observation::msg_ephemeris_dep_b::MsgEphemerisDepB; +use self::observation::msg_ephemeris_dep_c::MsgEphemerisDepC; +use self::observation::msg_ephemeris_dep_d::MsgEphemerisDepD; +use self::observation::msg_ephemeris_gal::MsgEphemerisGal; +use self::observation::msg_ephemeris_gal_dep_a::MsgEphemerisGalDepA; +use self::observation::msg_ephemeris_glo::MsgEphemerisGlo; +use self::observation::msg_ephemeris_glo_dep_a::MsgEphemerisGloDepA; +use self::observation::msg_ephemeris_glo_dep_b::MsgEphemerisGloDepB; +use self::observation::msg_ephemeris_glo_dep_c::MsgEphemerisGloDepC; +use self::observation::msg_ephemeris_glo_dep_d::MsgEphemerisGloDepD; +use self::observation::msg_ephemeris_gps::MsgEphemerisGps; +use self::observation::msg_ephemeris_gps_dep_e::MsgEphemerisGpsDepE; +use self::observation::msg_ephemeris_gps_dep_f::MsgEphemerisGpsDepF; +use self::observation::msg_ephemeris_qzss::MsgEphemerisQzss; +use self::observation::msg_ephemeris_sbas::MsgEphemerisSbas; +use self::observation::msg_ephemeris_sbas_dep_a::MsgEphemerisSbasDepA; +use self::observation::msg_ephemeris_sbas_dep_b::MsgEphemerisSbasDepB; +use self::observation::msg_glo_biases::MsgGloBiases; +use self::observation::msg_gnss_capb::MsgGnssCapb; +use self::observation::msg_group_delay::MsgGroupDelay; +use self::observation::msg_group_delay_dep_a::MsgGroupDelayDepA; +use self::observation::msg_group_delay_dep_b::MsgGroupDelayDepB; +use self::observation::msg_iono::MsgIono; +use self::observation::msg_obs::MsgObs; +use self::observation::msg_obs_dep_a::MsgObsDepA; +use self::observation::msg_obs_dep_b::MsgObsDepB; +use self::observation::msg_obs_dep_c::MsgObsDepC; +use self::observation::msg_osr::MsgOsr; +use self::observation::msg_sv_az_el::MsgSvAzEl; +use self::observation::msg_sv_configuration_gps_dep::MsgSvConfigurationGpsDep; +use self::orientation::msg_angular_rate::MsgAngularRate; +use self::orientation::msg_baseline_heading::MsgBaselineHeading; +use self::orientation::msg_orient_euler::MsgOrientEuler; +use self::orientation::msg_orient_quat::MsgOrientQuat; +use self::piksi::msg_almanac::MsgAlmanac; +use self::piksi::msg_cell_modem_status::MsgCellModemStatus; +use self::piksi::msg_command_output::MsgCommandOutput; +use self::piksi::msg_command_req::MsgCommandReq; +use self::piksi::msg_command_resp::MsgCommandResp; +use self::piksi::msg_cw_results::MsgCwResults; +use self::piksi::msg_cw_start::MsgCwStart; +use self::piksi::msg_device_monitor::MsgDeviceMonitor; +use self::piksi::msg_front_end_gain::MsgFrontEndGain; +use self::piksi::msg_iar_state::MsgIarState; +use self::piksi::msg_init_base_dep::MsgInitBaseDep; +use self::piksi::msg_mask_satellite::MsgMaskSatellite; +use self::piksi::msg_mask_satellite_dep::MsgMaskSatelliteDep; +use self::piksi::msg_network_bandwidth_usage::MsgNetworkBandwidthUsage; +use self::piksi::msg_network_state_req::MsgNetworkStateReq; +use self::piksi::msg_network_state_resp::MsgNetworkStateResp; +use self::piksi::msg_reset::MsgReset; +use self::piksi::msg_reset_dep::MsgResetDep; +use self::piksi::msg_reset_filters::MsgResetFilters; +use self::piksi::msg_set_time::MsgSetTime; +use self::piksi::msg_specan::MsgSpecan; +use self::piksi::msg_specan_dep::MsgSpecanDep; +use self::piksi::msg_thread_state::MsgThreadState; +use self::piksi::msg_uart_state::MsgUartState; +use self::piksi::msg_uart_state_depa::MsgUartStateDepa; +use self::sbas::msg_sbas_raw::MsgSbasRaw; +use self::settings::msg_settings_read_by_index_done::MsgSettingsReadByIndexDone; +use self::settings::msg_settings_read_by_index_req::MsgSettingsReadByIndexReq; +use self::settings::msg_settings_read_by_index_resp::MsgSettingsReadByIndexResp; +use self::settings::msg_settings_read_req::MsgSettingsReadReq; +use self::settings::msg_settings_read_resp::MsgSettingsReadResp; +use self::settings::msg_settings_register::MsgSettingsRegister; +use self::settings::msg_settings_register_resp::MsgSettingsRegisterResp; +use self::settings::msg_settings_save::MsgSettingsSave; +use self::settings::msg_settings_write::MsgSettingsWrite; +use self::settings::msg_settings_write_resp::MsgSettingsWriteResp; +use self::solution_meta::msg_soln_meta::MsgSolnMeta; +use self::solution_meta::msg_soln_meta_dep_a::MsgSolnMetaDepA; +use self::ssr::msg_ssr_code_biases::MsgSsrCodeBiases; +use self::ssr::msg_ssr_grid_definition_dep_a::MsgSsrGridDefinitionDepA; +use self::ssr::msg_ssr_gridded_correction::MsgSsrGriddedCorrection; +use self::ssr::msg_ssr_gridded_correction_dep_a::MsgSsrGriddedCorrectionDepA; +use self::ssr::msg_ssr_gridded_correction_no_std_dep_a::MsgSsrGriddedCorrectionNoStdDepA; +use self::ssr::msg_ssr_orbit_clock::MsgSsrOrbitClock; +use self::ssr::msg_ssr_orbit_clock_dep_a::MsgSsrOrbitClockDepA; +use self::ssr::msg_ssr_phase_biases::MsgSsrPhaseBiases; +use self::ssr::msg_ssr_satellite_apc::MsgSsrSatelliteApc; +use self::ssr::msg_ssr_stec_correction::MsgSsrStecCorrection; +use self::ssr::msg_ssr_stec_correction_dep_a::MsgSsrStecCorrectionDepA; +use self::ssr::msg_ssr_tile_definition::MsgSsrTileDefinition; +use self::system::msg_csac_telemetry::MsgCsacTelemetry; +use self::system::msg_csac_telemetry_labels::MsgCsacTelemetryLabels; +use self::system::msg_dgnss_status::MsgDgnssStatus; +use self::system::msg_gnss_time_offset::MsgGnssTimeOffset; +use self::system::msg_group_meta::MsgGroupMeta; +use self::system::msg_heartbeat::MsgHeartbeat; +use self::system::msg_ins_status::MsgInsStatus; +use self::system::msg_ins_updates::MsgInsUpdates; +use self::system::msg_pps_time::MsgPpsTime; +use self::system::msg_sensor_aid_event::MsgSensorAidEvent; +use self::system::msg_startup::MsgStartup; +use self::system::msg_status_report::MsgStatusReport; +use self::tracking::msg_measurement_state::MsgMeasurementState; +use self::tracking::msg_tracking_iq::MsgTrackingIq; +use self::tracking::msg_tracking_iq_dep_a::MsgTrackingIqDepA; +use self::tracking::msg_tracking_iq_dep_b::MsgTrackingIqDepB; +use self::tracking::msg_tracking_state::MsgTrackingState; +use self::tracking::msg_tracking_state_dep_a::MsgTrackingStateDepA; +use self::tracking::msg_tracking_state_dep_b::MsgTrackingStateDepB; +use self::tracking::msg_tracking_state_detailed_dep::MsgTrackingStateDetailedDep; +use self::tracking::msg_tracking_state_detailed_dep_a::MsgTrackingStateDetailedDepA; use self::unknown::Unknown; use self::user::msg_user_data::MsgUserData; use self::vehicle::msg_odometry::MsgOdometry; diff --git a/rust/sbp/src/messages/system.rs b/rust/sbp/src/messages/system.rs index 568a18e565..74d7f2e405 100644 --- a/rust/sbp/src/messages/system.rs +++ b/rust/sbp/src/messages/system.rs @@ -22,6 +22,7 @@ pub use msg_heartbeat::MsgHeartbeat; pub use msg_ins_status::MsgInsStatus; pub use msg_ins_updates::MsgInsUpdates; pub use msg_pps_time::MsgPpsTime; +pub use msg_sensor_aid_event::MsgSensorAidEvent; pub use msg_startup::MsgStartup; pub use msg_status_report::MsgStatusReport; pub use sub_system_report::SubSystemReport; @@ -1838,129 +1839,239 @@ pub mod msg_pps_time { } } -/// Sensor state and update status data -/// -/// This diagnostic message contains state and update status information for -/// all sensors that are being used by the fusion engine. This message will be -/// generated asynchronously to the solution messages and will be emitted -/// anytime a sensor update is being processed. -/// -#[cfg_attr(feature = "serde", derive(serde::Serialize))] -#[derive(Debug, Clone)] -pub struct MsgSensorAidEvent { - /// The message sender_id - #[cfg_attr(feature = "serde", serde(skip_serializing))] - pub sender_id: Option, - /// Update timestamp in milliseconds. - #[cfg_attr(feature = "serde", serde(rename(serialize = "time")))] - pub time: u32, - /// Sensor type - #[cfg_attr(feature = "serde", serde(rename(serialize = "sensor_type")))] - pub sensor_type: u8, - /// Sensor identifier - #[cfg_attr(feature = "serde", serde(rename(serialize = "sensor_id")))] - pub sensor_id: u16, - /// Reserved for future use - #[cfg_attr(feature = "serde", serde(rename(serialize = "sensor_state")))] - pub sensor_state: u8, - /// Number of available measurements in this epoch - #[cfg_attr(feature = "serde", serde(rename(serialize = "n_available_meas")))] - pub n_available_meas: u8, - /// Number of attempted measurements in this epoch - #[cfg_attr(feature = "serde", serde(rename(serialize = "n_attempted_meas")))] - pub n_attempted_meas: u8, - /// Number of accepted measurements in this epoch - #[cfg_attr(feature = "serde", serde(rename(serialize = "n_accepted_meas")))] - pub n_accepted_meas: u8, - /// Reserved for future use - #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] - pub flags: u32, -} + /// Time uncertainty + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] + pub enum TimeUncertainty { + /// Unknown + Unknown = 0, + + /// +/- 10 milliseconds + _10Milliseconds = 1, + + /// +/- 10 microseconds + _10Microseconds = 2, + + /// < 1 microseconds + _1Microseconds = 3, + } -impl ConcreteMessage for MsgSensorAidEvent { - const MESSAGE_TYPE: u16 = 65289; - const MESSAGE_NAME: &'static str = "MSG_SENSOR_AID_EVENT"; + impl std::fmt::Display for TimeUncertainty { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TimeUncertainty::Unknown => f.write_str("Unknown"), + TimeUncertainty::_10Milliseconds => f.write_str("+/- 10 milliseconds"), + TimeUncertainty::_10Microseconds => f.write_str("+/- 10 microseconds"), + TimeUncertainty::_1Microseconds => f.write_str("< 1 microseconds"), + } + } + } + + impl TryFrom for TimeUncertainty { + type Error = u8; + fn try_from(i: u8) -> Result { + match i { + 0 => Ok(TimeUncertainty::Unknown), + 1 => Ok(TimeUncertainty::_10Milliseconds), + 2 => Ok(TimeUncertainty::_10Microseconds), + 3 => Ok(TimeUncertainty::_1Microseconds), + i => Err(i), + } + } + } } -impl SbpMessage for MsgSensorAidEvent { - fn message_name(&self) -> &'static str { - ::MESSAGE_NAME +pub mod msg_sensor_aid_event { + #![allow(unused_imports)] + + use super::*; + use crate::messages::lib::*; + + /// Sensor state and update status data + /// + /// This diagnostic message contains state and update status information for + /// all sensors that are being used by the fusion engine. This message will be + /// generated asynchronously to the solution messages and will be emitted + /// anytime a sensor update is being processed. + /// + #[cfg_attr(feature = "serde", derive(serde::Serialize))] + #[derive(Debug, Clone)] + pub struct MsgSensorAidEvent { + /// The message sender_id + #[cfg_attr(feature = "serde", serde(skip_serializing))] + pub sender_id: Option, + /// Update timestamp in milliseconds. + #[cfg_attr(feature = "serde", serde(rename(serialize = "time")))] + pub time: u32, + /// Sensor type + #[cfg_attr(feature = "serde", serde(rename(serialize = "sensor_type")))] + pub sensor_type: u8, + /// Sensor identifier + #[cfg_attr(feature = "serde", serde(rename(serialize = "sensor_id")))] + pub sensor_id: u16, + /// Reserved for future use + #[cfg_attr(feature = "serde", serde(rename(serialize = "sensor_state")))] + pub sensor_state: u8, + /// Number of available measurements in this epoch + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_available_meas")))] + pub n_available_meas: u8, + /// Number of attempted measurements in this epoch + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_attempted_meas")))] + pub n_attempted_meas: u8, + /// Number of accepted measurements in this epoch + #[cfg_attr(feature = "serde", serde(rename(serialize = "n_accepted_meas")))] + pub n_accepted_meas: u8, + /// Reserved for future use + #[cfg_attr(feature = "serde", serde(rename(serialize = "flags")))] + pub flags: u32, } - fn message_type(&self) -> u16 { - ::MESSAGE_TYPE + + impl MsgSensorAidEvent { + /// Gets the [TypeIdentifier][self::TypeIdentifier] stored in the `sensor_type` bitfield. + /// + /// Returns `Ok` if the bitrange contains a known `TypeIdentifier` variant. + /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message, + /// or because new variants of `TypeIdentifier` were added. + pub fn type_identifier(&self) -> Result { + get_bit_range!(self.sensor_type, u8, u8, 7, 0).try_into() + } + + /// Set the bitrange corresponding to the [TypeIdentifier][TypeIdentifier] of the `sensor_type` bitfield. + pub fn set_type_identifier(&mut self, type_identifier: TypeIdentifier) { + set_bit_range!(&mut self.sensor_type, type_identifier, u8, u8, 7, 0); + } } - fn sender_id(&self) -> Option { - self.sender_id + + impl ConcreteMessage for MsgSensorAidEvent { + const MESSAGE_TYPE: u16 = 65289; + const MESSAGE_NAME: &'static str = "MSG_SENSOR_AID_EVENT"; } - fn set_sender_id(&mut self, new_id: u16) { - self.sender_id = Some(new_id); + + impl SbpMessage for MsgSensorAidEvent { + 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 encoded_len(&self) -> usize { + WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + } } - fn encoded_len(&self) -> usize { - WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN + + impl TryFrom for MsgSensorAidEvent { + type Error = TryFromSbpError; + fn try_from(msg: Sbp) -> Result { + match msg { + Sbp::MsgSensorAidEvent(m) => Ok(m), + _ => Err(TryFromSbpError), + } + } } -} -impl TryFrom for MsgSensorAidEvent { - type Error = TryFromSbpError; - fn try_from(msg: Sbp) -> Result { - match msg { - Sbp::MsgSensorAidEvent(m) => Ok(m), - _ => Err(TryFromSbpError), + impl WireFormat for MsgSensorAidEvent { + const MIN_LEN: usize = ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN + + ::MIN_LEN; + fn len(&self) -> usize { + WireFormat::len(&self.time) + + WireFormat::len(&self.sensor_type) + + WireFormat::len(&self.sensor_id) + + WireFormat::len(&self.sensor_state) + + WireFormat::len(&self.n_available_meas) + + WireFormat::len(&self.n_attempted_meas) + + WireFormat::len(&self.n_accepted_meas) + + WireFormat::len(&self.flags) + } + fn write(&self, buf: &mut B) { + WireFormat::write(&self.time, buf); + WireFormat::write(&self.sensor_type, buf); + WireFormat::write(&self.sensor_id, buf); + WireFormat::write(&self.sensor_state, buf); + WireFormat::write(&self.n_available_meas, buf); + WireFormat::write(&self.n_attempted_meas, buf); + WireFormat::write(&self.n_accepted_meas, buf); + WireFormat::write(&self.flags, buf); + } + fn parse_unchecked(buf: &mut B) -> Self { + MsgSensorAidEvent { + sender_id: None, + time: WireFormat::parse_unchecked(buf), + sensor_type: WireFormat::parse_unchecked(buf), + sensor_id: WireFormat::parse_unchecked(buf), + sensor_state: WireFormat::parse_unchecked(buf), + n_available_meas: WireFormat::parse_unchecked(buf), + n_attempted_meas: WireFormat::parse_unchecked(buf), + n_accepted_meas: WireFormat::parse_unchecked(buf), + flags: WireFormat::parse_unchecked(buf), + } } } -} -impl WireFormat for MsgSensorAidEvent { - const MIN_LEN: usize = ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN - + ::MIN_LEN; - fn len(&self) -> usize { - WireFormat::len(&self.time) - + WireFormat::len(&self.sensor_type) - + WireFormat::len(&self.sensor_id) - + WireFormat::len(&self.sensor_state) - + WireFormat::len(&self.n_available_meas) - + WireFormat::len(&self.n_attempted_meas) - + WireFormat::len(&self.n_accepted_meas) - + WireFormat::len(&self.flags) - } - fn write(&self, buf: &mut B) { - WireFormat::write(&self.time, buf); - WireFormat::write(&self.sensor_type, buf); - WireFormat::write(&self.sensor_id, buf); - WireFormat::write(&self.sensor_state, buf); - WireFormat::write(&self.n_available_meas, buf); - WireFormat::write(&self.n_attempted_meas, buf); - WireFormat::write(&self.n_accepted_meas, buf); - WireFormat::write(&self.flags, buf); - } - fn parse_unchecked(buf: &mut B) -> Self { - MsgSensorAidEvent { - sender_id: None, - time: WireFormat::parse_unchecked(buf), - sensor_type: WireFormat::parse_unchecked(buf), - sensor_id: WireFormat::parse_unchecked(buf), - sensor_state: WireFormat::parse_unchecked(buf), - n_available_meas: WireFormat::parse_unchecked(buf), - n_attempted_meas: WireFormat::parse_unchecked(buf), - n_accepted_meas: WireFormat::parse_unchecked(buf), - flags: WireFormat::parse_unchecked(buf), + /// Type identifier + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] + pub enum TypeIdentifier { + /// GNSS position + GnssPosition = 0, + + /// GNSS average velocity + GnssAverageVelocity = 1, + + /// GNSS instantaneous velocity + GnssInstantaneousVelocity = 2, + + /// Wheel ticks + WheelTicks = 3, + + /// Wheel speed + WheelSpeed = 4, + + /// IMU + Imu = 5, + + /// Time differences of carrier phase + TimeDifferencesOfCarrierPhase = 6, + } + + impl std::fmt::Display for TypeIdentifier { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + TypeIdentifier::GnssPosition => f.write_str("GNSS position"), + TypeIdentifier::GnssAverageVelocity => f.write_str("GNSS average velocity"), + TypeIdentifier::GnssInstantaneousVelocity => { + f.write_str("GNSS instantaneous velocity") + } + TypeIdentifier::WheelTicks => f.write_str("Wheel ticks"), + TypeIdentifier::WheelSpeed => f.write_str("Wheel speed"), + TypeIdentifier::Imu => f.write_str("IMU"), + TypeIdentifier::TimeDifferencesOfCarrierPhase => { + f.write_str("Time differences of carrier phase") + } + } } } - impl TryFrom for TimeUncertainty { + impl TryFrom for TypeIdentifier { type Error = u8; fn try_from(i: u8) -> Result { match i { - 0 => Ok(TimeUncertainty::Unknown), - 1 => Ok(TimeUncertainty::_10Milliseconds), - 2 => Ok(TimeUncertainty::_10Microseconds), - 3 => Ok(TimeUncertainty::_1Microseconds), + 0 => Ok(TypeIdentifier::GnssPosition), + 1 => Ok(TypeIdentifier::GnssAverageVelocity), + 2 => Ok(TypeIdentifier::GnssInstantaneousVelocity), + 3 => Ok(TypeIdentifier::WheelTicks), + 4 => Ok(TypeIdentifier::WheelSpeed), + 5 => Ok(TypeIdentifier::Imu), + 6 => Ok(TypeIdentifier::TimeDifferencesOfCarrierPhase), i => Err(i), } } From 29ead594fd7c250458af64be448b8b1e747ca148 Mon Sep 17 00:00:00 2001 From: notoriaga Date: Fri, 4 Feb 2022 11:20:22 -0800 Subject: [PATCH 10/13] fix MSG_STATUS_REPORT bitrange --- spec/yaml/swiftnav/sbp/system.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/yaml/swiftnav/sbp/system.yaml b/spec/yaml/swiftnav/sbp/system.yaml index 61e075275a..98e8e5d942 100644 --- a/spec/yaml/swiftnav/sbp/system.yaml +++ b/spec/yaml/swiftnav/sbp/system.yaml @@ -201,7 +201,7 @@ definitions: type: u16 desc: SBP protocol version fields: - - 8-16: + - 8-15: desc: SBP major protocol version number - 0-7: desc: SBP minor protocol version number From 2d7dd481205567e0ee834548a1de64865ed9f360 Mon Sep 17 00:00:00 2001 From: notoriaga Date: Fri, 4 Feb 2022 11:20:28 -0800 Subject: [PATCH 11/13] add bitfield docs --- rust/sbp/src/lib.rs | 77 +++++++++++++++++++++++++++++++++ rust/sbp/src/messages/system.rs | 4 +- 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/rust/sbp/src/lib.rs b/rust/sbp/src/lib.rs index 36163d8a97..9caad6a6fa 100644 --- a/rust/sbp/src/lib.rs +++ b/rust/sbp/src/lib.rs @@ -64,6 +64,83 @@ //! process::exit(1); //! } //! } +//! +//! ``` +//! +//! # Bitfield Types +//! +//! A number of messages have fields that encode multiple values using a [bitfield](https://en.wikipedia.org/wiki/Bit_field). +//! This crate provides getters and setters on messages with these values. The getters and setters +//! have slightly different semantics that can be grouped into three categories. +//! +//! ## Enumerations +//! +//! Most bitfield members are mapped to a dataless enum. The setter accepts a variant of that enum. +//! The getter will return a variant of this enum wrapped in a `Result`. The getter returns `Ok` +//! if the bitfield member contains a known variant of the enum. Otherwise, the integral value of the +//! bitfield member is returned in the `Err` variant. This may be because of a malformed message, +//! or because you're SBP client is outdated and new variants of the enum were added. +//! +//! ``` +//! # use sbp::messages::navigation::msg_pos_llh::{FixMode, MsgPosLlh}; +//! # let msg = MsgPosLlh { +//! # sender_id: None, +//! # tow: 0, +//! # lat: 0., +//! # lon: 0., +//! # height: 0., +//! # h_accuracy: 0, +//! # v_accuracy: 0, +//! # n_sats: 0, +//! # flags: 0, +//! # }.into(); +//! let mut msg = MsgPosLlh::from(msg); +//! msg.set_fix_mode(FixMode::DeadReckoning); +//! assert_eq!(msg.fix_mode(), Ok(FixMode::DeadReckoning)); +//! ``` +//! +//! ## Integral +//! +//! Some bitfield members are represented by an integral type. In this case, the getter accepts the +//! smallest integer type that can contain the bitfield member. For example, if the bitfield member +//! spans 6 bits, the setter will accept a `u8`, and mask off any extra bits when setting the value. +//! The getter will return the integer value, again using the smallest integer type that will contain +//! the bitfield member. +//! +//! ``` +//! # use sbp::messages::system::MsgStatusReport; +//! # let msg = MsgStatusReport { +//! # sender_id: None, +//! # reporting_system: 0, +//! # sbp_version: 0, +//! # sequence: 0, +//! # uptime: 0, +//! # status: Vec::new(), +//! # }.into(); +//! let mut msg = MsgStatusReport::from(msg); +//! msg.set_sbp_major_protocol_version_number(3); +//! assert_eq!(msg.sbp_major_protocol_version_number(), 3); +//! ``` +//! +//! ## Boolean +//! +//! If the bitfield members is represented by a single bit, getters and setters use `bool`s. +//! +//! ``` +//! # use sbp::messages::navigation::MsgDops; +//! # let msg = MsgDops { +//! # sender_id: None, +//! # tow: 0, +//! # gdop: 0, +//! # pdop: 0, +//! # tdop: 0, +//! # hdop: 0, +//! # vdop: 0, +//! # flags: 0, +//! # }.into(); +//! let mut msg = MsgDops::from(msg); +//! msg.set_raim_repair_flag(true); +//! assert!(msg.raim_repair_flag()); //! ``` pub mod messages; diff --git a/rust/sbp/src/messages/system.rs b/rust/sbp/src/messages/system.rs index 74d7f2e405..596d3a050e 100644 --- a/rust/sbp/src/messages/system.rs +++ b/rust/sbp/src/messages/system.rs @@ -2321,7 +2321,7 @@ pub mod msg_status_report { /// Gets the `sbp_major_protocol_version_number` stored in `sbp_version`. pub fn sbp_major_protocol_version_number(&self) -> u8 { - get_bit_range!(self.sbp_version, u16, u8, 16, 8) + get_bit_range!(self.sbp_version, u16, u8, 15, 8) } /// Sets the `sbp_major_protocol_version_number` bitrange of `sbp_version`. @@ -2334,7 +2334,7 @@ pub mod msg_status_report { sbp_major_protocol_version_number, u16, u8, - 16, + 15, 8 ); } From b060d84c9d6c15157260678581e8806e7566241b Mon Sep 17 00:00:00 2001 From: notoriaga Date: Fri, 4 Feb 2022 11:22:19 -0800 Subject: [PATCH 12/13] gen-c --- c/include/libsbp/system_macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/include/libsbp/system_macros.h b/c/include/libsbp/system_macros.h index fe6cad067f..8121fe768d 100644 --- a/c/include/libsbp/system_macros.h +++ b/c/include/libsbp/system_macros.h @@ -247,7 +247,7 @@ #define SBP_STATUS_REPORT_SYSTEM_STARLING (0) #define SBP_STATUS_REPORT_SYSTEM_PRECISION_GNSS_MODULE (1) -#define SBP_STATUS_REPORT_SBP_MAJOR_PROTOCOL_VERSION_NUMBER_MASK (0x1ff) +#define SBP_STATUS_REPORT_SBP_MAJOR_PROTOCOL_VERSION_NUMBER_MASK (0xff) #define SBP_STATUS_REPORT_SBP_MAJOR_PROTOCOL_VERSION_NUMBER_SHIFT (8u) #define SBP_STATUS_REPORT_SBP_MAJOR_PROTOCOL_VERSION_NUMBER_GET(flags) \ ((u16)( \ From f5c0e27d9abdab56e2537d81e20c373e7a208900 Mon Sep 17 00:00:00 2001 From: notoriaga Date: Fri, 4 Feb 2022 11:51:09 -0800 Subject: [PATCH 13/13] run rust/c gen --- c/include/libsbp/version.h | 2 +- rust/sbp/Cargo.toml | 2 +- rust/sbp2json/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/c/include/libsbp/version.h b/c/include/libsbp/version.h index ce4aac8776..870cb6d554 100644 --- a/c/include/libsbp/version.h +++ b/c/include/libsbp/version.h @@ -28,7 +28,7 @@ #define SBP_PATCH_VERSION 3 /** Full SBP version string. */ -#define SBP_VERSION "4.1.3" +#define SBP_VERSION "4.1.4-alpha" /** \} */ diff --git a/rust/sbp/Cargo.toml b/rust/sbp/Cargo.toml index 80d398cb6c..17647d0b5d 100644 --- a/rust/sbp/Cargo.toml +++ b/rust/sbp/Cargo.toml @@ -7,7 +7,7 @@ [package] name = "sbp" -version = "4.1.3" +version = "4.1.4-alpha" description = "Rust native implementation of SBP (Swift Binary Protocol) for communicating with devices made by Swift Navigation" authors = ["Swift Navigation "] repository = "https://github.com/swift-nav/libsbp" diff --git a/rust/sbp2json/Cargo.toml b/rust/sbp2json/Cargo.toml index f6a16f9ff4..db666f7749 100644 --- a/rust/sbp2json/Cargo.toml +++ b/rust/sbp2json/Cargo.toml @@ -7,7 +7,7 @@ [package] name = "sbp2json" -version = "4.1.3-unreleased" +version = "4.1.4-alpha" description = "Rust native implementation of SBP (Swift Binary Protocol) to JSON conversion tools" authors = ["Swift Navigation "] edition = "2018"