bump spacepackets, clippy fixes

This commit is contained in:
2023-02-04 15:35:18 +01:00
parent 44ce25cd82
commit 7dbbd18be4
8 changed files with 85 additions and 155 deletions

View File

@ -53,10 +53,10 @@ default-features = false
optional = true
[dependencies.spacepackets]
version = "0.5.2"
# version = "0.5.2"
# path = "../spacepackets"
# git = "https://egit.irs.uni-stuttgart.de/rust/spacepackets.git"
# rev = "..."
git = "https://egit.irs.uni-stuttgart.de/rust/spacepackets.git"
rev = "cfa5f8099c95389628440a1611766e3b178fcdb3"
default-features = false

View File

@ -7,56 +7,8 @@ use spacepackets::{SpHeader, MAX_APID};
use crate::pus::EcssTmSenderCore;
#[cfg(feature = "alloc")]
pub use allocvec::EventReporter;
pub use spacepackets::ecss::event::*;
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
pub enum Subservices {
TmInfoReport = 1,
TmLowSeverityReport = 2,
TmMediumSeverityReport = 3,
TmHighSeverityReport = 4,
TcEnableEventGeneration = 5,
TcDisableEventGeneration = 6,
TcReportDisabledList = 7,
TmDisabledEventsReport = 8,
}
impl From<Subservices> for u8 {
fn from(enumeration: Subservices) -> Self {
enumeration as u8
}
}
impl TryFrom<u8> for Subservices {
type Error = ();
fn try_from(value: u8) -> Result<Self, Self::Error> {
match value {
x if x == Subservices::TmInfoReport as u8 => Ok(Subservices::TmInfoReport),
x if x == Subservices::TmLowSeverityReport as u8 => {
Ok(Subservices::TmLowSeverityReport)
}
x if x == Subservices::TmMediumSeverityReport as u8 => {
Ok(Subservices::TmMediumSeverityReport)
}
x if x == Subservices::TmHighSeverityReport as u8 => {
Ok(Subservices::TmHighSeverityReport)
}
x if x == Subservices::TcEnableEventGeneration as u8 => {
Ok(Subservices::TcEnableEventGeneration)
}
x if x == Subservices::TcDisableEventGeneration as u8 => {
Ok(Subservices::TcDisableEventGeneration)
}
x if x == Subservices::TcReportDisabledList as u8 => {
Ok(Subservices::TcReportDisabledList)
}
x if x == Subservices::TmDisabledEventsReport as u8 => {
Ok(Subservices::TmDisabledEventsReport)
}
_ => Err(()),
}
}
}
pub struct EventReporterBase {
msg_count: u16,
apid: u16,
@ -85,7 +37,7 @@ impl EventReporterBase {
) -> Result<(), EcssTmErrorWithSend<E>> {
self.generate_and_send_generic_tm(
buf,
Subservices::TmInfoReport,
Subservice::TmInfoReport,
sender,
time_stamp,
event_id,
@ -103,7 +55,7 @@ impl EventReporterBase {
) -> Result<(), EcssTmErrorWithSend<E>> {
self.generate_and_send_generic_tm(
buf,
Subservices::TmLowSeverityReport,
Subservice::TmLowSeverityReport,
sender,
time_stamp,
event_id,
@ -121,7 +73,7 @@ impl EventReporterBase {
) -> Result<(), EcssTmErrorWithSend<E>> {
self.generate_and_send_generic_tm(
buf,
Subservices::TmMediumSeverityReport,
Subservice::TmMediumSeverityReport,
sender,
time_stamp,
event_id,
@ -139,7 +91,7 @@ impl EventReporterBase {
) -> Result<(), EcssTmErrorWithSend<E>> {
self.generate_and_send_generic_tm(
buf,
Subservices::TmHighSeverityReport,
Subservice::TmHighSeverityReport,
sender,
time_stamp,
event_id,
@ -150,7 +102,7 @@ impl EventReporterBase {
fn generate_and_send_generic_tm<E>(
&mut self,
buf: &mut [u8],
subservice: Subservices,
subservice: Subservice,
sender: &mut (impl EcssTmSenderCore<Error = E> + ?Sized),
time_stamp: &[u8],
event_id: impl EcssEnumeration,
@ -165,7 +117,7 @@ impl EventReporterBase {
fn generate_generic_event_tm<'a>(
&'a self,
buf: &'a mut [u8],
subservice: Subservices,
subservice: Subservice,
time_stamp: &'a [u8],
event_id: impl EcssEnumeration,
aux_data: Option<&[u8]>,
@ -332,12 +284,12 @@ mod tests {
}
}
fn severity_to_subservice(severity: Severity) -> Subservices {
fn severity_to_subservice(severity: Severity) -> Subservice {
match severity {
Severity::INFO => Subservices::TmInfoReport,
Severity::LOW => Subservices::TmLowSeverityReport,
Severity::MEDIUM => Subservices::TmMediumSeverityReport,
Severity::HIGH => Subservices::TmHighSeverityReport,
Severity::INFO => Subservice::TmInfoReport,
Severity::LOW => Subservice::TmLowSeverityReport,
Severity::MEDIUM => Subservice::TmMediumSeverityReport,
Severity::HIGH => Subservice::TmHighSeverityReport,
}
}

View File

@ -1,8 +1 @@
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum Subservice {
TcEnableGeneration = 5,
TcDisableGeneration = 6,
TmHkPacket = 25,
TcGenerateOneShotHk = 27,
TcModifyCollectionInterval = 31,
}
pub use spacepackets::ecss::hk::*;

View File

@ -83,16 +83,6 @@ impl From<TimestampError> for ScheduleError {
#[cfg(feature = "std")]
impl Error for ScheduleError {}
//TODO: Move to spacepackets
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub enum ScheduleSubservice {
EnableScheduling = 1,
DisableScheduling = 2,
ResetScheduling = 3,
InsertActivity = 4,
DeleteActivity = 5,
}
/// This is the core data structure for scheduling PUS telecommands with [alloc] support.
///
/// It is assumed that the actual telecommand data is stored in a separate TC pool offering
@ -323,17 +313,9 @@ impl PusScheduler {
mod tests {
use crate::pool::{LocalPool, PoolCfg, PoolProvider, StoreAddr};
use crate::pus::scheduling::{PusScheduler, ScheduleError};
use crate::tmtc::ccsds_distrib::tests::generate_ping_tc;
use alloc::rc::Rc;
use core::borrow::BorrowMut;
use spacepackets::ecss::PacketTypeCodes::UnsignedInt;
use spacepackets::ecss::PusPacket;
use spacepackets::tc::PusTc;
use spacepackets::time::{cds, TimeWriter, UnixTimestamp};
use spacepackets::{CcsdsPacket, SpHeader};
use std::cell::RefCell;
use std::sync::mpsc;
use std::sync::mpsc::{channel, Receiver, TryRecvError};
use spacepackets::SpHeader;
use std::time::Duration;
use std::vec::Vec;
#[allow(unused_imports)]
@ -404,7 +386,7 @@ mod tests {
)
.unwrap();
let worked = scheduler
scheduler
.insert_unwrapped_and_stored_tc(
UnixTimestamp::new_only_seconds(100),
StoreAddr {
@ -414,7 +396,7 @@ mod tests {
)
.unwrap();
let worked = scheduler
scheduler
.insert_unwrapped_and_stored_tc(
UnixTimestamp::new_only_seconds(300),
StoreAddr {
@ -465,10 +447,14 @@ mod tests {
let first_addr = pool.add(&[2, 2, 2]).unwrap();
scheduler.insert_unwrapped_and_stored_tc(UnixTimestamp::new_only_seconds(100), first_addr);
scheduler
.insert_unwrapped_and_stored_tc(UnixTimestamp::new_only_seconds(100), first_addr)
.expect("insertion failed");
let second_addr = pool.add(&[5, 6, 7]).unwrap();
scheduler.insert_unwrapped_and_stored_tc(UnixTimestamp::new_only_seconds(200), second_addr);
scheduler
.insert_unwrapped_and_stored_tc(UnixTimestamp::new_only_seconds(200), second_addr)
.expect("insertion failed");
let mut i = 0;
let mut test_closure_1 = |boolvar: bool, store_addr: &StoreAddr| {
@ -523,10 +509,14 @@ mod tests {
let first_addr = pool.add(&[2, 2, 2]).unwrap();
scheduler.insert_unwrapped_and_stored_tc(UnixTimestamp::new_only_seconds(100), first_addr);
scheduler
.insert_unwrapped_and_stored_tc(UnixTimestamp::new_only_seconds(100), first_addr)
.expect("insertion failed");
let second_addr = pool.add(&[2, 2, 2]).unwrap();
scheduler.insert_unwrapped_and_stored_tc(UnixTimestamp::new_only_seconds(100), second_addr);
scheduler
.insert_unwrapped_and_stored_tc(UnixTimestamp::new_only_seconds(100), second_addr)
.expect("insertion failed");
let mut i = 0;
let mut test_closure = |boolvar: bool, store_addr: &StoreAddr| {
@ -572,10 +562,14 @@ mod tests {
let first_addr = pool.add(&[2, 2, 2]).unwrap();
scheduler.insert_unwrapped_and_stored_tc(UnixTimestamp::new_only_seconds(100), first_addr);
scheduler
.insert_unwrapped_and_stored_tc(UnixTimestamp::new_only_seconds(100), first_addr)
.expect("insertion failed");
let second_addr = pool.add(&[5, 6, 7]).unwrap();
scheduler.insert_unwrapped_and_stored_tc(UnixTimestamp::new_only_seconds(200), second_addr);
scheduler
.insert_unwrapped_and_stored_tc(UnixTimestamp::new_only_seconds(200), second_addr)
.expect("insertion failed");
let mut i = 0;
let mut test_closure_1 = |boolvar: bool, store_addr: &StoreAddr| {

View File

@ -88,6 +88,7 @@ use spacepackets::{CcsdsPacket, PacketId, PacketSequenceCtrl};
use spacepackets::{SpHeader, MAX_APID};
pub use crate::seq_count::SeqCountProviderSimple;
pub use spacepackets::ecss::verification::*;
#[cfg(feature = "alloc")]
pub use alloc_mod::{
@ -103,24 +104,6 @@ pub use stdmod::{
StdVerifSenderError,
};
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
pub enum Subservice {
TmAcceptanceSuccess = 1,
TmAcceptanceFailure = 2,
TmStartSuccess = 3,
TmStartFailure = 4,
TmStepSuccess = 5,
TmStepFailure = 6,
TmCompletionSuccess = 7,
TmCompletionFailure = 8,
}
impl From<Subservice> for u8 {
fn from(enumeration: Subservice) -> Self {
enumeration as u8
}
}
/// This is a request identifier as specified in 5.4.11.2 c. of the PUS standard
/// This field equivalent to the first two bytes of the CCSDS space packet header.
#[derive(Debug, Eq, Copy, Clone)]