continue fixing old code
This commit is contained in:
parent
0f2a700ef1
commit
9903194cfc
@ -1,54 +1,119 @@
|
|||||||
use log::{error, warn};
|
use log::{error, warn};
|
||||||
use satrs::action::{ActionRequest, ActionRequestVariant};
|
use satrs::action::{ActionRequest, ActionRequestVariant};
|
||||||
|
use satrs::params::WritableToBeBytes;
|
||||||
use satrs::pool::{SharedStaticMemoryPool, StoreAddr};
|
use satrs::pool::{SharedStaticMemoryPool, StoreAddr};
|
||||||
use satrs::pus::action::{
|
use satrs::pus::action::{
|
||||||
ActionReplyPus, ActionReplyPusWithActionId, ActiveActionRequest, DefaultActiveActionRequestMap,
|
ActionReplyPus, ActionReplyPusWithActionId, ActionRequestWithId, ActivePusActionRequest,
|
||||||
PusService8ReplyHandler,
|
DefaultActiveActionRequestMap,
|
||||||
};
|
};
|
||||||
use satrs::pus::verification::{
|
use satrs::pus::verification::{
|
||||||
FailParams, TcStateAccepted, VerificationReporterWithSharedPoolMpscBoundedSender,
|
self, FailParams, FailParamsWithStep, TcStateAccepted,
|
||||||
VerificationReporterWithVecMpscSender, VerificationReportingProvider, VerificationToken,
|
VerificationReporterWithSharedPoolMpscBoundedSender, VerificationReporterWithVecMpscSender,
|
||||||
|
VerificationReportingProvider, VerificationToken,
|
||||||
};
|
};
|
||||||
use satrs::pus::{
|
use satrs::pus::{
|
||||||
EcssTcAndToken, EcssTcInMemConverter, EcssTcInSharedStoreConverter, EcssTcInVecConverter,
|
ActiveRequestProvider, EcssTcAndToken, EcssTcInMemConverter, EcssTcInSharedStoreConverter,
|
||||||
EcssTcReceiverCore, EcssTmSenderCore, MpscTcReceiver, PusPacketHandlerResult,
|
EcssTcInVecConverter, EcssTcReceiverCore, EcssTmSenderCore, EcssTmtcError, MpscTcReceiver,
|
||||||
PusPacketHandlingError, PusReplyHandler, PusServiceHelper, PusTcToRequestConverter,
|
PusPacketHandlerResult, PusPacketHandlingError, PusReplyHandler, PusServiceHelper,
|
||||||
ReplyHandlerHook, TmAsVecSenderWithId, TmAsVecSenderWithMpsc,
|
PusTcToRequestConverter, TmAsVecSenderWithId, TmAsVecSenderWithMpsc,
|
||||||
TmInSharedPoolSenderWithBoundedMpsc, TmInSharedPoolSenderWithId,
|
TmInSharedPoolSenderWithBoundedMpsc, TmInSharedPoolSenderWithId,
|
||||||
};
|
};
|
||||||
use satrs::request::TargetAndApidId;
|
use satrs::request::{GenericMessage, TargetAndApidId};
|
||||||
use satrs::spacepackets::ecss::tc::PusTcReader;
|
use satrs::spacepackets::ecss::tc::PusTcReader;
|
||||||
use satrs::spacepackets::ecss::PusPacket;
|
use satrs::spacepackets::ecss::{EcssEnumU16, PusPacket};
|
||||||
|
use satrs::spacepackets::time::UnixTimestamp;
|
||||||
use satrs::tmtc::tm_helper::SharedTmPool;
|
use satrs::tmtc::tm_helper::SharedTmPool;
|
||||||
use satrs::{ChannelId, TargetId};
|
use satrs::ChannelId;
|
||||||
use satrs_example::config::tmtc_err::REQUEST_TIMEOUT;
|
|
||||||
use satrs_example::config::{tmtc_err, TcReceiverId, TmSenderId, PUS_APID};
|
use satrs_example::config::{tmtc_err, TcReceiverId, TmSenderId, PUS_APID};
|
||||||
use std::sync::mpsc::{self};
|
use std::sync::mpsc::{self};
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use crate::requests::GenericRequestRouter;
|
use crate::requests::GenericRequestRouter;
|
||||||
|
|
||||||
use super::PusTargetedRequestService;
|
use super::PusTargetedRequestService;
|
||||||
|
|
||||||
#[derive(Default)]
|
pub struct ActionReplyHandler {
|
||||||
pub struct ActionReplyHandler {}
|
fail_data_buf: [u8; 128],
|
||||||
|
}
|
||||||
|
|
||||||
impl PusReplyHandler<ActiveActionRequest, ActionReplyPusWithActionId> for ActionReplyHandler {
|
impl Default for ActionReplyHandler {
|
||||||
type Error = ();
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
fail_data_buf: [0; 128],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PusReplyHandler<ActivePusActionRequest, ActionReplyPusWithActionId> for ActionReplyHandler {
|
||||||
|
type Error = EcssTmtcError;
|
||||||
|
|
||||||
fn handle_unexpected_reply(
|
fn handle_unexpected_reply(
|
||||||
&mut self,
|
&mut self,
|
||||||
reply: &satrs::request::GenericMessage<ActionReplyPusWithActionId>,
|
reply: &GenericMessage<ActionReplyPusWithActionId>,
|
||||||
|
tm_sender: &impl EcssTmSenderCore,
|
||||||
) {
|
) {
|
||||||
log::warn!("received unexpected reply for service {SERVICE}: {reply}");
|
log::warn!("received unexpected reply for service 8: {reply:?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_reply(
|
fn handle_reply(
|
||||||
&mut self,
|
&mut self,
|
||||||
reply: &satrs::request::GenericMessage<ActionReplyPusWithActionId>,
|
reply: &satrs::request::GenericMessage<ActionReplyPusWithActionId>,
|
||||||
|
active_request: &ActivePusActionRequest,
|
||||||
verification_handler: &impl VerificationReportingProvider,
|
verification_handler: &impl VerificationReportingProvider,
|
||||||
|
time_stamp: &[u8],
|
||||||
tm_sender: &impl EcssTmSenderCore,
|
tm_sender: &impl EcssTmSenderCore,
|
||||||
) -> Result<bool, Self::Error> {
|
) -> Result<bool, Self::Error> {
|
||||||
todo!()
|
let remove_entry = match reply.message.variant {
|
||||||
|
ActionReplyPus::CompletionFailed { error_code, params } => {
|
||||||
|
let fail_data_len = params.write_to_be_bytes(&mut self.fail_data_buf)?;
|
||||||
|
verification_handler
|
||||||
|
.completion_failure(
|
||||||
|
active_request.token(),
|
||||||
|
FailParams::new(
|
||||||
|
time_stamp,
|
||||||
|
&error_code,
|
||||||
|
&self.fail_data_buf[..fail_data_len],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.map_err(|e| e.0)?;
|
||||||
|
true
|
||||||
|
}
|
||||||
|
ActionReplyPus::StepFailed {
|
||||||
|
error_code,
|
||||||
|
step,
|
||||||
|
params,
|
||||||
|
} => {
|
||||||
|
let fail_data_len = params.write_to_be_bytes(&mut self.fail_data_buf)?;
|
||||||
|
verification_handler
|
||||||
|
.step_failure(
|
||||||
|
active_request.token(),
|
||||||
|
FailParamsWithStep::new(
|
||||||
|
time_stamp,
|
||||||
|
&EcssEnumU16::new(step),
|
||||||
|
&error_code,
|
||||||
|
&self.fail_data_buf[..fail_data_len],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.map_err(|e| e.0)?;
|
||||||
|
true
|
||||||
|
}
|
||||||
|
ActionReplyPus::Completed => {
|
||||||
|
verification_handler
|
||||||
|
.completion_success(active_request.token(), time_stamp)
|
||||||
|
.map_err(|e| e.0)?;
|
||||||
|
true
|
||||||
|
}
|
||||||
|
ActionReplyPus::StepSuccess { step } => {
|
||||||
|
verification_handler.step_success(
|
||||||
|
&active_request.token(),
|
||||||
|
time_stamp,
|
||||||
|
EcssEnumU16::new(step),
|
||||||
|
)?;
|
||||||
|
false
|
||||||
|
}
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
|
Ok(remove_entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -65,7 +130,9 @@ impl PusReplyHandler<ActiveActionRequest, ActionReplyPusWithActionId> for Action
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct ExampleActionRequestConverter {}
|
pub struct ExampleActionRequestConverter {}
|
||||||
|
|
||||||
impl PusTcToRequestConverter<ActionRequest> for ExampleActionRequestConverter {
|
impl PusTcToRequestConverter<ActivePusActionRequest, ActionRequestWithId>
|
||||||
|
for ExampleActionRequestConverter
|
||||||
|
{
|
||||||
type Error = PusPacketHandlingError;
|
type Error = PusPacketHandlingError;
|
||||||
|
|
||||||
fn convert(
|
fn convert(
|
||||||
@ -74,7 +141,7 @@ impl PusTcToRequestConverter<ActionRequest> for ExampleActionRequestConverter {
|
|||||||
tc: &PusTcReader,
|
tc: &PusTcReader,
|
||||||
time_stamp: &[u8],
|
time_stamp: &[u8],
|
||||||
verif_reporter: &impl VerificationReportingProvider,
|
verif_reporter: &impl VerificationReportingProvider,
|
||||||
) -> Result<(TargetId, ActionRequest), Self::Error> {
|
) -> Result<(ActivePusActionRequest, ActionRequestWithId), Self::Error> {
|
||||||
let subservice = tc.subservice();
|
let subservice = tc.subservice();
|
||||||
let user_data = tc.user_data();
|
let user_data = tc.user_data();
|
||||||
if user_data.len() < 8 {
|
if user_data.len() < 8 {
|
||||||
@ -89,15 +156,27 @@ impl PusTcToRequestConverter<ActionRequest> for ExampleActionRequestConverter {
|
|||||||
found: user_data.len(),
|
found: user_data.len(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let target_id = TargetAndApidId::from_pus_tc(tc).unwrap();
|
let target_id_and_apid = TargetAndApidId::from_pus_tc(tc).unwrap();
|
||||||
let action_id = u32::from_be_bytes(user_data[4..8].try_into().unwrap());
|
let action_id = u32::from_be_bytes(user_data[4..8].try_into().unwrap());
|
||||||
if subservice == 128 {
|
if subservice == 128 {
|
||||||
|
let token = verif_reporter
|
||||||
|
.start_success(token, time_stamp)
|
||||||
|
.map_err(|e| e.0)?;
|
||||||
Ok((
|
Ok((
|
||||||
target_id.raw(),
|
ActivePusActionRequest::new(
|
||||||
ActionRequest::new(
|
|
||||||
action_id,
|
action_id,
|
||||||
ActionRequestVariant::VecData(user_data[8..].to_vec()),
|
target_id_and_apid.into(),
|
||||||
|
token,
|
||||||
|
UnixTimestamp::from_now().unwrap(),
|
||||||
|
Duration::from_secs(30),
|
||||||
),
|
),
|
||||||
|
ActionRequestWithId {
|
||||||
|
request_id: verification::RequestId::new(tc).into(),
|
||||||
|
request: ActionRequest::new(
|
||||||
|
action_id,
|
||||||
|
ActionRequestVariant::VecData(user_data[8..].to_vec()),
|
||||||
|
),
|
||||||
|
},
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
verif_reporter
|
verif_reporter
|
||||||
@ -148,7 +227,7 @@ pub fn create_action_service_static(
|
|||||||
// TODO: Implementation which does not use run-time allocation? Maybe something like
|
// TODO: Implementation which does not use run-time allocation? Maybe something like
|
||||||
// a bounded wrapper which pre-allocates using [HashMap::with_capacity]..
|
// a bounded wrapper which pre-allocates using [HashMap::with_capacity]..
|
||||||
DefaultActiveActionRequestMap::default(),
|
DefaultActiveActionRequestMap::default(),
|
||||||
ActionReplyHandler::<8>::default(),
|
ActionReplyHandler::default(),
|
||||||
);
|
);
|
||||||
Pus8Wrapper {
|
Pus8Wrapper {
|
||||||
action_request_handler,
|
action_request_handler,
|
||||||
@ -187,17 +266,18 @@ pub fn create_action_service_dynamic(
|
|||||||
ExampleActionRequestConverter::default(),
|
ExampleActionRequestConverter::default(),
|
||||||
action_router,
|
action_router,
|
||||||
DefaultActiveActionRequestMap::default(),
|
DefaultActiveActionRequestMap::default(),
|
||||||
ActionReplyHandler::<8>::default(),
|
ActionReplyHandler::default(),
|
||||||
);
|
);
|
||||||
Pus8Wrapper {
|
Pus8Wrapper {
|
||||||
action_request_handler,
|
action_request_handler,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct PusActionReplyHook {}
|
pub struct PusActionReplyHook {}
|
||||||
|
|
||||||
impl ReplyHandlerHook<ActiveActionRequest, ActionReplyPusWithActionId> for PusActionReplyHook {
|
impl ReplyHandlerHook<ActivePusActionRequest, ActionReplyPusWithActionId> for PusActionReplyHook {
|
||||||
fn handle_unexpected_reply(
|
fn handle_unexpected_reply(
|
||||||
&mut self,
|
&mut self,
|
||||||
reply: &satrs::request::GenericMessage<ActionReplyPusWithActionId>,
|
reply: &satrs::request::GenericMessage<ActionReplyPusWithActionId>,
|
||||||
@ -205,7 +285,7 @@ impl ReplyHandlerHook<ActiveActionRequest, ActionReplyPusWithActionId> for PusAc
|
|||||||
println!("received unexpected action reply {:?}", reply);
|
println!("received unexpected action reply {:?}", reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn timeout_callback(&self, active_request: &ActiveActionRequest) {
|
fn timeout_callback(&self, active_request: &ActivePusActionRequest) {
|
||||||
println!("active request {active_request:?} timed out");
|
println!("active request {active_request:?} timed out");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,6 +293,8 @@ impl ReplyHandlerHook<ActiveActionRequest, ActionReplyPusWithActionId> for PusAc
|
|||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
pub struct Pus8Wrapper<
|
pub struct Pus8Wrapper<
|
||||||
TcReceiver: EcssTcReceiverCore,
|
TcReceiver: EcssTcReceiverCore,
|
||||||
TmSender: EcssTmSenderCore,
|
TmSender: EcssTmSenderCore,
|
||||||
@ -225,7 +307,11 @@ pub struct Pus8Wrapper<
|
|||||||
TcInMemConverter,
|
TcInMemConverter,
|
||||||
VerificationReporter,
|
VerificationReporter,
|
||||||
ExampleActionRequestConverter,
|
ExampleActionRequestConverter,
|
||||||
ActionRequest,
|
ActionReplyHandler,
|
||||||
|
DefaultActiveActionRequestMap,
|
||||||
|
ActivePusActionRequest,
|
||||||
|
ActionRequestWithId,
|
||||||
|
ActionReplyPusWithActionId,
|
||||||
>,
|
>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,8 +322,8 @@ impl<
|
|||||||
VerificationReporter: VerificationReportingProvider,
|
VerificationReporter: VerificationReportingProvider,
|
||||||
> Pus8Wrapper<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>
|
> Pus8Wrapper<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>
|
||||||
{
|
{
|
||||||
pub fn handle_next_packet(&mut self) -> bool {
|
pub fn handle_next_packet(&mut self, time_stamp: &[u8]) -> bool {
|
||||||
match self.action_request_handler.handle_one_tc() {
|
match self.action_request_handler.handle_one_tc(time_stamp) {
|
||||||
Ok(result) => match result {
|
Ok(result) => match result {
|
||||||
PusPacketHandlerResult::RequestHandled => {}
|
PusPacketHandlerResult::RequestHandled => {}
|
||||||
PusPacketHandlerResult::RequestHandledPartialSuccess(e) => {
|
PusPacketHandlerResult::RequestHandledPartialSuccess(e) => {
|
||||||
|
@ -1,31 +1,83 @@
|
|||||||
use log::{error, warn};
|
use log::{error, warn};
|
||||||
use satrs::hk::{CollectionIntervalFactor, HkRequest};
|
use satrs::hk::{CollectionIntervalFactor, HkRequest};
|
||||||
use satrs::pool::{SharedStaticMemoryPool, StoreAddr};
|
use satrs::pool::{SharedStaticMemoryPool, StoreAddr};
|
||||||
use satrs::pus::hk::PusService3HkRequestHandler;
|
|
||||||
use satrs::pus::verification::{
|
use satrs::pus::verification::{
|
||||||
FailParams, TcStateAccepted, VerificationReporterWithSharedPoolMpscBoundedSender,
|
FailParams, TcStateAccepted, VerificationReporterWithSharedPoolMpscBoundedSender,
|
||||||
VerificationReporterWithVecMpscSender, VerificationReportingProvider, VerificationToken,
|
VerificationReporterWithVecMpscSender, VerificationReportingProvider, VerificationToken,
|
||||||
};
|
};
|
||||||
use satrs::pus::{
|
use satrs::pus::{
|
||||||
EcssTcAndToken, EcssTcInMemConverter, EcssTcInSharedStoreConverter, EcssTcInVecConverter,
|
ActivePusRequest, ActiveRequestProvider, DefaultActiveRequestMap, EcssTcAndToken,
|
||||||
EcssTcReceiverCore, EcssTmSenderCore, MpscTcReceiver, PusPacketHandlerResult,
|
EcssTcInMemConverter, EcssTcInSharedStoreConverter, EcssTcInVecConverter, EcssTcReceiverCore,
|
||||||
PusPacketHandlingError, PusServiceHelper, PusTcToRequestConverter, TmAsVecSenderWithId,
|
EcssTmSenderCore, MpscTcReceiver, PusPacketHandlerResult, PusPacketHandlingError,
|
||||||
|
PusReplyHandler, PusServiceHelper, PusTcToRequestConverter, TmAsVecSenderWithId,
|
||||||
TmAsVecSenderWithMpsc, TmInSharedPoolSenderWithBoundedMpsc, TmInSharedPoolSenderWithId,
|
TmAsVecSenderWithMpsc, TmInSharedPoolSenderWithBoundedMpsc, TmInSharedPoolSenderWithId,
|
||||||
};
|
};
|
||||||
use satrs::request::TargetAndApidId;
|
use satrs::request::TargetAndApidId;
|
||||||
use satrs::spacepackets::ecss::tc::PusTcReader;
|
use satrs::spacepackets::ecss::tc::PusTcReader;
|
||||||
use satrs::spacepackets::ecss::{hk, PusPacket};
|
use satrs::spacepackets::ecss::{hk, PusPacket};
|
||||||
|
use satrs::spacepackets::time::UnixTimestamp;
|
||||||
use satrs::tmtc::tm_helper::SharedTmPool;
|
use satrs::tmtc::tm_helper::SharedTmPool;
|
||||||
use satrs::{ChannelId, TargetId};
|
use satrs::{ChannelId, TargetId};
|
||||||
use satrs_example::config::{hk_err, tmtc_err, TcReceiverId, TmSenderId, PUS_APID};
|
use satrs_example::config::{hk_err, tmtc_err, TcReceiverId, TmSenderId, PUS_APID};
|
||||||
use std::sync::mpsc::{self};
|
use std::sync::mpsc::{self};
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use crate::requests::GenericRequestRouter;
|
use crate::requests::GenericRequestRouter;
|
||||||
|
|
||||||
|
use super::PusTargetedRequestService;
|
||||||
|
|
||||||
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
|
pub enum HkReply {
|
||||||
|
Ack,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct HkReplyHandler {
|
||||||
|
fail_data_buf: [u8; 128],
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for HkReplyHandler {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
fail_data_buf: [0; 128],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PusReplyHandler<ActivePusRequest, HkReply> for HkReplyHandler {
|
||||||
|
type Error = ();
|
||||||
|
|
||||||
|
fn handle_unexpected_reply(
|
||||||
|
&mut self,
|
||||||
|
reply: &satrs::request::GenericMessage<HkReply>,
|
||||||
|
tm_sender: &impl EcssTmSenderCore,
|
||||||
|
) {
|
||||||
|
log::warn!("received unexpected reply for service 3: {reply:?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle_reply(
|
||||||
|
&mut self,
|
||||||
|
reply: &satrs::request::GenericMessage<HkReply>,
|
||||||
|
active_request: &ActivePusRequest,
|
||||||
|
verification_handler: &impl VerificationReportingProvider,
|
||||||
|
time_stamp: &[u8],
|
||||||
|
tm_sender: &impl EcssTmSenderCore,
|
||||||
|
) -> Result<bool, Self::Error> {
|
||||||
|
let remove_entry = match reply.message {
|
||||||
|
HkReply::Ack => {
|
||||||
|
verification_handler
|
||||||
|
.completion_success(active_request.token(), time_stamp)
|
||||||
|
.expect("Sending end success TM failed");
|
||||||
|
true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Ok(remove_entry)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct ExampleHkRequestConverter {}
|
pub struct ExampleHkRequestConverter {}
|
||||||
|
|
||||||
impl PusTcToRequestConverter<HkRequest> for ExampleHkRequestConverter {
|
impl PusTcToRequestConverter<ActivePusRequest, HkRequest> for ExampleHkRequestConverter {
|
||||||
type Error = PusPacketHandlingError;
|
type Error = PusPacketHandlingError;
|
||||||
|
|
||||||
fn convert(
|
fn convert(
|
||||||
@ -34,7 +86,7 @@ impl PusTcToRequestConverter<HkRequest> for ExampleHkRequestConverter {
|
|||||||
tc: &PusTcReader,
|
tc: &PusTcReader,
|
||||||
time_stamp: &[u8],
|
time_stamp: &[u8],
|
||||||
verif_reporter: &impl VerificationReportingProvider,
|
verif_reporter: &impl VerificationReportingProvider,
|
||||||
) -> Result<(TargetId, HkRequest), Self::Error> {
|
) -> Result<(ActivePusRequest, HkRequest), Self::Error> {
|
||||||
let user_data = tc.user_data();
|
let user_data = tc.user_data();
|
||||||
if user_data.is_empty() {
|
if user_data.is_empty() {
|
||||||
let user_data_len = user_data.len() as u32;
|
let user_data_len = user_data.len() as u32;
|
||||||
@ -71,7 +123,7 @@ impl PusTcToRequestConverter<HkRequest> for ExampleHkRequestConverter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
let subservice = tc.subservice();
|
let subservice = tc.subservice();
|
||||||
let target_id = TargetAndApidId::from_pus_tc(tc).expect("invalid tc format");
|
let target_id_and_apid = TargetAndApidId::from_pus_tc(tc).expect("invalid tc format");
|
||||||
let unique_id = u32::from_be_bytes(tc.user_data()[4..8].try_into().unwrap());
|
let unique_id = u32::from_be_bytes(tc.user_data()[4..8].try_into().unwrap());
|
||||||
|
|
||||||
let standard_subservice = hk::Subservice::try_from(subservice);
|
let standard_subservice = hk::Subservice::try_from(subservice);
|
||||||
@ -84,58 +136,66 @@ impl PusTcToRequestConverter<HkRequest> for ExampleHkRequestConverter {
|
|||||||
.expect("Sending start failure TM failed");
|
.expect("Sending start failure TM failed");
|
||||||
return Err(PusPacketHandlingError::InvalidSubservice(subservice));
|
return Err(PusPacketHandlingError::InvalidSubservice(subservice));
|
||||||
}
|
}
|
||||||
Ok((
|
let request = match standard_subservice.unwrap() {
|
||||||
target_id.into(),
|
hk::Subservice::TcEnableHkGeneration | hk::Subservice::TcEnableDiagGeneration => {
|
||||||
match standard_subservice.unwrap() {
|
HkRequest::Enable(unique_id)
|
||||||
hk::Subservice::TcEnableHkGeneration | hk::Subservice::TcEnableDiagGeneration => {
|
}
|
||||||
HkRequest::Enable(unique_id)
|
hk::Subservice::TcDisableHkGeneration | hk::Subservice::TcDisableDiagGeneration => {
|
||||||
}
|
HkRequest::Disable(unique_id)
|
||||||
hk::Subservice::TcDisableHkGeneration | hk::Subservice::TcDisableDiagGeneration => {
|
}
|
||||||
HkRequest::Disable(unique_id)
|
hk::Subservice::TcReportHkReportStructures => todo!(),
|
||||||
}
|
hk::Subservice::TmHkPacket => todo!(),
|
||||||
hk::Subservice::TcReportHkReportStructures => todo!(),
|
hk::Subservice::TcGenerateOneShotHk | hk::Subservice::TcGenerateOneShotDiag => {
|
||||||
hk::Subservice::TmHkPacket => todo!(),
|
HkRequest::OneShot(unique_id)
|
||||||
hk::Subservice::TcGenerateOneShotHk | hk::Subservice::TcGenerateOneShotDiag => {
|
}
|
||||||
HkRequest::OneShot(unique_id)
|
hk::Subservice::TcModifyDiagCollectionInterval
|
||||||
}
|
| hk::Subservice::TcModifyHkCollectionInterval => {
|
||||||
hk::Subservice::TcModifyDiagCollectionInterval
|
if user_data.len() < 12 {
|
||||||
| hk::Subservice::TcModifyHkCollectionInterval => {
|
|
||||||
if user_data.len() < 12 {
|
|
||||||
verif_reporter
|
|
||||||
.start_failure(
|
|
||||||
token,
|
|
||||||
FailParams::new_no_fail_data(
|
|
||||||
time_stamp,
|
|
||||||
&tmtc_err::NOT_ENOUGH_APP_DATA,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.expect("Sending start failure TM failed");
|
|
||||||
return Err(PusPacketHandlingError::NotEnoughAppData {
|
|
||||||
expected: 12,
|
|
||||||
found: user_data.len(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
HkRequest::ModifyCollectionInterval(
|
|
||||||
unique_id,
|
|
||||||
CollectionIntervalFactor::from_be_bytes(
|
|
||||||
user_data[8..12].try_into().unwrap(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
verif_reporter
|
verif_reporter
|
||||||
.start_failure(
|
.start_failure(
|
||||||
token,
|
token,
|
||||||
FailParams::new(
|
FailParams::new_no_fail_data(
|
||||||
time_stamp,
|
time_stamp,
|
||||||
&tmtc_err::PUS_SUBSERVICE_NOT_IMPLEMENTED,
|
&tmtc_err::NOT_ENOUGH_APP_DATA,
|
||||||
&[subservice],
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.expect("Sending start failure TM failed");
|
.expect("Sending start failure TM failed");
|
||||||
return Err(PusPacketHandlingError::InvalidSubservice(subservice));
|
return Err(PusPacketHandlingError::NotEnoughAppData {
|
||||||
|
expected: 12,
|
||||||
|
found: user_data.len(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
HkRequest::ModifyCollectionInterval(
|
||||||
|
unique_id,
|
||||||
|
CollectionIntervalFactor::from_be_bytes(user_data[8..12].try_into().unwrap()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
verif_reporter
|
||||||
|
.start_failure(
|
||||||
|
token,
|
||||||
|
FailParams::new(
|
||||||
|
time_stamp,
|
||||||
|
&tmtc_err::PUS_SUBSERVICE_NOT_IMPLEMENTED,
|
||||||
|
&[subservice],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.expect("Sending start failure TM failed");
|
||||||
|
return Err(PusPacketHandlingError::InvalidSubservice(subservice));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let token = verif_reporter
|
||||||
|
.start_success(token, time_stamp)
|
||||||
|
.map_err(|e| e.0)?;
|
||||||
|
Ok((
|
||||||
|
ActivePusRequest::new(
|
||||||
|
target_id_and_apid.into(),
|
||||||
|
token,
|
||||||
|
UnixTimestamp::from_now().unwrap(),
|
||||||
|
Duration::from_secs(60),
|
||||||
|
)
|
||||||
|
.into(),
|
||||||
|
request,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,7 +221,7 @@ pub fn create_hk_service_static(
|
|||||||
);
|
);
|
||||||
let hk_srv_receiver =
|
let hk_srv_receiver =
|
||||||
MpscTcReceiver::new(TcReceiverId::PusHk as ChannelId, "PUS_8_TC_RECV", pus_hk_rx);
|
MpscTcReceiver::new(TcReceiverId::PusHk as ChannelId, "PUS_8_TC_RECV", pus_hk_rx);
|
||||||
let pus_3_handler = PusService3HkRequestHandler::new(
|
let pus_3_handler = PusTargetedRequestService::new(
|
||||||
PusServiceHelper::new(
|
PusServiceHelper::new(
|
||||||
hk_srv_receiver,
|
hk_srv_receiver,
|
||||||
hk_srv_tm_sender,
|
hk_srv_tm_sender,
|
||||||
@ -171,6 +231,8 @@ pub fn create_hk_service_static(
|
|||||||
),
|
),
|
||||||
ExampleHkRequestConverter::default(),
|
ExampleHkRequestConverter::default(),
|
||||||
request_router,
|
request_router,
|
||||||
|
DefaultActiveRequestMap::default(),
|
||||||
|
HkReplyHandler::default(),
|
||||||
);
|
);
|
||||||
Pus3Wrapper { pus_3_handler }
|
Pus3Wrapper { pus_3_handler }
|
||||||
}
|
}
|
||||||
@ -193,7 +255,7 @@ pub fn create_hk_service_dynamic(
|
|||||||
);
|
);
|
||||||
let hk_srv_receiver =
|
let hk_srv_receiver =
|
||||||
MpscTcReceiver::new(TcReceiverId::PusHk as ChannelId, "PUS_8_TC_RECV", pus_hk_rx);
|
MpscTcReceiver::new(TcReceiverId::PusHk as ChannelId, "PUS_8_TC_RECV", pus_hk_rx);
|
||||||
let pus_3_handler = PusService3HkRequestHandler::new(
|
let pus_3_handler = PusTargetedRequestService::new(
|
||||||
PusServiceHelper::new(
|
PusServiceHelper::new(
|
||||||
hk_srv_receiver,
|
hk_srv_receiver,
|
||||||
hk_srv_tm_sender,
|
hk_srv_tm_sender,
|
||||||
@ -203,6 +265,8 @@ pub fn create_hk_service_dynamic(
|
|||||||
),
|
),
|
||||||
ExampleHkRequestConverter::default(),
|
ExampleHkRequestConverter::default(),
|
||||||
request_router,
|
request_router,
|
||||||
|
DefaultActiveRequestMap::default(),
|
||||||
|
HkReplyHandler::default(),
|
||||||
);
|
);
|
||||||
Pus3Wrapper { pus_3_handler }
|
Pus3Wrapper { pus_3_handler }
|
||||||
}
|
}
|
||||||
@ -213,13 +277,17 @@ pub struct Pus3Wrapper<
|
|||||||
TcInMemConverter: EcssTcInMemConverter,
|
TcInMemConverter: EcssTcInMemConverter,
|
||||||
VerificationReporter: VerificationReportingProvider,
|
VerificationReporter: VerificationReportingProvider,
|
||||||
> {
|
> {
|
||||||
pub(crate) pus_3_handler: PusService3HkRequestHandler<
|
pub(crate) pus_3_handler: PusTargetedRequestService<
|
||||||
TcReceiver,
|
TcReceiver,
|
||||||
TmSender,
|
TmSender,
|
||||||
TcInMemConverter,
|
TcInMemConverter,
|
||||||
VerificationReporter,
|
VerificationReporter,
|
||||||
ExampleHkRequestConverter,
|
ExampleHkRequestConverter,
|
||||||
GenericRequestRouter,
|
HkReplyHandler,
|
||||||
|
DefaultActiveRequestMap<ActivePusRequest>,
|
||||||
|
ActivePusRequest,
|
||||||
|
HkRequest,
|
||||||
|
HkReply,
|
||||||
>,
|
>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,8 +298,8 @@ impl<
|
|||||||
VerificationReporter: VerificationReportingProvider,
|
VerificationReporter: VerificationReportingProvider,
|
||||||
> Pus3Wrapper<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>
|
> Pus3Wrapper<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>
|
||||||
{
|
{
|
||||||
pub fn handle_next_packet(&mut self) -> bool {
|
pub fn handle_next_packet(&mut self, time_stamp: &[u8]) -> bool {
|
||||||
match self.pus_3_handler.handle_one_tc() {
|
match self.pus_3_handler.handle_one_tc(time_stamp) {
|
||||||
Ok(result) => match result {
|
Ok(result) => match result {
|
||||||
PusPacketHandlerResult::RequestHandled => {}
|
PusPacketHandlerResult::RequestHandled => {}
|
||||||
PusPacketHandlerResult::RequestHandledPartialSuccess(e) => {
|
PusPacketHandlerResult::RequestHandledPartialSuccess(e) => {
|
||||||
|
@ -1,16 +1,11 @@
|
|||||||
use crate::requests::GenericRequestRouter;
|
use crate::requests::GenericRequestRouter;
|
||||||
use crate::tmtc::MpscStoreAndSendError;
|
use crate::tmtc::MpscStoreAndSendError;
|
||||||
use log::warn;
|
use log::warn;
|
||||||
use satrs::pus::verification::{
|
use satrs::pus::verification::{self, FailParams, VerificationReportingProvider};
|
||||||
self, FailParams, VerificationReporter, VerificationReporterWithSharedPoolMpscBoundedSender,
|
|
||||||
VerificationReporterWithVecMpscSender, VerificationReportingProvider,
|
|
||||||
};
|
|
||||||
use satrs::pus::{
|
use satrs::pus::{
|
||||||
ActiveRequestMapProvider, ActiveRequestProvider, DefaultActiveRequestMap, EcssTcAndToken,
|
ActiveRequestMapProvider, ActiveRequestProvider, EcssTcAndToken, EcssTcInMemConverter,
|
||||||
EcssTcInMemConverter, EcssTcInSharedStoreConverter, EcssTcInVecConverter, EcssTcReceiverCore,
|
EcssTcReceiverCore, EcssTmSenderCore, PusPacketHandlerResult, PusPacketHandlingError,
|
||||||
EcssTmSenderCore, GenericRoutingError, MpscTcReceiver, PusPacketHandlerResult, PusReplyHandler,
|
PusReplyHandler, PusRequestRouter, PusServiceHelper, PusTcToRequestConverter, TcInMemory,
|
||||||
PusServiceHelper, PusServiceReplyHandler, PusTcToRequestConverter, ReplyHandlerHook,
|
|
||||||
TcInMemory, TmAsVecSenderWithMpsc, TmInSharedPoolSenderWithBoundedMpsc,
|
|
||||||
};
|
};
|
||||||
use satrs::request::GenericMessage;
|
use satrs::request::GenericMessage;
|
||||||
use satrs::spacepackets::ecss::tc::PusTcReader;
|
use satrs::spacepackets::ecss::tc::PusTcReader;
|
||||||
@ -85,10 +80,10 @@ pub struct PusTargetedRequestService<
|
|||||||
TmSender: EcssTmSenderCore,
|
TmSender: EcssTmSenderCore,
|
||||||
TcInMemConverter: EcssTcInMemConverter,
|
TcInMemConverter: EcssTcInMemConverter,
|
||||||
VerificationReporter: VerificationReportingProvider,
|
VerificationReporter: VerificationReportingProvider,
|
||||||
RequestConverter: PusTcToRequestConverter<RequestType>,
|
RequestConverter: PusTcToRequestConverter<ActiveRequestInfo, RequestType, Error = PusPacketHandlingError>,
|
||||||
ReplyHook: ReplyHandlerHook<RequestType, ReplyType>,
|
ReplyHandler: PusReplyHandler<ActiveRequestInfo, ReplyType>,
|
||||||
ActiveRequestMap: ActiveRequestMapProvider<RequestType>,
|
ActiveRequestMap: ActiveRequestMapProvider<ActiveRequestInfo>,
|
||||||
ActiveRequestType: ActiveRequestProvider,
|
ActiveRequestInfo: ActiveRequestProvider,
|
||||||
RequestType,
|
RequestType,
|
||||||
ReplyType,
|
ReplyType,
|
||||||
> {
|
> {
|
||||||
@ -97,8 +92,8 @@ pub struct PusTargetedRequestService<
|
|||||||
pub request_router: GenericRequestRouter,
|
pub request_router: GenericRequestRouter,
|
||||||
pub request_converter: RequestConverter,
|
pub request_converter: RequestConverter,
|
||||||
pub active_request_map: ActiveRequestMap,
|
pub active_request_map: ActiveRequestMap,
|
||||||
pub reply_hook: ReplyHook,
|
pub reply_hook: ReplyHandler,
|
||||||
phantom: std::marker::PhantomData<RequestType>,
|
phantom: std::marker::PhantomData<(RequestType, ActiveRequestInfo, ReplyType)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<
|
impl<
|
||||||
@ -106,10 +101,10 @@ impl<
|
|||||||
TmSender: EcssTmSenderCore,
|
TmSender: EcssTmSenderCore,
|
||||||
TcInMemConverter: EcssTcInMemConverter,
|
TcInMemConverter: EcssTcInMemConverter,
|
||||||
VerificationReporter: VerificationReportingProvider,
|
VerificationReporter: VerificationReportingProvider,
|
||||||
RequestConverter: PusTcToRequestConverter<RequestType>,
|
RequestConverter: PusTcToRequestConverter<ActiveRequestInfo, RequestType, Error = PusPacketHandlingError>,
|
||||||
ReplyHandler: PusReplyHandler<ActiveRequestType, ReplyType>,
|
ReplyHandler: PusReplyHandler<ActiveRequestInfo, ReplyType>,
|
||||||
ActiveRequestMap: ActiveRequestMapProvider<ActiveRequestType>,
|
ActiveRequestMap: ActiveRequestMapProvider<ActiveRequestInfo>,
|
||||||
ActiveRequestType: ActiveRequestProvider,
|
ActiveRequestInfo: ActiveRequestProvider,
|
||||||
RequestType,
|
RequestType,
|
||||||
ReplyType,
|
ReplyType,
|
||||||
>
|
>
|
||||||
@ -121,7 +116,7 @@ impl<
|
|||||||
RequestConverter,
|
RequestConverter,
|
||||||
ReplyHandler,
|
ReplyHandler,
|
||||||
ActiveRequestMap,
|
ActiveRequestMap,
|
||||||
ActiveRequestType,
|
ActiveRequestInfo,
|
||||||
RequestType,
|
RequestType,
|
||||||
ReplyType,
|
ReplyType,
|
||||||
>
|
>
|
||||||
@ -148,7 +143,10 @@ impl<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_one_tc(&mut self) {
|
pub fn handle_one_tc(
|
||||||
|
&mut self,
|
||||||
|
time_stamp: &[u8],
|
||||||
|
) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
|
||||||
let possible_packet = self.service_helper.retrieve_and_accept_next_packet()?;
|
let possible_packet = self.service_helper.retrieve_and_accept_next_packet()?;
|
||||||
if possible_packet.is_none() {
|
if possible_packet.is_none() {
|
||||||
return Ok(PusPacketHandlerResult::Empty);
|
return Ok(PusPacketHandlerResult::Empty);
|
||||||
@ -159,7 +157,6 @@ impl<
|
|||||||
.tc_in_mem_converter
|
.tc_in_mem_converter
|
||||||
.convert_ecss_tc_in_memory_to_reader(&ecss_tc_and_token.tc_in_memory)?;
|
.convert_ecss_tc_in_memory_to_reader(&ecss_tc_and_token.tc_in_memory)?;
|
||||||
let mut partial_error = None;
|
let mut partial_error = None;
|
||||||
let time_stamp = get_current_cds_short_timestamp(&mut partial_error);
|
|
||||||
let (active_request, action_request) = self.request_converter.convert(
|
let (active_request, action_request) = self.request_converter.convert(
|
||||||
ecss_tc_and_token.token,
|
ecss_tc_and_token.token,
|
||||||
&tc,
|
&tc,
|
||||||
@ -175,7 +172,7 @@ impl<
|
|||||||
self.active_request_map
|
self.active_request_map
|
||||||
.insert(verif_request_id.into(), active_request);
|
.insert(verif_request_id.into(), active_request);
|
||||||
self.request_router.handle_error(
|
self.request_router.handle_error(
|
||||||
target_id,
|
active_request.target_id(),
|
||||||
ecss_tc_and_token.token,
|
ecss_tc_and_token.token,
|
||||||
&tc,
|
&tc,
|
||||||
e.clone(),
|
e.clone(),
|
||||||
|
@ -5,7 +5,7 @@ use crate::{
|
|||||||
ChannelId, TargetId,
|
ChannelId, TargetId,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{verification::VerificationToken, ActiveRequest, ActiveRequestProvider};
|
use super::{verification::VerificationToken, ActivePusRequest, ActiveRequestProvider};
|
||||||
|
|
||||||
use delegate::delegate;
|
use delegate::delegate;
|
||||||
use satrs_shared::res_code::ResultU16;
|
use satrs_shared::res_code::ResultU16;
|
||||||
@ -75,12 +75,12 @@ impl GenericActionReplyPus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct ActiveActionRequest {
|
pub struct ActivePusActionRequest {
|
||||||
pub action_id: ActionId,
|
pub action_id: ActionId,
|
||||||
common: ActiveRequest,
|
common: ActivePusRequest,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ActiveRequestProvider for ActiveActionRequest {
|
impl ActiveRequestProvider for ActivePusActionRequest {
|
||||||
delegate! {
|
delegate! {
|
||||||
to self.common {
|
to self.common {
|
||||||
fn target_id(&self) -> TargetId;
|
fn target_id(&self) -> TargetId;
|
||||||
@ -91,6 +91,21 @@ impl ActiveRequestProvider for ActiveActionRequest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ActivePusActionRequest {
|
||||||
|
pub fn new(
|
||||||
|
action_id: ActionId,
|
||||||
|
target_id: TargetId,
|
||||||
|
token: VerificationToken<super::verification::TcStateStarted>,
|
||||||
|
start_time: spacepackets::time::UnixTimestamp,
|
||||||
|
timeout: core::time::Duration,
|
||||||
|
) -> Self {
|
||||||
|
Self {
|
||||||
|
action_id,
|
||||||
|
common: ActivePusRequest::new(target_id, token, start_time, timeout),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
|
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
|
||||||
pub mod alloc_mod {}
|
pub mod alloc_mod {}
|
||||||
@ -105,7 +120,6 @@ pub mod std_mod {
|
|||||||
self, FailParams, FailParamsWithStep, TcStateStarted, VerificationReportingProvider,
|
self, FailParams, FailParamsWithStep, TcStateStarted, VerificationReportingProvider,
|
||||||
},
|
},
|
||||||
ActiveRequestMapProvider, DefaultActiveRequestMap, EcssTmSenderCore, EcssTmtcError,
|
ActiveRequestMapProvider, DefaultActiveRequestMap, EcssTmSenderCore, EcssTmtcError,
|
||||||
ReplyHandlerHook,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
@ -114,7 +128,7 @@ pub mod std_mod {
|
|||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
pub type DefaultActiveActionRequestMap = DefaultActiveRequestMap<ActiveActionRequest>;
|
pub type DefaultActiveActionRequestMap = DefaultActiveRequestMap<ActivePusActionRequest>;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
/// Type definition for a PUS 8 action service reply handler which constrains the
|
/// Type definition for a PUS 8 action service reply handler which constrains the
|
||||||
@ -317,12 +331,13 @@ mod tests {
|
|||||||
},
|
},
|
||||||
EcssTcInMemConverter, EcssTcInVecConverter, EcssTmtcError, GenericRoutingError,
|
EcssTcInMemConverter, EcssTcInVecConverter, EcssTmtcError, GenericRoutingError,
|
||||||
MpscTcReceiver, PusPacketHandlerResult, PusPacketHandlingError, PusRequestRouter,
|
MpscTcReceiver, PusPacketHandlerResult, PusPacketHandlingError, PusRequestRouter,
|
||||||
PusServiceHelper, PusTcToRequestConverter, ReplyHandlerHook, TmAsVecSenderWithMpsc,
|
PusServiceHelper, PusTcToRequestConverter, TmAsVecSenderWithMpsc,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
/*
|
||||||
impl<Request> PusRequestRouter<Request> for TestRouter<Request> {
|
impl<Request> PusRequestRouter<Request> for TestRouter<Request> {
|
||||||
type Error = GenericRoutingError;
|
type Error = GenericRoutingError;
|
||||||
|
|
||||||
@ -507,15 +522,15 @@ mod tests {
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct TestReplyHandlerHook {
|
pub struct TestReplyHandlerHook {
|
||||||
pub unexpected_replies: VecDeque<GenericActionReplyPus>,
|
pub unexpected_replies: VecDeque<GenericActionReplyPus>,
|
||||||
pub timeouts: RefCell<VecDeque<ActiveActionRequest>>,
|
pub timeouts: RefCell<VecDeque<ActivePusActionRequest>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ReplyHandlerHook<ActiveActionRequest, ActionReplyPusWithActionId> for TestReplyHandlerHook {
|
impl ReplyHandlerHook<ActivePusActionRequest, ActionReplyPusWithActionId> for TestReplyHandlerHook {
|
||||||
fn handle_unexpected_reply(&mut self, reply: &GenericActionReplyPus) {
|
fn handle_unexpected_reply(&mut self, reply: &GenericActionReplyPus) {
|
||||||
self.unexpected_replies.push_back(reply.clone());
|
self.unexpected_replies.push_back(reply.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn timeout_callback(&self, active_request: &ActiveActionRequest) {
|
fn timeout_callback(&self, active_request: &ActivePusActionRequest) {
|
||||||
self.timeouts.borrow_mut().push_back(active_request.clone());
|
self.timeouts.borrow_mut().push_back(active_request.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -870,4 +885,5 @@ mod tests {
|
|||||||
assert_eq!(reply.request_id, request_id);
|
assert_eq!(reply.request_id, request_id);
|
||||||
assert_eq!(reply.message.variant, ActionReplyPus::Completed);
|
assert_eq!(reply.message.variant, ActionReplyPus::Completed);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
@ -304,6 +304,22 @@ pub struct ActivePusRequest {
|
|||||||
timeout: Duration,
|
timeout: Duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ActivePusRequest {
|
||||||
|
pub fn new(
|
||||||
|
target_id: TargetId,
|
||||||
|
token: VerificationToken<TcStateStarted>,
|
||||||
|
start_time: UnixTimestamp,
|
||||||
|
timeout: Duration,
|
||||||
|
) -> Self {
|
||||||
|
Self {
|
||||||
|
target_id,
|
||||||
|
token,
|
||||||
|
start_time,
|
||||||
|
timeout,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ActiveRequestProvider for ActivePusRequest {
|
impl ActiveRequestProvider for ActivePusRequest {
|
||||||
fn target_id(&self) -> TargetId {
|
fn target_id(&self) -> TargetId {
|
||||||
self.target_id
|
self.target_id
|
||||||
@ -330,7 +346,7 @@ pub trait PusRequestRouter<Request> {
|
|||||||
fn route(
|
fn route(
|
||||||
&self,
|
&self,
|
||||||
target_id: TargetId,
|
target_id: TargetId,
|
||||||
hk_request: Request,
|
request: Request,
|
||||||
token: VerificationToken<TcStateAccepted>,
|
token: VerificationToken<TcStateAccepted>,
|
||||||
) -> Result<(), Self::Error>;
|
) -> Result<(), Self::Error>;
|
||||||
|
|
||||||
@ -351,7 +367,9 @@ pub trait PusReplyHandler<ActiveRequestInfo: ActiveRequestProvider, ReplyType> {
|
|||||||
fn handle_reply(
|
fn handle_reply(
|
||||||
&mut self,
|
&mut self,
|
||||||
reply: &GenericMessage<ReplyType>,
|
reply: &GenericMessage<ReplyType>,
|
||||||
|
active_request: &ActiveRequestInfo,
|
||||||
verification_handler: &impl VerificationReportingProvider,
|
verification_handler: &impl VerificationReportingProvider,
|
||||||
|
time_stamp: &[u8],
|
||||||
tm_sender: &impl EcssTmSenderCore,
|
tm_sender: &impl EcssTmSenderCore,
|
||||||
) -> Result<bool, Self::Error>;
|
) -> Result<bool, Self::Error>;
|
||||||
|
|
||||||
@ -467,7 +485,7 @@ pub mod alloc_mod {
|
|||||||
///
|
///
|
||||||
/// A [VerificationReportingProvider] instance is passed to the user to also allow handling
|
/// A [VerificationReportingProvider] instance is passed to the user to also allow handling
|
||||||
/// of the verification process as part of the PUS standard requirements.
|
/// of the verification process as part of the PUS standard requirements.
|
||||||
pub trait PusTcToRequestConverter<ActiveRequestInfo, Request> {
|
pub trait PusTcToRequestConverter<ActiveRequestInfo: ActiveRequestProvider, Request> {
|
||||||
type Error;
|
type Error;
|
||||||
fn convert(
|
fn convert(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -42,26 +42,16 @@ pub mod std_mod {
|
|||||||
SpHeader,
|
SpHeader,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
/*
|
||||||
mode::GenericModeReply,
|
|
||||||
pus::{
|
|
||||||
mode::Subservice,
|
|
||||||
verification::{
|
|
||||||
self, FailParams, TcStateStarted, VerificationReportingProvider, VerificationToken,
|
|
||||||
},
|
|
||||||
ActivePusRequest, ActiveRequestMapProvider, EcssTmSenderCore, EcssTmtcError,
|
|
||||||
PusServiceReplyHandler, PusTmWrapper, ReplyHandlerHook,
|
|
||||||
},
|
|
||||||
TargetId,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub trait ModeReplyHook: ReplyHandlerHook<ActivePusRequest, ModeReply> {
|
pub trait ModeReplyHook: ReplyHandlerHook<ActivePusRequest, ModeReply> {
|
||||||
fn wrong_mode_result_code(&self) -> ResultU16;
|
fn wrong_mode_result_code(&self) -> ResultU16;
|
||||||
fn can_not_reach_mode_result_code(&self) -> ResultU16;
|
fn can_not_reach_mode_result_code(&self) -> ResultU16;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
use super::{ModeReply, MODE_SERVICE_ID};
|
use super::{ModeReply, MODE_SERVICE_ID};
|
||||||
|
|
||||||
|
/*
|
||||||
/// Type definition for a PUS mode servicd reply handler which constrains the
|
/// Type definition for a PUS mode servicd reply handler which constrains the
|
||||||
/// [PusServiceReplyHandler] active request and reply generics to the [ActiveActionRequest] and
|
/// [PusServiceReplyHandler] active request and reply generics to the [ActiveActionRequest] and
|
||||||
/// [ActionReplyPusWithIds] type.
|
/// [ActionReplyPusWithIds] type.
|
||||||
@ -180,6 +170,7 @@ pub mod std_mod {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
Loading…
Reference in New Issue
Block a user