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" # version = "0.5.4"
# path = "../spacepackets" # path = "../spacepackets"
git = "https://egit.irs.uni-stuttgart.de/rust/spacepackets.git" git = "https://egit.irs.uni-stuttgart.de/rust/spacepackets.git"
rev = "ef4244c8cb5c" rev = "28cd8c02ac0"
default-features = false default-features = false
[dev-dependencies] [dev-dependencies]

View File

@ -186,13 +186,14 @@ pub mod std_mod {
} }
} }
impl EcssTmSenderCore for MpscTmtcInStoreSender { impl MpscTmtcInStoreSender {
type Error = MpscPusInStoreSendError; pub fn send_tmtc(
&mut self,
fn send_tm(&mut self, tm: PusTm) -> Result<(), Self::Error> { tmtc: impl SerializablePusPacket,
) -> Result<(), MpscPusInStoreSendError> {
let operation = |mut store: RwLockWriteGuard<ShareablePoolProvider>| { let operation = |mut store: RwLockWriteGuard<ShareablePoolProvider>| {
let (addr, slice) = store.free_element(tm.len_packed())?; let (addr, slice) = store.free_element(tmtc.len_packed())?;
tm.write_to_bytes(slice)?; tmtc.write_to_bytes(slice)?;
self.sender.send(addr)?; self.sender.send(addr)?;
Ok(()) 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 { impl EcssTcSenderCore for MpscTmtcInStoreSender {
type Error = MpscPusInStoreSendError; type Error = MpscPusInStoreSendError;
fn send_tc(&mut self, tc: PusTc) -> Result<(), Self::Error> { fn send_tc(&mut self, tc: PusTc) -> Result<(), Self::Error> {
let operation = |mut store: RwLockWriteGuard<ShareablePoolProvider>| { self.send_tmtc(tc)
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)
}
}
}
} }
} }

View File

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

View File

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

File diff suppressed because it is too large Load Diff