Merge remote-tracking branch 'origin/main' into tricky-pus-abstraction-changes
All checks were successful
Rust/sat-rs/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2024-01-31 12:09:55 +01:00
commit e2086391bc
Signed by: muellerr
GPG Key ID: A649FB78196E3849
17 changed files with 232 additions and 164 deletions

View File

@ -1,6 +1,6 @@
use crate::events::EventU32; use crate::events::EventU32;
use crate::pus::event_man::{EventRequest, EventRequestWithToken}; use crate::pus::event_man::{EventRequest, EventRequestWithToken};
use crate::pus::verification::{StdVerifReporterWithSender, TcStateToken}; use crate::pus::verification::TcStateToken;
use crate::pus::{ use crate::pus::{
EcssTcReceiver, EcssTmSender, PartialPusHandlingError, PusPacketHandlerResult, EcssTcReceiver, EcssTmSender, PartialPusHandlingError, PusPacketHandlerResult,
PusPacketHandlingError, PusPacketHandlingError,
@ -10,6 +10,7 @@ use spacepackets::ecss::event::Subservice;
use spacepackets::ecss::PusPacket; use spacepackets::ecss::PusPacket;
use std::sync::mpsc::Sender; use std::sync::mpsc::Sender;
use super::verification::VerificationReporterWithSender;
use super::{EcssTcInMemConverter, PusServiceBase, PusServiceHandler}; use super::{EcssTcInMemConverter, PusServiceBase, PusServiceHandler};
pub struct PusService5EventHandler<TcInMemConverter: EcssTcInMemConverter> { pub struct PusService5EventHandler<TcInMemConverter: EcssTcInMemConverter> {
@ -22,9 +23,9 @@ impl<TcInMemConverter: EcssTcInMemConverter> PusService5EventHandler<TcInMemConv
tc_receiver: Box<dyn EcssTcReceiver>, tc_receiver: Box<dyn EcssTcReceiver>,
tm_sender: Box<dyn EcssTmSender>, tm_sender: Box<dyn EcssTmSender>,
tm_apid: u16, tm_apid: u16,
verification_handler: StdVerifReporterWithSender, verification_handler: VerificationReporterWithSender,
event_request_tx: Sender<EventRequestWithToken>,
tc_in_mem_converter: TcInMemConverter, tc_in_mem_converter: TcInMemConverter,
event_request_tx: Sender<EventRequestWithToken>,
) -> Self { ) -> Self {
Self { Self {
psb: PusServiceHandler::new( psb: PusServiceHandler::new(

View File

@ -646,6 +646,8 @@ pub mod std_mod {
InvalidSubservice(u8), InvalidSubservice(u8),
#[error("not enough application data available: {0}")] #[error("not enough application data available: {0}")]
NotEnoughAppData(String), NotEnoughAppData(String),
#[error("PUS packet too large, does not fit in buffer: {0}")]
PusPacketTooLarge(usize),
#[error("invalid application data")] #[error("invalid application data")]
InvalidAppData(String), InvalidAppData(String),
#[error("invalid format of TC in memory: {0:?}")] #[error("invalid format of TC in memory: {0:?}")]
@ -687,12 +689,20 @@ pub mod std_mod {
} }
pub trait EcssTcInMemConverter { pub trait EcssTcInMemConverter {
fn cache_ecss_tc_in_memory<'a>(
&'a mut self,
possible_packet: &'a AcceptedEcssTcAndToken,
) -> Result<(), PusPacketHandlingError>;
fn tc_slice_raw(&self) -> &[u8];
fn convert_ecss_tc_in_memory_to_reader<'a>( fn convert_ecss_tc_in_memory_to_reader<'a>(
&'a mut self, &'a mut self,
possible_packet: &'a AcceptedEcssTcAndToken, possible_packet: &'a AcceptedEcssTcAndToken,
) -> Result<PusTcReader<'a>, PusPacketHandlingError>; ) -> Result<PusTcReader<'a>, PusPacketHandlingError> {
self.cache_ecss_tc_in_memory(possible_packet)?;
fn tc_slice_raw(&self) -> &[u8]; Ok(PusTcReader::new(self.tc_slice_raw())?.0)
}
} }
pub struct EcssTcInVecConverter { pub struct EcssTcInVecConverter {
@ -700,10 +710,11 @@ pub mod std_mod {
} }
impl EcssTcInMemConverter for EcssTcInVecConverter { impl EcssTcInMemConverter for EcssTcInVecConverter {
fn convert_ecss_tc_in_memory_to_reader<'a>( fn cache_ecss_tc_in_memory<'a>(
&'a mut self, &'a mut self,
possible_packet: &'a AcceptedEcssTcAndToken, possible_packet: &'a AcceptedEcssTcAndToken,
) -> Result<PusTcReader<'a>, PusPacketHandlingError> { ) -> Result<(), PusPacketHandlingError> {
self.pus_tc_raw = None;
match &possible_packet.tc_in_memory { match &possible_packet.tc_in_memory {
super::TcInMemory::StoreAddr(_) => { super::TcInMemory::StoreAddr(_) => {
return Err(PusPacketHandlingError::InvalidTcInMemoryFormat( return Err(PusPacketHandlingError::InvalidTcInMemoryFormat(
@ -714,8 +725,7 @@ pub mod std_mod {
self.pus_tc_raw = Some(vec.clone()); self.pus_tc_raw = Some(vec.clone());
} }
}; };
let (tc, _) = PusTcReader::new(self.pus_tc_raw.as_ref().unwrap())?; Ok(())
Ok(tc)
} }
fn tc_slice_raw(&self) -> &[u8] { fn tc_slice_raw(&self) -> &[u8] {
@ -728,14 +738,14 @@ pub mod std_mod {
pub struct EcssTcInStoreConverter { pub struct EcssTcInStoreConverter {
pub shared_tc_store: SharedPool, pub shared_tc_store: SharedPool,
pub pus_buf: [u8; 2048], pub pus_buf: Vec<u8>,
} }
impl EcssTcInStoreConverter { impl EcssTcInStoreConverter {
pub fn new(shared_tc_store: SharedPool) -> Self { pub fn new(shared_tc_store: SharedPool, max_expected_tc_size: usize) -> Self {
Self { Self {
shared_tc_store, shared_tc_store,
pus_buf: [0; 2048], pus_buf: alloc::vec![0; max_expected_tc_size],
} }
} }
@ -747,27 +757,30 @@ pub mod std_mod {
.map_err(|_| PusPacketHandlingError::EcssTmtc(EcssTmtcError::StoreLock))?; .map_err(|_| PusPacketHandlingError::EcssTmtc(EcssTmtcError::StoreLock))?;
let tc_guard = tc_pool.read_with_guard(addr); let tc_guard = tc_pool.read_with_guard(addr);
let tc_raw = tc_guard.read().unwrap(); let tc_raw = tc_guard.read().unwrap();
if tc_raw.len() > self.pus_buf.len() {
return Err(PusPacketHandlingError::PusPacketTooLarge(tc_raw.len()));
}
self.pus_buf[0..tc_raw.len()].copy_from_slice(tc_raw); self.pus_buf[0..tc_raw.len()].copy_from_slice(tc_raw);
Ok(()) Ok(())
} }
} }
impl EcssTcInMemConverter for EcssTcInStoreConverter { impl EcssTcInMemConverter for EcssTcInStoreConverter {
fn convert_ecss_tc_in_memory_to_reader<'a>( fn cache_ecss_tc_in_memory<'a>(
&'a mut self, &'a mut self,
possible_packet: &'a AcceptedEcssTcAndToken, possible_packet: &'a AcceptedEcssTcAndToken,
) -> Result<PusTcReader<'a>, PusPacketHandlingError> { ) -> Result<(), PusPacketHandlingError> {
Ok(match &possible_packet.tc_in_memory { match &possible_packet.tc_in_memory {
super::TcInMemory::StoreAddr(addr) => { super::TcInMemory::StoreAddr(addr) => {
self.copy_tc_to_buf(*addr)?; self.copy_tc_to_buf(*addr)?;
PusTcReader::new(&self.pus_buf)?.0
} }
super::TcInMemory::Vec(_) => { super::TcInMemory::Vec(_) => {
return Err(PusPacketHandlingError::InvalidTcInMemoryFormat( return Err(PusPacketHandlingError::InvalidTcInMemoryFormat(
possible_packet.tc_in_memory.clone(), possible_packet.tc_in_memory.clone(),
)); ));
} }
}) };
Ok(())
} }
fn tc_slice_raw(&self) -> &[u8] { fn tc_slice_raw(&self) -> &[u8] {

View File

@ -1,11 +1,11 @@
use crate::pool::SharedPool; use crate::pool::SharedPool;
use crate::pus::scheduler::PusScheduler; use crate::pus::scheduler::PusScheduler;
use crate::pus::verification::StdVerifReporterWithSender;
use crate::pus::{EcssTcReceiver, EcssTmSender, PusPacketHandlerResult, PusPacketHandlingError}; use crate::pus::{EcssTcReceiver, EcssTmSender, PusPacketHandlerResult, PusPacketHandlingError};
use spacepackets::ecss::{scheduling, PusPacket}; use spacepackets::ecss::{scheduling, PusPacket};
use spacepackets::time::cds::TimeProvider; use spacepackets::time::cds::TimeProvider;
use std::boxed::Box; 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 11 (scheduling service) /// This is a helper class for [std] environments to handle generic PUS 11 (scheduling service)
@ -27,7 +27,7 @@ impl<TcInMemConverter: EcssTcInMemConverter> PusService11SchedHandler<TcInMemCon
tc_receiver: Box<dyn EcssTcReceiver>, tc_receiver: Box<dyn EcssTcReceiver>,
tm_sender: Box<dyn EcssTmSender>, tm_sender: Box<dyn EcssTmSender>,
tm_apid: u16, tm_apid: u16,
verification_handler: StdVerifReporterWithSender, verification_handler: VerificationReporterWithSender,
tc_in_mem_converter: TcInMemConverter, tc_in_mem_converter: TcInMemConverter,
shared_tc_store: SharedPool, shared_tc_store: SharedPool,
scheduler: PusScheduler, scheduler: PusScheduler,

View File

@ -144,7 +144,7 @@ mod tests {
VerificationReporterWithSender::new(&verif_cfg, Box::new(verif_sender)); VerificationReporterWithSender::new(&verif_cfg, Box::new(verif_sender));
let test_srv_tm_sender = MpscTmInStoreSender::new(0, "TEST_SENDER", shared_tm_store, tm_tx); let test_srv_tm_sender = MpscTmInStoreSender::new(0, "TEST_SENDER", shared_tm_store, tm_tx);
let test_srv_tc_receiver = MpscTcInStoreReceiver::new(0, "TEST_RECEIVER", test_srv_tc_rx); let test_srv_tc_receiver = MpscTcInStoreReceiver::new(0, "TEST_RECEIVER", test_srv_tc_rx);
let in_store_converter = EcssTcInStoreConverter::new(tc_pool_shared.clone()); let in_store_converter = EcssTcInStoreConverter::new(tc_pool_shared.clone(), 2048);
let mut pus_17_handler = PusService17TestHandler::new( let mut pus_17_handler = PusService17TestHandler::new(
Box::new(test_srv_tc_receiver), Box::new(test_srv_tc_receiver),
Box::new(test_srv_tm_sender), Box::new(test_srv_tm_sender),

View File

@ -7,9 +7,7 @@
//! routing without the overhead and complication of using message queues. However, it also requires //! routing without the overhead and complication of using message queues. However, it also requires
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
use downcast_rs::{impl_downcast, Downcast}; use downcast_rs::{impl_downcast, Downcast};
#[cfg(feature = "serde")] use spacepackets::SpHeader;
use serde::{Deserialize, Serialize};
use spacepackets::{ByteConversionError, SpHeader};
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
pub mod ccsds_distrib; pub mod ccsds_distrib;
@ -24,40 +22,6 @@ pub use pus_distrib::{PusDistributor, PusServiceProvider};
pub type TargetId = u32; pub type TargetId = u32;
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct AddressableId {
pub target_id: TargetId,
pub unique_id: u32,
}
impl AddressableId {
pub fn from_raw_be(buf: &[u8]) -> Result<Self, ByteConversionError> {
if buf.len() < 8 {
return Err(ByteConversionError::FromSliceTooSmall {
found: buf.len(),
expected: 8,
});
}
Ok(Self {
target_id: u32::from_be_bytes(buf[0..4].try_into().unwrap()),
unique_id: u32::from_be_bytes(buf[4..8].try_into().unwrap()),
})
}
pub fn write_to_be_bytes(&self, buf: &mut [u8]) -> Result<usize, ByteConversionError> {
if buf.len() < 8 {
return Err(ByteConversionError::ToSliceTooSmall {
found: buf.len(),
expected: 8,
});
}
buf[0..4].copy_from_slice(&self.target_id.to_be_bytes());
buf[4..8].copy_from_slice(&self.unique_id.to_be_bytes());
Ok(8)
}
}
/// Generic trait for object which can receive any telecommands in form of a raw bytestream, with /// Generic trait for object which can receive any telecommands in form of a raw bytestream, with
/// no assumptions about the received protocol. /// no assumptions about the received protocol.
/// ///

1
satrs-example/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/output.log

View File

@ -17,6 +17,7 @@ zerocopy = "0.6"
csv = "1" csv = "1"
num_enum = "0.7" num_enum = "0.7"
thiserror = "1" thiserror = "1"
derive-new = "0.5"
[dependencies.satrs-core] [dependencies.satrs-core]
# version = "0.1.0-alpha.1" # version = "0.1.0-alpha.1"

View File

@ -1,4 +1,37 @@
use derive_new::new;
use satrs_core::spacepackets::ByteConversionError;
#[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum AcsHkIds { pub enum AcsHkIds {
TestMgmSet = 1, TestMgmSet = 1,
} }
#[derive(Debug, new, Copy, Clone)]
pub struct HkUniqueId {
target_id: u32,
set_id: u32,
}
impl HkUniqueId {
#[allow(dead_code)]
pub fn target_id(&self) -> u32 {
self.target_id
}
#[allow(dead_code)]
pub fn set_id(&self) -> u32 {
self.set_id
}
pub fn write_to_be_bytes(&self, buf: &mut [u8]) -> Result<usize, ByteConversionError> {
if buf.len() < 8 {
return Err(ByteConversionError::ToSliceTooSmall {
found: buf.len(),
expected: 8,
});
}
buf[0..4].copy_from_slice(&self.target_id.to_be_bytes());
buf[4..8].copy_from_slice(&self.set_id.to_be_bytes());
Ok(8)
}
}

View File

@ -1,11 +1,68 @@
use derive_new::new;
use num_enum::{IntoPrimitive, TryFromPrimitive}; use num_enum::{IntoPrimitive, TryFromPrimitive};
use satrs_core::events::{EventU32TypedSev, SeverityInfo}; use satrs_core::events::{EventU32TypedSev, SeverityInfo};
use satrs_core::objects::ObjectId; use satrs_core::objects::ObjectId;
use satrs_core::spacepackets::ecss::tc::IsPusTelecommand;
use satrs_core::spacepackets::ecss::PusPacket;
use satrs_core::spacepackets::{ByteConversionError, CcsdsPacket};
use satrs_core::tmtc::TargetId;
use std::fmt;
use std::net::Ipv4Addr; use std::net::Ipv4Addr;
use thiserror::Error;
use satrs_mib::res_code::{ResultU16, ResultU16Info}; use satrs_mib::res_code::{ResultU16, ResultU16Info};
use satrs_mib::resultcode; use satrs_mib::resultcode;
pub type Apid = u16;
#[derive(Debug, Error)]
pub enum TargetIdCreationError {
#[error("byte conversion")]
ByteConversion(#[from] ByteConversionError),
#[error("not enough app data to generate target ID")]
NotEnoughAppData(usize),
}
// TODO: can these stay pub?
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, new)]
pub struct TargetIdWithApid {
pub apid: Apid,
pub target: TargetId,
}
impl fmt::Display for TargetIdWithApid {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}, {}", self.apid, self.target)
}
}
impl TargetIdWithApid {
pub fn apid(&self) -> Apid {
self.apid
}
pub fn target_id(&self) -> TargetId {
self.target
}
}
impl TargetIdWithApid {
pub fn from_tc(
tc: &(impl CcsdsPacket + PusPacket + IsPusTelecommand),
) -> Result<Self, TargetIdCreationError> {
if tc.user_data().len() < 4 {
return Err(ByteConversionError::FromSliceTooSmall {
found: tc.user_data().len(),
expected: 8,
}
.into());
}
Ok(Self {
apid: tc.apid(),
target: u32::from_be_bytes(tc.user_data()[0..4].try_into().unwrap()),
})
}
}
pub const PUS_APID: u16 = 0x02; pub const PUS_APID: u16 = 0x02;
#[derive(Copy, Clone, PartialEq, Eq, Debug, TryFromPrimitive, IntoPrimitive)] #[derive(Copy, Clone, PartialEq, Eq, Debug, TryFromPrimitive, IntoPrimitive)]
@ -20,6 +77,8 @@ pub enum RequestTargetId {
AcsSubsystem = 1, AcsSubsystem = 1,
} }
pub const AOCS_APID: u16 = 1;
pub const ACS_OBJECT_ID: ObjectId = ObjectId { pub const ACS_OBJECT_ID: ObjectId = ObjectId {
id: RequestTargetId::AcsSubsystem as u32, id: RequestTargetId::AcsSubsystem as u32,
name: "ACS_SUBSYSTEM", name: "ACS_SUBSYSTEM",

View File

@ -4,13 +4,14 @@ pub fn setup_logger() -> Result<(), fern::InitError> {
out.finish(format_args!( out.finish(format_args!(
"{}[{}][{}] {}", "{}[{}][{}] {}",
chrono::Local::now().format("[%Y-%m-%d][%H:%M:%S]"), chrono::Local::now().format("[%Y-%m-%d][%H:%M:%S]"),
record.target(), //(std::thread::current().name().expect("unnamed_thread"), std::thread::current().name().expect("unnamed_thread"),
record.level(), record.level(),
message message
)) ))
}) })
.level(log::LevelFilter::Debug) .level(log::LevelFilter::Debug)
.chain(std::io::stdout()) .chain(std::io::stdout())
.chain(fern::log_file("output.log")?)
.apply()?; .apply()?;
Ok(()) Ok(())
} }

View File

@ -1,6 +1,6 @@
mod ccsds; mod ccsds;
mod hk; mod hk;
mod logging; mod logger;
mod pus; mod pus;
mod requests; mod requests;
mod tcp; mod tcp;
@ -12,8 +12,8 @@ use satrs_core::hal::std::tcp_server::ServerConfig;
use satrs_core::hal::std::udp_server::UdpTcServer; use satrs_core::hal::std::udp_server::UdpTcServer;
use crate::ccsds::CcsdsReceiver; use crate::ccsds::CcsdsReceiver;
use crate::hk::AcsHkIds; use crate::hk::{AcsHkIds, HkUniqueId};
use crate::logging::setup_logger; use crate::logger::setup_logger;
use crate::pus::action::{Pus8Wrapper, PusService8ActionHandler}; use crate::pus::action::{Pus8Wrapper, PusService8ActionHandler};
use crate::pus::event::Pus5Wrapper; use crate::pus::event::Pus5Wrapper;
use crate::pus::hk::{Pus3Wrapper, PusService3HkHandler}; use crate::pus::hk::{Pus3Wrapper, PusService3HkHandler};
@ -42,7 +42,7 @@ 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::{MpscTcInStoreReceiver, MpscTmInStoreSender}; use satrs_core::pus::{EcssTcInStoreConverter, MpscTcInStoreReceiver, MpscTmInStoreSender};
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::{
@ -50,10 +50,11 @@ use satrs_core::spacepackets::{
SpHeader, SpHeader,
}; };
use satrs_core::tmtc::tm_helper::SharedTmStore; use satrs_core::tmtc::tm_helper::SharedTmStore;
use satrs_core::tmtc::{AddressableId, CcsdsDistributor, TargetId}; use satrs_core::tmtc::{CcsdsDistributor, TargetId};
use satrs_core::ChannelId; use satrs_core::ChannelId;
use satrs_example::{ use satrs_example::{
RequestTargetId, TcReceiverId, TmSenderId, OBSW_SERVER_ADDR, PUS_APID, SERVER_PORT, RequestTargetId, TargetIdWithApid, TcReceiverId, TmSenderId, OBSW_SERVER_ADDR, PUS_APID,
SERVER_PORT,
}; };
use std::collections::HashMap; use std::collections::HashMap;
use std::net::{IpAddr, SocketAddr}; use std::net::{IpAddr, SocketAddr};
@ -131,7 +132,8 @@ fn main() {
// Some request are targetable. This map is used to retrieve sender handles based on a target ID. // Some request are targetable. This map is used to retrieve sender handles based on a target ID.
let mut request_map = HashMap::new(); let mut request_map = HashMap::new();
let (acs_thread_tx, acs_thread_rx) = channel::<RequestWithToken>(); let (acs_thread_tx, acs_thread_rx) = channel::<RequestWithToken>();
request_map.insert(RequestTargetId::AcsSubsystem as TargetId, acs_thread_tx); let target_apid = TargetIdWithApid::new(PUS_APID, RequestTargetId::AcsSubsystem as TargetId);
request_map.insert(target_apid, acs_thread_tx);
let tc_source_wrapper = PusTcSource { let tc_source_wrapper = PusTcSource {
tc_store: tc_store.clone(), tc_store: tc_store.clone(),
@ -177,10 +179,10 @@ fn main() {
); );
let pus17_handler = PusService17TestHandler::new( let pus17_handler = PusService17TestHandler::new(
Box::new(test_srv_receiver), Box::new(test_srv_receiver),
tc_store.pool.clone(),
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),
); );
let mut pus_17_wrapper = Service17CustomWrapper { let mut pus_17_wrapper = Service17CustomWrapper {
pus17_handler, pus17_handler,
@ -202,10 +204,11 @@ fn main() {
.expect("Creating PUS Scheduler failed"); .expect("Creating PUS Scheduler failed");
let pus_11_handler = PusService11SchedHandler::new( let pus_11_handler = PusService11SchedHandler::new(
Box::new(sched_srv_receiver), Box::new(sched_srv_receiver),
tc_store.pool.clone(),
Box::new(sched_srv_tm_sender), Box::new(sched_srv_tm_sender),
PUS_APID, PUS_APID,
verif_reporter.clone(), verif_reporter.clone(),
EcssTcInStoreConverter::new(tc_store.pool.clone(), 2048),
tc_store.pool.clone(),
scheduler, scheduler,
); );
let mut pus_11_wrapper = Pus11Wrapper { let mut pus_11_wrapper = Pus11Wrapper {
@ -226,10 +229,10 @@ fn main() {
); );
let pus_5_handler = PusService5EventHandler::new( let pus_5_handler = PusService5EventHandler::new(
Box::new(event_srv_receiver), Box::new(event_srv_receiver),
tc_store.pool.clone(),
Box::new(event_srv_tm_sender), Box::new(event_srv_tm_sender),
PUS_APID, PUS_APID,
verif_reporter.clone(), verif_reporter.clone(),
EcssTcInStoreConverter::new(tc_store.pool.clone(), 2048),
event_request_tx, event_request_tx,
); );
let mut pus_5_wrapper = Pus5Wrapper { pus_5_handler }; let mut pus_5_wrapper = Pus5Wrapper { pus_5_handler };
@ -247,10 +250,10 @@ fn main() {
); );
let pus_8_handler = PusService8ActionHandler::new( let pus_8_handler = PusService8ActionHandler::new(
Box::new(action_srv_receiver), Box::new(action_srv_receiver),
tc_store.pool.clone(),
Box::new(action_srv_tm_sender), Box::new(action_srv_tm_sender),
PUS_APID, PUS_APID,
verif_reporter.clone(), verif_reporter.clone(),
EcssTcInStoreConverter::new(tc_store.pool.clone(), 2048),
request_map.clone(), request_map.clone(),
); );
let mut pus_8_wrapper = Pus8Wrapper { pus_8_handler }; let mut pus_8_wrapper = Pus8Wrapper { pus_8_handler };
@ -265,10 +268,10 @@ fn main() {
MpscTcInStoreReceiver::new(TcReceiverId::PusHk as ChannelId, "PUS_8_TC_RECV", pus_hk_rx); MpscTcInStoreReceiver::new(TcReceiverId::PusHk as ChannelId, "PUS_8_TC_RECV", pus_hk_rx);
let pus_3_handler = PusService3HkHandler::new( let pus_3_handler = PusService3HkHandler::new(
Box::new(hk_srv_receiver), Box::new(hk_srv_receiver),
tc_store.pool.clone(),
Box::new(hk_srv_tm_sender), Box::new(hk_srv_tm_sender),
PUS_APID, PUS_APID,
verif_reporter.clone(), verif_reporter.clone(),
EcssTcInStoreConverter::new(tc_store.pool.clone(), 2048),
request_map, request_map,
); );
let mut pus_3_wrapper = Pus3Wrapper { pus_3_handler }; let mut pus_3_wrapper = Pus3Wrapper { pus_3_handler };
@ -440,9 +443,13 @@ fn main() {
match request.targeted_request.request { match request.targeted_request.request {
Request::Hk(hk_req) => match hk_req { Request::Hk(hk_req) => match hk_req {
HkRequest::OneShot(unique_id) => { HkRequest::OneShot(unique_id) => {
// TODO: We should check whether the unique ID is even valid.
let target = request.targeted_request.target_id; let target = request.targeted_request.target_id;
assert_eq!(target, RequestTargetId::AcsSubsystem as u32); assert_eq!(
if request.targeted_request.target_id target.target_id(),
RequestTargetId::AcsSubsystem as u32
);
if request.targeted_request.target_id.target
== AcsHkIds::TestMgmSet as u32 == AcsHkIds::TestMgmSet as u32
{ {
let mut sp_header = SpHeader::tm( let mut sp_header = SpHeader::tm(
@ -458,11 +465,8 @@ fn main() {
&timestamp, &timestamp,
); );
let mut buf: [u8; 8] = [0; 8]; let mut buf: [u8; 8] = [0; 8];
let addressable_id = AddressableId { let hk_id = HkUniqueId::new(target.target_id(), unique_id);
target_id: target, hk_id.write_to_be_bytes(&mut buf).unwrap();
unique_id,
};
addressable_id.write_to_be_bytes(&mut buf).unwrap();
let pus_tm = PusTmCreator::new( let pus_tm = PusTmCreator::new(
&mut sp_header, &mut sp_header,
sec_header, sec_header,

View File

@ -1,47 +1,44 @@
use crate::requests::{ActionRequest, Request, RequestWithToken}; use crate::requests::{ActionRequest, Request, RequestWithToken};
use log::{error, warn}; use log::{error, warn};
use satrs_core::pool::SharedPool;
use satrs_core::pus::verification::{ use satrs_core::pus::verification::{
FailParams, StdVerifReporterWithSender, TcStateAccepted, VerificationToken, FailParams, TcStateAccepted, VerificationReporterWithSender, VerificationToken,
}; };
use satrs_core::pus::{ use satrs_core::pus::{
EcssTcReceiver, EcssTmSender, PusPacketHandlerResult, PusPacketHandlingError, PusServiceHandler, EcssTcInMemConverter, EcssTcInStoreConverter, EcssTcReceiver, EcssTmSender,
PusPacketHandlerResult, PusPacketHandlingError, PusServiceBase, PusServiceHandler,
}; };
use satrs_core::spacepackets::ecss::tc::PusTcReader; use satrs_core::spacepackets::ecss::tc::PusTcReader;
use satrs_core::spacepackets::ecss::PusPacket; use satrs_core::spacepackets::ecss::PusPacket;
use satrs_core::tmtc::TargetId; use satrs_example::{tmtc_err, TargetIdWithApid};
use satrs_example::tmtc_err;
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::mpsc::Sender; use std::sync::mpsc::Sender;
pub struct PusService8ActionHandler { pub struct PusService8ActionHandler<TcInMemConverter: EcssTcInMemConverter> {
psb: PusServiceHandler, psb: PusServiceHandler<TcInMemConverter>,
request_handlers: HashMap<TargetId, Sender<RequestWithToken>>, request_handlers: HashMap<TargetIdWithApid, Sender<RequestWithToken>>,
} }
impl PusService8ActionHandler { impl<TcInMemConverter: EcssTcInMemConverter> PusService8ActionHandler<TcInMemConverter> {
pub fn new( pub fn new(
tc_receiver: Box<dyn EcssTcReceiver>, tc_receiver: Box<dyn EcssTcReceiver>,
shared_tc_pool: SharedPool,
tm_sender: Box<dyn EcssTmSender>, tm_sender: Box<dyn EcssTmSender>,
tm_apid: u16, tm_apid: u16,
verification_handler: VerificationReporterWithSender, verification_handler: VerificationReporterWithSender,
request_handlers: HashMap<TargetId, Sender<RequestWithToken>>, tc_in_mem_converter: TcInMemConverter,
request_handlers: HashMap<TargetIdWithApid, Sender<RequestWithToken>>,
) -> Self { ) -> Self {
Self { Self {
psb: PusServiceHandler::new( psb: PusServiceHandler::new(
tc_receiver, tc_receiver,
shared_tc_pool,
tm_sender, tm_sender,
tm_apid, tm_apid,
verification_handler, verification_handler,
tc_in_mem_converter,
), ),
request_handlers, request_handlers,
} }
} }
}
impl PusService8ActionHandler {
fn handle_action_request_with_id( fn handle_action_request_with_id(
&self, &self,
token: VerificationToken<TcStateAccepted>, token: VerificationToken<TcStateAccepted>,
@ -51,6 +48,7 @@ impl PusService8ActionHandler {
let user_data = tc.user_data(); let user_data = tc.user_data();
if user_data.len() < 8 { if user_data.len() < 8 {
self.psb self.psb
.common
.verification_handler .verification_handler
.borrow_mut() .borrow_mut()
.start_failure( .start_failure(
@ -62,7 +60,8 @@ impl PusService8ActionHandler {
"Expected at least 4 bytes".into(), "Expected at least 4 bytes".into(),
)); ));
} }
let target_id = u32::from_be_bytes(user_data[0..4].try_into().unwrap()); //let target_id = u32::from_be_bytes(user_data[0..4].try_into().unwrap());
let target_id = TargetIdWithApid::from_tc(tc).unwrap();
let action_id = u32::from_be_bytes(user_data[4..8].try_into().unwrap()); let action_id = u32::from_be_bytes(user_data[4..8].try_into().unwrap());
if let Some(sender) = self.request_handlers.get(&target_id) { if let Some(sender) = self.request_handlers.get(&target_id) {
sender sender
@ -77,8 +76,9 @@ impl PusService8ActionHandler {
.expect("Forwarding action request failed"); .expect("Forwarding action request failed");
} else { } else {
let mut fail_data: [u8; 4] = [0; 4]; let mut fail_data: [u8; 4] = [0; 4];
fail_data.copy_from_slice(&target_id.to_be_bytes()); fail_data.copy_from_slice(&target_id.target.to_be_bytes());
self.psb self.psb
.common
.verification_handler .verification_handler
.borrow_mut() .borrow_mut()
.start_failure( .start_failure(
@ -104,11 +104,12 @@ impl PusService8ActionHandler {
} }
let ecss_tc_and_token = possible_packet.unwrap(); let ecss_tc_and_token = possible_packet.unwrap();
self.psb self.psb
.convert_possible_packet_to_tc_buf(&ecss_tc_and_token)?; .tc_in_mem_converter
let (tc, _) = PusTcReader::new(&self.psb.pus_buf).unwrap(); .cache_ecss_tc_in_memory(&ecss_tc_and_token)?;
let tc = PusTcReader::new(self.psb.tc_in_mem_converter.tc_slice_raw())?.0;
let subservice = tc.subservice(); let subservice = tc.subservice();
let mut partial_error = None; let mut partial_error = None;
let time_stamp = self.psb.get_current_timestamp(&mut partial_error); let time_stamp = PusServiceBase::get_current_timestamp(&mut partial_error);
match subservice { match subservice {
128 => { 128 => {
self.handle_action_request_with_id(ecss_tc_and_token.token, &tc, &time_stamp)?; self.handle_action_request_with_id(ecss_tc_and_token.token, &tc, &time_stamp)?;
@ -116,6 +117,7 @@ impl PusService8ActionHandler {
_ => { _ => {
let fail_data = [subservice]; let fail_data = [subservice];
self.psb self.psb
.common
.verification_handler .verification_handler
.get_mut() .get_mut()
.start_failure( .start_failure(
@ -140,7 +142,7 @@ impl PusService8ActionHandler {
} }
pub struct Pus8Wrapper { pub struct Pus8Wrapper {
pub(crate) pus_8_handler: PusService8ActionHandler, pub(crate) pus_8_handler: PusService8ActionHandler<EcssTcInStoreConverter>,
} }
impl Pus8Wrapper { impl Pus8Wrapper {

View File

@ -1,9 +1,9 @@
use log::{error, warn}; use log::{error, warn};
use satrs_core::pus::event_srv::PusService5EventHandler; use satrs_core::pus::event_srv::PusService5EventHandler;
use satrs_core::pus::PusPacketHandlerResult; use satrs_core::pus::{EcssTcInStoreConverter, PusPacketHandlerResult};
pub struct Pus5Wrapper { pub struct Pus5Wrapper {
pub pus_5_handler: PusService5EventHandler, pub pus_5_handler: PusService5EventHandler<EcssTcInStoreConverter>,
} }
impl Pus5Wrapper { impl Pus5Wrapper {

View File

@ -1,39 +1,37 @@
use crate::requests::{Request, RequestWithToken}; use crate::requests::{Request, RequestWithToken};
use log::{error, warn}; use log::{error, warn};
use satrs_core::hk::{CollectionIntervalFactor, HkRequest}; use satrs_core::hk::{CollectionIntervalFactor, HkRequest};
use satrs_core::pool::SharedPool;
use satrs_core::pus::verification::{FailParams, StdVerifReporterWithSender}; use satrs_core::pus::verification::{FailParams, StdVerifReporterWithSender};
use satrs_core::pus::{ use satrs_core::pus::{
EcssTcReceiver, EcssTmSender, PusPacketHandlerResult, PusPacketHandlingError, PusServiceHandler, EcssTcInMemConverter, EcssTcInStoreConverter, EcssTcReceiver, EcssTmSender,
PusPacketHandlerResult, PusPacketHandlingError, PusServiceBase, PusServiceHandler,
}; };
use satrs_core::spacepackets::ecss::tc::PusTcReader;
use satrs_core::spacepackets::ecss::{hk, PusPacket}; use satrs_core::spacepackets::ecss::{hk, PusPacket};
use satrs_core::tmtc::{AddressableId, TargetId}; use satrs_example::{hk_err, tmtc_err, TargetIdWithApid};
use satrs_example::{hk_err, tmtc_err};
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::mpsc::Sender; use std::sync::mpsc::Sender;
pub struct PusService3HkHandler { pub struct PusService3HkHandler<TcInMemConverter: EcssTcInMemConverter> {
psb: PusServiceHandler, psb: PusServiceHandler<TcInMemConverter>,
request_handlers: HashMap<TargetId, Sender<RequestWithToken>>, request_handlers: HashMap<TargetIdWithApid, Sender<RequestWithToken>>,
} }
impl PusService3HkHandler { impl<TcInMemConverter: EcssTcInMemConverter> PusService3HkHandler<TcInMemConverter> {
pub fn new( pub fn new(
tc_receiver: Box<dyn EcssTcReceiver>, tc_receiver: Box<dyn EcssTcReceiver>,
shared_tc_pool: SharedPool,
tm_sender: Box<dyn EcssTmSender>, tm_sender: Box<dyn EcssTmSender>,
tm_apid: u16, tm_apid: u16,
verification_handler: StdVerifReporterWithSender, verification_handler: StdVerifReporterWithSender,
request_handlers: HashMap<TargetId, Sender<RequestWithToken>>, tc_in_mem_converter: TcInMemConverter,
request_handlers: HashMap<TargetIdWithApid, Sender<RequestWithToken>>,
) -> Self { ) -> Self {
Self { Self {
psb: PusServiceHandler::new( psb: PusServiceHandler::new(
tc_receiver, tc_receiver,
shared_tc_pool,
tm_sender, tm_sender,
tm_apid, tm_apid,
verification_handler, verification_handler,
tc_in_mem_converter,
), ),
request_handlers, request_handlers,
} }
@ -45,15 +43,17 @@ impl PusService3HkHandler {
return Ok(PusPacketHandlerResult::Empty); return Ok(PusPacketHandlerResult::Empty);
} }
let ecss_tc_and_token = possible_packet.unwrap(); let ecss_tc_and_token = possible_packet.unwrap();
self.psb let tc = self
.convert_possible_packet_to_tc_buf(&ecss_tc_and_token)?; .psb
let (tc, _) = PusTcReader::new(&self.psb.pus_buf).unwrap(); .tc_in_mem_converter
.convert_ecss_tc_in_memory_to_reader(&ecss_tc_and_token)?;
let subservice = tc.subservice(); let subservice = tc.subservice();
let mut partial_error = None; let mut partial_error = None;
let time_stamp = self.psb.get_current_timestamp(&mut partial_error); let time_stamp = PusServiceBase::get_current_timestamp(&mut partial_error);
let user_data = tc.user_data(); let user_data = tc.user_data();
if user_data.is_empty() { if user_data.is_empty() {
self.psb self.psb
.common
.verification_handler .verification_handler
.borrow_mut() .borrow_mut()
.start_failure( .start_failure(
@ -72,6 +72,7 @@ impl PusService3HkHandler {
&hk_err::UNIQUE_ID_MISSING &hk_err::UNIQUE_ID_MISSING
}; };
self.psb self.psb
.common
.verification_handler .verification_handler
.borrow_mut() .borrow_mut()
.start_failure( .start_failure(
@ -83,12 +84,11 @@ impl PusService3HkHandler {
"Expected at least 8 bytes of app data".into(), "Expected at least 8 bytes of app data".into(),
)); ));
} }
let addressable_id = AddressableId::from_raw_be(user_data).unwrap(); let target_id = TargetIdWithApid::from_tc(&tc).expect("invalid tc format");
if !self let unique_id = u32::from_be_bytes(tc.user_data()[0..4].try_into().unwrap());
.request_handlers if !self.request_handlers.contains_key(&target_id) {
.contains_key(&addressable_id.target_id)
{
self.psb self.psb
.common
.verification_handler .verification_handler
.borrow_mut() .borrow_mut()
.start_failure( .start_failure(
@ -96,16 +96,12 @@ impl PusService3HkHandler {
FailParams::new(Some(&time_stamp), &hk_err::UNKNOWN_TARGET_ID, None), FailParams::new(Some(&time_stamp), &hk_err::UNKNOWN_TARGET_ID, None),
) )
.expect("Sending start failure TM failed"); .expect("Sending start failure TM failed");
let tgt_id = addressable_id.target_id;
return Err(PusPacketHandlingError::NotEnoughAppData(format!( return Err(PusPacketHandlingError::NotEnoughAppData(format!(
"Unknown target ID {tgt_id}" "Unknown target ID {target_id}"
))); )));
} }
let send_request = |target: TargetId, request: HkRequest| { let send_request = |target: TargetIdWithApid, request: HkRequest| {
let sender = self let sender = self.request_handlers.get(&target).unwrap();
.request_handlers
.get(&addressable_id.target_id)
.unwrap();
sender sender
.send(RequestWithToken::new( .send(RequestWithToken::new(
target, target,
@ -115,23 +111,15 @@ impl PusService3HkHandler {
.unwrap_or_else(|_| panic!("Sending HK request {request:?} failed")); .unwrap_or_else(|_| panic!("Sending HK request {request:?} failed"));
}; };
if subservice == hk::Subservice::TcEnableHkGeneration as u8 { if subservice == hk::Subservice::TcEnableHkGeneration as u8 {
send_request( send_request(target_id, HkRequest::Enable(unique_id));
addressable_id.target_id,
HkRequest::Enable(addressable_id.unique_id),
);
} else if subservice == hk::Subservice::TcDisableHkGeneration as u8 { } else if subservice == hk::Subservice::TcDisableHkGeneration as u8 {
send_request( send_request(target_id, HkRequest::Disable(unique_id));
addressable_id.target_id,
HkRequest::Disable(addressable_id.unique_id),
);
} else if subservice == hk::Subservice::TcGenerateOneShotHk as u8 { } else if subservice == hk::Subservice::TcGenerateOneShotHk as u8 {
send_request( send_request(target_id, HkRequest::OneShot(unique_id));
addressable_id.target_id,
HkRequest::OneShot(addressable_id.unique_id),
);
} else if subservice == hk::Subservice::TcModifyHkCollectionInterval as u8 { } else if subservice == hk::Subservice::TcModifyHkCollectionInterval as u8 {
if user_data.len() < 12 { if user_data.len() < 12 {
self.psb self.psb
.common
.verification_handler .verification_handler
.borrow_mut() .borrow_mut()
.start_failure( .start_failure(
@ -148,9 +136,9 @@ impl PusService3HkHandler {
)); ));
} }
send_request( send_request(
addressable_id.target_id, target_id,
HkRequest::ModifyCollectionInterval( HkRequest::ModifyCollectionInterval(
addressable_id.unique_id, unique_id,
CollectionIntervalFactor::from_be_bytes(user_data[8..12].try_into().unwrap()), CollectionIntervalFactor::from_be_bytes(user_data[8..12].try_into().unwrap()),
), ),
); );
@ -160,7 +148,7 @@ impl PusService3HkHandler {
} }
pub struct Pus3Wrapper { pub struct Pus3Wrapper {
pub(crate) pus_3_handler: PusService3HkHandler, pub(crate) pus_3_handler: PusService3HkHandler<EcssTcInStoreConverter>,
} }
impl Pus3Wrapper { impl Pus3Wrapper {

View File

@ -2,10 +2,10 @@ use crate::tmtc::PusTcSource;
use log::{error, info, warn}; use log::{error, info, warn};
use satrs_core::pus::scheduler::TcInfo; use satrs_core::pus::scheduler::TcInfo;
use satrs_core::pus::scheduler_srv::PusService11SchedHandler; use satrs_core::pus::scheduler_srv::PusService11SchedHandler;
use satrs_core::pus::PusPacketHandlerResult; use satrs_core::pus::{EcssTcInStoreConverter, PusPacketHandlerResult};
pub struct Pus11Wrapper { pub struct Pus11Wrapper {
pub pus_11_handler: PusService11SchedHandler, pub pus_11_handler: PusService11SchedHandler<EcssTcInStoreConverter>,
pub tc_source_wrapper: PusTcSource, pub tc_source_wrapper: PusTcSource,
} }

View File

@ -1,18 +1,18 @@
use log::{info, warn}; use log::{info, warn};
use satrs_core::events::EventU32;
use satrs_core::params::Params; use satrs_core::params::Params;
use satrs_core::pus::test::PusService17TestHandler; use satrs_core::pus::test::PusService17TestHandler;
use satrs_core::pus::verification::FailParams; use satrs_core::pus::verification::FailParams;
use satrs_core::pus::PusPacketHandlerResult; use satrs_core::pus::{EcssTcInMemConverter, PusPacketHandlerResult};
use satrs_core::spacepackets::ecss::tc::PusTcReader; use satrs_core::spacepackets::ecss::tc::PusTcReader;
use satrs_core::spacepackets::ecss::PusPacket; use satrs_core::spacepackets::ecss::PusPacket;
use satrs_core::spacepackets::time::cds::TimeProvider; use satrs_core::spacepackets::time::cds::TimeProvider;
use satrs_core::spacepackets::time::TimeWriter; use satrs_core::spacepackets::time::TimeWriter;
use satrs_core::{events::EventU32, pus::EcssTcInStoreConverter};
use satrs_example::{tmtc_err, TEST_EVENT}; use satrs_example::{tmtc_err, TEST_EVENT};
use std::sync::mpsc::Sender; use std::sync::mpsc::Sender;
pub struct Service17CustomWrapper { pub struct Service17CustomWrapper {
pub pus17_handler: PusService17TestHandler, pub pus17_handler: PusService17TestHandler<EcssTcInStoreConverter>,
pub test_srv_event_sender: Sender<(EventU32, Option<Params>)>, pub test_srv_event_sender: Sender<(EventU32, Option<Params>)>,
} }
@ -38,9 +38,9 @@ impl Service17CustomWrapper {
warn!("PUS17: Subservice {subservice} not implemented") warn!("PUS17: Subservice {subservice} not implemented")
} }
PusPacketHandlerResult::CustomSubservice(subservice, token) => { PusPacketHandlerResult::CustomSubservice(subservice, token) => {
let psb_mut = &mut self.pus17_handler.psb; let (tc, _) =
let buf = psb_mut.pus_buf; PusTcReader::new(self.pus17_handler.psb.tc_in_mem_converter.tc_slice_raw())
let (tc, _) = PusTcReader::new(&buf).unwrap(); .unwrap();
let time_stamper = TimeProvider::from_now_with_u16_days().unwrap(); let time_stamper = TimeProvider::from_now_with_u16_days().unwrap();
let mut stamp_buf: [u8; 7] = [0; 7]; let mut stamp_buf: [u8; 7] = [0; 7];
time_stamper.write_to_bytes(&mut stamp_buf).unwrap(); time_stamper.write_to_bytes(&mut stamp_buf).unwrap();
@ -49,12 +49,17 @@ impl Service17CustomWrapper {
self.test_srv_event_sender self.test_srv_event_sender
.send((TEST_EVENT.into(), None)) .send((TEST_EVENT.into(), None))
.expect("Sending test event failed"); .expect("Sending test event failed");
let start_token = psb_mut let start_token = self
.pus17_handler
.psb
.common
.verification_handler .verification_handler
.get_mut() .get_mut()
.start_success(token.into(), Some(&stamp_buf)) .start_success(token, Some(&stamp_buf))
.expect("Error sending start success"); .expect("Error sending start success");
psb_mut self.pus17_handler
.psb
.common
.verification_handler .verification_handler
.get_mut() .get_mut()
.completion_success(start_token, Some(&stamp_buf)) .completion_success(start_token, Some(&stamp_buf))
@ -63,6 +68,7 @@ impl Service17CustomWrapper {
let fail_data = [tc.subservice()]; let fail_data = [tc.subservice()];
self.pus17_handler self.pus17_handler
.psb .psb
.common
.verification_handler .verification_handler
.get_mut() .get_mut()
.start_failure( .start_failure(

View File

@ -1,7 +1,8 @@
use derive_new::new;
use satrs_core::hk::HkRequest; use satrs_core::hk::HkRequest;
use satrs_core::mode::ModeRequest; use satrs_core::mode::ModeRequest;
use satrs_core::pus::verification::{TcStateAccepted, VerificationToken}; use satrs_core::pus::verification::{TcStateAccepted, VerificationToken};
use satrs_core::tmtc::TargetId; use satrs_example::TargetIdWithApid;
#[allow(dead_code)] #[allow(dead_code)]
#[derive(Clone, Eq, PartialEq, Debug)] #[derive(Clone, Eq, PartialEq, Debug)]
@ -19,18 +20,12 @@ pub enum Request {
Action(ActionRequest), Action(ActionRequest),
} }
#[derive(Clone, Eq, PartialEq, Debug)] #[derive(Clone, Eq, PartialEq, Debug, new)]
pub struct TargetedRequest { pub struct TargetedRequest {
pub(crate) target_id: TargetId, pub(crate) target_id: TargetIdWithApid,
pub(crate) request: Request, pub(crate) request: Request,
} }
impl TargetedRequest {
pub fn new(target_id: TargetId, request: Request) -> Self {
Self { target_id, request }
}
}
#[derive(Clone, Eq, PartialEq, Debug)] #[derive(Clone, Eq, PartialEq, Debug)]
pub struct RequestWithToken { pub struct RequestWithToken {
pub(crate) targeted_request: TargetedRequest, pub(crate) targeted_request: TargetedRequest,
@ -39,7 +34,7 @@ pub struct RequestWithToken {
impl RequestWithToken { impl RequestWithToken {
pub fn new( pub fn new(
target_id: u32, target_id: TargetIdWithApid,
request: Request, request: Request,
token: VerificationToken<TcStateAccepted>, token: VerificationToken<TcStateAccepted>,
) -> Self { ) -> Self {