This commit is contained in:
2023-07-04 15:17:43 +02:00
parent e786773a65
commit 3a1c5832a9
6 changed files with 149 additions and 36 deletions

View File

@ -20,7 +20,6 @@ pub mod verification;
#[cfg(feature = "alloc")]
pub use alloc_mod::*;
use crate::pus::verification::TcStateToken;
use crate::SenderId;
#[cfg(feature = "std")]
pub use std_mod::*;

View File

@ -1,8 +1,43 @@
use spacepackets::ecss::SerializablePusPacket;
use spacepackets::time::cds::TimeProvider;
use spacepackets::time::TimeWriter;
use spacepackets::tm::{PusTm, PusTmSecondaryHeader};
use spacepackets::SpHeader;
#[cfg(feature = "std")]
pub use std_mod::*;
#[cfg(feature = "std")]
pub mod std_mod {
use crate::pool::{SharedPool, StoreAddr};
use spacepackets::ecss::SerializablePusPacket;
use spacepackets::tm::PusTm;
#[derive(Clone)]
pub struct SharedTmStore {
pool: SharedPool,
}
impl SharedTmStore {
pub fn new(backing_pool: SharedPool) -> Self {
Self { pool: backing_pool }
}
pub fn backing_pool(&self) -> SharedPool {
self.pool.clone()
}
pub fn add_pus_tm(&mut self, pus_tm: &PusTm) -> StoreAddr {
let mut pg = self.pool.write().expect("error locking TM store");
let (addr, buf) = pg.free_element(pus_tm.len_packed()).expect("Store error");
pus_tm
.write_to_bytes(buf)
.expect("writing PUS TM to store failed");
addr
}
}
}
pub struct PusTmWithCdsShortHelper {
apid: u16,
cds_short_buf: [u8; 7],