use same example packet as spacepackets python example

This commit is contained in:
Robin Müller 2022-06-18 15:03:26 +02:00
parent 75319496b5
commit 5f8ac2a8f5
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
2 changed files with 6 additions and 5 deletions

View File

@ -42,7 +42,7 @@ fn main() {
some_bool: true as u8,
some_u16: U16::from(0x42),
some_i32: I32::from(-200),
some_float: 7.7_f32.to_ne_bytes(),
some_float: 7.7_f32.to_be_bytes(),
};
let mut slice = [0; 11];
sample_hk.write_to(slice.as_mut_slice());

View File

@ -1,6 +1,7 @@
use std::mem::size_of;
type CrcType = u16;
/// PUS C secondary header length is fixed
pub const PUC_TC_SECONDARY_HEADER_LEN: usize = size_of::<zc::PusTcDataFieldHeader>();
pub const PUS_TC_MIN_LEN_WITHOUT_APP_DATA: usize =
@ -169,7 +170,7 @@ pub mod srd {
curr_idx += app_data.len();
}
mut_slice[curr_idx..curr_idx + 2]
.copy_from_slice(self.crc16.unwrap().to_ne_bytes().as_slice());
.copy_from_slice(self.crc16.unwrap().to_be_bytes().as_slice());
curr_idx += 2;
Ok(curr_idx)
}
@ -191,7 +192,7 @@ pub mod srd {
if let Some(app_data) = self.app_data {
vec.extend_from_slice(app_data);
}
vec.extend_from_slice(self.crc16.unwrap().to_ne_bytes().as_slice());
vec.extend_from_slice(self.crc16.unwrap().to_be_bytes().as_slice());
Ok(appended_len)
}
}
@ -253,8 +254,8 @@ mod tests {
#[test]
fn test_tc() {
let mut sph = SpHeader::tc(0x42, 12).unwrap();
let mut pus_tc = PusTc::new(&mut sph, 1, 1, None);
let mut sph = SpHeader::tc(0x01, 0).unwrap();
let mut pus_tc = PusTc::new(&mut sph, 17, 1, None);
let _out = to_stdvec(&pus_tc).unwrap();
let mut test_buf = [0; 32];
pus_tc.update_packet_fields();