Larger update #49

Merged
muellerr merged 41 commits from this-is-complex into main 2023-07-08 15:02:42 +02:00
3 changed files with 26 additions and 0 deletions
Showing only changes of commit 985af06d94 - Show all commits

View File

@ -1,4 +1,7 @@
//! # PUS support modules
//!
//! This module contains structures to make working with the PUS C standard easier.
//! The satrs-example application contains various usage examples of these components.
#[cfg(feature = "alloc")]
use downcast_rs::{impl_downcast, Downcast};
#[cfg(feature = "alloc")]
@ -296,6 +299,8 @@ pub mod std_mod {
InvalidSubservice(u8),
#[error("Not enough application data available: {0}")]
NotEnoughAppData(String),
#[error("Invalid application data")]
InvalidAppData(String),
#[error("Generic store error: {0}")]
StoreError(#[from] StoreError),
#[error("Error with the pool RwGuard: {0}")]
@ -318,6 +323,7 @@ pub mod std_mod {
VerificationError,
}
/// Generic result type for handlers which can process PUS packets.
#[derive(Debug, Clone)]
pub enum PusPacketHandlerResult {
RequestHandled,
@ -333,8 +339,13 @@ pub mod std_mod {
}
}
/// Generic abstraction for a telecommand being sent around after is has been accepted.
/// The actual telecommand is stored inside a pre-allocated pool structure.
pub type AcceptedTc = (StoreAddr, VerificationToken<TcStateAccepted>);
/// Base class for handlers which can handle PUS TC packets. Right now, the message queue
/// backend is constrained to [mpsc::channel]s and the verification reporter
/// is constrained to the [StdVerifReporterWithSender].
pub struct PusServiceBase {
pub tc_rx: mpsc::Receiver<AcceptedTc>,
pub tc_store: SharedPool,
@ -383,6 +394,7 @@ pub mod std_mod {
}
time_stamp
}
pub fn get_current_timestamp_ignore_error(&self) -> [u8; 7] {
let mut dummy = None;
self.get_current_timestamp(&mut dummy)

View File

@ -10,6 +10,14 @@ use spacepackets::tc::PusTc;
use spacepackets::time::cds::TimeProvider;
use std::sync::mpsc::{Receiver, Sender};
/// This is a helper class for [std] environments to handle generic PUS 11 (scheduling service)
/// packets. This handler is constrained to using the [PusScheduler], but is able to process
/// the most important PUS requests for a scheduling service.
///
/// Please note that this class does not do the regular periodic handling like releasing any
/// telecommands inside the scheduler. The user can retrieve the wrapped scheduler via the
/// [Self::scheduler] and [Self::scheduler_mut] function and then use the scheduler API to release
/// telecommands when applicable.
pub struct PusService11SchedHandler {
psb: PusServiceBase,
scheduler: PusScheduler,
@ -41,6 +49,10 @@ impl PusService11SchedHandler {
pub fn scheduler_mut(&mut self) -> &mut PusScheduler {
&mut self.scheduler
}
pub fn scheduler(&self) -> &PusScheduler {
&self.scheduler
}
}
impl PusServiceHandler for PusService11SchedHandler {

View File

@ -12,6 +12,8 @@ use spacepackets::SpHeader;
use std::format;
use std::sync::mpsc::{Receiver, Sender};
/// This is a helper class for [std] environments to handle generic PUS 17 (test service) packets.
/// This handler only processes ping requests and generates a ping reply for them accordingly.
pub struct PusService17TestHandler {
psb: PusServiceBase,
}