Add CUC impl #4

Merged
muellerr merged 28 commits from add_cuc_time_impl into main 2023-01-09 11:14:42 +01:00
2 changed files with 7 additions and 3 deletions
Showing only changes of commit ec8a2e1d24 - Show all commits

View File

@ -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<ProvidesDaysLen: ProvidesDaysLength> TimeProvider<ProvidesDaysLen> {
day_seg_len: LengthOfDaySegment,
submillis_prec: Option<SubmillisPrecision>,
) -> 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,

View File

@ -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<FractionalResolution>) -> 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