This commit is contained in:
parent
7da7e5329c
commit
795abc57fa
@ -17,9 +17,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
## Changed
|
||||
|
||||
- Better names for generic error enumerations: `PacketError` renamed to `ByteConversionError`
|
||||
- `ssc` abbreviations fully replaced by better name `seq_count`
|
||||
- CCSDS module: `ssc` abbreviations fully replaced by better name `seq_count`
|
||||
- Time module: `CcsdsTimeProvider::date_time` now has `Option<DateTime<Utc>>` as
|
||||
a returnvalue instead of `DateTime<Utc>`
|
||||
- `PusTc` and `PusTm`: `new_from_raw_slice` renamed to simpler `from_bytes`
|
||||
|
||||
# [v0.1.0] 16.08.2022
|
||||
|
||||
|
10
src/tc.rs
10
src/tc.rs
@ -26,7 +26,7 @@
|
||||
//! println!("{:?}", &test_buf[0..size]);
|
||||
//!
|
||||
//! // Deserialize from the raw byte representation
|
||||
//! let pus_tc_deserialized = PusTc::new_from_raw_slice(&test_buf).expect("Deserialization failed");
|
||||
//! let pus_tc_deserialized = PusTc::from_bytes(&test_buf).expect("Deserialization failed");
|
||||
//! assert_eq!(pus_tc.service(), 17);
|
||||
//! assert_eq!(pus_tc.subservice(), 1);
|
||||
//! assert_eq!(pus_tc.apid(), 0x02);
|
||||
@ -401,7 +401,7 @@ impl<'slice> PusTc<'slice> {
|
||||
|
||||
/// Create a [PusTc] instance from a raw slice. On success, it returns a tuple containing
|
||||
/// the instance and the found byte length of the packet
|
||||
pub fn new_from_raw_slice(slice: &'slice [u8]) -> Result<(Self, usize), PusError> {
|
||||
pub fn from_bytes(slice: &'slice [u8]) -> Result<(Self, usize), PusError> {
|
||||
let raw_data_len = slice.len();
|
||||
if raw_data_len < PUS_TC_MIN_LEN_WITHOUT_APP_DATA {
|
||||
return Err(PusError::RawDataTooShort(raw_data_len));
|
||||
@ -522,7 +522,7 @@ mod tests {
|
||||
.write_to_bytes(test_buf.as_mut_slice())
|
||||
.expect("Error writing TC to buffer");
|
||||
assert_eq!(size, 13);
|
||||
let (tc_from_raw, size) = PusTc::new_from_raw_slice(&test_buf)
|
||||
let (tc_from_raw, size) = PusTc::from_bytes(&test_buf)
|
||||
.expect("Creating PUS TC struct from raw buffer failed");
|
||||
assert_eq!(size, 13);
|
||||
verify_test_tc(&tc_from_raw, false, 13);
|
||||
@ -548,7 +548,7 @@ mod tests {
|
||||
.write_to_bytes(test_buf.as_mut_slice())
|
||||
.expect("Error writing TC to buffer");
|
||||
assert_eq!(size, 16);
|
||||
let (tc_from_raw, size) = PusTc::new_from_raw_slice(&test_buf)
|
||||
let (tc_from_raw, size) = PusTc::from_bytes(&test_buf)
|
||||
.expect("Creating PUS TC struct from raw buffer failed");
|
||||
assert_eq!(size, 16);
|
||||
verify_test_tc(&tc_from_raw, true, 16);
|
||||
@ -579,7 +579,7 @@ mod tests {
|
||||
.write_to_bytes(test_buf.as_mut_slice())
|
||||
.expect("Error writing TC to buffer");
|
||||
test_buf[12] = 0;
|
||||
let res = PusTc::new_from_raw_slice(&test_buf);
|
||||
let res = PusTc::from_bytes(&test_buf);
|
||||
assert!(res.is_err());
|
||||
let err = res.unwrap_err();
|
||||
assert!(matches!(err, PusError::IncorrectCrc { .. }));
|
||||
|
@ -387,7 +387,7 @@ impl<'slice> PusTm<'slice> {
|
||||
/// Create a [PusTm] instance from a raw slice. On success, it returns a tuple containing
|
||||
/// the instance and the found byte length of the packet. The timestamp length needs to be
|
||||
/// known beforehand.
|
||||
pub fn new_from_raw_slice(
|
||||
pub fn from_bytes(
|
||||
slice: &'slice [u8],
|
||||
timestamp_len: usize,
|
||||
) -> Result<(Self, usize), PusError> {
|
||||
@ -541,7 +541,7 @@ mod tests {
|
||||
.expect("Serialization failed");
|
||||
assert_eq!(ser_len, 22);
|
||||
let (tm_deserialized, size) =
|
||||
PusTm::new_from_raw_slice(&buf, 7).expect("Deserialization failed");
|
||||
PusTm::from_bytes(&buf, 7).expect("Deserialization failed");
|
||||
assert_eq!(ser_len, size);
|
||||
verify_ping_reply(&tm_deserialized, false, 22, dummy_time_stamp());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user