Add initial support for request ID in scheduler #31

Merged
muellerr merged 7 commits from request_id_support_sched into main 2023-02-13 09:30:53 +01:00
6 changed files with 826 additions and 125 deletions

View File

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

View File

@ -1,4 +1,4 @@
//! # Core components of the Flight Software Rust Crate (FSRC) collection
//! # Core components of the sat-rs framework
//!
//! This is a collection of Rust crates which can be used to build On-Board Software for remote
//! systems like satellites of rovers. It has special support for space tailored protocols

View File

@ -79,6 +79,8 @@ use alloc::vec;
use alloc::vec::Vec;
use core::fmt::{Display, Formatter};
use delegate::delegate;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "std")]
use std::boxed::Box;
#[cfg(feature = "std")]
@ -130,6 +132,7 @@ pub struct LocalPool {
/// Simple address type used for transactions with the local pool.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct StoreAddr {
pub(crate) pool_idx: u16,
pub(crate) packet_idx: NumBlocks,
@ -144,6 +147,7 @@ impl StoreAddr {
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum StoreIdError {
InvalidSubpool(u16),
InvalidPacketIdx(u16),
@ -166,6 +170,7 @@ impl Display for StoreIdError {
impl Error for StoreIdError {}
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum StoreError {
/// Requested data block is too large
DataTooLarge(usize),
@ -252,6 +257,14 @@ pub trait PoolProvider {
/// Delete data inside the pool given a [StoreAddr]
fn delete(&mut self, addr: StoreAddr) -> Result<(), StoreError>;
fn has_element_at(&self, addr: &StoreAddr) -> Result<bool, StoreError>;
/// Retrieve the length of the data at the given store address.
fn len_of_data(&self, addr: &StoreAddr) -> Result<usize, StoreError> {
if !self.has_element_at(addr)? {
return Err(StoreError::DataDoesNotExist(*addr));
}
return Ok(self.read(addr)?.len());
}
}
impl LocalPool {

File diff suppressed because it is too large Load Diff

View File

@ -104,8 +104,11 @@ pub use stdmod::{
StdVerifSenderError,
};
/// This is a request identifier as specified in 5.4.11.2 c. of the PUS standard
/// 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.
/// This version of the request ID is supplied in the verification reports and does not contain
/// the source ID.
#[derive(Debug, Eq, Copy, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct RequestId {

View File

@ -16,7 +16,7 @@ use crate::pus::{PusReceiver, PusTcArgs, PusTmArgs};
use crate::requests::RequestWithToken;
use satrs_core::pool::{SharedPool, StoreAddr, StoreError};
use satrs_core::pus::event_man::EventRequestWithToken;
use satrs_core::pus::scheduling::PusScheduler;
use satrs_core::pus::scheduling::{PusScheduler, TcInfo};
use satrs_core::pus::verification::StdVerifReporterWithSender;
use satrs_core::spacepackets::{ecss::PusPacket, tc::PusTc, tm::PusTm, SpHeader};
use satrs_core::tmtc::{
@ -217,12 +217,12 @@ fn core_tmtc_loop(
pus_receiver: &mut PusReceiver,
scheduler: Rc<RefCell<PusScheduler>>,
) {
let releaser = |enabled: bool, addr: &StoreAddr| -> bool {
let releaser = |enabled: bool, info: &TcInfo| -> bool {
if enabled {
tc_args
.tc_source
.tc_source
.send(*addr)
.send(info.addr())
.expect("sending TC to TC source failed");
}
true
@ -239,7 +239,7 @@ fn core_tmtc_loop(
scheduler.update_time_from_now().unwrap();
if let Ok(released_tcs) = scheduler.release_telecommands(releaser, pool.as_mut()) {
if released_tcs > 0 {
println!("{} Tc(s) released from scheduler", released_tcs);
println!("{released_tcs} TC(s) released from scheduler");
}
}
drop(pool);