better handling for MGM HK
Some checks failed
Rust/sat-rs/pipeline/pr-main There was a failure building this commit

This commit is contained in:
Robin Müller 2024-04-03 13:24:33 +02:00
parent 3e55fde3b4
commit 575003db94
Signed by: muellerr
GPG Key ID: A649FB78196E3849

View File

@ -74,6 +74,7 @@ pub struct MgmHandler<ComInterface: SpiInterface, TmSender: EcssTmSenderCore> {
#[new(default)] #[new(default)]
rx_buf: [u8; 12], rx_buf: [u8; 12],
#[new(default)] #[new(default)]
tm_buf: [u8; 12],
stamp_helper: TimeStampHelper, stamp_helper: TimeStampHelper,
} }
@ -135,10 +136,11 @@ impl<ComInterface: SpiInterface, TmSender: EcssTmSenderCore> MgmHandler<ComInter
); );
// Let's serialize it as JSON for now.. This is a lot simpler than binary // Let's serialize it as JSON for now.. This is a lot simpler than binary
// serialization. // serialization.
let mgm_data_serialized = let mgm_snapshot = *self.shared_mgm_set.lock().unwrap();
serde_json::to_vec(&*self.shared_mgm_set.lock().unwrap()).unwrap(); self.tm_buf[0..4].copy_from_slice(&mgm_snapshot.x.to_be_bytes());
let hk_tm = self.tm_buf[4..8].copy_from_slice(&mgm_snapshot.y.to_be_bytes());
PusTmCreator::new(&mut sp_header, sec_header, &mgm_data_serialized, true); self.tm_buf[8..12].copy_from_slice(&mgm_snapshot.z.to_be_bytes());
let hk_tm = PusTmCreator::new(&mut sp_header, sec_header, &self.tm_buf[0..12], true);
self.tm_sender self.tm_sender
.send_tm(self.id.id(), PusTmVariant::Direct(hk_tm)) .send_tm(self.id.id(), PusTmVariant::Direct(hk_tm))
.expect("failed to send HK TM"); .expect("failed to send HK TM");