From c0e70daf58ff62d59dd4b5d00d93088c5ffa9405 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 10 Jul 2023 23:29:55 +0200 Subject: [PATCH] some tweaks and test update --- src/ecss/tc.rs | 7 +++++-- src/ecss/tm.rs | 7 ++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ecss/tc.rs b/src/ecss/tc.rs index 5d9918e..ddac404 100644 --- a/src/ecss/tc.rs +++ b/src/ecss/tc.rs @@ -790,6 +790,10 @@ impl<'raw_data> PusTcReader<'raw_data> { Ok((pus_tc, total_len)) } + pub fn raw_data(&self) -> &[u8] { + self.raw_data + } + pub fn len_packed(&self) -> usize { self.sp_header.total_len() } @@ -854,8 +858,7 @@ impl PartialEq> for PusTcCreator<'_> { #[cfg(all(test, feature = "std"))] mod tests { use crate::ecss::tc::{ - GenericPusTcSecondaryHeader, PusTc, PusTcCreator, PusTcReader, PusTcSecondaryHeader, - ACK_ALL, + GenericPusTcSecondaryHeader, PusTcCreator, PusTcReader, PusTcSecondaryHeader, ACK_ALL, }; use crate::ecss::PusVersion::PusC; use crate::ecss::{PusError, PusPacket, SerializablePusPacket}; diff --git a/src/ecss/tm.rs b/src/ecss/tm.rs index df377b3..e4def6d 100644 --- a/src/ecss/tm.rs +++ b/src/ecss/tm.rs @@ -829,7 +829,7 @@ impl<'raw_data> PusTmReader<'raw_data> { /// If [Self] was constructed [Self::from_bytes], this function will return the slice it was /// constructed from. Otherwise, [None] will be returned. - pub fn raw_bytes(&self) -> &'raw_data [u8] { + pub fn raw_data(&self) -> &[u8] { self.raw_data } } @@ -1051,13 +1051,10 @@ mod tests { fn test_manual_field_update() { let mut sph = SpHeader::tm_unseg(0x123, 0x234, 0).unwrap(); let tc_header = PusTmSecondaryHeader::new_simple(17, 2, dummy_timestamp()); - let mut tm = PusTm::new(&mut sph, tc_header, None, false); + let mut tm = PusTmCreator::new(&mut sph, tc_header, None, false); tm.calc_crc_on_serialization = false; assert_eq!(tm.data_len(), 0x00); let mut buf: [u8; 32] = [0; 32]; - let res = tm.write_to_bytes(&mut buf); - assert!(res.is_err()); - assert!(matches!(res.unwrap_err(), PusError::CrcCalculationMissing)); tm.update_ccsds_data_len(); assert_eq!(tm.data_len(), 15); tm.calc_own_crc16();