always supply addressable ID
This commit is contained in:
parent
d69e03a675
commit
4e450808b7
@ -40,6 +40,18 @@ impl AddressableId {
|
||||
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
|
||||
|
@ -1,4 +1,5 @@
|
||||
#![allow(dead_code)]
|
||||
use satrs_core::tmtc::AddressableId;
|
||||
|
||||
pub type CollectionIntervalFactor = u32;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
@ -8,8 +9,8 @@ pub enum AcsHkIds {
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub enum HkRequest {
|
||||
OneShot(u32),
|
||||
Enable(u32),
|
||||
Disable(u32),
|
||||
ModifyCollectionInterval(CollectionIntervalFactor),
|
||||
OneShot(AddressableId),
|
||||
Enable(AddressableId),
|
||||
Disable(AddressableId),
|
||||
ModifyCollectionInterval(AddressableId, CollectionIntervalFactor),
|
||||
}
|
||||
|
@ -4,7 +4,8 @@ mod pus;
|
||||
mod requests;
|
||||
mod tmtc;
|
||||
|
||||
use crate::requests::RequestWithToken;
|
||||
use crate::hk::{AcsHkIds, HkRequest};
|
||||
use crate::requests::{Request, RequestWithToken};
|
||||
use crate::tmtc::{
|
||||
core_tmtc_task, OtherArgs, PusTcSource, TcArgs, TcStore, TmArgs, TmFunnel, TmStore, PUS_APID,
|
||||
};
|
||||
@ -214,8 +215,17 @@ fn main() {
|
||||
Ok(request) => {
|
||||
println!("ACS thread: Received HK request {:?}", request.0);
|
||||
update_time(&mut time_provider, &mut timestamp);
|
||||
match request.0 {
|
||||
Request::HkRequest(hk_req) => match hk_req {
|
||||
HkRequest::OneShot(one_shot_req) => {
|
||||
assert_eq!(
|
||||
one_shot_req.unique_id,
|
||||
RequestTargetId::AcsSubsystem as u32
|
||||
);
|
||||
if one_shot_req.unique_id == AcsHkIds::TestMgmSet as u32 {
|
||||
let mut sp_header =
|
||||
SpHeader::tm(PUS_APID, SequenceFlags::Unsegmented, 0, 0).unwrap();
|
||||
SpHeader::tm(PUS_APID, SequenceFlags::Unsegmented, 0, 0)
|
||||
.unwrap();
|
||||
let sec_header = PusTmSecondaryHeader::new_simple(
|
||||
3,
|
||||
Subservice::TmHkPacket as u8,
|
||||
@ -224,6 +234,13 @@ fn main() {
|
||||
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
|
||||
.start_success(request.1, ×tamp)
|
||||
.expect("Sending start success failed");
|
||||
|
@ -171,11 +171,11 @@ impl PusReceiver {
|
||||
.unwrap_or_else(|_| panic!("Sending HK request {:?} failed", request));
|
||||
};
|
||||
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 {
|
||||
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 {
|
||||
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
|
||||
{
|
||||
if user_data.len() < 12 {
|
||||
@ -193,6 +193,7 @@ impl PusReceiver {
|
||||
return;
|
||||
}
|
||||
send_request(HkRequest::ModifyCollectionInterval(
|
||||
addressable_id,
|
||||
CollectionIntervalFactor::from_be_bytes(user_data[8..12].try_into().unwrap()),
|
||||
));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user