use new sender abstraction
This commit is contained in:
parent
1f4e6714ba
commit
2783442f91
@ -61,10 +61,10 @@ default-features = false
|
||||
optional = true
|
||||
|
||||
[dependencies.spacepackets]
|
||||
version = "0.6"
|
||||
# version = "0.6"
|
||||
# path = "../spacepackets"
|
||||
# git = "https://egit.irs.uni-stuttgart.de/rust/spacepackets.git"
|
||||
# rev = "4485ed26699d32"
|
||||
git = "https://egit.irs.uni-stuttgart.de/rust/spacepackets.git"
|
||||
rev = "4969d6c33c6"
|
||||
default-features = false
|
||||
|
||||
[dev-dependencies]
|
||||
|
@ -8,7 +8,6 @@ use crate::pus::{
|
||||
AcceptedTc, EcssTmSender, PartialPusHandlingError, PusPacketHandlerResult,
|
||||
PusPacketHandlingError, PusServiceBase, PusServiceHandler,
|
||||
};
|
||||
use crate::tmtc::tm_helper::SharedTmStore;
|
||||
use spacepackets::ecss::event::Subservice;
|
||||
use spacepackets::ecss::PusPacket;
|
||||
use spacepackets::tc::PusTc;
|
||||
|
@ -206,20 +206,19 @@ mod alloc_mod {
|
||||
pub mod std_mod {
|
||||
use crate::pool::{ShareablePoolProvider, SharedPool, StoreAddr, StoreError};
|
||||
use crate::pus::verification::{
|
||||
StdVerifReporterWithSender, TcStateAccepted, TcStateToken, VerificationToken,
|
||||
StdVerifReporterWithSender, TcStateAccepted, VerificationToken,
|
||||
};
|
||||
use crate::pus::{
|
||||
EcssSender, EcssTmSender, EcssTmSenderCore, EcssTmtcErrorWithSend, GenericSendError,
|
||||
PusTmWrapper,
|
||||
};
|
||||
use crate::tmtc::tm_helper::SharedTmStore;
|
||||
use crate::SenderId;
|
||||
use alloc::boxed::Box;
|
||||
use alloc::vec::Vec;
|
||||
use spacepackets::ecss::{PusError, SerializablePusPacket};
|
||||
use spacepackets::tc::PusTc;
|
||||
use spacepackets::time::cds::TimeProvider;
|
||||
use spacepackets::time::{StdTimestampError, TimeWriter};
|
||||
use spacepackets::time::std_mod::StdTimestampError;
|
||||
use spacepackets::time::TimeWriter;
|
||||
use std::cell::RefCell;
|
||||
use std::format;
|
||||
use std::string::String;
|
||||
|
@ -5,12 +5,11 @@ use crate::pus::{
|
||||
AcceptedTc, EcssTmSender, PusPacketHandlerResult, PusPacketHandlingError, PusServiceBase,
|
||||
PusServiceHandler,
|
||||
};
|
||||
use crate::tmtc::tm_helper::SharedTmStore;
|
||||
use spacepackets::ecss::{scheduling, PusPacket};
|
||||
use spacepackets::tc::PusTc;
|
||||
use spacepackets::time::cds::TimeProvider;
|
||||
use std::boxed::Box;
|
||||
use std::sync::mpsc::{Receiver, Sender};
|
||||
use std::sync::mpsc::Receiver;
|
||||
|
||||
/// This is a helper class for [std] environments to handle generic PUS 11 (scheduling service)
|
||||
/// packets. This handler is constrained to using the [PusScheduler], but is able to process
|
||||
|
@ -4,14 +4,12 @@ use crate::pus::{
|
||||
AcceptedTc, EcssTmSender, PartialPusHandlingError, PusPacketHandlerResult,
|
||||
PusPacketHandlingError, PusServiceBase, PusServiceHandler, PusTmWrapper,
|
||||
};
|
||||
use crate::tmtc::tm_helper::SharedTmStore;
|
||||
use spacepackets::ecss::PusPacket;
|
||||
use spacepackets::tc::PusTc;
|
||||
use spacepackets::tm::{PusTm, PusTmSecondaryHeader};
|
||||
use spacepackets::SpHeader;
|
||||
use std::boxed::Box;
|
||||
use std::format;
|
||||
use std::sync::mpsc::{Receiver, Sender};
|
||||
use std::sync::mpsc::Receiver;
|
||||
|
||||
/// This is a helper class for [std] environments to handle generic PUS 17 (test service) packets.
|
||||
/// This handler only processes ping requests and generates a ping reply for them accordingly.
|
||||
@ -70,7 +68,14 @@ impl PusServiceHandler for PusService17TestHandler {
|
||||
let mut reply_header = SpHeader::tm_unseg(self.psb.tm_apid, 0, 0).unwrap();
|
||||
let tc_header = PusTmSecondaryHeader::new_simple(17, 2, &time_stamp);
|
||||
let ping_reply = PusTm::new(&mut reply_header, tc_header, None, true);
|
||||
let result = self.psb.tm_sender.send_tm(PusTmWrapper::Direct(ping_reply));
|
||||
let result = self
|
||||
.psb
|
||||
.tm_sender
|
||||
.send_tm(PusTmWrapper::Direct(ping_reply))
|
||||
.map_err(PartialPusHandlingError::TmSend);
|
||||
if let Err(err) = result {
|
||||
partial_error = Some(err);
|
||||
}
|
||||
|
||||
if let Some(start_token) = start_token {
|
||||
if self
|
||||
|
@ -73,3 +73,14 @@ pub mod hk_err {
|
||||
#[resultcode]
|
||||
pub const COLLECTION_INTERVAL_MISSING: ResultU16 = ResultU16::const_new(GroupId::Hk as u8, 3);
|
||||
}
|
||||
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||
pub enum TmSenderId {
|
||||
PusVerification = 0,
|
||||
PusTest = 1,
|
||||
PusEvent = 2,
|
||||
PusHk = 3,
|
||||
PusAction = 4,
|
||||
PusSched = 5,
|
||||
}
|
||||
|
@ -44,7 +44,8 @@ use satrs_core::spacepackets::{
|
||||
};
|
||||
use satrs_core::tmtc::tm_helper::SharedTmStore;
|
||||
use satrs_core::tmtc::{AddressableId, TargetId};
|
||||
use satrs_example::{RequestTargetId, OBSW_SERVER_ADDR, SERVER_PORT};
|
||||
use satrs_core::SenderId;
|
||||
use satrs_example::{RequestTargetId, TmSenderId, OBSW_SERVER_ADDR, SERVER_PORT};
|
||||
use std::collections::HashMap;
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
use std::sync::mpsc::{channel, TryRecvError};
|
||||
@ -84,7 +85,7 @@ fn main() {
|
||||
let (tm_funnel_tx, tm_funnel_rx) = channel();
|
||||
let (tm_server_tx, tm_server_rx) = channel();
|
||||
let verif_sender = MpscTmInStoreSender::new(
|
||||
0,
|
||||
TmSenderId::PusVerification as SenderId,
|
||||
"verif_sender",
|
||||
tm_store.backing_pool(),
|
||||
tm_funnel_tx.clone(),
|
||||
@ -154,11 +155,16 @@ fn main() {
|
||||
hk_service_receiver: pus_hk_tx,
|
||||
action_service_receiver: pus_action_tx,
|
||||
};
|
||||
let test_srv_tm_sender = MpscTmInStoreSender::new(
|
||||
TmSenderId::PusTest as SenderId,
|
||||
"PUS_17_TM_SENDER",
|
||||
tm_store.backing_pool().clone(),
|
||||
tm_funnel_tx.clone(),
|
||||
);
|
||||
let pus17_handler = PusService17TestHandler::new(
|
||||
pus_test_rx,
|
||||
tc_store.pool.clone(),
|
||||
tm_funnel_tx.clone(),
|
||||
tm_store.clone(),
|
||||
Box::new(test_srv_tm_sender),
|
||||
PUS_APID,
|
||||
verif_reporter.clone(),
|
||||
);
|
||||
@ -166,13 +172,19 @@ fn main() {
|
||||
pus17_handler,
|
||||
test_srv_event_sender,
|
||||
};
|
||||
|
||||
let sched_srv_tm_sender = MpscTmInStoreSender::new(
|
||||
TmSenderId::PusSched as SenderId,
|
||||
"PUS_11_TM_SENDER",
|
||||
tm_store.backing_pool().clone(),
|
||||
tm_funnel_tx.clone(),
|
||||
);
|
||||
let scheduler = PusScheduler::new_with_current_init_time(Duration::from_secs(5))
|
||||
.expect("Creating PUS Scheduler failed");
|
||||
let pus_11_handler = PusService11SchedHandler::new(
|
||||
pus_sched_rx,
|
||||
tc_store.pool.clone(),
|
||||
tm_funnel_tx.clone(),
|
||||
tm_store.clone(),
|
||||
Box::new(sched_srv_tm_sender),
|
||||
PUS_APID,
|
||||
verif_reporter.clone(),
|
||||
scheduler,
|
||||
@ -181,33 +193,49 @@ fn main() {
|
||||
pus_11_handler,
|
||||
tc_source_wrapper,
|
||||
};
|
||||
|
||||
let event_srv_tm_sender = MpscTmInStoreSender::new(
|
||||
TmSenderId::PusEvent as SenderId,
|
||||
"PUS_5_TM_SENDER",
|
||||
tm_store.backing_pool().clone(),
|
||||
tm_funnel_tx.clone(),
|
||||
);
|
||||
let pus_5_handler = PusService5EventHandler::new(
|
||||
pus_event_rx,
|
||||
tc_store.pool.clone(),
|
||||
tm_funnel_tx.clone(),
|
||||
tm_store.clone(),
|
||||
Box::new(event_srv_tm_sender),
|
||||
PUS_APID,
|
||||
verif_reporter.clone(),
|
||||
event_request_tx,
|
||||
);
|
||||
let mut pus_5_wrapper = Pus5Wrapper { pus_5_handler };
|
||||
|
||||
let action_srv_tm_sender = MpscTmInStoreSender::new(
|
||||
TmSenderId::PusAction as SenderId,
|
||||
"PUS_8_TM_SENDER",
|
||||
tm_store.backing_pool().clone(),
|
||||
tm_funnel_tx.clone(),
|
||||
);
|
||||
let pus_8_handler = PusService8ActionHandler::new(
|
||||
pus_action_rx,
|
||||
tc_store.pool.clone(),
|
||||
tm_funnel_tx.clone(),
|
||||
tm_store.clone(),
|
||||
Box::new(action_srv_tm_sender),
|
||||
PUS_APID,
|
||||
verif_reporter.clone(),
|
||||
request_map.clone(),
|
||||
);
|
||||
let mut pus_8_wrapper = Pus8Wrapper { pus_8_handler };
|
||||
|
||||
let hk_srv_tm_sender = MpscTmInStoreSender::new(
|
||||
TmSenderId::PusHk as SenderId,
|
||||
"PUS_3_TM_SENDER",
|
||||
tm_store.backing_pool().clone(),
|
||||
tm_funnel_tx.clone(),
|
||||
);
|
||||
let pus_3_handler = PusService3HkHandler::new(
|
||||
pus_hk_rx,
|
||||
tc_store.pool.clone(),
|
||||
tm_funnel_tx.clone(),
|
||||
tm_store.clone(),
|
||||
Box::new(hk_srv_tm_sender),
|
||||
PUS_APID,
|
||||
verif_reporter.clone(),
|
||||
request_map,
|
||||
|
@ -5,11 +5,11 @@ use satrs_core::pus::verification::{
|
||||
FailParams, StdVerifReporterWithSender, TcStateAccepted, VerificationToken,
|
||||
};
|
||||
use satrs_core::pus::{
|
||||
AcceptedTc, PusPacketHandlerResult, PusPacketHandlingError, PusServiceBase, PusServiceHandler,
|
||||
AcceptedTc, EcssTmSender, PusPacketHandlerResult, PusPacketHandlingError, PusServiceBase,
|
||||
PusServiceHandler,
|
||||
};
|
||||
use satrs_core::spacepackets::ecss::PusPacket;
|
||||
use satrs_core::spacepackets::tc::PusTc;
|
||||
use satrs_core::tmtc::tm_helper::SharedTmStore;
|
||||
use satrs_core::tmtc::TargetId;
|
||||
use satrs_example::tmtc_err;
|
||||
use std::collections::HashMap;
|
||||
@ -24,21 +24,13 @@ impl PusService8ActionHandler {
|
||||
pub fn new(
|
||||
receiver: Receiver<AcceptedTc>,
|
||||
tc_pool: SharedPool,
|
||||
tm_tx: Sender<StoreAddr>,
|
||||
tm_store: SharedTmStore,
|
||||
tm_sender: Box<dyn EcssTmSender>,
|
||||
tm_apid: u16,
|
||||
verification_handler: StdVerifReporterWithSender,
|
||||
request_handlers: HashMap<TargetId, Sender<RequestWithToken>>,
|
||||
) -> Self {
|
||||
Self {
|
||||
psb: PusServiceBase::new(
|
||||
receiver,
|
||||
tc_pool,
|
||||
tm_tx,
|
||||
tm_store,
|
||||
tm_apid,
|
||||
verification_handler,
|
||||
),
|
||||
psb: PusServiceBase::new(receiver, tc_pool, tm_sender, tm_apid, verification_handler),
|
||||
request_handlers,
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,11 @@ use satrs_core::pus::verification::{
|
||||
FailParams, StdVerifReporterWithSender, TcStateAccepted, VerificationToken,
|
||||
};
|
||||
use satrs_core::pus::{
|
||||
AcceptedTc, PusPacketHandlerResult, PusPacketHandlingError, PusServiceBase, PusServiceHandler,
|
||||
AcceptedTc, EcssTmSender, PusPacketHandlerResult, PusPacketHandlingError, PusServiceBase,
|
||||
PusServiceHandler,
|
||||
};
|
||||
use satrs_core::spacepackets::ecss::{hk, PusPacket};
|
||||
use satrs_core::spacepackets::tc::PusTc;
|
||||
use satrs_core::tmtc::tm_helper::SharedTmStore;
|
||||
use satrs_core::tmtc::{AddressableId, TargetId};
|
||||
use satrs_example::{hk_err, tmtc_err};
|
||||
use std::collections::HashMap;
|
||||
@ -25,21 +25,13 @@ impl PusService3HkHandler {
|
||||
pub fn new(
|
||||
receiver: Receiver<AcceptedTc>,
|
||||
tc_pool: SharedPool,
|
||||
tm_tx: Sender<StoreAddr>,
|
||||
tm_store: SharedTmStore,
|
||||
tm_sender: Box<dyn EcssTmSender>,
|
||||
tm_apid: u16,
|
||||
verification_handler: StdVerifReporterWithSender,
|
||||
request_handlers: HashMap<TargetId, Sender<RequestWithToken>>,
|
||||
) -> Self {
|
||||
Self {
|
||||
psb: PusServiceBase::new(
|
||||
receiver,
|
||||
tc_pool,
|
||||
tm_tx,
|
||||
tm_store,
|
||||
tm_apid,
|
||||
verification_handler,
|
||||
),
|
||||
psb: PusServiceBase::new(receiver, tc_pool, tm_sender, tm_apid, verification_handler),
|
||||
request_handlers,
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user