Compare commits
4 Commits
ce9ca14b8f
...
3edf13cca2
Author | SHA1 | Date | |
---|---|---|---|
3edf13cca2
|
|||
01168d8ab2
|
|||
caaecdff0c | |||
ef37a84edc
|
@ -237,7 +237,7 @@ impl<'raw_data> PusTcCreator<'raw_data> {
|
|||||||
/// and subservice type
|
/// and subservice type
|
||||||
/// * `app_data` - Custom application data
|
/// * `app_data` - Custom application data
|
||||||
/// * `set_ccsds_len` - Can be used to automatically update the CCSDS space packet data length
|
/// * `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
|
/// field. If this is not set to true, [PusTc::update_ccsds_data_len] can be called to set
|
||||||
/// the correct value to this field manually
|
/// the correct value to this field manually
|
||||||
pub fn new(
|
pub fn new(
|
||||||
sp_header: &mut SpHeader,
|
sp_header: &mut SpHeader,
|
||||||
@ -258,7 +258,7 @@ impl<'raw_data> PusTcCreator<'raw_data> {
|
|||||||
pus_tc
|
pus_tc
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Simplified version of the [Self::new] function which allows to only specify service
|
/// Simplified version of the [PusTcCreator::new] function which allows to only specify service
|
||||||
/// and subservice instead of the full PUS TC secondary header.
|
/// and subservice instead of the full PUS TC secondary header.
|
||||||
pub fn new_simple(
|
pub fn new_simple(
|
||||||
sph: &mut SpHeader,
|
sph: &mut SpHeader,
|
||||||
@ -302,7 +302,7 @@ impl<'raw_data> PusTcCreator<'raw_data> {
|
|||||||
sp_header_impls!();
|
sp_header_impls!();
|
||||||
|
|
||||||
/// Calculate the CCSDS space packet data length field and sets it
|
/// Calculate the CCSDS space packet data length field and sets it
|
||||||
/// This is called automatically if the `set_ccsds_len` argument in the [Self::new] call was
|
/// This is called automatically if the `set_ccsds_len` argument in the [PusTc::new] call was
|
||||||
/// used.
|
/// used.
|
||||||
/// If this was not done or the application data is set or changed after construction,
|
/// If this was not done or the application data is set or changed after construction,
|
||||||
/// this function needs to be called to ensure that the data length field of the CCSDS header
|
/// this function needs to be called to ensure that the data length field of the CCSDS header
|
||||||
@ -312,7 +312,8 @@ impl<'raw_data> PusTcCreator<'raw_data> {
|
|||||||
self.len_written() as u16 - size_of::<crate::zc::SpHeader>() as u16 - 1;
|
self.len_written() as u16 - size_of::<crate::zc::SpHeader>() as u16 - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This function calculates and returns the CRC16 for the current packet.
|
/// This function should be called before the TC packet is serialized if
|
||||||
|
/// [PusTc::calc_crc_on_serialization] is set to False. It will calculate and cache the CRC16.
|
||||||
pub fn calc_own_crc16(&self) -> u16 {
|
pub fn calc_own_crc16(&self) -> u16 {
|
||||||
let mut digest = CRC_CCITT_FALSE.digest();
|
let mut digest = CRC_CCITT_FALSE.digest();
|
||||||
let sph_zc = crate::zc::SpHeader::from(self.sp_header);
|
let sph_zc = crate::zc::SpHeader::from(self.sp_header);
|
||||||
|
@ -215,8 +215,8 @@ pub struct PusTmCreator<'time, 'raw_data> {
|
|||||||
#[cfg_attr(feature="serde", serde(borrow))]
|
#[cfg_attr(feature="serde", serde(borrow))]
|
||||||
pub sec_header: PusTmSecondaryHeader<'time>,
|
pub sec_header: PusTmSecondaryHeader<'time>,
|
||||||
source_data: &'raw_data [u8],
|
source_data: &'raw_data [u8],
|
||||||
/// If this is set to false, a manual call to [Self::calc_own_crc16] or
|
/// If this is set to false, a manual call to [PusTm::calc_own_crc16] or
|
||||||
/// [Self::update_packet_fields] is necessary for the serialized or cached CRC16 to be valid.
|
/// [PusTm::update_packet_fields] is necessary for the serialized or cached CRC16 to be valid.
|
||||||
pub calc_crc_on_serialization: bool,
|
pub calc_crc_on_serialization: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ impl<'time, 'raw_data> PusTmCreator<'time, 'raw_data> {
|
|||||||
/// and subservice type
|
/// and subservice type
|
||||||
/// * `source_data` - Custom application data
|
/// * `source_data` - Custom application data
|
||||||
/// * `set_ccsds_len` - Can be used to automatically update the CCSDS space packet data length
|
/// * `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
|
/// field. If this is not set to true, [PusTm::update_ccsds_data_len] can be called to set
|
||||||
/// the correct value to this field manually
|
/// the correct value to this field manually
|
||||||
pub fn new(
|
pub fn new(
|
||||||
sp_header: &mut SpHeader,
|
sp_header: &mut SpHeader,
|
||||||
@ -303,7 +303,7 @@ impl<'time, 'raw_data> PusTmCreator<'time, 'raw_data> {
|
|||||||
|
|
||||||
sp_header_impls!();
|
sp_header_impls!();
|
||||||
|
|
||||||
/// This is called automatically if the `set_ccsds_len` argument in the [Self::new] call was
|
/// This is called automatically if the `set_ccsds_len` argument in the [PusTm::new] call was
|
||||||
/// used.
|
/// used.
|
||||||
/// If this was not done or the time stamp or source data is set or changed after construction,
|
/// If this was not done or the time stamp or source data is set or changed after construction,
|
||||||
/// this function needs to be called to ensure that the data length field of the CCSDS header
|
/// this function needs to be called to ensure that the data length field of the CCSDS header
|
||||||
@ -314,7 +314,7 @@ impl<'time, 'raw_data> PusTmCreator<'time, 'raw_data> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// This function should be called before the TM packet is serialized if
|
/// This function should be called before the TM packet is serialized if
|
||||||
/// [Self::calc_crc_on_serialization] is set to False. It will calculate and cache the CRC16.
|
/// [PusTm.calc_crc_on_serialization] is set to False. It will calculate and cache the CRC16.
|
||||||
pub fn calc_own_crc16(&self) -> u16 {
|
pub fn calc_own_crc16(&self) -> u16 {
|
||||||
let mut digest = CRC_CCITT_FALSE.digest();
|
let mut digest = CRC_CCITT_FALSE.digest();
|
||||||
let sph_zc = crate::zc::SpHeader::from(self.sp_header);
|
let sph_zc = crate::zc::SpHeader::from(self.sp_header);
|
||||||
@ -326,7 +326,7 @@ impl<'time, 'raw_data> PusTmCreator<'time, 'raw_data> {
|
|||||||
digest.finalize()
|
digest.finalize()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This helper function calls both [Self::update_ccsds_data_len] and [Self::calc_own_crc16]
|
/// This helper function calls both [PusTm.update_ccsds_data_len] and [PusTm.calc_own_crc16]
|
||||||
pub fn update_packet_fields(&mut self) {
|
pub fn update_packet_fields(&mut self) {
|
||||||
self.update_ccsds_data_len();
|
self.update_ccsds_data_len();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user