Larger update #49
@ -1,4 +1,7 @@
|
|||||||
//! # PUS support modules
|
//! # 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")]
|
#[cfg(feature = "alloc")]
|
||||||
use downcast_rs::{impl_downcast, Downcast};
|
use downcast_rs::{impl_downcast, Downcast};
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
@ -296,6 +299,8 @@ pub mod std_mod {
|
|||||||
InvalidSubservice(u8),
|
InvalidSubservice(u8),
|
||||||
#[error("Not enough application data available: {0}")]
|
#[error("Not enough application data available: {0}")]
|
||||||
NotEnoughAppData(String),
|
NotEnoughAppData(String),
|
||||||
|
#[error("Invalid application data")]
|
||||||
|
InvalidAppData(String),
|
||||||
#[error("Generic store error: {0}")]
|
#[error("Generic store error: {0}")]
|
||||||
StoreError(#[from] StoreError),
|
StoreError(#[from] StoreError),
|
||||||
#[error("Error with the pool RwGuard: {0}")]
|
#[error("Error with the pool RwGuard: {0}")]
|
||||||
@ -318,6 +323,7 @@ pub mod std_mod {
|
|||||||
VerificationError,
|
VerificationError,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Generic result type for handlers which can process PUS packets.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum PusPacketHandlerResult {
|
pub enum PusPacketHandlerResult {
|
||||||
RequestHandled,
|
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>);
|
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 struct PusServiceBase {
|
||||||
pub tc_rx: mpsc::Receiver<AcceptedTc>,
|
pub tc_rx: mpsc::Receiver<AcceptedTc>,
|
||||||
pub tc_store: SharedPool,
|
pub tc_store: SharedPool,
|
||||||
@ -383,6 +394,7 @@ pub mod std_mod {
|
|||||||
}
|
}
|
||||||
time_stamp
|
time_stamp
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_current_timestamp_ignore_error(&self) -> [u8; 7] {
|
pub fn get_current_timestamp_ignore_error(&self) -> [u8; 7] {
|
||||||
let mut dummy = None;
|
let mut dummy = None;
|
||||||
self.get_current_timestamp(&mut dummy)
|
self.get_current_timestamp(&mut dummy)
|
||||||
|
@ -10,6 +10,14 @@ use spacepackets::tc::PusTc;
|
|||||||
use spacepackets::time::cds::TimeProvider;
|
use spacepackets::time::cds::TimeProvider;
|
||||||
use std::sync::mpsc::{Receiver, Sender};
|
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 {
|
pub struct PusService11SchedHandler {
|
||||||
psb: PusServiceBase,
|
psb: PusServiceBase,
|
||||||
scheduler: PusScheduler,
|
scheduler: PusScheduler,
|
||||||
@ -41,6 +49,10 @@ impl PusService11SchedHandler {
|
|||||||
pub fn scheduler_mut(&mut self) -> &mut PusScheduler {
|
pub fn scheduler_mut(&mut self) -> &mut PusScheduler {
|
||||||
&mut self.scheduler
|
&mut self.scheduler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn scheduler(&self) -> &PusScheduler {
|
||||||
|
&self.scheduler
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PusServiceHandler for PusService11SchedHandler {
|
impl PusServiceHandler for PusService11SchedHandler {
|
||||||
|
@ -12,6 +12,8 @@ use spacepackets::SpHeader;
|
|||||||
use std::format;
|
use std::format;
|
||||||
use std::sync::mpsc::{Receiver, Sender};
|
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 {
|
pub struct PusService17TestHandler {
|
||||||
psb: PusServiceBase,
|
psb: PusServiceBase,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user