diff --git a/CHANGELOG.md b/CHANGELOG.md index 7def3e0..66e3fd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Added +- `SpHeader::packet_len` direct method. - `AckFlags` which is implemented with `bitbybit::bitfield` - `ApidOutOfRangeError` and `SequenceCountOutOfRangeError` - Added PUS A legacy support for telecommands inside the `ecss.tc_pus_a` module diff --git a/src/lib.rs b/src/lib.rs index a622c50..c1e60ec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -302,6 +302,7 @@ pub trait CcsdsPacket { /// Retrieve data length field fn data_len(&self) -> u16; + /// Retrieve the total packet size based on the data length field #[inline] fn packet_len(&self) -> usize { @@ -504,6 +505,12 @@ impl SpHeader { } } + /// Retrieve the total packet size based on the data length field + #[inline] + fn packet_len(&self) -> usize { + usize::from(self.data_len()) + CCSDS_HEADER_LEN + 1 + } + #[inline] pub fn set_seq_count(&mut self, seq_count: u14) { self.psc.seq_count = seq_count;