This commit is contained in:
@ -1,38 +1,14 @@
|
||||
use spacepackets::ecss::tc::PusTcReader;
|
||||
|
||||
use crate::{action::ActionRequest, TargetId};
|
||||
|
||||
use super::verification::{TcStateAccepted, VerificationReporterWithSender, VerificationToken};
|
||||
use super::verification::{TcStateAccepted, VerificationToken};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
|
||||
pub use std_mod::*;
|
||||
|
||||
/// This trait is an abstraction for the conversion of a PUS service 8 action telecommand into
|
||||
/// an [ActionRequest].
|
||||
///
|
||||
/// Having a dedicated trait for this allows maximum flexiblity and tailoring of the standard.
|
||||
/// The only requirement is that a valid [TargetId] and an [ActionRequest] are returned by the
|
||||
/// core conversion function.
|
||||
///
|
||||
/// The user should take care of performing the error handling as well. Some of the following
|
||||
/// aspects might be relevant:
|
||||
///
|
||||
/// - Checking the validity of the APID, service ID, subservice ID.
|
||||
/// - Checking the validity of the user data.
|
||||
///
|
||||
/// A [VerificationReporterWithSender] instance is passed to the user to also allow handling
|
||||
/// of the verification process as part of the PUS standard requirements.
|
||||
pub trait PusActionToRequestConverter {
|
||||
type Error;
|
||||
fn convert(
|
||||
&mut self,
|
||||
token: VerificationToken<TcStateAccepted>,
|
||||
tc: &PusTcReader,
|
||||
time_stamp: &[u8],
|
||||
verif_reporter: &mut VerificationReporterWithSender,
|
||||
) -> Result<(TargetId, ActionRequest), Self::Error>;
|
||||
}
|
||||
#[cfg(feature = "alloc")]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
|
||||
pub use alloc_mod::*;
|
||||
|
||||
/// This trait is an abstraction for the routing of PUS service 8 action requests to a dedicated
|
||||
/// recipient using the generic [TargetId].
|
||||
@ -46,6 +22,42 @@ pub trait PusActionRequestRouter {
|
||||
) -> Result<(), Self::Error>;
|
||||
}
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
|
||||
pub mod alloc_mod {
|
||||
use spacepackets::ecss::tc::PusTcReader;
|
||||
|
||||
use crate::pus::verification::VerificationReporterWithSender;
|
||||
|
||||
use super::*;
|
||||
|
||||
/// This trait is an abstraction for the conversion of a PUS service 8 action telecommand into
|
||||
/// an [ActionRequest].
|
||||
///
|
||||
/// Having a dedicated trait for this allows maximum flexiblity and tailoring of the standard.
|
||||
/// The only requirement is that a valid [TargetId] and an [ActionRequest] are returned by the
|
||||
/// core conversion function.
|
||||
///
|
||||
/// The user should take care of performing the error handling as well. Some of the following
|
||||
/// aspects might be relevant:
|
||||
///
|
||||
/// - Checking the validity of the APID, service ID, subservice ID.
|
||||
/// - Checking the validity of the user data.
|
||||
///
|
||||
/// A [VerificationReporterWithSender] instance is passed to the user to also allow handling
|
||||
/// of the verification process as part of the PUS standard requirements.
|
||||
pub trait PusActionToRequestConverter {
|
||||
type Error;
|
||||
fn convert(
|
||||
&mut self,
|
||||
token: VerificationToken<TcStateAccepted>,
|
||||
tc: &PusTcReader,
|
||||
time_stamp: &[u8],
|
||||
verif_reporter: &mut VerificationReporterWithSender,
|
||||
) -> Result<(TargetId, ActionRequest), Self::Error>;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
|
||||
pub mod std_mod {
|
||||
|
@ -1,28 +1,16 @@
|
||||
pub use spacepackets::ecss::hk::*;
|
||||
use spacepackets::ecss::tc::PusTcReader;
|
||||
|
||||
use crate::{hk::HkRequest, TargetId};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
|
||||
pub use std_mod::*;
|
||||
|
||||
use super::{
|
||||
verification::{TcStateAccepted, VerificationReporterWithSender, VerificationToken},
|
||||
EcssTcInMemConverter, GenericRoutingError, PusPacketHandlerResult, PusPacketHandlingError,
|
||||
PusRoutingErrorHandler, PusServiceBase, PusServiceHelper,
|
||||
};
|
||||
#[cfg(feature = "alloc")]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
|
||||
pub use alloc_mod::*;
|
||||
|
||||
pub trait PusHkToRequestConverter {
|
||||
type Error;
|
||||
fn convert(
|
||||
&mut self,
|
||||
token: VerificationToken<TcStateAccepted>,
|
||||
tc: &PusTcReader,
|
||||
time_stamp: &[u8],
|
||||
verif_reporter: &mut VerificationReporterWithSender,
|
||||
) -> Result<(TargetId, HkRequest), Self::Error>;
|
||||
}
|
||||
use crate::{hk::HkRequest, TargetId};
|
||||
|
||||
use super::verification::{TcStateAccepted, VerificationToken};
|
||||
|
||||
pub trait PusHkRequestRouter {
|
||||
type Error;
|
||||
@ -34,9 +22,35 @@ pub trait PusHkRequestRouter {
|
||||
) -> Result<(), Self::Error>;
|
||||
}
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
|
||||
pub mod alloc_mod {
|
||||
use spacepackets::ecss::tc::PusTcReader;
|
||||
|
||||
use crate::pus::verification::VerificationReporterWithSender;
|
||||
|
||||
use super::*;
|
||||
|
||||
pub trait PusHkToRequestConverter {
|
||||
type Error;
|
||||
fn convert(
|
||||
&mut self,
|
||||
token: VerificationToken<TcStateAccepted>,
|
||||
tc: &PusTcReader,
|
||||
time_stamp: &[u8],
|
||||
verif_reporter: &mut VerificationReporterWithSender,
|
||||
) -> Result<(TargetId, HkRequest), Self::Error>;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
|
||||
pub mod std_mod {
|
||||
use crate::pus::{
|
||||
EcssTcInMemConverter, GenericRoutingError, PusPacketHandlerResult, PusPacketHandlingError,
|
||||
PusRoutingErrorHandler, PusServiceBase, PusServiceHelper,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
|
||||
pub struct PusService3HkHandler<
|
||||
|
@ -3,7 +3,7 @@
|
||||
//! This module contains structures to make working with the PUS C standard easier.
|
||||
//! The satrs-example application contains various usage examples of these components.
|
||||
use crate::queue::{GenericRecvError, GenericSendError};
|
||||
use crate::{ChannelId, TargetId};
|
||||
use crate::ChannelId;
|
||||
use core::fmt::{Display, Formatter};
|
||||
#[cfg(feature = "alloc")]
|
||||
use downcast_rs::{impl_downcast, Downcast};
|
||||
@ -39,8 +39,6 @@ use crate::pus::verification::{TcStateAccepted, TcStateToken, VerificationToken}
|
||||
#[cfg(feature = "std")]
|
||||
pub use std_mod::*;
|
||||
|
||||
use self::verification::VerificationReporterWithSender;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum PusTmWrapper<'tm> {
|
||||
InStore(StoreAddr),
|
||||
@ -262,6 +260,10 @@ pub trait ReceivesEcssPusTc {
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
mod alloc_mod {
|
||||
use crate::TargetId;
|
||||
|
||||
use self::verification::VerificationReporterWithSender;
|
||||
|
||||
use super::*;
|
||||
|
||||
/// Extension trait for [EcssTmSenderCore].
|
||||
|
@ -1704,11 +1704,9 @@ mod tests {
|
||||
.helper
|
||||
.acceptance_success(tok, Some(&EMPTY_STAMP))
|
||||
.expect("Sending acceptance success failed");
|
||||
let empty = b
|
||||
.helper
|
||||
b.helper
|
||||
.start_failure(accepted_token, fail_params)
|
||||
.expect("Start failure failure");
|
||||
assert_eq!(empty, ());
|
||||
let sender: &mut TestSender = b.helper.sender.downcast_mut().unwrap();
|
||||
start_fail_check(sender, tok.req_id, fail_data_raw);
|
||||
}
|
||||
|
Reference in New Issue
Block a user