spacepackets update #51
@ -64,7 +64,7 @@ optional = true
|
||||
# version = "0.6"
|
||||
# path = "../spacepackets"
|
||||
git = "https://egit.irs.uni-stuttgart.de/rust/spacepackets.git"
|
||||
rev = "eca7e09d19"
|
||||
rev = "46eab3529004"
|
||||
default-features = false
|
||||
|
||||
[dev-dependencies]
|
||||
|
@ -22,7 +22,7 @@ use std::vec::Vec;
|
||||
/// use satrs_core::hal::host::udp_server::UdpTcServer;
|
||||
/// use satrs_core::tmtc::{ReceivesTc, ReceivesTcCore};
|
||||
/// use spacepackets::SpHeader;
|
||||
/// use spacepackets::ecss::tc::PusTc;
|
||||
/// use spacepackets::ecss::tc::PusTcCreator;
|
||||
///
|
||||
/// #[derive (Default)]
|
||||
/// struct PingReceiver {}
|
||||
@ -40,7 +40,7 @@ use std::vec::Vec;
|
||||
/// let mut udp_tc_server = UdpTcServer::new(dest_addr, 2048, Box::new(ping_receiver))
|
||||
/// .expect("Creating UDP TMTC server failed");
|
||||
/// let mut sph = SpHeader::tc_unseg(0x02, 0, 0).unwrap();
|
||||
/// let pus_tc = PusTc::new_simple(&mut sph, 17, 1, None, true);
|
||||
/// let pus_tc = PusTcCreator::new_simple(&mut sph, 17, 1, None, true);
|
||||
/// let len = pus_tc
|
||||
/// .write_to_bytes(&mut buf)
|
||||
/// .expect("Error writing PUS TC packet");
|
||||
@ -142,7 +142,7 @@ impl<E: 'static> UdpTcServer<E> {
|
||||
mod tests {
|
||||
use crate::hal::host::udp_server::{ReceiveResult, UdpTcServer};
|
||||
use crate::tmtc::ReceivesTcCore;
|
||||
use spacepackets::ecss::tc::PusTc;
|
||||
use spacepackets::ecss::tc::PusTcCreator;
|
||||
use spacepackets::ecss::SerializablePusPacket;
|
||||
use spacepackets::SpHeader;
|
||||
use std::boxed::Box;
|
||||
@ -178,7 +178,7 @@ mod tests {
|
||||
.expect("Creating UDP TMTC server failed");
|
||||
is_send(&udp_tc_server);
|
||||
let mut sph = SpHeader::tc_unseg(0x02, 0, 0).unwrap();
|
||||
let pus_tc = PusTc::new_simple(&mut sph, 17, 1, None, true);
|
||||
let pus_tc = PusTcCreator::new_simple(&mut sph, 17, 1, None, true);
|
||||
let len = pus_tc
|
||||
.write_to_bytes(&mut buf)
|
||||
.expect("Error writing PUS TC packet");
|
||||
|
@ -281,8 +281,8 @@ mod tests {
|
||||
panic!("TestSender: unexpected call with address");
|
||||
}
|
||||
PusTmWrapper::Direct(tm) => {
|
||||
assert!(tm.source_data().is_some());
|
||||
let src_data = tm.source_data().unwrap();
|
||||
assert!(!tm.source_data().is_empty());
|
||||
let src_data = tm.source_data();
|
||||
assert!(src_data.len() >= 4);
|
||||
let event =
|
||||
EventU32::from(u32::from_be_bytes(src_data[0..4].try_into().unwrap()));
|
||||
|
@ -65,12 +65,12 @@ impl PusServiceHandler for PusService5EventHandler {
|
||||
));
|
||||
}
|
||||
let handle_enable_disable_request = |enable: bool, stamp: [u8; 7]| {
|
||||
if tc.user_data().is_none() || tc.user_data().unwrap().len() < 4 {
|
||||
if tc.user_data().len() < 4 {
|
||||
return Err(PusPacketHandlingError::NotEnoughAppData(
|
||||
"At least 4 bytes event ID expected".into(),
|
||||
));
|
||||
}
|
||||
let user_data = tc.user_data().unwrap();
|
||||
let user_data = tc.user_data();
|
||||
let event_u32 = EventU32::from(u32::from_be_bytes(user_data[0..4].try_into().unwrap()));
|
||||
let start_token = self
|
||||
.psb
|
||||
|
@ -232,7 +232,9 @@ pub trait EcssTcReceiverCore: EcssChannel {
|
||||
|
||||
/// Generic trait for objects which can receive ECSS PUS telecommands. This trait is
|
||||
/// implemented by the [crate::tmtc::pus_distrib::PusDistributor] objects to allow passing PUS TC
|
||||
/// packets into it.
|
||||
/// packets into it. It is generally assumed that the telecommand is stored in some pool structure,
|
||||
/// and the store address is passed as well. This allows efficient zero-copy forwarding of
|
||||
/// telecommands.
|
||||
pub trait ReceivesEcssPusTc {
|
||||
type Error;
|
||||
fn pass_pus_tc(&mut self, header: &SpHeader, pus_tc: &PusTcReader) -> Result<(), Self::Error>;
|
||||
@ -317,7 +319,7 @@ pub mod std_mod {
|
||||
use crate::ChannelId;
|
||||
use alloc::boxed::Box;
|
||||
use alloc::vec::Vec;
|
||||
use spacepackets::ecss::tm::{PusTm, PusTmCreator};
|
||||
use spacepackets::ecss::tm::PusTmCreator;
|
||||
use spacepackets::ecss::PusError;
|
||||
use spacepackets::time::cds::TimeProvider;
|
||||
use spacepackets::time::StdTimestampError;
|
||||
@ -641,7 +643,7 @@ pub(crate) fn source_buffer_large_enough(cap: usize, len: usize) -> Result<(), E
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use spacepackets::ecss::tm::{GenericPusTmSecondaryHeader, PusTm};
|
||||
use spacepackets::ecss::tm::{GenericPusTmSecondaryHeader, PusTmCreator};
|
||||
use spacepackets::CcsdsPacket;
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Clone)]
|
||||
@ -654,7 +656,7 @@ pub(crate) mod tests {
|
||||
}
|
||||
|
||||
impl CommonTmInfo {
|
||||
pub fn new_from_tm(tm: &PusTm) -> Self {
|
||||
pub fn new_from_tm(tm: &PusTmCreator) -> Self {
|
||||
let mut time_stamp = [0; 7];
|
||||
time_stamp.clone_from_slice(&tm.timestamp().unwrap()[0..7]);
|
||||
Self {
|
||||
|
@ -8,7 +8,7 @@ use core::time::Duration;
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use spacepackets::ecss::scheduling::TimeWindowType;
|
||||
use spacepackets::ecss::tc::{GenericPusTcSecondaryHeader, PusTc};
|
||||
use spacepackets::ecss::tc::{GenericPusTcSecondaryHeader, IsPusTelecommand};
|
||||
use spacepackets::ecss::PusError;
|
||||
use spacepackets::time::{CcsdsTimeProvider, TimestampError, UnixTimestamp};
|
||||
use spacepackets::CcsdsPacket;
|
||||
@ -46,7 +46,9 @@ impl RequestId {
|
||||
self.seq_count
|
||||
}
|
||||
|
||||
pub fn from_tc(tc: &PusTc) -> Self {
|
||||
pub fn from_tc(
|
||||
tc: &(impl CcsdsPacket + GenericPusTcSecondaryHeader + IsPusTelecommand),
|
||||
) -> Self {
|
||||
RequestId {
|
||||
source_id: tc.source_id(),
|
||||
apid: tc.apid(),
|
||||
@ -57,22 +59,6 @@ impl RequestId {
|
||||
pub fn as_u64(&self) -> u64 {
|
||||
((self.source_id as u64) << 32) | ((self.apid as u64) << 16) | self.seq_count as u64
|
||||
}
|
||||
|
||||
/*
|
||||
pub fn from_bytes(buf: &[u8]) -> Result<Self, ByteConversionError> {
|
||||
if buf.len() < core::mem::size_of::<u64>() {
|
||||
return Err(ByteConversionError::FromSliceTooSmall(SizeMissmatch {
|
||||
found: buf.len(),
|
||||
expected: core::mem::size_of::<u64>(),
|
||||
}));
|
||||
}
|
||||
Ok(Self {
|
||||
source_id: u16::from_be_bytes(buf[0..2].try_into().unwrap()),
|
||||
apid: u16::from_be_bytes(buf[2..4].try_into().unwrap()),
|
||||
seq_count: u16::from_be_bytes(buf[4..6].try_into().unwrap()),
|
||||
})
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@ -239,7 +225,9 @@ pub mod alloc_mod {
|
||||
use alloc::vec::Vec;
|
||||
use core::time::Duration;
|
||||
use spacepackets::ecss::scheduling::TimeWindowType;
|
||||
use spacepackets::ecss::tc::PusTc;
|
||||
use spacepackets::ecss::tc::{
|
||||
GenericPusTcSecondaryHeader, IsPusTelecommand, PusTc, PusTcReader,
|
||||
};
|
||||
use spacepackets::ecss::PusPacket;
|
||||
use spacepackets::time::cds::DaysLen24Bits;
|
||||
use spacepackets::time::{cds, CcsdsTimeProvider, TimeReader, UnixTimestamp};
|
||||
@ -387,7 +375,7 @@ pub mod alloc_mod {
|
||||
tc: &[u8],
|
||||
pool: &mut (impl PoolProvider + ?Sized),
|
||||
) -> Result<TcInfo, ScheduleError> {
|
||||
let check_tc = PusTc::from_bytes(tc)?;
|
||||
let check_tc = PusTcReader::new(tc)?;
|
||||
if PusPacket::service(&check_tc.0) == 11 && PusPacket::subservice(&check_tc.0) == 4 {
|
||||
return Err(ScheduleError::NestedScheduledTc);
|
||||
}
|
||||
@ -407,7 +395,7 @@ pub mod alloc_mod {
|
||||
/// provider needs to be supplied via a generic.
|
||||
pub fn insert_wrapped_tc<TimeStamp: CcsdsTimeProvider + TimeReader>(
|
||||
&mut self,
|
||||
pus_tc: &PusTc,
|
||||
pus_tc: &(impl IsPusTelecommand + PusPacket + GenericPusTcSecondaryHeader),
|
||||
pool: &mut (impl PoolProvider + ?Sized),
|
||||
) -> Result<TcInfo, ScheduleError> {
|
||||
if PusPacket::service(pus_tc) != 11 {
|
||||
@ -416,14 +404,14 @@ pub mod alloc_mod {
|
||||
if PusPacket::subservice(pus_tc) != 4 {
|
||||
return Err(ScheduleError::WrongSubservice);
|
||||
}
|
||||
return if let Some(user_data) = pus_tc.user_data() {
|
||||
let stamp: TimeStamp = TimeReader::from_bytes(user_data)?;
|
||||
let unix_stamp = stamp.unix_stamp();
|
||||
let stamp_len = stamp.len_as_bytes();
|
||||
self.insert_unwrapped_tc(unix_stamp, &user_data[stamp_len..], pool)
|
||||
} else {
|
||||
Err(ScheduleError::TcDataEmpty)
|
||||
};
|
||||
if pus_tc.user_data().is_empty() {
|
||||
return Err(ScheduleError::TcDataEmpty);
|
||||
}
|
||||
let user_data = pus_tc.user_data();
|
||||
let stamp: TimeStamp = TimeReader::from_bytes(user_data)?;
|
||||
let unix_stamp = stamp.unix_stamp();
|
||||
let stamp_len = stamp.len_as_bytes();
|
||||
self.insert_unwrapped_tc(unix_stamp, &user_data[stamp_len..], pool)
|
||||
}
|
||||
|
||||
/// Insert a telecommand based on the fully wrapped time-tagged telecommand using a CDS
|
||||
@ -641,7 +629,7 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::pool::{LocalPool, PoolCfg, PoolProvider, StoreAddr, StoreError};
|
||||
use alloc::collections::btree_map::Range;
|
||||
use spacepackets::ecss::tc::{PusTc, PusTcSecondaryHeader};
|
||||
use spacepackets::ecss::tc::{PusTcCreator, PusTcReader, PusTcSecondaryHeader};
|
||||
use spacepackets::ecss::SerializablePusPacket;
|
||||
use spacepackets::time::{cds, TimeWriter, UnixTimestamp};
|
||||
use spacepackets::SpHeader;
|
||||
@ -662,32 +650,32 @@ mod tests {
|
||||
)
|
||||
}
|
||||
|
||||
fn scheduled_tc(timestamp: UnixTimestamp, buf: &mut [u8]) -> PusTc {
|
||||
fn scheduled_tc(timestamp: UnixTimestamp, buf: &mut [u8]) -> PusTcCreator {
|
||||
let (mut sph, len_app_data) = pus_tc_base(timestamp, buf);
|
||||
PusTc::new_simple(&mut sph, 11, 4, Some(&buf[..len_app_data]), true)
|
||||
PusTcCreator::new_simple(&mut sph, 11, 4, Some(&buf[..len_app_data]), true)
|
||||
}
|
||||
|
||||
fn wrong_tc_service(timestamp: UnixTimestamp, buf: &mut [u8]) -> PusTc {
|
||||
fn wrong_tc_service(timestamp: UnixTimestamp, buf: &mut [u8]) -> PusTcCreator {
|
||||
let (mut sph, len_app_data) = pus_tc_base(timestamp, buf);
|
||||
PusTc::new_simple(&mut sph, 12, 4, Some(&buf[..len_app_data]), true)
|
||||
PusTcCreator::new_simple(&mut sph, 12, 4, Some(&buf[..len_app_data]), true)
|
||||
}
|
||||
|
||||
fn wrong_tc_subservice(timestamp: UnixTimestamp, buf: &mut [u8]) -> PusTc {
|
||||
fn wrong_tc_subservice(timestamp: UnixTimestamp, buf: &mut [u8]) -> PusTcCreator {
|
||||
let (mut sph, len_app_data) = pus_tc_base(timestamp, buf);
|
||||
PusTc::new_simple(&mut sph, 11, 5, Some(&buf[..len_app_data]), true)
|
||||
PusTcCreator::new_simple(&mut sph, 11, 5, Some(&buf[..len_app_data]), true)
|
||||
}
|
||||
|
||||
fn double_wrapped_time_tagged_tc(timestamp: UnixTimestamp, buf: &mut [u8]) -> PusTc {
|
||||
fn double_wrapped_time_tagged_tc(timestamp: UnixTimestamp, buf: &mut [u8]) -> PusTcCreator {
|
||||
let cds_time = cds::TimeProvider::from_unix_secs_with_u16_days(×tamp).unwrap();
|
||||
let len_time_stamp = cds_time.write_to_bytes(buf).unwrap();
|
||||
let mut sph = SpHeader::tc_unseg(0x02, 0x34, 0).unwrap();
|
||||
// app data should not matter, double wrapped time-tagged commands should be rejected right
|
||||
// away
|
||||
let inner_time_tagged_tc = PusTc::new_simple(&mut sph, 11, 4, None, true);
|
||||
let inner_time_tagged_tc = PusTcCreator::new_simple(&mut sph, 11, 4, None, true);
|
||||
let packet_len = inner_time_tagged_tc
|
||||
.write_to_bytes(&mut buf[len_time_stamp..])
|
||||
.expect("writing inner time tagged tc failed");
|
||||
PusTc::new_simple(
|
||||
PusTcCreator::new_simple(
|
||||
&mut sph,
|
||||
11,
|
||||
4,
|
||||
@ -696,14 +684,17 @@ mod tests {
|
||||
)
|
||||
}
|
||||
|
||||
fn invalid_time_tagged_cmd() -> PusTc<'static> {
|
||||
fn invalid_time_tagged_cmd() -> PusTcCreator<'static> {
|
||||
let mut sph = SpHeader::tc_unseg(0x02, 0x34, 1).unwrap();
|
||||
PusTc::new_simple(&mut sph, 11, 4, None, true)
|
||||
PusTcCreator::new_simple(&mut sph, 11, 4, None, true)
|
||||
}
|
||||
|
||||
fn base_ping_tc_simple_ctor(seq_count: u16, app_data: Option<&'static [u8]>) -> PusTc<'static> {
|
||||
fn base_ping_tc_simple_ctor(
|
||||
seq_count: u16,
|
||||
app_data: Option<&'static [u8]>,
|
||||
) -> PusTcCreator<'static> {
|
||||
let mut sph = SpHeader::tc_unseg(0x02, seq_count, 0).unwrap();
|
||||
PusTc::new_simple(&mut sph, 17, 1, app_data, true)
|
||||
PusTcCreator::new_simple(&mut sph, 17, 1, app_data, true)
|
||||
}
|
||||
|
||||
fn ping_tc_to_store(
|
||||
@ -870,7 +861,7 @@ mod tests {
|
||||
let mut sp_header = SpHeader::tc_unseg(apid_to_set, 105, 0).unwrap();
|
||||
let mut sec_header = PusTcSecondaryHeader::new_simple(17, 1);
|
||||
sec_header.source_id = src_id_to_set;
|
||||
let ping_tc = PusTc::new(&mut sp_header, sec_header, None, true);
|
||||
let ping_tc = PusTcCreator::new(&mut sp_header, sec_header, None, true);
|
||||
let req_id = RequestId::from_tc(&ping_tc);
|
||||
assert_eq!(req_id.source_id(), src_id_to_set);
|
||||
assert_eq!(req_id.apid(), apid_to_set);
|
||||
@ -1085,7 +1076,7 @@ mod tests {
|
||||
assert!(pool.has_element_at(&tc_info_0.addr()).unwrap());
|
||||
|
||||
let data = pool.read(&tc_info_0.addr()).unwrap();
|
||||
let check_tc = PusTc::from_bytes(&data).expect("incorrect Pus tc raw data");
|
||||
let check_tc = PusTcReader::new(&data).expect("incorrect Pus tc raw data");
|
||||
assert_eq!(check_tc.0, base_ping_tc_simple_ctor(0, None));
|
||||
|
||||
assert_eq!(scheduler.num_scheduled_telecommands(), 1);
|
||||
@ -1107,7 +1098,7 @@ mod tests {
|
||||
.unwrap();
|
||||
|
||||
let data = pool.read(&addr_vec[0]).unwrap();
|
||||
let check_tc = PusTc::from_bytes(&data).expect("incorrect Pus tc raw data");
|
||||
let check_tc = PusTcReader::new(&data).expect("incorrect Pus tc raw data");
|
||||
assert_eq!(check_tc.0, base_ping_tc_simple_ctor(0, None));
|
||||
}
|
||||
|
||||
@ -1131,7 +1122,7 @@ mod tests {
|
||||
assert!(pool.has_element_at(&info.addr).unwrap());
|
||||
|
||||
let data = pool.read(&info.addr).unwrap();
|
||||
let check_tc = PusTc::from_bytes(&data).expect("incorrect Pus tc raw data");
|
||||
let check_tc = PusTcReader::new(&data).expect("incorrect Pus tc raw data");
|
||||
assert_eq!(check_tc.0, base_ping_tc_simple_ctor(0, None));
|
||||
|
||||
assert_eq!(scheduler.num_scheduled_telecommands(), 1);
|
||||
@ -1153,7 +1144,7 @@ mod tests {
|
||||
.unwrap();
|
||||
|
||||
let data = pool.read(&addr_vec[0]).unwrap();
|
||||
let check_tc = PusTc::from_bytes(&data).expect("incorrect Pus tc raw data");
|
||||
let check_tc = PusTcReader::new(&data).expect("incorrect PUS tc raw data");
|
||||
assert_eq!(check_tc.0, base_ping_tc_simple_ctor(0, None));
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ use crate::pus::{
|
||||
PusPacketHandlingError, PusServiceBase, PusServiceHandler, PusTmWrapper,
|
||||
};
|
||||
use spacepackets::ecss::tc::PusTc;
|
||||
use spacepackets::ecss::tm::{PusTm, PusTmCreator, PusTmSecondaryHeader};
|
||||
use spacepackets::ecss::tm::{PusTmCreator, PusTmSecondaryHeader};
|
||||
use spacepackets::ecss::PusPacket;
|
||||
use spacepackets::SpHeader;
|
||||
use std::boxed::Box;
|
||||
@ -116,8 +116,8 @@ mod tests {
|
||||
};
|
||||
use crate::pus::{MpscTcInStoreReceiver, MpscTmInStoreSender, PusServiceHandler};
|
||||
use crate::tmtc::tm_helper::SharedTmStore;
|
||||
use spacepackets::ecss::tc::{PusTc, PusTcSecondaryHeader};
|
||||
use spacepackets::ecss::tm::PusTm;
|
||||
use spacepackets::ecss::tc::{PusTcCreator, PusTcSecondaryHeader};
|
||||
use spacepackets::ecss::tm::PusTmReader;
|
||||
use spacepackets::ecss::{PusPacket, SerializablePusPacket};
|
||||
use spacepackets::{SequenceFlags, SpHeader};
|
||||
use std::boxed::Box;
|
||||
@ -154,7 +154,7 @@ mod tests {
|
||||
// Create a ping TC, verify acceptance.
|
||||
let mut sp_header = SpHeader::tc(TEST_APID, SequenceFlags::Unsegmented, 0, 0).unwrap();
|
||||
let sec_header = PusTcSecondaryHeader::new_simple(17, 1);
|
||||
let ping_tc = PusTc::new(&mut sp_header, sec_header, None, true);
|
||||
let ping_tc = PusTcCreator::new(&mut sp_header, sec_header, None, true);
|
||||
let token = verification_handler.add_tc(&ping_tc);
|
||||
let token = verification_handler
|
||||
.acceptance_success(token, None)
|
||||
@ -174,10 +174,10 @@ mod tests {
|
||||
let mut tm_addr = next_msg.unwrap();
|
||||
let tm_pool = tm_pool_shared.read().unwrap();
|
||||
let tm_raw = tm_pool.read(&tm_addr).unwrap();
|
||||
let (tm, _) = PusTm::from_bytes(&tm_raw, 0).unwrap();
|
||||
let (tm, _) = PusTmReader::new(&tm_raw, 0).unwrap();
|
||||
assert_eq!(tm.service(), 1);
|
||||
assert_eq!(tm.subservice(), 1);
|
||||
let req_id = RequestId::from_bytes(tm.user_data().unwrap()).unwrap();
|
||||
let req_id = RequestId::from_bytes(tm.user_data()).expect("generating request ID failed");
|
||||
assert_eq!(req_id, token.req_id());
|
||||
|
||||
// Acceptance TM
|
||||
@ -186,10 +186,10 @@ mod tests {
|
||||
tm_addr = next_msg.unwrap();
|
||||
let tm_raw = tm_pool.read(&tm_addr).unwrap();
|
||||
// Is generated with CDS short timestamp.
|
||||
let (tm, _) = PusTm::from_bytes(&tm_raw, 7).unwrap();
|
||||
let (tm, _) = PusTmReader::new(&tm_raw, 7).unwrap();
|
||||
assert_eq!(tm.service(), 1);
|
||||
assert_eq!(tm.subservice(), 3);
|
||||
let req_id = RequestId::from_bytes(tm.user_data().unwrap()).unwrap();
|
||||
let req_id = RequestId::from_bytes(tm.user_data()).expect("generating request ID failed");
|
||||
assert_eq!(req_id, token.req_id());
|
||||
|
||||
// Ping reply
|
||||
@ -198,10 +198,10 @@ mod tests {
|
||||
tm_addr = next_msg.unwrap();
|
||||
let tm_raw = tm_pool.read(&tm_addr).unwrap();
|
||||
// Is generated with CDS short timestamp.
|
||||
let (tm, _) = PusTm::from_bytes(&tm_raw, 7).unwrap();
|
||||
let (tm, _) = PusTmReader::new(&tm_raw, 7).unwrap();
|
||||
assert_eq!(tm.service(), 17);
|
||||
assert_eq!(tm.subservice(), 2);
|
||||
assert!(tm.user_data().is_none());
|
||||
assert!(tm.user_data().is_empty());
|
||||
|
||||
// TM completion
|
||||
next_msg = tm_rx.try_recv();
|
||||
@ -209,10 +209,10 @@ mod tests {
|
||||
tm_addr = next_msg.unwrap();
|
||||
let tm_raw = tm_pool.read(&tm_addr).unwrap();
|
||||
// Is generated with CDS short timestamp.
|
||||
let (tm, _) = PusTm::from_bytes(&tm_raw, 7).unwrap();
|
||||
let (tm, _) = PusTmReader::new(&tm_raw, 7).unwrap();
|
||||
assert_eq!(tm.service(), 1);
|
||||
assert_eq!(tm.subservice(), 7);
|
||||
let req_id = RequestId::from_bytes(tm.user_data().unwrap()).unwrap();
|
||||
let req_id = RequestId::from_bytes(tm.user_data()).expect("generating request ID failed");
|
||||
assert_eq!(req_id, token.req_id());
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,8 @@
|
||||
//! use satrs_core::tmtc::tm_helper::SharedTmStore;
|
||||
//! use spacepackets::ecss::PusPacket;
|
||||
//! use spacepackets::SpHeader;
|
||||
//! use spacepackets::ecss::tc::{PusTc, PusTcSecondaryHeader};
|
||||
//! use spacepackets::ecss::tm::PusTm;
|
||||
//! use spacepackets::ecss::tc::{PusTcCreator, PusTcSecondaryHeader};
|
||||
//! use spacepackets::ecss::tm::PusTmReader;
|
||||
//!
|
||||
//! const EMPTY_STAMP: [u8; 7] = [0; 7];
|
||||
//! const TEST_APID: u16 = 0x02;
|
||||
@ -39,7 +39,7 @@
|
||||
//!
|
||||
//! let mut sph = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||
//! let tc_header = PusTcSecondaryHeader::new_simple(17, 1);
|
||||
//! let pus_tc_0 = PusTc::new(&mut sph, tc_header, None, true);
|
||||
//! let pus_tc_0 = PusTcCreator::new(&mut sph, tc_header, None, true);
|
||||
//! let init_token = reporter.add_tc(&pus_tc_0);
|
||||
//!
|
||||
//! // Complete success sequence for a telecommand
|
||||
@ -60,7 +60,7 @@
|
||||
//! tm_len = slice.len();
|
||||
//! tm_buf[0..tm_len].copy_from_slice(slice);
|
||||
//! }
|
||||
//! let (pus_tm, _) = PusTm::from_bytes(&tm_buf[0..tm_len], 7)
|
||||
//! let (pus_tm, _) = PusTmReader::new(&tm_buf[0..tm_len], 7)
|
||||
//! .expect("Error reading verification TM");
|
||||
//! if packet_idx == 0 {
|
||||
//! assert_eq!(pus_tm.subservice(), 1);
|
||||
@ -85,8 +85,8 @@ use core::mem::size_of;
|
||||
use delegate::delegate;
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use spacepackets::ecss::tc::PusTc;
|
||||
use spacepackets::ecss::tm::{PusTm, PusTmCreator, PusTmSecondaryHeader};
|
||||
use spacepackets::ecss::tc::IsPusTelecommand;
|
||||
use spacepackets::ecss::tm::{PusTmCreator, PusTmSecondaryHeader};
|
||||
use spacepackets::ecss::{EcssEnumeration, PusError, SerializablePusPacket};
|
||||
use spacepackets::{CcsdsPacket, PacketId, PacketSequenceCtrl};
|
||||
use spacepackets::{SpHeader, MAX_APID};
|
||||
@ -163,7 +163,7 @@ impl RequestId {
|
||||
}
|
||||
impl RequestId {
|
||||
/// This allows extracting the request ID from a given PUS telecommand.
|
||||
pub fn new(tc: &PusTc) -> Self {
|
||||
pub fn new(tc: &(impl CcsdsPacket + IsPusTelecommand)) -> Self {
|
||||
RequestId {
|
||||
version_number: tc.ccsds_version(),
|
||||
packet_id: tc.packet_id(),
|
||||
@ -436,7 +436,10 @@ impl VerificationReporterCore {
|
||||
|
||||
/// Initialize verification handling by passing a TC reference. This returns a token required
|
||||
/// to call the acceptance functions
|
||||
pub fn add_tc(&mut self, pus_tc: &PusTc) -> VerificationToken<TcStateNone> {
|
||||
pub fn add_tc(
|
||||
&mut self,
|
||||
pus_tc: &(impl CcsdsPacket + IsPusTelecommand),
|
||||
) -> VerificationToken<TcStateNone> {
|
||||
self.add_tc_with_req_id(RequestId::new(pus_tc))
|
||||
}
|
||||
|
||||
@ -888,6 +891,7 @@ mod alloc_mod {
|
||||
use alloc::boxed::Box;
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use spacepackets::ecss::tc::IsPusTelecommand;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct VerificationReporterCfg {
|
||||
@ -949,7 +953,7 @@ mod alloc_mod {
|
||||
to self.reporter {
|
||||
pub fn set_apid(&mut self, apid: u16) -> bool;
|
||||
pub fn apid(&self) -> u16;
|
||||
pub fn add_tc(&mut self, pus_tc: &PusTc) -> VerificationToken<TcStateNone>;
|
||||
pub fn add_tc(&mut self, pus_tc: &(impl CcsdsPacket + IsPusTelecommand)) -> VerificationToken<TcStateNone>;
|
||||
pub fn add_tc_with_req_id(&mut self, req_id: RequestId) -> VerificationToken<TcStateNone>;
|
||||
pub fn dest_id(&self) -> u16;
|
||||
pub fn set_dest_id(&mut self, dest_id: u16);
|
||||
@ -1213,7 +1217,7 @@ mod alloc_mod {
|
||||
to self.reporter {
|
||||
pub fn set_apid(&mut self, apid: u16) -> bool;
|
||||
pub fn apid(&self) -> u16;
|
||||
pub fn add_tc(&mut self, pus_tc: &PusTc) -> VerificationToken<TcStateNone>;
|
||||
pub fn add_tc(&mut self, pus_tc: &(impl CcsdsPacket + IsPusTelecommand)) -> VerificationToken<TcStateNone>;
|
||||
pub fn add_tc_with_req_id(&mut self, req_id: RequestId) -> VerificationToken<TcStateNone>;
|
||||
pub fn dest_id(&self) -> u16;
|
||||
pub fn set_dest_id(&mut self, dest_id: u16);
|
||||
@ -1304,192 +1308,8 @@ mod std_mod {
|
||||
use crate::pus::verification::VerificationReporterWithSender;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
// use super::alloc_mod::VerificationReporterWithSender;
|
||||
// use super::*;
|
||||
// use crate::pool::{ShareablePoolProvider, SharedPool, StoreAddr};
|
||||
// use crate::pus::{EcssSender, MpscPusInStoreSendError, PusTmWrapper};
|
||||
// use crate::SenderId;
|
||||
// use delegate::delegate;
|
||||
// use spacepackets::ecss::SerializablePusPacket;
|
||||
// use std::sync::{mpsc, Arc, Mutex, RwLockWriteGuard};
|
||||
//
|
||||
pub type StdVerifReporterWithSender = VerificationReporterWithSender;
|
||||
pub type SharedStdVerifReporterWithSender = Arc<Mutex<StdVerifReporterWithSender>>;
|
||||
//
|
||||
// trait SendBackend: Send {
|
||||
// type SendError: Debug;
|
||||
//
|
||||
// fn send(&self, addr: StoreAddr) -> Result<(), Self::SendError>;
|
||||
// }
|
||||
//
|
||||
// #[derive(Clone)]
|
||||
// struct StdSenderBase<S> {
|
||||
// id: SenderId,
|
||||
// name: &'static str,
|
||||
// tm_store: SharedPool,
|
||||
// tx: S,
|
||||
// pub ignore_poison_error: bool,
|
||||
// }
|
||||
//
|
||||
// impl<S: SendBackend> StdSenderBase<S> {
|
||||
// pub fn new(id: SenderId, name: &'static str, tm_store: SharedPool, tx: S) -> Self {
|
||||
// Self {
|
||||
// id,
|
||||
// name,
|
||||
// tm_store,
|
||||
// tx,
|
||||
// ignore_poison_error: false,
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// unsafe impl<S: Sync> Sync for StdSenderBase<S> {}
|
||||
// unsafe impl<S: Send> Send for StdSenderBase<S> {}
|
||||
//
|
||||
// impl SendBackend for mpsc::Sender<StoreAddr> {
|
||||
// type SendError = mpsc::SendError<StoreAddr>;
|
||||
//
|
||||
// fn send(&self, addr: StoreAddr) -> Result<(), Self::SendError> {
|
||||
// self.send(addr)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// #[derive(Clone)]
|
||||
// pub struct MpscVerifSender {
|
||||
// base: StdSenderBase<mpsc::Sender<StoreAddr>>,
|
||||
// }
|
||||
//
|
||||
// /// Verification sender with a [mpsc::Sender] backend.
|
||||
// /// It implements the [EcssTmSenderCore] trait to be used as PUS Verification TM sender.
|
||||
// impl MpscVerifSender {
|
||||
// pub fn new(
|
||||
// id: SenderId,
|
||||
// name: &'static str,
|
||||
// tm_store: SharedPool,
|
||||
// tx: mpsc::Sender<StoreAddr>,
|
||||
// ) -> Self {
|
||||
// Self {
|
||||
// base: StdSenderBase::new(id, name, tm_store, tx),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //noinspection RsTraitImplementation
|
||||
// impl EcssSender for MpscVerifSender {
|
||||
// delegate!(
|
||||
// to self.base {
|
||||
// fn id(&self) -> SenderId;
|
||||
// fn name(&self) -> &'static str;
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// //noinspection RsTraitImplementation
|
||||
// impl EcssTmSenderCore for MpscVerifSender {
|
||||
// type Error = MpscPusInStoreSendError;
|
||||
//
|
||||
// delegate!(
|
||||
// to self.base {
|
||||
// fn send_tm(&self, tm: PusTmWrapper) -> Result<(), Self::Error>;
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// impl SendBackend for crossbeam_channel::Sender<StoreAddr> {
|
||||
// type SendError = crossbeam_channel::SendError<StoreAddr>;
|
||||
//
|
||||
// fn send(&self, addr: StoreAddr) -> Result<(), Self::SendError> {
|
||||
// self.send(addr)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /// Verification sender with a [crossbeam_channel::Sender] backend.
|
||||
// /// It implements the [EcssTmSenderCore] trait to be used as PUS Verification TM sender
|
||||
// #[cfg(feature = "crossbeam")]
|
||||
// #[derive(Clone)]
|
||||
// pub struct CrossbeamVerifSender {
|
||||
// base: StdSenderBase<crossbeam_channel::Sender<StoreAddr>>,
|
||||
// }
|
||||
//
|
||||
// #[cfg(feature = "crossbeam")]
|
||||
// impl CrossbeamVerifSender {
|
||||
// pub fn new(
|
||||
// id: SenderId,
|
||||
// name: &'static str,
|
||||
// tm_store: SharedPool,
|
||||
// tx: crossbeam_channel::Sender<StoreAddr>,
|
||||
// ) -> Self {
|
||||
// Self {
|
||||
// base: StdSenderBase::new(id, name, tm_store, tx),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //noinspection RsTraitImplementation
|
||||
// #[cfg(feature = "crossbeam")]
|
||||
// impl EcssSender for CrossbeamVerifSender {
|
||||
// delegate!(
|
||||
// to self.base {
|
||||
// fn id(&self) -> SenderId;
|
||||
// fn name(&self) -> &'static str;
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// //noinspection RsTraitImplementation
|
||||
// #[cfg(feature = "crossbeam")]
|
||||
// impl EcssTmSenderCore for CrossbeamVerifSender {
|
||||
// type Error = MpscPusInStoreSendError;
|
||||
//
|
||||
// delegate!(
|
||||
// to self.base {
|
||||
// fn send_tm(&mut self, tm: PusTm) -> Result<(), Self::Error>;
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// impl<S: SendBackend + Clone + 'static> EcssSender for StdSenderBase<S> {
|
||||
// fn id(&self) -> SenderId {
|
||||
// self.id
|
||||
// }
|
||||
// fn name(&self) -> &'static str {
|
||||
// self.name
|
||||
// }
|
||||
// }
|
||||
// impl<S: SendBackend + Clone + 'static> EcssTmSenderCore for StdSenderBase<S> {
|
||||
// type Error = MpscPusInStoreSendError;
|
||||
//
|
||||
// fn send_tm(&self, tm: PusTmWrapper) -> Result<(), Self::Error> {
|
||||
// match tm {
|
||||
// PusTmWrapper::InStore(addr) => {
|
||||
// self.tx.send(addr).unwrap();
|
||||
// Ok(())
|
||||
// }
|
||||
// PusTmWrapper::Direct(tm) => {
|
||||
// let operation = |mut mg: RwLockWriteGuard<ShareablePoolProvider>| {
|
||||
// let (addr, buf) = mg.free_element(tm.len_packed())?;
|
||||
// tm.write_to_bytes(buf)
|
||||
// .map_err(MpscPusInStoreSendError::Pus)?;
|
||||
// drop(mg);
|
||||
// self.tx
|
||||
// .send(addr)
|
||||
// .map_err(|_| MpscPusInStoreSendError::RxDisconnected(addr))?;
|
||||
// Ok(())
|
||||
// };
|
||||
// match self.tm_store.write() {
|
||||
// Ok(lock) => operation(lock),
|
||||
// Err(poison_error) => {
|
||||
// if self.ignore_poison_error {
|
||||
// operation(poison_error.into_inner())
|
||||
// } else {
|
||||
// Err(MpscPusInStoreSendError::StoreLock)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -1506,7 +1326,7 @@ mod tests {
|
||||
use crate::ChannelId;
|
||||
use alloc::boxed::Box;
|
||||
use alloc::format;
|
||||
use spacepackets::ecss::tc::{PusTc, PusTcSecondaryHeader};
|
||||
use spacepackets::ecss::tc::{PusTcCreator, PusTcSecondaryHeader};
|
||||
use spacepackets::ecss::tm::PusTm;
|
||||
use spacepackets::ecss::{EcssEnumU16, EcssEnumU32, EcssEnumU8, PusError, PusPacket};
|
||||
use spacepackets::util::UnsignedEnum;
|
||||
@ -1554,10 +1374,10 @@ mod tests {
|
||||
}
|
||||
PusTmWrapper::Direct(tm) => {
|
||||
assert_eq!(PusPacket::service(&tm), 1);
|
||||
assert!(tm.source_data().is_some());
|
||||
assert!(!tm.source_data().is_empty());
|
||||
let mut time_stamp = [0; 7];
|
||||
time_stamp.clone_from_slice(&tm.timestamp().unwrap()[0..7]);
|
||||
let src_data = tm.source_data().unwrap();
|
||||
let src_data = tm.source_data();
|
||||
assert!(src_data.len() >= 4);
|
||||
let req_id =
|
||||
RequestId::from_bytes(&src_data[0..RequestId::SIZE_AS_BYTES]).unwrap();
|
||||
@ -1581,7 +1401,7 @@ mod tests {
|
||||
struct TestBase<'a> {
|
||||
vr: VerificationReporter,
|
||||
#[allow(dead_code)]
|
||||
tc: PusTc<'a>,
|
||||
tc: PusTcCreator<'a>,
|
||||
}
|
||||
|
||||
impl<'a> TestBase<'a> {
|
||||
@ -1592,7 +1412,7 @@ mod tests {
|
||||
struct TestBaseWithHelper<'a> {
|
||||
helper: VerificationReporterWithSender,
|
||||
#[allow(dead_code)]
|
||||
tc: PusTc<'a>,
|
||||
tc: PusTcCreator<'a>,
|
||||
}
|
||||
|
||||
impl<'a> TestBaseWithHelper<'a> {
|
||||
@ -1606,10 +1426,10 @@ mod tests {
|
||||
VerificationReporter::new(&cfg)
|
||||
}
|
||||
|
||||
fn base_tc_init(app_data: Option<&[u8]>) -> (PusTc, RequestId) {
|
||||
fn base_tc_init(app_data: Option<&[u8]>) -> (PusTcCreator, RequestId) {
|
||||
let mut sph = SpHeader::tc_unseg(TEST_APID, 0x34, 0).unwrap();
|
||||
let tc_header = PusTcSecondaryHeader::new_simple(17, 1);
|
||||
let pus_tc = PusTc::new(&mut sph, tc_header, app_data, true);
|
||||
let pus_tc = PusTcCreator::new(&mut sph, tc_header, app_data, true);
|
||||
let req_id = RequestId::new(&pus_tc);
|
||||
(pus_tc, req_id)
|
||||
}
|
||||
@ -2333,7 +2153,7 @@ mod tests {
|
||||
|
||||
let mut sph = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||
let tc_header = PusTcSecondaryHeader::new_simple(17, 1);
|
||||
let pus_tc_0 = PusTc::new(&mut sph, tc_header, None, true);
|
||||
let pus_tc_0 = PusTcCreator::new(&mut sph, tc_header, None, true);
|
||||
let init_token = reporter.add_tc(&pus_tc_0);
|
||||
|
||||
// Complete success sequence for a telecommand
|
||||
|
@ -22,7 +22,7 @@
|
||||
//! use satrs_core::tmtc::{ReceivesTc, ReceivesTcCore};
|
||||
//! use spacepackets::{CcsdsPacket, SpHeader};
|
||||
//! use spacepackets::ecss::SerializablePusPacket;
|
||||
//! use spacepackets::ecss::tc::PusTc;
|
||||
//! use spacepackets::ecss::tc::{PusTc, PusTcCreator};
|
||||
//!
|
||||
//! #[derive (Default)]
|
||||
//! struct ConcreteApidHandler {
|
||||
@ -56,7 +56,7 @@
|
||||
//!
|
||||
//! // Create and pass PUS telecommand with a valid APID
|
||||
//! let mut space_packet_header = SpHeader::tc_unseg(0x002, 0x34, 0).unwrap();
|
||||
//! let mut pus_tc = PusTc::new_simple(&mut space_packet_header, 17, 1, None, true);
|
||||
//! let mut pus_tc = PusTcCreator::new_simple(&mut space_packet_header, 17, 1, None, true);
|
||||
//! let mut test_buf: [u8; 32] = [0; 32];
|
||||
//! let mut size = pus_tc
|
||||
//! .write_to_bytes(test_buf.as_mut_slice())
|
||||
@ -225,7 +225,7 @@ impl<E: 'static> CcsdsDistributor<E> {
|
||||
pub(crate) mod tests {
|
||||
use super::*;
|
||||
use crate::tmtc::ccsds_distrib::{CcsdsDistributor, CcsdsPacketHandler};
|
||||
use spacepackets::ecss::tc::PusTc;
|
||||
use spacepackets::ecss::tc::PusTcCreator;
|
||||
use spacepackets::ecss::SerializablePusPacket;
|
||||
use spacepackets::CcsdsPacket;
|
||||
use std::collections::VecDeque;
|
||||
@ -236,7 +236,7 @@ pub(crate) mod tests {
|
||||
|
||||
pub fn generate_ping_tc(buf: &mut [u8]) -> &[u8] {
|
||||
let mut sph = SpHeader::tc_unseg(0x002, 0x34, 0).unwrap();
|
||||
let pus_tc = PusTc::new_simple(&mut sph, 17, 1, None, true);
|
||||
let pus_tc = PusTcCreator::new_simple(&mut sph, 17, 1, None, true);
|
||||
let size = pus_tc
|
||||
.write_to_bytes(buf)
|
||||
.expect("Error writing TC to buffer");
|
||||
@ -350,7 +350,7 @@ pub(crate) mod tests {
|
||||
};
|
||||
let mut ccsds_distrib = CcsdsDistributor::new(Box::new(apid_handler));
|
||||
let mut sph = SpHeader::tc_unseg(0x004, 0x34, 0).unwrap();
|
||||
let pus_tc = PusTc::new_simple(&mut sph, 17, 1, None, true);
|
||||
let pus_tc = PusTcCreator::new_simple(&mut sph, 17, 1, None, true);
|
||||
let mut test_buf: [u8; 32] = [0; 32];
|
||||
pus_tc
|
||||
.write_to_bytes(test_buf.as_mut_slice())
|
||||
|
@ -21,7 +21,7 @@
|
||||
//! use satrs_core::tmtc::pus_distrib::{PusDistributor, PusServiceProvider};
|
||||
//! use satrs_core::tmtc::{ReceivesTc, ReceivesTcCore};
|
||||
//! use spacepackets::SpHeader;
|
||||
//! use spacepackets::ecss::tc::PusTc;
|
||||
//! use spacepackets::ecss::tc::{PusTcCreator, PusTcReader};
|
||||
//! struct ConcretePusHandler {
|
||||
//! handler_call_count: u32
|
||||
//! }
|
||||
@ -30,7 +30,7 @@
|
||||
//! // which is used to verify the handler was called
|
||||
//! impl PusServiceProvider for ConcretePusHandler {
|
||||
//! type Error = ();
|
||||
//! fn handle_pus_tc_packet(&mut self, service: u8, header: &SpHeader, pus_tc: &PusTc) -> Result<(), Self::Error> {
|
||||
//! fn handle_pus_tc_packet(&mut self, service: u8, header: &SpHeader, pus_tc: &PusTcReader) -> Result<(), Self::Error> {
|
||||
//! assert_eq!(service, 17);
|
||||
//! assert_eq!(pus_tc.len_packed(), 13);
|
||||
//! self.handler_call_count += 1;
|
||||
@ -45,7 +45,7 @@
|
||||
//!
|
||||
//! // Create and pass PUS ping telecommand with a valid APID
|
||||
//! let mut space_packet_header = SpHeader::tc_unseg(0x002, 0x34, 0).unwrap();
|
||||
//! let mut pus_tc = PusTc::new_simple(&mut space_packet_header, 17, 1, None, true);
|
||||
//! let mut pus_tc = PusTcCreator::new_simple(&mut space_packet_header, 17, 1, None, true);
|
||||
//! let mut test_buf: [u8; 32] = [0; 32];
|
||||
//! let mut size = pus_tc
|
||||
//! .write_to_bytes(test_buf.as_mut_slice())
|
||||
@ -66,7 +66,7 @@ use crate::tmtc::{ReceivesCcsdsTc, ReceivesTcCore};
|
||||
use alloc::boxed::Box;
|
||||
use core::fmt::{Display, Formatter};
|
||||
use downcast_rs::Downcast;
|
||||
use spacepackets::ecss::tc::{PusTc, PusTcReader};
|
||||
use spacepackets::ecss::tc::PusTcReader;
|
||||
use spacepackets::ecss::{PusError, PusPacket};
|
||||
use spacepackets::SpHeader;
|
||||
#[cfg(feature = "std")]
|
||||
@ -175,7 +175,6 @@ mod tests {
|
||||
};
|
||||
use crate::tmtc::ccsds_distrib::{CcsdsDistributor, CcsdsPacketHandler};
|
||||
use alloc::vec::Vec;
|
||||
use spacepackets::ecss::tc::PusTc;
|
||||
use spacepackets::ecss::PusError;
|
||||
use spacepackets::CcsdsPacket;
|
||||
#[cfg(feature = "std")]
|
||||
@ -200,10 +199,10 @@ mod tests {
|
||||
&mut self,
|
||||
service: u8,
|
||||
sp_header: &SpHeader,
|
||||
pus_tc: &PusTc,
|
||||
pus_tc: &PusTcReader,
|
||||
) -> Result<(), Self::Error> {
|
||||
let mut vec: Vec<u8> = Vec::new();
|
||||
pus_tc.append_to_vec(&mut vec)?;
|
||||
vec.extend_from_slice(pus_tc.raw_data());
|
||||
Ok(self
|
||||
.pus_queue
|
||||
.lock()
|
||||
@ -218,10 +217,10 @@ mod tests {
|
||||
&mut self,
|
||||
service: u8,
|
||||
sp_header: &SpHeader,
|
||||
pus_tc: &PusTc,
|
||||
pus_tc: &PusTcReader,
|
||||
) -> Result<(), Self::Error> {
|
||||
let mut vec: Vec<u8> = Vec::new();
|
||||
pus_tc.append_to_vec(&mut vec)?;
|
||||
vec.extend_from_slice(pus_tc.raw_data());
|
||||
Ok(self.pus_queue.push_back((service, sp_header.apid(), vec)))
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use spacepackets::ecss::tm::{PusTm, PusTmSecondaryHeader};
|
||||
use spacepackets::ecss::tm::{PusTmCreator, PusTmSecondaryHeader};
|
||||
use spacepackets::time::cds::TimeProvider;
|
||||
use spacepackets::time::TimeWriter;
|
||||
use spacepackets::SpHeader;
|
||||
@ -10,7 +10,7 @@ pub use std_mod::*;
|
||||
pub mod std_mod {
|
||||
use crate::pool::{ShareablePoolProvider, SharedPool, StoreAddr};
|
||||
use crate::pus::EcssTmtcError;
|
||||
use spacepackets::ecss::tm::{PusTm, PusTmCreator};
|
||||
use spacepackets::ecss::tm::PusTmCreator;
|
||||
use spacepackets::ecss::SerializablePusPacket;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
@ -61,7 +61,7 @@ impl PusTmWithCdsShortHelper {
|
||||
subservice: u8,
|
||||
source_data: Option<&'a [u8]>,
|
||||
seq_count: u16,
|
||||
) -> PusTm {
|
||||
) -> PusTmCreator {
|
||||
let time_stamp = TimeProvider::from_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)
|
||||
@ -74,7 +74,7 @@ impl PusTmWithCdsShortHelper {
|
||||
source_data: Option<&'a [u8]>,
|
||||
stamper: &TimeProvider,
|
||||
seq_count: u16,
|
||||
) -> PusTm {
|
||||
) -> PusTmCreator {
|
||||
stamper.write_to_bytes(&mut self.cds_short_buf).unwrap();
|
||||
self.create_pus_tm_common(service, subservice, source_data, seq_count)
|
||||
}
|
||||
@ -85,9 +85,9 @@ impl PusTmWithCdsShortHelper {
|
||||
subservice: u8,
|
||||
source_data: Option<&'a [u8]>,
|
||||
seq_count: u16,
|
||||
) -> PusTm {
|
||||
) -> PusTmCreator {
|
||||
let mut reply_header = SpHeader::tm_unseg(self.apid, seq_count, 0).unwrap();
|
||||
let tc_header = PusTmSecondaryHeader::new_simple(service, subservice, &self.cds_short_buf);
|
||||
PusTm::new(&mut reply_header, tc_header, source_data, true)
|
||||
PusTmCreator::new(&mut reply_header, tc_header, source_data, true)
|
||||
}
|
||||
}
|
||||
|
@ -107,8 +107,7 @@ fn test_threaded_usage() {
|
||||
assert_eq!(tm.0.service(), 5);
|
||||
assert_eq!(tm.0.subservice(), 1);
|
||||
let src_data = tm.0.source_data();
|
||||
assert!(src_data.is_some());
|
||||
let src_data = src_data.unwrap();
|
||||
assert!(!src_data.is_empty());
|
||||
assert_eq!(src_data.len(), 4);
|
||||
let event =
|
||||
EventU32::from(u32::from_be_bytes(src_data[0..4].try_into().unwrap()));
|
||||
@ -137,8 +136,7 @@ fn test_threaded_usage() {
|
||||
assert_eq!(tm.0.service(), 5);
|
||||
assert_eq!(tm.0.subservice(), 2);
|
||||
let src_data = tm.0.source_data();
|
||||
assert!(src_data.is_some());
|
||||
let src_data = src_data.unwrap();
|
||||
assert!(!src_data.is_empty());
|
||||
assert_eq!(src_data.len(), 12);
|
||||
let event =
|
||||
EventU32::from(u32::from_be_bytes(src_data[0..4].try_into().unwrap()));
|
||||
|
@ -9,7 +9,7 @@ pub mod crossbeam_test {
|
||||
};
|
||||
use satrs_core::pus::MpscTmInStoreSender;
|
||||
use satrs_core::tmtc::tm_helper::SharedTmStore;
|
||||
use spacepackets::ecss::tc::{PusTc, PusTcSecondaryHeader};
|
||||
use spacepackets::ecss::tc::{PusTc, PusTcCreator, PusTcSecondaryHeader};
|
||||
use spacepackets::ecss::tm::PusTm;
|
||||
use spacepackets::ecss::{EcssEnumU16, EcssEnumU8, PusPacket, SerializablePusPacket};
|
||||
use spacepackets::SpHeader;
|
||||
@ -56,14 +56,14 @@ pub mod crossbeam_test {
|
||||
let mut tc_guard = shared_tc_pool_0.write().unwrap();
|
||||
let mut sph = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||
let tc_header = PusTcSecondaryHeader::new_simple(17, 1);
|
||||
let pus_tc_0 = PusTc::new(&mut sph, tc_header, None, true);
|
||||
let pus_tc_0 = PusTcCreator::new(&mut sph, tc_header, None, true);
|
||||
req_id_0 = RequestId::new(&pus_tc_0);
|
||||
let (addr, mut buf) = tc_guard.free_element(pus_tc_0.len_packed()).unwrap();
|
||||
pus_tc_0.write_to_bytes(&mut buf).unwrap();
|
||||
tx_tc_0.send(addr).unwrap();
|
||||
let mut sph = SpHeader::tc_unseg(TEST_APID, 1, 0).unwrap();
|
||||
let tc_header = PusTcSecondaryHeader::new_simple(5, 1);
|
||||
let pus_tc_1 = PusTc::new(&mut sph, tc_header, None, true);
|
||||
let pus_tc_1 = PusTcCreator::new(&mut sph, tc_header, None, true);
|
||||
req_id_1 = RequestId::new(&pus_tc_1);
|
||||
let (addr, mut buf) = tc_guard.free_element(pus_tc_0.len_packed()).unwrap();
|
||||
pus_tc_1.write_to_bytes(&mut buf).unwrap();
|
||||
@ -156,11 +156,9 @@ pub mod crossbeam_test {
|
||||
}
|
||||
let (pus_tm, _) = PusTm::from_bytes(&tm_buf[0..tm_len], 7)
|
||||
.expect("Error reading verification TM");
|
||||
let req_id = RequestId::from_bytes(
|
||||
&pus_tm.source_data().expect("Invalid TM source data")
|
||||
[0..RequestId::SIZE_AS_BYTES],
|
||||
)
|
||||
.unwrap();
|
||||
let req_id =
|
||||
RequestId::from_bytes(&pus_tm.source_data()[0..RequestId::SIZE_AS_BYTES])
|
||||
.expect("reading request ID from PUS TM source data failed");
|
||||
if !verif_map.contains_key(&req_id) {
|
||||
let mut content = Vec::new();
|
||||
content.push(pus_tm.subservice());
|
||||
|
@ -1,7 +1,7 @@
|
||||
use satrs_core::pus::verification::RequestId;
|
||||
use satrs_core::spacepackets::ecss::tc::PusTcCreator;
|
||||
use satrs_core::spacepackets::ecss::tm::PusTmReader;
|
||||
use satrs_core::{
|
||||
spacepackets::ecss::tc::PusTc,
|
||||
spacepackets::ecss::tm::PusTm,
|
||||
spacepackets::ecss::{PusPacket, SerializablePusPacket},
|
||||
spacepackets::SpHeader,
|
||||
};
|
||||
@ -13,7 +13,7 @@ fn main() {
|
||||
let mut buf = [0; 32];
|
||||
let addr = SocketAddr::new(IpAddr::V4(OBSW_SERVER_ADDR), SERVER_PORT);
|
||||
let mut sph = SpHeader::tc_unseg(0x02, 0, 0).unwrap();
|
||||
let pus_tc = PusTc::new_simple(&mut sph, 17, 1, None, true);
|
||||
let pus_tc = PusTcCreator::new_simple(&mut sph, 17, 1, None, true);
|
||||
let client = UdpSocket::bind("127.0.0.1:7302").expect("Connecting to UDP server failed");
|
||||
let tc_req_id = RequestId::new(&pus_tc);
|
||||
println!("Packing and sending PUS ping command TC[17,1] with request ID {tc_req_id}");
|
||||
@ -30,14 +30,14 @@ fn main() {
|
||||
let res = client.recv(&mut buf);
|
||||
match res {
|
||||
Ok(_len) => {
|
||||
let (pus_tm, size) = PusTm::from_bytes(&buf, 7).expect("Parsing PUS TM failed");
|
||||
let (pus_tm, size) = PusTmReader::new(&buf, 7).expect("Parsing PUS TM failed");
|
||||
if pus_tm.service() == 17 && pus_tm.subservice() == 2 {
|
||||
println!("Received PUS Ping Reply TM[17,2]")
|
||||
} else if pus_tm.service() == 1 {
|
||||
if pus_tm.source_data().is_none() {
|
||||
if pus_tm.source_data().is_empty() {
|
||||
println!("Invalid verification TM, no source data");
|
||||
}
|
||||
let src_data = pus_tm.source_data().unwrap();
|
||||
let src_data = pus_tm.source_data();
|
||||
if src_data.len() < 4 {
|
||||
println!("Invalid verification TM source data, less than 4 bytes")
|
||||
}
|
||||
|
@ -37,12 +37,10 @@ use satrs_core::pus::verification::{
|
||||
};
|
||||
use satrs_core::pus::{MpscTcInStoreReceiver, MpscTmInStoreSender};
|
||||
use satrs_core::seq_count::{CcsdsSimpleSeqCountProvider, SequenceCountProviderCore};
|
||||
use satrs_core::spacepackets::ecss::tm::PusTmZeroCopyWriter;
|
||||
use satrs_core::spacepackets::ecss::tm::{PusTmCreator, PusTmZeroCopyWriter};
|
||||
use satrs_core::spacepackets::{
|
||||
ecss::tm::{PusTm, PusTmSecondaryHeader},
|
||||
time::cds::TimeProvider,
|
||||
time::TimeWriter,
|
||||
SequenceFlags, SpHeader,
|
||||
ecss::tm::PusTmSecondaryHeader, time::cds::TimeProvider, time::TimeWriter, SequenceFlags,
|
||||
SpHeader,
|
||||
};
|
||||
use satrs_core::tmtc::tm_helper::SharedTmStore;
|
||||
use satrs_core::tmtc::{AddressableId, TargetId};
|
||||
@ -415,7 +413,7 @@ fn main() {
|
||||
unique_id,
|
||||
};
|
||||
addressable_id.write_to_be_bytes(&mut buf).unwrap();
|
||||
let pus_tm = PusTm::new(
|
||||
let pus_tm = PusTmCreator::new(
|
||||
&mut sp_header,
|
||||
sec_header,
|
||||
Some(&buf),
|
||||
|
@ -50,7 +50,7 @@ impl PusService8ActionHandler {
|
||||
time_stamp: &[u8],
|
||||
) -> Result<(), PusPacketHandlingError> {
|
||||
let user_data = tc.user_data();
|
||||
if user_data.is_none() || user_data.unwrap().len() < 8 {
|
||||
if user_data.len() < 8 {
|
||||
self.psb()
|
||||
.verification_handler
|
||||
.borrow_mut()
|
||||
@ -63,7 +63,6 @@ impl PusService8ActionHandler {
|
||||
"Expected at least 4 bytes".into(),
|
||||
));
|
||||
}
|
||||
let user_data = user_data.unwrap();
|
||||
let target_id = u32::from_be_bytes(user_data[0..4].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) {
|
||||
|
@ -61,8 +61,8 @@ impl PusServiceHandler for PusService3HkHandler {
|
||||
let subservice = tc.subservice();
|
||||
let mut partial_error = None;
|
||||
let time_stamp = self.psb().get_current_timestamp(&mut partial_error);
|
||||
let user_data = tc.user_data().unwrap();
|
||||
if tc.user_data().is_none() {
|
||||
let user_data = tc.user_data();
|
||||
if user_data.is_empty() {
|
||||
self.psb
|
||||
.verification_handler
|
||||
.borrow_mut()
|
||||
|
@ -11,8 +11,8 @@ use crate::pus::{PusReceiver, PusTcMpscRouter};
|
||||
use satrs_core::pool::{SharedPool, StoreAddr, StoreError};
|
||||
use satrs_core::pus::verification::StdVerifReporterWithSender;
|
||||
use satrs_core::pus::{ReceivesEcssPusTc, TcAddrWithToken};
|
||||
use satrs_core::spacepackets::ecss::tc::{PusTc, PusTcCreator, PusTcReader};
|
||||
use satrs_core::spacepackets::ecss::{PusPacket, SerializablePusPacket};
|
||||
use satrs_core::spacepackets::ecss::tc::{PusTc, PusTcReader};
|
||||
use satrs_core::spacepackets::ecss::PusPacket;
|
||||
use satrs_core::spacepackets::SpHeader;
|
||||
use satrs_core::tmtc::tm_helper::SharedTmStore;
|
||||
use satrs_core::tmtc::{CcsdsDistributor, CcsdsError, ReceivesCcsdsTc};
|
||||
@ -53,12 +53,10 @@ pub struct TcStore {
|
||||
}
|
||||
|
||||
impl TcStore {
|
||||
pub fn add_pus_tc(&mut self, pus_tc: &PusTcCreator) -> Result<StoreAddr, StoreError> {
|
||||
pub fn add_pus_tc(&mut self, pus_tc: &PusTcReader) -> Result<StoreAddr, StoreError> {
|
||||
let mut pg = self.pool.write().expect("error locking TC store");
|
||||
let (addr, buf) = pg.free_element(pus_tc.len_packed())?;
|
||||
pus_tc
|
||||
.write_to_bytes(buf)
|
||||
.expect("writing PUS TC to store failed");
|
||||
buf[0..pus_tc.len_packed()].copy_from_slice(pus_tc.raw_data());
|
||||
Ok(addr)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user