always supply addressable ID

This commit is contained in:
Robin Müller 2022-12-22 09:26:00 +01:00
parent d69e03a675
commit 4e450808b7
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
4 changed files with 50 additions and 19 deletions

View File

@ -40,6 +40,18 @@ impl AddressableId {
unique_id: u32::from_be_bytes(buf[4..8].try_into().unwrap()), unique_id: u32::from_be_bytes(buf[4..8].try_into().unwrap()),
}) })
} }
pub fn write_to_be_bytes(&self, buf: &mut [u8]) -> Result<usize, ByteConversionError> {
if buf.len() < 8 {
return Err(ByteConversionError::ToSliceTooSmall(SizeMissmatch {
found: buf.len(),
expected: 8,
}));
}
buf[0..4].copy_from_slice(&self.target_id.to_be_bytes());
buf[4..8].copy_from_slice(&self.unique_id.to_be_bytes());
Ok(8)
}
} }
/// Generic trait for object which can receive any telecommands in form of a raw bytestream, with /// Generic trait for object which can receive any telecommands in form of a raw bytestream, with

View File

@ -1,4 +1,5 @@
#![allow(dead_code)] use satrs_core::tmtc::AddressableId;
pub type CollectionIntervalFactor = u32; pub type CollectionIntervalFactor = u32;
#[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
@ -8,8 +9,8 @@ pub enum AcsHkIds {
#[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum HkRequest { pub enum HkRequest {
OneShot(u32), OneShot(AddressableId),
Enable(u32), Enable(AddressableId),
Disable(u32), Disable(AddressableId),
ModifyCollectionInterval(CollectionIntervalFactor), ModifyCollectionInterval(AddressableId, CollectionIntervalFactor),
} }

View File

@ -4,7 +4,8 @@ mod pus;
mod requests; mod requests;
mod tmtc; mod tmtc;
use crate::requests::RequestWithToken; use crate::hk::{AcsHkIds, HkRequest};
use crate::requests::{Request, RequestWithToken};
use crate::tmtc::{ use crate::tmtc::{
core_tmtc_task, OtherArgs, PusTcSource, TcArgs, TcStore, TmArgs, TmFunnel, TmStore, PUS_APID, core_tmtc_task, OtherArgs, PusTcSource, TcArgs, TcStore, TmArgs, TmFunnel, TmStore, PUS_APID,
}; };
@ -214,16 +215,32 @@ fn main() {
Ok(request) => { Ok(request) => {
println!("ACS thread: Received HK request {:?}", request.0); println!("ACS thread: Received HK request {:?}", request.0);
update_time(&mut time_provider, &mut timestamp); update_time(&mut time_provider, &mut timestamp);
let mut sp_header = match request.0 {
SpHeader::tm(PUS_APID, SequenceFlags::Unsegmented, 0, 0).unwrap(); Request::HkRequest(hk_req) => match hk_req {
let sec_header = PusTmSecondaryHeader::new_simple( HkRequest::OneShot(one_shot_req) => {
3, assert_eq!(
Subservice::TmHkPacket as u8, one_shot_req.unique_id,
&timestamp, RequestTargetId::AcsSubsystem as u32
); );
let pus_tm = PusTm::new(&mut sp_header, sec_header, None, true); if one_shot_req.unique_id == AcsHkIds::TestMgmSet as u32 {
let addr = aocs_tm_store.add_pus_tm(&pus_tm); let mut sp_header =
aocs_to_funnel.send(addr).expect("Sending HK TM failed"); SpHeader::tm(PUS_APID, SequenceFlags::Unsegmented, 0, 0)
.unwrap();
let sec_header = PusTmSecondaryHeader::new_simple(
3,
Subservice::TmHkPacket as u8,
&timestamp,
);
let pus_tm = PusTm::new(&mut sp_header, sec_header, None, true);
let addr = aocs_tm_store.add_pus_tm(&pus_tm);
aocs_to_funnel.send(addr).expect("Sending HK TM failed");
}
}
HkRequest::Enable(_) => {}
HkRequest::Disable(_) => {}
HkRequest::ModifyCollectionInterval(_, _) => {}
},
}
let started_token = reporter_aocs let started_token = reporter_aocs
.start_success(request.1, &timestamp) .start_success(request.1, &timestamp)
.expect("Sending start success failed"); .expect("Sending start success failed");

View File

@ -171,11 +171,11 @@ impl PusReceiver {
.unwrap_or_else(|_| panic!("Sending HK request {:?} failed", request)); .unwrap_or_else(|_| panic!("Sending HK request {:?} failed", request));
}; };
if PusPacket::subservice(pus_tc) == hk::Subservice::TcEnableGeneration as u8 { if PusPacket::subservice(pus_tc) == hk::Subservice::TcEnableGeneration as u8 {
send_request(HkRequest::Enable(addressable_id.unique_id)); send_request(HkRequest::Enable(addressable_id));
} else if PusPacket::subservice(pus_tc) == hk::Subservice::TcDisableGeneration as u8 { } else if PusPacket::subservice(pus_tc) == hk::Subservice::TcDisableGeneration as u8 {
send_request(HkRequest::Disable(addressable_id.unique_id)); send_request(HkRequest::Disable(addressable_id));
} else if PusPacket::subservice(pus_tc) == hk::Subservice::TcGenerateOneShotHk as u8 { } else if PusPacket::subservice(pus_tc) == hk::Subservice::TcGenerateOneShotHk as u8 {
send_request(HkRequest::OneShot(addressable_id.unique_id)); send_request(HkRequest::OneShot(addressable_id));
} else if PusPacket::subservice(pus_tc) == hk::Subservice::TcModifyCollectionInterval as u8 } else if PusPacket::subservice(pus_tc) == hk::Subservice::TcModifyCollectionInterval as u8
{ {
if user_data.len() < 12 { if user_data.len() < 12 {
@ -193,6 +193,7 @@ impl PusReceiver {
return; return;
} }
send_request(HkRequest::ModifyCollectionInterval( send_request(HkRequest::ModifyCollectionInterval(
addressable_id,
CollectionIntervalFactor::from_be_bytes(user_data[8..12].try_into().unwrap()), CollectionIntervalFactor::from_be_bytes(user_data[8..12].try_into().unwrap()),
)); ));
} }