It's getting tricky, but this is good..

This commit is contained in:
2024-02-02 01:58:38 +01:00
parent 317a3b833d
commit 76a84a4393
18 changed files with 203 additions and 156 deletions

View File

@ -8,7 +8,7 @@ pub use std_mod::*;
#[cfg(feature = "std")]
pub mod std_mod {
use crate::pool::{ShareablePoolProvider, SharedPool, StoreAddr};
use crate::pool::{MemPoolProvider, SharedStaticMemoryPool, StaticMemoryPool, StoreAddr};
use crate::pus::EcssTmtcError;
use spacepackets::ecss::tm::PusTmCreator;
use spacepackets::ecss::WritablePusPacket;
@ -16,22 +16,25 @@ pub mod std_mod {
#[derive(Clone)]
pub struct SharedTmStore {
pub pool: SharedPool,
pub shared_pool: SharedStaticMemoryPool,
}
impl SharedTmStore {
pub fn new(backing_pool: ShareablePoolProvider) -> Self {
pub fn new(shared_pool: StaticMemoryPool) -> Self {
Self {
pool: Arc::new(RwLock::new(backing_pool)),
shared_pool: Arc::new(RwLock::new(shared_pool)),
}
}
pub fn clone_backing_pool(&self) -> SharedPool {
self.pool.clone()
pub fn clone_backing_pool(&self) -> SharedStaticMemoryPool {
self.shared_pool.clone()
}
pub fn add_pus_tm(&self, pus_tm: &PusTmCreator) -> Result<StoreAddr, EcssTmtcError> {
let mut pg = self.pool.write().map_err(|_| EcssTmtcError::StoreLock)?;
let mut pg = self
.shared_pool
.write()
.map_err(|_| EcssTmtcError::StoreLock)?;
let (addr, buf) = pg.free_element(pus_tm.len_written())?;
pus_tm
.write_to_bytes(buf)