doc fixes
This commit is contained in:
parent
985dca351a
commit
a952a8405f
@ -12,7 +12,7 @@ use std::vec::Vec;
|
||||
/// be declared upfront. This avoids dynamic allocation during run-time. The user can specify a TC
|
||||
/// receiver in form of a special trait object which implements [ReceivesTc]. Please note that the
|
||||
/// receiver should copy out the received data if it the data is required past the
|
||||
/// [ReceivesTc::pass_tc] call.
|
||||
/// [ReceivesTcCore::pass_tc] call.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -4,7 +4,7 @@ use spacepackets::tm::PusTm;
|
||||
use spacepackets::tm::PusTmSecondaryHeader;
|
||||
use spacepackets::{SpHeader, MAX_APID};
|
||||
|
||||
use crate::pus::EcssTmSenderBase;
|
||||
use crate::pus::EcssTmSenderCore;
|
||||
#[cfg(feature = "alloc")]
|
||||
pub use allocvec::EventReporter;
|
||||
|
||||
@ -78,7 +78,7 @@ impl EventReporterBase {
|
||||
pub fn event_info<E>(
|
||||
&mut self,
|
||||
buf: &mut [u8],
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
event_id: impl EcssEnumeration,
|
||||
aux_data: Option<&[u8]>,
|
||||
@ -96,7 +96,7 @@ impl EventReporterBase {
|
||||
pub fn event_low_severity<E>(
|
||||
&mut self,
|
||||
buf: &mut [u8],
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
event_id: impl EcssEnumeration,
|
||||
aux_data: Option<&[u8]>,
|
||||
@ -114,7 +114,7 @@ impl EventReporterBase {
|
||||
pub fn event_medium_severity<E>(
|
||||
&mut self,
|
||||
buf: &mut [u8],
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
event_id: impl EcssEnumeration,
|
||||
aux_data: Option<&[u8]>,
|
||||
@ -132,7 +132,7 @@ impl EventReporterBase {
|
||||
pub fn event_high_severity<E>(
|
||||
&mut self,
|
||||
buf: &mut [u8],
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
event_id: impl EcssEnumeration,
|
||||
aux_data: Option<&[u8]>,
|
||||
@ -151,7 +151,7 @@ impl EventReporterBase {
|
||||
&mut self,
|
||||
buf: &mut [u8],
|
||||
subservice: Subservices,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
event_id: impl EcssEnumeration,
|
||||
aux_data: Option<&[u8]>,
|
||||
@ -220,7 +220,7 @@ mod allocvec {
|
||||
}
|
||||
pub fn event_info<E>(
|
||||
&mut self,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
event_id: impl EcssEnumeration,
|
||||
aux_data: Option<&[u8]>,
|
||||
@ -236,7 +236,7 @@ mod allocvec {
|
||||
|
||||
pub fn event_low_severity<E>(
|
||||
&mut self,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
event_id: impl EcssEnumeration,
|
||||
aux_data: Option<&[u8]>,
|
||||
@ -252,7 +252,7 @@ mod allocvec {
|
||||
|
||||
pub fn event_medium_severity<E>(
|
||||
&mut self,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
event_id: impl EcssEnumeration,
|
||||
aux_data: Option<&[u8]>,
|
||||
@ -268,7 +268,7 @@ mod allocvec {
|
||||
|
||||
pub fn event_high_severity<E>(
|
||||
&mut self,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
event_id: impl EcssEnumeration,
|
||||
aux_data: Option<&[u8]>,
|
||||
@ -311,7 +311,7 @@ mod tests {
|
||||
pub service_queue: VecDeque<TmInfo>,
|
||||
}
|
||||
|
||||
impl EcssTmSenderBase for TestSender {
|
||||
impl EcssTmSenderCore for TestSender {
|
||||
type Error = ();
|
||||
|
||||
fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<()>> {
|
||||
|
@ -13,7 +13,7 @@ pub use crate::pus::event::EventReporter;
|
||||
use crate::pus::verification::{TcStateStarted, VerificationToken};
|
||||
use crate::pus::EcssTmError;
|
||||
#[cfg(feature = "alloc")]
|
||||
use crate::pus::EcssTmSenderBase;
|
||||
use crate::pus::EcssTmSenderCore;
|
||||
#[cfg(feature = "alloc")]
|
||||
#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))]
|
||||
pub use alloc_mod::*;
|
||||
@ -175,7 +175,7 @@ pub mod alloc_mod {
|
||||
|
||||
pub fn generate_pus_event_tm_generic<E>(
|
||||
&mut self,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
event: Event,
|
||||
aux_data: Option<&[u8]>,
|
||||
@ -225,7 +225,7 @@ pub mod alloc_mod {
|
||||
|
||||
pub fn generate_pus_event_tm<E, Severity: HasSeverity>(
|
||||
&mut self,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
event: EventU32TypedSev<Severity>,
|
||||
aux_data: Option<&[u8]>,
|
||||
@ -252,7 +252,7 @@ mod tests {
|
||||
sender: std::sync::mpsc::Sender<Vec<u8>>,
|
||||
}
|
||||
|
||||
impl EcssTmSenderBase for EventTmSender {
|
||||
impl EcssTmSenderCore for EventTmSender {
|
||||
type Error = SendError<Vec<u8>>;
|
||||
fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<Self::Error>> {
|
||||
let mut vec = Vec::new();
|
||||
|
@ -44,10 +44,8 @@ impl<E> From<ByteConversionError> for EcssTmError<E> {
|
||||
|
||||
/// Generic trait for a user supplied sender object.
|
||||
///
|
||||
/// This sender object is responsible for sending telemetry to a TM sink. The [Downcast] trait
|
||||
/// is implemented to allow passing the sender as a boxed trait object and still retrieve the
|
||||
/// concrete type at a later point.
|
||||
pub trait EcssTmSenderBase: Send {
|
||||
/// This sender object is responsible for sending telemetry to a TM sink.
|
||||
pub trait EcssTmSenderCore: Send {
|
||||
type Error;
|
||||
|
||||
fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<Self::Error>>;
|
||||
@ -57,7 +55,21 @@ pub trait EcssTmSenderBase: Send {
|
||||
pub mod alloc_mod {
|
||||
use super::*;
|
||||
|
||||
pub trait EcssTmSender: EcssTmSenderBase + Downcast + DynClone {}
|
||||
/// Extension trait for [EcssTmSenderCore].
|
||||
///
|
||||
/// It provides additional functionality, for example by implementing the [Downcast] trait
|
||||
/// and the [DynClone] trait.
|
||||
///
|
||||
/// [Downcast] is implemented to allow passing the sender as a boxed trait object and still
|
||||
/// retrieve the concrete type at a later point.
|
||||
///
|
||||
/// [DynClone] allows cloning the trait object as long as the boxed object implements
|
||||
/// [Clone].
|
||||
pub trait EcssTmSender: EcssTmSenderCore + Downcast + DynClone {}
|
||||
|
||||
/// Blanket implementation for all types which implement [EcssTmSenderCore] and are clonable.
|
||||
impl<T> EcssTmSender for T where T: EcssTmSenderCore + Clone + 'static {}
|
||||
|
||||
dyn_clone::clone_trait_object!(<T> EcssTmSender<Error=T>);
|
||||
impl_downcast!(EcssTmSender assoc Error);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@
|
||||
//! The [integration test](https://egit.irs.uni-stuttgart.de/rust/fsrc-launchpad/src/branch/main/fsrc-core/tests/verification_test.rs)
|
||||
//! for the verification module contains examples how this module could be used in a more complex
|
||||
//! context involving multiple threads
|
||||
use crate::pus::{source_buffer_large_enough, EcssTmError, EcssTmSenderBase};
|
||||
use crate::pus::{source_buffer_large_enough, EcssTmError, EcssTmSenderCore};
|
||||
use core::fmt::{Display, Formatter};
|
||||
use core::hash::{Hash, Hasher};
|
||||
use core::marker::PhantomData;
|
||||
@ -91,7 +91,7 @@ pub use crate::seq_count::SimpleSeqCountProvider;
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
pub use alloc_mod::{
|
||||
VerificationReporterCfg, VerificationReporterWithBuf, VerificationReporterWithSender,
|
||||
VerificationReporter, VerificationReporterCfg, VerificationReporterWithSender,
|
||||
};
|
||||
|
||||
use crate::seq_count::SequenceCountProvider;
|
||||
@ -289,12 +289,12 @@ impl<'a> FailParamsWithStep<'a> {
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct VerificationReporterBasic {
|
||||
pub struct VerificationReporterCore {
|
||||
pub dest_id: u16,
|
||||
apid: u16,
|
||||
}
|
||||
|
||||
impl VerificationReporterBasic {
|
||||
impl VerificationReporterCore {
|
||||
pub fn new(apid: u16) -> Option<Self> {
|
||||
if apid > MAX_APID {
|
||||
return None;
|
||||
@ -339,7 +339,7 @@ impl VerificationReporterBasic {
|
||||
&mut self,
|
||||
buf: &mut [u8],
|
||||
token: VerificationToken<TcStateNone>,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
) -> Result<VerificationToken<TcStateAccepted>, VerificationErrorWithToken<E, TcStateNone>>
|
||||
@ -370,7 +370,7 @@ impl VerificationReporterBasic {
|
||||
&mut self,
|
||||
buf: &mut [u8],
|
||||
token: VerificationToken<TcStateNone>,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized),
|
||||
params: FailParams,
|
||||
) -> Result<(), VerificationErrorWithToken<E, TcStateNone>> {
|
||||
@ -398,7 +398,7 @@ impl VerificationReporterBasic {
|
||||
&mut self,
|
||||
buf: &mut [u8],
|
||||
token: VerificationToken<TcStateAccepted>,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
) -> Result<VerificationToken<TcStateStarted>, VerificationErrorWithToken<E, TcStateAccepted>>
|
||||
@ -431,7 +431,7 @@ impl VerificationReporterBasic {
|
||||
&mut self,
|
||||
buf: &mut [u8],
|
||||
token: VerificationToken<TcStateAccepted>,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized),
|
||||
params: FailParams,
|
||||
) -> Result<(), VerificationErrorWithToken<E, TcStateAccepted>> {
|
||||
@ -459,7 +459,7 @@ impl VerificationReporterBasic {
|
||||
&mut self,
|
||||
buf: &mut [u8],
|
||||
token: &VerificationToken<TcStateStarted>,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
step: impl EcssEnumeration,
|
||||
@ -485,7 +485,7 @@ impl VerificationReporterBasic {
|
||||
&mut self,
|
||||
buf: &mut [u8],
|
||||
token: VerificationToken<TcStateStarted>,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized),
|
||||
params: FailParamsWithStep,
|
||||
) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> {
|
||||
@ -514,7 +514,7 @@ impl VerificationReporterBasic {
|
||||
&mut self,
|
||||
buf: &mut [u8],
|
||||
token: VerificationToken<TcStateStarted>,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> {
|
||||
@ -543,7 +543,7 @@ impl VerificationReporterBasic {
|
||||
&mut self,
|
||||
buf: &mut [u8],
|
||||
token: VerificationToken<TcStateStarted>,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
seq_counter: &mut (impl SequenceCountProvider<u16> + ?Sized),
|
||||
params: FailParams,
|
||||
) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> {
|
||||
@ -703,15 +703,15 @@ mod alloc_mod {
|
||||
/// Primary verification handler. It provides an API to send PUS 1 verification telemetry packets
|
||||
/// and verify the various steps of telecommand handling as specified in the PUS standard.
|
||||
#[derive(Clone)]
|
||||
pub struct VerificationReporterWithBuf {
|
||||
pub struct VerificationReporter {
|
||||
source_data_buf: Vec<u8>,
|
||||
seq_counter: Box<dyn SequenceCountProviderClonable<u16> + Send + 'static>,
|
||||
pub reporter: VerificationReporterBasic,
|
||||
pub reporter: VerificationReporterCore,
|
||||
}
|
||||
|
||||
impl VerificationReporterWithBuf {
|
||||
impl VerificationReporter {
|
||||
pub fn new(cfg: &VerificationReporterCfg) -> Self {
|
||||
let reporter = VerificationReporterBasic::new(cfg.apid).unwrap();
|
||||
let reporter = VerificationReporterCore::new(cfg.apid).unwrap();
|
||||
Self {
|
||||
source_data_buf: vec![
|
||||
0;
|
||||
@ -744,7 +744,7 @@ mod alloc_mod {
|
||||
pub fn acceptance_success<E>(
|
||||
&mut self,
|
||||
token: VerificationToken<TcStateNone>,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
) -> Result<VerificationToken<TcStateAccepted>, VerificationErrorWithToken<E, TcStateNone>>
|
||||
{
|
||||
@ -761,7 +761,7 @@ mod alloc_mod {
|
||||
pub fn acceptance_failure<E>(
|
||||
&mut self,
|
||||
token: VerificationToken<TcStateNone>,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
params: FailParams,
|
||||
) -> Result<(), VerificationErrorWithToken<E, TcStateNone>> {
|
||||
self.reporter.acceptance_failure(
|
||||
@ -779,7 +779,7 @@ mod alloc_mod {
|
||||
pub fn start_success<E>(
|
||||
&mut self,
|
||||
token: VerificationToken<TcStateAccepted>,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
) -> Result<VerificationToken<TcStateStarted>, VerificationErrorWithToken<E, TcStateAccepted>>
|
||||
{
|
||||
@ -799,7 +799,7 @@ mod alloc_mod {
|
||||
pub fn start_failure<E>(
|
||||
&mut self,
|
||||
token: VerificationToken<TcStateAccepted>,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
params: FailParams,
|
||||
) -> Result<(), VerificationErrorWithToken<E, TcStateAccepted>> {
|
||||
self.reporter.start_failure(
|
||||
@ -817,7 +817,7 @@ mod alloc_mod {
|
||||
pub fn step_success<E>(
|
||||
&mut self,
|
||||
token: &VerificationToken<TcStateStarted>,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
step: impl EcssEnumeration,
|
||||
) -> Result<(), EcssTmError<E>> {
|
||||
@ -838,7 +838,7 @@ mod alloc_mod {
|
||||
pub fn step_failure<E>(
|
||||
&mut self,
|
||||
token: VerificationToken<TcStateStarted>,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
params: FailParamsWithStep,
|
||||
) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> {
|
||||
self.reporter.step_failure(
|
||||
@ -857,7 +857,7 @@ mod alloc_mod {
|
||||
pub fn completion_success<E>(
|
||||
&mut self,
|
||||
token: VerificationToken<TcStateStarted>,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> {
|
||||
self.reporter.completion_success(
|
||||
@ -876,7 +876,7 @@ mod alloc_mod {
|
||||
pub fn completion_failure<E>(
|
||||
&mut self,
|
||||
token: VerificationToken<TcStateStarted>,
|
||||
sender: &mut (impl EcssTmSenderBase<Error = E> + ?Sized),
|
||||
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
||||
params: FailParams,
|
||||
) -> Result<(), VerificationErrorWithToken<E, TcStateStarted>> {
|
||||
self.reporter.completion_failure(
|
||||
@ -893,7 +893,7 @@ mod alloc_mod {
|
||||
/// API as [VerificationReporter] but without the explicit sender arguments.
|
||||
#[derive(Clone)]
|
||||
pub struct VerificationReporterWithSender<E> {
|
||||
pub reporter: VerificationReporterWithBuf,
|
||||
pub reporter: VerificationReporter,
|
||||
pub sender: Box<dyn EcssTmSender<Error = E>>,
|
||||
}
|
||||
|
||||
@ -902,12 +902,12 @@ mod alloc_mod {
|
||||
cfg: &VerificationReporterCfg,
|
||||
sender: Box<dyn EcssTmSender<Error = E>>,
|
||||
) -> Self {
|
||||
let reporter = VerificationReporterWithBuf::new(cfg);
|
||||
let reporter = VerificationReporter::new(cfg);
|
||||
Self::new_from_reporter(reporter, sender)
|
||||
}
|
||||
|
||||
pub fn new_from_reporter(
|
||||
reporter: VerificationReporterWithBuf,
|
||||
reporter: VerificationReporter,
|
||||
sender: Box<dyn EcssTmSender<Error = E>>,
|
||||
) -> Self {
|
||||
Self { reporter, sender }
|
||||
@ -1006,7 +1006,6 @@ mod stdmod {
|
||||
use super::alloc_mod::VerificationReporterWithSender;
|
||||
use super::*;
|
||||
use crate::pool::{ShareablePoolProvider, SharedPool, StoreAddr, StoreError};
|
||||
use crate::pus::alloc_mod::EcssTmSender;
|
||||
use delegate::delegate;
|
||||
use spacepackets::tm::PusTm;
|
||||
use std::sync::{mpsc, Arc, Mutex, RwLockWriteGuard};
|
||||
@ -1069,7 +1068,7 @@ mod stdmod {
|
||||
}
|
||||
|
||||
/// Verification sender with a [mpsc::Sender] backend.
|
||||
/// It implements the [EcssTmSenderBase] trait to be used as PUS Verification TM sender.
|
||||
/// It implements the [EcssTmSenderCore] trait to be used as PUS Verification TM sender.
|
||||
impl MpscVerifSender {
|
||||
pub fn new(tm_store: SharedPool, tx: mpsc::Sender<StoreAddr>) -> Self {
|
||||
Self {
|
||||
@ -1079,7 +1078,7 @@ mod stdmod {
|
||||
}
|
||||
|
||||
//noinspection RsTraitImplementation
|
||||
impl EcssTmSenderBase for MpscVerifSender {
|
||||
impl EcssTmSenderCore for MpscVerifSender {
|
||||
type Error = StdVerifSenderError;
|
||||
|
||||
delegate!(
|
||||
@ -1089,8 +1088,6 @@ mod stdmod {
|
||||
);
|
||||
}
|
||||
|
||||
impl EcssTmSender for MpscVerifSender {}
|
||||
|
||||
impl SendBackend for crossbeam_channel::Sender<StoreAddr> {
|
||||
fn send(&self, addr: StoreAddr) -> Result<(), StoreAddr> {
|
||||
self.send(addr).map_err(|_| addr)
|
||||
@ -1098,7 +1095,7 @@ mod stdmod {
|
||||
}
|
||||
|
||||
/// Verification sender with a [crossbeam_channel::Sender] backend.
|
||||
/// It implements the [EcssTmSenderBase] trait to be used as PUS Verification TM sender
|
||||
/// It implements the [EcssTmSenderCore] trait to be used as PUS Verification TM sender
|
||||
#[cfg(feature = "crossbeam")]
|
||||
#[derive(Clone)]
|
||||
pub struct CrossbeamVerifSender {
|
||||
@ -1116,7 +1113,7 @@ mod stdmod {
|
||||
|
||||
//noinspection RsTraitImplementation
|
||||
#[cfg(feature = "crossbeam")]
|
||||
impl EcssTmSenderBase for CrossbeamVerifSender {
|
||||
impl EcssTmSenderCore for CrossbeamVerifSender {
|
||||
type Error = StdVerifSenderError;
|
||||
|
||||
delegate!(
|
||||
@ -1126,10 +1123,7 @@ mod stdmod {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(feature = "crossbeam")]
|
||||
impl EcssTmSender for CrossbeamVerifSender {}
|
||||
|
||||
impl<S: SendBackend + Clone + 'static> EcssTmSenderBase for StdSenderBase<S> {
|
||||
impl<S: SendBackend + Clone + 'static> EcssTmSenderCore for StdSenderBase<S> {
|
||||
type Error = StdVerifSenderError;
|
||||
fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<Self::Error>> {
|
||||
let operation = |mut mg: RwLockWriteGuard<ShareablePoolProvider>| {
|
||||
@ -1158,12 +1152,11 @@ mod stdmod {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::pool::{LocalPool, PoolCfg, SharedPool};
|
||||
use crate::pus::alloc_mod::EcssTmSender;
|
||||
use crate::pus::tests::CommonTmInfo;
|
||||
use crate::pus::verification::{
|
||||
EcssTmError, EcssTmSenderBase, FailParams, FailParamsWithStep, MpscVerifSender, RequestId,
|
||||
TcStateNone, VerificationReporterCfg, VerificationReporterWithBuf,
|
||||
VerificationReporterWithSender, VerificationToken,
|
||||
EcssTmError, EcssTmSenderCore, FailParams, FailParamsWithStep, MpscVerifSender, RequestId,
|
||||
TcStateNone, VerificationReporter, VerificationReporterCfg, VerificationReporterWithSender,
|
||||
VerificationToken,
|
||||
};
|
||||
use crate::seq_count::SimpleSeqCountProvider;
|
||||
use alloc::boxed::Box;
|
||||
@ -1196,7 +1189,7 @@ mod tests {
|
||||
pub service_queue: VecDeque<TmInfo>,
|
||||
}
|
||||
|
||||
impl EcssTmSenderBase for TestSender {
|
||||
impl EcssTmSenderCore for TestSender {
|
||||
type Error = ();
|
||||
fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<Self::Error>> {
|
||||
assert_eq!(PusPacket::service(&tm), 1);
|
||||
@ -1221,30 +1214,26 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
impl EcssTmSender for TestSender {}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
struct DummyError {}
|
||||
#[derive(Default, Clone)]
|
||||
struct FallibleSender {}
|
||||
|
||||
impl EcssTmSenderBase for FallibleSender {
|
||||
impl EcssTmSenderCore for FallibleSender {
|
||||
type Error = DummyError;
|
||||
fn send_tm(&mut self, _: PusTm) -> Result<(), EcssTmError<DummyError>> {
|
||||
Err(EcssTmError::SendError(DummyError {}))
|
||||
}
|
||||
}
|
||||
|
||||
impl EcssTmSender for FallibleSender {}
|
||||
|
||||
struct TestBase<'a> {
|
||||
vr: VerificationReporterWithBuf,
|
||||
vr: VerificationReporter,
|
||||
#[allow(dead_code)]
|
||||
tc: PusTc<'a>,
|
||||
}
|
||||
|
||||
impl<'a> TestBase<'a> {
|
||||
fn rep(&mut self) -> &mut VerificationReporterWithBuf {
|
||||
fn rep(&mut self) -> &mut VerificationReporter {
|
||||
&mut self.vr
|
||||
}
|
||||
}
|
||||
@ -1255,12 +1244,12 @@ mod tests {
|
||||
}
|
||||
|
||||
impl<'a, E> TestBaseWithHelper<'a, E> {
|
||||
fn rep(&mut self) -> &mut VerificationReporterWithBuf {
|
||||
fn rep(&mut self) -> &mut VerificationReporter {
|
||||
&mut self.helper.reporter
|
||||
}
|
||||
}
|
||||
|
||||
fn base_reporter() -> VerificationReporterWithBuf {
|
||||
fn base_reporter() -> VerificationReporter {
|
||||
let cfg = VerificationReporterCfg::new(
|
||||
TEST_APID,
|
||||
Box::new(SimpleSeqCountProvider::default()),
|
||||
@ -1269,7 +1258,7 @@ mod tests {
|
||||
8,
|
||||
)
|
||||
.unwrap();
|
||||
VerificationReporterWithBuf::new(&cfg)
|
||||
VerificationReporter::new(&cfg)
|
||||
}
|
||||
|
||||
fn base_tc_init(app_data: Option<&[u8]>) -> (PusTc, RequestId) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
//! 1. [CcsdsDistributor] component which dispatches received packets to a user-provided handler
|
||||
//! 2. [CcsdsPacketHandler] trait which should be implemented by the user-provided packet handler.
|
||||
//!
|
||||
//! The [CcsdsDistributor] implements the [ReceivesCcsdsTc] and [ReceivesTc] trait which allows to
|
||||
//! The [CcsdsDistributor] implements the [ReceivesCcsdsTc] and [ReceivesTcCore] trait which allows to
|
||||
//! pass raw or CCSDS packets to it. Upon receiving a packet, it performs the following steps:
|
||||
//!
|
||||
//! 1. It tries to identify the target Application Process Identifier (APID) based on the
|
||||
|
@ -5,9 +5,9 @@
|
||||
//! 2. [PusServiceProvider] trait which should be implemented by the user-provided PUS packet
|
||||
//! handler.
|
||||
//!
|
||||
//! The [PusDistributor] implements the [ReceivesEcssPusTc], [ReceivesCcsdsTc] and the [ReceivesTc]
|
||||
//! trait which allows to pass raw packets, CCSDS packets and PUS TC packets into it.
|
||||
//! Upon receiving a packet, it performs the following steps:
|
||||
//! The [PusDistributor] implements the [ReceivesEcssPusTc], [ReceivesCcsdsTc] and the
|
||||
//! [ReceivesTcCore] trait which allows to pass raw packets, CCSDS packets and PUS TC packets into
|
||||
//! it. Upon receiving a packet, it performs the following steps:
|
||||
//!
|
||||
//! 1. It tries to extract the [SpHeader] and [PusTc] objects from the raw bytestream. If this
|
||||
//! process fails, a [PusDistribError::PusError] is returned to the user.
|
||||
|
@ -7,7 +7,7 @@ use satrs_core::params::{Params, ParamsHeapless, WritableToBeBytes};
|
||||
use satrs_core::pus::event_man::{
|
||||
DefaultPusMgmtBackendProvider, EventReporter, PusEventDispatcher,
|
||||
};
|
||||
use satrs_core::pus::{EcssTmError, EcssTmSenderBase};
|
||||
use satrs_core::pus::{EcssTmError, EcssTmSenderCore};
|
||||
use spacepackets::ecss::PusPacket;
|
||||
use spacepackets::tm::PusTm;
|
||||
use std::sync::mpsc::{channel, SendError, TryRecvError};
|
||||
@ -23,7 +23,7 @@ struct EventTmSender {
|
||||
sender: std::sync::mpsc::Sender<Vec<u8>>,
|
||||
}
|
||||
|
||||
impl EcssTmSenderBase for EventTmSender {
|
||||
impl EcssTmSenderCore for EventTmSender {
|
||||
type Error = SendError<Vec<u8>>;
|
||||
fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<Self::Error>> {
|
||||
let mut vec = Vec::new();
|
||||
|
@ -22,7 +22,7 @@ use satrs_core::pus::hk::Subservice;
|
||||
use satrs_core::pus::verification::{
|
||||
MpscVerifSender, VerificationReporterCfg, VerificationReporterWithSender,
|
||||
};
|
||||
use satrs_core::pus::{EcssTmError, EcssTmSenderBase};
|
||||
use satrs_core::pus::{EcssTmError, EcssTmSenderCore};
|
||||
use satrs_core::seq_count::SimpleSeqCountProvider;
|
||||
use satrs_example::{RequestTargetId, OBSW_SERVER_ADDR, SERVER_PORT};
|
||||
use spacepackets::time::cds::TimeProvider;
|
||||
@ -51,7 +51,7 @@ impl EventTmSender {
|
||||
}
|
||||
}
|
||||
|
||||
impl EcssTmSenderBase for EventTmSender {
|
||||
impl EcssTmSenderCore for EventTmSender {
|
||||
type Error = mpsc::SendError<StoreAddr>;
|
||||
|
||||
fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmError<Self::Error>> {
|
||||
|
Loading…
Reference in New Issue
Block a user