diff --git a/src/ecss/mod.rs b/src/ecss/mod.rs index 31e4a18..966db47 100644 --- a/src/ecss/mod.rs +++ b/src/ecss/mod.rs @@ -436,7 +436,9 @@ pub trait WritablePusPacket { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub struct CreatorConfig { + /// Set the CCSDS data length field on construction. pub set_ccsds_len: bool, + /// CRC-16-CCITT Checksum is present. pub has_checksum: bool, } diff --git a/src/ecss/tc.rs b/src/ecss/tc.rs index 7cc3b00..f53cf89 100644 --- a/src/ecss/tc.rs +++ b/src/ecss/tc.rs @@ -247,17 +247,13 @@ impl<'app_data> PusTcCreator<'app_data> { /// * `sec_header` - Information contained in the data field header, including the service /// and subservice type /// * `app_data` - Custom application data - /// * `set_ccsds_len` - Can be used to automatically update the CCSDS space packet data length - /// field. If this is not set to true, [Self::update_ccsds_data_len] can be called to set - /// the correct value to this field manually - /// * `has_checksum` - A CRC16 checksum will be generated and appended to the end of the - /// packet. + /// * `packet_config` - Common configuration options for TC packet creation #[inline] pub fn new( mut sp_header: SpHeader, sec_header: PusTcSecondaryHeader, app_data: &'app_data [u8], - creator_config: CreatorConfig, + packet_config: CreatorConfig, ) -> Self { sp_header.set_packet_type(PacketType::Tc); sp_header.set_sec_header_flag(); @@ -265,9 +261,9 @@ impl<'app_data> PusTcCreator<'app_data> { sp_header, app_data, sec_header, - has_checksum: creator_config.has_checksum, + has_checksum: packet_config.has_checksum, }; - if creator_config.set_ccsds_len { + if packet_config.set_ccsds_len { pus_tc.update_ccsds_data_len(); } pus_tc @@ -281,13 +277,13 @@ impl<'app_data> PusTcCreator<'app_data> { service: u8, subservice: u8, app_data: &'app_data [u8], - creator_config: CreatorConfig, + packet_config: CreatorConfig, ) -> Self { Self::new( sph, PusTcSecondaryHeader::new(service, subservice, ACK_ALL, 0), app_data, - creator_config, + packet_config, ) } @@ -295,9 +291,9 @@ impl<'app_data> PusTcCreator<'app_data> { pub fn new_no_app_data( sp_header: SpHeader, sec_header: PusTcSecondaryHeader, - creator_config: CreatorConfig, + packet_config: CreatorConfig, ) -> Self { - Self::new(sp_header, sec_header, &[], creator_config) + Self::new(sp_header, sec_header, &[], packet_config) } #[inline] diff --git a/src/ecss/tm.rs b/src/ecss/tm.rs index a484193..eb1b9fe 100644 --- a/src/ecss/tm.rs +++ b/src/ecss/tm.rs @@ -288,9 +288,7 @@ impl<'time, 'src_data> PusTmCreator<'time, 'src_data> { /// * `sec_header` - Information contained in the secondary header, including the service /// and subservice type /// * `source_data` - Custom application data - /// * `set_ccsds_len` - Can be used to automatically update the CCSDS space packet data length - /// field. If this is not set to true, [Self::update_ccsds_data_len] can be called to set - /// the correct value to this field manually + /// * `packet_config` - Common configuration options for TM packet creation #[inline] pub fn new( mut sp_header: SpHeader, @@ -726,7 +724,8 @@ pub struct PusTmReader<'raw_data> { #[cfg_attr(feature = "serde", serde(skip))] raw_data: &'raw_data [u8], source_data: &'raw_data [u8], - checksum_crc16: Option, + // CRC-16-CCITT checksum. + checksum: Option, } impl<'raw_data> PusTmReader<'raw_data> { @@ -734,7 +733,7 @@ impl<'raw_data> PusTmReader<'raw_data> { /// the instance and the found byte length of the packet. The timestamp length needs to be /// known beforehand. /// - /// This function will check the CRC-16 of the PUS packet and will return an appropriate + /// This function will verify the CRC-16-CCITT of the PUS packet and will return an appropriate /// [PusError] if the check fails. pub fn new(slice: &'raw_data [u8], timestamp_len: usize) -> Result { let tc = Self::new_no_checksum_verification( @@ -822,7 +821,7 @@ impl<'raw_data> PusTmReader<'raw_data> { slice, reader_config.has_checksum, )?, - checksum_crc16: crc16, + checksum: crc16, }) } @@ -843,7 +842,7 @@ impl<'raw_data> PusTmReader<'raw_data> { #[inline] pub fn checksum(&self) -> Option { - self.checksum_crc16 + self.checksum } /// This function will return the slice [Self] was constructed from. @@ -858,7 +857,7 @@ impl PartialEq for PusTmReader<'_> { self.sec_header == other.sec_header && self.source_data == other.source_data && self.sp_header == other.sp_header - && self.checksum_crc16 == other.checksum_crc16 + && self.checksum == other.checksum } } @@ -878,7 +877,7 @@ impl PusPacket for PusTmReader<'_> { #[inline] fn has_checksum(&self) -> bool { - self.checksum_crc16.is_some() + self.checksum.is_some() } #[inline]