This commit is contained in:
parent
b45a219c6d
commit
fd950c5a94
@ -25,7 +25,7 @@ path = "../satrs"
|
||||
|
||||
[dependencies.satrs-mib]
|
||||
version = "0.1.1"
|
||||
# path = "../satrs-mib"
|
||||
path = "../satrs-mib"
|
||||
|
||||
[features]
|
||||
dyn_tmtc = []
|
||||
|
@ -9,7 +9,7 @@ use satrs::{
|
||||
hk::HkRequest,
|
||||
spacepackets::{
|
||||
ecss::tm::{PusTmCreator, PusTmSecondaryHeader},
|
||||
time::cds::{DaysLen16Bits, TimeProvider},
|
||||
time::cds::{DaysLen16Bits, CdsTime},
|
||||
SequenceFlags, SpHeader,
|
||||
},
|
||||
};
|
||||
@ -23,7 +23,7 @@ use crate::{
|
||||
|
||||
pub struct AcsTask<VerificationReporter: VerificationReportingProvider> {
|
||||
timestamp: [u8; 7],
|
||||
time_provider: TimeProvider<DaysLen16Bits>,
|
||||
time_provider: CdsTime<DaysLen16Bits>,
|
||||
verif_reporter: VerificationReporter,
|
||||
tm_sender: Box<dyn EcssTmSender>,
|
||||
request_rx: mpsc::Receiver<RequestWithToken>,
|
||||
@ -37,7 +37,7 @@ impl<VerificationReporter: VerificationReportingProvider> AcsTask<VerificationRe
|
||||
) -> Self {
|
||||
Self {
|
||||
timestamp: [0; 7],
|
||||
time_provider: TimeProvider::new_with_u16_days(0, 0),
|
||||
time_provider: CdsTime::new_with_u16_days(0, 0),
|
||||
verif_reporter,
|
||||
tm_sender: Box::new(tm_sender),
|
||||
request_rx,
|
||||
|
@ -14,7 +14,7 @@ use satrs::{
|
||||
verification::{TcStateStarted, VerificationReportingProvider, VerificationToken},
|
||||
EcssTmSender,
|
||||
},
|
||||
spacepackets::time::cds::{self, TimeProvider},
|
||||
spacepackets::time::cds::{self, CdsTime},
|
||||
};
|
||||
use satrs_example::config::PUS_APID;
|
||||
|
||||
@ -25,7 +25,7 @@ pub struct PusEventHandler<VerificationReporter: VerificationReportingProvider>
|
||||
pus_event_dispatcher: DefaultPusEventU32Dispatcher<()>,
|
||||
pus_event_man_rx: mpsc::Receiver<(EventU32, Option<Params>)>,
|
||||
tm_sender: Box<dyn EcssTmSender>,
|
||||
time_provider: TimeProvider,
|
||||
time_provider: CdsTime,
|
||||
timestamp: [u8; 7],
|
||||
verif_handler: VerificationReporter,
|
||||
}
|
||||
@ -57,7 +57,7 @@ impl<VerificationReporter: VerificationReportingProvider> PusEventHandler<Verifi
|
||||
event_request_rx,
|
||||
pus_event_dispatcher,
|
||||
pus_event_man_rx,
|
||||
time_provider: cds::TimeProvider::new_with_u16_days(0, 0),
|
||||
time_provider: cds::CdsTime::new_with_u16_days(0, 0),
|
||||
timestamp: [0; 7],
|
||||
verif_handler,
|
||||
tm_sender: Box::new(tm_sender),
|
||||
|
@ -45,7 +45,7 @@ use crate::udp::{StaticUdpTmHandler, UdpTmtcServer};
|
||||
use satrs::pus::event_man::EventRequestWithToken;
|
||||
use satrs::pus::verification::{VerificationReporterCfg, VerificationReporterWithSender};
|
||||
use satrs::pus::{EcssTmSender, TmAsVecSenderWithId, TmInSharedPoolSenderWithId};
|
||||
use satrs::spacepackets::{time::cds::TimeProvider, time::TimeWriter};
|
||||
use satrs::spacepackets::{time::cds::CdsTime, time::TimeWriter};
|
||||
use satrs::tmtc::CcsdsDistributor;
|
||||
use satrs::ChannelId;
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
@ -513,7 +513,7 @@ fn main() {
|
||||
dyn_tmtc_pool_main();
|
||||
}
|
||||
|
||||
pub fn update_time(time_provider: &mut TimeProvider, timestamp: &mut [u8]) {
|
||||
pub fn update_time(time_provider: &mut CdsTime, timestamp: &mut [u8]) {
|
||||
time_provider
|
||||
.update_from_now()
|
||||
.expect("Could not get current time");
|
||||
|
@ -6,7 +6,7 @@ use satrs::pus::{
|
||||
};
|
||||
use satrs::spacepackets::ecss::tc::PusTcReader;
|
||||
use satrs::spacepackets::ecss::PusServiceId;
|
||||
use satrs::spacepackets::time::cds::TimeProvider;
|
||||
use satrs::spacepackets::time::cds::CdsTime;
|
||||
use satrs::spacepackets::time::TimeWriter;
|
||||
use satrs_example::config::{tmtc_err, CustomPusServiceId};
|
||||
use std::sync::mpsc::Sender;
|
||||
@ -33,14 +33,14 @@ pub struct PusReceiver<VerificationReporter: VerificationReportingProvider> {
|
||||
}
|
||||
|
||||
struct TimeStampHelper {
|
||||
stamper: TimeProvider,
|
||||
stamper: CdsTime,
|
||||
time_stamp: [u8; 7],
|
||||
}
|
||||
|
||||
impl TimeStampHelper {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
stamper: TimeProvider::new_with_u16_days(0, 0),
|
||||
stamper: CdsTime::new_with_u16_days(0, 0),
|
||||
time_stamp: [0; 7],
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ use satrs::pus::{
|
||||
};
|
||||
use satrs::spacepackets::ecss::tc::PusTcReader;
|
||||
use satrs::spacepackets::ecss::PusPacket;
|
||||
use satrs::spacepackets::time::cds::TimeProvider;
|
||||
use satrs::spacepackets::time::cds::CdsTime;
|
||||
use satrs::spacepackets::time::TimeWriter;
|
||||
use satrs::tmtc::tm_helper::SharedTmPool;
|
||||
use satrs::ChannelId;
|
||||
@ -139,7 +139,7 @@ impl<
|
||||
.tc_slice_raw(),
|
||||
)
|
||||
.unwrap();
|
||||
let time_stamper = TimeProvider::from_now_with_u16_days().unwrap();
|
||||
let time_stamper = CdsTime::now_with_u16_days().unwrap();
|
||||
let mut stamp_buf: [u8; 7] = [0; 7];
|
||||
time_stamper.write_to_bytes(&mut stamp_buf).unwrap();
|
||||
if subservice == 128 {
|
||||
|
@ -23,6 +23,7 @@ version = "1"
|
||||
optional = true
|
||||
|
||||
[dependencies.satrs-shared]
|
||||
path = "../satrs-shared"
|
||||
version = "0.1.2"
|
||||
features = ["serde"]
|
||||
|
||||
|
@ -26,7 +26,10 @@ features = ["full"]
|
||||
|
||||
[dev-dependencies]
|
||||
trybuild = { version = "1", features = ["diff"] }
|
||||
satrs-shared = "0.1.2"
|
||||
|
||||
[dev-dependencies.satrs-shared]
|
||||
version = "0.1.2"
|
||||
path = "../../satrs-shared"
|
||||
|
||||
[dev-dependencies.satrs-mib]
|
||||
path = ".."
|
||||
|
@ -18,7 +18,9 @@ default-features = false
|
||||
optional = true
|
||||
|
||||
[dependencies.spacepackets]
|
||||
version = "0.10"
|
||||
git = "https://egit.irs.uni-stuttgart.de/rust/spacepackets.git"
|
||||
version = "0.11.0-rc.0"
|
||||
branch = "main"
|
||||
default-features = false
|
||||
|
||||
[features]
|
||||
|
@ -17,7 +17,10 @@ delegate = ">0.7, <=0.10"
|
||||
paste = "1"
|
||||
smallvec = "1"
|
||||
crc = "3"
|
||||
satrs-shared = "0.1.2"
|
||||
|
||||
[dependencies.satrs-shared]
|
||||
version = "0.1.2"
|
||||
path = "../satrs-shared"
|
||||
|
||||
[dependencies.num_enum]
|
||||
version = ">0.5, <=0.7"
|
||||
@ -68,7 +71,9 @@ features = ["all"]
|
||||
optional = true
|
||||
|
||||
[dependencies.spacepackets]
|
||||
version = "0.10"
|
||||
git = "https://egit.irs.uni-stuttgart.de/rust/spacepackets.git"
|
||||
version = "0.11.0-rc.0"
|
||||
branch = "main"
|
||||
default-features = false
|
||||
|
||||
[dependencies.cobs]
|
||||
|
@ -2,6 +2,7 @@ use crate::pus::{source_buffer_large_enough, EcssTmtcError};
|
||||
use spacepackets::ecss::tm::PusTmCreator;
|
||||
use spacepackets::ecss::tm::PusTmSecondaryHeader;
|
||||
use spacepackets::ecss::{EcssEnumeration, PusError};
|
||||
use spacepackets::ByteConversionError;
|
||||
use spacepackets::{SpHeader, MAX_APID};
|
||||
|
||||
use crate::pus::EcssTmSenderCore;
|
||||
@ -9,145 +10,125 @@ use crate::pus::EcssTmSenderCore;
|
||||
pub use alloc_mod::EventReporter;
|
||||
pub use spacepackets::ecss::event::*;
|
||||
|
||||
pub struct EventReporterBase {
|
||||
msg_count: u16,
|
||||
pub struct EventReportCreator {
|
||||
apid: u16,
|
||||
pub dest_id: u16,
|
||||
}
|
||||
|
||||
impl EventReporterBase {
|
||||
impl EventReportCreator {
|
||||
pub fn new(apid: u16) -> Option<Self> {
|
||||
if apid > MAX_APID {
|
||||
return None;
|
||||
}
|
||||
Some(Self {
|
||||
msg_count: 0,
|
||||
// msg_count: 0,
|
||||
dest_id: 0,
|
||||
apid,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn event_info(
|
||||
pub fn event_info<'time, 'src_data>(
|
||||
&mut self,
|
||||
buf: &mut [u8],
|
||||
sender: &mut (impl EcssTmSenderCore + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
src_data_buf: &'src_data mut [u8],
|
||||
time_stamp: &'time [u8],
|
||||
event_id: impl EcssEnumeration,
|
||||
aux_data: Option<&[u8]>,
|
||||
) -> Result<(), EcssTmtcError> {
|
||||
aux_data: Option<&'src_data [u8]>,
|
||||
) -> Result<PusTmCreator<'time, 'src_data>, ByteConversionError> {
|
||||
self.generate_and_send_generic_tm(
|
||||
buf,
|
||||
src_data_buf,
|
||||
Subservice::TmInfoReport,
|
||||
sender,
|
||||
time_stamp,
|
||||
event_id,
|
||||
aux_data,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn event_low_severity(
|
||||
pub fn event_low_severity<'time, 'src_data>(
|
||||
&mut self,
|
||||
buf: &mut [u8],
|
||||
sender: &mut (impl EcssTmSenderCore + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
src_data_buf: &'src_data mut [u8],
|
||||
time_stamp: &'time [u8],
|
||||
event_id: impl EcssEnumeration,
|
||||
aux_data: Option<&[u8]>,
|
||||
) -> Result<(), EcssTmtcError> {
|
||||
aux_data: Option<&'src_data [u8]>,
|
||||
) -> Result<PusTmCreator<'time, 'src_data>, ByteConversionError> {
|
||||
self.generate_and_send_generic_tm(
|
||||
buf,
|
||||
src_data_buf,
|
||||
Subservice::TmLowSeverityReport,
|
||||
sender,
|
||||
time_stamp,
|
||||
event_id,
|
||||
aux_data,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn event_medium_severity(
|
||||
pub fn event_medium_severity<'time, 'src_data>(
|
||||
&mut self,
|
||||
buf: &mut [u8],
|
||||
sender: &mut (impl EcssTmSenderCore + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
buf: &'src_data mut [u8],
|
||||
time_stamp: &'time [u8],
|
||||
event_id: impl EcssEnumeration,
|
||||
aux_data: Option<&[u8]>,
|
||||
) -> Result<(), EcssTmtcError> {
|
||||
aux_data: Option<&'src_data [u8]>,
|
||||
) -> Result<PusTmCreator<'time, 'src_data>, ByteConversionError> {
|
||||
self.generate_and_send_generic_tm(
|
||||
buf,
|
||||
Subservice::TmMediumSeverityReport,
|
||||
sender,
|
||||
time_stamp,
|
||||
event_id,
|
||||
aux_data,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn event_high_severity(
|
||||
pub fn event_high_severity<'time, 'src_data>(
|
||||
&mut self,
|
||||
buf: &mut [u8],
|
||||
sender: &mut (impl EcssTmSenderCore + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
src_data_buf: &'src_data mut [u8],
|
||||
time_stamp: &'time [u8],
|
||||
event_id: impl EcssEnumeration,
|
||||
aux_data: Option<&[u8]>,
|
||||
) -> Result<(), EcssTmtcError> {
|
||||
aux_data: Option<&'src_data [u8]>,
|
||||
) -> Result<PusTmCreator<'time, 'src_data>, ByteConversionError> {
|
||||
self.generate_and_send_generic_tm(
|
||||
buf,
|
||||
src_data_buf,
|
||||
Subservice::TmHighSeverityReport,
|
||||
sender,
|
||||
time_stamp,
|
||||
event_id,
|
||||
aux_data,
|
||||
)
|
||||
}
|
||||
|
||||
fn generate_and_send_generic_tm(
|
||||
fn generate_and_send_generic_tm<'time, 'src_data>(
|
||||
&mut self,
|
||||
buf: &mut [u8],
|
||||
src_data_buf: &'src_data mut [u8],
|
||||
subservice: Subservice,
|
||||
sender: &mut (impl EcssTmSenderCore + ?Sized),
|
||||
time_stamp: &[u8],
|
||||
time_stamp: &'time [u8],
|
||||
event_id: impl EcssEnumeration,
|
||||
aux_data: Option<&[u8]>,
|
||||
) -> Result<(), EcssTmtcError> {
|
||||
let tm = self.generate_generic_event_tm(buf, subservice, time_stamp, event_id, aux_data)?;
|
||||
sender.send_tm(tm.into())?;
|
||||
self.msg_count += 1;
|
||||
Ok(())
|
||||
aux_data: Option<&'src_data [u8]>,
|
||||
) -> Result<PusTmCreator<'time, 'src_data>, ByteConversionError> {
|
||||
self.generate_generic_event_tm(src_data_buf, subservice, time_stamp, event_id, aux_data)
|
||||
}
|
||||
|
||||
fn generate_generic_event_tm<'a>(
|
||||
&'a self,
|
||||
buf: &'a mut [u8],
|
||||
fn generate_generic_event_tm<'time, 'src_data>(
|
||||
&self,
|
||||
src_data_buf: &'src_data mut [u8],
|
||||
subservice: Subservice,
|
||||
time_stamp: &'a [u8],
|
||||
time_stamp: &'time [u8],
|
||||
event_id: impl EcssEnumeration,
|
||||
aux_data: Option<&[u8]>,
|
||||
) -> Result<PusTmCreator, EcssTmtcError> {
|
||||
aux_data: Option<&'src_data [u8]>,
|
||||
) -> Result<PusTmCreator<'time, 'src_data>, ByteConversionError> {
|
||||
let mut src_data_len = event_id.size();
|
||||
if let Some(aux_data) = aux_data {
|
||||
src_data_len += aux_data.len();
|
||||
}
|
||||
source_buffer_large_enough(buf.len(), src_data_len)?;
|
||||
source_buffer_large_enough(src_data_buf.len(), src_data_len)?;
|
||||
let mut sp_header = SpHeader::tm_unseg(self.apid, 0, 0).unwrap();
|
||||
let sec_header = PusTmSecondaryHeader::new(
|
||||
5,
|
||||
subservice.into(),
|
||||
self.msg_count,
|
||||
self.dest_id,
|
||||
Some(time_stamp),
|
||||
);
|
||||
let sec_header =
|
||||
PusTmSecondaryHeader::new(5, subservice.into(), 0, self.dest_id, Some(time_stamp));
|
||||
let mut current_idx = 0;
|
||||
event_id
|
||||
.write_to_be_bytes(&mut buf[0..event_id.size()])
|
||||
.map_err(PusError::ByteConversion)?;
|
||||
event_id.write_to_be_bytes(&mut src_data_buf[0..event_id.size()])?;
|
||||
current_idx += event_id.size();
|
||||
if let Some(aux_data) = aux_data {
|
||||
buf[current_idx..current_idx + aux_data.len()].copy_from_slice(aux_data);
|
||||
src_data_buf[current_idx..current_idx + aux_data.len()].copy_from_slice(aux_data);
|
||||
current_idx += aux_data.len();
|
||||
}
|
||||
Ok(PusTmCreator::new(
|
||||
&mut sp_header,
|
||||
sec_header,
|
||||
&buf[0..current_idx],
|
||||
&src_data_buf[0..current_idx],
|
||||
true,
|
||||
))
|
||||
}
|
||||
@ -161,12 +142,12 @@ mod alloc_mod {
|
||||
|
||||
pub struct EventReporter {
|
||||
source_data_buf: Vec<u8>,
|
||||
pub reporter: EventReporterBase,
|
||||
pub reporter: EventReportCreator,
|
||||
}
|
||||
|
||||
impl EventReporter {
|
||||
pub fn new(apid: u16, max_event_id_and_aux_data_size: usize) -> Option<Self> {
|
||||
let reporter = EventReporterBase::new(apid)?;
|
||||
let reporter = EventReportCreator::new(apid)?;
|
||||
Some(Self {
|
||||
source_data_buf: vec![0; max_event_id_and_aux_data_size],
|
||||
reporter,
|
||||
@ -179,13 +160,17 @@ mod alloc_mod {
|
||||
event_id: impl EcssEnumeration,
|
||||
aux_data: Option<&[u8]>,
|
||||
) -> Result<(), EcssTmtcError> {
|
||||
self.reporter.event_info(
|
||||
self.source_data_buf.as_mut_slice(),
|
||||
sender,
|
||||
time_stamp,
|
||||
event_id,
|
||||
aux_data,
|
||||
)
|
||||
let tm_creator = self
|
||||
.reporter
|
||||
.event_info(
|
||||
self.source_data_buf.as_mut_slice(),
|
||||
time_stamp,
|
||||
event_id,
|
||||
aux_data,
|
||||
)
|
||||
.map_err(PusError::ByteConversion)?;
|
||||
sender.send_tm(tm_creator.into())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn event_low_severity(
|
||||
@ -195,13 +180,17 @@ mod alloc_mod {
|
||||
event_id: impl EcssEnumeration,
|
||||
aux_data: Option<&[u8]>,
|
||||
) -> Result<(), EcssTmtcError> {
|
||||
self.reporter.event_low_severity(
|
||||
self.source_data_buf.as_mut_slice(),
|
||||
sender,
|
||||
time_stamp,
|
||||
event_id,
|
||||
aux_data,
|
||||
)
|
||||
let tm_creator = self
|
||||
.reporter
|
||||
.event_low_severity(
|
||||
self.source_data_buf.as_mut_slice(),
|
||||
time_stamp,
|
||||
event_id,
|
||||
aux_data,
|
||||
)
|
||||
.map_err(PusError::ByteConversion)?;
|
||||
sender.send_tm(tm_creator.into())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn event_medium_severity(
|
||||
@ -211,13 +200,17 @@ mod alloc_mod {
|
||||
event_id: impl EcssEnumeration,
|
||||
aux_data: Option<&[u8]>,
|
||||
) -> Result<(), EcssTmtcError> {
|
||||
self.reporter.event_medium_severity(
|
||||
self.source_data_buf.as_mut_slice(),
|
||||
sender,
|
||||
time_stamp,
|
||||
event_id,
|
||||
aux_data,
|
||||
)
|
||||
let tm_creator = self
|
||||
.reporter
|
||||
.event_medium_severity(
|
||||
self.source_data_buf.as_mut_slice(),
|
||||
time_stamp,
|
||||
event_id,
|
||||
aux_data,
|
||||
)
|
||||
.map_err(PusError::ByteConversion)?;
|
||||
sender.send_tm(tm_creator.into())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn event_high_severity(
|
||||
@ -227,13 +220,17 @@ mod alloc_mod {
|
||||
event_id: impl EcssEnumeration,
|
||||
aux_data: Option<&[u8]>,
|
||||
) -> Result<(), EcssTmtcError> {
|
||||
self.reporter.event_high_severity(
|
||||
self.source_data_buf.as_mut_slice(),
|
||||
sender,
|
||||
time_stamp,
|
||||
event_id,
|
||||
aux_data,
|
||||
)
|
||||
let tm_creator = self
|
||||
.reporter
|
||||
.event_high_severity(
|
||||
self.source_data_buf.as_mut_slice(),
|
||||
time_stamp,
|
||||
event_id,
|
||||
aux_data,
|
||||
)
|
||||
.map_err(PusError::ByteConversion)?;
|
||||
sender.send_tm(tm_creator.into())?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,19 +40,19 @@ pub use alloc_mod::*;
|
||||
pub use std_mod::*;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub enum PusTmWrapper<'tm> {
|
||||
pub enum PusTmWrapper<'time, 'src_data> {
|
||||
InStore(StoreAddr),
|
||||
Direct(PusTmCreator<'tm>),
|
||||
Direct(PusTmCreator<'time, 'src_data>),
|
||||
}
|
||||
|
||||
impl From<StoreAddr> for PusTmWrapper<'_> {
|
||||
impl From<StoreAddr> for PusTmWrapper<'_, '_> {
|
||||
fn from(value: StoreAddr) -> Self {
|
||||
Self::InStore(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tm> From<PusTmCreator<'tm>> for PusTmWrapper<'tm> {
|
||||
fn from(value: PusTmCreator<'tm>) -> Self {
|
||||
impl<'time, 'src_data> From<PusTmCreator<'time, 'src_data>> for PusTmWrapper<'time, 'src_data> {
|
||||
fn from(value: PusTmCreator<'time, 'src_data>) -> Self {
|
||||
Self::Direct(value)
|
||||
}
|
||||
}
|
||||
@ -380,7 +380,7 @@ pub mod std_mod {
|
||||
use spacepackets::ecss::tc::PusTcReader;
|
||||
use spacepackets::ecss::tm::PusTmCreator;
|
||||
use spacepackets::ecss::{PusError, WritablePusPacket};
|
||||
use spacepackets::time::cds::TimeProvider;
|
||||
use spacepackets::time::cds::CdsTime;
|
||||
use spacepackets::time::StdTimestampError;
|
||||
use spacepackets::time::TimeWriter;
|
||||
use std::string::String;
|
||||
@ -860,8 +860,7 @@ pub mod std_mod {
|
||||
partial_error: &mut Option<PartialPusHandlingError>,
|
||||
) -> [u8; 7] {
|
||||
let mut time_stamp: [u8; 7] = [0; 7];
|
||||
let time_provider =
|
||||
TimeProvider::from_now_with_u16_days().map_err(PartialPusHandlingError::Time);
|
||||
let time_provider = CdsTime::now_with_u16_days().map_err(PartialPusHandlingError::Time);
|
||||
if let Ok(time_provider) = time_provider {
|
||||
// Can't fail, we have a buffer with the exact required size.
|
||||
time_provider.write_to_bytes(&mut time_stamp).unwrap();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -14,7 +14,7 @@ use crate::pool::PoolProvider;
|
||||
use crate::pus::{PusPacketHandlerResult, PusPacketHandlingError};
|
||||
use alloc::string::ToString;
|
||||
use spacepackets::ecss::{scheduling, PusPacket};
|
||||
use spacepackets::time::cds::TimeProvider;
|
||||
use spacepackets::time::cds::CdsTime;
|
||||
|
||||
/// This is a helper class for [std] environments to handle generic PUS 11 (scheduling service)
|
||||
/// packets. This handler is able to handle the most important PUS requests for a scheduling
|
||||
@ -168,7 +168,7 @@ impl<
|
||||
|
||||
// let mut pool = self.sched_tc_pool.write().expect("locking pool failed");
|
||||
self.scheduler
|
||||
.insert_wrapped_tc::<TimeProvider>(&tc, sched_tc_pool)
|
||||
.insert_wrapped_tc::<CdsTime>(&tc, sched_tc_pool)
|
||||
.expect("insertion of activity into pool failed");
|
||||
|
||||
self.service_helper
|
||||
@ -303,7 +303,7 @@ mod tests {
|
||||
}
|
||||
|
||||
impl PusSchedulerProvider for TestScheduler {
|
||||
type TimeProvider = cds::TimeProvider;
|
||||
type TimeProvider = cds::CdsTime;
|
||||
|
||||
fn reset(
|
||||
&mut self,
|
||||
@ -329,7 +329,7 @@ mod tests {
|
||||
|
||||
fn insert_unwrapped_and_stored_tc(
|
||||
&mut self,
|
||||
_time_stamp: spacepackets::time::UnixTimestamp,
|
||||
_time_stamp: spacepackets::time::UnixTime,
|
||||
info: crate::pus::scheduler::TcInfo,
|
||||
) -> Result<(), crate::pus::scheduler::ScheduleError> {
|
||||
self.inserted_tcs.push_back(info);
|
||||
@ -390,7 +390,7 @@ mod tests {
|
||||
let mut sec_header = PusTcSecondaryHeader::new_simple(17, 1);
|
||||
let ping_tc = PusTcCreator::new(&mut reply_header, sec_header, &[], true);
|
||||
let req_id_ping_tc = scheduler::RequestId::from_tc(&ping_tc);
|
||||
let stamper = cds::TimeProvider::from_now_with_u16_days().expect("time provider failed");
|
||||
let stamper = cds::CdsTime::now_with_u16_days().expect("time provider failed");
|
||||
let mut sched_app_data: [u8; 64] = [0; 64];
|
||||
let mut written_len = stamper.write_to_bytes(&mut sched_app_data).unwrap();
|
||||
let ping_raw = ping_tc.to_vec().expect("generating raw tc failed");
|
||||
|
@ -444,15 +444,15 @@ impl VerificationReportCreator {
|
||||
VerificationToken::<TcStateNone>::new(req_id)
|
||||
}
|
||||
|
||||
fn success_verification_no_step<'src_data, State: Copy>(
|
||||
fn success_verification_no_step<'time, 'src_data, State: Copy>(
|
||||
&self,
|
||||
src_data_buf: &'src_data mut [u8],
|
||||
subservice: u8,
|
||||
token: VerificationToken<State>,
|
||||
seq_count: u16,
|
||||
msg_count: u16,
|
||||
time_stamp: &'src_data [u8],
|
||||
) -> Result<PusTmCreator, ByteConversionError> {
|
||||
time_stamp: &'time [u8],
|
||||
) -> Result<PusTmCreator<'time, 'src_data>, ByteConversionError> {
|
||||
let tm_creator = self.create_pus_verif_success_tm(
|
||||
src_data_buf,
|
||||
subservice,
|
||||
@ -467,7 +467,7 @@ impl VerificationReportCreator {
|
||||
|
||||
// Internal helper function, too many arguments is acceptable for this case.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn failure_verification_no_step<'src_data, State: Copy>(
|
||||
fn failure_verification_no_step<'time, 'src_data, State: Copy>(
|
||||
&self,
|
||||
src_data_buf: &'src_data mut [u8],
|
||||
subservice: u8,
|
||||
@ -475,8 +475,8 @@ impl VerificationReportCreator {
|
||||
seq_count: u16,
|
||||
msg_count: u16,
|
||||
step: Option<&(impl EcssEnumeration + ?Sized)>,
|
||||
params: &FailParams<'src_data, '_>,
|
||||
) -> Result<PusTmCreator, ByteConversionError> {
|
||||
params: &FailParams<'time, '_>,
|
||||
) -> Result<PusTmCreator<'time, 'src_data>, ByteConversionError> {
|
||||
let tm_creator = self.create_pus_verif_fail_tm(
|
||||
src_data_buf,
|
||||
subservice,
|
||||
@ -490,15 +490,20 @@ impl VerificationReportCreator {
|
||||
}
|
||||
|
||||
/// Package a PUS TM\[1, 1\] packet, see 8.1.2.1 of the PUS standard.
|
||||
pub fn acceptance_success<'src_data>(
|
||||
pub fn acceptance_success<'time, 'src_data>(
|
||||
&self,
|
||||
src_data_buf: &'src_data mut [u8],
|
||||
token: VerificationToken<TcStateNone>,
|
||||
seq_count: u16,
|
||||
msg_count: u16,
|
||||
time_stamp: &'src_data [u8],
|
||||
) -> Result<(PusTmCreator<'src_data>, VerificationToken<TcStateAccepted>), ByteConversionError>
|
||||
{
|
||||
time_stamp: &'time [u8],
|
||||
) -> Result<
|
||||
(
|
||||
PusTmCreator<'time, 'src_data>,
|
||||
VerificationToken<TcStateAccepted>,
|
||||
),
|
||||
ByteConversionError,
|
||||
> {
|
||||
let tm_creator = self.success_verification_no_step(
|
||||
src_data_buf,
|
||||
Subservice::TmAcceptanceSuccess.into(),
|
||||
@ -517,14 +522,14 @@ impl VerificationReportCreator {
|
||||
}
|
||||
|
||||
/// Package a PUS TM\[1, 2\] packet, see 8.1.2.2 of the PUS standard.
|
||||
pub fn acceptance_failure<'src_data>(
|
||||
pub fn acceptance_failure<'time, 'src_data>(
|
||||
&self,
|
||||
src_data_buf: &'src_data mut [u8],
|
||||
token: VerificationToken<TcStateNone>,
|
||||
seq_count: u16,
|
||||
msg_count: u16,
|
||||
params: FailParams<'src_data, '_>,
|
||||
) -> Result<PusTmCreator, ByteConversionError> {
|
||||
params: FailParams<'time, '_>,
|
||||
) -> Result<PusTmCreator<'time, 'src_data>, ByteConversionError> {
|
||||
self.failure_verification_no_step(
|
||||
src_data_buf,
|
||||
Subservice::TmAcceptanceFailure.into(),
|
||||
@ -539,14 +544,20 @@ impl VerificationReportCreator {
|
||||
/// 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<'src_data>(
|
||||
pub fn start_success<'time, 'src_data>(
|
||||
&self,
|
||||
src_data_buf: &'src_data mut [u8],
|
||||
token: VerificationToken<TcStateAccepted>,
|
||||
seq_count: u16,
|
||||
msg_count: u16,
|
||||
time_stamp: &'src_data [u8],
|
||||
) -> Result<(PusTmCreator, VerificationToken<TcStateStarted>), ByteConversionError> {
|
||||
time_stamp: &'time [u8],
|
||||
) -> Result<
|
||||
(
|
||||
PusTmCreator<'time, 'src_data>,
|
||||
VerificationToken<TcStateStarted>,
|
||||
),
|
||||
ByteConversionError,
|
||||
> {
|
||||
let tm_creator = self.success_verification_no_step(
|
||||
src_data_buf,
|
||||
Subservice::TmStartSuccess.into(),
|
||||
@ -568,14 +579,14 @@ impl VerificationReportCreator {
|
||||
///
|
||||
/// Requires a token previously acquired by calling [Self::acceptance_success]. It consumes
|
||||
/// the token because verification handling is done.
|
||||
pub fn start_failure<'src_data>(
|
||||
pub fn start_failure<'time, 'src_data>(
|
||||
&self,
|
||||
src_data_buf: &'src_data mut [u8],
|
||||
token: VerificationToken<TcStateAccepted>,
|
||||
seq_count: u16,
|
||||
msg_count: u16,
|
||||
params: FailParams<'src_data, '_>,
|
||||
) -> Result<PusTmCreator, ByteConversionError> {
|
||||
params: FailParams<'time, '_>,
|
||||
) -> Result<PusTmCreator<'time, 'src_data>, ByteConversionError> {
|
||||
self.failure_verification_no_step(
|
||||
src_data_buf,
|
||||
Subservice::TmStartFailure.into(),
|
||||
@ -590,15 +601,15 @@ impl VerificationReportCreator {
|
||||
/// 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<'src_data>(
|
||||
pub fn step_success<'time, 'src_data>(
|
||||
&self,
|
||||
src_data_buf: &'src_data mut [u8],
|
||||
token: &VerificationToken<TcStateStarted>,
|
||||
seq_count: u16,
|
||||
msg_count: u16,
|
||||
time_stamp: &'src_data [u8],
|
||||
time_stamp: &'time [u8],
|
||||
step: impl EcssEnumeration,
|
||||
) -> Result<PusTmCreator, ByteConversionError> {
|
||||
) -> Result<PusTmCreator<'time, 'src_data>, ByteConversionError> {
|
||||
self.create_pus_verif_success_tm(
|
||||
src_data_buf,
|
||||
Subservice::TmStepSuccess.into(),
|
||||
@ -614,14 +625,14 @@ impl VerificationReportCreator {
|
||||
///
|
||||
/// Requires a token previously acquired by calling [Self::start_success]. It consumes the
|
||||
/// token because verification handling is done.
|
||||
pub fn step_failure<'src_data>(
|
||||
pub fn step_failure<'time, 'src_data>(
|
||||
&self,
|
||||
src_data_buf: &'src_data mut [u8],
|
||||
token: VerificationToken<TcStateStarted>,
|
||||
seq_count: u16,
|
||||
msg_count: u16,
|
||||
params: FailParamsWithStep<'src_data, '_>,
|
||||
) -> Result<PusTmCreator, ByteConversionError> {
|
||||
params: FailParamsWithStep<'time, '_>,
|
||||
) -> Result<PusTmCreator<'time, 'src_data>, ByteConversionError> {
|
||||
self.create_pus_verif_fail_tm(
|
||||
src_data_buf,
|
||||
Subservice::TmStepFailure.into(),
|
||||
@ -637,14 +648,14 @@ impl VerificationReportCreator {
|
||||
///
|
||||
/// Requires a token previously acquired by calling [Self::start_success]. It consumes the
|
||||
/// token because verification handling is done.
|
||||
pub fn completion_success<'src_data, TcState: WasAtLeastAccepted + Copy>(
|
||||
pub fn completion_success<'time, 'src_data, TcState: WasAtLeastAccepted + Copy>(
|
||||
&self,
|
||||
src_data_buf: &'src_data mut [u8],
|
||||
token: VerificationToken<TcState>,
|
||||
seq_counter: u16,
|
||||
msg_counter: u16,
|
||||
time_stamp: &'src_data [u8],
|
||||
) -> Result<PusTmCreator, ByteConversionError> {
|
||||
time_stamp: &'time [u8],
|
||||
) -> Result<PusTmCreator<'time, 'src_data>, ByteConversionError> {
|
||||
self.success_verification_no_step(
|
||||
src_data_buf,
|
||||
Subservice::TmCompletionSuccess.into(),
|
||||
@ -659,14 +670,14 @@ impl VerificationReportCreator {
|
||||
///
|
||||
/// Requires a token previously acquired by calling [Self::start_success]. It consumes the
|
||||
/// token because verification handling is done.
|
||||
pub fn completion_failure<'src_data, TcState: WasAtLeastAccepted + Copy>(
|
||||
pub fn completion_failure<'time, 'src_data, TcState: WasAtLeastAccepted + Copy>(
|
||||
&self,
|
||||
src_data_buf: &'src_data mut [u8],
|
||||
token: VerificationToken<TcState>,
|
||||
seq_count: u16,
|
||||
msg_count: u16,
|
||||
params: FailParams<'src_data, '_>,
|
||||
) -> Result<PusTmCreator, ByteConversionError> {
|
||||
params: FailParams<'time, '_>,
|
||||
) -> Result<PusTmCreator<'time, 'src_data>, ByteConversionError> {
|
||||
self.failure_verification_no_step(
|
||||
src_data_buf,
|
||||
Subservice::TmCompletionFailure.into(),
|
||||
@ -680,16 +691,16 @@ impl VerificationReportCreator {
|
||||
|
||||
// Internal helper function, too many arguments is acceptable for this case.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn create_pus_verif_success_tm<'src_data>(
|
||||
fn create_pus_verif_success_tm<'time, 'src_data>(
|
||||
&self,
|
||||
src_data_buf: &'src_data mut [u8],
|
||||
subservice: u8,
|
||||
seq_count: u16,
|
||||
msg_counter: u16,
|
||||
req_id: &RequestId,
|
||||
time_stamp: &'src_data [u8],
|
||||
time_stamp: &'time [u8],
|
||||
step: Option<&(impl EcssEnumeration + ?Sized)>,
|
||||
) -> Result<PusTmCreator<'src_data>, ByteConversionError> {
|
||||
) -> Result<PusTmCreator<'time, 'src_data>, ByteConversionError> {
|
||||
let mut source_data_len = size_of::<u32>();
|
||||
if let Some(step) = step {
|
||||
source_data_len += step.size();
|
||||
@ -716,7 +727,7 @@ impl VerificationReportCreator {
|
||||
|
||||
// Internal helper function, too many arguments is acceptable for this case.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn create_pus_verif_fail_tm<'src_data>(
|
||||
fn create_pus_verif_fail_tm<'time, 'src_data>(
|
||||
&self,
|
||||
src_data_buf: &'src_data mut [u8],
|
||||
subservice: u8,
|
||||
@ -724,8 +735,8 @@ impl VerificationReportCreator {
|
||||
msg_counter: u16,
|
||||
req_id: &RequestId,
|
||||
step: Option<&(impl EcssEnumeration + ?Sized)>,
|
||||
params: &FailParams<'src_data, '_>,
|
||||
) -> Result<PusTmCreator<'src_data>, ByteConversionError> {
|
||||
params: &FailParams<'time, '_>,
|
||||
) -> Result<PusTmCreator<'time, 'src_data>, ByteConversionError> {
|
||||
let mut idx = 0;
|
||||
let mut source_data_len = RequestId::SIZE_AS_BYTES + params.failure_code.size();
|
||||
if let Some(step) = step {
|
||||
@ -757,15 +768,15 @@ impl VerificationReportCreator {
|
||||
))
|
||||
}
|
||||
|
||||
fn create_pus_verif_tm_base<'src_data>(
|
||||
fn create_pus_verif_tm_base<'time, 'src_data>(
|
||||
&self,
|
||||
src_data_buf: &'src_data mut [u8],
|
||||
subservice: u8,
|
||||
msg_counter: u16,
|
||||
sp_header: &mut SpHeader,
|
||||
time_stamp: &'src_data [u8],
|
||||
time_stamp: &'time [u8],
|
||||
source_data_len: usize,
|
||||
) -> PusTmCreator<'src_data> {
|
||||
) -> PusTmCreator<'time, 'src_data> {
|
||||
let tm_sec_header =
|
||||
PusTmSecondaryHeader::new(1, subservice, msg_counter, self.dest_id, Some(time_stamp));
|
||||
PusTmCreator::new(
|
||||
@ -873,7 +884,6 @@ pub mod alloc_mod {
|
||||
.as_ref()
|
||||
.map_or(0, |v| v.get_and_increment());
|
||||
let mut source_data_buf = self.source_data_buf.borrow_mut();
|
||||
let old_token = token.clone();
|
||||
let (tm_creator, token) = self
|
||||
.reporter
|
||||
.acceptance_success(
|
||||
|
@ -22,7 +22,7 @@
|
||||
//! use satrs::tmtc::{ReceivesTc, ReceivesTcCore};
|
||||
//! use spacepackets::{CcsdsPacket, SpHeader};
|
||||
//! use spacepackets::ecss::WritablePusPacket;
|
||||
//! use spacepackets::ecss::tc::{PusTc, PusTcCreator};
|
||||
//! use spacepackets::ecss::tc::PusTcCreator;
|
||||
//!
|
||||
//! #[derive (Default)]
|
||||
//! struct ConcreteApidHandler {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use spacepackets::ecss::tm::{PusTmCreator, PusTmSecondaryHeader};
|
||||
use spacepackets::time::cds::TimeProvider;
|
||||
use spacepackets::time::cds::CdsTime;
|
||||
use spacepackets::time::TimeWriter;
|
||||
use spacepackets::SpHeader;
|
||||
|
||||
@ -66,7 +66,7 @@ impl PusTmWithCdsShortHelper {
|
||||
source_data: &'a [u8],
|
||||
seq_count: u16,
|
||||
) -> PusTmCreator {
|
||||
let time_stamp = TimeProvider::from_now_with_u16_days().unwrap();
|
||||
let time_stamp = CdsTime::now_with_u16_days().unwrap();
|
||||
time_stamp.write_to_bytes(&mut self.cds_short_buf).unwrap();
|
||||
self.create_pus_tm_common(service, subservice, source_data, seq_count)
|
||||
}
|
||||
@ -76,7 +76,7 @@ impl PusTmWithCdsShortHelper {
|
||||
service: u8,
|
||||
subservice: u8,
|
||||
source_data: &'a [u8],
|
||||
stamper: &TimeProvider,
|
||||
stamper: &CdsTime,
|
||||
seq_count: u16,
|
||||
) -> PusTmCreator {
|
||||
stamper.write_to_bytes(&mut self.cds_short_buf).unwrap();
|
||||
@ -98,14 +98,14 @@ impl PusTmWithCdsShortHelper {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use spacepackets::{ecss::PusPacket, time::cds::TimeProvider, CcsdsPacket};
|
||||
use spacepackets::{ecss::PusPacket, time::cds::CdsTime, 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 stamper = CdsTime::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);
|
||||
|
@ -2,7 +2,7 @@
|
||||
use core::mem::size_of;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use spacepackets::ecss::{PfcReal, PfcUnsigned, Ptc};
|
||||
use spacepackets::time::cds::TimeProvider;
|
||||
use spacepackets::time::cds::CdsTime;
|
||||
use spacepackets::time::{CcsdsTimeProvider, TimeWriter};
|
||||
|
||||
enum NumOfParamsInfo {
|
||||
@ -36,7 +36,7 @@ struct TestMgmHkWithIndividualValidity {
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct TestMgmHkWithGroupValidity {
|
||||
last_valid_stamp: TimeProvider,
|
||||
last_valid_stamp: CdsTime,
|
||||
valid: bool,
|
||||
temp: f32,
|
||||
mgm_vals: [u16; 3],
|
||||
@ -150,7 +150,7 @@ pub fn main() {
|
||||
// The easiest and probably best approach, trading off big advantages for TM downlink capacity:
|
||||
// Use a JSON format
|
||||
let mgm_hk_group_validity = TestMgmHkWithGroupValidity {
|
||||
last_valid_stamp: TimeProvider::from_now_with_u16_days().unwrap(),
|
||||
last_valid_stamp: CdsTime::now_with_u16_days().unwrap(),
|
||||
valid: false,
|
||||
temp: 20.0,
|
||||
mgm_vals: [0x1f1f, 0x2f2f, 0x3f3f],
|
||||
|
Loading…
Reference in New Issue
Block a user