Skip to content

Commit

Permalink
[IOTE-2][IOTE-326] Add local timestamp week rollover flag
Browse files Browse the repository at this point in the history
  • Loading branch information
jakalm committed Mar 15, 2024
1 parent 0a3878f commit 29a05ba
Show file tree
Hide file tree
Showing 18 changed files with 133 additions and 16 deletions.
2 changes: 1 addition & 1 deletion c/include/libsbp/legacy/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ typedef struct SBP_ATTR_PACKED SBP_DEPRECATED {
s32 milliseconds; /**< Milliseconds portion of the time offset [ms] */
s16 microseconds; /**< Microseconds portion of the time offset [microseconds]
*/
u8 flags; /**< Status flags (reserved) */
u8 flags; /**< Status flags */
} msg_gnss_time_offset_t;

/** Local time at detection of PPS pulse
Expand Down
2 changes: 1 addition & 1 deletion c/include/libsbp/system/MSG_GNSS_TIME_OFFSET.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ typedef struct {
s16 microseconds;

/**
* Status flags (reserved)
* Status flags
*/
u8 flags;
} sbp_msg_gnss_time_offset_t;
Expand Down
41 changes: 41 additions & 0 deletions c/include/libsbp/system_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,47 @@
#define SBP_MSG_INS_UPDATES_ENCODED_LEN 10u

#define SBP_MSG_GNSS_TIME_OFFSET 0xFF07
#define SBP_GNSS_TIME_OFFSET_RESERVED_SET_TO_ZERO_MASK (0x7fu)
#define SBP_GNSS_TIME_OFFSET_RESERVED_SET_TO_ZERO_SHIFT (1u)
#define SBP_GNSS_TIME_OFFSET_RESERVED_SET_TO_ZERO_GET(flags) \
((u8)((u8)((flags) >> SBP_GNSS_TIME_OFFSET_RESERVED_SET_TO_ZERO_SHIFT) & \
SBP_GNSS_TIME_OFFSET_RESERVED_SET_TO_ZERO_MASK))
#define SBP_GNSS_TIME_OFFSET_RESERVED_SET_TO_ZERO_SET(flags, val) \
do { \
(flags) = (u8)( \
(flags & (~(SBP_GNSS_TIME_OFFSET_RESERVED_SET_TO_ZERO_MASK \
<< SBP_GNSS_TIME_OFFSET_RESERVED_SET_TO_ZERO_SHIFT))) | \
(((val) & (SBP_GNSS_TIME_OFFSET_RESERVED_SET_TO_ZERO_MASK)) \
<< (SBP_GNSS_TIME_OFFSET_RESERVED_SET_TO_ZERO_SHIFT))); \
} while (0)

#define SBP_GNSS_TIME_OFFSET_ALIGNED_WITH_LOCAL_TIMESTAMP_WEEK_ROLLOVER_MASK \
(0x1u)
#define SBP_GNSS_TIME_OFFSET_ALIGNED_WITH_LOCAL_TIMESTAMP_WEEK_ROLLOVER_SHIFT \
(0u)
#define SBP_GNSS_TIME_OFFSET_ALIGNED_WITH_LOCAL_TIMESTAMP_WEEK_ROLLOVER_GET( \
flags) \
((u8)( \
(u8)( \
(flags) >> \
SBP_GNSS_TIME_OFFSET_ALIGNED_WITH_LOCAL_TIMESTAMP_WEEK_ROLLOVER_SHIFT) & \
SBP_GNSS_TIME_OFFSET_ALIGNED_WITH_LOCAL_TIMESTAMP_WEEK_ROLLOVER_MASK))
#define SBP_GNSS_TIME_OFFSET_ALIGNED_WITH_LOCAL_TIMESTAMP_WEEK_ROLLOVER_SET( \
flags, val) \
do { \
(flags) = (u8)( \
(flags & \
(~(SBP_GNSS_TIME_OFFSET_ALIGNED_WITH_LOCAL_TIMESTAMP_WEEK_ROLLOVER_MASK \
<< SBP_GNSS_TIME_OFFSET_ALIGNED_WITH_LOCAL_TIMESTAMP_WEEK_ROLLOVER_SHIFT))) | \
(((val) & \
(SBP_GNSS_TIME_OFFSET_ALIGNED_WITH_LOCAL_TIMESTAMP_WEEK_ROLLOVER_MASK)) \
<< (SBP_GNSS_TIME_OFFSET_ALIGNED_WITH_LOCAL_TIMESTAMP_WEEK_ROLLOVER_SHIFT))); \
} while (0)

#define SBP_GNSS_TIME_OFFSET_ALIGNED_WITH_LOCAL_TIMESTAMP_WEEK_ROLLOVER_NOT_AFFECTED_BY_LOCAL_TIMESTAMP_WEEK_ROLLOVER \
(0)
#define SBP_GNSS_TIME_OFFSET_ALIGNED_WITH_LOCAL_TIMESTAMP_WEEK_ROLLOVER_WEEK_NUMBER_INCREMENTED_ON_LOCAL_TIMESTAMP_WEEK_ROLLOVER \
(1)
/**
* Encoded length of sbp_msg_gnss_time_offset_t (V4 API) and
* msg_gnss_time_offset_t (legacy API)
Expand Down
2 changes: 1 addition & 1 deletion c/include/libsbp/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#define SBP_PATCH_VERSION 6

/** Full SBP version string. */
#define SBP_VERSION "5.0.6"
#define SBP_VERSION "5.0.7-alpha"

/** Is this a staging branch? */
#define SBP_STAGING 0
Expand Down
Binary file modified docs/sbp.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion haskell/sbp.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sbp
version: 5.0.6
version: 5.0.7-alpha
synopsis: SwiftNav's SBP Library
homepage: https://github.com/swift-nav/libsbp
license: MIT
Expand Down
2 changes: 1 addition & 1 deletion haskell/src/SwiftNav/SBP/System.hs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ data MsgGnssTimeOffset = MsgGnssTimeOffset
, _msgGnssTimeOffset_microseconds :: !Int16
-- ^ Microseconds portion of the time offset
, _msgGnssTimeOffset_flags :: !Word8
-- ^ Status flags (reserved)
-- ^ Status flags
} deriving ( Show, Read, Eq )

instance Binary MsgGnssTimeOffset where
Expand Down
2 changes: 1 addition & 1 deletion java/src/com/swiftnav/sbp/system/MsgGnssTimeOffset.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class MsgGnssTimeOffset extends SBPMessage {
/** Microseconds portion of the time offset */
public int microseconds;

/** Status flags (reserved) */
/** Status flags */
public int flags;

public MsgGnssTimeOffset(int sender) {
Expand Down
2 changes: 1 addition & 1 deletion javascript/sbp/RELEASE-VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.6
5.0.7-alpha
2 changes: 1 addition & 1 deletion javascript/sbp/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ MsgInsUpdates.prototype.fieldSpec.push(['zerovel', 'writeUInt8', 1]);
* @field weeks number (signed 16-bit int, 2 bytes) Weeks portion of the time offset
* @field milliseconds number (signed 32-bit int, 4 bytes) Milliseconds portion of the time offset
* @field microseconds number (signed 16-bit int, 2 bytes) Microseconds portion of the time offset
* @field flags number (unsigned 8-bit int, 1 byte) Status flags (reserved)
* @field flags number (unsigned 8-bit int, 1 byte) Status flags
*
* @param sbp An SBP object with a payload to be decoded.
*/
Expand Down
2 changes: 1 addition & 1 deletion kaitai/ksy/sbp.ksy
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
#
# Kaitai Struct definition file for Swift Binary Protocol 5.0.6-alpha
# Kaitai Struct definition file for Swift Binary Protocol 5.0.7-alpha
#
# Automatically generated with generate.py. Do not hand edit!

Expand Down
2 changes: 1 addition & 1 deletion kaitai/ksy/system.ksy
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ types:
type: s2
- id: flags
doc: |
Status flags (reserved)
Status flags
type: u1

msg_pps_time:
Expand Down
2 changes: 1 addition & 1 deletion python/sbp/RELEASE-VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.6
5.0.7-alpha
2 changes: 1 addition & 1 deletion python/sbp/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ class MsgGnssTimeOffset(SBP):
microseconds : int
Microseconds portion of the time offset
flags : int
Status flags (reserved)
Status flags
sender : int
Optional sender ID, defaults to SENDER_ID (see sbp/msg.py).
Expand Down
2 changes: 1 addition & 1 deletion rust/sbp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

[package]
name = "sbp"
version = "5.0.6"
version = "5.0.7-alpha"
description = "Rust native implementation of SBP (Swift Binary Protocol) for communicating with devices made by Swift Navigation"
authors = ["Swift Navigation <[email protected]>"]
repository = "https://github.com/swift-nav/libsbp"
Expand Down
70 changes: 69 additions & 1 deletion rust/sbp/src/messages/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,49 @@ pub mod msg_gnss_time_offset {
/// Microseconds portion of the time offset
#[cfg_attr(feature = "serde", serde(rename = "microseconds"))]
pub microseconds: i16,
/// Status flags (reserved)
/// Status flags
#[cfg_attr(feature = "serde", serde(rename = "flags"))]
pub flags: u8,
}

impl MsgGnssTimeOffset {
/// 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, 1)
}

/// 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, 1);
}

/// Gets the [AlignedWithLocalTimestampWeekRollover][self::AlignedWithLocalTimestampWeekRollover] stored in the `flags` bitfield.
///
/// Returns `Ok` if the bitrange contains a known `AlignedWithLocalTimestampWeekRollover` 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 `AlignedWithLocalTimestampWeekRollover` were added.
pub fn aligned_with_local_timestamp_week_rollover(
&self,
) -> Result<AlignedWithLocalTimestampWeekRollover, u8> {
get_bit_range!(self.flags, u8, u8, 0, 0).try_into()
}

/// Set the bitrange corresponding to the [AlignedWithLocalTimestampWeekRollover][AlignedWithLocalTimestampWeekRollover] of the `flags` bitfield.
pub fn set_aligned_with_local_timestamp_week_rollover(
&mut self,
aligned_with_local_timestamp_week_rollover: AlignedWithLocalTimestampWeekRollover,
) {
set_bit_range!(
&mut self.flags,
aligned_with_local_timestamp_week_rollover,
u8,
u8,
0,
0
);
}
}

impl ConcreteMessage for MsgGnssTimeOffset {
const MESSAGE_TYPE: u16 = 65287;
const MESSAGE_NAME: &'static str = "MSG_GNSS_TIME_OFFSET";
Expand Down Expand Up @@ -478,6 +516,36 @@ pub mod msg_gnss_time_offset {
}
}
}

/// Aligned with local timestamp week rollover
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum AlignedWithLocalTimestampWeekRollover {
/// Not affected by local timestamp week rollover
NotAffectedByLocalTimestampWeekRollover = 0,

/// Week number incremented on local timestamp week rollover
WeekNumberIncrementedOnLocalTimestampWeekRollover = 1,
}

impl std::fmt::Display for AlignedWithLocalTimestampWeekRollover {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
AlignedWithLocalTimestampWeekRollover::NotAffectedByLocalTimestampWeekRollover => f.write_str("Not affected by local timestamp week rollover"),
AlignedWithLocalTimestampWeekRollover::WeekNumberIncrementedOnLocalTimestampWeekRollover => f.write_str("Week number incremented on local timestamp week rollover"),
}
}
}

impl TryFrom<u8> for AlignedWithLocalTimestampWeekRollover {
type Error = u8;
fn try_from(i: u8) -> Result<Self, u8> {
match i {
0 => Ok( AlignedWithLocalTimestampWeekRollover :: NotAffectedByLocalTimestampWeekRollover ),
1 => Ok( AlignedWithLocalTimestampWeekRollover :: WeekNumberIncrementedOnLocalTimestampWeekRollover ),
i => Err(i),
}
}
}
}

pub mod msg_group_meta {
Expand Down
2 changes: 1 addition & 1 deletion rust/sbp2json/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

[package]
name = "sbp2json"
version = "5.0.6-unreleased"
version = "5.0.7-alpha"
repository = "https://github.com/swift-nav/libsbp"
description = "Rust native implementation of SBP (Swift Binary Protocol) to JSON conversion tools"
authors = ["Swift Navigation <[email protected]>"]
Expand Down
10 changes: 9 additions & 1 deletion spec/yaml/swiftnav/sbp/system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,15 @@ definitions:
desc: Microseconds portion of the time offset
- flags:
type: u8
desc: Status flags (reserved)
desc: Status flags
fields:
- 1-7:
desc: Reserved, set to zero
- 0:
desc: Aligned with local timestamp week rollover
values:
- 0: Not affected by local timestamp week rollover
- 1: Week number incremented on local timestamp week rollover

- MSG_PPS_TIME:
id: 0xFF08
Expand Down

0 comments on commit 29a05ba

Please sign in to comment.