simplify verification reporter core
This commit is contained in:
parent
8280c70682
commit
b45a219c6d
@ -981,15 +981,16 @@ pub mod std_mod {
|
|||||||
>;
|
>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn source_buffer_large_enough(cap: usize, len: usize) -> Result<(), EcssTmtcError> {
|
pub(crate) fn source_buffer_large_enough(
|
||||||
|
cap: usize,
|
||||||
|
len: usize,
|
||||||
|
) -> Result<(), ByteConversionError> {
|
||||||
if len > cap {
|
if len > cap {
|
||||||
return Err(
|
return Err(ByteConversionError::ToSliceTooSmall {
|
||||||
PusError::ByteConversion(ByteConversionError::ToSliceTooSmall {
|
found: cap,
|
||||||
found: cap,
|
expected: len,
|
||||||
expected: len,
|
}
|
||||||
})
|
.into());
|
||||||
.into(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -87,8 +87,8 @@ use delegate::delegate;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use spacepackets::ecss::tc::IsPusTelecommand;
|
use spacepackets::ecss::tc::IsPusTelecommand;
|
||||||
use spacepackets::ecss::tm::{PusTmCreator, PusTmSecondaryHeader};
|
use spacepackets::ecss::tm::{PusTmCreator, PusTmSecondaryHeader};
|
||||||
use spacepackets::ecss::{EcssEnumeration, PusError, WritablePusPacket};
|
use spacepackets::ecss::{EcssEnumeration, PusError};
|
||||||
use spacepackets::{CcsdsPacket, PacketId, PacketSequenceCtrl};
|
use spacepackets::{ByteConversionError, CcsdsPacket, PacketId, PacketSequenceCtrl};
|
||||||
use spacepackets::{SpHeader, MAX_APID};
|
use spacepackets::{SpHeader, MAX_APID};
|
||||||
|
|
||||||
pub use crate::seq_count::SeqCountProviderSimple;
|
pub use crate::seq_count::SeqCountProviderSimple;
|
||||||
@ -328,87 +328,6 @@ impl<'stamp, 'fargs> FailParamsWithStep<'stamp, 'fargs> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct VerificationReporterCore {
|
|
||||||
pub dest_id: u16,
|
|
||||||
apid: u16,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub enum VerifSuccess {}
|
|
||||||
pub enum VerifFailure {}
|
|
||||||
|
|
||||||
/// Abstraction for a sendable PUS TM. The user is expected to send the TM packet to a TM sink.
|
|
||||||
///
|
|
||||||
/// This struct generally mutably borrows the source data buffer.
|
|
||||||
pub struct VerificationSendable<'src_data, State, SuccessOrFailure> {
|
|
||||||
token: Option<VerificationToken<State>>,
|
|
||||||
pus_tm: Option<PusTmCreator<'src_data>>,
|
|
||||||
phantom: PhantomData<SuccessOrFailure>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'src_data, State, SuccessOrFailure> VerificationSendable<'src_data, State, SuccessOrFailure> {
|
|
||||||
pub(crate) fn new(pus_tm: PusTmCreator<'src_data>, token: VerificationToken<State>) -> Self {
|
|
||||||
Self {
|
|
||||||
token: Some(token),
|
|
||||||
pus_tm: Some(pus_tm),
|
|
||||||
phantom: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub(crate) fn new_no_token(pus_tm: PusTmCreator<'src_data>) -> Self {
|
|
||||||
Self {
|
|
||||||
token: None,
|
|
||||||
pus_tm: Some(pus_tm),
|
|
||||||
phantom: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn len_packed(&self) -> usize {
|
|
||||||
self.pus_tm.as_ref().unwrap().len_written()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn pus_tm(&self) -> &PusTmCreator<'src_data> {
|
|
||||||
self.pus_tm.as_ref().unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn pus_tm_mut(&mut self) -> &mut PusTmCreator<'src_data> {
|
|
||||||
self.pus_tm.as_mut().unwrap()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'src_data, State> VerificationSendable<'src_data, State, VerifFailure> {
|
|
||||||
pub fn send_success_verif_failure(self) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'src_data, State> VerificationSendable<'src_data, State, VerifFailure> {
|
|
||||||
pub fn send_failure(self) -> (PusTmCreator<'src_data>, VerificationToken<State>) {
|
|
||||||
(self.pus_tm.unwrap(), self.token.unwrap())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'src_data> VerificationSendable<'src_data, TcStateNone, VerifSuccess> {
|
|
||||||
pub fn send_success_acceptance_success(self) -> VerificationToken<TcStateAccepted> {
|
|
||||||
VerificationToken {
|
|
||||||
state: PhantomData,
|
|
||||||
req_id: self.token.unwrap().req_id(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'src_data> VerificationSendable<'src_data, TcStateAccepted, VerifSuccess> {
|
|
||||||
pub fn send_success_start_success(self) -> VerificationToken<TcStateStarted> {
|
|
||||||
VerificationToken {
|
|
||||||
state: PhantomData,
|
|
||||||
req_id: self.token.unwrap().req_id(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'src_data, TcState: WasAtLeastAccepted + Copy>
|
|
||||||
VerificationSendable<'src_data, TcState, VerifSuccess>
|
|
||||||
{
|
|
||||||
pub fn send_success_step_or_completion_success(self) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait VerificationReportingProvider {
|
pub trait VerificationReportingProvider {
|
||||||
fn add_tc(
|
fn add_tc(
|
||||||
&mut self,
|
&mut self,
|
||||||
@ -423,25 +342,25 @@ pub trait VerificationReportingProvider {
|
|||||||
&self,
|
&self,
|
||||||
token: VerificationToken<TcStateNone>,
|
token: VerificationToken<TcStateNone>,
|
||||||
time_stamp: &[u8],
|
time_stamp: &[u8],
|
||||||
) -> Result<VerificationToken<TcStateAccepted>, VerificationOrSendErrorWithToken<TcStateNone>>;
|
) -> Result<VerificationToken<TcStateAccepted>, EcssTmtcError>;
|
||||||
|
|
||||||
fn acceptance_failure(
|
fn acceptance_failure(
|
||||||
&self,
|
&self,
|
||||||
token: VerificationToken<TcStateNone>,
|
token: VerificationToken<TcStateNone>,
|
||||||
params: FailParams,
|
params: FailParams,
|
||||||
) -> Result<(), VerificationOrSendErrorWithToken<TcStateNone>>;
|
) -> Result<(), EcssTmtcError>;
|
||||||
|
|
||||||
fn start_success(
|
fn start_success(
|
||||||
&self,
|
&self,
|
||||||
token: VerificationToken<TcStateAccepted>,
|
token: VerificationToken<TcStateAccepted>,
|
||||||
time_stamp: &[u8],
|
time_stamp: &[u8],
|
||||||
) -> Result<VerificationToken<TcStateStarted>, VerificationOrSendErrorWithToken<TcStateAccepted>>;
|
) -> Result<VerificationToken<TcStateStarted>, EcssTmtcError>;
|
||||||
|
|
||||||
fn start_failure(
|
fn start_failure(
|
||||||
&self,
|
&self,
|
||||||
token: VerificationToken<TcStateAccepted>,
|
token: VerificationToken<TcStateAccepted>,
|
||||||
params: FailParams,
|
params: FailParams,
|
||||||
) -> Result<(), VerificationOrSendErrorWithToken<TcStateAccepted>>;
|
) -> Result<(), EcssTmtcError>;
|
||||||
|
|
||||||
fn step_success(
|
fn step_success(
|
||||||
&self,
|
&self,
|
||||||
@ -454,29 +373,35 @@ pub trait VerificationReportingProvider {
|
|||||||
&self,
|
&self,
|
||||||
token: VerificationToken<TcStateStarted>,
|
token: VerificationToken<TcStateStarted>,
|
||||||
params: FailParamsWithStep,
|
params: FailParamsWithStep,
|
||||||
) -> Result<(), VerificationOrSendErrorWithToken<TcStateStarted>>;
|
) -> Result<(), EcssTmtcError>;
|
||||||
|
|
||||||
fn completion_success<TcState: WasAtLeastAccepted + Copy>(
|
fn completion_success<TcState: WasAtLeastAccepted + Copy>(
|
||||||
&self,
|
&self,
|
||||||
token: VerificationToken<TcState>,
|
token: VerificationToken<TcState>,
|
||||||
time_stamp: &[u8],
|
time_stamp: &[u8],
|
||||||
) -> Result<(), VerificationOrSendErrorWithToken<TcState>>;
|
) -> Result<(), EcssTmtcError>;
|
||||||
|
|
||||||
fn completion_failure<TcState: WasAtLeastAccepted + Copy>(
|
fn completion_failure<TcState: WasAtLeastAccepted + Copy>(
|
||||||
&self,
|
&self,
|
||||||
token: VerificationToken<TcState>,
|
token: VerificationToken<TcState>,
|
||||||
params: FailParams,
|
params: FailParams,
|
||||||
) -> Result<(), VerificationOrSendErrorWithToken<TcState>>;
|
) -> Result<(), EcssTmtcError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Primary verification handler. It provides an API to send PUS 1 verification telemetry packets
|
/// Primary verification handler. It provides an API to generate PUS 1 verification telemetry
|
||||||
/// and verify the various steps of telecommand handling as specified in the PUS standard.
|
/// packets and verify the various steps of telecommand handling as specified in the PUS standard.
|
||||||
///
|
///
|
||||||
/// This is the core component which can be used without [`alloc`] support. Please note that
|
/// This is the core component which can be used without [`alloc`] support. Please note that
|
||||||
/// the buffer passed to the API exposes by this struct will be used to serialize the source data.
|
/// the buffer passed to the API exposes by this struct will be used to serialize the source data.
|
||||||
/// This buffer may not be re-used to serialize the whole telemetry because that would overwrite
|
/// This buffer may not be re-used to serialize the whole telemetry because that would overwrite
|
||||||
/// the source data itself.
|
/// the source data itself.
|
||||||
impl VerificationReporterCore {
|
#[derive(Clone)]
|
||||||
|
pub struct VerificationReportCreator {
|
||||||
|
pub dest_id: u16,
|
||||||
|
apid: u16,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl VerificationReportCreator {
|
||||||
pub fn new(apid: u16) -> Option<Self> {
|
pub fn new(apid: u16) -> Option<Self> {
|
||||||
if apid > MAX_APID {
|
if apid > MAX_APID {
|
||||||
return None;
|
return None;
|
||||||
@ -519,7 +444,7 @@ impl VerificationReporterCore {
|
|||||||
VerificationToken::<TcStateNone>::new(req_id)
|
VerificationToken::<TcStateNone>::new(req_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sendable_success_no_step<'src_data, State: Copy>(
|
fn success_verification_no_step<'src_data, State: Copy>(
|
||||||
&self,
|
&self,
|
||||||
src_data_buf: &'src_data mut [u8],
|
src_data_buf: &'src_data mut [u8],
|
||||||
subservice: u8,
|
subservice: u8,
|
||||||
@ -527,28 +452,22 @@ impl VerificationReporterCore {
|
|||||||
seq_count: u16,
|
seq_count: u16,
|
||||||
msg_count: u16,
|
msg_count: u16,
|
||||||
time_stamp: &'src_data [u8],
|
time_stamp: &'src_data [u8],
|
||||||
) -> Result<
|
) -> Result<PusTmCreator, ByteConversionError> {
|
||||||
VerificationSendable<'src_data, State, VerifSuccess>,
|
let tm_creator = self.create_pus_verif_success_tm(
|
||||||
VerificationErrorWithToken<State>,
|
src_data_buf,
|
||||||
> {
|
subservice,
|
||||||
Ok(VerificationSendable::new(
|
seq_count,
|
||||||
self.create_pus_verif_success_tm(
|
msg_count,
|
||||||
src_data_buf,
|
&token.req_id,
|
||||||
subservice,
|
time_stamp,
|
||||||
seq_count,
|
None::<&dyn EcssEnumeration>,
|
||||||
msg_count,
|
)?;
|
||||||
&token.req_id,
|
Ok(tm_creator)
|
||||||
time_stamp,
|
|
||||||
None::<&dyn EcssEnumeration>,
|
|
||||||
)
|
|
||||||
.map_err(|e| VerificationErrorWithToken(e, token))?,
|
|
||||||
token,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Internal helper function, too many arguments is acceptable for this case.
|
// Internal helper function, too many arguments is acceptable for this case.
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn sendable_failure_no_step<'src_data, State: Copy>(
|
fn failure_verification_no_step<'src_data, State: Copy>(
|
||||||
&self,
|
&self,
|
||||||
src_data_buf: &'src_data mut [u8],
|
src_data_buf: &'src_data mut [u8],
|
||||||
subservice: u8,
|
subservice: u8,
|
||||||
@ -557,23 +476,17 @@ impl VerificationReporterCore {
|
|||||||
msg_count: u16,
|
msg_count: u16,
|
||||||
step: Option<&(impl EcssEnumeration + ?Sized)>,
|
step: Option<&(impl EcssEnumeration + ?Sized)>,
|
||||||
params: &FailParams<'src_data, '_>,
|
params: &FailParams<'src_data, '_>,
|
||||||
) -> Result<
|
) -> Result<PusTmCreator, ByteConversionError> {
|
||||||
VerificationSendable<'src_data, State, VerifFailure>,
|
let tm_creator = self.create_pus_verif_fail_tm(
|
||||||
VerificationErrorWithToken<State>,
|
src_data_buf,
|
||||||
> {
|
subservice,
|
||||||
Ok(VerificationSendable::new(
|
seq_count,
|
||||||
self.create_pus_verif_fail_tm(
|
msg_count,
|
||||||
src_data_buf,
|
&token.req_id,
|
||||||
subservice,
|
step,
|
||||||
seq_count,
|
params,
|
||||||
msg_count,
|
)?;
|
||||||
&token.req_id,
|
Ok(tm_creator)
|
||||||
step,
|
|
||||||
params,
|
|
||||||
)
|
|
||||||
.map_err(|e| VerificationErrorWithToken(e, token))?,
|
|
||||||
token,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Package a PUS TM\[1, 1\] packet, see 8.1.2.1 of the PUS standard.
|
/// Package a PUS TM\[1, 1\] packet, see 8.1.2.1 of the PUS standard.
|
||||||
@ -584,42 +497,23 @@ impl VerificationReporterCore {
|
|||||||
seq_count: u16,
|
seq_count: u16,
|
||||||
msg_count: u16,
|
msg_count: u16,
|
||||||
time_stamp: &'src_data [u8],
|
time_stamp: &'src_data [u8],
|
||||||
) -> Result<
|
) -> Result<(PusTmCreator<'src_data>, VerificationToken<TcStateAccepted>), ByteConversionError>
|
||||||
VerificationSendable<'src_data, TcStateNone, VerifSuccess>,
|
{
|
||||||
VerificationErrorWithToken<TcStateNone>,
|
let tm_creator = self.success_verification_no_step(
|
||||||
> {
|
|
||||||
self.sendable_success_no_step(
|
|
||||||
src_data_buf,
|
src_data_buf,
|
||||||
Subservice::TmAcceptanceSuccess.into(),
|
Subservice::TmAcceptanceSuccess.into(),
|
||||||
token,
|
token,
|
||||||
seq_count,
|
seq_count,
|
||||||
msg_count,
|
msg_count,
|
||||||
time_stamp,
|
time_stamp,
|
||||||
)
|
)?;
|
||||||
}
|
Ok((
|
||||||
|
tm_creator,
|
||||||
pub fn send_acceptance_success(
|
VerificationToken {
|
||||||
&self,
|
state: PhantomData,
|
||||||
mut sendable: VerificationSendable<'_, TcStateNone, VerifSuccess>,
|
req_id: token.req_id,
|
||||||
sender: &(impl EcssTmSenderCore + ?Sized),
|
},
|
||||||
) -> Result<VerificationToken<TcStateAccepted>, VerificationOrSendErrorWithToken<TcStateNone>>
|
))
|
||||||
{
|
|
||||||
sender
|
|
||||||
.send_tm(sendable.pus_tm.take().unwrap().into())
|
|
||||||
.map_err(|e| VerificationOrSendErrorWithToken(e, sendable.token.unwrap()))?;
|
|
||||||
Ok(sendable.send_success_acceptance_success())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn send_acceptance_failure(
|
|
||||||
&self,
|
|
||||||
mut sendable: VerificationSendable<'_, TcStateNone, VerifFailure>,
|
|
||||||
sender: &(impl EcssTmSenderCore + ?Sized),
|
|
||||||
) -> Result<(), VerificationOrSendErrorWithToken<TcStateNone>> {
|
|
||||||
sender
|
|
||||||
.send_tm(sendable.pus_tm.take().unwrap().into())
|
|
||||||
.map_err(|e| VerificationOrSendErrorWithToken(e, sendable.token.unwrap()))?;
|
|
||||||
sendable.send_success_verif_failure();
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Package a PUS TM\[1, 2\] packet, see 8.1.2.2 of the PUS standard.
|
/// Package a PUS TM\[1, 2\] packet, see 8.1.2.2 of the PUS standard.
|
||||||
@ -630,11 +524,8 @@ impl VerificationReporterCore {
|
|||||||
seq_count: u16,
|
seq_count: u16,
|
||||||
msg_count: u16,
|
msg_count: u16,
|
||||||
params: FailParams<'src_data, '_>,
|
params: FailParams<'src_data, '_>,
|
||||||
) -> Result<
|
) -> Result<PusTmCreator, ByteConversionError> {
|
||||||
VerificationSendable<'src_data, TcStateNone, VerifFailure>,
|
self.failure_verification_no_step(
|
||||||
VerificationErrorWithToken<TcStateNone>,
|
|
||||||
> {
|
|
||||||
self.sendable_failure_no_step(
|
|
||||||
src_data_buf,
|
src_data_buf,
|
||||||
Subservice::TmAcceptanceFailure.into(),
|
Subservice::TmAcceptanceFailure.into(),
|
||||||
token,
|
token,
|
||||||
@ -655,30 +546,22 @@ impl VerificationReporterCore {
|
|||||||
seq_count: u16,
|
seq_count: u16,
|
||||||
msg_count: u16,
|
msg_count: u16,
|
||||||
time_stamp: &'src_data [u8],
|
time_stamp: &'src_data [u8],
|
||||||
) -> Result<
|
) -> Result<(PusTmCreator, VerificationToken<TcStateStarted>), ByteConversionError> {
|
||||||
VerificationSendable<'src_data, TcStateAccepted, VerifSuccess>,
|
let tm_creator = self.success_verification_no_step(
|
||||||
VerificationErrorWithToken<TcStateAccepted>,
|
|
||||||
> {
|
|
||||||
self.sendable_success_no_step(
|
|
||||||
src_data_buf,
|
src_data_buf,
|
||||||
Subservice::TmStartSuccess.into(),
|
Subservice::TmStartSuccess.into(),
|
||||||
token,
|
token,
|
||||||
seq_count,
|
seq_count,
|
||||||
msg_count,
|
msg_count,
|
||||||
time_stamp,
|
time_stamp,
|
||||||
)
|
)?;
|
||||||
}
|
Ok((
|
||||||
|
tm_creator,
|
||||||
pub fn send_start_success(
|
VerificationToken {
|
||||||
&self,
|
state: PhantomData,
|
||||||
mut sendable: VerificationSendable<'_, TcStateAccepted, VerifSuccess>,
|
req_id: token.req_id,
|
||||||
sender: &(impl EcssTmSenderCore + ?Sized),
|
},
|
||||||
) -> Result<VerificationToken<TcStateStarted>, VerificationOrSendErrorWithToken<TcStateAccepted>>
|
))
|
||||||
{
|
|
||||||
sender
|
|
||||||
.send_tm(sendable.pus_tm.take().unwrap().into())
|
|
||||||
.map_err(|e| VerificationOrSendErrorWithToken(e, sendable.token.unwrap()))?;
|
|
||||||
Ok(sendable.send_success_start_success())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Package and send a PUS TM\[1, 4\] packet, see 8.1.2.4 of the PUS standard.
|
/// Package and send a PUS TM\[1, 4\] packet, see 8.1.2.4 of the PUS standard.
|
||||||
@ -692,11 +575,8 @@ impl VerificationReporterCore {
|
|||||||
seq_count: u16,
|
seq_count: u16,
|
||||||
msg_count: u16,
|
msg_count: u16,
|
||||||
params: FailParams<'src_data, '_>,
|
params: FailParams<'src_data, '_>,
|
||||||
) -> Result<
|
) -> Result<PusTmCreator, ByteConversionError> {
|
||||||
VerificationSendable<'src_data, TcStateAccepted, VerifFailure>,
|
self.failure_verification_no_step(
|
||||||
VerificationErrorWithToken<TcStateAccepted>,
|
|
||||||
> {
|
|
||||||
self.sendable_failure_no_step(
|
|
||||||
src_data_buf,
|
src_data_buf,
|
||||||
Subservice::TmStartFailure.into(),
|
Subservice::TmStartFailure.into(),
|
||||||
token,
|
token,
|
||||||
@ -707,18 +587,6 @@ impl VerificationReporterCore {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_start_failure(
|
|
||||||
&self,
|
|
||||||
mut sendable: VerificationSendable<'_, TcStateAccepted, VerifFailure>,
|
|
||||||
sender: &(impl EcssTmSenderCore + ?Sized),
|
|
||||||
) -> Result<(), VerificationOrSendErrorWithToken<TcStateAccepted>> {
|
|
||||||
sender
|
|
||||||
.send_tm(sendable.pus_tm.take().unwrap().into())
|
|
||||||
.map_err(|e| VerificationOrSendErrorWithToken(e, sendable.token.unwrap()))?;
|
|
||||||
sendable.send_success_verif_failure();
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Package and send a PUS TM\[1, 5\] packet, see 8.1.2.5 of the PUS standard.
|
/// Package and send a PUS TM\[1, 5\] packet, see 8.1.2.5 of the PUS standard.
|
||||||
///
|
///
|
||||||
/// Requires a token previously acquired by calling [Self::start_success].
|
/// Requires a token previously acquired by calling [Self::start_success].
|
||||||
@ -730,18 +598,16 @@ impl VerificationReporterCore {
|
|||||||
msg_count: u16,
|
msg_count: u16,
|
||||||
time_stamp: &'src_data [u8],
|
time_stamp: &'src_data [u8],
|
||||||
step: impl EcssEnumeration,
|
step: impl EcssEnumeration,
|
||||||
) -> Result<VerificationSendable<'src_data, TcStateStarted, VerifSuccess>, EcssTmtcError> {
|
) -> Result<PusTmCreator, ByteConversionError> {
|
||||||
Ok(VerificationSendable::new_no_token(
|
self.create_pus_verif_success_tm(
|
||||||
self.create_pus_verif_success_tm(
|
src_data_buf,
|
||||||
src_data_buf,
|
Subservice::TmStepSuccess.into(),
|
||||||
Subservice::TmStepSuccess.into(),
|
seq_count,
|
||||||
seq_count,
|
msg_count,
|
||||||
msg_count,
|
&token.req_id,
|
||||||
&token.req_id,
|
time_stamp,
|
||||||
time_stamp,
|
Some(&step),
|
||||||
Some(&step),
|
)
|
||||||
)?,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Package and send a PUS TM\[1, 6\] packet, see 8.1.2.6 of the PUS standard.
|
/// Package and send a PUS TM\[1, 6\] packet, see 8.1.2.6 of the PUS standard.
|
||||||
@ -755,23 +621,16 @@ impl VerificationReporterCore {
|
|||||||
seq_count: u16,
|
seq_count: u16,
|
||||||
msg_count: u16,
|
msg_count: u16,
|
||||||
params: FailParamsWithStep<'src_data, '_>,
|
params: FailParamsWithStep<'src_data, '_>,
|
||||||
) -> Result<
|
) -> Result<PusTmCreator, ByteConversionError> {
|
||||||
VerificationSendable<'src_data, TcStateStarted, VerifFailure>,
|
self.create_pus_verif_fail_tm(
|
||||||
VerificationErrorWithToken<TcStateStarted>,
|
src_data_buf,
|
||||||
> {
|
Subservice::TmStepFailure.into(),
|
||||||
Ok(VerificationSendable::new(
|
seq_count,
|
||||||
self.create_pus_verif_fail_tm(
|
msg_count,
|
||||||
src_data_buf,
|
&token.req_id,
|
||||||
Subservice::TmStepFailure.into(),
|
Some(params.step),
|
||||||
seq_count,
|
¶ms.bp,
|
||||||
msg_count,
|
)
|
||||||
&token.req_id,
|
|
||||||
Some(params.step),
|
|
||||||
¶ms.bp,
|
|
||||||
)
|
|
||||||
.map_err(|e| VerificationErrorWithToken(e, token))?,
|
|
||||||
token,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Package and send a PUS TM\[1, 7\] packet, see 8.1.2.7 of the PUS standard.
|
/// Package and send a PUS TM\[1, 7\] packet, see 8.1.2.7 of the PUS standard.
|
||||||
@ -785,11 +644,8 @@ impl VerificationReporterCore {
|
|||||||
seq_counter: u16,
|
seq_counter: u16,
|
||||||
msg_counter: u16,
|
msg_counter: u16,
|
||||||
time_stamp: &'src_data [u8],
|
time_stamp: &'src_data [u8],
|
||||||
) -> Result<
|
) -> Result<PusTmCreator, ByteConversionError> {
|
||||||
VerificationSendable<'src_data, TcState, VerifSuccess>,
|
self.success_verification_no_step(
|
||||||
VerificationErrorWithToken<TcState>,
|
|
||||||
> {
|
|
||||||
self.sendable_success_no_step(
|
|
||||||
src_data_buf,
|
src_data_buf,
|
||||||
Subservice::TmCompletionSuccess.into(),
|
Subservice::TmCompletionSuccess.into(),
|
||||||
token,
|
token,
|
||||||
@ -810,11 +666,8 @@ impl VerificationReporterCore {
|
|||||||
seq_count: u16,
|
seq_count: u16,
|
||||||
msg_count: u16,
|
msg_count: u16,
|
||||||
params: FailParams<'src_data, '_>,
|
params: FailParams<'src_data, '_>,
|
||||||
) -> Result<
|
) -> Result<PusTmCreator, ByteConversionError> {
|
||||||
VerificationSendable<'src_data, TcState, VerifFailure>,
|
self.failure_verification_no_step(
|
||||||
VerificationErrorWithToken<TcState>,
|
|
||||||
> {
|
|
||||||
self.sendable_failure_no_step(
|
|
||||||
src_data_buf,
|
src_data_buf,
|
||||||
Subservice::TmCompletionFailure.into(),
|
Subservice::TmCompletionFailure.into(),
|
||||||
token,
|
token,
|
||||||
@ -825,30 +678,6 @@ impl VerificationReporterCore {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_step_or_completion_success<TcState: WasAtLeastAccepted + Copy>(
|
|
||||||
&self,
|
|
||||||
mut sendable: VerificationSendable<'_, TcState, VerifSuccess>,
|
|
||||||
sender: &(impl EcssTmSenderCore + ?Sized),
|
|
||||||
) -> Result<(), VerificationOrSendErrorWithToken<TcState>> {
|
|
||||||
sender
|
|
||||||
.send_tm(sendable.pus_tm.take().unwrap().into())
|
|
||||||
.map_err(|e| VerificationOrSendErrorWithToken(e, sendable.token.unwrap()))?;
|
|
||||||
sendable.send_success_step_or_completion_success();
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn send_step_or_completion_failure<TcState: WasAtLeastAccepted + Copy>(
|
|
||||||
&self,
|
|
||||||
mut sendable: VerificationSendable<'_, TcState, VerifFailure>,
|
|
||||||
sender: &(impl EcssTmSenderCore + ?Sized),
|
|
||||||
) -> Result<(), VerificationOrSendErrorWithToken<TcState>> {
|
|
||||||
sender
|
|
||||||
.send_tm(sendable.pus_tm.take().unwrap().into())
|
|
||||||
.map_err(|e| VerificationOrSendErrorWithToken(e, sendable.token.unwrap()))?;
|
|
||||||
sendable.send_success_verif_failure();
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Internal helper function, too many arguments is acceptable for this case.
|
// Internal helper function, too many arguments is acceptable for this case.
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn create_pus_verif_success_tm<'src_data>(
|
fn create_pus_verif_success_tm<'src_data>(
|
||||||
@ -860,7 +689,7 @@ impl VerificationReporterCore {
|
|||||||
req_id: &RequestId,
|
req_id: &RequestId,
|
||||||
time_stamp: &'src_data [u8],
|
time_stamp: &'src_data [u8],
|
||||||
step: Option<&(impl EcssEnumeration + ?Sized)>,
|
step: Option<&(impl EcssEnumeration + ?Sized)>,
|
||||||
) -> Result<PusTmCreator<'src_data>, EcssTmtcError> {
|
) -> Result<PusTmCreator<'src_data>, ByteConversionError> {
|
||||||
let mut source_data_len = size_of::<u32>();
|
let mut source_data_len = size_of::<u32>();
|
||||||
if let Some(step) = step {
|
if let Some(step) = step {
|
||||||
source_data_len += step.size();
|
source_data_len += step.size();
|
||||||
@ -896,7 +725,7 @@ impl VerificationReporterCore {
|
|||||||
req_id: &RequestId,
|
req_id: &RequestId,
|
||||||
step: Option<&(impl EcssEnumeration + ?Sized)>,
|
step: Option<&(impl EcssEnumeration + ?Sized)>,
|
||||||
params: &FailParams<'src_data, '_>,
|
params: &FailParams<'src_data, '_>,
|
||||||
) -> Result<PusTmCreator<'src_data>, EcssTmtcError> {
|
) -> Result<PusTmCreator<'src_data>, ByteConversionError> {
|
||||||
let mut idx = 0;
|
let mut idx = 0;
|
||||||
let mut source_data_len = RequestId::SIZE_AS_BYTES + params.failure_code.size();
|
let mut source_data_len = RequestId::SIZE_AS_BYTES + params.failure_code.size();
|
||||||
if let Some(step) = step {
|
if let Some(step) = step {
|
||||||
@ -914,8 +743,7 @@ impl VerificationReporterCore {
|
|||||||
}
|
}
|
||||||
params
|
params
|
||||||
.failure_code
|
.failure_code
|
||||||
.write_to_be_bytes(&mut src_data_buf[idx..idx + params.failure_code.size()])
|
.write_to_be_bytes(&mut src_data_buf[idx..idx + params.failure_code.size()])?;
|
||||||
.map_err(PusError::ByteConversion)?;
|
|
||||||
idx += params.failure_code.size();
|
idx += params.failure_code.size();
|
||||||
src_data_buf[idx..idx + params.failure_data.len()].copy_from_slice(params.failure_data);
|
src_data_buf[idx..idx + params.failure_data.len()].copy_from_slice(params.failure_data);
|
||||||
let mut sp_header = SpHeader::tm_unseg(self.apid(), seq_count, 0).unwrap();
|
let mut sp_header = SpHeader::tm_unseg(self.apid(), seq_count, 0).unwrap();
|
||||||
@ -953,7 +781,7 @@ impl VerificationReporterCore {
|
|||||||
pub mod alloc_mod {
|
pub mod alloc_mod {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
pus::{TmAsVecSenderWithId, TmInSharedPoolSenderWithId},
|
pus::{PusTmWrapper, TmAsVecSenderWithId, TmInSharedPoolSenderWithId},
|
||||||
seq_count::SequenceCountProvider,
|
seq_count::SequenceCountProvider,
|
||||||
};
|
};
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
@ -994,12 +822,12 @@ pub mod alloc_mod {
|
|||||||
source_data_buf: RefCell<alloc::vec::Vec<u8>>,
|
source_data_buf: RefCell<alloc::vec::Vec<u8>>,
|
||||||
pub seq_count_provider: Option<alloc::boxed::Box<dyn SequenceCountProvider<u16> + Send>>,
|
pub seq_count_provider: Option<alloc::boxed::Box<dyn SequenceCountProvider<u16> + Send>>,
|
||||||
pub msg_count_provider: Option<alloc::boxed::Box<dyn SequenceCountProvider<u16> + Send>>,
|
pub msg_count_provider: Option<alloc::boxed::Box<dyn SequenceCountProvider<u16> + Send>>,
|
||||||
pub reporter: VerificationReporterCore,
|
pub reporter: VerificationReportCreator,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VerificationReporter {
|
impl VerificationReporter {
|
||||||
pub fn new(cfg: &VerificationReporterCfg) -> Self {
|
pub fn new(cfg: &VerificationReporterCfg) -> Self {
|
||||||
let reporter = VerificationReporterCore::new(cfg.apid).unwrap();
|
let reporter = VerificationReportCreator::new(cfg.apid).unwrap();
|
||||||
Self {
|
Self {
|
||||||
source_data_buf: RefCell::new(alloc::vec![
|
source_data_buf: RefCell::new(alloc::vec![
|
||||||
0;
|
0;
|
||||||
@ -1035,8 +863,7 @@ pub mod alloc_mod {
|
|||||||
token: VerificationToken<TcStateNone>,
|
token: VerificationToken<TcStateNone>,
|
||||||
sender: &(impl EcssTmSenderCore + ?Sized),
|
sender: &(impl EcssTmSenderCore + ?Sized),
|
||||||
time_stamp: &[u8],
|
time_stamp: &[u8],
|
||||||
) -> Result<VerificationToken<TcStateAccepted>, VerificationOrSendErrorWithToken<TcStateNone>>
|
) -> Result<VerificationToken<TcStateAccepted>, EcssTmtcError> {
|
||||||
{
|
|
||||||
let seq_count = self
|
let seq_count = self
|
||||||
.seq_count_provider
|
.seq_count_provider
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@ -1046,14 +873,19 @@ pub mod alloc_mod {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(0, |v| v.get_and_increment());
|
.map_or(0, |v| v.get_and_increment());
|
||||||
let mut source_data_buf = self.source_data_buf.borrow_mut();
|
let mut source_data_buf = self.source_data_buf.borrow_mut();
|
||||||
let sendable = self.reporter.acceptance_success(
|
let old_token = token.clone();
|
||||||
source_data_buf.as_mut_slice(),
|
let (tm_creator, token) = self
|
||||||
token,
|
.reporter
|
||||||
seq_count,
|
.acceptance_success(
|
||||||
msg_count,
|
source_data_buf.as_mut_slice(),
|
||||||
time_stamp,
|
token,
|
||||||
)?;
|
seq_count,
|
||||||
self.reporter.send_acceptance_success(sendable, sender)
|
msg_count,
|
||||||
|
time_stamp,
|
||||||
|
)
|
||||||
|
.map_err(PusError::ByteConversion)?;
|
||||||
|
sender.send_tm(PusTmWrapper::Direct(tm_creator))?;
|
||||||
|
Ok(token)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Package and send a PUS TM\[1, 2\] packet, see 8.1.2.2 of the PUS standard
|
/// Package and send a PUS TM\[1, 2\] packet, see 8.1.2.2 of the PUS standard
|
||||||
@ -1062,7 +894,7 @@ pub mod alloc_mod {
|
|||||||
token: VerificationToken<TcStateNone>,
|
token: VerificationToken<TcStateNone>,
|
||||||
sender: &(impl EcssTmSenderCore + ?Sized),
|
sender: &(impl EcssTmSenderCore + ?Sized),
|
||||||
params: FailParams,
|
params: FailParams,
|
||||||
) -> Result<(), VerificationOrSendErrorWithToken<TcStateNone>> {
|
) -> Result<(), EcssTmtcError> {
|
||||||
let seq_count = self
|
let seq_count = self
|
||||||
.seq_count_provider
|
.seq_count_provider
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@ -1072,14 +904,12 @@ pub mod alloc_mod {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(0, |v| v.get_and_increment());
|
.map_or(0, |v| v.get_and_increment());
|
||||||
let mut buf = self.source_data_buf.borrow_mut();
|
let mut buf = self.source_data_buf.borrow_mut();
|
||||||
let sendable = self.reporter.acceptance_failure(
|
let sendable = self
|
||||||
buf.as_mut_slice(),
|
.reporter
|
||||||
token,
|
.acceptance_failure(buf.as_mut_slice(), token, seq_count, msg_count, params)
|
||||||
seq_count,
|
.map_err(PusError::ByteConversion)?;
|
||||||
msg_count,
|
sender.send_tm(PusTmWrapper::Direct(sendable))?;
|
||||||
params,
|
Ok(())
|
||||||
)?;
|
|
||||||
self.reporter.send_acceptance_failure(sendable, sender)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Package and send a PUS TM\[1, 3\] packet, see 8.1.2.3 of the PUS standard.
|
/// Package and send a PUS TM\[1, 3\] packet, see 8.1.2.3 of the PUS standard.
|
||||||
@ -1090,10 +920,7 @@ pub mod alloc_mod {
|
|||||||
token: VerificationToken<TcStateAccepted>,
|
token: VerificationToken<TcStateAccepted>,
|
||||||
sender: &(impl EcssTmSenderCore + ?Sized),
|
sender: &(impl EcssTmSenderCore + ?Sized),
|
||||||
time_stamp: &[u8],
|
time_stamp: &[u8],
|
||||||
) -> Result<
|
) -> Result<VerificationToken<TcStateStarted>, EcssTmtcError> {
|
||||||
VerificationToken<TcStateStarted>,
|
|
||||||
VerificationOrSendErrorWithToken<TcStateAccepted>,
|
|
||||||
> {
|
|
||||||
let seq_count = self
|
let seq_count = self
|
||||||
.seq_count_provider
|
.seq_count_provider
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@ -1103,14 +930,13 @@ pub mod alloc_mod {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(0, |v| v.get_and_increment());
|
.map_or(0, |v| v.get_and_increment());
|
||||||
let mut buf = self.source_data_buf.borrow_mut();
|
let mut buf = self.source_data_buf.borrow_mut();
|
||||||
let sendable = self.reporter.start_success(
|
let (tm_creator, started_token) = self
|
||||||
buf.as_mut_slice(),
|
.reporter
|
||||||
token,
|
.start_success(buf.as_mut_slice(), token, seq_count, msg_count, time_stamp)
|
||||||
seq_count,
|
.map_err(PusError::ByteConversion)?;
|
||||||
msg_count,
|
sender.send_tm(PusTmWrapper::Direct(tm_creator))?;
|
||||||
time_stamp,
|
Ok(started_token)
|
||||||
)?;
|
//self.reporter.send_start_success(sendable, sender)
|
||||||
self.reporter.send_start_success(sendable, sender)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Package and send a PUS TM\[1, 4\] packet, see 8.1.2.4 of the PUS standard.
|
/// Package and send a PUS TM\[1, 4\] packet, see 8.1.2.4 of the PUS standard.
|
||||||
@ -1122,7 +948,7 @@ pub mod alloc_mod {
|
|||||||
token: VerificationToken<TcStateAccepted>,
|
token: VerificationToken<TcStateAccepted>,
|
||||||
sender: &(impl EcssTmSenderCore + ?Sized),
|
sender: &(impl EcssTmSenderCore + ?Sized),
|
||||||
params: FailParams,
|
params: FailParams,
|
||||||
) -> Result<(), VerificationOrSendErrorWithToken<TcStateAccepted>> {
|
) -> Result<(), EcssTmtcError> {
|
||||||
let seq_count = self
|
let seq_count = self
|
||||||
.seq_count_provider
|
.seq_count_provider
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@ -1132,14 +958,12 @@ pub mod alloc_mod {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(0, |v| v.get_and_increment());
|
.map_or(0, |v| v.get_and_increment());
|
||||||
let mut buf = self.source_data_buf.borrow_mut();
|
let mut buf = self.source_data_buf.borrow_mut();
|
||||||
let sendable = self.reporter.start_failure(
|
let sendable = self
|
||||||
buf.as_mut_slice(),
|
.reporter
|
||||||
token,
|
.start_failure(buf.as_mut_slice(), token, seq_count, msg_count, params)
|
||||||
seq_count,
|
.map_err(PusError::ByteConversion)?;
|
||||||
msg_count,
|
sender.send_tm(PusTmWrapper::Direct(sendable))?;
|
||||||
params,
|
Ok(())
|
||||||
)?;
|
|
||||||
self.reporter.send_start_failure(sendable, sender)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Package and send a PUS TM\[1, 5\] packet, see 8.1.2.5 of the PUS standard.
|
/// Package and send a PUS TM\[1, 5\] packet, see 8.1.2.5 of the PUS standard.
|
||||||
@ -1161,17 +985,19 @@ pub mod alloc_mod {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(0, |v| v.get_and_increment());
|
.map_or(0, |v| v.get_and_increment());
|
||||||
let mut buf = self.source_data_buf.borrow_mut();
|
let mut buf = self.source_data_buf.borrow_mut();
|
||||||
let sendable = self.reporter.step_success(
|
let sendable = self
|
||||||
buf.as_mut_slice(),
|
.reporter
|
||||||
token,
|
.step_success(
|
||||||
seq_count,
|
buf.as_mut_slice(),
|
||||||
msg_count,
|
token,
|
||||||
time_stamp,
|
seq_count,
|
||||||
step,
|
msg_count,
|
||||||
)?;
|
time_stamp,
|
||||||
self.reporter
|
step,
|
||||||
.send_step_or_completion_success(sendable, sender)
|
)
|
||||||
.map_err(|e| e.0)
|
.map_err(PusError::ByteConversion)?;
|
||||||
|
sender.send_tm(PusTmWrapper::Direct(sendable))?;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Package and send a PUS TM\[1, 6\] packet, see 8.1.2.6 of the PUS standard.
|
/// Package and send a PUS TM\[1, 6\] packet, see 8.1.2.6 of the PUS standard.
|
||||||
@ -1183,7 +1009,7 @@ pub mod alloc_mod {
|
|||||||
token: VerificationToken<TcStateStarted>,
|
token: VerificationToken<TcStateStarted>,
|
||||||
sender: &(impl EcssTmSenderCore + ?Sized),
|
sender: &(impl EcssTmSenderCore + ?Sized),
|
||||||
params: FailParamsWithStep,
|
params: FailParamsWithStep,
|
||||||
) -> Result<(), VerificationOrSendErrorWithToken<TcStateStarted>> {
|
) -> Result<(), EcssTmtcError> {
|
||||||
let seq_count = self
|
let seq_count = self
|
||||||
.seq_count_provider
|
.seq_count_provider
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@ -1193,15 +1019,12 @@ pub mod alloc_mod {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(0, |v| v.get_and_increment());
|
.map_or(0, |v| v.get_and_increment());
|
||||||
let mut buf = self.source_data_buf.borrow_mut();
|
let mut buf = self.source_data_buf.borrow_mut();
|
||||||
let sendable = self.reporter.step_failure(
|
let sendable = self
|
||||||
buf.as_mut_slice(),
|
.reporter
|
||||||
token,
|
.step_failure(buf.as_mut_slice(), token, seq_count, msg_count, params)
|
||||||
seq_count,
|
.map_err(PusError::ByteConversion)?;
|
||||||
msg_count,
|
sender.send_tm(PusTmWrapper::Direct(sendable))?;
|
||||||
params,
|
Ok(())
|
||||||
)?;
|
|
||||||
self.reporter
|
|
||||||
.send_step_or_completion_failure(sendable, sender)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Package and send a PUS TM\[1, 7\] packet, see 8.1.2.7 of the PUS standard.
|
/// Package and send a PUS TM\[1, 7\] packet, see 8.1.2.7 of the PUS standard.
|
||||||
@ -1213,7 +1036,7 @@ pub mod alloc_mod {
|
|||||||
token: VerificationToken<TcState>,
|
token: VerificationToken<TcState>,
|
||||||
sender: &(impl EcssTmSenderCore + ?Sized),
|
sender: &(impl EcssTmSenderCore + ?Sized),
|
||||||
time_stamp: &[u8],
|
time_stamp: &[u8],
|
||||||
) -> Result<(), VerificationOrSendErrorWithToken<TcState>> {
|
) -> Result<(), EcssTmtcError> {
|
||||||
let seq_count = self
|
let seq_count = self
|
||||||
.seq_count_provider
|
.seq_count_provider
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@ -1223,15 +1046,12 @@ pub mod alloc_mod {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(0, |v| v.get_and_increment());
|
.map_or(0, |v| v.get_and_increment());
|
||||||
let mut buf = self.source_data_buf.borrow_mut();
|
let mut buf = self.source_data_buf.borrow_mut();
|
||||||
let sendable = self.reporter.completion_success(
|
let sendable = self
|
||||||
buf.as_mut_slice(),
|
.reporter
|
||||||
token,
|
.completion_success(buf.as_mut_slice(), token, seq_count, msg_count, time_stamp)
|
||||||
seq_count,
|
.map_err(PusError::ByteConversion)?;
|
||||||
msg_count,
|
sender.send_tm(PusTmWrapper::Direct(sendable))?;
|
||||||
time_stamp,
|
Ok(())
|
||||||
)?;
|
|
||||||
self.reporter
|
|
||||||
.send_step_or_completion_success(sendable, sender)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Package and send a PUS TM\[1, 8\] packet, see 8.1.2.8 of the PUS standard.
|
/// Package and send a PUS TM\[1, 8\] packet, see 8.1.2.8 of the PUS standard.
|
||||||
@ -1243,7 +1063,7 @@ pub mod alloc_mod {
|
|||||||
token: VerificationToken<TcState>,
|
token: VerificationToken<TcState>,
|
||||||
sender: &(impl EcssTmSenderCore + ?Sized),
|
sender: &(impl EcssTmSenderCore + ?Sized),
|
||||||
params: FailParams,
|
params: FailParams,
|
||||||
) -> Result<(), VerificationOrSendErrorWithToken<TcState>> {
|
) -> Result<(), EcssTmtcError> {
|
||||||
let seq_count = self
|
let seq_count = self
|
||||||
.seq_count_provider
|
.seq_count_provider
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@ -1253,15 +1073,12 @@ pub mod alloc_mod {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(0, |v| v.get_and_increment());
|
.map_or(0, |v| v.get_and_increment());
|
||||||
let mut buf = self.source_data_buf.borrow_mut();
|
let mut buf = self.source_data_buf.borrow_mut();
|
||||||
let sendable = self.reporter.completion_failure(
|
let sendable = self
|
||||||
buf.as_mut_slice(),
|
.reporter
|
||||||
token,
|
.completion_failure(buf.as_mut_slice(), token, seq_count, msg_count, params)
|
||||||
seq_count,
|
.map_err(PusError::ByteConversion)?;
|
||||||
msg_count,
|
sender.send_tm(PusTmWrapper::Direct(sendable))?;
|
||||||
params,
|
Ok(())
|
||||||
)?;
|
|
||||||
self.reporter
|
|
||||||
.send_step_or_completion_failure(sendable, sender)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1310,8 +1127,7 @@ pub mod alloc_mod {
|
|||||||
&self,
|
&self,
|
||||||
token: VerificationToken<TcStateNone>,
|
token: VerificationToken<TcStateNone>,
|
||||||
time_stamp: &[u8],
|
time_stamp: &[u8],
|
||||||
) -> Result<VerificationToken<TcStateAccepted>, VerificationOrSendErrorWithToken<TcStateNone>>
|
) -> Result<VerificationToken<TcStateAccepted>, EcssTmtcError> {
|
||||||
{
|
|
||||||
self.reporter
|
self.reporter
|
||||||
.acceptance_success(token, &self.sender, time_stamp)
|
.acceptance_success(token, &self.sender, time_stamp)
|
||||||
}
|
}
|
||||||
@ -1320,7 +1136,7 @@ pub mod alloc_mod {
|
|||||||
&self,
|
&self,
|
||||||
token: VerificationToken<TcStateNone>,
|
token: VerificationToken<TcStateNone>,
|
||||||
params: FailParams,
|
params: FailParams,
|
||||||
) -> Result<(), VerificationOrSendErrorWithToken<TcStateNone>> {
|
) -> Result<(), EcssTmtcError> {
|
||||||
self.reporter
|
self.reporter
|
||||||
.acceptance_failure(token, &self.sender, params)
|
.acceptance_failure(token, &self.sender, params)
|
||||||
}
|
}
|
||||||
@ -1329,10 +1145,7 @@ pub mod alloc_mod {
|
|||||||
&self,
|
&self,
|
||||||
token: VerificationToken<TcStateAccepted>,
|
token: VerificationToken<TcStateAccepted>,
|
||||||
time_stamp: &[u8],
|
time_stamp: &[u8],
|
||||||
) -> Result<
|
) -> Result<VerificationToken<TcStateStarted>, EcssTmtcError> {
|
||||||
VerificationToken<TcStateStarted>,
|
|
||||||
VerificationOrSendErrorWithToken<TcStateAccepted>,
|
|
||||||
> {
|
|
||||||
self.reporter.start_success(token, &self.sender, time_stamp)
|
self.reporter.start_success(token, &self.sender, time_stamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1340,7 +1153,7 @@ pub mod alloc_mod {
|
|||||||
&self,
|
&self,
|
||||||
token: VerificationToken<TcStateAccepted>,
|
token: VerificationToken<TcStateAccepted>,
|
||||||
params: FailParams,
|
params: FailParams,
|
||||||
) -> Result<(), VerificationOrSendErrorWithToken<TcStateAccepted>> {
|
) -> Result<(), EcssTmtcError> {
|
||||||
self.reporter.start_failure(token, &self.sender, params)
|
self.reporter.start_failure(token, &self.sender, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1358,7 +1171,7 @@ pub mod alloc_mod {
|
|||||||
&self,
|
&self,
|
||||||
token: VerificationToken<TcStateStarted>,
|
token: VerificationToken<TcStateStarted>,
|
||||||
params: FailParamsWithStep,
|
params: FailParamsWithStep,
|
||||||
) -> Result<(), VerificationOrSendErrorWithToken<TcStateStarted>> {
|
) -> Result<(), EcssTmtcError> {
|
||||||
self.reporter.step_failure(token, &self.sender, params)
|
self.reporter.step_failure(token, &self.sender, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1366,7 +1179,7 @@ pub mod alloc_mod {
|
|||||||
&self,
|
&self,
|
||||||
token: VerificationToken<TcState>,
|
token: VerificationToken<TcState>,
|
||||||
time_stamp: &[u8],
|
time_stamp: &[u8],
|
||||||
) -> Result<(), VerificationOrSendErrorWithToken<TcState>> {
|
) -> Result<(), EcssTmtcError> {
|
||||||
self.reporter
|
self.reporter
|
||||||
.completion_success(token, &self.sender, time_stamp)
|
.completion_success(token, &self.sender, time_stamp)
|
||||||
}
|
}
|
||||||
@ -1375,7 +1188,7 @@ pub mod alloc_mod {
|
|||||||
&self,
|
&self,
|
||||||
token: VerificationToken<TcState>,
|
token: VerificationToken<TcState>,
|
||||||
params: FailParams,
|
params: FailParams,
|
||||||
) -> Result<(), VerificationOrSendErrorWithToken<TcState>> {
|
) -> Result<(), EcssTmtcError> {
|
||||||
self.reporter
|
self.reporter
|
||||||
.completion_failure(token, &self.sender, params)
|
.completion_failure(token, &self.sender, params)
|
||||||
}
|
}
|
||||||
@ -1490,10 +1303,7 @@ pub mod tests {
|
|||||||
&self,
|
&self,
|
||||||
token: VerificationToken<TcStateNone>,
|
token: VerificationToken<TcStateNone>,
|
||||||
_time_stamp: &[u8],
|
_time_stamp: &[u8],
|
||||||
) -> Result<
|
) -> Result<VerificationToken<super::TcStateAccepted>, EcssTmtcError> {
|
||||||
VerificationToken<super::TcStateAccepted>,
|
|
||||||
super::VerificationOrSendErrorWithToken<TcStateNone>,
|
|
||||||
> {
|
|
||||||
let verif_map = self.verification_map.lock().unwrap();
|
let verif_map = self.verification_map.lock().unwrap();
|
||||||
match verif_map.borrow_mut().get_mut(&token.req_id) {
|
match verif_map.borrow_mut().get_mut(&token.req_id) {
|
||||||
Some(entry) => entry.accepted = Some(true),
|
Some(entry) => entry.accepted = Some(true),
|
||||||
@ -1512,7 +1322,7 @@ pub mod tests {
|
|||||||
&self,
|
&self,
|
||||||
token: VerificationToken<TcStateNone>,
|
token: VerificationToken<TcStateNone>,
|
||||||
params: FailParams,
|
params: FailParams,
|
||||||
) -> Result<(), super::VerificationOrSendErrorWithToken<TcStateNone>> {
|
) -> Result<(), EcssTmtcError> {
|
||||||
let verif_map = self.verification_map.lock().unwrap();
|
let verif_map = self.verification_map.lock().unwrap();
|
||||||
match verif_map.borrow_mut().get_mut(&token.req_id) {
|
match verif_map.borrow_mut().get_mut(&token.req_id) {
|
||||||
Some(entry) => {
|
Some(entry) => {
|
||||||
@ -1532,10 +1342,7 @@ pub mod tests {
|
|||||||
&self,
|
&self,
|
||||||
token: VerificationToken<super::TcStateAccepted>,
|
token: VerificationToken<super::TcStateAccepted>,
|
||||||
_time_stamp: &[u8],
|
_time_stamp: &[u8],
|
||||||
) -> Result<
|
) -> Result<VerificationToken<super::TcStateStarted>, EcssTmtcError> {
|
||||||
VerificationToken<super::TcStateStarted>,
|
|
||||||
super::VerificationOrSendErrorWithToken<super::TcStateAccepted>,
|
|
||||||
> {
|
|
||||||
let verif_map = self.verification_map.lock().unwrap();
|
let verif_map = self.verification_map.lock().unwrap();
|
||||||
match verif_map.borrow_mut().get_mut(&token.req_id) {
|
match verif_map.borrow_mut().get_mut(&token.req_id) {
|
||||||
Some(entry) => entry.started = Some(true),
|
Some(entry) => entry.started = Some(true),
|
||||||
@ -1551,7 +1358,7 @@ pub mod tests {
|
|||||||
&self,
|
&self,
|
||||||
token: VerificationToken<super::TcStateAccepted>,
|
token: VerificationToken<super::TcStateAccepted>,
|
||||||
params: FailParams,
|
params: FailParams,
|
||||||
) -> Result<(), super::VerificationOrSendErrorWithToken<super::TcStateAccepted>> {
|
) -> Result<(), EcssTmtcError> {
|
||||||
let verif_map = self.verification_map.lock().unwrap();
|
let verif_map = self.verification_map.lock().unwrap();
|
||||||
match verif_map.borrow_mut().get_mut(&token.req_id) {
|
match verif_map.borrow_mut().get_mut(&token.req_id) {
|
||||||
Some(entry) => {
|
Some(entry) => {
|
||||||
@ -1585,7 +1392,7 @@ pub mod tests {
|
|||||||
&self,
|
&self,
|
||||||
token: VerificationToken<super::TcStateStarted>,
|
token: VerificationToken<super::TcStateStarted>,
|
||||||
_params: FailParamsWithStep,
|
_params: FailParamsWithStep,
|
||||||
) -> Result<(), super::VerificationOrSendErrorWithToken<super::TcStateStarted>> {
|
) -> Result<(), EcssTmtcError> {
|
||||||
let verif_map = self.verification_map.lock().unwrap();
|
let verif_map = self.verification_map.lock().unwrap();
|
||||||
match verif_map.borrow_mut().get_mut(&token.req_id) {
|
match verif_map.borrow_mut().get_mut(&token.req_id) {
|
||||||
Some(entry) => {
|
Some(entry) => {
|
||||||
@ -1600,7 +1407,7 @@ pub mod tests {
|
|||||||
&self,
|
&self,
|
||||||
token: VerificationToken<TcState>,
|
token: VerificationToken<TcState>,
|
||||||
_time_stamp: &[u8],
|
_time_stamp: &[u8],
|
||||||
) -> Result<(), super::VerificationOrSendErrorWithToken<TcState>> {
|
) -> Result<(), EcssTmtcError> {
|
||||||
let verif_map = self.verification_map.lock().unwrap();
|
let verif_map = self.verification_map.lock().unwrap();
|
||||||
match verif_map.borrow_mut().get_mut(&token.req_id) {
|
match verif_map.borrow_mut().get_mut(&token.req_id) {
|
||||||
Some(entry) => entry.completed = Some(true),
|
Some(entry) => entry.completed = Some(true),
|
||||||
@ -1616,7 +1423,7 @@ pub mod tests {
|
|||||||
&self,
|
&self,
|
||||||
token: VerificationToken<TcState>,
|
token: VerificationToken<TcState>,
|
||||||
params: FailParams,
|
params: FailParams,
|
||||||
) -> Result<(), super::VerificationOrSendErrorWithToken<TcState>> {
|
) -> Result<(), EcssTmtcError> {
|
||||||
let verif_map = self.verification_map.lock().unwrap();
|
let verif_map = self.verification_map.lock().unwrap();
|
||||||
match verif_map.borrow_mut().get_mut(&token.req_id) {
|
match verif_map.borrow_mut().get_mut(&token.req_id) {
|
||||||
Some(entry) => {
|
Some(entry) => {
|
||||||
@ -1860,8 +1667,7 @@ pub mod tests {
|
|||||||
let res = b.helper.acceptance_failure(tok, fail_params);
|
let res = b.helper.acceptance_failure(tok, fail_params);
|
||||||
assert!(res.is_err());
|
assert!(res.is_err());
|
||||||
let err_with_token = res.unwrap_err();
|
let err_with_token = res.unwrap_err();
|
||||||
assert_eq!(err_with_token.1, tok);
|
match err_with_token {
|
||||||
match err_with_token.0 {
|
|
||||||
EcssTmtcError::Pus(PusError::ByteConversion(e)) => match e {
|
EcssTmtcError::Pus(PusError::ByteConversion(e)) => match e {
|
||||||
ByteConversionError::ToSliceTooSmall { found, expected } => {
|
ByteConversionError::ToSliceTooSmall { found, expected } => {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -1875,7 +1681,7 @@ pub mod tests {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
panic!("{}", format!("Unexpected error {:?}", err_with_token.0))
|
panic!("{}", format!("Unexpected error {:?}", err_with_token))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user