Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions generator/sbpg/targets/resources/sbp-cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -49,7 +49,7 @@ features = ["derive"]
optional = true

[dependencies.serde_json]
version = "1"
version = "1.0"
optional = true

[dependencies.base64]
Expand Down
4 changes: 2 additions & 2 deletions generator/sbpg/targets/resources/sbp2json-cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jemallocator = "0.3"
sha2 = "0.8"
hex = "0.4"
assert_cmd = "1.0.1"
serde_json = "1"
assert-json-diff = "1.1.0"
serde_json = "1.0"
assert-json-diff = "2.0"

[profile.release]
lto = true
Expand Down
4 changes: 2 additions & 2 deletions generator/sbpg/targets/resources/sbp_messages_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub trait SBPMessage: SbpSerialize {
fn set_sender_id(&mut self, new_id: u16);
fn to_frame(&self) -> std::result::Result<Vec<u8>, crate::FramerError>;
fn write_frame(&self, buf: &mut Vec<u8>) -> std::result::Result<(), crate::FramerError>;
#[cfg(feature = "swiftnav-rs")]
#[cfg(feature = "swiftnav")]
fn gps_time(&self) -> Option<std::result::Result<crate::time::MessageTime, crate::time::GpsTimeError>> {
None
}
Expand Down Expand Up @@ -156,7 +156,7 @@ impl crate::SBPMessage for SBP {
}
}

#[cfg(feature = "swiftnav-rs")]
#[cfg(feature = "swiftnav")]
fn gps_time(&self) -> Option<std::result::Result<crate::time::MessageTime, crate::time::GpsTimeError>> {
match self {
((*- for m in msgs *))
Expand Down
2 changes: 1 addition & 1 deletion generator/sbpg/targets/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def gen_ret():
ret = gen_ret()

return f"""
#[cfg(feature = "swiftnav-rs")]
#[cfg(feature = "swiftnav")]
fn gps_time(&self) -> Option<std::result::Result<crate::time::MessageTime, crate::time::GpsTimeError>> {{
{body}
{ret}
Expand Down
6 changes: 3 additions & 3 deletions rust/sbp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -49,7 +49,7 @@ features = ["derive"]
optional = true

[dependencies.serde_json]
version = "1"
version = "1.0"
optional = true

[dependencies.base64]
Expand Down
75 changes: 35 additions & 40 deletions rust/sbp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -161,16 +161,16 @@ pub enum FramerError {
NoSenderId,
}

#[cfg(feature = "swiftnav-rs")]
mod swiftnav_rs_conversions {
#[cfg(feature = "swiftnav")]
mod swiftnav_conversions {
use std::convert::{TryFrom, TryInto};

use crate::messages;

#[derive(Debug, Clone, thiserror::Error)]
pub enum GpsTimeError {
#[error(transparent)]
InvalidGpsTime(#[from] swiftnav_rs::time::InvalidGpsTime),
InvalidGpsTime(#[from] swiftnav::time::InvalidGpsTime),

#[error("Failed to convert week number to i16")]
TryFromIntError(#[from] std::num::TryFromIntError),
Expand All @@ -182,54 +182,53 @@ mod swiftnav_rs_conversions {
}
}

impl TryFrom<messages::gnss::GPSTime> for swiftnav_rs::time::GpsTime {
type Error = swiftnav_rs::time::InvalidGpsTime;
impl TryFrom<messages::gnss::GPSTime> for swiftnav::time::GpsTime {
type Error = swiftnav::time::InvalidGpsTime;

fn try_from(
msg: messages::gnss::GPSTime,
) -> Result<swiftnav_rs::time::GpsTime, swiftnav_rs::time::InvalidGpsTime> {
) -> Result<swiftnav::time::GpsTime, swiftnav::time::InvalidGpsTime> {
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<messages::gnss::GPSTimeSec> for swiftnav_rs::time::GpsTime {
type Error = swiftnav_rs::time::InvalidGpsTime;
impl TryFrom<messages::gnss::GPSTimeSec> for swiftnav::time::GpsTime {
type Error = swiftnav::time::InvalidGpsTime;

fn try_from(
msg: messages::gnss::GPSTimeSec,
) -> Result<swiftnav_rs::time::GpsTime, swiftnav_rs::time::InvalidGpsTime> {
swiftnav_rs::time::GpsTime::new(msg.wn as i16, msg.tow as f64)
) -> Result<swiftnav::time::GpsTime, swiftnav::time::InvalidGpsTime> {
swiftnav::time::GpsTime::new(msg.wn as i16, msg.tow as f64)
}
}

impl TryFrom<messages::gnss::GnssSignal> for swiftnav_rs::signal::GnssSignal {
type Error = swiftnav_rs::signal::InvalidGnssSignal;
impl TryFrom<messages::gnss::GnssSignal> for swiftnav::signal::GnssSignal {
type Error = swiftnav::signal::InvalidGnssSignal;

fn try_from(
value: messages::gnss::GnssSignal,
) -> Result<swiftnav_rs::signal::GnssSignal, swiftnav_rs::signal::InvalidGnssSignal>
{
swiftnav_rs::signal::GnssSignal::new(value.sat as u16, value.code.try_into()?)
) -> Result<swiftnav::signal::GnssSignal, swiftnav::signal::InvalidGnssSignal> {
swiftnav::signal::GnssSignal::new(value.sat as u16, value.code.try_into()?)
}
}

impl TryFrom<messages::observation::MsgEphemerisGPS> for swiftnav_rs::ephemeris::Ephemeris {
impl TryFrom<messages::observation::MsgEphemerisGPS> for swiftnav::ephemeris::Ephemeris {
type Error = EphemerisDecodeError;

fn try_from(
eph: messages::observation::MsgEphemerisGPS,
) -> Result<swiftnav_rs::ephemeris::Ephemeris, EphemerisDecodeError> {
Ok(swiftnav_rs::ephemeris::Ephemeris::new(
) -> Result<swiftnav::ephemeris::Ephemeris, EphemerisDecodeError> {
Ok(swiftnav::ephemeris::Ephemeris::new(
eph.common.sid.try_into()?,
eph.common.toe.try_into()?,
eph.common.ura,
eph.common.fit_interval,
eph.common.valid,
eph.common.health_bits,
0,
swiftnav_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,
Expand Down Expand Up @@ -257,22 +256,22 @@ mod swiftnav_rs_conversions {
}
}

impl TryFrom<messages::observation::MsgEphemerisGal> for swiftnav_rs::ephemeris::Ephemeris {
impl TryFrom<messages::observation::MsgEphemerisGal> for swiftnav::ephemeris::Ephemeris {
type Error = EphemerisDecodeError;

fn try_from(
eph: messages::observation::MsgEphemerisGal,
) -> Result<swiftnav_rs::ephemeris::Ephemeris, EphemerisDecodeError> {
Ok(swiftnav_rs::ephemeris::Ephemeris::new(
) -> Result<swiftnav::ephemeris::Ephemeris, EphemerisDecodeError> {
Ok(swiftnav::ephemeris::Ephemeris::new(
eph.common.sid.try_into()?,
eph.common.toe.try_into()?,
eph.common.ura,
eph.common.fit_interval,
eph.common.valid,
eph.common.health_bits,
eph.source,
swiftnav_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,
Expand Down Expand Up @@ -303,26 +302,22 @@ 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<messages::observation::PackedObsContent>
for swiftnav_rs::navmeas::NavigationMeasurement
{
type Error = swiftnav_rs::signal::InvalidGnssSignal;
impl TryFrom<messages::observation::PackedObsContent> for swiftnav::navmeas::NavigationMeasurement {
type Error = swiftnav::signal::InvalidGnssSignal;

fn try_from(
observation: messages::observation::PackedObsContent,
) -> Result<
swiftnav_rs::navmeas::NavigationMeasurement,
swiftnav_rs::signal::InvalidGnssSignal,
> {
let mut measurement = swiftnav_rs::navmeas::NavigationMeasurement::new();
) -> Result<swiftnav::navmeas::NavigationMeasurement, swiftnav::signal::InvalidGnssSignal>
{
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 {
Expand All @@ -337,7 +332,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.flags() | swiftnav::navmeas::NAV_MEAS_FLAG_RAIM_EXCLUSION,
);
}

Expand Down
2 changes: 1 addition & 1 deletion rust/sbp/src/messages/ext_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::result::Result<crate::time::MessageTime, crate::time::GpsTimeError>> {
Expand Down
2 changes: 1 addition & 1 deletion rust/sbp/src/messages/imu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::result::Result<crate::time::MessageTime, crate::time::GpsTimeError>> {
Expand Down
2 changes: 1 addition & 1 deletion rust/sbp/src/messages/mag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::result::Result<crate::time::MessageTime, crate::time::GpsTimeError>> {
Expand Down
4 changes: 2 additions & 2 deletions rust/sbp/src/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ pub trait SBPMessage: SbpSerialize {
fn set_sender_id(&mut self, new_id: u16);
fn to_frame(&self) -> std::result::Result<Vec<u8>, crate::FramerError>;
fn write_frame(&self, buf: &mut Vec<u8>) -> std::result::Result<(), crate::FramerError>;
#[cfg(feature = "swiftnav-rs")]
#[cfg(feature = "swiftnav")]
fn gps_time(
&self,
) -> Option<std::result::Result<crate::time::MessageTime, crate::time::GpsTimeError>> {
Expand Down Expand Up @@ -2749,7 +2749,7 @@ impl crate::SBPMessage for SBP {
}
}

#[cfg(feature = "swiftnav-rs")]
#[cfg(feature = "swiftnav")]
fn gps_time(
&self,
) -> Option<std::result::Result<crate::time::MessageTime, crate::time::GpsTimeError>> {
Expand Down
Loading