actually need to do something with the IDs
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-02-27 16:52:14 +01:00
parent a7e614dfb3
commit 9f82c57a95

View File

@ -4,7 +4,7 @@ use crate::{
TargetId, TargetId,
}; };
use super::verification::{TcStateAccepted, VerificationToken}; use super::verification::{RequestId, TcStateAccepted, VerificationToken};
use satrs_shared::res_code::ResultU16; use satrs_shared::res_code::ResultU16;
use spacepackets::ecss::EcssEnumU16; use spacepackets::ecss::EcssEnumU16;
@ -17,22 +17,36 @@ pub use std_mod::*;
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
pub use alloc_mod::*; pub use alloc_mod::*;
#[derive(Clone, Debug)]
pub struct ActionRequestWithId {
pub req_id: RequestId,
pub request: ActionRequest,
}
#[derive(Clone, Debug)]
pub struct ActionReplyPusWithIds {
pub action_id: ActionId,
pub req_id: RequestId,
pub reply: ActionReplyPus,
}
/// A reply to an action request, but tailored to the PUS standard verification process. /// A reply to an action request, but tailored to the PUS standard verification process.
#[non_exhaustive] #[non_exhaustive]
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum ActionReplyPus { pub enum ActionReplyPus {
Completed,
StepSuccess {
step: EcssEnumU16,
},
CompletionFailed { CompletionFailed {
id: ActionId,
error_code: ResultU16, error_code: ResultU16,
params: Params, params: Params,
}, },
StepFailed { StepFailed {
id: ActionId,
error_code: ResultU16, error_code: ResultU16,
step: EcssEnumU16, step: EcssEnumU16,
params: Params, params: Params,
}, },
Completed(ActionId),
} }
/// This trait is an abstraction for the routing of PUS service 8 action requests to a dedicated /// This trait is an abstraction for the routing of PUS service 8 action requests to a dedicated
@ -280,36 +294,34 @@ pub mod std_mod {
pub fn handle_action_reply( pub fn handle_action_reply(
&mut self, &mut self,
reply: ActionReplyPus, action_reply_with_ids: ActionReplyPusWithIds,
token: VerificationToken<TcStateStarted>,
time_stamp: &[u8], time_stamp: &[u8],
) -> Result<(), EcssTmtcError> { ) -> Result<(), EcssTmtcError> {
match reply { let active_req = self.active_requests.get(&action_reply_with_ids.req_id);
ActionReplyPus::CompletionFailed { if active_req.is_none() {
id: _, // TODO: This is an unexpected reply. We need to deal with this somehow.
error_code, }
params, let active_req = active_req.unwrap();
} => { match action_reply_with_ids.reply {
self.active_requests.remove(&token.req_id()); ActionReplyPus::CompletionFailed { error_code, params } => {
params.write_to_be_bytes(&mut self.fail_data_buf)?; params.write_to_be_bytes(&mut self.fail_data_buf)?;
self.verification_reporter self.verification_reporter
.completion_failure( .completion_failure(
token, active_req.token,
FailParams::new(time_stamp, &error_code, &self.fail_data_buf), FailParams::new(time_stamp, &error_code, &self.fail_data_buf),
) )
.map_err(|e| e.0)?; .map_err(|e| e.0)?;
self.active_requests.remove(&action_reply_with_ids.req_id);
} }
ActionReplyPus::StepFailed { ActionReplyPus::StepFailed {
id: _,
error_code, error_code,
step, step,
params, params,
} => { } => {
self.active_requests.remove(&token.req_id());
params.write_to_be_bytes(&mut self.fail_data_buf)?; params.write_to_be_bytes(&mut self.fail_data_buf)?;
self.verification_reporter self.verification_reporter
.step_failure( .step_failure(
token, active_req.token,
FailParamsWithStep::new( FailParamsWithStep::new(
time_stamp, time_stamp,
&step, &step,
@ -318,12 +330,17 @@ pub mod std_mod {
), ),
) )
.map_err(|e| e.0)?; .map_err(|e| e.0)?;
self.active_requests.remove(&action_reply_with_ids.req_id);
} }
ActionReplyPus::Completed(_id) => { ActionReplyPus::Completed => {
self.active_requests.remove(&token.req_id());
self.verification_reporter self.verification_reporter
.completion_success(token, time_stamp) .completion_success(active_req.token, time_stamp)
.map_err(|e| e.0)?; .map_err(|e| e.0)?;
self.active_requests.remove(&action_reply_with_ids.req_id);
}
ActionReplyPus::StepSuccess { step } => {
self.verification_reporter
.step_success(&active_req.token, time_stamp, step)?;
} }
} }
Ok(()) Ok(())