From 489f2d2e6e473b2fa05c5680c96c9ad7e6cdef44 Mon Sep 17 00:00:00 2001 From: Jason Mobarak Date: Wed, 22 Sep 2021 13:47:00 -0700 Subject: [PATCH 1/7] rust: update to swiftnav 0.6.1 --- rust/sbp/Cargo.toml | 6 ++-- rust/sbp/src/lib.rs | 66 +++++++++++++++++++-------------------- rust/sbp/src/sbp_tools.rs | 2 +- rust/sbp/src/time.rs | 4 +-- 4 files changed, 39 insertions(+), 39 deletions(-) diff --git a/rust/sbp/Cargo.toml b/rust/sbp/Cargo.toml index b1daf2ab35..3af2f169b0 100644 --- a/rust/sbp/Cargo.toml +++ b/rust/sbp/Cargo.toml @@ -34,9 +34,9 @@ log = "0.4" nom = "6.0" thiserror = "1.0" -[dependencies.swiftnav-rs] +[dependencies.swiftnav] git = "https://github.com/swift-nav/swiftnav-rs" -tag = "v0.5.1" +tag = "v0.6.1" optional = true [dependencies.slotmap] @@ -65,4 +65,4 @@ version = "0.3.0" default-features = false [dev-dependencies] -serialport = "2.1.0" \ No newline at end of file +serialport = "2.1.0" diff --git a/rust/sbp/src/lib.rs b/rust/sbp/src/lib.rs index e661cd3993..65da04b5ae 100644 --- a/rust/sbp/src/lib.rs +++ b/rust/sbp/src/lib.rs @@ -162,7 +162,7 @@ pub enum FramerError { } #[cfg(feature = "swiftnav-rs")] -mod swiftnav_rs_conversions { +mod swiftnav_conversions { use std::convert::{TryFrom, TryInto}; use crate::messages; @@ -170,7 +170,7 @@ mod swiftnav_rs_conversions { #[derive(Debug, Clone, thiserror::Error)] pub enum GpsTimeError { #[error(transparent)] - InvalidGpsTime(#[from] swiftnav_rs::time::InvalidGpsTime), + InvalidGpsTime(#[from] swiftnav::time::InvalidGpsTime), #[error("Failed to convert week number to i16")] TryFromIntError(#[from] std::num::TryFromIntError), @@ -182,45 +182,45 @@ mod swiftnav_rs_conversions { } } - impl TryFrom for swiftnav_rs::time::GpsTime { - type Error = swiftnav_rs::time::InvalidGpsTime; + impl TryFrom for swiftnav::time::GpsTime { + type Error = swiftnav::time::InvalidGpsTime; fn try_from( msg: messages::gnss::GPSTime, - ) -> Result { + ) -> Result { let tow = (msg.tow as f64) * 1e-3 + (msg.ns_residual as f64) * 1e-9; - swiftnav_rs::time::GpsTime::new(msg.wn as i16, tow) + swiftnav::time::GpsTime::new(msg.wn as i16, tow) } } - impl TryFrom for swiftnav_rs::time::GpsTime { - type Error = swiftnav_rs::time::InvalidGpsTime; + impl TryFrom for swiftnav::time::GpsTime { + type Error = swiftnav::time::InvalidGpsTime; fn try_from( msg: messages::gnss::GPSTimeSec, - ) -> Result { - swiftnav_rs::time::GpsTime::new(msg.wn as i16, msg.tow as f64) + ) -> Result { + swiftnav::time::GpsTime::new(msg.wn as i16, msg.tow as f64) } } - impl TryFrom for swiftnav_rs::signal::GnssSignal { - type Error = swiftnav_rs::signal::InvalidGnssSignal; + impl TryFrom for swiftnav::signal::GnssSignal { + type Error = swiftnav::signal::InvalidGnssSignal; fn try_from( value: messages::gnss::GnssSignal, - ) -> Result + ) -> Result { - swiftnav_rs::signal::GnssSignal::new(value.sat as u16, value.code.try_into()?) + swiftnav::signal::GnssSignal::new(value.sat as u16, value.code.try_into()?) } } - impl TryFrom for swiftnav_rs::ephemeris::Ephemeris { + impl TryFrom for swiftnav::ephemeris::Ephemeris { type Error = EphemerisDecodeError; fn try_from( eph: messages::observation::MsgEphemerisGPS, - ) -> Result { - Ok(swiftnav_rs::ephemeris::Ephemeris::new( + ) -> Result { + Ok(swiftnav::ephemeris::Ephemeris::new( eph.common.sid.try_into()?, eph.common.toe.try_into()?, eph.common.ura, @@ -228,8 +228,8 @@ mod swiftnav_rs_conversions { eph.common.valid, eph.common.health_bits, 0, - swiftnav_rs::ephemeris::EphemerisTerms::new_kepler( - swiftnav_rs::signal::Constellation::Gps, + swiftnav::ephemeris::EphemerisTerms::new_kepler( + swiftnav::signal::Constellation::Gps, [eph.tgd, 0.], eph.c_rc as f64, eph.c_rs as f64, @@ -257,13 +257,13 @@ mod swiftnav_rs_conversions { } } - impl TryFrom for swiftnav_rs::ephemeris::Ephemeris { + impl TryFrom for swiftnav::ephemeris::Ephemeris { type Error = EphemerisDecodeError; fn try_from( eph: messages::observation::MsgEphemerisGal, - ) -> Result { - Ok(swiftnav_rs::ephemeris::Ephemeris::new( + ) -> Result { + Ok(swiftnav::ephemeris::Ephemeris::new( eph.common.sid.try_into()?, eph.common.toe.try_into()?, eph.common.ura, @@ -271,8 +271,8 @@ mod swiftnav_rs_conversions { eph.common.valid, eph.common.health_bits, eph.source, - swiftnav_rs::ephemeris::EphemerisTerms::new_kepler( - swiftnav_rs::signal::Constellation::Gal, + swiftnav::ephemeris::EphemerisTerms::new_kepler( + swiftnav::signal::Constellation::Gal, [eph.bgd_e1e5a, eph.bgd_e1e5b], eph.c_rc as f64, eph.c_rs as f64, @@ -303,26 +303,26 @@ mod swiftnav_rs_conversions { #[derive(Debug, Copy, Clone, PartialOrd, PartialEq, thiserror::Error)] pub enum EphemerisDecodeError { #[error(transparent)] - InvalidTime(#[from] swiftnav_rs::time::InvalidGpsTime), + InvalidTime(#[from] swiftnav::time::InvalidGpsTime), #[error(transparent)] - InvalidSignal(#[from] swiftnav_rs::signal::InvalidGnssSignal), + InvalidSignal(#[from] swiftnav::signal::InvalidGnssSignal), } impl TryFrom - for swiftnav_rs::navmeas::NavigationMeasurement + for swiftnav::navmeas::NavigationMeasurement { - type Error = swiftnav_rs::signal::InvalidGnssSignal; + type Error = swiftnav::signal::InvalidGnssSignal; fn try_from( observation: messages::observation::PackedObsContent, ) -> Result< - swiftnav_rs::navmeas::NavigationMeasurement, - swiftnav_rs::signal::InvalidGnssSignal, + swiftnav::navmeas::NavigationMeasurement, + swiftnav::signal::InvalidGnssSignal, > { - let mut measurement = swiftnav_rs::navmeas::NavigationMeasurement::new(); + let mut measurement = swiftnav::navmeas::NavigationMeasurement::new(); - measurement.set_lock_time(swiftnav_rs::navmeas::decode_lock_time(observation.lock)); + measurement.set_lock_time(swiftnav::navmeas::decode_lock_time(observation.lock)); measurement.set_sid(observation.sid.try_into()?); // A CN0 of 0 is considered invalid if observation.cn0 != 0 { @@ -337,7 +337,7 @@ mod swiftnav_rs_conversions { } if observation.flags & 0x80 != 0 { measurement.set_flags( - measurement.get_flags() | swiftnav_rs::navmeas::NAV_MEAS_FLAG_RAIM_EXCLUSION, + measurement.get_flags() | swiftnav::navmeas::NAV_MEAS_FLAG_RAIM_EXCLUSION, ); } diff --git a/rust/sbp/src/sbp_tools.rs b/rust/sbp/src/sbp_tools.rs index f327b70ba2..b5e29cfe8d 100644 --- a/rust/sbp/src/sbp_tools.rs +++ b/rust/sbp/src/sbp_tools.rs @@ -1,5 +1,5 @@ #[cfg(feature = "swiftnav-rs")] -use swiftnav_rs::time::GpsTime; +use swiftnav::time::GpsTime; #[cfg(feature = "swiftnav-rs")] use crate::{ diff --git a/rust/sbp/src/time.rs b/rust/sbp/src/time.rs index c25c519cb8..260706a28f 100644 --- a/rust/sbp/src/time.rs +++ b/rust/sbp/src/time.rs @@ -1,6 +1,6 @@ -pub use swiftnav_rs::time::GpsTime; +pub use swiftnav::time::GpsTime; -pub use crate::swiftnav_rs_conversions::GpsTimeError; +pub use crate::swiftnav_conversions::GpsTimeError; #[derive(Debug, Clone, Copy)] pub enum MessageTime { From 1ccda911c816c62096d5f7ee5f321ed2b1b67c90 Mon Sep 17 00:00:00 2001 From: Jason Mobarak Date: Wed, 22 Sep 2021 13:50:33 -0700 Subject: [PATCH 2/7] cargo fmt --- rust/sbp/src/lib.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/rust/sbp/src/lib.rs b/rust/sbp/src/lib.rs index 65da04b5ae..9975047038 100644 --- a/rust/sbp/src/lib.rs +++ b/rust/sbp/src/lib.rs @@ -208,8 +208,7 @@ mod swiftnav_conversions { fn try_from( value: messages::gnss::GnssSignal, - ) -> Result - { + ) -> Result { swiftnav::signal::GnssSignal::new(value.sat as u16, value.code.try_into()?) } } @@ -309,17 +308,13 @@ mod swiftnav_conversions { InvalidSignal(#[from] swiftnav::signal::InvalidGnssSignal), } - impl TryFrom - for swiftnav::navmeas::NavigationMeasurement - { + impl TryFrom for swiftnav::navmeas::NavigationMeasurement { type Error = swiftnav::signal::InvalidGnssSignal; fn try_from( observation: messages::observation::PackedObsContent, - ) -> Result< - swiftnav::navmeas::NavigationMeasurement, - swiftnav::signal::InvalidGnssSignal, - > { + ) -> Result + { let mut measurement = swiftnav::navmeas::NavigationMeasurement::new(); measurement.set_lock_time(swiftnav::navmeas::decode_lock_time(observation.lock)); From bacfc658267ad5fb44902c879e40852292e6fcc5 Mon Sep 17 00:00:00 2001 From: Jason Mobarak Date: Wed, 22 Sep 2021 14:14:53 -0700 Subject: [PATCH 3/7] update feature name --- generator/sbpg/targets/rust.py | 2 +- rust/sbp/src/lib.rs | 4 +- rust/sbp/src/messages/ext_events.rs | 2 +- rust/sbp/src/messages/imu.rs | 2 +- rust/sbp/src/messages/mag.rs | 2 +- rust/sbp/src/messages/mod.rs | 4 +- rust/sbp/src/messages/navigation.rs | 74 +++++++++++++------------- rust/sbp/src/messages/observation.rs | 10 ++-- rust/sbp/src/messages/orientation.rs | 8 +-- rust/sbp/src/messages/sbas.rs | 2 +- rust/sbp/src/messages/solution_meta.rs | 2 +- rust/sbp/src/messages/system.rs | 2 +- rust/sbp/src/messages/vehicle.rs | 4 +- rust/sbp/src/sbp_tools.rs | 12 ++--- 14 files changed, 65 insertions(+), 65 deletions(-) diff --git a/generator/sbpg/targets/rust.py b/generator/sbpg/targets/rust.py index 93a016fe1a..a957f060a6 100644 --- a/generator/sbpg/targets/rust.py +++ b/generator/sbpg/targets/rust.py @@ -203,7 +203,7 @@ def gen_ret(): ret = gen_ret() return f""" - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time(&self) -> Option> {{ {body} {ret} diff --git a/rust/sbp/src/lib.rs b/rust/sbp/src/lib.rs index 9975047038..f8099d5237 100644 --- a/rust/sbp/src/lib.rs +++ b/rust/sbp/src/lib.rs @@ -9,7 +9,7 @@ pub mod messages; pub(crate) mod parser; pub mod sbp_tools; pub mod serialize; -#[cfg(feature = "swiftnav-rs")] +#[cfg(feature = "swiftnav")] pub mod time; use std::{fmt, result}; @@ -161,7 +161,7 @@ pub enum FramerError { NoSenderId, } -#[cfg(feature = "swiftnav-rs")] +#[cfg(feature = "swiftnav")] mod swiftnav_conversions { use std::convert::{TryFrom, TryInto}; diff --git a/rust/sbp/src/messages/ext_events.rs b/rust/sbp/src/messages/ext_events.rs index 6c8bd59797..2da912c55e 100644 --- a/rust/sbp/src/messages/ext_events.rs +++ b/rust/sbp/src/messages/ext_events.rs @@ -90,7 +90,7 @@ impl super::SBPMessage for MsgExtEvent { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { diff --git a/rust/sbp/src/messages/imu.rs b/rust/sbp/src/messages/imu.rs index 6ab5d190bb..cd2cf0b01b 100644 --- a/rust/sbp/src/messages/imu.rs +++ b/rust/sbp/src/messages/imu.rs @@ -195,7 +195,7 @@ impl super::SBPMessage for MsgImuRaw { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { diff --git a/rust/sbp/src/messages/mag.rs b/rust/sbp/src/messages/mag.rs index 5600d13486..39a195437a 100644 --- a/rust/sbp/src/messages/mag.rs +++ b/rust/sbp/src/messages/mag.rs @@ -88,7 +88,7 @@ impl super::SBPMessage for MsgMagRaw { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { diff --git a/rust/sbp/src/messages/mod.rs b/rust/sbp/src/messages/mod.rs index ddd3935635..0363766a39 100644 --- a/rust/sbp/src/messages/mod.rs +++ b/rust/sbp/src/messages/mod.rs @@ -244,7 +244,7 @@ pub trait SBPMessage: SbpSerialize { fn set_sender_id(&mut self, new_id: u16); fn to_frame(&self) -> std::result::Result, crate::FramerError>; fn write_frame(&self, buf: &mut Vec) -> std::result::Result<(), crate::FramerError>; - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -2749,7 +2749,7 @@ impl crate::SBPMessage for SBP { } } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { diff --git a/rust/sbp/src/messages/navigation.rs b/rust/sbp/src/messages/navigation.rs index 9743207563..972e2e391b 100644 --- a/rust/sbp/src/messages/navigation.rs +++ b/rust/sbp/src/messages/navigation.rs @@ -165,7 +165,7 @@ impl super::SBPMessage for MsgAgeCorrections { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -278,7 +278,7 @@ impl super::SBPMessage for MsgBaselineECEF { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -401,7 +401,7 @@ impl super::SBPMessage for MsgBaselineECEFDepA { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -514,7 +514,7 @@ impl super::SBPMessage for MsgBaselineHeadingDepA { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -636,7 +636,7 @@ impl super::SBPMessage for MsgBaselineNED { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -766,7 +766,7 @@ impl super::SBPMessage for MsgBaselineNEDDepA { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -891,7 +891,7 @@ impl super::SBPMessage for MsgDops { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -1009,7 +1009,7 @@ impl super::SBPMessage for MsgDopsDepA { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -1129,7 +1129,7 @@ impl super::SBPMessage for MsgGPSTime { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -1249,7 +1249,7 @@ impl super::SBPMessage for MsgGPSTimeDepA { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -1369,7 +1369,7 @@ impl super::SBPMessage for MsgGPSTimeGnss { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -1493,7 +1493,7 @@ impl super::SBPMessage for MsgPosECEF { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -1635,7 +1635,7 @@ impl super::SBPMessage for MsgPosECEFCov { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -1787,7 +1787,7 @@ impl super::SBPMessage for MsgPosECEFCovGnss { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -1923,7 +1923,7 @@ impl super::SBPMessage for MsgPosECEFDepA { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -2049,7 +2049,7 @@ impl super::SBPMessage for MsgPosECEFGnss { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -2178,7 +2178,7 @@ impl super::SBPMessage for MsgPosLLH { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -2335,7 +2335,7 @@ impl super::SBPMessage for MsgPosLLHAcc { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -2489,7 +2489,7 @@ impl super::SBPMessage for MsgPosLLHCov { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -2641,7 +2641,7 @@ impl super::SBPMessage for MsgPosLLHCovGnss { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -2780,7 +2780,7 @@ impl super::SBPMessage for MsgPosLLHDepA { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -2911,7 +2911,7 @@ impl super::SBPMessage for MsgPosLLHGnss { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -3079,7 +3079,7 @@ impl super::SBPMessage for MsgProtectionLevel { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -3233,7 +3233,7 @@ impl super::SBPMessage for MsgProtectionLevelDepA { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -3361,7 +3361,7 @@ impl super::SBPMessage for MsgUtcTime { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -3493,7 +3493,7 @@ impl super::SBPMessage for MsgUtcTimeGnss { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -3640,7 +3640,7 @@ impl super::SBPMessage for MsgVelBody { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -3772,7 +3772,7 @@ impl super::SBPMessage for MsgVelECEF { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -3909,7 +3909,7 @@ impl super::SBPMessage for MsgVelECEFCov { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -4056,7 +4056,7 @@ impl super::SBPMessage for MsgVelECEFCovGnss { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -4188,7 +4188,7 @@ impl super::SBPMessage for MsgVelECEFDepA { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -4310,7 +4310,7 @@ impl super::SBPMessage for MsgVelECEFGnss { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -4436,7 +4436,7 @@ impl super::SBPMessage for MsgVelNED { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -4578,7 +4578,7 @@ impl super::SBPMessage for MsgVelNEDCov { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -4728,7 +4728,7 @@ impl super::SBPMessage for MsgVelNEDCovGnss { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -4864,7 +4864,7 @@ impl super::SBPMessage for MsgVelNEDDepA { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -4992,7 +4992,7 @@ impl super::SBPMessage for MsgVelNEDGnss { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { diff --git a/rust/sbp/src/messages/observation.rs b/rust/sbp/src/messages/observation.rs index 8befee65c8..c0b7201113 100644 --- a/rust/sbp/src/messages/observation.rs +++ b/rust/sbp/src/messages/observation.rs @@ -5103,7 +5103,7 @@ impl super::SBPMessage for MsgObs { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -5202,7 +5202,7 @@ impl super::SBPMessage for MsgObsDepA { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -5304,7 +5304,7 @@ impl super::SBPMessage for MsgObsDepB { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -5408,7 +5408,7 @@ impl super::SBPMessage for MsgObsDepC { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -5508,7 +5508,7 @@ impl super::SBPMessage for MsgOsr { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { diff --git a/rust/sbp/src/messages/orientation.rs b/rust/sbp/src/messages/orientation.rs index 0b7d4d9af0..dfe7f122dc 100644 --- a/rust/sbp/src/messages/orientation.rs +++ b/rust/sbp/src/messages/orientation.rs @@ -95,7 +95,7 @@ impl super::SBPMessage for MsgAngularRate { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -206,7 +206,7 @@ impl super::SBPMessage for MsgBaselineHeading { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -328,7 +328,7 @@ impl super::SBPMessage for MsgOrientEuler { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -464,7 +464,7 @@ impl super::SBPMessage for MsgOrientQuat { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { diff --git a/rust/sbp/src/messages/sbas.rs b/rust/sbp/src/messages/sbas.rs index 7fa903a4ef..058033051a 100644 --- a/rust/sbp/src/messages/sbas.rs +++ b/rust/sbp/src/messages/sbas.rs @@ -86,7 +86,7 @@ impl super::SBPMessage for MsgSbasRaw { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { diff --git a/rust/sbp/src/messages/solution_meta.rs b/rust/sbp/src/messages/solution_meta.rs index 95ffd49d34..8497fe6a2a 100644 --- a/rust/sbp/src/messages/solution_meta.rs +++ b/rust/sbp/src/messages/solution_meta.rs @@ -214,7 +214,7 @@ impl super::SBPMessage for MsgSolnMeta { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { diff --git a/rust/sbp/src/messages/system.rs b/rust/sbp/src/messages/system.rs index 72c8eb05f3..7ed3c13904 100644 --- a/rust/sbp/src/messages/system.rs +++ b/rust/sbp/src/messages/system.rs @@ -718,7 +718,7 @@ impl super::SBPMessage for MsgInsUpdates { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { diff --git a/rust/sbp/src/messages/vehicle.rs b/rust/sbp/src/messages/vehicle.rs index 41d1499030..788667b242 100644 --- a/rust/sbp/src/messages/vehicle.rs +++ b/rust/sbp/src/messages/vehicle.rs @@ -91,7 +91,7 @@ impl super::SBPMessage for MsgOdometry { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { @@ -209,7 +209,7 @@ impl super::SBPMessage for MsgWheeltick { crate::write_frame(self, frame) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time( &self, ) -> Option> { diff --git a/rust/sbp/src/sbp_tools.rs b/rust/sbp/src/sbp_tools.rs index b5e29cfe8d..8e2afd40fe 100644 --- a/rust/sbp/src/sbp_tools.rs +++ b/rust/sbp/src/sbp_tools.rs @@ -1,7 +1,7 @@ -#[cfg(feature = "swiftnav-rs")] +#[cfg(feature = "swiftnav")] use swiftnav::time::GpsTime; -#[cfg(feature = "swiftnav-rs")] +#[cfg(feature = "swiftnav")] use crate::{ messages::SBPMessage, time::{GpsTimeError, MessageTime, RoverTime}, @@ -41,7 +41,7 @@ pub trait SBPTools: Iterator { HandleErrorsIter::new(self, on_err) } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn with_rover_time(self) -> RoverTimeIter where Self: Sized, @@ -107,13 +107,13 @@ where } } -#[cfg(feature = "swiftnav-rs")] +#[cfg(feature = "swiftnav")] pub struct RoverTimeIter { messages: I, clock: Option, } -#[cfg(feature = "swiftnav-rs")] +#[cfg(feature = "swiftnav")] impl RoverTimeIter where I: Iterator, @@ -149,7 +149,7 @@ where } } -#[cfg(feature = "swiftnav-rs")] +#[cfg(feature = "swiftnav")] impl Iterator for RoverTimeIter where I: Iterator, From a87cb8fb846fecc9e577aff0e2b7b9d9b6279f2c Mon Sep 17 00:00:00 2001 From: Jason Mobarak Date: Wed, 22 Sep 2021 14:19:15 -0700 Subject: [PATCH 4/7] fix-up method name --- rust/sbp/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/sbp/src/lib.rs b/rust/sbp/src/lib.rs index f8099d5237..5ba79abb44 100644 --- a/rust/sbp/src/lib.rs +++ b/rust/sbp/src/lib.rs @@ -332,7 +332,7 @@ mod swiftnav_conversions { } if observation.flags & 0x80 != 0 { measurement.set_flags( - measurement.get_flags() | swiftnav::navmeas::NAV_MEAS_FLAG_RAIM_EXCLUSION, + measurement.flags() | swiftnav::navmeas::NAV_MEAS_FLAG_RAIM_EXCLUSION, ); } From 7a89883a965302fbf30cc1005e10f166537c0bf0 Mon Sep 17 00:00:00 2001 From: Jason Mobarak Date: Wed, 22 Sep 2021 14:39:34 -0700 Subject: [PATCH 5/7] update templates --- generator/sbpg/targets/resources/sbp-cargo.toml | 4 ++-- generator/sbpg/targets/resources/sbp_messages_mod.rs | 4 ++-- rust/sbp/Cargo.toml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/generator/sbpg/targets/resources/sbp-cargo.toml b/generator/sbpg/targets/resources/sbp-cargo.toml index 4c14b7d93a..4f5f5fdb81 100644 --- a/generator/sbpg/targets/resources/sbp-cargo.toml +++ b/generator/sbpg/targets/resources/sbp-cargo.toml @@ -34,9 +34,9 @@ log = "0.4" nom = "6.0" thiserror = "1.0" -[dependencies.swiftnav-rs] +[dependencies.swiftnav] git = "https://github.com/swift-nav/swiftnav-rs" -tag = "v0.5.1" +tag = "v0.6.1" optional = true [dependencies.slotmap] diff --git a/generator/sbpg/targets/resources/sbp_messages_mod.rs b/generator/sbpg/targets/resources/sbp_messages_mod.rs index d777a6423c..41d9b4175e 100644 --- a/generator/sbpg/targets/resources/sbp_messages_mod.rs +++ b/generator/sbpg/targets/resources/sbp_messages_mod.rs @@ -31,7 +31,7 @@ pub trait SBPMessage: SbpSerialize { fn set_sender_id(&mut self, new_id: u16); fn to_frame(&self) -> std::result::Result, crate::FramerError>; fn write_frame(&self, buf: &mut Vec) -> std::result::Result<(), crate::FramerError>; - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time(&self) -> Option> { None } @@ -156,7 +156,7 @@ impl crate::SBPMessage for SBP { } } - #[cfg(feature = "swiftnav-rs")] + #[cfg(feature = "swiftnav")] fn gps_time(&self) -> Option> { match self { ((*- for m in msgs *)) diff --git a/rust/sbp/Cargo.toml b/rust/sbp/Cargo.toml index 3af2f169b0..30a63e1c0b 100644 --- a/rust/sbp/Cargo.toml +++ b/rust/sbp/Cargo.toml @@ -65,4 +65,4 @@ version = "0.3.0" default-features = false [dev-dependencies] -serialport = "2.1.0" +serialport = "2.1.0" \ No newline at end of file From df0da9a60815583bffd797386854b0e7b9d00a00 Mon Sep 17 00:00:00 2001 From: Jason Mobarak Date: Wed, 22 Sep 2021 15:04:20 -0700 Subject: [PATCH 6/7] pin serde_json see https://github.com/serde-rs/json/pull/801 --- generator/sbpg/targets/resources/sbp-cargo.toml | 2 +- generator/sbpg/targets/resources/sbp2json-cargo.toml | 4 ++-- rust/sbp/Cargo.toml | 4 ++-- rust/sbp2json/Cargo.toml | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/generator/sbpg/targets/resources/sbp-cargo.toml b/generator/sbpg/targets/resources/sbp-cargo.toml index 4f5f5fdb81..519d6481bc 100644 --- a/generator/sbpg/targets/resources/sbp-cargo.toml +++ b/generator/sbpg/targets/resources/sbp-cargo.toml @@ -49,7 +49,7 @@ features = ["derive"] optional = true [dependencies.serde_json] -version = "1" +version = "=1.0.67" optional = true [dependencies.base64] diff --git a/generator/sbpg/targets/resources/sbp2json-cargo.toml b/generator/sbpg/targets/resources/sbp2json-cargo.toml index 218c0ecbfc..beeef028d0 100644 --- a/generator/sbpg/targets/resources/sbp2json-cargo.toml +++ b/generator/sbpg/targets/resources/sbp2json-cargo.toml @@ -17,7 +17,7 @@ features = ["json"] [dependencies] env_logger = "0.8" -serde_json = "1.0" +serde_json = "=1.0.67" structopt = "0.3" [dependencies.dencode] @@ -31,7 +31,7 @@ jemallocator = "0.3" sha2 = "0.8" hex = "0.4" assert_cmd = "1.0.1" -serde_json = "1" +serde_json = "=1.0.67" assert-json-diff = "1.1.0" [profile.release] diff --git a/rust/sbp/Cargo.toml b/rust/sbp/Cargo.toml index 30a63e1c0b..d280260a8e 100644 --- a/rust/sbp/Cargo.toml +++ b/rust/sbp/Cargo.toml @@ -49,7 +49,7 @@ features = ["derive"] optional = true [dependencies.serde_json] -version = "1" +version = "=1.0.67" optional = true [dependencies.base64] @@ -65,4 +65,4 @@ version = "0.3.0" default-features = false [dev-dependencies] -serialport = "2.1.0" \ No newline at end of file +serialport = "2.1.0" diff --git a/rust/sbp2json/Cargo.toml b/rust/sbp2json/Cargo.toml index b1b0b3fe3e..4f9d0578b5 100644 --- a/rust/sbp2json/Cargo.toml +++ b/rust/sbp2json/Cargo.toml @@ -17,7 +17,7 @@ features = ["json"] [dependencies] env_logger = "0.8" -serde_json = "1.0" +serde_json = "=1.0.67" structopt = "0.3" [dependencies.dencode] @@ -31,7 +31,7 @@ jemallocator = "0.3" sha2 = "0.8" hex = "0.4" assert_cmd = "1.0.1" -serde_json = "1" +serde_json = "=1.0.67" assert-json-diff = "1.1.0" [profile.release] @@ -52,4 +52,4 @@ path = "src/bin/json2sbp.rs" [[bin]] name = "json2json" -path = "src/bin/json2json.rs" \ No newline at end of file +path = "src/bin/json2json.rs" From d380158b16e18ef2345b09f503b13368f414501c Mon Sep 17 00:00:00 2001 From: Jason Mobarak Date: Wed, 22 Sep 2021 15:33:59 -0700 Subject: [PATCH 7/7] use newer json assert lib --- generator/sbpg/targets/resources/sbp-cargo.toml | 2 +- generator/sbpg/targets/resources/sbp2json-cargo.toml | 6 +++--- rust/sbp/Cargo.toml | 4 ++-- rust/sbp2json/Cargo.toml | 8 ++++---- rust/sbp2json/tests/common/mod.rs | 6 +++++- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/generator/sbpg/targets/resources/sbp-cargo.toml b/generator/sbpg/targets/resources/sbp-cargo.toml index 519d6481bc..94cd4633e9 100644 --- a/generator/sbpg/targets/resources/sbp-cargo.toml +++ b/generator/sbpg/targets/resources/sbp-cargo.toml @@ -49,7 +49,7 @@ features = ["derive"] optional = true [dependencies.serde_json] -version = "=1.0.67" +version = "1.0" optional = true [dependencies.base64] diff --git a/generator/sbpg/targets/resources/sbp2json-cargo.toml b/generator/sbpg/targets/resources/sbp2json-cargo.toml index beeef028d0..69b42e4f2d 100644 --- a/generator/sbpg/targets/resources/sbp2json-cargo.toml +++ b/generator/sbpg/targets/resources/sbp2json-cargo.toml @@ -17,7 +17,7 @@ features = ["json"] [dependencies] env_logger = "0.8" -serde_json = "=1.0.67" +serde_json = "1.0" structopt = "0.3" [dependencies.dencode] @@ -31,8 +31,8 @@ jemallocator = "0.3" sha2 = "0.8" hex = "0.4" assert_cmd = "1.0.1" -serde_json = "=1.0.67" -assert-json-diff = "1.1.0" +serde_json = "1.0" +assert-json-diff = "2.0" [profile.release] lto = true diff --git a/rust/sbp/Cargo.toml b/rust/sbp/Cargo.toml index d280260a8e..20d7e12a7f 100644 --- a/rust/sbp/Cargo.toml +++ b/rust/sbp/Cargo.toml @@ -49,7 +49,7 @@ features = ["derive"] optional = true [dependencies.serde_json] -version = "=1.0.67" +version = "1.0" optional = true [dependencies.base64] @@ -65,4 +65,4 @@ version = "0.3.0" default-features = false [dev-dependencies] -serialport = "2.1.0" +serialport = "2.1.0" \ No newline at end of file diff --git a/rust/sbp2json/Cargo.toml b/rust/sbp2json/Cargo.toml index 4f9d0578b5..6a1639cccc 100644 --- a/rust/sbp2json/Cargo.toml +++ b/rust/sbp2json/Cargo.toml @@ -17,7 +17,7 @@ features = ["json"] [dependencies] env_logger = "0.8" -serde_json = "=1.0.67" +serde_json = "1.0" structopt = "0.3" [dependencies.dencode] @@ -31,8 +31,8 @@ jemallocator = "0.3" sha2 = "0.8" hex = "0.4" assert_cmd = "1.0.1" -serde_json = "=1.0.67" -assert-json-diff = "1.1.0" +serde_json = "1.0" +assert-json-diff = "2.0" [profile.release] lto = true @@ -52,4 +52,4 @@ path = "src/bin/json2sbp.rs" [[bin]] name = "json2json" -path = "src/bin/json2json.rs" +path = "src/bin/json2json.rs" \ No newline at end of file diff --git a/rust/sbp2json/tests/common/mod.rs b/rust/sbp2json/tests/common/mod.rs index d8f1c5cc3f..6ab7b0ab18 100644 --- a/rust/sbp2json/tests/common/mod.rs +++ b/rust/sbp2json/tests/common/mod.rs @@ -8,6 +8,7 @@ use std::{ }; use assert_cmd::{assert::OutputAssertExt, cargo::CommandCargoExt}; +use assert_json_diff::{assert_json_matches_no_panic, CompareMode, Config, NumericMode}; use serde_json::{Deserializer, Value}; use sha2::{Digest, Sha256}; @@ -234,7 +235,10 @@ fn json_file_equals(a: File, b: File) -> bool { let wrong = a .iter() .zip(b.iter()) - .map(|(a, b)| assert_json_diff::assert_json_eq_no_panic(a, b)) + .map(|(a, b)| { + let config = Config::new(CompareMode::Strict).numeric_mode(NumericMode::AssumeFloat); + assert_json_matches_no_panic(a, b, config) + }) .enumerate() .find(|(_, res)| res.is_err());