this is complex..

This commit is contained in:
Robin Müller 2023-07-03 01:33:13 +02:00
parent 46c47a3a0f
commit 5fa9553656
Signed by: muellerr
GPG Key ID: A649FB78196E3849
5 changed files with 608 additions and 552 deletions

View File

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

View File

@ -186,13 +186,14 @@ pub mod std_mod {
}
}
impl EcssTmSenderCore for MpscTmtcInStoreSender {
type Error = MpscPusInStoreSendError;
fn send_tm(&mut self, tm: PusTm) -> Result<(), Self::Error> {
impl MpscTmtcInStoreSender {
pub fn send_tmtc(
&mut self,
tmtc: impl SerializablePusPacket,
) -> Result<(), MpscPusInStoreSendError> {
let operation = |mut store: RwLockWriteGuard<ShareablePoolProvider>| {
let (addr, slice) = store.free_element(tm.len_packed())?;
tm.write_to_bytes(slice)?;
let (addr, slice) = store.free_element(tmtc.len_packed())?;
tmtc.write_to_bytes(slice)?;
self.sender.send(addr)?;
Ok(())
};
@ -209,26 +210,19 @@ pub mod std_mod {
}
}
impl EcssTmSenderCore for MpscTmtcInStoreSender {
type Error = MpscPusInStoreSendError;
fn send_tm(&mut self, tm: PusTm) -> Result<(), Self::Error> {
self.send_tmtc(tm)
}
}
impl EcssTcSenderCore for MpscTmtcInStoreSender {
type Error = MpscPusInStoreSendError;
fn send_tc(&mut self, tc: PusTc) -> Result<(), Self::Error> {
let operation = |mut store: RwLockWriteGuard<ShareablePoolProvider>| {
let (addr, slice) = store.free_element(tc.len_packed())?;
tc.write_to_bytes(slice)?;
self.sender.send(addr)?;
Ok(())
};
match self.store_helper.write() {
Ok(pool) => operation(pool),
Err(e) => {
if self.ignore_poison_errors {
operation(e.into_inner())
} else {
Err(MpscPusInStoreSendError::LockError)
}
}
}
self.send_tmtc(tc)
}
}

View File

@ -84,7 +84,7 @@ use core::mem::size_of;
use delegate::delegate;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use spacepackets::ecss::{scheduling, EcssEnumeration, PusPacket};
use spacepackets::ecss::{scheduling, EcssEnumeration, PusPacket, SerializablePusPacket};
use spacepackets::tc::PusTc;
use spacepackets::tm::{PusTm, PusTmSecondaryHeader};
use spacepackets::{CcsdsPacket, PacketId, PacketSequenceCtrl};

View File

@ -17,6 +17,7 @@
//! # Example
//!
//! ```rust
//! use spacepackets::ecss::SerializablePusPacket;
//! use satrs_core::tmtc::pus_distrib::{PusDistributor, PusServiceProvider};
//! use satrs_core::tmtc::{ReceivesTc, ReceivesTcCore};
//! use spacepackets::SpHeader;

File diff suppressed because it is too large Load Diff