Merge pull request 'PTC and PFC extensions' (#5) from ptc_pfc_extension into main
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good

Reviewed-on: #5
This commit is contained in:
Robin Müller 2022-12-20 16:19:21 +01:00
commit 2895d7645a
2 changed files with 35 additions and 5 deletions

View File

@ -65,6 +65,36 @@ pub enum PacketTypeCodes {
Packet = 12, Packet = 12,
} }
pub type Ptc = PacketTypeCodes;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum UnsignedPfc {
OneByte = 4,
TwelveBits = 8,
TwoBytes = 12,
ThreeBytes = 13,
FourBytes = 14,
SixBytes = 15,
EightBytes = 16,
OneBit = 17,
TwoBits = 18,
ThreeBits = 19,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum RealPfc {
/// 4 octets simple precision format (IEEE)
Float = 1,
/// 8 octets simple precision format (IEEE)
Double = 2,
/// 4 octets simple precision format (MIL-STD)
FloatMilStd = 3,
/// 8 octets simple precision format (MIL-STD)
DoubleMilStd = 4,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum PusError { pub enum PusError {
@ -288,13 +318,13 @@ impl<TYPE: ToBeBytes> EcssEnumeration for GenericEcssEnumWrapper<TYPE> {
} }
fn write_to_be_bytes(&self, buf: &mut [u8]) -> Result<(), ByteConversionError> { fn write_to_be_bytes(&self, buf: &mut [u8]) -> Result<(), ByteConversionError> {
if buf.len() < self.byte_width() as usize { if buf.len() < self.byte_width() {
return Err(ByteConversionError::ToSliceTooSmall(SizeMissmatch { return Err(ByteConversionError::ToSliceTooSmall(SizeMissmatch {
found: buf.len(), found: buf.len(),
expected: self.byte_width() as usize, expected: self.byte_width(),
})); }));
} }
buf[0..self.byte_width() as usize].copy_from_slice(self.val.to_be_bytes().as_ref()); buf[0..self.byte_width()].copy_from_slice(self.val.to_be_bytes().as_ref());
Ok(()) Ok(())
} }
} }

View File

@ -134,7 +134,7 @@ impl CdsShortTimeProvider {
}; };
let unix_days_seconds = let unix_days_seconds =
ccsds_to_unix_days(ccsds_days as i32) as i64 * SECONDS_PER_DAY as i64; ccsds_to_unix_days(ccsds_days as i32) as i64 * SECONDS_PER_DAY as i64;
provider.setup(unix_days_seconds as i64, ms_of_day.into()) provider.setup(unix_days_seconds, ms_of_day.into())
} }
#[cfg(feature = "std")] #[cfg(feature = "std")]
@ -223,7 +223,7 @@ impl CcsdsTimeProvider for CdsShortTimeProvider {
} }
fn date_time(&self) -> Option<DateTime<Utc>> { fn date_time(&self) -> Option<DateTime<Utc>> {
self.calc_date_time((self.ms_of_day % 1000) as u32) self.calc_date_time(self.ms_of_day % 1000)
} }
} }