From 4a94fd8ffe0f4a2c0c9dddf2c02a7c429177375b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Feb 2024 11:32:44 +0100 Subject: [PATCH] some better naming and API improvements --- .../satrs-example-structure.graphml | 233 ++++++++++++++++++ satrs-core/src/pus/mod.rs | 44 ++-- satrs-core/src/tmtc/tm_helper.rs | 24 +- satrs-example/src/main.rs | 64 ++--- satrs-example/src/pus/action.rs | 8 +- satrs-example/src/pus/event.rs | 8 +- satrs-example/src/pus/hk.rs | 8 +- satrs-example/src/pus/scheduler.rs | 8 +- satrs-example/src/pus/test.rs | 8 +- satrs-example/src/tm_funnel.rs | 6 +- satrs-example/src/tmtc.rs | 41 ++- 11 files changed, 336 insertions(+), 116 deletions(-) create mode 100644 images/sat-rs-example-structure/satrs-example-structure.graphml diff --git a/images/sat-rs-example-structure/satrs-example-structure.graphml b/images/sat-rs-example-structure/satrs-example-structure.graphml new file mode 100644 index 0000000..e3cfe69 --- /dev/null +++ b/images/sat-rs-example-structure/satrs-example-structure.graphml @@ -0,0 +1,233 @@ + + + + + + + + + + + + + + + + + + + + + + + + satrs-example Component Structure + + + + + + + + + + + + TM Funnel + + + + + + + + + + + + UDP Server + + + + + + + + + + + + TCP Server + + + + + + + + + + + + TC Source + + + + + + + + + + + + ACS Task + + + + + + + + + + + + + + + + + + + + + + + + + Folder 1 + + + + + + + + + + + + + + + + + PUS Stack + + + + + + + + + + + + PUS 1 Verification + + + + + + + + + + + + PUS 3 Housekeeping + + + + + + + + + + + + PUS 5 Events + + + + + + + + + + + + PUS 8 Actions + + + + + + + + + + + + PUS 17 Test + + + + + + + + + + + + PUS 11 Scheduling + + + + + + + + + + + + + + Event Manager + + + + + + + + + + + + PUS Receiver + + + + + + + + + diff --git a/satrs-core/src/pus/mod.rs b/satrs-core/src/pus/mod.rs index 5c62375..64a78ce 100644 --- a/satrs-core/src/pus/mod.rs +++ b/satrs-core/src/pus/mod.rs @@ -399,7 +399,7 @@ pub mod std_mod { EcssTmSenderCore, EcssTmtcError, GenericRecvError, GenericSendError, PusTmWrapper, TryRecvTmtcError, }; - use crate::tmtc::tm_helper::SharedTmStore; + use crate::tmtc::tm_helper::SharedTmPool; use crate::ChannelId; use alloc::boxed::Box; use alloc::vec::Vec; @@ -441,14 +441,14 @@ pub mod std_mod { } #[derive(Clone)] - pub struct MpscTmInStoreSender { + pub struct MpscTmInSharedPoolSender { id: ChannelId, name: &'static str, - shared_tm_store: SharedTmStore, + shared_tm_store: SharedTmPool, sender: mpsc::Sender, } - impl EcssChannel for MpscTmInStoreSender { + impl EcssChannel for MpscTmInSharedPoolSender { fn id(&self) -> ChannelId { self.id } @@ -458,7 +458,7 @@ pub mod std_mod { } } - impl MpscTmInStoreSender { + impl MpscTmInSharedPoolSender { pub fn send_direct_tm(&self, tm: PusTmCreator) -> Result<(), EcssTmtcError> { let addr = self.shared_tm_store.add_pus_tm(&tm)?; self.sender @@ -467,7 +467,7 @@ pub mod std_mod { } } - impl EcssTmSenderCore for MpscTmInStoreSender { + impl EcssTmSenderCore for MpscTmInSharedPoolSender { fn send_tm(&self, tm: PusTmWrapper) -> Result<(), EcssTmtcError> { match tm { PusTmWrapper::InStore(addr) => { @@ -479,11 +479,11 @@ pub mod std_mod { } } - impl MpscTmInStoreSender { + impl MpscTmInSharedPoolSender { pub fn new( id: ChannelId, name: &'static str, - shared_tm_store: SharedTmStore, + shared_tm_store: SharedTmPool, sender: mpsc::Sender, ) -> Self { Self { @@ -582,7 +582,7 @@ pub mod std_mod { pub struct CrossbeamTmInStoreSender { id: ChannelId, name: &'static str, - shared_tm_store: SharedTmStore, + shared_tm_store: SharedTmPool, sender: crossbeam_channel::Sender, } @@ -590,7 +590,7 @@ pub mod std_mod { pub fn new( id: ChannelId, name: &'static str, - shared_tm_store: SharedTmStore, + shared_tm_store: SharedTmPool, sender: crossbeam_channel::Sender, ) -> Self { Self { @@ -951,15 +951,15 @@ pub mod tests { StoreAddr, }; use crate::pus::verification::RequestId; - use crate::tmtc::tm_helper::SharedTmStore; + use crate::tmtc::tm_helper::SharedTmPool; use super::verification::{ TcStateAccepted, VerificationReporterCfg, VerificationReporterWithSender, VerificationToken, }; use super::{ EcssTcAndToken, EcssTcInSharedStoreConverter, EcssTcInVecConverter, MpscTcReceiver, - MpscTmAsVecSender, MpscTmInStoreSender, PusPacketHandlerResult, PusPacketHandlingError, - PusServiceHelper, TcInMemory, + MpscTmAsVecSender, MpscTmInSharedPoolSender, PusPacketHandlerResult, + PusPacketHandlingError, PusServiceHelper, TcInMemory, }; pub const TEST_APID: u16 = 0x101; @@ -1003,7 +1003,7 @@ pub mod tests { pus_buf: [u8; 2048], tm_buf: [u8; 2048], tc_pool: SharedStaticMemoryPool, - tm_pool: SharedTmStore, + tm_pool: SharedTmPool, tc_sender: mpsc::Sender, tm_receiver: mpsc::Receiver, verification_handler: VerificationReporterWithSender, @@ -1019,17 +1019,21 @@ pub mod tests { let tc_pool = StaticMemoryPool::new(pool_cfg.clone()); let tm_pool = StaticMemoryPool::new(pool_cfg); let shared_tc_pool = SharedStaticMemoryPool::new(RwLock::new(tc_pool)); - let shared_tm_pool = SharedTmStore::new(tm_pool); + let shared_tm_pool = SharedTmPool::new(tm_pool); let (test_srv_tc_tx, test_srv_tc_rx) = mpsc::channel(); let (tm_tx, tm_rx) = mpsc::channel(); - let verif_sender = - MpscTmInStoreSender::new(0, "verif_sender", shared_tm_pool.clone(), tm_tx.clone()); + let verif_sender = MpscTmInSharedPoolSender::new( + 0, + "verif_sender", + shared_tm_pool.clone(), + tm_tx.clone(), + ); let verif_cfg = VerificationReporterCfg::new(TEST_APID, 1, 2, 8).unwrap(); let verification_handler = VerificationReporterWithSender::new(&verif_cfg, Box::new(verif_sender)); let test_srv_tm_sender = - MpscTmInStoreSender::new(0, "TEST_SENDER", shared_tm_pool.clone(), tm_tx); + MpscTmInSharedPoolSender::new(0, "TEST_SENDER", shared_tm_pool.clone(), tm_tx); let test_srv_tc_receiver = MpscTcReceiver::new(0, "TEST_RECEIVER", test_srv_tc_rx); let in_store_converter = EcssTcInSharedStoreConverter::new(shared_tc_pool.clone(), 2048); @@ -1073,7 +1077,7 @@ pub mod tests { let next_msg = self.tm_receiver.try_recv(); assert!(next_msg.is_ok()); let tm_addr = next_msg.unwrap(); - let tm_pool = self.tm_pool.shared_pool.read().unwrap(); + let tm_pool = self.tm_pool.0.read().unwrap(); let tm_raw = tm_pool.read(&tm_addr).unwrap(); self.tm_buf[0..tm_raw.len()].copy_from_slice(tm_raw); PusTmReader::new(&self.tm_buf, 7).unwrap().0 @@ -1091,7 +1095,7 @@ pub mod tests { let next_msg = self.tm_receiver.try_recv(); assert!(next_msg.is_ok()); let tm_addr = next_msg.unwrap(); - let tm_pool = self.tm_pool.shared_pool.read().unwrap(); + let tm_pool = self.tm_pool.0.read().unwrap(); let tm_raw = tm_pool.read(&tm_addr).unwrap(); let tm = PusTmReader::new(tm_raw, 7).unwrap().0; assert_eq!(PusPacket::service(&tm), 1); diff --git a/satrs-core/src/tmtc/tm_helper.rs b/satrs-core/src/tmtc/tm_helper.rs index fc0a8e9..c8a09a3 100644 --- a/satrs-core/src/tmtc/tm_helper.rs +++ b/satrs-core/src/tmtc/tm_helper.rs @@ -17,26 +17,26 @@ pub mod std_mod { use std::sync::{Arc, RwLock}; #[derive(Clone)] - pub struct SharedTmStore { - pub shared_pool: SharedStaticMemoryPool, - } + pub struct SharedTmPool(pub SharedStaticMemoryPool); - impl SharedTmStore { + impl SharedTmPool { pub fn new(shared_pool: StaticMemoryPool) -> Self { - Self { - shared_pool: Arc::new(RwLock::new(shared_pool)), - } + Self(Arc::new(RwLock::new(shared_pool))) } pub fn clone_backing_pool(&self) -> SharedStaticMemoryPool { - self.shared_pool.clone() + self.0.clone() + } + pub fn shared_pool(&self) -> &SharedStaticMemoryPool { + &self.0 + } + + pub fn shared_pool_mut(&mut self) -> &mut SharedStaticMemoryPool { + &mut self.0 } pub fn add_pus_tm(&self, pus_tm: &PusTmCreator) -> Result { - let mut pg = self - .shared_pool - .write() - .map_err(|_| EcssTmtcError::StoreLock)?; + let mut pg = self.0.write().map_err(|_| EcssTmtcError::StoreLock)?; let (addr, buf) = pg.free_element(pus_tm.len_written())?; pus_tm .write_to_bytes(buf) diff --git a/satrs-example/src/main.rs b/satrs-example/src/main.rs index 113103c..71774ce 100644 --- a/satrs-example/src/main.rs +++ b/satrs-example/src/main.rs @@ -17,6 +17,7 @@ use log::info; use pus::test::create_test_service_dynamic; use satrs_core::hal::std::tcp_server::ServerConfig; use satrs_core::hal::std::udp_server::UdpTcServer; +use satrs_core::tmtc::tm_helper::SharedTmPool; use satrs_example::config::pool::{create_sched_tc_pool, create_static_pools}; use satrs_example::config::tasks::{ FREQ_MS_AOCS, FREQ_MS_EVENT_HANDLING, FREQ_MS_PUS_STACK, FREQ_MS_UDP_TMTC, @@ -37,14 +38,13 @@ use crate::pus::{PusReceiver, PusTcMpscRouter}; use crate::requests::RequestWithToken; use crate::tcp::{SyncTcpTmSource, TcpTask}; use crate::tmtc::{ - PusTcSourceProviderSharedPool, SharedTcPool, TcArgs, TmArgs, TmtcTaskDynamic, TmtcTaskStatic, + PusTcSourceProviderSharedPool, SharedTcPool, TcSourceTaskDynamic, TcSourceTaskStatic, }; use crate::udp::{StaticUdpTmHandler, UdpTmtcServer}; use satrs_core::pus::event_man::EventRequestWithToken; use satrs_core::pus::verification::{VerificationReporterCfg, VerificationReporterWithSender}; -use satrs_core::pus::{EcssTmSender, MpscTmAsVecSender, MpscTmInStoreSender}; +use satrs_core::pus::{EcssTmSender, MpscTmAsVecSender, MpscTmInSharedPoolSender}; use satrs_core::spacepackets::{time::cds::TimeProvider, time::TimeWriter}; -use satrs_core::tmtc::tm_helper::SharedTmStore; use satrs_core::tmtc::{CcsdsDistributor, TargetId}; use satrs_core::ChannelId; use satrs_example::TargetIdWithApid; @@ -65,7 +65,7 @@ fn create_verification_reporter(verif_sender: impl EcssTmSender) -> Verification #[allow(dead_code)] fn static_tmtc_pool_main() { let (tm_pool, tc_pool) = create_static_pools(); - let shared_tm_store = SharedTmStore::new(tm_pool); + let shared_tm_pool = SharedTmPool::new(tm_pool); let shared_tc_pool = SharedTcPool { pool: Arc::new(RwLock::new(tc_pool)), }; @@ -75,10 +75,10 @@ fn static_tmtc_pool_main() { // Every software component which needs to generate verification telemetry, receives a cloned // verification reporter. - let verif_reporter = create_verification_reporter(MpscTmInStoreSender::new( + let verif_reporter = create_verification_reporter(MpscTmInSharedPoolSender::new( TmSenderId::PusVerification as ChannelId, "verif_sender", - shared_tm_store.clone(), + shared_tm_pool.clone(), tm_funnel_tx.clone(), )); @@ -88,22 +88,13 @@ fn static_tmtc_pool_main() { let mut request_map = HashMap::new(); request_map.insert(acs_target_id, acs_thread_tx); - let tc_source_wrapper = PusTcSourceProviderSharedPool { + // This helper structure is used by all telecommand providers which need to send telecommands + // to the TC source. + let tc_source = PusTcSourceProviderSharedPool { shared_pool: shared_tc_pool.clone(), tc_source: tc_source_tx, }; - // Create clones here to allow moving the values - let tc_args = TcArgs { - tc_source: tc_source_wrapper.clone(), - tc_receiver: tc_source_rx, - }; - let tm_args = TmArgs { - tm_store: shared_tm_store.clone(), - tm_sink_sender: tm_funnel_tx.clone(), - tm_udp_server_rx: tm_server_rx, - }; - // Create event handling components // These sender handles are used to send event requests, for example to enable or disable // certain events. @@ -112,10 +103,10 @@ fn static_tmtc_pool_main() { // The event task is the core handler to perform the event routing and TM handling as specified // in the sat-rs documentation. let mut event_handler = EventHandler::new( - MpscTmInStoreSender::new( + MpscTmInSharedPoolSender::new( TmSenderId::AllEvents as ChannelId, "ALL_EVENTS_TX", - shared_tm_store.clone(), + shared_tm_pool.clone(), tm_funnel_tx.clone(), ), verif_reporter.clone(), @@ -135,7 +126,7 @@ fn static_tmtc_pool_main() { action_service_receiver: pus_action_tx, }; let pus_test_service = create_test_service_static( - shared_tm_store.clone(), + shared_tm_pool.clone(), tm_funnel_tx.clone(), verif_reporter.clone(), shared_tc_pool.pool.clone(), @@ -143,15 +134,15 @@ fn static_tmtc_pool_main() { pus_test_rx, ); let pus_scheduler_service = create_scheduler_service_static( - shared_tm_store.clone(), + shared_tm_pool.clone(), tm_funnel_tx.clone(), verif_reporter.clone(), - tc_source_wrapper, + tc_source.clone(), pus_sched_rx, create_sched_tc_pool(), ); let pus_event_service = create_event_service_static( - shared_tm_store.clone(), + shared_tm_pool.clone(), tm_funnel_tx.clone(), verif_reporter.clone(), shared_tc_pool.pool.clone(), @@ -159,7 +150,7 @@ fn static_tmtc_pool_main() { event_request_tx, ); let pus_action_service = create_action_service_static( - shared_tm_store.clone(), + shared_tm_pool.clone(), tm_funnel_tx.clone(), verif_reporter.clone(), shared_tc_pool.pool.clone(), @@ -167,7 +158,7 @@ fn static_tmtc_pool_main() { request_map.clone(), ); let pus_hk_service = create_hk_service_static( - shared_tm_store.clone(), + shared_tm_pool.clone(), tm_funnel_tx.clone(), verif_reporter.clone(), shared_tc_pool.pool.clone(), @@ -182,11 +173,10 @@ fn static_tmtc_pool_main() { pus_test_service, ); - let ccsds_receiver = CcsdsReceiver { - tc_source: tc_args.tc_source.clone(), - }; - let mut tmtc_task = TmtcTaskStatic::new( - tc_args, + let ccsds_receiver = CcsdsReceiver { tc_source }; + let mut tmtc_task = TcSourceTaskStatic::new( + shared_tc_pool.clone(), + tc_source_rx, PusReceiver::new(verif_reporter.clone(), pus_router), ); @@ -197,8 +187,8 @@ fn static_tmtc_pool_main() { let mut udp_tmtc_server = UdpTmtcServer { udp_tc_server, tm_handler: StaticUdpTmHandler { - tm_rx: tm_args.tm_udp_server_rx, - tm_store: tm_args.tm_store.clone_backing_pool(), + tm_rx: tm_server_rx, + tm_store: shared_tm_pool.clone_backing_pool(), }, }; @@ -213,10 +203,10 @@ fn static_tmtc_pool_main() { .expect("tcp server creation failed"); let mut acs_task = AcsTask::new( - MpscTmInStoreSender::new( + MpscTmInSharedPoolSender::new( TmSenderId::AcsSubsystem as ChannelId, "ACS_TASK_SENDER", - shared_tm_store.clone(), + shared_tm_pool.clone(), tm_funnel_tx.clone(), ), acs_thread_rx, @@ -224,7 +214,7 @@ fn static_tmtc_pool_main() { ); let mut tm_funnel = TmFunnelStatic::new( - shared_tm_store, + shared_tm_pool, sync_tm_tcp_source, tm_funnel_rx, tm_server_tx, @@ -399,7 +389,7 @@ fn dyn_tmtc_pool_main() { let ccsds_receiver = CcsdsReceiver { tc_source }; - let mut tmtc_task = TmtcTaskDynamic::new( + let mut tmtc_task = TcSourceTaskDynamic::new( tc_source_rx, PusReceiver::new(verif_reporter.clone(), pus_router), ); diff --git a/satrs-example/src/pus/action.rs b/satrs-example/src/pus/action.rs index 2c7afb2..7c59723 100644 --- a/satrs-example/src/pus/action.rs +++ b/satrs-example/src/pus/action.rs @@ -6,12 +6,12 @@ use satrs_core::pus::verification::{ }; use satrs_core::pus::{ EcssTcAndToken, EcssTcInMemConverter, EcssTcInSharedStoreConverter, EcssTcInVecConverter, - EcssTcReceiver, EcssTmSender, MpscTcReceiver, MpscTmAsVecSender, MpscTmInStoreSender, + EcssTcReceiver, EcssTmSender, MpscTcReceiver, MpscTmAsVecSender, MpscTmInSharedPoolSender, PusPacketHandlerResult, PusPacketHandlingError, PusServiceBase, PusServiceHelper, }; use satrs_core::spacepackets::ecss::tc::PusTcReader; use satrs_core::spacepackets::ecss::PusPacket; -use satrs_core::tmtc::tm_helper::SharedTmStore; +use satrs_core::tmtc::tm_helper::SharedTmPool; use satrs_core::ChannelId; use satrs_example::config::{tmtc_err, TcReceiverId, TmSenderId, PUS_APID}; use satrs_example::TargetIdWithApid; @@ -19,14 +19,14 @@ use std::collections::HashMap; use std::sync::mpsc::{self, Sender}; pub fn create_action_service_static( - shared_tm_store: SharedTmStore, + shared_tm_store: SharedTmPool, tm_funnel_tx: mpsc::Sender, verif_reporter: VerificationReporterWithSender, tc_pool: SharedStaticMemoryPool, pus_action_rx: mpsc::Receiver, request_map: HashMap>, ) -> Pus8Wrapper { - let action_srv_tm_sender = MpscTmInStoreSender::new( + let action_srv_tm_sender = MpscTmInSharedPoolSender::new( TmSenderId::PusAction as ChannelId, "PUS_8_TM_SENDER", shared_tm_store.clone(), diff --git a/satrs-example/src/pus/event.rs b/satrs-example/src/pus/event.rs index 825c6fd..fbbe942 100644 --- a/satrs-example/src/pus/event.rs +++ b/satrs-example/src/pus/event.rs @@ -7,22 +7,22 @@ use satrs_core::pus::event_srv::PusService5EventHandler; use satrs_core::pus::verification::VerificationReporterWithSender; use satrs_core::pus::{ EcssTcAndToken, EcssTcInMemConverter, EcssTcInSharedStoreConverter, EcssTcInVecConverter, - MpscTcReceiver, MpscTmAsVecSender, MpscTmInStoreSender, PusPacketHandlerResult, + MpscTcReceiver, MpscTmAsVecSender, MpscTmInSharedPoolSender, PusPacketHandlerResult, PusServiceHelper, }; -use satrs_core::tmtc::tm_helper::SharedTmStore; +use satrs_core::tmtc::tm_helper::SharedTmPool; use satrs_core::ChannelId; use satrs_example::config::{TcReceiverId, TmSenderId, PUS_APID}; pub fn create_event_service_static( - shared_tm_store: SharedTmStore, + shared_tm_store: SharedTmPool, tm_funnel_tx: mpsc::Sender, verif_reporter: VerificationReporterWithSender, tc_pool: SharedStaticMemoryPool, pus_event_rx: mpsc::Receiver, event_request_tx: mpsc::Sender, ) -> Pus5Wrapper { - let event_srv_tm_sender = MpscTmInStoreSender::new( + let event_srv_tm_sender = MpscTmInSharedPoolSender::new( TmSenderId::PusEvent as ChannelId, "PUS_5_TM_SENDER", shared_tm_store.clone(), diff --git a/satrs-example/src/pus/hk.rs b/satrs-example/src/pus/hk.rs index a40fd7a..5a27e9f 100644 --- a/satrs-example/src/pus/hk.rs +++ b/satrs-example/src/pus/hk.rs @@ -7,11 +7,11 @@ use satrs_core::pus::verification::{ }; use satrs_core::pus::{ EcssTcAndToken, EcssTcInMemConverter, EcssTcInSharedStoreConverter, EcssTcInVecConverter, - EcssTcReceiver, EcssTmSender, MpscTcReceiver, MpscTmAsVecSender, MpscTmInStoreSender, + EcssTcReceiver, EcssTmSender, MpscTcReceiver, MpscTmAsVecSender, MpscTmInSharedPoolSender, PusPacketHandlerResult, PusPacketHandlingError, PusServiceBase, PusServiceHelper, }; use satrs_core::spacepackets::ecss::{hk, PusPacket}; -use satrs_core::tmtc::tm_helper::SharedTmStore; +use satrs_core::tmtc::tm_helper::SharedTmPool; use satrs_core::ChannelId; use satrs_example::config::{hk_err, tmtc_err, TcReceiverId, TmSenderId, PUS_APID}; use satrs_example::TargetIdWithApid; @@ -19,14 +19,14 @@ use std::collections::HashMap; use std::sync::mpsc::{self, Sender}; pub fn create_hk_service_static( - shared_tm_store: SharedTmStore, + shared_tm_store: SharedTmPool, tm_funnel_tx: mpsc::Sender, verif_reporter: VerificationReporterWithSender, tc_pool: SharedStaticMemoryPool, pus_hk_rx: mpsc::Receiver, request_map: HashMap>, ) -> Pus3Wrapper { - let hk_srv_tm_sender = MpscTmInStoreSender::new( + let hk_srv_tm_sender = MpscTmInSharedPoolSender::new( TmSenderId::PusHk as ChannelId, "PUS_3_TM_SENDER", shared_tm_store.clone(), diff --git a/satrs-example/src/pus/scheduler.rs b/satrs-example/src/pus/scheduler.rs index 04d8d7a..0842904 100644 --- a/satrs-example/src/pus/scheduler.rs +++ b/satrs-example/src/pus/scheduler.rs @@ -8,10 +8,10 @@ use satrs_core::pus::scheduler_srv::PusService11SchedHandler; use satrs_core::pus::verification::VerificationReporterWithSender; use satrs_core::pus::{ EcssTcAndToken, EcssTcInMemConverter, EcssTcInSharedStoreConverter, EcssTcInVecConverter, - MpscTcReceiver, MpscTmAsVecSender, MpscTmInStoreSender, PusPacketHandlerResult, + MpscTcReceiver, MpscTmAsVecSender, MpscTmInSharedPoolSender, PusPacketHandlerResult, PusServiceHelper, }; -use satrs_core::tmtc::tm_helper::SharedTmStore; +use satrs_core::tmtc::tm_helper::SharedTmPool; use satrs_core::ChannelId; use satrs_example::config::{TcReceiverId, TmSenderId, PUS_APID}; @@ -103,14 +103,14 @@ impl Pus11Wrapper { } pub fn create_scheduler_service_static( - shared_tm_store: SharedTmStore, + shared_tm_store: SharedTmPool, tm_funnel_tx: mpsc::Sender, verif_reporter: VerificationReporterWithSender, tc_releaser: PusTcSourceProviderSharedPool, pus_sched_rx: mpsc::Receiver, sched_tc_pool: StaticMemoryPool, ) -> Pus11Wrapper { - let sched_srv_tm_sender = MpscTmInStoreSender::new( + let sched_srv_tm_sender = MpscTmInSharedPoolSender::new( TmSenderId::PusSched as ChannelId, "PUS_11_TM_SENDER", shared_tm_store.clone(), diff --git a/satrs-example/src/pus/test.rs b/satrs-example/src/pus/test.rs index b00899c..1958055 100644 --- a/satrs-example/src/pus/test.rs +++ b/satrs-example/src/pus/test.rs @@ -5,27 +5,27 @@ use satrs_core::pus::test::PusService17TestHandler; use satrs_core::pus::verification::{FailParams, VerificationReporterWithSender}; use satrs_core::pus::{ EcssTcAndToken, EcssTcInMemConverter, EcssTcInVecConverter, MpscTcReceiver, MpscTmAsVecSender, - MpscTmInStoreSender, PusPacketHandlerResult, PusServiceHelper, + MpscTmInSharedPoolSender, PusPacketHandlerResult, PusServiceHelper, }; use satrs_core::spacepackets::ecss::tc::PusTcReader; use satrs_core::spacepackets::ecss::PusPacket; use satrs_core::spacepackets::time::cds::TimeProvider; use satrs_core::spacepackets::time::TimeWriter; -use satrs_core::tmtc::tm_helper::SharedTmStore; +use satrs_core::tmtc::tm_helper::SharedTmPool; use satrs_core::ChannelId; use satrs_core::{events::EventU32, pus::EcssTcInSharedStoreConverter}; use satrs_example::config::{tmtc_err, TcReceiverId, TmSenderId, PUS_APID, TEST_EVENT}; use std::sync::mpsc::{self, Sender}; pub fn create_test_service_static( - shared_tm_store: SharedTmStore, + shared_tm_store: SharedTmPool, tm_funnel_tx: mpsc::Sender, verif_reporter: VerificationReporterWithSender, tc_pool: SharedStaticMemoryPool, event_sender: mpsc::Sender<(EventU32, Option)>, pus_test_rx: mpsc::Receiver, ) -> Service17CustomWrapper { - let test_srv_tm_sender = MpscTmInStoreSender::new( + let test_srv_tm_sender = MpscTmInSharedPoolSender::new( TmSenderId::PusTest as ChannelId, "PUS_17_TM_SENDER", shared_tm_store.clone(), diff --git a/satrs-example/src/tm_funnel.rs b/satrs-example/src/tm_funnel.rs index ba1ff32..9069d72 100644 --- a/satrs-example/src/tm_funnel.rs +++ b/satrs-example/src/tm_funnel.rs @@ -11,7 +11,7 @@ use satrs_core::{ time::cds::MIN_CDS_FIELD_LEN, CcsdsPacket, }, - tmtc::tm_helper::SharedTmStore, + tmtc::tm_helper::SharedTmPool, }; use crate::tcp::SyncTcpTmSource; @@ -70,14 +70,14 @@ impl TmFunnelCommon { pub struct TmFunnelStatic { common: TmFunnelCommon, - shared_tm_store: SharedTmStore, + shared_tm_store: SharedTmPool, tm_funnel_rx: Receiver, tm_server_tx: Sender, } impl TmFunnelStatic { pub fn new( - shared_tm_store: SharedTmStore, + shared_tm_store: SharedTmPool, sync_tm_tcp_source: SyncTcpTmSource, tm_funnel_rx: Receiver, tm_server_tx: Sender, diff --git a/satrs-example/src/tmtc.rs b/satrs-example/src/tmtc.rs index 39b4b3c..f445499 100644 --- a/satrs-example/src/tmtc.rs +++ b/satrs-example/src/tmtc.rs @@ -8,26 +8,15 @@ use crate::pus::PusReceiver; use satrs_core::pool::{PoolProviderMemInPlace, SharedStaticMemoryPool, StoreAddr, StoreError}; use satrs_core::spacepackets::ecss::tc::PusTcReader; use satrs_core::spacepackets::ecss::PusPacket; -use satrs_core::tmtc::tm_helper::SharedTmStore; use satrs_core::tmtc::ReceivesCcsdsTc; +/* pub struct TmArgs { pub tm_store: SharedTmStore, pub tm_sink_sender: Sender, pub tm_udp_server_rx: Receiver, } - -pub struct TcArgs { - pub tc_source: PusTcSourceProviderSharedPool, - pub tc_receiver: Receiver, -} - -impl TcArgs { - #[allow(dead_code)] - fn split(self) -> (PusTcSourceProviderSharedPool, Receiver) { - (self.tc_source, self.tc_receiver) - } -} + */ #[derive(Debug, Clone, PartialEq, Eq, Error)] pub enum MpscStoreAndSendError { @@ -110,16 +99,22 @@ impl ReceivesCcsdsTc for PusTcSourceProviderDynamic { } } -pub struct TmtcTaskStatic { - tc_args: TcArgs, +pub struct TcSourceTaskStatic { + shared_tc_pool: SharedTcPool, + tc_receiver: Receiver, tc_buf: [u8; 4096], pus_receiver: PusReceiver, } -impl TmtcTaskStatic { - pub fn new(tc_args: TcArgs, pus_receiver: PusReceiver) -> Self { +impl TcSourceTaskStatic { + pub fn new( + shared_tc_pool: SharedTcPool, + tc_receiver: Receiver, + pus_receiver: PusReceiver, + ) -> Self { Self { - tc_args, + shared_tc_pool, + tc_receiver, tc_buf: [0; 4096], pus_receiver, } @@ -130,12 +125,10 @@ impl TmtcTaskStatic { } pub fn poll_tc(&mut self) -> bool { - match self.tc_args.tc_receiver.try_recv() { + match self.tc_receiver.try_recv() { Ok(addr) => { let pool = self - .tc_args - .tc_source - .shared_pool + .shared_tc_pool .pool .read() .expect("locking tc pool failed"); @@ -171,12 +164,12 @@ impl TmtcTaskStatic { } } -pub struct TmtcTaskDynamic { +pub struct TcSourceTaskDynamic { pub tc_receiver: Receiver>, pus_receiver: PusReceiver, } -impl TmtcTaskDynamic { +impl TcSourceTaskDynamic { pub fn new(tc_receiver: Receiver>, pus_receiver: PusReceiver) -> Self { Self { tc_receiver,