reduced features

This commit is contained in:
Robin Müller 2023-02-27 13:44:24 +01:00
parent f639eb9b9a
commit 1d19f09519
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
5 changed files with 88 additions and 36 deletions

View File

@ -1,5 +1,3 @@
use crate::tmtc::AddressableId;
pub type CollectionIntervalFactor = u32; pub type CollectionIntervalFactor = u32;
pub type UniqueId = u32; pub type UniqueId = u32;
@ -14,5 +12,5 @@ pub enum HkRequest {
#[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct TargetedHkRequest { pub struct TargetedHkRequest {
target: u32, target: u32,
hk_request: HkRequest hk_request: HkRequest,
} }

View File

@ -72,14 +72,14 @@ impl ModeCommand {
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum ModeRequest { pub enum ModeRequest {
SetMode(ModeAndSubmode), SetMode(ModeAndSubmode),
ReadMode(ModeRequest), ReadMode,
AnnounceMode(ModeRequest), AnnounceMode,
AnnounceModeRecursive(ModeRequest), AnnounceModeRecursive,
} }
#[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct TargetedModeRequest { pub struct TargetedModeRequest {
target_id: TargetId, target_id: TargetId,
mode_request: ModeRequest mode_request: ModeRequest,
} }

View File

@ -35,6 +35,7 @@ use satrs_core::spacepackets::{
tm::{PusTm, PusTmSecondaryHeader}, tm::{PusTm, PusTmSecondaryHeader},
SequenceFlags, SpHeader, SequenceFlags, SpHeader,
}; };
use satrs_core::tmtc::AddressableId;
use satrs_example::{RequestTargetId, OBSW_SERVER_ADDR, SERVER_PORT}; use satrs_example::{RequestTargetId, OBSW_SERVER_ADDR, SERVER_PORT};
use std::collections::HashMap; use std::collections::HashMap;
use std::net::{IpAddr, SocketAddr}; use std::net::{IpAddr, SocketAddr};
@ -253,16 +254,19 @@ fn main() {
loop { loop {
match acs_thread_rx.try_recv() { match acs_thread_rx.try_recv() {
Ok(request) => { Ok(request) => {
info!("ACS thread: Received HK request {:?}", request.0); info!(
update_time(&mut time_provider, &mut timestamp); "ACS thread: Received HK request {:?}",
match request.0 { request.targeted_request
Request::HkRequest(hk_req) => match hk_req {
HkRequest::OneShot(address) => {
assert_eq!(
address.target_id,
RequestTargetId::AcsSubsystem as u32
); );
if address.unique_id == AcsHkIds::TestMgmSet as u32 { update_time(&mut time_provider, &mut timestamp);
match request.targeted_request.request {
Request::HkRequest(hk_req) => match hk_req {
HkRequest::OneShot(unique_id) => {
let target = request.targeted_request.target_id;
assert_eq!(target, RequestTargetId::AcsSubsystem as u32);
if request.targeted_request.target_id
== AcsHkIds::TestMgmSet as u32
{
let mut sp_header = SpHeader::tm( let mut sp_header = SpHeader::tm(
PUS_APID, PUS_APID,
SequenceFlags::Unsegmented, SequenceFlags::Unsegmented,
@ -276,7 +280,11 @@ fn main() {
&timestamp, &timestamp,
); );
let mut buf: [u8; 8] = [0; 8]; let mut buf: [u8; 8] = [0; 8];
address.write_to_be_bytes(&mut buf).unwrap(); let addressable_id = AddressableId {
target_id: target,
unique_id,
};
addressable_id.write_to_be_bytes(&mut buf).unwrap();
let pus_tm = PusTm::new( let pus_tm = PusTm::new(
&mut sp_header, &mut sp_header,
sec_header, sec_header,
@ -296,7 +304,7 @@ fn main() {
} }
} }
let started_token = reporter_aocs let started_token = reporter_aocs
.start_success(request.1, Some(&timestamp)) .start_success(request.token, Some(&timestamp))
.expect("Sending start success failed"); .expect("Sending start success failed");
reporter_aocs reporter_aocs
.completion_success(started_token, Some(&timestamp)) .completion_success(started_token, Some(&timestamp))

View File

@ -3,7 +3,7 @@ use crate::tmtc::{PusTcSource, TmStore};
use log::{info, warn}; use log::{info, warn};
use satrs_core::events::EventU32; use satrs_core::events::EventU32;
use satrs_core::hk::{CollectionIntervalFactor, HkRequest}; use satrs_core::hk::{CollectionIntervalFactor, HkRequest};
use satrs_core::mode::{ModeAndSubmode, ModeCommand, ModeRequest}; use satrs_core::mode::{ModeAndSubmode, ModeRequest};
use satrs_core::params::Params; use satrs_core::params::Params;
use satrs_core::pool::StoreAddr; use satrs_core::pool::StoreAddr;
use satrs_core::pus::event_man::{EventRequest, EventRequestWithToken}; use satrs_core::pus::event_man::{EventRequest, EventRequestWithToken};
@ -268,22 +268,35 @@ impl PusReceiver {
.expect("Sending start failure TM failed"); .expect("Sending start failure TM failed");
return; return;
} }
let send_request = |request: HkRequest| { let send_request = |target: TargetId, request: HkRequest| {
let sender = self let sender = self
.tc_args .tc_args
.request_map .request_map
.get(&addressable_id.target_id) .get(&addressable_id.target_id)
.unwrap(); .unwrap();
sender sender
.send(RequestWithToken(Request::HkRequest(request), token)) .send(RequestWithToken::new(
target,
Request::HkRequest(request),
token,
))
.unwrap_or_else(|_| panic!("Sending HK request {request:?} failed")); .unwrap_or_else(|_| panic!("Sending HK request {request:?} failed"));
}; };
if PusPacket::subservice(pus_tc) == hk::Subservice::TcEnableHkGeneration as u8 { if PusPacket::subservice(pus_tc) == hk::Subservice::TcEnableHkGeneration as u8 {
send_request(HkRequest::Enable(addressable_id)); send_request(
addressable_id.target_id,
HkRequest::Enable(addressable_id.unique_id),
);
} else if PusPacket::subservice(pus_tc) == hk::Subservice::TcDisableHkGeneration as u8 { } else if PusPacket::subservice(pus_tc) == hk::Subservice::TcDisableHkGeneration as u8 {
send_request(HkRequest::Disable(addressable_id)); send_request(
addressable_id.target_id,
HkRequest::Disable(addressable_id.unique_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)); send_request(
addressable_id.target_id,
HkRequest::OneShot(addressable_id.unique_id),
);
} else if PusPacket::subservice(pus_tc) } else if PusPacket::subservice(pus_tc)
== hk::Subservice::TcModifyHkCollectionInterval as u8 == hk::Subservice::TcModifyHkCollectionInterval as u8
{ {
@ -301,10 +314,13 @@ impl PusReceiver {
.expect("Sending start failure TM failed"); .expect("Sending start failure TM failed");
return; return;
} }
send_request(HkRequest::ModifyCollectionInterval( send_request(
addressable_id, addressable_id.target_id,
HkRequest::ModifyCollectionInterval(
addressable_id.unique_id,
CollectionIntervalFactor::from_be_bytes(user_data[8..12].try_into().unwrap()), CollectionIntervalFactor::from_be_bytes(user_data[8..12].try_into().unwrap()),
)); ),
);
} }
} }
@ -550,7 +566,11 @@ impl PusReceiver {
None => warn!("not mode request recipient for target ID {target_id} found"), None => warn!("not mode request recipient for target ID {target_id} found"),
Some(sender_to_recipient) => { Some(sender_to_recipient) => {
sender_to_recipient sender_to_recipient
.send(RequestWithToken(Request::ModeRequest(mode_request), token)) .send(RequestWithToken::new(
target_id,
Request::ModeRequest(mode_request),
token,
))
.expect("sending mode request failed"); .expect("sending mode request failed");
} }
}; };
@ -582,22 +602,19 @@ impl PusReceiver {
.unwrap(), .unwrap(),
) )
.unwrap(); .unwrap();
forward_mode_request( forward_mode_request(target_id, ModeRequest::SetMode(mode_submode));
target_id,
ModeRequest::SetMode(ModeCommand::new(target_id, mode_submode)),
);
} }
Subservice::TcReadMode => { Subservice::TcReadMode => {
let target_id = u32::from_be_bytes(app_data[0..4].try_into().unwrap()); let target_id = u32::from_be_bytes(app_data[0..4].try_into().unwrap());
forward_mode_request(target_id, ModeRequest::ReadMode(target_id)); forward_mode_request(target_id, ModeRequest::ReadMode);
} }
Subservice::TcAnnounceMode => { Subservice::TcAnnounceMode => {
let target_id = u32::from_be_bytes(app_data[0..4].try_into().unwrap()); let target_id = u32::from_be_bytes(app_data[0..4].try_into().unwrap());
forward_mode_request(target_id, ModeRequest::AnnounceMode(target_id)); forward_mode_request(target_id, ModeRequest::AnnounceMode);
} }
Subservice::TcAnnounceModeRecursive => { Subservice::TcAnnounceModeRecursive => {
let target_id = u32::from_be_bytes(app_data[0..4].try_into().unwrap()); let target_id = u32::from_be_bytes(app_data[0..4].try_into().unwrap());
forward_mode_request(target_id, ModeRequest::AnnounceModeRecursive(target_id)); forward_mode_request(target_id, ModeRequest::AnnounceModeRecursive);
} }
_ => { _ => {
warn!("Can not process mode request with subservice {subservice:?}"); warn!("Can not process mode request with subservice {subservice:?}");

View File

@ -1,6 +1,7 @@
use satrs_core::hk::HkRequest; use satrs_core::hk::HkRequest;
use satrs_core::mode::ModeRequest; use satrs_core::mode::ModeRequest;
use satrs_core::pus::verification::{TcStateAccepted, VerificationToken}; use satrs_core::pus::verification::{TcStateAccepted, VerificationToken};
use satrs_core::tmtc::TargetId;
#[derive(Copy, Clone, Eq, PartialEq, Debug)] #[derive(Copy, Clone, Eq, PartialEq, Debug)]
#[non_exhaustive] #[non_exhaustive]
@ -10,4 +11,32 @@ pub enum Request {
} }
#[derive(Copy, Clone, Eq, PartialEq, Debug)] #[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub struct RequestWithToken(pub Request, pub VerificationToken<TcStateAccepted>); pub struct TargetedRequest {
pub(crate) target_id: TargetId,
pub(crate) request: Request,
}
impl TargetedRequest {
pub fn new(target_id: TargetId, request: Request) -> Self {
Self { target_id, request }
}
}
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub struct RequestWithToken {
pub(crate) targeted_request: TargetedRequest,
pub(crate) token: VerificationToken<TcStateAccepted>,
}
impl RequestWithToken {
pub fn new(
target_id: u32,
request: Request,
token: VerificationToken<TcStateAccepted>,
) -> Self {
Self {
targeted_request: TargetedRequest::new(target_id, request),
token,
}
}
}