Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

packets.rs: introduce NavClock and TimTos #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
111 changes: 110 additions & 1 deletion ublox/src/ubx_packets/packets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,28 @@ struct NavVelNed {
course_heading_accuracy_estimate: u32,
}

/// Navigation clock solution,
/// current receiver clock bias and drift estimates
#[ubx_packet_recv]
#[ubx(class = 0x01, id = 0x22, fixed_payload_len = 20)]
struct NavClock {
/// GPS time of week, in s
#[ubx(map_type = f64, scale = 1e-3)]
itow: u32,
/// Receiver clock bias (offset) in s
#[ubx(map_type = f64, scale = 1.0E-9)]
clk_bias: i32,
/// Clock drift (offset variations) [s/s]
#[ubx(map_type = f64, scale = 1.0E-9)]
clk_drift: i32,
/// time accuracy estimate
#[ubx(map_type = f64, scale = 1.0E-9)]
time_acc: u32,
/// frequency accuracy estimate [s/s]
#[ubx(map_type = f64, scale = 1.0E-12)]
freq_acc: u32,
}

/// Navigation Position Velocity Time Solution
#[ubx_packet_recv]
#[ubx(class = 1, id = 0x07, fixed_payload_len = 92)]
Expand Down Expand Up @@ -1149,7 +1171,7 @@ bitflags! {
/// Time mode survey-in status
#[ubx_packet_recv]
#[ubx(class = 0x0d, id = 0x04, fixed_payload_len = 28)]
struct TimSvin{
struct TimSvin {
/// Passed survey-in minimum duration
/// Units: s
dur: u32,
Expand Down Expand Up @@ -2600,6 +2622,91 @@ pub enum TimTm2TimeBase {
Utc,
}

/// Time pulse time & frequency data
#[ubx_packet_recv]
#[ubx(class = 0x0D, id = 0x12, fixed_payload_len = 56)]
struct TimTos {
version: u8,
/// GNSS system used for reporting GNSS time
gnss_id: u8,
reserved1: [u8; 2],
#[ubx(map_type = TimTosFlags)]
flags: u32,
/// Year of UTC time
year: u16,
/// Month of UTC time
month: u8,
/// Day of UTC time
day: u8,
/// Hour of UTC time
hour: u8,
/// Minute of UTC time
minute: u8,
/// Second of UTC time
second: u8,
/// UTC standard identifier
#[ubx(map_type = CfgNav5UtcStandard, may_fail)]
utc_standard: u8,
/// Time offset between preceding pulse and UTC top of second
utc_offset: i32,
/// Uncertainty of UTC offset
utc_uncertainty: u32,
/// GNSS week number
week: u32,
/// GNSS time of week
tow: u32,
/// Time offset between the preceding pulse and GNSS top of second
gnss_offset: i32,
/// Uncertainty of GNSS offset
gnss_uncertainty: u32,
#[ubx(map_type = f64, scale = 2.0E-8)]
int_osc_offset: i32,
#[ubx(map_type = f64, scale = 2.0E-8)]
int_osc_uncertainty: u32,
#[ubx(map_type = f64, scale = 2.0E-8)]
ext_osc_offset: i32,
#[ubx(map_type = f64, scale = 2.0E-8)]
ext_osc_uncertainty: u32,
}

#[ubx_extend_bitflags]
#[ubx(from, into_raw, rest_reserved)]
bitflags! {
#[derive(Default)]
pub struct TimTosFlags: u32 {
/// Currently in a leap second
const LEAP_NOW = 0x01;
/// Leap second in current minute
const LEAP_CURRENT_MINUTE = 0x02;
/// Positive leap second
const POSITIVE_LEAP = 0x04;
/// Time pulse is within tolerance limit (Ubx-CfgSmgr)
const TIME_IN_LIMIT = 0x08;
/// Internal oscillator is within tolerance limit (Ubx-CfgSmgr)
const INT_OSC_IN_LIMIT = 0x10;
/// Exteranl oscillator is within tolerance limit (Ubx-CfgSmgr)
const EXT_OSC_IN_LIMIT = 0x20;
/// GNSS Time is valid
const GNSS_TIME_IS_VALID = 0x40;
/// Disciplining source is GNSS
const GNSS_DISCIPLINING = 0x80;
/// Disciplining source is EXTINT0
const EXTINT0_DISCIPLINING = 0x100;
/// Disciplining source is EXTINT1
const EXTINT1_DISCIPLINING = 0x200;
/// Internal Osc measured by host
const INT_MEAS_BY_HOST = 0x400;
/// External Osc measured by host
const EXT_MEAS_BY_HOST = 0x800;
/// (T)RAIM system currently active
const RAIM = 0x1000;
/// Coherent pulse generation active
const COHERENT_PULSE = 0x2000;
/// Time pulse is locked
const TIME_PULSE_LOCKED = 0x4000;
}
}

#[ubx_packet_recv]
#[ubx(class = 0x02, id = 0x15, max_payload_len = 8176)] // 16 + 255 * 32
struct RxmRawx {
Expand Down Expand Up @@ -2901,6 +3008,7 @@ define_recv_packets!(
NavVelNed,
NavTimeUTC,
NavTimeLs,
NavClock,
NavSat,
NavEoe,
NavOdo,
Expand Down Expand Up @@ -2933,5 +3041,6 @@ define_recv_packets!(
MonHw,
RxmRtcm,
TimSvin,
TimTos,
}
);