From ec8a2e1d2401da93d5a63010c5b6e2a3aad4ea14 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 9 Jan 2023 11:07:43 +0100 Subject: [PATCH] rename pfield preamble constant, add for CUC --- src/time/cds.rs | 5 +++-- src/time/cuc.rs | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/time/cds.rs b/src/time/cds.rs index 1a843ec..9c00352 100644 --- a/src/time/cds.rs +++ b/src/time/cds.rs @@ -6,7 +6,8 @@ use super::*; use crate::private::Sealed; use core::fmt::Debug; -pub const CDS_SHORT_P_FIELD: u8 = (CcsdsTimeCodes::Cds as u8) << 4; +/// Base value for the preamble field for a time field parser to determine the time field type. +pub const P_FIELD_BASE: u8 = (CcsdsTimeCodes::Cds as u8) << 4; pub const MIN_CDS_FIELD_LEN: usize = 7; /// Generic trait implemented by token structs to specify the length of day field at type @@ -391,7 +392,7 @@ impl TimeProvider { day_seg_len: LengthOfDaySegment, submillis_prec: Option, ) -> u8 { - let mut pfield = CDS_SHORT_P_FIELD | ((day_seg_len as u8) << 2); + let mut pfield = P_FIELD_BASE | ((day_seg_len as u8) << 2); if let Some(submillis_prec) = submillis_prec { match submillis_prec { SubmillisPrecision::Microseconds(_) => pfield |= 0b01, diff --git a/src/time/cuc.rs b/src/time/cuc.rs index 6807769..029a241 100644 --- a/src/time/cuc.rs +++ b/src/time/cuc.rs @@ -6,6 +6,9 @@ use super::*; use core::fmt::Debug; const MIN_CUC_LEN: usize = 2; + +/// Base value for the preamble field for a time field parser to determine the time field type. +pub const P_FIELD_BASE: u8 = (CcsdsTimeCodes::CucCcsdsEpoch as u8) << 4; /// Maximum length if the preamble field is not extended. pub const MAX_CUC_LEN_SMALL_PREAMBLE: usize = 8; @@ -310,7 +313,7 @@ impl TimeProviderCcsdsEpoch { } fn build_p_field(counter_width: u8, fractions_width: Option) -> u8 { - let mut pfield = (CcsdsTimeCodes::CucCcsdsEpoch as u8) << 4; + let mut pfield = P_FIELD_BASE; if !(1..=4).contains(&counter_width) { // Okay to panic here, this function is private and all input values should // have been sanitized