2022-09-06 10:44:13 +02:00
|
|
|
//! # PUS Verification Service 1 Module
|
|
|
|
//!
|
|
|
|
//! This module allows packaging and sending PUS Service 1 packets. It is conforming to section
|
|
|
|
//! 8 of the PUS standard ECSS-E-ST-70-41C.
|
|
|
|
//!
|
2022-09-06 10:47:10 +02:00
|
|
|
//! The core object to report TC verification progress is the [VerificationReporter]. It exposes
|
2022-09-06 10:45:02 +02:00
|
|
|
//! an API which uses type-state programming to avoid calling the verification steps in
|
|
|
|
//! an invalid order.
|
2022-09-06 10:47:10 +02:00
|
|
|
//!
|
2022-09-07 15:19:16 +02:00
|
|
|
//! # Examples
|
|
|
|
//!
|
2022-09-07 15:21:44 +02:00
|
|
|
//! Basic single-threaded example where a full success sequence for a given ping telecommand is
|
2022-09-11 16:30:47 +02:00
|
|
|
//! executed. Note that the verification part could also be done in a separate thread.
|
2022-09-07 15:21:44 +02:00
|
|
|
//!
|
2022-09-07 15:19:16 +02:00
|
|
|
//! ```
|
2022-12-30 23:28:33 +01:00
|
|
|
//! use std::sync::{Arc, mpsc, RwLock};
|
2022-09-07 15:19:16 +02:00
|
|
|
//! use std::time::Duration;
|
2022-11-20 19:54:14 +01:00
|
|
|
//! use satrs_core::pool::{LocalPool, PoolCfg, PoolProvider, SharedPool};
|
2022-12-30 23:28:33 +01:00
|
|
|
//! use satrs_core::pus::verification::{MpscVerifSender, VerificationReporterCfg, VerificationReporterWithSender};
|
2023-01-03 16:35:23 +01:00
|
|
|
//! use satrs_core::seq_count::SeqCountProviderSimple;
|
2022-09-07 15:19:16 +02:00
|
|
|
//! use spacepackets::ecss::PusPacket;
|
|
|
|
//! use spacepackets::SpHeader;
|
|
|
|
//! use spacepackets::tc::{PusTc, PusTcSecondaryHeader};
|
|
|
|
//! use spacepackets::tm::PusTm;
|
|
|
|
//!
|
|
|
|
//! const EMPTY_STAMP: [u8; 7] = [0; 7];
|
|
|
|
//! const TEST_APID: u16 = 0x02;
|
|
|
|
//!
|
|
|
|
//! let pool_cfg = PoolCfg::new(vec![(10, 32), (10, 64), (10, 128), (10, 1024)]);
|
2022-09-10 13:34:04 +02:00
|
|
|
//! let shared_tm_pool: SharedPool = Arc::new(RwLock::new(Box::new(LocalPool::new(pool_cfg.clone()))));
|
2022-12-30 23:28:33 +01:00
|
|
|
//! let (verif_tx, verif_rx) = mpsc::channel();
|
|
|
|
//! let sender = MpscVerifSender::new(shared_tm_pool.clone(), verif_tx);
|
2023-01-03 16:35:23 +01:00
|
|
|
//! let cfg = VerificationReporterCfg::new(TEST_APID, Box::new(SeqCountProviderSimple::default()), 1, 2, 8).unwrap();
|
2022-11-21 10:28:31 +01:00
|
|
|
//! let mut reporter = VerificationReporterWithSender::new(&cfg , Box::new(sender));
|
2022-09-07 15:19:16 +02:00
|
|
|
//!
|
2022-12-04 20:00:20 +01:00
|
|
|
//! let mut sph = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
2022-09-07 15:19:16 +02:00
|
|
|
//! let tc_header = PusTcSecondaryHeader::new_simple(17, 1);
|
|
|
|
//! let pus_tc_0 = PusTc::new(&mut sph, tc_header, None, true);
|
|
|
|
//! let init_token = reporter.add_tc(&pus_tc_0);
|
|
|
|
//!
|
|
|
|
//! // Complete success sequence for a telecommand
|
|
|
|
//! let accepted_token = reporter.acceptance_success(init_token, &EMPTY_STAMP).unwrap();
|
|
|
|
//! let started_token = reporter.start_success(accepted_token, &EMPTY_STAMP).unwrap();
|
|
|
|
//! reporter.completion_success(started_token, &EMPTY_STAMP).unwrap();
|
|
|
|
//!
|
|
|
|
//! // Verify it arrives correctly on receiver end
|
|
|
|
//! let mut tm_buf: [u8; 1024] = [0; 1024];
|
|
|
|
//! let mut packet_idx = 0;
|
|
|
|
//! while packet_idx < 3 {
|
|
|
|
//! let addr = verif_rx.recv_timeout(Duration::from_millis(10)).unwrap();
|
|
|
|
//! let tm_len;
|
|
|
|
//! {
|
|
|
|
//! let mut rg = shared_tm_pool.write().expect("Error locking shared pool");
|
|
|
|
//! let store_guard = rg.read_with_guard(addr);
|
|
|
|
//! let slice = store_guard.read().expect("Error reading TM slice");
|
|
|
|
//! tm_len = slice.len();
|
|
|
|
//! tm_buf[0..tm_len].copy_from_slice(slice);
|
|
|
|
//! }
|
2022-09-13 10:43:07 +02:00
|
|
|
//! let (pus_tm, _) = PusTm::from_bytes(&tm_buf[0..tm_len], 7)
|
2022-09-07 15:19:16 +02:00
|
|
|
//! .expect("Error reading verification TM");
|
|
|
|
//! if packet_idx == 0 {
|
|
|
|
//! assert_eq!(pus_tm.subservice(), 1);
|
|
|
|
//! } else if packet_idx == 1 {
|
|
|
|
//! assert_eq!(pus_tm.subservice(), 3);
|
|
|
|
//! } else if packet_idx == 2 {
|
|
|
|
//! assert_eq!(pus_tm.subservice(), 7);
|
|
|
|
//! }
|
|
|
|
//! packet_idx += 1;
|
|
|
|
//! }
|
|
|
|
//! ```
|
|
|
|
//!
|
2022-09-11 16:31:38 +02:00
|
|
|
//! The [integration test](https://egit.irs.uni-stuttgart.de/rust/fsrc-launchpad/src/branch/main/fsrc-core/tests/verification_test.rs)
|
2022-09-07 15:19:16 +02:00
|
|
|
//! for the verification module contains examples how this module could be used in a more complex
|
|
|
|
//! context involving multiple threads
|
2023-01-03 20:44:28 +01:00
|
|
|
use crate::pus::{source_buffer_large_enough, EcssTmError, EcssTmErrorWithSend, EcssTmSenderCore};
|
2022-09-11 14:51:25 +02:00
|
|
|
use core::fmt::{Display, Formatter};
|
2022-09-07 11:02:45 +02:00
|
|
|
use core::hash::{Hash, Hasher};
|
2022-09-05 00:20:32 +02:00
|
|
|
use core::marker::PhantomData;
|
2022-09-03 17:09:36 +02:00
|
|
|
use core::mem::size_of;
|
2022-12-30 23:09:58 +01:00
|
|
|
#[cfg(feature = "alloc")]
|
2022-09-05 00:20:32 +02:00
|
|
|
use delegate::delegate;
|
2023-01-02 23:32:31 +01:00
|
|
|
#[cfg(feature = "serde")]
|
|
|
|
use serde::{Deserialize, Serialize};
|
2022-09-11 20:51:14 +02:00
|
|
|
use spacepackets::ecss::EcssEnumeration;
|
2022-09-03 16:30:37 +02:00
|
|
|
use spacepackets::tc::PusTc;
|
|
|
|
use spacepackets::tm::{PusTm, PusTmSecondaryHeader};
|
|
|
|
use spacepackets::{CcsdsPacket, PacketId, PacketSequenceCtrl};
|
2022-09-11 20:51:14 +02:00
|
|
|
use spacepackets::{SpHeader, MAX_APID};
|
|
|
|
|
2023-01-03 16:35:23 +01:00
|
|
|
pub use crate::seq_count::SeqCountProviderSimple;
|
2022-11-21 10:16:15 +01:00
|
|
|
|
2022-09-11 20:51:14 +02:00
|
|
|
#[cfg(feature = "alloc")]
|
2022-12-30 23:09:58 +01:00
|
|
|
pub use alloc_mod::{
|
2023-01-03 13:02:12 +01:00
|
|
|
VerificationReporter, VerificationReporterCfg, VerificationReporterWithSender,
|
2022-11-21 10:28:31 +01:00
|
|
|
};
|
2022-09-03 20:55:32 +02:00
|
|
|
|
2023-01-03 13:09:14 +01:00
|
|
|
use crate::seq_count::SequenceCountProviderCore;
|
2023-01-03 00:22:48 +01:00
|
|
|
#[cfg(all(feature = "crossbeam", feature = "std"))]
|
2022-12-30 23:28:33 +01:00
|
|
|
pub use stdmod::CrossbeamVerifSender;
|
2022-09-03 20:55:32 +02:00
|
|
|
#[cfg(feature = "std")]
|
2022-09-10 13:34:04 +02:00
|
|
|
pub use stdmod::{
|
2022-12-30 23:28:33 +01:00
|
|
|
MpscVerifSender, SharedStdVerifReporterWithSender, StdVerifReporterWithSender,
|
|
|
|
StdVerifSenderError,
|
2022-09-10 13:34:04 +02:00
|
|
|
};
|
2022-09-03 20:55:32 +02:00
|
|
|
|
2022-09-11 21:14:19 +02:00
|
|
|
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
|
2023-01-02 23:54:59 +01:00
|
|
|
pub enum Subservice {
|
2022-09-11 21:14:19 +02:00
|
|
|
TmAcceptanceSuccess = 1,
|
|
|
|
TmAcceptanceFailure = 2,
|
|
|
|
TmStartSuccess = 3,
|
|
|
|
TmStartFailure = 4,
|
|
|
|
TmStepSuccess = 5,
|
|
|
|
TmStepFailure = 6,
|
|
|
|
TmCompletionSuccess = 7,
|
|
|
|
TmCompletionFailure = 8,
|
|
|
|
}
|
|
|
|
|
2023-01-02 23:54:59 +01:00
|
|
|
impl From<Subservice> for u8 {
|
|
|
|
fn from(enumeration: Subservice) -> Self {
|
2022-09-11 21:14:19 +02:00
|
|
|
enumeration as u8
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-06 10:44:13 +02:00
|
|
|
/// This is a request identifier as specified in 5.4.11.2 c. of the PUS standard
|
|
|
|
/// This field equivalent to the first two bytes of the CCSDS space packet header.
|
2022-09-07 11:02:45 +02:00
|
|
|
#[derive(Debug, Eq, Copy, Clone)]
|
2023-01-02 23:32:31 +01:00
|
|
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
2022-09-03 16:30:37 +02:00
|
|
|
pub struct RequestId {
|
|
|
|
version_number: u8,
|
|
|
|
packet_id: PacketId,
|
|
|
|
psc: PacketSequenceCtrl,
|
|
|
|
}
|
|
|
|
|
2022-09-11 14:51:25 +02:00
|
|
|
impl Display for RequestId {
|
|
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
|
2022-09-11 14:58:51 +02:00
|
|
|
write!(f, "{:#08x}", self.raw())
|
2022-09-11 14:51:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-07 11:02:45 +02:00
|
|
|
impl Hash for RequestId {
|
|
|
|
fn hash<H: Hasher>(&self, state: &mut H) {
|
|
|
|
self.raw().hash(state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Implement manually to satisfy derive_hash_xor_eq lint
|
|
|
|
impl PartialEq for RequestId {
|
|
|
|
fn eq(&self, other: &Self) -> bool {
|
|
|
|
self.version_number == other.version_number
|
|
|
|
&& self.packet_id == other.packet_id
|
|
|
|
&& self.psc == other.psc
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-03 17:09:36 +02:00
|
|
|
impl RequestId {
|
2022-09-07 01:06:32 +02:00
|
|
|
pub const SIZE_AS_BYTES: usize = size_of::<u32>();
|
2022-09-03 17:09:36 +02:00
|
|
|
|
2022-09-07 01:06:32 +02:00
|
|
|
pub fn raw(&self) -> u32 {
|
|
|
|
((self.version_number as u32) << 29)
|
2022-09-03 17:09:36 +02:00
|
|
|
| ((self.packet_id.raw() as u32) << 16)
|
2022-09-07 01:06:32 +02:00
|
|
|
| self.psc.raw() as u32
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn to_bytes(&self, buf: &mut [u8]) {
|
|
|
|
let raw = self.raw();
|
2022-09-03 17:09:36 +02:00
|
|
|
buf.copy_from_slice(raw.to_be_bytes().as_slice());
|
|
|
|
}
|
2022-09-03 20:55:32 +02:00
|
|
|
|
|
|
|
pub fn from_bytes(buf: &[u8]) -> Option<Self> {
|
|
|
|
if buf.len() < 4 {
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
let raw = u32::from_be_bytes(buf[0..Self::SIZE_AS_BYTES].try_into().unwrap());
|
|
|
|
Some(Self {
|
|
|
|
version_number: ((raw >> 29) & 0b111) as u8,
|
|
|
|
packet_id: PacketId::from(((raw >> 16) & 0xffff) as u16),
|
|
|
|
psc: PacketSequenceCtrl::from((raw & 0xffff) as u16),
|
|
|
|
})
|
|
|
|
}
|
2022-09-03 17:09:36 +02:00
|
|
|
}
|
2022-09-03 16:30:37 +02:00
|
|
|
impl RequestId {
|
2022-09-06 10:44:13 +02:00
|
|
|
/// This allows extracting the request ID from a given PUS telecommand.
|
2022-09-03 16:30:37 +02:00
|
|
|
pub fn new(tc: &PusTc) -> Self {
|
|
|
|
RequestId {
|
|
|
|
version_number: tc.ccsds_version(),
|
|
|
|
packet_id: tc.packet_id(),
|
|
|
|
psc: tc.psc(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-06 10:44:13 +02:00
|
|
|
/// If a verification operation fails, the passed token will be returned as well. This allows
|
|
|
|
/// re-trying the operation at a later point.
|
2022-09-05 00:20:32 +02:00
|
|
|
#[derive(Debug, Clone)]
|
2023-01-03 20:44:28 +01:00
|
|
|
pub struct VerificationOrSendErrorWithToken<E, T>(EcssTmErrorWithSend<E>, VerificationToken<T>);
|
2022-09-06 00:17:52 +02:00
|
|
|
|
2023-01-03 20:44:28 +01:00
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub struct VerificationErrorWithToken<T>(EcssTmError, VerificationToken<T>);
|
|
|
|
|
|
|
|
impl<E, T> From<VerificationErrorWithToken<T>> for VerificationOrSendErrorWithToken<E, T> {
|
|
|
|
fn from(value: VerificationErrorWithToken<T>) -> Self {
|
|
|
|
VerificationOrSendErrorWithToken(value.0.into(), value.1)
|
|
|
|
}
|
|
|
|
}
|
2022-09-06 10:44:13 +02:00
|
|
|
/// Support token to allow type-state programming. This prevents calling the verification
|
|
|
|
/// steps in an invalid order.
|
2022-09-06 10:14:47 +02:00
|
|
|
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
2022-09-05 00:20:32 +02:00
|
|
|
pub struct VerificationToken<STATE> {
|
|
|
|
state: PhantomData<STATE>,
|
|
|
|
req_id: RequestId,
|
2022-09-03 20:55:32 +02:00
|
|
|
}
|
|
|
|
|
2022-09-06 10:14:47 +02:00
|
|
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
2022-11-13 21:07:16 +01:00
|
|
|
pub struct TcStateNone;
|
2022-09-06 10:14:47 +02:00
|
|
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
2022-11-13 21:07:16 +01:00
|
|
|
pub struct TcStateAccepted;
|
2022-09-06 10:14:47 +02:00
|
|
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
2022-11-13 21:07:16 +01:00
|
|
|
pub struct TcStateStarted;
|
2022-10-15 19:36:13 +02:00
|
|
|
|
2022-11-12 23:13:55 +01:00
|
|
|
#[derive(Debug, Eq, PartialEq)]
|
2022-11-13 21:07:16 +01:00
|
|
|
pub enum TcStateToken {
|
|
|
|
None(VerificationToken<TcStateNone>),
|
|
|
|
Accepted(VerificationToken<TcStateAccepted>),
|
|
|
|
Started(VerificationToken<TcStateStarted>),
|
2022-10-15 19:36:13 +02:00
|
|
|
}
|
2022-09-05 00:20:32 +02:00
|
|
|
|
2022-11-13 21:07:16 +01:00
|
|
|
impl From<VerificationToken<TcStateNone>> for TcStateToken {
|
|
|
|
fn from(t: VerificationToken<TcStateNone>) -> Self {
|
|
|
|
TcStateToken::None(t)
|
2022-11-12 23:13:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-13 21:07:16 +01:00
|
|
|
impl From<VerificationToken<TcStateAccepted>> for TcStateToken {
|
|
|
|
fn from(t: VerificationToken<TcStateAccepted>) -> Self {
|
|
|
|
TcStateToken::Accepted(t)
|
2022-11-12 23:13:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-13 21:07:16 +01:00
|
|
|
impl From<VerificationToken<TcStateStarted>> for TcStateToken {
|
|
|
|
fn from(t: VerificationToken<TcStateStarted>) -> Self {
|
|
|
|
TcStateToken::Started(t)
|
2022-11-12 23:13:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-05 00:20:32 +02:00
|
|
|
impl<STATE> VerificationToken<STATE> {
|
2022-11-13 21:07:16 +01:00
|
|
|
fn new(req_id: RequestId) -> VerificationToken<TcStateNone> {
|
2022-09-05 00:20:32 +02:00
|
|
|
VerificationToken {
|
|
|
|
state: PhantomData,
|
|
|
|
req_id,
|
2022-09-03 20:55:32 +02:00
|
|
|
}
|
|
|
|
}
|
2022-09-07 11:02:45 +02:00
|
|
|
|
|
|
|
pub fn req_id(&self) -> RequestId {
|
|
|
|
self.req_id
|
|
|
|
}
|
2022-09-03 20:55:32 +02:00
|
|
|
}
|
|
|
|
|
2022-09-06 10:44:13 +02:00
|
|
|
/// Composite helper struct to pass failure parameters to the [VerificationReporter]
|
2023-01-03 20:06:10 +01:00
|
|
|
pub struct FailParams<'stamp, 'fargs> {
|
|
|
|
time_stamp: &'stamp [u8],
|
|
|
|
failure_code: &'fargs dyn EcssEnumeration,
|
|
|
|
failure_data: Option<&'fargs [u8]>,
|
2022-09-03 18:51:01 +02:00
|
|
|
}
|
|
|
|
|
2023-01-03 20:06:10 +01:00
|
|
|
impl<'stamp, 'fargs> FailParams<'stamp, 'fargs> {
|
2022-09-03 18:51:01 +02:00
|
|
|
pub fn new(
|
2023-01-03 20:06:10 +01:00
|
|
|
time_stamp: &'stamp [u8],
|
|
|
|
failure_code: &'fargs impl EcssEnumeration,
|
|
|
|
failure_data: Option<&'fargs [u8]>,
|
2022-09-03 18:51:01 +02:00
|
|
|
) -> Self {
|
|
|
|
Self {
|
2022-09-03 20:55:32 +02:00
|
|
|
time_stamp,
|
2022-09-03 18:51:01 +02:00
|
|
|
failure_code,
|
|
|
|
failure_data,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-06 10:44:13 +02:00
|
|
|
/// Composite helper struct to pass step failure parameters to the [VerificationReporter]
|
2023-01-03 20:06:10 +01:00
|
|
|
pub struct FailParamsWithStep<'stamp, 'fargs> {
|
|
|
|
bp: FailParams<'stamp, 'fargs>,
|
|
|
|
step: &'fargs dyn EcssEnumeration,
|
2022-09-03 18:51:01 +02:00
|
|
|
}
|
|
|
|
|
2023-01-03 20:06:10 +01:00
|
|
|
impl<'stamp, 'fargs> FailParamsWithStep<'stamp, 'fargs> {
|
2022-09-03 18:51:01 +02:00
|
|
|
pub fn new(
|
2023-01-03 20:06:10 +01:00
|
|
|
time_stamp: &'stamp [u8],
|
|
|
|
step: &'fargs impl EcssEnumeration,
|
|
|
|
failure_code: &'fargs impl EcssEnumeration,
|
|
|
|
failure_data: Option<&'fargs [u8]>,
|
2022-09-03 18:51:01 +02:00
|
|
|
) -> Self {
|
|
|
|
Self {
|
2022-09-04 22:24:36 +02:00
|
|
|
bp: FailParams::new(time_stamp, failure_code, failure_data),
|
2022-09-03 18:51:01 +02:00
|
|
|
step,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-21 10:16:15 +01:00
|
|
|
#[derive(Clone)]
|
2023-01-03 13:02:12 +01:00
|
|
|
pub struct VerificationReporterCore {
|
2022-09-05 00:20:32 +02:00
|
|
|
pub dest_id: u16,
|
2022-09-11 20:51:14 +02:00
|
|
|
apid: u16,
|
2022-09-05 00:20:32 +02:00
|
|
|
}
|
|
|
|
|
2023-01-04 00:22:52 +01:00
|
|
|
pub struct VerificationSendableErased<State> {
|
2023-01-03 20:06:10 +01:00
|
|
|
token: Option<VerificationToken<State>>,
|
2023-01-04 00:22:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn increment_seq_counter(
|
|
|
|
seq_counter: Option<&(impl SequenceCountProviderCore<u16> + ?Sized)>,
|
|
|
|
) {
|
|
|
|
if let Some(seq_counter) = seq_counter {
|
|
|
|
seq_counter.increment();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<State> VerificationSendableErased<State> {
|
|
|
|
pub fn send_success_verif_failure(
|
|
|
|
self,
|
|
|
|
seq_counter: Option<&(impl SequenceCountProviderCore<u16> + ?Sized)>,
|
|
|
|
) {
|
|
|
|
increment_seq_counter(seq_counter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl VerificationSendableErased<TcStateNone> {
|
|
|
|
pub fn send_success_acceptance_success(
|
|
|
|
self,
|
|
|
|
seq_counter: Option<&(impl SequenceCountProviderCore<u16> + ?Sized)>,
|
|
|
|
) -> VerificationToken<TcStateAccepted> {
|
|
|
|
increment_seq_counter(seq_counter);
|
|
|
|
VerificationToken {
|
|
|
|
state: PhantomData,
|
|
|
|
req_id: self.token.unwrap().req_id(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pub fn send_failure(self) -> VerificationToken<TcStateNone> {
|
|
|
|
self.token.unwrap()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl VerificationSendableErased<TcStateAccepted> {
|
|
|
|
pub fn send_success_start_success(
|
|
|
|
self,
|
|
|
|
seq_counter: Option<&(impl SequenceCountProviderCore<u16> + ?Sized)>,
|
|
|
|
) -> VerificationToken<TcStateStarted> {
|
|
|
|
increment_seq_counter(seq_counter);
|
|
|
|
VerificationToken {
|
|
|
|
state: PhantomData,
|
|
|
|
req_id: self.token.unwrap().req_id(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pub fn send_failure(self) -> VerificationToken<TcStateAccepted> {
|
|
|
|
self.token.unwrap()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl VerificationSendableErased<TcStateStarted> {
|
|
|
|
pub fn send_success_step_or_completion_success(
|
|
|
|
self,
|
|
|
|
seq_counter: Option<&(impl SequenceCountProviderCore<u16> + ?Sized)>,
|
|
|
|
) {
|
|
|
|
increment_seq_counter(seq_counter);
|
|
|
|
}
|
|
|
|
pub fn send_failure(self) -> Option<VerificationToken<TcStateStarted>> {
|
|
|
|
self.token
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct VerificationSendable<'slice, State> {
|
|
|
|
inner: VerificationSendableErased<State>,
|
2023-01-03 20:06:10 +01:00
|
|
|
pus_tm: Option<PusTm<'slice>>,
|
|
|
|
}
|
|
|
|
|
2023-01-04 00:22:52 +01:00
|
|
|
impl<State> From<VerificationSendable<'_, State>> for VerificationSendableErased<State> {
|
|
|
|
fn from(value: VerificationSendable<State>) -> Self {
|
|
|
|
value.inner
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-04 11:07:58 +01:00
|
|
|
impl<'src_data, State> VerificationSendable<'src_data, State> {
|
|
|
|
pub(crate) fn new(pus_tm: PusTm<'src_data>, token: VerificationToken<State>) -> Self {
|
2023-01-04 00:22:52 +01:00
|
|
|
Self {
|
|
|
|
inner: VerificationSendableErased { token: Some(token) },
|
|
|
|
pus_tm: Some(pus_tm),
|
|
|
|
}
|
|
|
|
}
|
2023-01-04 11:07:58 +01:00
|
|
|
pub(crate) fn new_no_token(pus_tm: PusTm<'src_data>) -> Self {
|
2023-01-04 00:22:52 +01:00
|
|
|
Self {
|
|
|
|
inner: VerificationSendableErased { token: None },
|
|
|
|
pus_tm: Some(pus_tm),
|
|
|
|
}
|
|
|
|
}
|
2023-01-04 00:28:34 +01:00
|
|
|
|
|
|
|
pub fn len_packed(&self) -> usize {
|
|
|
|
self.pus_tm.as_ref().unwrap().len_packed()
|
|
|
|
}
|
|
|
|
|
2023-01-04 11:07:58 +01:00
|
|
|
pub fn pus_tm(&self) -> &PusTm<'src_data> {
|
2023-01-03 20:06:10 +01:00
|
|
|
self.pus_tm.as_ref().unwrap()
|
|
|
|
}
|
|
|
|
|
2023-01-04 11:07:58 +01:00
|
|
|
pub fn pus_tm_mut(&mut self) -> &mut PusTm<'src_data> {
|
2023-01-03 20:06:10 +01:00
|
|
|
self.pus_tm.as_mut().unwrap()
|
|
|
|
}
|
|
|
|
|
2023-01-04 00:29:47 +01:00
|
|
|
/// Release the PUS TM struct. This also releases the mutable slice reference,
|
2023-01-04 00:28:34 +01:00
|
|
|
/// which can be useful or necessary before sending the data.
|
2023-01-04 11:07:58 +01:00
|
|
|
pub fn release_slice(mut self) -> (VerificationSendableErased<State>, PusTm<'src_data>) {
|
|
|
|
(self.inner, self.pus_tm.take().unwrap())
|
2023-01-04 00:22:52 +01:00
|
|
|
}
|
|
|
|
|
2023-01-04 11:07:58 +01:00
|
|
|
pub(crate) fn take_tm(&mut self) -> PusTm<'src_data> {
|
2023-01-03 20:06:10 +01:00
|
|
|
self.pus_tm.take().unwrap()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn send_success_verif_failure(
|
|
|
|
self,
|
|
|
|
seq_counter: Option<&(impl SequenceCountProviderCore<u16> + ?Sized)>,
|
|
|
|
) {
|
2023-01-04 00:22:52 +01:00
|
|
|
self.inner.send_success_verif_failure(seq_counter)
|
2023-01-03 20:06:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-04 11:07:58 +01:00
|
|
|
impl<'src_data> VerificationSendable<'src_data, TcStateNone> {
|
2023-01-03 20:06:10 +01:00
|
|
|
pub fn send_success_acceptance_success(
|
|
|
|
self,
|
|
|
|
seq_counter: Option<&(impl SequenceCountProviderCore<u16> + ?Sized)>,
|
|
|
|
) -> VerificationToken<TcStateAccepted> {
|
2023-01-04 00:22:52 +01:00
|
|
|
self.inner.send_success_acceptance_success(seq_counter)
|
2023-01-03 20:06:10 +01:00
|
|
|
}
|
2023-01-04 11:07:58 +01:00
|
|
|
pub fn send_failure(self) -> (PusTm<'src_data>, VerificationToken<TcStateNone>) {
|
2023-01-04 00:22:52 +01:00
|
|
|
(self.pus_tm.unwrap(), self.inner.token.unwrap())
|
2023-01-03 20:06:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-04 11:07:58 +01:00
|
|
|
impl<'src_data> VerificationSendable<'src_data, TcStateAccepted> {
|
2023-01-03 20:06:10 +01:00
|
|
|
pub fn send_success_start_success(
|
|
|
|
self,
|
|
|
|
seq_counter: Option<&(impl SequenceCountProviderCore<u16> + ?Sized)>,
|
|
|
|
) -> VerificationToken<TcStateStarted> {
|
2023-01-04 00:22:52 +01:00
|
|
|
self.inner.send_success_start_success(seq_counter)
|
2023-01-03 20:06:10 +01:00
|
|
|
}
|
2023-01-04 00:22:52 +01:00
|
|
|
|
2023-01-04 11:07:58 +01:00
|
|
|
pub fn send_failure(self) -> (PusTm<'src_data>, VerificationToken<TcStateAccepted>) {
|
2023-01-04 00:22:52 +01:00
|
|
|
(self.pus_tm.unwrap(), self.inner.token.unwrap())
|
2023-01-03 20:06:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-04 11:07:58 +01:00
|
|
|
impl<'src_data> VerificationSendable<'src_data, TcStateStarted> {
|
2023-01-03 20:06:10 +01:00
|
|
|
pub fn send_success_step_or_completion_success(
|
|
|
|
self,
|
|
|
|
seq_counter: Option<&(impl SequenceCountProviderCore<u16> + ?Sized)>,
|
|
|
|
) {
|
2023-01-04 00:22:52 +01:00
|
|
|
increment_seq_counter(seq_counter);
|
2023-01-03 20:06:10 +01:00
|
|
|
}
|
2023-01-04 11:07:58 +01:00
|
|
|
pub fn send_failure(self) -> (PusTm<'src_data>, Option<VerificationToken<TcStateStarted>>) {
|
2023-01-04 00:22:52 +01:00
|
|
|
(self.pus_tm.unwrap(), self.inner.token)
|
2023-01-03 20:06:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-03 13:02:12 +01:00
|
|
|
impl VerificationReporterCore {
|
2022-09-11 20:51:14 +02:00
|
|
|
pub fn new(apid: u16) -> Option<Self> {
|
|
|
|
if apid > MAX_APID {
|
|
|
|
return None;
|
|
|
|
}
|
2022-11-21 10:28:31 +01:00
|
|
|
Some(Self { apid, dest_id: 0 })
|
2022-09-11 20:51:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_apid(&mut self, apid: u16) -> bool {
|
|
|
|
if apid > MAX_APID {
|
|
|
|
return false;
|
2022-09-03 17:09:36 +02:00
|
|
|
}
|
2022-09-11 20:51:14 +02:00
|
|
|
self.apid = apid;
|
|
|
|
true
|
2022-09-03 17:09:36 +02:00
|
|
|
}
|
|
|
|
|
2022-09-11 20:51:14 +02:00
|
|
|
pub fn apid(&self) -> u16 {
|
|
|
|
self.apid
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn dest_id(&self) -> u16 {
|
|
|
|
self.dest_id
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_dest_id(&mut self, dest_id: u16) {
|
|
|
|
self.dest_id = dest_id;
|
2022-09-06 10:14:47 +02:00
|
|
|
}
|
|
|
|
|
2022-09-06 10:44:13 +02:00
|
|
|
/// Initialize verification handling by passing a TC reference. This returns a token required
|
|
|
|
/// to call the acceptance functions
|
2022-11-13 21:07:16 +01:00
|
|
|
pub fn add_tc(&mut self, pus_tc: &PusTc) -> VerificationToken<TcStateNone> {
|
2022-09-03 20:55:32 +02:00
|
|
|
self.add_tc_with_req_id(RequestId::new(pus_tc))
|
|
|
|
}
|
|
|
|
|
2022-09-06 10:44:13 +02:00
|
|
|
/// Same as [Self::add_tc] but pass a request ID instead of the direct telecommand.
|
|
|
|
/// This can be useful if the executing thread does not have full access to the telecommand.
|
2022-11-13 21:07:16 +01:00
|
|
|
pub fn add_tc_with_req_id(&mut self, req_id: RequestId) -> VerificationToken<TcStateNone> {
|
|
|
|
VerificationToken::<TcStateNone>::new(req_id)
|
2022-09-03 16:30:37 +02:00
|
|
|
}
|
|
|
|
|
2023-01-04 11:07:58 +01:00
|
|
|
fn sendable_success_no_step<'src_data, State: Copy>(
|
2022-09-03 16:30:37 +02:00
|
|
|
&mut self,
|
2023-01-04 11:07:58 +01:00
|
|
|
buf: &'src_data mut [u8],
|
2023-01-03 20:06:10 +01:00
|
|
|
subservice: u8,
|
|
|
|
token: VerificationToken<State>,
|
|
|
|
seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized),
|
2023-01-04 11:07:58 +01:00
|
|
|
time_stamp: &'src_data [u8],
|
|
|
|
) -> Result<VerificationSendable<'src_data, State>, VerificationErrorWithToken<State>> {
|
2023-01-04 00:22:52 +01:00
|
|
|
Ok(VerificationSendable::new(
|
|
|
|
self.create_pus_verif_success_tm(
|
|
|
|
buf,
|
|
|
|
subservice,
|
|
|
|
seq_counter.get(),
|
|
|
|
&token.req_id,
|
|
|
|
time_stamp,
|
|
|
|
None::<&dyn EcssEnumeration>,
|
|
|
|
)
|
|
|
|
.map_err(|e| VerificationErrorWithToken(e, token))?,
|
|
|
|
token,
|
|
|
|
))
|
2023-01-03 20:06:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Package a PUS TM\[1, 1\] packet, see 8.1.2.1 of the PUS standard.
|
2023-01-04 11:07:58 +01:00
|
|
|
pub fn acceptance_success<'src_data>(
|
2023-01-03 20:06:10 +01:00
|
|
|
&mut self,
|
2023-01-04 11:07:58 +01:00
|
|
|
buf: &'src_data mut [u8],
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateNone>,
|
2023-01-03 17:20:17 +01:00
|
|
|
seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized),
|
2023-01-04 11:07:58 +01:00
|
|
|
time_stamp: &'src_data [u8],
|
|
|
|
) -> Result<VerificationSendable<'src_data, TcStateNone>, VerificationErrorWithToken<TcStateNone>>
|
2022-11-13 21:07:16 +01:00
|
|
|
{
|
2023-01-03 20:06:10 +01:00
|
|
|
self.sendable_success_no_step(
|
|
|
|
buf,
|
|
|
|
Subservice::TmAcceptanceSuccess.into(),
|
|
|
|
token,
|
|
|
|
seq_counter,
|
|
|
|
time_stamp,
|
|
|
|
)
|
2022-09-03 16:30:37 +02:00
|
|
|
}
|
|
|
|
|
2023-01-03 20:06:10 +01:00
|
|
|
/// Package a PUS TM\[1, 2\] packet, see 8.1.2.2 of the PUS standard.
|
2023-01-04 11:07:58 +01:00
|
|
|
pub fn acceptance_failure<'src_data>(
|
2022-09-06 09:48:12 +02:00
|
|
|
&mut self,
|
2023-01-04 11:07:58 +01:00
|
|
|
buf: &'src_data mut [u8],
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateNone>,
|
2023-01-03 17:20:17 +01:00
|
|
|
seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized),
|
2023-01-04 11:07:58 +01:00
|
|
|
params: FailParams<'src_data, '_>,
|
|
|
|
) -> Result<VerificationSendable<'src_data, TcStateNone>, VerificationErrorWithToken<TcStateNone>>
|
2023-01-03 20:06:10 +01:00
|
|
|
{
|
2023-01-04 00:22:52 +01:00
|
|
|
Ok(VerificationSendable::new(
|
|
|
|
self.create_pus_verif_fail_tm(
|
|
|
|
buf,
|
|
|
|
Subservice::TmAcceptanceFailure.into(),
|
|
|
|
seq_counter.get(),
|
|
|
|
&token.req_id,
|
|
|
|
None::<&dyn EcssEnumeration>,
|
|
|
|
¶ms,
|
|
|
|
)
|
|
|
|
.map_err(|e| VerificationErrorWithToken(e, token))?,
|
|
|
|
token,
|
|
|
|
))
|
2022-09-03 16:30:37 +02:00
|
|
|
}
|
|
|
|
|
2022-09-06 10:44:13 +02:00
|
|
|
/// Package and send a PUS TM\[1, 3\] packet, see 8.1.2.3 of the PUS standard.
|
|
|
|
///
|
|
|
|
/// Requires a token previously acquired by calling [Self::acceptance_success].
|
2023-01-04 11:07:58 +01:00
|
|
|
pub fn start_success<'src_data>(
|
2022-09-03 16:30:37 +02:00
|
|
|
&mut self,
|
2023-01-04 11:07:58 +01:00
|
|
|
buf: &'src_data mut [u8],
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateAccepted>,
|
2023-01-03 17:20:17 +01:00
|
|
|
seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized),
|
2023-01-04 11:07:58 +01:00
|
|
|
time_stamp: &'src_data [u8],
|
2023-01-03 20:06:10 +01:00
|
|
|
) -> Result<
|
2023-01-04 11:07:58 +01:00
|
|
|
VerificationSendable<'src_data, TcStateAccepted>,
|
2023-01-03 20:44:28 +01:00
|
|
|
VerificationErrorWithToken<TcStateAccepted>,
|
2023-01-03 20:06:10 +01:00
|
|
|
> {
|
|
|
|
self.sendable_success_no_step(
|
|
|
|
buf,
|
|
|
|
Subservice::TmStartSuccess.into(),
|
|
|
|
token,
|
|
|
|
seq_counter,
|
|
|
|
time_stamp,
|
|
|
|
)
|
2022-09-03 16:30:37 +02:00
|
|
|
}
|
|
|
|
|
2022-09-06 10:44:13 +02:00
|
|
|
/// Package and send a PUS TM\[1, 4\] packet, see 8.1.2.4 of the PUS standard.
|
|
|
|
///
|
|
|
|
/// Requires a token previously acquired by calling [Self::acceptance_success]. It consumes
|
|
|
|
/// the token because verification handling is done.
|
2023-01-04 11:07:58 +01:00
|
|
|
pub fn start_failure<'src_data>(
|
2022-09-03 18:51:01 +02:00
|
|
|
&mut self,
|
2023-01-04 11:07:58 +01:00
|
|
|
buf: &'src_data mut [u8],
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateAccepted>,
|
2023-01-03 17:20:17 +01:00
|
|
|
seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized),
|
2023-01-04 11:07:58 +01:00
|
|
|
params: FailParams<'src_data, '_>,
|
2023-01-03 20:06:10 +01:00
|
|
|
) -> Result<
|
2023-01-04 11:07:58 +01:00
|
|
|
VerificationSendable<'src_data, TcStateAccepted>,
|
2023-01-03 20:44:28 +01:00
|
|
|
VerificationErrorWithToken<TcStateAccepted>,
|
2023-01-03 20:06:10 +01:00
|
|
|
> {
|
2023-01-04 00:22:52 +01:00
|
|
|
Ok(VerificationSendable::new(
|
|
|
|
self.create_pus_verif_fail_tm(
|
|
|
|
buf,
|
|
|
|
Subservice::TmStartFailure.into(),
|
|
|
|
seq_counter.get(),
|
|
|
|
&token.req_id,
|
|
|
|
None::<&dyn EcssEnumeration>,
|
|
|
|
¶ms,
|
|
|
|
)
|
|
|
|
.map_err(|e| VerificationErrorWithToken(e, token))?,
|
|
|
|
token,
|
|
|
|
))
|
2022-09-03 18:51:01 +02:00
|
|
|
}
|
|
|
|
|
2022-09-06 10:44:13 +02:00
|
|
|
/// 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].
|
2023-01-04 11:07:58 +01:00
|
|
|
pub fn step_success<'src_data>(
|
2022-09-03 18:51:01 +02:00
|
|
|
&mut self,
|
2023-01-04 11:07:58 +01:00
|
|
|
buf: &'src_data mut [u8],
|
2022-11-13 21:07:16 +01:00
|
|
|
token: &VerificationToken<TcStateStarted>,
|
2023-01-03 17:20:17 +01:00
|
|
|
seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized),
|
2023-01-04 11:07:58 +01:00
|
|
|
time_stamp: &'src_data [u8],
|
2022-09-03 18:51:01 +02:00
|
|
|
step: impl EcssEnumeration,
|
2023-01-04 11:07:58 +01:00
|
|
|
) -> Result<VerificationSendable<'src_data, TcStateStarted>, EcssTmError> {
|
2023-01-04 00:22:52 +01:00
|
|
|
Ok(VerificationSendable::new_no_token(
|
|
|
|
self.create_pus_verif_success_tm(
|
2023-01-03 20:06:10 +01:00
|
|
|
buf,
|
|
|
|
Subservice::TmStepSuccess.into(),
|
|
|
|
seq_counter.get(),
|
|
|
|
&token.req_id,
|
|
|
|
time_stamp,
|
|
|
|
Some(&step),
|
2023-01-04 00:22:52 +01:00
|
|
|
)?,
|
|
|
|
))
|
2022-09-03 16:30:37 +02:00
|
|
|
}
|
|
|
|
|
2022-09-06 10:44:13 +02:00
|
|
|
/// Package and send a PUS TM\[1, 6\] packet, see 8.1.2.6 of the PUS standard.
|
|
|
|
///
|
|
|
|
/// Requires a token previously acquired by calling [Self::start_success]. It consumes the
|
|
|
|
/// token because verification handling is done.
|
2023-01-04 11:07:58 +01:00
|
|
|
pub fn step_failure<'src_data>(
|
2022-09-03 18:51:01 +02:00
|
|
|
&mut self,
|
2023-01-04 11:07:58 +01:00
|
|
|
buf: &'src_data mut [u8],
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateStarted>,
|
2023-01-03 17:20:17 +01:00
|
|
|
seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized),
|
2023-01-04 11:07:58 +01:00
|
|
|
params: FailParamsWithStep<'src_data, '_>,
|
2023-01-03 20:06:10 +01:00
|
|
|
) -> Result<
|
2023-01-04 11:07:58 +01:00
|
|
|
VerificationSendable<'src_data, TcStateStarted>,
|
2023-01-03 20:44:28 +01:00
|
|
|
VerificationErrorWithToken<TcStateStarted>,
|
2023-01-03 20:06:10 +01:00
|
|
|
> {
|
2023-01-04 00:22:52 +01:00
|
|
|
Ok(VerificationSendable::new(
|
|
|
|
self.create_pus_verif_fail_tm(
|
|
|
|
buf,
|
|
|
|
Subservice::TmStepFailure.into(),
|
|
|
|
seq_counter.get(),
|
|
|
|
&token.req_id,
|
|
|
|
Some(params.step),
|
|
|
|
¶ms.bp,
|
|
|
|
)
|
|
|
|
.map_err(|e| VerificationErrorWithToken(e, token))?,
|
|
|
|
token,
|
|
|
|
))
|
2022-09-03 16:30:37 +02:00
|
|
|
}
|
|
|
|
|
2022-09-06 10:44:13 +02:00
|
|
|
/// Package and send a PUS TM\[1, 7\] packet, see 8.1.2.7 of the PUS standard.
|
|
|
|
///
|
|
|
|
/// Requires a token previously acquired by calling [Self::start_success]. It consumes the
|
|
|
|
/// token because verification handling is done.
|
2023-01-04 11:07:58 +01:00
|
|
|
pub fn completion_success<'src_data>(
|
2022-09-03 18:51:01 +02:00
|
|
|
&mut self,
|
2023-01-04 11:07:58 +01:00
|
|
|
buf: &'src_data mut [u8],
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateStarted>,
|
2023-01-03 17:20:17 +01:00
|
|
|
seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized),
|
2023-01-04 11:07:58 +01:00
|
|
|
time_stamp: &'src_data [u8],
|
2023-01-03 20:06:10 +01:00
|
|
|
) -> Result<
|
2023-01-04 11:07:58 +01:00
|
|
|
VerificationSendable<'src_data, TcStateStarted>,
|
2023-01-03 20:44:28 +01:00
|
|
|
VerificationErrorWithToken<TcStateStarted>,
|
2023-01-03 20:06:10 +01:00
|
|
|
> {
|
|
|
|
self.sendable_success_no_step(
|
|
|
|
buf,
|
|
|
|
Subservice::TmCompletionSuccess.into(),
|
|
|
|
token,
|
|
|
|
seq_counter,
|
|
|
|
time_stamp,
|
|
|
|
)
|
2022-09-03 16:30:37 +02:00
|
|
|
}
|
|
|
|
|
2022-09-06 10:44:13 +02:00
|
|
|
/// Package and send a PUS TM\[1, 8\] packet, see 8.1.2.8 of the PUS standard.
|
|
|
|
///
|
|
|
|
/// Requires a token previously acquired by calling [Self::start_success]. It consumes the
|
|
|
|
/// token because verification handling is done.
|
2023-01-04 11:07:58 +01:00
|
|
|
pub fn completion_failure<'src_data>(
|
2022-09-03 18:51:01 +02:00
|
|
|
&mut self,
|
2023-01-04 11:07:58 +01:00
|
|
|
buf: &'src_data mut [u8],
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateStarted>,
|
2023-01-03 17:20:17 +01:00
|
|
|
seq_counter: &(impl SequenceCountProviderCore<u16> + ?Sized),
|
2023-01-04 11:07:58 +01:00
|
|
|
params: FailParams<'src_data, '_>,
|
2023-01-03 20:06:10 +01:00
|
|
|
) -> Result<
|
2023-01-04 11:07:58 +01:00
|
|
|
VerificationSendable<'src_data, TcStateStarted>,
|
2023-01-03 20:44:28 +01:00
|
|
|
VerificationErrorWithToken<TcStateStarted>,
|
2023-01-03 20:06:10 +01:00
|
|
|
> {
|
2023-01-04 00:22:52 +01:00
|
|
|
Ok(VerificationSendable::new(
|
|
|
|
self.create_pus_verif_fail_tm(
|
|
|
|
buf,
|
|
|
|
Subservice::TmCompletionFailure.into(),
|
|
|
|
seq_counter.get(),
|
|
|
|
&token.req_id,
|
|
|
|
None::<&dyn EcssEnumeration>,
|
|
|
|
¶ms,
|
|
|
|
)
|
|
|
|
.map_err(|e| VerificationErrorWithToken(e, token))?,
|
|
|
|
token,
|
|
|
|
))
|
2023-01-03 20:06:10 +01:00
|
|
|
}
|
|
|
|
|
2023-01-04 11:07:58 +01:00
|
|
|
fn create_pus_verif_success_tm<'src_data>(
|
2023-01-03 20:06:10 +01:00
|
|
|
&mut self,
|
2023-01-04 11:07:58 +01:00
|
|
|
buf: &'src_data mut [u8],
|
2022-09-03 18:51:01 +02:00
|
|
|
subservice: u8,
|
2022-11-21 10:16:15 +01:00
|
|
|
msg_counter: u16,
|
2022-09-03 18:51:01 +02:00
|
|
|
req_id: &RequestId,
|
2023-01-04 11:07:58 +01:00
|
|
|
time_stamp: &'src_data [u8],
|
2022-09-03 18:51:01 +02:00
|
|
|
step: Option<&(impl EcssEnumeration + ?Sized)>,
|
2023-01-04 11:07:58 +01:00
|
|
|
) -> Result<PusTm<'src_data>, EcssTmError> {
|
2022-09-03 18:51:01 +02:00
|
|
|
let mut source_data_len = size_of::<u32>();
|
|
|
|
if let Some(step) = step {
|
2022-12-20 17:23:11 +01:00
|
|
|
source_data_len += step.byte_width();
|
2022-09-03 18:51:01 +02:00
|
|
|
}
|
2022-09-11 20:51:14 +02:00
|
|
|
source_buffer_large_enough(buf.len(), source_data_len)?;
|
2022-09-03 18:51:01 +02:00
|
|
|
let mut idx = 0;
|
2022-09-11 20:51:14 +02:00
|
|
|
req_id.to_bytes(&mut buf[0..RequestId::SIZE_AS_BYTES]);
|
2022-09-03 18:51:01 +02:00
|
|
|
idx += RequestId::SIZE_AS_BYTES;
|
|
|
|
if let Some(step) = step {
|
|
|
|
// Size check was done beforehand
|
2022-12-20 17:23:11 +01:00
|
|
|
step.write_to_be_bytes(&mut buf[idx..idx + step.byte_width()])
|
2022-09-03 18:51:01 +02:00
|
|
|
.unwrap();
|
|
|
|
}
|
2022-12-04 20:00:20 +01:00
|
|
|
let mut sp_header = SpHeader::tm_unseg(self.apid(), 0, 0).unwrap();
|
2022-09-03 20:55:32 +02:00
|
|
|
Ok(self.create_pus_verif_tm_base(
|
2022-09-11 20:51:14 +02:00
|
|
|
buf,
|
2022-09-03 20:55:32 +02:00
|
|
|
subservice,
|
2022-11-21 10:16:15 +01:00
|
|
|
msg_counter,
|
2022-09-03 20:55:32 +02:00
|
|
|
&mut sp_header,
|
|
|
|
time_stamp,
|
|
|
|
source_data_len,
|
|
|
|
))
|
2022-09-03 16:30:37 +02:00
|
|
|
}
|
|
|
|
|
2023-01-04 11:07:58 +01:00
|
|
|
fn create_pus_verif_fail_tm<'src_data>(
|
2023-01-03 20:06:10 +01:00
|
|
|
&mut self,
|
2023-01-04 11:07:58 +01:00
|
|
|
buf: &'src_data mut [u8],
|
2022-09-03 17:09:36 +02:00
|
|
|
subservice: u8,
|
2022-11-21 10:16:15 +01:00
|
|
|
msg_counter: u16,
|
2022-09-03 17:09:36 +02:00
|
|
|
req_id: &RequestId,
|
2022-09-03 18:51:01 +02:00
|
|
|
step: Option<&(impl EcssEnumeration + ?Sized)>,
|
2023-01-04 11:07:58 +01:00
|
|
|
params: &FailParams<'src_data, '_>,
|
|
|
|
) -> Result<PusTm<'src_data>, EcssTmError> {
|
2022-09-03 18:51:01 +02:00
|
|
|
let mut idx = 0;
|
2022-12-20 17:23:11 +01:00
|
|
|
let mut source_data_len = RequestId::SIZE_AS_BYTES + params.failure_code.byte_width();
|
2022-09-03 18:51:01 +02:00
|
|
|
if let Some(step) = step {
|
2022-12-20 17:23:11 +01:00
|
|
|
source_data_len += step.byte_width();
|
2022-09-03 18:51:01 +02:00
|
|
|
}
|
2022-09-05 00:20:32 +02:00
|
|
|
if let Some(failure_data) = params.failure_data {
|
|
|
|
source_data_len += failure_data.len();
|
|
|
|
}
|
2022-09-11 20:51:14 +02:00
|
|
|
source_buffer_large_enough(buf.len(), source_data_len)?;
|
|
|
|
req_id.to_bytes(&mut buf[0..RequestId::SIZE_AS_BYTES]);
|
2022-09-03 18:51:01 +02:00
|
|
|
idx += RequestId::SIZE_AS_BYTES;
|
|
|
|
if let Some(step) = step {
|
|
|
|
// Size check done beforehand
|
2022-12-20 17:23:11 +01:00
|
|
|
step.write_to_be_bytes(&mut buf[idx..idx + step.byte_width()])
|
2022-09-03 18:51:01 +02:00
|
|
|
.unwrap();
|
2022-12-20 17:23:11 +01:00
|
|
|
idx += step.byte_width();
|
2022-09-03 18:51:01 +02:00
|
|
|
}
|
2022-09-11 20:51:14 +02:00
|
|
|
params
|
|
|
|
.failure_code
|
2022-12-20 17:23:11 +01:00
|
|
|
.write_to_be_bytes(&mut buf[idx..idx + params.failure_code.byte_width()])?;
|
|
|
|
idx += params.failure_code.byte_width();
|
2022-09-05 00:20:32 +02:00
|
|
|
if let Some(failure_data) = params.failure_data {
|
2022-09-11 20:51:14 +02:00
|
|
|
buf[idx..idx + failure_data.len()].copy_from_slice(failure_data);
|
2022-09-05 00:20:32 +02:00
|
|
|
}
|
2022-12-04 20:00:20 +01:00
|
|
|
let mut sp_header = SpHeader::tm_unseg(self.apid(), 0, 0).unwrap();
|
2022-09-03 20:55:32 +02:00
|
|
|
Ok(self.create_pus_verif_tm_base(
|
2022-09-11 20:51:14 +02:00
|
|
|
buf,
|
2022-09-03 20:55:32 +02:00
|
|
|
subservice,
|
2022-11-21 10:16:15 +01:00
|
|
|
msg_counter,
|
2022-09-03 20:55:32 +02:00
|
|
|
&mut sp_header,
|
2022-09-04 22:24:36 +02:00
|
|
|
params.time_stamp,
|
2022-09-03 20:55:32 +02:00
|
|
|
source_data_len,
|
|
|
|
))
|
2022-09-03 18:51:01 +02:00
|
|
|
}
|
|
|
|
|
2023-01-04 11:07:58 +01:00
|
|
|
fn create_pus_verif_tm_base<'src_data>(
|
2023-01-03 20:06:10 +01:00
|
|
|
&mut self,
|
2023-01-04 11:07:58 +01:00
|
|
|
buf: &'src_data mut [u8],
|
2022-09-03 18:51:01 +02:00
|
|
|
subservice: u8,
|
2022-11-21 10:16:15 +01:00
|
|
|
msg_counter: u16,
|
2022-09-03 18:51:01 +02:00
|
|
|
sp_header: &mut SpHeader,
|
2023-01-04 11:07:58 +01:00
|
|
|
time_stamp: &'src_data [u8],
|
2022-09-03 18:51:01 +02:00
|
|
|
source_data_len: usize,
|
2023-01-04 11:07:58 +01:00
|
|
|
) -> PusTm<'src_data> {
|
2022-09-11 21:14:19 +02:00
|
|
|
let tm_sec_header =
|
2022-11-21 10:16:15 +01:00
|
|
|
PusTmSecondaryHeader::new(1, subservice, msg_counter, self.dest_id, time_stamp);
|
2022-09-03 18:51:01 +02:00
|
|
|
PusTm::new(
|
|
|
|
sp_header,
|
2022-09-03 17:09:36 +02:00
|
|
|
tm_sec_header,
|
2022-09-11 20:51:14 +02:00
|
|
|
Some(&buf[0..source_data_len]),
|
2022-09-03 17:09:36 +02:00
|
|
|
true,
|
2022-09-03 18:51:01 +02:00
|
|
|
)
|
2022-09-03 16:30:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-11 20:51:14 +02:00
|
|
|
#[cfg(feature = "alloc")]
|
2022-12-30 23:09:58 +01:00
|
|
|
mod alloc_mod {
|
2022-09-11 20:51:14 +02:00
|
|
|
use super::*;
|
2023-01-03 01:15:17 +01:00
|
|
|
use crate::pus::alloc_mod::EcssTmSender;
|
2023-01-03 13:09:14 +01:00
|
|
|
use crate::seq_count::SequenceCountProvider;
|
2022-09-11 20:51:14 +02:00
|
|
|
use alloc::boxed::Box;
|
|
|
|
use alloc::vec;
|
|
|
|
use alloc::vec::Vec;
|
2022-09-03 16:30:37 +02:00
|
|
|
|
2022-11-21 10:16:15 +01:00
|
|
|
#[derive(Clone)]
|
2022-09-11 20:51:14 +02:00
|
|
|
pub struct VerificationReporterCfg {
|
|
|
|
apid: u16,
|
2023-01-03 13:09:14 +01:00
|
|
|
seq_counter: Box<dyn SequenceCountProvider<u16> + Send>,
|
2022-09-11 20:51:14 +02:00
|
|
|
pub step_field_width: usize,
|
|
|
|
pub fail_code_field_width: usize,
|
|
|
|
pub max_fail_data_len: usize,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl VerificationReporterCfg {
|
|
|
|
pub fn new(
|
|
|
|
apid: u16,
|
2023-01-03 13:09:14 +01:00
|
|
|
seq_counter: Box<dyn SequenceCountProvider<u16> + Send>,
|
2022-09-11 20:51:14 +02:00
|
|
|
step_field_width: usize,
|
|
|
|
fail_code_field_width: usize,
|
|
|
|
max_fail_data_len: usize,
|
|
|
|
) -> Option<Self> {
|
|
|
|
if apid > MAX_APID {
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
Some(Self {
|
|
|
|
apid,
|
2022-11-21 10:16:15 +01:00
|
|
|
seq_counter,
|
2022-09-11 20:51:14 +02:00
|
|
|
step_field_width,
|
|
|
|
fail_code_field_width,
|
|
|
|
max_fail_data_len,
|
|
|
|
})
|
|
|
|
}
|
2022-09-06 00:17:52 +02:00
|
|
|
}
|
|
|
|
|
2022-09-11 20:51:14 +02:00
|
|
|
/// 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.
|
2022-11-21 10:28:31 +01:00
|
|
|
#[derive(Clone)]
|
2023-01-03 13:02:12 +01:00
|
|
|
pub struct VerificationReporter {
|
2022-09-11 20:51:14 +02:00
|
|
|
source_data_buf: Vec<u8>,
|
2023-01-03 13:09:14 +01:00
|
|
|
seq_counter: Box<dyn SequenceCountProvider<u16> + Send + 'static>,
|
2023-01-03 13:02:12 +01:00
|
|
|
pub reporter: VerificationReporterCore,
|
2022-09-05 00:20:32 +02:00
|
|
|
}
|
2022-09-03 16:30:37 +02:00
|
|
|
|
2023-01-03 13:02:12 +01:00
|
|
|
impl VerificationReporter {
|
2022-11-21 10:16:15 +01:00
|
|
|
pub fn new(cfg: &VerificationReporterCfg) -> Self {
|
2023-01-03 13:02:12 +01:00
|
|
|
let reporter = VerificationReporterCore::new(cfg.apid).unwrap();
|
2022-09-11 20:51:14 +02:00
|
|
|
Self {
|
|
|
|
source_data_buf: vec![
|
|
|
|
0;
|
|
|
|
RequestId::SIZE_AS_BYTES
|
2022-12-20 17:23:11 +01:00
|
|
|
+ cfg.step_field_width
|
|
|
|
+ cfg.fail_code_field_width
|
2022-09-11 20:51:14 +02:00
|
|
|
+ cfg.max_fail_data_len
|
|
|
|
],
|
2022-11-21 10:16:15 +01:00
|
|
|
seq_counter: cfg.seq_counter.clone(),
|
2022-09-11 20:51:14 +02:00
|
|
|
reporter,
|
|
|
|
}
|
2022-09-05 00:20:32 +02:00
|
|
|
}
|
|
|
|
|
2022-09-11 20:51:14 +02:00
|
|
|
delegate!(
|
|
|
|
to self.reporter {
|
|
|
|
pub fn set_apid(&mut self, apid: u16) -> bool;
|
|
|
|
pub fn apid(&self) -> u16;
|
2022-11-13 21:07:16 +01:00
|
|
|
pub fn add_tc(&mut self, pus_tc: &PusTc) -> VerificationToken<TcStateNone>;
|
|
|
|
pub fn add_tc_with_req_id(&mut self, req_id: RequestId) -> VerificationToken<TcStateNone>;
|
2022-09-11 20:51:14 +02:00
|
|
|
pub fn dest_id(&self) -> u16;
|
|
|
|
pub fn set_dest_id(&mut self, dest_id: u16);
|
|
|
|
}
|
|
|
|
);
|
2022-09-05 00:20:32 +02:00
|
|
|
|
2022-09-11 20:51:14 +02:00
|
|
|
pub fn allowed_source_data_len(&self) -> usize {
|
|
|
|
self.source_data_buf.capacity()
|
|
|
|
}
|
2022-09-05 00:20:32 +02:00
|
|
|
|
2022-09-11 20:51:14 +02:00
|
|
|
/// Package and send a PUS TM\[1, 1\] packet, see 8.1.2.1 of the PUS standard
|
|
|
|
pub fn acceptance_success<E>(
|
|
|
|
&mut self,
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateNone>,
|
2023-01-03 13:02:12 +01:00
|
|
|
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
2022-09-11 20:51:14 +02:00
|
|
|
time_stamp: &[u8],
|
2023-01-03 20:44:28 +01:00
|
|
|
) -> Result<
|
|
|
|
VerificationToken<TcStateAccepted>,
|
|
|
|
VerificationOrSendErrorWithToken<E, TcStateNone>,
|
|
|
|
> {
|
2023-01-03 20:06:10 +01:00
|
|
|
let mut sendable = self.reporter.acceptance_success(
|
2022-09-11 20:51:14 +02:00
|
|
|
self.source_data_buf.as_mut_slice(),
|
|
|
|
token,
|
2023-01-03 20:06:10 +01:00
|
|
|
self.seq_counter.as_ref(),
|
2022-09-11 20:51:14 +02:00
|
|
|
time_stamp,
|
2023-01-03 20:06:10 +01:00
|
|
|
)?;
|
|
|
|
sender
|
|
|
|
.send_tm(sendable.take_tm())
|
2023-01-03 20:44:28 +01:00
|
|
|
.map_err(|e| VerificationOrSendErrorWithToken(e, token))?;
|
2023-01-03 20:06:10 +01:00
|
|
|
let token = sendable.send_success_acceptance_success(Some(self.seq_counter.as_ref()));
|
|
|
|
Ok(token)
|
2022-09-11 20:51:14 +02:00
|
|
|
}
|
2022-09-05 00:20:32 +02:00
|
|
|
|
2022-09-11 20:51:14 +02:00
|
|
|
/// Package and send a PUS TM\[1, 2\] packet, see 8.1.2.2 of the PUS standard
|
|
|
|
pub fn acceptance_failure<E>(
|
|
|
|
&mut self,
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateNone>,
|
2023-01-03 13:02:12 +01:00
|
|
|
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
2022-09-11 20:51:14 +02:00
|
|
|
params: FailParams,
|
2023-01-03 20:44:28 +01:00
|
|
|
) -> Result<(), VerificationOrSendErrorWithToken<E, TcStateNone>> {
|
2023-01-03 20:06:10 +01:00
|
|
|
let mut sendable = self.reporter.acceptance_failure(
|
2022-09-11 20:51:14 +02:00
|
|
|
self.source_data_buf.as_mut_slice(),
|
|
|
|
token,
|
2023-01-03 20:06:10 +01:00
|
|
|
self.seq_counter.as_ref(),
|
2022-09-11 20:51:14 +02:00
|
|
|
params,
|
2023-01-03 20:06:10 +01:00
|
|
|
)?;
|
|
|
|
sender
|
|
|
|
.send_tm(sendable.take_tm())
|
2023-01-03 20:44:28 +01:00
|
|
|
.map_err(|e| VerificationOrSendErrorWithToken(e, token))?;
|
2023-01-03 20:06:10 +01:00
|
|
|
sendable.send_success_verif_failure(Some(self.seq_counter.as_ref()));
|
|
|
|
Ok(())
|
2022-09-11 20:51:14 +02:00
|
|
|
}
|
2022-09-05 00:20:32 +02:00
|
|
|
|
2022-09-11 20:51:14 +02:00
|
|
|
/// Package and send a PUS TM\[1, 3\] packet, see 8.1.2.3 of the PUS standard.
|
|
|
|
///
|
|
|
|
/// Requires a token previously acquired by calling [Self::acceptance_success].
|
|
|
|
pub fn start_success<E>(
|
|
|
|
&mut self,
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateAccepted>,
|
2023-01-03 13:02:12 +01:00
|
|
|
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
2022-09-11 20:51:14 +02:00
|
|
|
time_stamp: &[u8],
|
2023-01-03 20:44:28 +01:00
|
|
|
) -> Result<
|
|
|
|
VerificationToken<TcStateStarted>,
|
|
|
|
VerificationOrSendErrorWithToken<E, TcStateAccepted>,
|
|
|
|
> {
|
2023-01-03 20:06:10 +01:00
|
|
|
let mut sendable = self.reporter.start_success(
|
2022-09-11 20:51:14 +02:00
|
|
|
self.source_data_buf.as_mut_slice(),
|
|
|
|
token,
|
2022-11-21 10:16:15 +01:00
|
|
|
self.seq_counter.as_mut(),
|
2022-09-11 20:51:14 +02:00
|
|
|
time_stamp,
|
2023-01-03 20:06:10 +01:00
|
|
|
)?;
|
|
|
|
sender
|
|
|
|
.send_tm(sendable.take_tm())
|
2023-01-03 20:44:28 +01:00
|
|
|
.map_err(|e| VerificationOrSendErrorWithToken(e, token))?;
|
2023-01-03 20:06:10 +01:00
|
|
|
let token = sendable.send_success_start_success(Some(self.seq_counter.as_ref()));
|
|
|
|
Ok(token)
|
2022-09-11 20:51:14 +02:00
|
|
|
}
|
2022-09-05 00:20:32 +02:00
|
|
|
|
2022-09-11 20:51:14 +02:00
|
|
|
/// Package and send a PUS TM\[1, 4\] packet, see 8.1.2.4 of the PUS standard.
|
|
|
|
///
|
|
|
|
/// Requires a token previously acquired by calling [Self::acceptance_success]. It consumes
|
|
|
|
/// the token because verification handling is done.
|
|
|
|
pub fn start_failure<E>(
|
|
|
|
&mut self,
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateAccepted>,
|
2023-01-03 13:02:12 +01:00
|
|
|
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
2022-09-11 20:51:14 +02:00
|
|
|
params: FailParams,
|
2023-01-03 20:44:28 +01:00
|
|
|
) -> Result<(), VerificationOrSendErrorWithToken<E, TcStateAccepted>> {
|
2023-01-03 20:06:10 +01:00
|
|
|
let mut sendable = self.reporter.start_failure(
|
2022-11-21 10:28:31 +01:00
|
|
|
self.source_data_buf.as_mut_slice(),
|
|
|
|
token,
|
|
|
|
self.seq_counter.as_mut(),
|
|
|
|
params,
|
2023-01-03 20:06:10 +01:00
|
|
|
)?;
|
|
|
|
sender
|
|
|
|
.send_tm(sendable.take_tm())
|
2023-01-03 20:44:28 +01:00
|
|
|
.map_err(|e| VerificationOrSendErrorWithToken(e, token))?;
|
2023-01-03 20:06:10 +01:00
|
|
|
sendable.send_success_verif_failure(Some(self.seq_counter.as_ref()));
|
|
|
|
Ok(())
|
2022-09-11 20:51:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// 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].
|
|
|
|
pub fn step_success<E>(
|
|
|
|
&mut self,
|
2022-11-13 21:07:16 +01:00
|
|
|
token: &VerificationToken<TcStateStarted>,
|
2023-01-03 13:02:12 +01:00
|
|
|
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
2022-09-11 20:51:14 +02:00
|
|
|
time_stamp: &[u8],
|
|
|
|
step: impl EcssEnumeration,
|
2023-01-03 20:44:28 +01:00
|
|
|
) -> Result<(), EcssTmErrorWithSend<E>> {
|
2023-01-03 20:06:10 +01:00
|
|
|
let mut sendable = self.reporter.step_success(
|
2022-09-11 20:51:14 +02:00
|
|
|
self.source_data_buf.as_mut_slice(),
|
|
|
|
token,
|
2022-11-21 10:16:15 +01:00
|
|
|
self.seq_counter.as_mut(),
|
2022-09-11 20:51:14 +02:00
|
|
|
time_stamp,
|
|
|
|
step,
|
2023-01-03 20:06:10 +01:00
|
|
|
)?;
|
|
|
|
sender.send_tm(sendable.take_tm())?;
|
|
|
|
sendable.send_success_step_or_completion_success(Some(self.seq_counter.as_ref()));
|
|
|
|
Ok(())
|
2022-09-11 20:51:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Package and send a PUS TM\[1, 6\] packet, see 8.1.2.6 of the PUS standard.
|
|
|
|
///
|
|
|
|
/// Requires a token previously acquired by calling [Self::start_success]. It consumes the
|
|
|
|
/// token because verification handling is done.
|
|
|
|
pub fn step_failure<E>(
|
|
|
|
&mut self,
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateStarted>,
|
2023-01-03 13:02:12 +01:00
|
|
|
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
2022-09-11 20:51:14 +02:00
|
|
|
params: FailParamsWithStep,
|
2023-01-03 20:44:28 +01:00
|
|
|
) -> Result<(), VerificationOrSendErrorWithToken<E, TcStateStarted>> {
|
2023-01-03 20:06:10 +01:00
|
|
|
let mut sendable = self.reporter.step_failure(
|
2022-11-21 10:28:31 +01:00
|
|
|
self.source_data_buf.as_mut_slice(),
|
|
|
|
token,
|
|
|
|
self.seq_counter.as_mut(),
|
|
|
|
params,
|
2023-01-03 20:06:10 +01:00
|
|
|
)?;
|
|
|
|
sender
|
|
|
|
.send_tm(sendable.take_tm())
|
2023-01-03 20:44:28 +01:00
|
|
|
.map_err(|e| VerificationOrSendErrorWithToken(e, token))?;
|
2023-01-03 20:06:10 +01:00
|
|
|
sendable.send_success_step_or_completion_success(Some(self.seq_counter.as_ref()));
|
|
|
|
Ok(())
|
2022-09-11 20:51:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Package and send a PUS TM\[1, 7\] packet, see 8.1.2.7 of the PUS standard.
|
|
|
|
///
|
|
|
|
/// Requires a token previously acquired by calling [Self::start_success]. It consumes the
|
|
|
|
/// token because verification handling is done.
|
|
|
|
pub fn completion_success<E>(
|
|
|
|
&mut self,
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateStarted>,
|
2023-01-03 13:02:12 +01:00
|
|
|
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
2022-09-11 20:51:14 +02:00
|
|
|
time_stamp: &[u8],
|
2023-01-03 20:44:28 +01:00
|
|
|
) -> Result<(), VerificationOrSendErrorWithToken<E, TcStateStarted>> {
|
2023-01-03 20:06:10 +01:00
|
|
|
let mut sendable = self.reporter.completion_success(
|
2022-09-11 20:51:14 +02:00
|
|
|
self.source_data_buf.as_mut_slice(),
|
|
|
|
token,
|
2022-11-21 10:16:15 +01:00
|
|
|
self.seq_counter.as_mut(),
|
2022-09-11 20:51:14 +02:00
|
|
|
time_stamp,
|
2023-01-03 20:06:10 +01:00
|
|
|
)?;
|
|
|
|
sender
|
|
|
|
.send_tm(sendable.take_tm())
|
2023-01-03 20:44:28 +01:00
|
|
|
.map_err(|e| VerificationOrSendErrorWithToken(e, token))?;
|
2023-01-03 20:06:10 +01:00
|
|
|
sendable.send_success_step_or_completion_success(Some(self.seq_counter.as_ref()));
|
|
|
|
Ok(())
|
2022-09-11 20:51:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Package and send a PUS TM\[1, 8\] packet, see 8.1.2.8 of the PUS standard.
|
|
|
|
///
|
|
|
|
/// Requires a token previously acquired by calling [Self::start_success]. It consumes the
|
|
|
|
/// token because verification handling is done.
|
|
|
|
pub fn completion_failure<E>(
|
|
|
|
&mut self,
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateStarted>,
|
2023-01-03 13:02:12 +01:00
|
|
|
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
|
2022-09-11 20:51:14 +02:00
|
|
|
params: FailParams,
|
2023-01-03 20:44:28 +01:00
|
|
|
) -> Result<(), VerificationOrSendErrorWithToken<E, TcStateStarted>> {
|
2023-01-03 20:06:10 +01:00
|
|
|
let mut sendable = self.reporter.completion_failure(
|
2022-09-11 20:51:14 +02:00
|
|
|
self.source_data_buf.as_mut_slice(),
|
|
|
|
token,
|
2022-11-21 10:16:15 +01:00
|
|
|
self.seq_counter.as_mut(),
|
2022-09-11 20:51:14 +02:00
|
|
|
params,
|
2023-01-03 20:06:10 +01:00
|
|
|
)?;
|
|
|
|
sender
|
|
|
|
.send_tm(sendable.take_tm())
|
2023-01-03 20:44:28 +01:00
|
|
|
.map_err(|e| VerificationOrSendErrorWithToken(e, token))?;
|
2023-01-03 20:06:10 +01:00
|
|
|
sendable.send_success_step_or_completion_success(Some(self.seq_counter.as_ref()));
|
|
|
|
Ok(())
|
2022-09-11 20:51:14 +02:00
|
|
|
}
|
2022-09-05 00:20:32 +02:00
|
|
|
}
|
|
|
|
|
2022-09-11 20:51:14 +02:00
|
|
|
/// Helper object which caches the sender passed as a trait object. Provides the same
|
|
|
|
/// API as [VerificationReporter] but without the explicit sender arguments.
|
2022-11-21 10:28:31 +01:00
|
|
|
#[derive(Clone)]
|
2022-09-11 20:51:14 +02:00
|
|
|
pub struct VerificationReporterWithSender<E> {
|
2023-01-03 13:02:12 +01:00
|
|
|
pub reporter: VerificationReporter,
|
2023-01-03 01:15:17 +01:00
|
|
|
pub sender: Box<dyn EcssTmSender<Error = E>>,
|
2022-09-05 00:20:32 +02:00
|
|
|
}
|
|
|
|
|
2022-09-11 20:51:14 +02:00
|
|
|
impl<E: 'static> VerificationReporterWithSender<E> {
|
2022-11-21 10:28:31 +01:00
|
|
|
pub fn new(
|
|
|
|
cfg: &VerificationReporterCfg,
|
2023-01-03 01:15:17 +01:00
|
|
|
sender: Box<dyn EcssTmSender<Error = E>>,
|
2022-11-21 10:28:31 +01:00
|
|
|
) -> Self {
|
2023-01-03 13:02:12 +01:00
|
|
|
let reporter = VerificationReporter::new(cfg);
|
2022-09-11 20:51:14 +02:00
|
|
|
Self::new_from_reporter(reporter, sender)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn new_from_reporter(
|
2023-01-03 13:02:12 +01:00
|
|
|
reporter: VerificationReporter,
|
2023-01-03 01:15:17 +01:00
|
|
|
sender: Box<dyn EcssTmSender<Error = E>>,
|
2022-09-11 20:51:14 +02:00
|
|
|
) -> Self {
|
|
|
|
Self { reporter, sender }
|
|
|
|
}
|
|
|
|
|
|
|
|
delegate! {
|
|
|
|
to self.reporter {
|
|
|
|
pub fn set_apid(&mut self, apid: u16) -> bool;
|
|
|
|
pub fn apid(&self) -> u16;
|
2022-11-13 21:07:16 +01:00
|
|
|
pub fn add_tc(&mut self, pus_tc: &PusTc) -> VerificationToken<TcStateNone>;
|
|
|
|
pub fn add_tc_with_req_id(&mut self, req_id: RequestId) -> VerificationToken<TcStateNone>;
|
2022-09-11 20:51:14 +02:00
|
|
|
pub fn dest_id(&self) -> u16;
|
|
|
|
pub fn set_dest_id(&mut self, dest_id: u16);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn acceptance_success(
|
|
|
|
&mut self,
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateNone>,
|
2022-09-11 20:51:14 +02:00
|
|
|
time_stamp: &[u8],
|
2023-01-03 20:44:28 +01:00
|
|
|
) -> Result<
|
|
|
|
VerificationToken<TcStateAccepted>,
|
|
|
|
VerificationOrSendErrorWithToken<E, TcStateNone>,
|
|
|
|
> {
|
2022-09-11 20:51:14 +02:00
|
|
|
self.reporter
|
|
|
|
.acceptance_success(token, self.sender.as_mut(), time_stamp)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn acceptance_failure(
|
|
|
|
&mut self,
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateNone>,
|
2022-09-11 20:51:14 +02:00
|
|
|
params: FailParams,
|
2023-01-03 20:44:28 +01:00
|
|
|
) -> Result<(), VerificationOrSendErrorWithToken<E, TcStateNone>> {
|
2022-09-11 20:51:14 +02:00
|
|
|
self.reporter
|
|
|
|
.acceptance_failure(token, self.sender.as_mut(), params)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn start_success(
|
|
|
|
&mut self,
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateAccepted>,
|
2022-09-11 20:51:14 +02:00
|
|
|
time_stamp: &[u8],
|
2023-01-03 20:44:28 +01:00
|
|
|
) -> Result<
|
|
|
|
VerificationToken<TcStateStarted>,
|
|
|
|
VerificationOrSendErrorWithToken<E, TcStateAccepted>,
|
|
|
|
> {
|
2022-09-11 20:51:14 +02:00
|
|
|
self.reporter
|
|
|
|
.start_success(token, self.sender.as_mut(), time_stamp)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn start_failure(
|
|
|
|
&mut self,
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateAccepted>,
|
2022-09-11 20:51:14 +02:00
|
|
|
params: FailParams,
|
2023-01-03 20:44:28 +01:00
|
|
|
) -> Result<(), VerificationOrSendErrorWithToken<E, TcStateAccepted>> {
|
2022-09-11 20:51:14 +02:00
|
|
|
self.reporter
|
|
|
|
.start_failure(token, self.sender.as_mut(), params)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn step_success(
|
|
|
|
&mut self,
|
2022-11-13 21:07:16 +01:00
|
|
|
token: &VerificationToken<TcStateStarted>,
|
2022-09-11 20:51:14 +02:00
|
|
|
time_stamp: &[u8],
|
|
|
|
step: impl EcssEnumeration,
|
2023-01-03 20:44:28 +01:00
|
|
|
) -> Result<(), EcssTmErrorWithSend<E>> {
|
2022-09-11 20:51:14 +02:00
|
|
|
self.reporter
|
|
|
|
.step_success(token, self.sender.as_mut(), time_stamp, step)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn step_failure(
|
|
|
|
&mut self,
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateStarted>,
|
2022-09-11 20:51:14 +02:00
|
|
|
params: FailParamsWithStep,
|
2023-01-03 20:44:28 +01:00
|
|
|
) -> Result<(), VerificationOrSendErrorWithToken<E, TcStateStarted>> {
|
2022-09-11 20:51:14 +02:00
|
|
|
self.reporter
|
|
|
|
.step_failure(token, self.sender.as_mut(), params)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn completion_success(
|
|
|
|
&mut self,
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateStarted>,
|
2022-09-11 20:51:14 +02:00
|
|
|
time_stamp: &[u8],
|
2023-01-03 20:44:28 +01:00
|
|
|
) -> Result<(), VerificationOrSendErrorWithToken<E, TcStateStarted>> {
|
2022-09-11 20:51:14 +02:00
|
|
|
self.reporter
|
|
|
|
.completion_success(token, self.sender.as_mut(), time_stamp)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn completion_failure(
|
|
|
|
&mut self,
|
2022-11-13 21:07:16 +01:00
|
|
|
token: VerificationToken<TcStateStarted>,
|
2022-09-11 20:51:14 +02:00
|
|
|
params: FailParams,
|
2023-01-03 20:44:28 +01:00
|
|
|
) -> Result<(), VerificationOrSendErrorWithToken<E, TcStateStarted>> {
|
2022-09-11 20:51:14 +02:00
|
|
|
self.reporter
|
|
|
|
.completion_failure(token, self.sender.as_mut(), params)
|
|
|
|
}
|
2022-09-05 00:20:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(feature = "std")]
|
2022-09-07 11:02:45 +02:00
|
|
|
mod stdmod {
|
2022-12-30 23:09:58 +01:00
|
|
|
use super::alloc_mod::VerificationReporterWithSender;
|
2022-09-11 20:51:14 +02:00
|
|
|
use super::*;
|
2022-09-10 13:34:04 +02:00
|
|
|
use crate::pool::{ShareablePoolProvider, SharedPool, StoreAddr, StoreError};
|
2022-09-07 11:02:45 +02:00
|
|
|
use delegate::delegate;
|
|
|
|
use spacepackets::tm::PusTm;
|
2022-09-10 13:34:04 +02:00
|
|
|
use std::sync::{mpsc, Arc, Mutex, RwLockWriteGuard};
|
|
|
|
|
|
|
|
pub type StdVerifReporterWithSender = VerificationReporterWithSender<StdVerifSenderError>;
|
|
|
|
pub type SharedStdVerifReporterWithSender = Arc<Mutex<StdVerifReporterWithSender>>;
|
2022-09-05 00:20:32 +02:00
|
|
|
|
2022-11-21 10:28:31 +01:00
|
|
|
#[derive(Debug, Eq, PartialEq, Clone)]
|
2022-09-07 11:02:45 +02:00
|
|
|
pub enum StdVerifSenderError {
|
|
|
|
PoisonError,
|
|
|
|
StoreError(StoreError),
|
|
|
|
RxDisconnected(StoreAddr),
|
|
|
|
}
|
|
|
|
|
2022-09-10 19:57:58 +02:00
|
|
|
impl From<StoreError> for StdVerifSenderError {
|
|
|
|
fn from(e: StoreError) -> Self {
|
|
|
|
StdVerifSenderError::StoreError(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-03 20:44:28 +01:00
|
|
|
impl From<StoreError> for EcssTmErrorWithSend<StdVerifSenderError> {
|
2022-09-10 19:57:58 +02:00
|
|
|
fn from(e: StoreError) -> Self {
|
2023-01-03 20:44:28 +01:00
|
|
|
EcssTmErrorWithSend::SendError(e.into())
|
2022-09-10 19:57:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-07 11:02:45 +02:00
|
|
|
trait SendBackend: Send {
|
|
|
|
fn send(&self, addr: StoreAddr) -> Result<(), StoreAddr>;
|
|
|
|
}
|
|
|
|
|
2022-11-21 10:28:31 +01:00
|
|
|
#[derive(Clone)]
|
2022-09-07 11:02:45 +02:00
|
|
|
struct StdSenderBase<S> {
|
|
|
|
pub ignore_poison_error: bool,
|
2022-09-10 13:34:04 +02:00
|
|
|
tm_store: SharedPool,
|
2022-09-07 11:02:45 +02:00
|
|
|
tx: S,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<S: SendBackend> StdSenderBase<S> {
|
2022-09-10 13:34:04 +02:00
|
|
|
pub fn new(tm_store: SharedPool, tx: S) -> Self {
|
2022-09-07 11:02:45 +02:00
|
|
|
Self {
|
|
|
|
ignore_poison_error: false,
|
|
|
|
tm_store,
|
|
|
|
tx,
|
|
|
|
}
|
2022-09-05 00:20:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-10 13:34:04 +02:00
|
|
|
unsafe impl<S: Sync> Sync for StdSenderBase<S> {}
|
|
|
|
unsafe impl<S: Send> Send for StdSenderBase<S> {}
|
|
|
|
|
2022-09-07 11:02:45 +02:00
|
|
|
impl SendBackend for mpsc::Sender<StoreAddr> {
|
|
|
|
fn send(&self, addr: StoreAddr) -> Result<(), StoreAddr> {
|
|
|
|
self.send(addr).map_err(|_| addr)
|
|
|
|
}
|
|
|
|
}
|
2022-09-07 01:06:32 +02:00
|
|
|
|
2022-11-21 10:28:31 +01:00
|
|
|
#[derive(Clone)]
|
2022-09-10 13:34:04 +02:00
|
|
|
pub struct MpscVerifSender {
|
2022-09-07 11:02:45 +02:00
|
|
|
base: StdSenderBase<mpsc::Sender<StoreAddr>>,
|
|
|
|
}
|
2022-09-05 00:20:32 +02:00
|
|
|
|
2022-09-07 14:57:44 +02:00
|
|
|
/// Verification sender with a [mpsc::Sender] backend.
|
2023-01-03 13:02:12 +01:00
|
|
|
/// It implements the [EcssTmSenderCore] trait to be used as PUS Verification TM sender.
|
2022-09-10 13:34:04 +02:00
|
|
|
impl MpscVerifSender {
|
|
|
|
pub fn new(tm_store: SharedPool, tx: mpsc::Sender<StoreAddr>) -> Self {
|
2022-09-07 11:02:45 +02:00
|
|
|
Self {
|
|
|
|
base: StdSenderBase::new(tm_store, tx),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//noinspection RsTraitImplementation
|
2023-01-03 13:02:12 +01:00
|
|
|
impl EcssTmSenderCore for MpscVerifSender {
|
2022-10-31 01:25:02 +01:00
|
|
|
type Error = StdVerifSenderError;
|
|
|
|
|
2022-09-07 11:02:45 +02:00
|
|
|
delegate!(
|
|
|
|
to self.base {
|
2023-01-03 20:44:28 +01:00
|
|
|
fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmErrorWithSend<StdVerifSenderError>>;
|
2022-09-07 11:02:45 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2023-01-03 01:00:51 +01:00
|
|
|
|
2022-09-07 11:02:45 +02:00
|
|
|
impl SendBackend for crossbeam_channel::Sender<StoreAddr> {
|
|
|
|
fn send(&self, addr: StoreAddr) -> Result<(), StoreAddr> {
|
|
|
|
self.send(addr).map_err(|_| addr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-07 14:57:44 +02:00
|
|
|
/// Verification sender with a [crossbeam_channel::Sender] backend.
|
2023-01-03 13:02:12 +01:00
|
|
|
/// It implements the [EcssTmSenderCore] trait to be used as PUS Verification TM sender
|
2022-12-30 23:28:33 +01:00
|
|
|
#[cfg(feature = "crossbeam")]
|
2022-11-21 10:28:31 +01:00
|
|
|
#[derive(Clone)]
|
2022-09-07 11:02:45 +02:00
|
|
|
pub struct CrossbeamVerifSender {
|
|
|
|
base: StdSenderBase<crossbeam_channel::Sender<StoreAddr>>,
|
|
|
|
}
|
|
|
|
|
2022-12-30 23:28:33 +01:00
|
|
|
#[cfg(feature = "crossbeam")]
|
2022-09-07 11:02:45 +02:00
|
|
|
impl CrossbeamVerifSender {
|
2022-09-10 13:34:04 +02:00
|
|
|
pub fn new(tm_store: SharedPool, tx: crossbeam_channel::Sender<StoreAddr>) -> Self {
|
2022-09-07 11:02:45 +02:00
|
|
|
Self {
|
|
|
|
base: StdSenderBase::new(tm_store, tx),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//noinspection RsTraitImplementation
|
2022-12-30 23:28:33 +01:00
|
|
|
#[cfg(feature = "crossbeam")]
|
2023-01-03 13:02:12 +01:00
|
|
|
impl EcssTmSenderCore for CrossbeamVerifSender {
|
2022-10-31 01:25:02 +01:00
|
|
|
type Error = StdVerifSenderError;
|
|
|
|
|
2022-09-07 11:02:45 +02:00
|
|
|
delegate!(
|
|
|
|
to self.base {
|
2023-01-03 20:44:28 +01:00
|
|
|
fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmErrorWithSend<StdVerifSenderError>>;
|
2022-09-07 11:02:45 +02:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-01-03 13:02:12 +01:00
|
|
|
impl<S: SendBackend + Clone + 'static> EcssTmSenderCore for StdSenderBase<S> {
|
2022-10-31 01:25:02 +01:00
|
|
|
type Error = StdVerifSenderError;
|
2023-01-03 20:44:28 +01:00
|
|
|
fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmErrorWithSend<Self::Error>> {
|
2022-09-10 13:34:04 +02:00
|
|
|
let operation = |mut mg: RwLockWriteGuard<ShareablePoolProvider>| {
|
2022-09-10 19:57:58 +02:00
|
|
|
let (addr, buf) = mg.free_element(tm.len_packed())?;
|
2022-09-11 20:51:14 +02:00
|
|
|
tm.write_to_bytes(buf).map_err(EcssTmError::PusError)?;
|
2022-09-07 14:48:43 +02:00
|
|
|
drop(mg);
|
2022-09-07 11:02:45 +02:00
|
|
|
self.tx.send(addr).map_err(|_| {
|
2023-01-03 20:44:28 +01:00
|
|
|
EcssTmErrorWithSend::SendError(StdVerifSenderError::RxDisconnected(addr))
|
2022-09-07 11:02:45 +02:00
|
|
|
})?;
|
|
|
|
Ok(())
|
|
|
|
};
|
|
|
|
match self.tm_store.write() {
|
|
|
|
Ok(lock) => operation(lock),
|
|
|
|
Err(poison_error) => {
|
|
|
|
if self.ignore_poison_error {
|
|
|
|
operation(poison_error.into_inner())
|
|
|
|
} else {
|
2023-01-03 20:44:28 +01:00
|
|
|
Err(EcssTmErrorWithSend::SendError(
|
|
|
|
StdVerifSenderError::PoisonError,
|
|
|
|
))
|
2022-09-07 11:02:45 +02:00
|
|
|
}
|
2022-09-05 00:20:32 +02:00
|
|
|
}
|
|
|
|
}
|
2022-09-03 16:30:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
2023-01-03 01:00:51 +01:00
|
|
|
use crate::pool::{LocalPool, PoolCfg, SharedPool};
|
2022-10-15 21:14:27 +02:00
|
|
|
use crate::pus::tests::CommonTmInfo;
|
2022-09-03 20:55:32 +02:00
|
|
|
use crate::pus::verification::{
|
2023-01-03 13:02:12 +01:00
|
|
|
EcssTmError, EcssTmSenderCore, FailParams, FailParamsWithStep, MpscVerifSender, RequestId,
|
|
|
|
TcStateNone, VerificationReporter, VerificationReporterCfg, VerificationReporterWithSender,
|
|
|
|
VerificationToken,
|
2022-09-03 20:55:32 +02:00
|
|
|
};
|
2023-01-03 20:44:28 +01:00
|
|
|
use crate::pus::EcssTmErrorWithSend;
|
2023-01-03 16:35:23 +01:00
|
|
|
use crate::seq_count::SeqCountProviderSimple;
|
2022-09-06 00:17:52 +02:00
|
|
|
use alloc::boxed::Box;
|
2022-09-06 10:14:47 +02:00
|
|
|
use alloc::format;
|
2022-10-15 21:14:27 +02:00
|
|
|
use spacepackets::ecss::{EcssEnumU16, EcssEnumU32, EcssEnumU8, EcssEnumeration, PusPacket};
|
2022-09-03 20:55:32 +02:00
|
|
|
use spacepackets::tc::{PusTc, PusTcSecondaryHeader};
|
2022-10-15 19:56:53 +02:00
|
|
|
use spacepackets::tm::PusTm;
|
|
|
|
use spacepackets::{ByteConversionError, SpHeader};
|
2022-10-15 21:14:27 +02:00
|
|
|
use std::collections::VecDeque;
|
2023-01-03 01:00:51 +01:00
|
|
|
use std::sync::{mpsc, Arc, RwLock};
|
|
|
|
use std::vec;
|
2022-10-15 21:14:27 +02:00
|
|
|
use std::vec::Vec;
|
2022-09-03 20:55:32 +02:00
|
|
|
|
2023-01-03 01:00:51 +01:00
|
|
|
fn is_send<T: Send>(_: &T) {}
|
|
|
|
#[allow(dead_code)]
|
|
|
|
fn is_sync<T: Sync>(_: &T) {}
|
|
|
|
|
2022-09-03 20:55:32 +02:00
|
|
|
const TEST_APID: u16 = 0x02;
|
2022-09-06 00:17:52 +02:00
|
|
|
const EMPTY_STAMP: [u8; 7] = [0; 7];
|
2022-09-03 16:30:37 +02:00
|
|
|
|
2022-11-21 10:28:31 +01:00
|
|
|
#[derive(Debug, Eq, PartialEq, Clone)]
|
2022-10-15 21:14:27 +02:00
|
|
|
struct TmInfo {
|
|
|
|
pub common: CommonTmInfo,
|
|
|
|
pub req_id: RequestId,
|
|
|
|
pub additional_data: Option<Vec<u8>>,
|
|
|
|
}
|
|
|
|
|
2022-11-21 10:28:31 +01:00
|
|
|
#[derive(Default, Clone)]
|
2022-10-15 21:14:27 +02:00
|
|
|
struct TestSender {
|
|
|
|
pub service_queue: VecDeque<TmInfo>,
|
|
|
|
}
|
|
|
|
|
2023-01-03 13:02:12 +01:00
|
|
|
impl EcssTmSenderCore for TestSender {
|
2022-10-31 01:25:02 +01:00
|
|
|
type Error = ();
|
2023-01-03 20:44:28 +01:00
|
|
|
fn send_tm(&mut self, tm: PusTm) -> Result<(), EcssTmErrorWithSend<Self::Error>> {
|
2022-10-15 21:14:27 +02:00
|
|
|
assert_eq!(PusPacket::service(&tm), 1);
|
|
|
|
assert!(tm.source_data().is_some());
|
|
|
|
let mut time_stamp = [0; 7];
|
|
|
|
time_stamp.clone_from_slice(&tm.time_stamp()[0..7]);
|
|
|
|
let src_data = tm.source_data().unwrap();
|
|
|
|
assert!(src_data.len() >= 4);
|
|
|
|
let req_id = RequestId::from_bytes(&src_data[0..RequestId::SIZE_AS_BYTES]).unwrap();
|
|
|
|
let mut vec = None;
|
|
|
|
if src_data.len() > 4 {
|
|
|
|
let mut new_vec = Vec::new();
|
|
|
|
new_vec.extend_from_slice(&src_data[RequestId::SIZE_AS_BYTES..]);
|
|
|
|
vec = Some(new_vec);
|
|
|
|
}
|
|
|
|
self.service_queue.push_back(TmInfo {
|
|
|
|
common: CommonTmInfo::new_from_tm(&tm),
|
|
|
|
req_id,
|
|
|
|
additional_data: vec,
|
|
|
|
});
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-06 10:14:47 +02:00
|
|
|
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
|
|
|
struct DummyError {}
|
2022-11-21 10:28:31 +01:00
|
|
|
#[derive(Default, Clone)]
|
2022-09-06 10:14:47 +02:00
|
|
|
struct FallibleSender {}
|
|
|
|
|
2023-01-03 13:02:12 +01:00
|
|
|
impl EcssTmSenderCore for FallibleSender {
|
2022-11-01 18:03:01 +01:00
|
|
|
type Error = DummyError;
|
2023-01-03 20:44:28 +01:00
|
|
|
fn send_tm(&mut self, _: PusTm) -> Result<(), EcssTmErrorWithSend<DummyError>> {
|
|
|
|
Err(EcssTmErrorWithSend::SendError(DummyError {}))
|
2022-09-06 10:14:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-06 00:17:52 +02:00
|
|
|
struct TestBase<'a> {
|
2023-01-03 13:02:12 +01:00
|
|
|
vr: VerificationReporter,
|
2022-09-06 00:17:52 +02:00
|
|
|
#[allow(dead_code)]
|
|
|
|
tc: PusTc<'a>,
|
|
|
|
}
|
|
|
|
|
2022-09-06 09:48:12 +02:00
|
|
|
impl<'a> TestBase<'a> {
|
2023-01-03 13:02:12 +01:00
|
|
|
fn rep(&mut self) -> &mut VerificationReporter {
|
2022-09-06 09:48:12 +02:00
|
|
|
&mut self.vr
|
|
|
|
}
|
|
|
|
}
|
2022-09-06 00:17:52 +02:00
|
|
|
struct TestBaseWithHelper<'a, E> {
|
|
|
|
helper: VerificationReporterWithSender<E>,
|
|
|
|
#[allow(dead_code)]
|
|
|
|
tc: PusTc<'a>,
|
|
|
|
}
|
|
|
|
|
2022-09-06 09:48:12 +02:00
|
|
|
impl<'a, E> TestBaseWithHelper<'a, E> {
|
2023-01-03 13:02:12 +01:00
|
|
|
fn rep(&mut self) -> &mut VerificationReporter {
|
2022-09-06 09:48:12 +02:00
|
|
|
&mut self.helper.reporter
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-03 13:02:12 +01:00
|
|
|
fn base_reporter() -> VerificationReporter {
|
2022-11-21 10:28:31 +01:00
|
|
|
let cfg = VerificationReporterCfg::new(
|
|
|
|
TEST_APID,
|
2023-01-03 16:35:23 +01:00
|
|
|
Box::new(SeqCountProviderSimple::default()),
|
2022-11-21 10:28:31 +01:00
|
|
|
1,
|
|
|
|
2,
|
|
|
|
8,
|
|
|
|
)
|
|
|
|
.unwrap();
|
2023-01-03 13:02:12 +01:00
|
|
|
VerificationReporter::new(&cfg)
|
2022-09-06 00:17:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fn base_tc_init(app_data: Option<&[u8]>) -> (PusTc, RequestId) {
|
2022-12-04 20:00:20 +01:00
|
|
|
let mut sph = SpHeader::tc_unseg(TEST_APID, 0x34, 0).unwrap();
|
2022-09-06 00:17:52 +02:00
|
|
|
let tc_header = PusTcSecondaryHeader::new_simple(17, 1);
|
|
|
|
let pus_tc = PusTc::new(&mut sph, tc_header, app_data, true);
|
|
|
|
let req_id = RequestId::new(&pus_tc);
|
|
|
|
(pus_tc, req_id)
|
|
|
|
}
|
|
|
|
|
2022-11-13 21:07:16 +01:00
|
|
|
fn base_init(api_sel: bool) -> (TestBase<'static>, VerificationToken<TcStateNone>) {
|
2022-09-06 09:48:12 +02:00
|
|
|
let mut reporter = base_reporter();
|
2022-09-06 00:17:52 +02:00
|
|
|
let (tc, req_id) = base_tc_init(None);
|
2022-09-06 09:48:12 +02:00
|
|
|
let init_tok;
|
|
|
|
if api_sel {
|
|
|
|
init_tok = reporter.add_tc_with_req_id(req_id);
|
|
|
|
} else {
|
|
|
|
init_tok = reporter.add_tc(&tc);
|
|
|
|
}
|
|
|
|
(TestBase { vr: reporter, tc }, init_tok)
|
2022-09-06 00:17:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fn base_with_helper_init() -> (
|
|
|
|
TestBaseWithHelper<'static, ()>,
|
2022-11-13 21:07:16 +01:00
|
|
|
VerificationToken<TcStateNone>,
|
2022-09-06 00:17:52 +02:00
|
|
|
) {
|
2022-09-06 09:48:12 +02:00
|
|
|
let mut reporter = base_reporter();
|
|
|
|
let (tc, _) = base_tc_init(None);
|
2022-09-06 00:17:52 +02:00
|
|
|
let init_tok = reporter.add_tc(&tc);
|
|
|
|
let sender = TestSender::default();
|
|
|
|
let helper = VerificationReporterWithSender::new_from_reporter(reporter, Box::new(sender));
|
2022-09-06 09:48:12 +02:00
|
|
|
(TestBaseWithHelper { helper, tc }, init_tok)
|
2022-09-06 00:17:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fn acceptance_check(sender: &mut TestSender, req_id: &RequestId) {
|
|
|
|
let cmp_info = TmInfo {
|
2022-10-15 21:14:27 +02:00
|
|
|
common: CommonTmInfo {
|
|
|
|
subservice: 1,
|
|
|
|
apid: TEST_APID,
|
|
|
|
msg_counter: 0,
|
|
|
|
dest_id: 0,
|
|
|
|
time_stamp: EMPTY_STAMP,
|
|
|
|
},
|
2022-09-06 00:17:52 +02:00
|
|
|
additional_data: None,
|
|
|
|
req_id: req_id.clone(),
|
|
|
|
};
|
|
|
|
assert_eq!(sender.service_queue.len(), 1);
|
|
|
|
let info = sender.service_queue.pop_front().unwrap();
|
|
|
|
assert_eq!(info, cmp_info);
|
|
|
|
}
|
|
|
|
|
2023-01-03 01:00:51 +01:00
|
|
|
#[test]
|
|
|
|
fn test_mpsc_verif_send_sync() {
|
|
|
|
let pool = LocalPool::new(PoolCfg::new(vec![(8, 8)]));
|
|
|
|
let shared_pool: SharedPool = Arc::new(RwLock::new(Box::new(pool)));
|
|
|
|
let (tx, _) = mpsc::channel();
|
|
|
|
let mpsc_verif_sender = MpscVerifSender::new(shared_pool, tx);
|
|
|
|
is_send(&mpsc_verif_sender);
|
|
|
|
}
|
|
|
|
|
2022-09-11 20:51:14 +02:00
|
|
|
#[test]
|
|
|
|
fn test_state() {
|
|
|
|
let (mut b, _) = base_init(false);
|
|
|
|
assert_eq!(b.vr.apid(), TEST_APID);
|
|
|
|
b.vr.set_apid(TEST_APID + 1);
|
|
|
|
assert_eq!(b.vr.apid(), TEST_APID + 1);
|
|
|
|
}
|
|
|
|
|
2022-09-03 16:30:37 +02:00
|
|
|
#[test]
|
2022-09-06 00:17:52 +02:00
|
|
|
fn test_basic_acceptance_success() {
|
2022-09-06 09:48:12 +02:00
|
|
|
let (mut b, tok) = base_init(false);
|
2022-09-03 20:55:32 +02:00
|
|
|
let mut sender = TestSender::default();
|
2022-09-06 00:17:52 +02:00
|
|
|
b.vr.acceptance_success(tok, &mut sender, &EMPTY_STAMP)
|
2022-09-03 20:55:32 +02:00
|
|
|
.expect("Sending acceptance success failed");
|
2022-09-06 09:48:12 +02:00
|
|
|
acceptance_check(&mut sender, &tok.req_id);
|
2022-09-06 00:17:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_basic_acceptance_success_with_helper() {
|
|
|
|
let (mut b, tok) = base_with_helper_init();
|
|
|
|
b.helper
|
|
|
|
.acceptance_success(tok, &EMPTY_STAMP)
|
|
|
|
.expect("Sending acceptance success failed");
|
|
|
|
let sender: &mut TestSender = b.helper.sender.downcast_mut().unwrap();
|
2022-09-06 09:48:12 +02:00
|
|
|
acceptance_check(sender, &tok.req_id);
|
2022-09-03 16:30:37 +02:00
|
|
|
}
|
2022-09-05 00:20:32 +02:00
|
|
|
|
2022-09-06 10:14:47 +02:00
|
|
|
#[test]
|
|
|
|
fn test_acceptance_send_fails() {
|
|
|
|
let (mut b, tok) = base_init(false);
|
|
|
|
let mut faulty_sender = FallibleSender::default();
|
|
|
|
let res =
|
|
|
|
b.vr.acceptance_success(tok, &mut faulty_sender, &EMPTY_STAMP);
|
|
|
|
assert!(res.is_err());
|
|
|
|
let err = res.unwrap_err();
|
|
|
|
assert_eq!(err.1, tok);
|
|
|
|
match err.0 {
|
2023-01-03 20:44:28 +01:00
|
|
|
EcssTmErrorWithSend::SendError(e) => {
|
2022-09-06 10:14:47 +02:00
|
|
|
assert_eq!(e, DummyError {})
|
|
|
|
}
|
|
|
|
_ => panic!("{}", format!("Unexpected error {:?}", err.0)),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-06 09:48:12 +02:00
|
|
|
fn acceptance_fail_check(sender: &mut TestSender, req_id: RequestId, stamp_buf: [u8; 7]) {
|
2022-09-06 00:17:52 +02:00
|
|
|
let cmp_info = TmInfo {
|
2022-10-15 21:14:27 +02:00
|
|
|
common: CommonTmInfo {
|
|
|
|
subservice: 2,
|
|
|
|
apid: TEST_APID,
|
|
|
|
msg_counter: 0,
|
|
|
|
dest_id: 5,
|
|
|
|
time_stamp: stamp_buf,
|
|
|
|
},
|
2022-09-06 00:17:52 +02:00
|
|
|
additional_data: Some([0, 2].to_vec()),
|
|
|
|
req_id,
|
|
|
|
};
|
2022-09-05 00:20:32 +02:00
|
|
|
assert_eq!(sender.service_queue.len(), 1);
|
|
|
|
let info = sender.service_queue.pop_front().unwrap();
|
2022-09-06 00:17:52 +02:00
|
|
|
assert_eq!(info, cmp_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2022-09-06 09:48:12 +02:00
|
|
|
fn test_basic_acceptance_failure() {
|
|
|
|
let (mut b, tok) = base_init(true);
|
2022-09-11 20:51:14 +02:00
|
|
|
b.rep().reporter.dest_id = 5;
|
2022-09-06 09:48:12 +02:00
|
|
|
let stamp_buf = [1, 2, 3, 4, 5, 6, 7];
|
|
|
|
let mut sender = TestSender::default();
|
|
|
|
let fail_code = EcssEnumU16::new(2);
|
|
|
|
let fail_params = FailParams::new(stamp_buf.as_slice(), &fail_code, None);
|
|
|
|
b.vr.acceptance_failure(tok, &mut sender, fail_params)
|
|
|
|
.expect("Sending acceptance success failed");
|
|
|
|
acceptance_fail_check(&mut sender, tok.req_id, stamp_buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_basic_acceptance_failure_with_helper() {
|
|
|
|
let (mut b, tok) = base_with_helper_init();
|
2022-09-11 20:51:14 +02:00
|
|
|
b.rep().reporter.dest_id = 5;
|
2022-09-06 09:48:12 +02:00
|
|
|
let stamp_buf = [1, 2, 3, 4, 5, 6, 7];
|
|
|
|
let fail_code = EcssEnumU16::new(2);
|
|
|
|
let fail_params = FailParams::new(stamp_buf.as_slice(), &fail_code, None);
|
|
|
|
b.helper
|
|
|
|
.acceptance_failure(tok, fail_params)
|
|
|
|
.expect("Sending acceptance success failed");
|
|
|
|
let sender: &mut TestSender = b.helper.sender.downcast_mut().unwrap();
|
|
|
|
acceptance_fail_check(sender, tok.req_id, stamp_buf);
|
|
|
|
}
|
|
|
|
|
2022-09-06 10:14:47 +02:00
|
|
|
#[test]
|
|
|
|
fn test_acceptance_fail_data_too_large() {
|
|
|
|
let (mut b, tok) = base_with_helper_init();
|
2022-09-11 20:51:14 +02:00
|
|
|
b.rep().reporter.dest_id = 5;
|
2022-09-06 10:14:47 +02:00
|
|
|
let stamp_buf = [1, 2, 3, 4, 5, 6, 7];
|
|
|
|
let fail_code = EcssEnumU16::new(2);
|
|
|
|
let fail_data: [u8; 16] = [0; 16];
|
|
|
|
// 4 req ID + 1 byte step + 2 byte error code + 8 byte fail data
|
|
|
|
assert_eq!(b.rep().allowed_source_data_len(), 15);
|
|
|
|
let fail_params =
|
|
|
|
FailParams::new(stamp_buf.as_slice(), &fail_code, Some(fail_data.as_slice()));
|
|
|
|
let res = b.helper.acceptance_failure(tok, fail_params);
|
|
|
|
assert!(res.is_err());
|
|
|
|
let err_with_token = res.unwrap_err();
|
|
|
|
assert_eq!(err_with_token.1, tok);
|
|
|
|
match err_with_token.0 {
|
2023-01-03 20:44:28 +01:00
|
|
|
EcssTmErrorWithSend::EcssTmError(EcssTmError::ByteConversionError(e)) => match e {
|
2022-09-06 10:14:47 +02:00
|
|
|
ByteConversionError::ToSliceTooSmall(missmatch) => {
|
|
|
|
assert_eq!(
|
|
|
|
missmatch.expected,
|
|
|
|
fail_data.len() + RequestId::SIZE_AS_BYTES + fail_code.byte_width()
|
|
|
|
);
|
|
|
|
assert_eq!(missmatch.found, b.rep().allowed_source_data_len());
|
|
|
|
}
|
|
|
|
_ => {
|
|
|
|
panic!("{}", format!("Unexpected error {:?}", e))
|
|
|
|
}
|
|
|
|
},
|
|
|
|
_ => {
|
|
|
|
panic!("{}", format!("Unexpected error {:?}", err_with_token.0))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-06 09:48:12 +02:00
|
|
|
#[test]
|
|
|
|
fn test_basic_acceptance_failure_with_fail_data() {
|
|
|
|
let (mut b, tok) = base_init(false);
|
2022-09-06 00:17:52 +02:00
|
|
|
let mut sender = TestSender::default();
|
|
|
|
let fail_code = EcssEnumU8::new(10);
|
|
|
|
let fail_data = EcssEnumU32::new(12);
|
|
|
|
let mut fail_data_raw = [0; 4];
|
2022-11-02 00:36:49 +01:00
|
|
|
fail_data.write_to_be_bytes(&mut fail_data_raw).unwrap();
|
2022-09-06 00:17:52 +02:00
|
|
|
let fail_params = FailParams::new(&EMPTY_STAMP, &fail_code, Some(fail_data_raw.as_slice()));
|
2022-09-06 09:48:12 +02:00
|
|
|
b.vr.acceptance_failure(tok, &mut sender, fail_params)
|
2022-09-06 00:17:52 +02:00
|
|
|
.expect("Sending acceptance success failed");
|
|
|
|
let cmp_info = TmInfo {
|
2022-10-15 21:14:27 +02:00
|
|
|
common: CommonTmInfo {
|
|
|
|
subservice: 2,
|
|
|
|
apid: TEST_APID,
|
|
|
|
msg_counter: 0,
|
|
|
|
dest_id: 0,
|
|
|
|
time_stamp: EMPTY_STAMP,
|
|
|
|
},
|
2022-09-06 00:17:52 +02:00
|
|
|
additional_data: Some([10, 0, 0, 0, 12].to_vec()),
|
2022-09-06 09:48:12 +02:00
|
|
|
req_id: tok.req_id,
|
2022-09-06 00:17:52 +02:00
|
|
|
};
|
|
|
|
assert_eq!(sender.service_queue.len(), 1);
|
|
|
|
let info = sender.service_queue.pop_front().unwrap();
|
|
|
|
assert_eq!(info, cmp_info);
|
|
|
|
}
|
|
|
|
|
2022-09-06 09:48:12 +02:00
|
|
|
fn start_fail_check(sender: &mut TestSender, req_id: RequestId, fail_data_raw: [u8; 4]) {
|
2022-09-06 00:17:52 +02:00
|
|
|
assert_eq!(sender.service_queue.len(), 2);
|
|
|
|
let mut cmp_info = TmInfo {
|
2022-10-15 21:14:27 +02:00
|
|
|
common: CommonTmInfo {
|
|
|
|
subservice: 1,
|
|
|
|
apid: TEST_APID,
|
|
|
|
msg_counter: 0,
|
|
|
|
dest_id: 0,
|
|
|
|
time_stamp: EMPTY_STAMP,
|
|
|
|
},
|
2022-09-06 00:17:52 +02:00
|
|
|
additional_data: None,
|
|
|
|
req_id,
|
|
|
|
};
|
|
|
|
let mut info = sender.service_queue.pop_front().unwrap();
|
|
|
|
assert_eq!(info, cmp_info);
|
|
|
|
|
|
|
|
cmp_info = TmInfo {
|
2022-10-15 21:14:27 +02:00
|
|
|
common: CommonTmInfo {
|
|
|
|
subservice: 4,
|
|
|
|
apid: TEST_APID,
|
|
|
|
msg_counter: 1,
|
|
|
|
dest_id: 0,
|
|
|
|
time_stamp: EMPTY_STAMP,
|
|
|
|
},
|
2022-09-06 00:17:52 +02:00
|
|
|
additional_data: Some([&[22], fail_data_raw.as_slice()].concat().to_vec()),
|
|
|
|
req_id,
|
|
|
|
};
|
|
|
|
info = sender.service_queue.pop_front().unwrap();
|
|
|
|
assert_eq!(info, cmp_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2022-09-06 09:48:12 +02:00
|
|
|
fn test_start_failure() {
|
|
|
|
let (mut b, tok) = base_init(false);
|
2022-09-06 00:17:52 +02:00
|
|
|
let mut sender = TestSender::default();
|
2022-09-06 09:48:12 +02:00
|
|
|
let fail_code = EcssEnumU8::new(22);
|
|
|
|
let fail_data: i32 = -12;
|
|
|
|
let mut fail_data_raw = [0; 4];
|
|
|
|
fail_data_raw.copy_from_slice(fail_data.to_be_bytes().as_slice());
|
|
|
|
let fail_params = FailParams::new(&EMPTY_STAMP, &fail_code, Some(fail_data_raw.as_slice()));
|
|
|
|
|
|
|
|
let accepted_token =
|
|
|
|
b.vr.acceptance_success(tok, &mut sender, &EMPTY_STAMP)
|
|
|
|
.expect("Sending acceptance success failed");
|
|
|
|
let empty =
|
|
|
|
b.vr.start_failure(accepted_token, &mut sender, fail_params)
|
|
|
|
.expect("Start failure failure");
|
2022-09-06 00:17:52 +02:00
|
|
|
assert_eq!(empty, ());
|
2022-09-06 09:48:12 +02:00
|
|
|
start_fail_check(&mut sender, tok.req_id, fail_data_raw);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_start_failure_with_helper() {
|
|
|
|
let (mut b, tok) = base_with_helper_init();
|
|
|
|
let fail_code = EcssEnumU8::new(22);
|
|
|
|
let fail_data: i32 = -12;
|
|
|
|
let mut fail_data_raw = [0; 4];
|
|
|
|
fail_data_raw.copy_from_slice(fail_data.to_be_bytes().as_slice());
|
|
|
|
let fail_params = FailParams::new(&EMPTY_STAMP, &fail_code, Some(fail_data_raw.as_slice()));
|
|
|
|
|
|
|
|
let accepted_token = b
|
|
|
|
.helper
|
|
|
|
.acceptance_success(tok, &EMPTY_STAMP)
|
|
|
|
.expect("Sending acceptance success failed");
|
|
|
|
let empty = b
|
|
|
|
.helper
|
|
|
|
.start_failure(accepted_token, fail_params)
|
|
|
|
.expect("Start failure failure");
|
2022-09-06 00:17:52 +02:00
|
|
|
assert_eq!(empty, ());
|
2022-09-06 09:48:12 +02:00
|
|
|
let sender: &mut TestSender = b.helper.sender.downcast_mut().unwrap();
|
|
|
|
start_fail_check(sender, tok.req_id, fail_data_raw);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn step_success_check(sender: &mut TestSender, req_id: RequestId) {
|
2022-09-06 00:17:52 +02:00
|
|
|
let mut cmp_info = TmInfo {
|
2022-10-15 21:14:27 +02:00
|
|
|
common: CommonTmInfo {
|
|
|
|
subservice: 1,
|
|
|
|
apid: TEST_APID,
|
|
|
|
msg_counter: 0,
|
|
|
|
dest_id: 0,
|
|
|
|
time_stamp: EMPTY_STAMP,
|
|
|
|
},
|
2022-09-06 00:17:52 +02:00
|
|
|
additional_data: None,
|
|
|
|
req_id,
|
|
|
|
};
|
|
|
|
let mut info = sender.service_queue.pop_front().unwrap();
|
|
|
|
assert_eq!(info, cmp_info);
|
|
|
|
cmp_info = TmInfo {
|
2022-10-15 21:14:27 +02:00
|
|
|
common: CommonTmInfo {
|
|
|
|
subservice: 3,
|
|
|
|
apid: TEST_APID,
|
|
|
|
msg_counter: 1,
|
|
|
|
dest_id: 0,
|
|
|
|
time_stamp: [0, 1, 0, 1, 0, 1, 0],
|
|
|
|
},
|
2022-09-06 00:17:52 +02:00
|
|
|
additional_data: None,
|
|
|
|
req_id,
|
|
|
|
};
|
|
|
|
info = sender.service_queue.pop_front().unwrap();
|
|
|
|
assert_eq!(info, cmp_info);
|
|
|
|
cmp_info = TmInfo {
|
2022-10-15 21:14:27 +02:00
|
|
|
common: CommonTmInfo {
|
|
|
|
subservice: 5,
|
|
|
|
apid: TEST_APID,
|
|
|
|
msg_counter: 2,
|
|
|
|
dest_id: 0,
|
|
|
|
time_stamp: EMPTY_STAMP,
|
|
|
|
},
|
2022-09-06 00:17:52 +02:00
|
|
|
additional_data: Some([0].to_vec()),
|
|
|
|
req_id,
|
|
|
|
};
|
|
|
|
info = sender.service_queue.pop_front().unwrap();
|
|
|
|
assert_eq!(info, cmp_info);
|
|
|
|
cmp_info = TmInfo {
|
2022-10-15 21:14:27 +02:00
|
|
|
common: CommonTmInfo {
|
|
|
|
subservice: 5,
|
|
|
|
apid: TEST_APID,
|
|
|
|
msg_counter: 3,
|
|
|
|
dest_id: 0,
|
|
|
|
time_stamp: EMPTY_STAMP,
|
|
|
|
},
|
2022-09-06 00:17:52 +02:00
|
|
|
additional_data: Some([1].to_vec()),
|
|
|
|
req_id,
|
|
|
|
};
|
|
|
|
info = sender.service_queue.pop_front().unwrap();
|
|
|
|
assert_eq!(info, cmp_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2022-09-06 09:48:12 +02:00
|
|
|
fn test_steps_success() {
|
|
|
|
let (mut b, tok) = base_init(false);
|
2022-09-06 00:17:52 +02:00
|
|
|
let mut sender = TestSender::default();
|
2022-09-06 09:48:12 +02:00
|
|
|
let accepted_token = b
|
|
|
|
.rep()
|
|
|
|
.acceptance_success(tok, &mut sender, &EMPTY_STAMP)
|
2022-09-06 00:17:52 +02:00
|
|
|
.expect("Sending acceptance success failed");
|
2022-09-06 09:48:12 +02:00
|
|
|
let started_token = b
|
|
|
|
.rep()
|
2022-09-06 00:17:52 +02:00
|
|
|
.start_success(accepted_token, &mut sender, &[0, 1, 0, 1, 0, 1, 0])
|
|
|
|
.expect("Sending start success failed");
|
2022-09-06 09:48:12 +02:00
|
|
|
let mut empty = b
|
|
|
|
.rep()
|
2022-09-06 00:17:52 +02:00
|
|
|
.step_success(
|
|
|
|
&started_token,
|
|
|
|
&mut sender,
|
|
|
|
&EMPTY_STAMP,
|
|
|
|
EcssEnumU8::new(0),
|
|
|
|
)
|
2022-09-06 09:48:12 +02:00
|
|
|
.expect("Sending step 0 success failed");
|
2022-09-06 00:17:52 +02:00
|
|
|
assert_eq!(empty, ());
|
2022-09-06 09:48:12 +02:00
|
|
|
empty =
|
|
|
|
b.vr.step_success(
|
|
|
|
&started_token,
|
|
|
|
&mut sender,
|
|
|
|
&EMPTY_STAMP,
|
|
|
|
EcssEnumU8::new(1),
|
|
|
|
)
|
|
|
|
.expect("Sending step 1 success failed");
|
2022-09-06 00:17:52 +02:00
|
|
|
assert_eq!(empty, ());
|
|
|
|
assert_eq!(sender.service_queue.len(), 4);
|
2022-09-06 09:48:12 +02:00
|
|
|
step_success_check(&mut sender, tok.req_id);
|
|
|
|
}
|
2022-09-06 00:17:52 +02:00
|
|
|
|
2022-09-06 09:48:12 +02:00
|
|
|
#[test]
|
|
|
|
fn test_steps_success_with_helper() {
|
|
|
|
let (mut b, tok) = base_with_helper_init();
|
|
|
|
let accepted_token = b
|
|
|
|
.helper
|
|
|
|
.acceptance_success(tok, &EMPTY_STAMP)
|
|
|
|
.expect("Sending acceptance success failed");
|
|
|
|
let started_token = b
|
|
|
|
.helper
|
|
|
|
.start_success(accepted_token, &[0, 1, 0, 1, 0, 1, 0])
|
|
|
|
.expect("Sending start success failed");
|
|
|
|
let mut empty = b
|
|
|
|
.helper
|
|
|
|
.step_success(&started_token, &EMPTY_STAMP, EcssEnumU8::new(0))
|
|
|
|
.expect("Sending step 0 success failed");
|
|
|
|
assert_eq!(empty, ());
|
|
|
|
empty = b
|
|
|
|
.helper
|
|
|
|
.step_success(&started_token, &EMPTY_STAMP, EcssEnumU8::new(1))
|
|
|
|
.expect("Sending step 1 success failed");
|
|
|
|
assert_eq!(empty, ());
|
|
|
|
let sender: &mut TestSender = b.helper.sender.downcast_mut().unwrap();
|
|
|
|
assert_eq!(sender.service_queue.len(), 4);
|
|
|
|
step_success_check(sender, tok.req_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn check_step_failure(sender: &mut TestSender, req_id: RequestId, fail_data_raw: [u8; 4]) {
|
|
|
|
assert_eq!(sender.service_queue.len(), 4);
|
2022-09-06 00:17:52 +02:00
|
|
|
let mut cmp_info = TmInfo {
|
2022-10-15 21:14:27 +02:00
|
|
|
common: CommonTmInfo {
|
|
|
|
subservice: 1,
|
|
|
|
apid: TEST_APID,
|
|
|
|
msg_counter: 0,
|
|
|
|
dest_id: 0,
|
|
|
|
time_stamp: EMPTY_STAMP,
|
|
|
|
},
|
2022-09-06 00:17:52 +02:00
|
|
|
additional_data: None,
|
|
|
|
req_id,
|
|
|
|
};
|
|
|
|
let mut info = sender.service_queue.pop_front().unwrap();
|
|
|
|
assert_eq!(info, cmp_info);
|
|
|
|
|
|
|
|
cmp_info = TmInfo {
|
2022-10-15 21:14:27 +02:00
|
|
|
common: CommonTmInfo {
|
|
|
|
subservice: 3,
|
|
|
|
apid: TEST_APID,
|
|
|
|
msg_counter: 1,
|
|
|
|
dest_id: 0,
|
|
|
|
time_stamp: [0, 1, 0, 1, 0, 1, 0],
|
|
|
|
},
|
2022-09-06 00:17:52 +02:00
|
|
|
additional_data: None,
|
|
|
|
req_id,
|
|
|
|
};
|
|
|
|
info = sender.service_queue.pop_front().unwrap();
|
|
|
|
assert_eq!(info, cmp_info);
|
|
|
|
|
|
|
|
cmp_info = TmInfo {
|
2022-10-15 21:14:27 +02:00
|
|
|
common: CommonTmInfo {
|
|
|
|
subservice: 5,
|
|
|
|
apid: TEST_APID,
|
|
|
|
msg_counter: 2,
|
|
|
|
dest_id: 0,
|
|
|
|
time_stamp: EMPTY_STAMP,
|
|
|
|
},
|
2022-09-06 00:17:52 +02:00
|
|
|
additional_data: Some([0].to_vec()),
|
|
|
|
req_id,
|
|
|
|
};
|
|
|
|
info = sender.service_queue.pop_front().unwrap();
|
|
|
|
assert_eq!(info, cmp_info);
|
|
|
|
|
|
|
|
cmp_info = TmInfo {
|
2022-10-15 21:14:27 +02:00
|
|
|
common: CommonTmInfo {
|
|
|
|
subservice: 6,
|
|
|
|
apid: TEST_APID,
|
|
|
|
msg_counter: 3,
|
|
|
|
dest_id: 0,
|
|
|
|
time_stamp: EMPTY_STAMP,
|
|
|
|
},
|
2022-09-06 00:17:52 +02:00
|
|
|
additional_data: Some(
|
|
|
|
[
|
|
|
|
[1].as_slice(),
|
|
|
|
&[0, 0, 0x10, 0x20],
|
|
|
|
fail_data_raw.as_slice(),
|
|
|
|
]
|
|
|
|
.concat()
|
|
|
|
.to_vec(),
|
|
|
|
),
|
|
|
|
req_id,
|
|
|
|
};
|
|
|
|
info = sender.service_queue.pop_front().unwrap();
|
|
|
|
assert_eq!(info, cmp_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2022-09-06 09:48:12 +02:00
|
|
|
fn test_step_failure() {
|
|
|
|
let (mut b, tok) = base_init(false);
|
2022-09-06 00:17:52 +02:00
|
|
|
let mut sender = TestSender::default();
|
2022-09-06 09:48:12 +02:00
|
|
|
let req_id = tok.req_id;
|
2022-09-06 00:17:52 +02:00
|
|
|
let fail_code = EcssEnumU32::new(0x1020);
|
2022-09-06 09:48:12 +02:00
|
|
|
let fail_data: f32 = -22.3232;
|
|
|
|
let mut fail_data_raw = [0; 4];
|
|
|
|
fail_data_raw.copy_from_slice(fail_data.to_be_bytes().as_slice());
|
|
|
|
let fail_step = EcssEnumU8::new(1);
|
|
|
|
let fail_params = FailParamsWithStep::new(
|
|
|
|
&EMPTY_STAMP,
|
|
|
|
&fail_step,
|
|
|
|
&fail_code,
|
|
|
|
Some(fail_data_raw.as_slice()),
|
|
|
|
);
|
|
|
|
|
|
|
|
let accepted_token =
|
|
|
|
b.vr.acceptance_success(tok, &mut sender, &EMPTY_STAMP)
|
|
|
|
.expect("Sending acceptance success failed");
|
|
|
|
let started_token =
|
|
|
|
b.vr.start_success(accepted_token, &mut sender, &[0, 1, 0, 1, 0, 1, 0])
|
|
|
|
.expect("Sending start success failed");
|
|
|
|
let mut empty =
|
|
|
|
b.vr.step_success(
|
|
|
|
&started_token,
|
|
|
|
&mut sender,
|
|
|
|
&EMPTY_STAMP,
|
|
|
|
EcssEnumU8::new(0),
|
|
|
|
)
|
|
|
|
.expect("Sending completion success failed");
|
|
|
|
assert_eq!(empty, ());
|
|
|
|
empty =
|
|
|
|
b.vr.step_failure(started_token, &mut sender, fail_params)
|
|
|
|
.expect("Step failure failed");
|
|
|
|
assert_eq!(empty, ());
|
|
|
|
check_step_failure(&mut sender, req_id, fail_data_raw);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_steps_failure_with_helper() {
|
|
|
|
let (mut b, tok) = base_with_helper_init();
|
|
|
|
let req_id = tok.req_id;
|
|
|
|
let fail_code = EcssEnumU32::new(0x1020);
|
|
|
|
let fail_data: f32 = -22.3232;
|
|
|
|
let mut fail_data_raw = [0; 4];
|
|
|
|
fail_data_raw.copy_from_slice(fail_data.to_be_bytes().as_slice());
|
|
|
|
let fail_step = EcssEnumU8::new(1);
|
|
|
|
let fail_params = FailParamsWithStep::new(
|
|
|
|
&EMPTY_STAMP,
|
|
|
|
&fail_step,
|
|
|
|
&fail_code,
|
|
|
|
Some(fail_data_raw.as_slice()),
|
|
|
|
);
|
2022-09-06 00:17:52 +02:00
|
|
|
|
2022-09-06 09:48:12 +02:00
|
|
|
let accepted_token = b
|
|
|
|
.helper
|
|
|
|
.acceptance_success(tok, &EMPTY_STAMP)
|
2022-09-06 00:17:52 +02:00
|
|
|
.expect("Sending acceptance success failed");
|
2022-09-06 09:48:12 +02:00
|
|
|
let started_token = b
|
|
|
|
.helper
|
|
|
|
.start_success(accepted_token, &[0, 1, 0, 1, 0, 1, 0])
|
2022-09-06 00:17:52 +02:00
|
|
|
.expect("Sending start success failed");
|
2022-09-06 09:48:12 +02:00
|
|
|
let mut empty = b
|
|
|
|
.helper
|
|
|
|
.step_success(&started_token, &EMPTY_STAMP, EcssEnumU8::new(0))
|
|
|
|
.expect("Sending completion success failed");
|
2022-09-06 00:17:52 +02:00
|
|
|
assert_eq!(empty, ());
|
2022-09-06 09:48:12 +02:00
|
|
|
empty = b
|
|
|
|
.helper
|
|
|
|
.step_failure(started_token, fail_params)
|
|
|
|
.expect("Step failure failed");
|
|
|
|
assert_eq!(empty, ());
|
|
|
|
let sender: &mut TestSender = b.helper.sender.downcast_mut().unwrap();
|
|
|
|
check_step_failure(sender, req_id, fail_data_raw);
|
|
|
|
}
|
2022-09-06 00:17:52 +02:00
|
|
|
|
2022-09-06 09:48:12 +02:00
|
|
|
fn completion_fail_check(sender: &mut TestSender, req_id: RequestId) {
|
2022-09-06 00:17:52 +02:00
|
|
|
assert_eq!(sender.service_queue.len(), 3);
|
|
|
|
|
|
|
|
let mut cmp_info = TmInfo {
|
2022-10-15 21:14:27 +02:00
|
|
|
common: CommonTmInfo {
|
|
|
|
subservice: 1,
|
|
|
|
apid: TEST_APID,
|
|
|
|
msg_counter: 0,
|
|
|
|
dest_id: 0,
|
|
|
|
time_stamp: EMPTY_STAMP,
|
|
|
|
},
|
2022-09-06 00:17:52 +02:00
|
|
|
additional_data: None,
|
|
|
|
req_id,
|
|
|
|
};
|
|
|
|
let mut info = sender.service_queue.pop_front().unwrap();
|
|
|
|
assert_eq!(info, cmp_info);
|
|
|
|
|
|
|
|
cmp_info = TmInfo {
|
2022-10-15 21:14:27 +02:00
|
|
|
common: CommonTmInfo {
|
|
|
|
subservice: 3,
|
|
|
|
apid: TEST_APID,
|
|
|
|
msg_counter: 1,
|
|
|
|
dest_id: 0,
|
|
|
|
time_stamp: [0, 1, 0, 1, 0, 1, 0],
|
|
|
|
},
|
2022-09-06 00:17:52 +02:00
|
|
|
additional_data: None,
|
|
|
|
req_id,
|
|
|
|
};
|
|
|
|
info = sender.service_queue.pop_front().unwrap();
|
|
|
|
assert_eq!(info, cmp_info);
|
|
|
|
|
|
|
|
cmp_info = TmInfo {
|
2022-10-15 21:14:27 +02:00
|
|
|
common: CommonTmInfo {
|
|
|
|
subservice: 8,
|
|
|
|
apid: TEST_APID,
|
|
|
|
msg_counter: 2,
|
|
|
|
dest_id: 0,
|
|
|
|
time_stamp: EMPTY_STAMP,
|
|
|
|
},
|
2022-09-06 00:17:52 +02:00
|
|
|
additional_data: Some([0, 0, 0x10, 0x20].to_vec()),
|
|
|
|
req_id,
|
|
|
|
};
|
|
|
|
info = sender.service_queue.pop_front().unwrap();
|
|
|
|
assert_eq!(info, cmp_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2022-09-06 09:48:12 +02:00
|
|
|
fn test_completion_failure() {
|
|
|
|
let (mut b, tok) = base_init(false);
|
2022-09-06 00:17:52 +02:00
|
|
|
let mut sender = TestSender::default();
|
2022-09-06 09:48:12 +02:00
|
|
|
let req_id = tok.req_id;
|
|
|
|
let fail_code = EcssEnumU32::new(0x1020);
|
|
|
|
let fail_params = FailParams::new(&EMPTY_STAMP, &fail_code, None);
|
|
|
|
|
|
|
|
let accepted_token =
|
|
|
|
b.vr.acceptance_success(tok, &mut sender, &EMPTY_STAMP)
|
|
|
|
.expect("Sending acceptance success failed");
|
|
|
|
let started_token =
|
|
|
|
b.vr.start_success(accepted_token, &mut sender, &[0, 1, 0, 1, 0, 1, 0])
|
|
|
|
.expect("Sending start success failed");
|
|
|
|
let empty =
|
|
|
|
b.vr.completion_failure(started_token, &mut sender, fail_params)
|
|
|
|
.expect("Completion failure");
|
|
|
|
assert_eq!(empty, ());
|
|
|
|
completion_fail_check(&mut sender, req_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_completion_failure_with_helper() {
|
|
|
|
let (mut b, tok) = base_with_helper_init();
|
|
|
|
let req_id = tok.req_id;
|
|
|
|
let fail_code = EcssEnumU32::new(0x1020);
|
|
|
|
let fail_params = FailParams::new(&EMPTY_STAMP, &fail_code, None);
|
|
|
|
|
|
|
|
let accepted_token = b
|
|
|
|
.helper
|
|
|
|
.acceptance_success(tok, &EMPTY_STAMP)
|
2022-09-06 00:17:52 +02:00
|
|
|
.expect("Sending acceptance success failed");
|
2022-09-06 09:48:12 +02:00
|
|
|
let started_token = b
|
|
|
|
.helper
|
|
|
|
.start_success(accepted_token, &[0, 1, 0, 1, 0, 1, 0])
|
2022-09-06 00:17:52 +02:00
|
|
|
.expect("Sending start success failed");
|
2022-09-06 09:48:12 +02:00
|
|
|
let empty = b
|
|
|
|
.helper
|
|
|
|
.completion_failure(started_token, fail_params)
|
|
|
|
.expect("Completion failure");
|
2022-09-06 00:17:52 +02:00
|
|
|
assert_eq!(empty, ());
|
2022-09-06 09:48:12 +02:00
|
|
|
let sender: &mut TestSender = b.helper.sender.downcast_mut().unwrap();
|
|
|
|
completion_fail_check(sender, req_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn completion_success_check(sender: &mut TestSender, req_id: RequestId) {
|
2022-09-06 00:17:52 +02:00
|
|
|
assert_eq!(sender.service_queue.len(), 3);
|
|
|
|
let cmp_info = TmInfo {
|
2022-10-15 21:14:27 +02:00
|
|
|
common: CommonTmInfo {
|
|
|
|
subservice: 1,
|
|
|
|
apid: TEST_APID,
|
|
|
|
msg_counter: 0,
|
|
|
|
dest_id: 0,
|
|
|
|
time_stamp: EMPTY_STAMP,
|
|
|
|
},
|
2022-09-06 00:17:52 +02:00
|
|
|
additional_data: None,
|
|
|
|
req_id,
|
|
|
|
};
|
|
|
|
let mut info = sender.service_queue.pop_front().unwrap();
|
|
|
|
assert_eq!(info, cmp_info);
|
|
|
|
|
|
|
|
let cmp_info = TmInfo {
|
2022-10-15 21:14:27 +02:00
|
|
|
common: CommonTmInfo {
|
|
|
|
subservice: 3,
|
|
|
|
apid: TEST_APID,
|
|
|
|
msg_counter: 1,
|
|
|
|
dest_id: 0,
|
|
|
|
time_stamp: [0, 1, 0, 1, 0, 1, 0],
|
|
|
|
},
|
2022-09-06 00:17:52 +02:00
|
|
|
additional_data: None,
|
|
|
|
req_id,
|
|
|
|
};
|
|
|
|
info = sender.service_queue.pop_front().unwrap();
|
|
|
|
assert_eq!(info, cmp_info);
|
|
|
|
let cmp_info = TmInfo {
|
2022-10-15 21:14:27 +02:00
|
|
|
common: CommonTmInfo {
|
|
|
|
subservice: 7,
|
|
|
|
apid: TEST_APID,
|
|
|
|
msg_counter: 2,
|
|
|
|
dest_id: 0,
|
|
|
|
time_stamp: EMPTY_STAMP,
|
|
|
|
},
|
2022-09-06 00:17:52 +02:00
|
|
|
additional_data: None,
|
|
|
|
req_id,
|
|
|
|
};
|
|
|
|
info = sender.service_queue.pop_front().unwrap();
|
|
|
|
assert_eq!(info, cmp_info);
|
2022-09-05 00:20:32 +02:00
|
|
|
}
|
2022-09-06 09:48:12 +02:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_complete_success_sequence() {
|
|
|
|
let (mut b, tok) = base_init(false);
|
|
|
|
let mut sender = TestSender::default();
|
|
|
|
let accepted_token =
|
|
|
|
b.vr.acceptance_success(tok, &mut sender, &EMPTY_STAMP)
|
|
|
|
.expect("Sending acceptance success failed");
|
|
|
|
let started_token =
|
|
|
|
b.vr.start_success(accepted_token, &mut sender, &[0, 1, 0, 1, 0, 1, 0])
|
|
|
|
.expect("Sending start success failed");
|
|
|
|
let empty =
|
|
|
|
b.vr.completion_success(started_token, &mut sender, &EMPTY_STAMP)
|
|
|
|
.expect("Sending completion success failed");
|
|
|
|
assert_eq!(empty, ());
|
|
|
|
completion_success_check(&mut sender, tok.req_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_complete_success_sequence_with_helper() {
|
|
|
|
let (mut b, tok) = base_with_helper_init();
|
|
|
|
let accepted_token = b
|
|
|
|
.helper
|
|
|
|
.acceptance_success(tok, &EMPTY_STAMP)
|
|
|
|
.expect("Sending acceptance success failed");
|
|
|
|
let started_token = b
|
|
|
|
.helper
|
|
|
|
.start_success(accepted_token, &[0, 1, 0, 1, 0, 1, 0])
|
|
|
|
.expect("Sending start success failed");
|
|
|
|
let empty = b
|
|
|
|
.helper
|
|
|
|
.completion_success(started_token, &EMPTY_STAMP)
|
|
|
|
.expect("Sending completion success failed");
|
|
|
|
assert_eq!(empty, ());
|
|
|
|
let sender: &mut TestSender = b.helper.sender.downcast_mut().unwrap();
|
|
|
|
completion_success_check(sender, tok.req_id);
|
|
|
|
}
|
2022-09-03 16:30:37 +02:00
|
|
|
}
|