From 46e2af41d2cfec0d131b0aca9cfd0fc7ec57f0a9 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Sun, 18 Dec 2022 16:21:20 +0100 Subject: [PATCH 1/2] PTC and PFC extensions - Add Ptc typedefinition for PacketTypeCode enum - Add `UnsignedPfc` and `RealPfc` PFC enumerations --- src/ecss.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/ecss.rs b/src/ecss.rs index f06b4c7..579c04e 100644 --- a/src/ecss.rs +++ b/src/ecss.rs @@ -55,6 +55,36 @@ pub enum PacketTypeCodes { 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)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum PusError { -- 2.43.0 From f964342556f3050e5c8d66442eae161f65736512 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 18 Dec 2022 23:54:13 +0100 Subject: [PATCH 2/2] removed unnecessary casts --- src/ecss.rs | 6 +++--- src/time.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ecss.rs b/src/ecss.rs index 579c04e..93009ce 100644 --- a/src/ecss.rs +++ b/src/ecss.rs @@ -308,13 +308,13 @@ impl EcssEnumeration for GenericEcssEnumWrapper { } 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 { 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(()) } } diff --git a/src/time.rs b/src/time.rs index 45277bc..907f9c3 100644 --- a/src/time.rs +++ b/src/time.rs @@ -134,7 +134,7 @@ impl CdsShortTimeProvider { }; let unix_days_seconds = 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")] @@ -223,7 +223,7 @@ impl CcsdsTimeProvider for CdsShortTimeProvider { } fn date_time(&self) -> Option> { - self.calc_date_time((self.ms_of_day % 1000) as u32) + self.calc_date_time(self.ms_of_day % 1000) } } -- 2.43.0