rename pfield preamble constant, add for CUC
Some checks failed
Rust/spacepackets/pipeline/head This commit looks good
Rust/spacepackets/pipeline/pr-main There was a failure building this commit

This commit is contained in:
Robin Müller 2023-01-09 11:07:43 +01:00
parent 192e2f2c76
commit ec8a2e1d24
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
2 changed files with 7 additions and 3 deletions

View File

@ -6,7 +6,8 @@ use super::*;
use crate::private::Sealed; use crate::private::Sealed;
use core::fmt::Debug; 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; pub const MIN_CDS_FIELD_LEN: usize = 7;
/// Generic trait implemented by token structs to specify the length of day field at type /// 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, day_seg_len: LengthOfDaySegment,
submillis_prec: Option<SubmillisPrecision>, submillis_prec: Option<SubmillisPrecision>,
) -> u8 { ) -> 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 { if let Some(submillis_prec) = submillis_prec {
match submillis_prec { match submillis_prec {
SubmillisPrecision::Microseconds(_) => pfield |= 0b01, SubmillisPrecision::Microseconds(_) => pfield |= 0b01,

View File

@ -6,6 +6,9 @@ use super::*;
use core::fmt::Debug; use core::fmt::Debug;
const MIN_CUC_LEN: usize = 2; 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. /// Maximum length if the preamble field is not extended.
pub const MAX_CUC_LEN_SMALL_PREAMBLE: usize = 8; 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 { 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) { if !(1..=4).contains(&counter_width) {
// Okay to panic here, this function is private and all input values should // Okay to panic here, this function is private and all input values should
// have been sanitized // have been sanitized