added some more tests
All checks were successful
Rust/sat-rs/pipeline/pr-main This commit looks good
All checks were successful
Rust/sat-rs/pipeline/pr-main This commit looks good
This commit is contained in:
parent
68a5f67589
commit
ec9617bba4
@ -1,13 +1,10 @@
|
|||||||
use crate::pus::{
|
use crate::pus::{
|
||||||
EcssTcReceiver, EcssTmSender, PartialPusHandlingError, PusPacketHandlerResult,
|
PartialPusHandlingError, PusPacketHandlerResult, PusPacketHandlingError, PusTmWrapper,
|
||||||
PusPacketHandlingError, PusTmWrapper,
|
|
||||||
};
|
};
|
||||||
use spacepackets::ecss::tm::{PusTmCreator, PusTmSecondaryHeader};
|
use spacepackets::ecss::tm::{PusTmCreator, PusTmSecondaryHeader};
|
||||||
use spacepackets::ecss::PusPacket;
|
use spacepackets::ecss::PusPacket;
|
||||||
use spacepackets::SpHeader;
|
use spacepackets::SpHeader;
|
||||||
use std::boxed::Box;
|
|
||||||
|
|
||||||
use super::verification::VerificationReporterWithSender;
|
|
||||||
use super::{EcssTcInMemConverter, PusServiceBase, PusServiceHandler};
|
use super::{EcssTcInMemConverter, PusServiceBase, PusServiceHandler};
|
||||||
|
|
||||||
/// This is a helper class for [std] environments to handle generic PUS 17 (test service) packets.
|
/// This is a helper class for [std] environments to handle generic PUS 17 (test service) packets.
|
||||||
|
@ -91,3 +91,33 @@ impl PusTmWithCdsShortHelper {
|
|||||||
PusTmCreator::new(&mut reply_header, tc_header, source_data, true)
|
PusTmCreator::new(&mut reply_header, tc_header, source_data, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use spacepackets::{ecss::PusPacket, time::cds::TimeProvider, CcsdsPacket};
|
||||||
|
|
||||||
|
use super::PusTmWithCdsShortHelper;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_helper_with_stamper() {
|
||||||
|
let mut pus_tm_helper = PusTmWithCdsShortHelper::new(0x123);
|
||||||
|
let stamper = TimeProvider::new_with_u16_days(0, 0);
|
||||||
|
let tm = pus_tm_helper.create_pus_tm_with_stamper(17, 1, &[1, 2, 3, 4], &stamper, 25);
|
||||||
|
assert_eq!(tm.service(), 17);
|
||||||
|
assert_eq!(tm.subservice(), 1);
|
||||||
|
assert_eq!(tm.user_data(), &[1, 2, 3, 4]);
|
||||||
|
assert_eq!(tm.seq_count(), 25);
|
||||||
|
assert_eq!(tm.timestamp(), [64, 0, 0, 0, 0, 0, 0])
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_helper_from_now() {
|
||||||
|
let mut pus_tm_helper = PusTmWithCdsShortHelper::new(0x123);
|
||||||
|
let tm = pus_tm_helper.create_pus_tm_timestamp_now(17, 1, &[1, 2, 3, 4], 25);
|
||||||
|
assert_eq!(tm.service(), 17);
|
||||||
|
assert_eq!(tm.subservice(), 1);
|
||||||
|
assert_eq!(tm.user_data(), &[1, 2, 3, 4]);
|
||||||
|
assert_eq!(tm.seq_count(), 25);
|
||||||
|
assert_eq!(tm.timestamp().len(), 7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -42,7 +42,9 @@ use satrs_core::pus::test::PusService17TestHandler;
|
|||||||
use satrs_core::pus::verification::{
|
use satrs_core::pus::verification::{
|
||||||
TcStateStarted, VerificationReporterCfg, VerificationReporterWithSender, VerificationToken,
|
TcStateStarted, VerificationReporterCfg, VerificationReporterWithSender, VerificationToken,
|
||||||
};
|
};
|
||||||
use satrs_core::pus::{EcssTcInStoreConverter, MpscTcReceiver, MpscTmInStoreSender};
|
use satrs_core::pus::{
|
||||||
|
EcssTcInStoreConverter, MpscTcReceiver, MpscTmInStoreSender, PusServiceHandler,
|
||||||
|
};
|
||||||
use satrs_core::seq_count::{CcsdsSimpleSeqCountProvider, SequenceCountProviderCore};
|
use satrs_core::seq_count::{CcsdsSimpleSeqCountProvider, SequenceCountProviderCore};
|
||||||
use satrs_core::spacepackets::ecss::tm::{PusTmCreator, PusTmZeroCopyWriter};
|
use satrs_core::spacepackets::ecss::tm::{PusTmCreator, PusTmZeroCopyWriter};
|
||||||
use satrs_core::spacepackets::{
|
use satrs_core::spacepackets::{
|
||||||
@ -177,13 +179,13 @@ fn main() {
|
|||||||
"PUS_17_TC_RECV",
|
"PUS_17_TC_RECV",
|
||||||
pus_test_rx,
|
pus_test_rx,
|
||||||
);
|
);
|
||||||
let pus17_handler = PusService17TestHandler::new(
|
let pus17_handler = PusService17TestHandler::new(PusServiceHandler::new(
|
||||||
Box::new(test_srv_receiver),
|
Box::new(test_srv_receiver),
|
||||||
Box::new(test_srv_tm_sender),
|
Box::new(test_srv_tm_sender),
|
||||||
PUS_APID,
|
PUS_APID,
|
||||||
verif_reporter.clone(),
|
verif_reporter.clone(),
|
||||||
EcssTcInStoreConverter::new(tc_store.pool.clone(), 2048),
|
EcssTcInStoreConverter::new(tc_store.pool.clone(), 2048),
|
||||||
);
|
));
|
||||||
let mut pus_17_wrapper = Service17CustomWrapper {
|
let mut pus_17_wrapper = Service17CustomWrapper {
|
||||||
pus17_handler,
|
pus17_handler,
|
||||||
test_srv_event_sender,
|
test_srv_event_sender,
|
||||||
|
Loading…
Reference in New Issue
Block a user