Skip to content

Commit

Permalink
rust: check time source for MsgGpsTime (#1375)
Browse files Browse the repository at this point in the history
# Description

@swift-nav/devinfra

<!-- Changes proposed in this PR -->

# API compatibility

Does this change introduce a API compatibility risk?

<!-- Provide a short explanation why or why not -->

## API compatibility plan

If the above is "Yes", please detail the compatibility (or migration)
plan:

<!-- Provide a short explanation plan here -->

# JIRA Reference

https://swift-nav.atlassian.net/browse/BOARD-XXXX
  • Loading branch information
notoriaga committed Nov 13, 2023
1 parent 28a1089 commit 12f7c44
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions generator/sbpg/targets/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
BASE_TIME_MSGS = ["MSG_OBS", "MSG_OSR", "MSG_SSR"]

CUSTOM_GPS_TIME_MSGS = {
"MSG_GPS_TIME": """
if !matches!(self.time_source(), Ok(TimeSource::GnssSolution) | Ok(TimeSource::Propagated)) {
return None;
}
""".strip() + GPS_TIME,
"MSG_IMU_RAW": """
const IMU_RAW_TIME_STATUS_MASK: u32 = (1 << 30) | (1 << 31);
if self.tow & IMU_RAW_TIME_STATUS_MASK != 0 {
Expand Down
6 changes: 6 additions & 0 deletions rust/sbp/src/messages/navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1888,6 +1888,12 @@ pub mod msg_gps_time {

#[cfg(feature = "swiftnav")]
fn gps_time(&self) -> Option<std::result::Result<time::MessageTime, time::GpsTimeError>> {
if !matches!(
self.time_source(),
Ok(TimeSource::GnssSolution) | Ok(TimeSource::Propagated)
) {
return None;
}
let tow_s = (self.tow as f64) / 1000.0;
#[allow(clippy::useless_conversion)]
let wn: i16 = match self.wn.try_into() {
Expand Down

0 comments on commit 12f7c44

Please sign in to comment.