zero copy TM funnel
This commit is contained in:
parent
f34ef841bf
commit
8210e01615
@ -64,7 +64,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 = "28cd8c02ac0"
|
rev = "4485ed26699d32"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
@ -233,7 +233,7 @@ impl TryFrom<TcStateToken> for VerificationToken<TcStateAccepted> {
|
|||||||
if let TcStateToken::Accepted(token) = value {
|
if let TcStateToken::Accepted(token) = value {
|
||||||
Ok(token)
|
Ok(token)
|
||||||
} else {
|
} else {
|
||||||
return Err(());
|
Err(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ mod requests;
|
|||||||
mod tmtc;
|
mod tmtc;
|
||||||
|
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use std::collections::hash_map::Entry;
|
|
||||||
|
|
||||||
use crate::hk::AcsHkIds;
|
use crate::hk::AcsHkIds;
|
||||||
use crate::logging::setup_logger;
|
use crate::logging::setup_logger;
|
||||||
@ -38,7 +37,7 @@ use satrs_core::pus::verification::{
|
|||||||
};
|
};
|
||||||
use satrs_core::pus::MpscTmtcInStoreSender;
|
use satrs_core::pus::MpscTmtcInStoreSender;
|
||||||
use satrs_core::seq_count::{SeqCountProviderSimple, SequenceCountProviderCore};
|
use satrs_core::seq_count::{SeqCountProviderSimple, SequenceCountProviderCore};
|
||||||
use satrs_core::spacepackets::ecss::{PusPacket, SerializablePusPacket};
|
use satrs_core::spacepackets::tm::PusTmZeroCopyWriter;
|
||||||
use satrs_core::spacepackets::{
|
use satrs_core::spacepackets::{
|
||||||
time::cds::TimeProvider,
|
time::cds::TimeProvider,
|
||||||
time::TimeWriter,
|
time::TimeWriter,
|
||||||
@ -213,38 +212,35 @@ fn main() {
|
|||||||
let jh1 = thread::Builder::new()
|
let jh1 = thread::Builder::new()
|
||||||
.name("TM Funnel".to_string())
|
.name("TM Funnel".to_string())
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
let mut tm_buf: [u8; 2048] = [0; 2048];
|
|
||||||
let tm_funnel = TmFunnel {
|
let tm_funnel = TmFunnel {
|
||||||
tm_server_tx,
|
tm_server_tx,
|
||||||
tm_funnel_rx,
|
tm_funnel_rx,
|
||||||
};
|
};
|
||||||
loop {
|
loop {
|
||||||
if let Ok(addr) = tm_funnel.tm_funnel_rx.recv() {
|
if let Ok(addr) = tm_funnel.tm_funnel_rx.recv() {
|
||||||
// Read the TM, set sequence counter and message counter, and finally write
|
// Read the TM, set sequence counter and message counter, and finally update
|
||||||
// it back with the updated CRC.
|
// the CRC.
|
||||||
// We could theoretically manipulate the counters and the CRC directly
|
|
||||||
// in place as an optimization, but I don't think this is necessary..
|
|
||||||
let shared_pool = tm_store.backing_pool();
|
let shared_pool = tm_store.backing_pool();
|
||||||
let mut pool_guard = shared_pool.write().expect("Locking TM pool failed");
|
let mut pool_guard = shared_pool.write().expect("Locking TM pool failed");
|
||||||
let tm_raw = pool_guard
|
let tm_raw = pool_guard
|
||||||
.modify(&addr)
|
.modify(&addr)
|
||||||
.expect("Reading TM from pool failed");
|
.expect("Reading TM from pool failed");
|
||||||
tm_buf[0..tm_raw.len()].copy_from_slice(&tm_raw);
|
let mut zero_copy_writer = PusTmZeroCopyWriter::new(tm_raw)
|
||||||
let (mut tm, size) =
|
.expect("Creating TM zero copy writer failed");
|
||||||
PusTm::from_bytes(&tm_buf, 7).expect("Creating TM from raw slice failed");
|
zero_copy_writer.set_apid(PUS_APID);
|
||||||
tm.sp_header.set_apid(PUS_APID);
|
zero_copy_writer.set_seq_count(seq_count_provider.get_and_increment());
|
||||||
tm.sp_header
|
let entry = msg_counter_map
|
||||||
.set_seq_count(seq_count_provider.get_and_increment());
|
.entry(zero_copy_writer.service())
|
||||||
let entry = msg_counter_map.entry(tm.service()).or_insert(0);
|
.or_insert(0);
|
||||||
tm.sec_header.msg_counter = *entry;
|
zero_copy_writer.set_msg_count(*entry);
|
||||||
if *entry == u16::MAX {
|
if *entry == u16::MAX {
|
||||||
*entry = 0;
|
*entry = 0;
|
||||||
} else {
|
} else {
|
||||||
*entry += 1;
|
*entry += 1;
|
||||||
}
|
}
|
||||||
tm.calc_crc_on_serialization = true;
|
|
||||||
tm.write_to_bytes(tm_raw)
|
// This operation has to come last!
|
||||||
.expect("Writing PUS TM back failed");
|
zero_copy_writer.finish();
|
||||||
tm_funnel
|
tm_funnel
|
||||||
.tm_server_tx
|
.tm_server_tx
|
||||||
.send(addr)
|
.send(addr)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
use crate::tmtc::PusTcSource;
|
use crate::tmtc::PusTcSource;
|
||||||
use log::{error, info, warn};
|
use log::{error, info, warn};
|
||||||
use satrs_core::pool::{SharedPool, StoreAddr};
|
|
||||||
use satrs_core::pus::scheduler::TcInfo;
|
use satrs_core::pus::scheduler::TcInfo;
|
||||||
use satrs_core::pus::scheduler_srv::PusService11SchedHandler;
|
use satrs_core::pus::scheduler_srv::PusService11SchedHandler;
|
||||||
use satrs_core::pus::{PusPacketHandlerResult, PusServiceHandler};
|
use satrs_core::pus::{PusPacketHandlerResult, PusServiceHandler};
|
||||||
|
Loading…
Reference in New Issue
Block a user