Skip to content

Commit 957af03

Browse files
Add description for constellation identifier to bounds messages [OC-1087] (#1407)
1 parent 3f933a2 commit 957af03

File tree

3 files changed

+217
-0
lines changed

3 files changed

+217
-0
lines changed

c/include/libsbp/ssr_macros.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,22 @@
495495
#define SBP_ORBIT_CLOCK_BOUND_ENCODED_LEN 9u
496496

497497
#define SBP_MSG_SSR_ORBIT_CLOCK_BOUNDS 0x05DE
498+
#define SBP_SSR_ORBIT_CLOCK_BOUNDS__MASK (0xffu)
499+
#define SBP_SSR_ORBIT_CLOCK_BOUNDS__SHIFT (0u)
500+
#define SBP_SSR_ORBIT_CLOCK_BOUNDS__GET(flags) \
501+
((u8)((u8)((flags) >> SBP_SSR_ORBIT_CLOCK_BOUNDS__SHIFT) & \
502+
SBP_SSR_ORBIT_CLOCK_BOUNDS__MASK))
503+
#define SBP_SSR_ORBIT_CLOCK_BOUNDS__SET(flags, val) \
504+
do { \
505+
(flags) = (u8)((flags & (~(SBP_SSR_ORBIT_CLOCK_BOUNDS__MASK \
506+
<< SBP_SSR_ORBIT_CLOCK_BOUNDS__SHIFT))) | \
507+
(((val) & (SBP_SSR_ORBIT_CLOCK_BOUNDS__MASK)) \
508+
<< (SBP_SSR_ORBIT_CLOCK_BOUNDS__SHIFT))); \
509+
} while (0)
510+
511+
#define SBP_SSR_ORBIT_CLOCK_BOUNDS_GPS (0)
512+
#define SBP_SSR_ORBIT_CLOCK_BOUNDS_BDS (3)
513+
#define SBP_SSR_ORBIT_CLOCK_BOUNDS_GAL (5)
498514
/**
499515
* The maximum number of items that can be stored in
500516
* sbp_msg_ssr_orbit_clock_bounds_t::orbit_clock_bounds (V4 API) or
@@ -525,6 +541,22 @@
525541
#define SBP_CODE_PHASE_BIASES_SAT_SIG_ENCODED_LEN 6u
526542

527543
#define SBP_MSG_SSR_CODE_PHASE_BIASES_BOUNDS 0x05EC
544+
#define SBP_SSR_CODE_PHASE_BIASES_BOUNDS__MASK (0xffu)
545+
#define SBP_SSR_CODE_PHASE_BIASES_BOUNDS__SHIFT (0u)
546+
#define SBP_SSR_CODE_PHASE_BIASES_BOUNDS__GET(flags) \
547+
((u8)((u8)((flags) >> SBP_SSR_CODE_PHASE_BIASES_BOUNDS__SHIFT) & \
548+
SBP_SSR_CODE_PHASE_BIASES_BOUNDS__MASK))
549+
#define SBP_SSR_CODE_PHASE_BIASES_BOUNDS__SET(flags, val) \
550+
do { \
551+
(flags) = (u8)((flags & (~(SBP_SSR_CODE_PHASE_BIASES_BOUNDS__MASK \
552+
<< SBP_SSR_CODE_PHASE_BIASES_BOUNDS__SHIFT))) | \
553+
(((val) & (SBP_SSR_CODE_PHASE_BIASES_BOUNDS__MASK)) \
554+
<< (SBP_SSR_CODE_PHASE_BIASES_BOUNDS__SHIFT))); \
555+
} while (0)
556+
557+
#define SBP_SSR_CODE_PHASE_BIASES_BOUNDS_GPS (0)
558+
#define SBP_SSR_CODE_PHASE_BIASES_BOUNDS_BDS (3)
559+
#define SBP_SSR_CODE_PHASE_BIASES_BOUNDS_GAL (5)
528560
/**
529561
* The maximum number of items that can be stored in
530562
* sbp_msg_ssr_code_phase_biases_bounds_t::satellites_signals (V4 API) or
@@ -555,6 +587,23 @@
555587
#define SBP_ORBIT_CLOCK_BOUND_DEGRADATION_ENCODED_LEN 8u
556588

557589
#define SBP_MSG_SSR_ORBIT_CLOCK_BOUNDS_DEGRADATION 0x05DF
590+
#define SBP_SSR_ORBIT_CLOCK_BOUNDS_DEGRADATION__MASK (0xffu)
591+
#define SBP_SSR_ORBIT_CLOCK_BOUNDS_DEGRADATION__SHIFT (0u)
592+
#define SBP_SSR_ORBIT_CLOCK_BOUNDS_DEGRADATION__GET(flags) \
593+
((u8)((u8)((flags) >> SBP_SSR_ORBIT_CLOCK_BOUNDS_DEGRADATION__SHIFT) & \
594+
SBP_SSR_ORBIT_CLOCK_BOUNDS_DEGRADATION__MASK))
595+
#define SBP_SSR_ORBIT_CLOCK_BOUNDS_DEGRADATION__SET(flags, val) \
596+
do { \
597+
(flags) = \
598+
(u8)((flags & (~(SBP_SSR_ORBIT_CLOCK_BOUNDS_DEGRADATION__MASK \
599+
<< SBP_SSR_ORBIT_CLOCK_BOUNDS_DEGRADATION__SHIFT))) | \
600+
(((val) & (SBP_SSR_ORBIT_CLOCK_BOUNDS_DEGRADATION__MASK)) \
601+
<< (SBP_SSR_ORBIT_CLOCK_BOUNDS_DEGRADATION__SHIFT))); \
602+
} while (0)
603+
604+
#define SBP_SSR_ORBIT_CLOCK_BOUNDS_DEGRADATION_GPS (0)
605+
#define SBP_SSR_ORBIT_CLOCK_BOUNDS_DEGRADATION_BDS (3)
606+
#define SBP_SSR_ORBIT_CLOCK_BOUNDS_DEGRADATION_GAL (5)
558607
/**
559608
* Encoded length of sbp_msg_ssr_orbit_clock_bounds_degradation_t (V4 API) and
560609
* msg_ssr_orbit_clock_bounds_degradation_t (legacy API)

rust/sbp/src/messages/ssr.rs

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,22 @@ pub mod msg_ssr_code_phase_biases_bounds {
608608
pub satellites_signals: Vec<CodePhaseBiasesSatSig>,
609609
}
610610

611+
impl MsgSsrCodePhaseBiasesBounds {
612+
/// Gets the [ConstId][self::ConstId] stored in the `const_id` bitfield.
613+
///
614+
/// Returns `Ok` if the bitrange contains a known `ConstId` variant.
615+
/// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
616+
/// or because new variants of `ConstId` were added.
617+
pub fn const_id(&self) -> Result<ConstId, u8> {
618+
get_bit_range!(self.const_id, u8, u8, 7, 0).try_into()
619+
}
620+
621+
/// Set the bitrange corresponding to the [ConstId][ConstId] of the `const_id` bitfield.
622+
pub fn set_const_id(&mut self, const_id: ConstId) {
623+
set_bit_range!(&mut self.const_id, const_id, u8, u8, 7, 0);
624+
}
625+
}
626+
611627
impl ConcreteMessage for MsgSsrCodePhaseBiasesBounds {
612628
const MESSAGE_TYPE: u16 = 1516;
613629
const MESSAGE_NAME: &'static str = "MSG_SSR_CODE_PHASE_BIASES_BOUNDS";
@@ -684,6 +700,40 @@ pub mod msg_ssr_code_phase_biases_bounds {
684700
}
685701
}
686702
}
703+
704+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
705+
pub enum ConstId {
706+
/// GPS
707+
Gps = 0,
708+
709+
/// BDS
710+
Bds = 3,
711+
712+
/// GAL
713+
Gal = 5,
714+
}
715+
716+
impl std::fmt::Display for ConstId {
717+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
718+
match self {
719+
ConstId::Gps => f.write_str("GPS"),
720+
ConstId::Bds => f.write_str("BDS"),
721+
ConstId::Gal => f.write_str("GAL"),
722+
}
723+
}
724+
}
725+
726+
impl TryFrom<u8> for ConstId {
727+
type Error = u8;
728+
fn try_from(i: u8) -> Result<Self, u8> {
729+
match i {
730+
0 => Ok(ConstId::Gps),
731+
3 => Ok(ConstId::Bds),
732+
5 => Ok(ConstId::Gal),
733+
i => Err(i),
734+
}
735+
}
736+
}
687737
}
688738

689739
pub mod msg_ssr_gridded_correction {
@@ -1490,6 +1540,22 @@ pub mod msg_ssr_orbit_clock_bounds {
14901540
pub orbit_clock_bounds: Vec<OrbitClockBound>,
14911541
}
14921542

1543+
impl MsgSsrOrbitClockBounds {
1544+
/// Gets the [ConstId][self::ConstId] stored in the `const_id` bitfield.
1545+
///
1546+
/// Returns `Ok` if the bitrange contains a known `ConstId` variant.
1547+
/// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
1548+
/// or because new variants of `ConstId` were added.
1549+
pub fn const_id(&self) -> Result<ConstId, u8> {
1550+
get_bit_range!(self.const_id, u8, u8, 7, 0).try_into()
1551+
}
1552+
1553+
/// Set the bitrange corresponding to the [ConstId][ConstId] of the `const_id` bitfield.
1554+
pub fn set_const_id(&mut self, const_id: ConstId) {
1555+
set_bit_range!(&mut self.const_id, const_id, u8, u8, 7, 0);
1556+
}
1557+
}
1558+
14931559
impl ConcreteMessage for MsgSsrOrbitClockBounds {
14941560
const MESSAGE_TYPE: u16 = 1502;
14951561
const MESSAGE_NAME: &'static str = "MSG_SSR_ORBIT_CLOCK_BOUNDS";
@@ -1566,6 +1632,40 @@ pub mod msg_ssr_orbit_clock_bounds {
15661632
}
15671633
}
15681634
}
1635+
1636+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1637+
pub enum ConstId {
1638+
/// GPS
1639+
Gps = 0,
1640+
1641+
/// BDS
1642+
Bds = 3,
1643+
1644+
/// GAL
1645+
Gal = 5,
1646+
}
1647+
1648+
impl std::fmt::Display for ConstId {
1649+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1650+
match self {
1651+
ConstId::Gps => f.write_str("GPS"),
1652+
ConstId::Bds => f.write_str("BDS"),
1653+
ConstId::Gal => f.write_str("GAL"),
1654+
}
1655+
}
1656+
}
1657+
1658+
impl TryFrom<u8> for ConstId {
1659+
type Error = u8;
1660+
fn try_from(i: u8) -> Result<Self, u8> {
1661+
match i {
1662+
0 => Ok(ConstId::Gps),
1663+
3 => Ok(ConstId::Bds),
1664+
5 => Ok(ConstId::Gal),
1665+
i => Err(i),
1666+
}
1667+
}
1668+
}
15691669
}
15701670

15711671
pub mod msg_ssr_orbit_clock_bounds_degradation {
@@ -1601,6 +1701,22 @@ pub mod msg_ssr_orbit_clock_bounds_degradation {
16011701
pub orbit_clock_bounds_degradation: OrbitClockBoundDegradation,
16021702
}
16031703

1704+
impl MsgSsrOrbitClockBoundsDegradation {
1705+
/// Gets the [ConstId][self::ConstId] stored in the `const_id` bitfield.
1706+
///
1707+
/// Returns `Ok` if the bitrange contains a known `ConstId` variant.
1708+
/// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
1709+
/// or because new variants of `ConstId` were added.
1710+
pub fn const_id(&self) -> Result<ConstId, u8> {
1711+
get_bit_range!(self.const_id, u8, u8, 7, 0).try_into()
1712+
}
1713+
1714+
/// Set the bitrange corresponding to the [ConstId][ConstId] of the `const_id` bitfield.
1715+
pub fn set_const_id(&mut self, const_id: ConstId) {
1716+
set_bit_range!(&mut self.const_id, const_id, u8, u8, 7, 0);
1717+
}
1718+
}
1719+
16041720
impl ConcreteMessage for MsgSsrOrbitClockBoundsDegradation {
16051721
const MESSAGE_TYPE: u16 = 1503;
16061722
const MESSAGE_NAME: &'static str = "MSG_SSR_ORBIT_CLOCK_BOUNDS_DEGRADATION";
@@ -1677,6 +1793,40 @@ pub mod msg_ssr_orbit_clock_bounds_degradation {
16771793
}
16781794
}
16791795
}
1796+
1797+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1798+
pub enum ConstId {
1799+
/// GPS
1800+
Gps = 0,
1801+
1802+
/// BDS
1803+
Bds = 3,
1804+
1805+
/// GAL
1806+
Gal = 5,
1807+
}
1808+
1809+
impl std::fmt::Display for ConstId {
1810+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1811+
match self {
1812+
ConstId::Gps => f.write_str("GPS"),
1813+
ConstId::Bds => f.write_str("BDS"),
1814+
ConstId::Gal => f.write_str("GAL"),
1815+
}
1816+
}
1817+
}
1818+
1819+
impl TryFrom<u8> for ConstId {
1820+
type Error = u8;
1821+
fn try_from(i: u8) -> Result<Self, u8> {
1822+
match i {
1823+
0 => Ok(ConstId::Gps),
1824+
3 => Ok(ConstId::Bds),
1825+
5 => Ok(ConstId::Gal),
1826+
i => Err(i),
1827+
}
1828+
}
1829+
}
16801830
}
16811831

16821832
pub mod msg_ssr_orbit_clock_dep_a {

spec/yaml/swiftnav/sbp/ssr.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,12 @@ definitions:
12671267
- const_id:
12681268
type: u8
12691269
desc: Constellation ID to which the SVs belong.
1270+
fields:
1271+
- 0-7:
1272+
values:
1273+
- 0: GPS
1274+
- 3: BDS
1275+
- 5: GAL
12701276
- n_sats:
12711277
type: u8
12721278
desc: Number of satellites.
@@ -1328,6 +1334,12 @@ definitions:
13281334
- const_id:
13291335
type: u8
13301336
desc: Constellation ID to which the SVs belong.
1337+
fields:
1338+
- 0-7:
1339+
values:
1340+
- 0: GPS
1341+
- 3: BDS
1342+
- 5: GAL
13311343
- n_sats_signals:
13321344
type: u8
13331345
desc: Number of satellite-signal couples.
@@ -1403,6 +1415,12 @@ definitions:
14031415
- const_id:
14041416
type: u8
14051417
desc: Constellation ID to which the SVs belong.
1418+
fields:
1419+
- 0-7:
1420+
values:
1421+
- 0: GPS
1422+
- 3: BDS
1423+
- 5: GAL
14061424
- sat_bitmask:
14071425
type: u64
14081426
desc: >

0 commit comments

Comments
 (0)