fixed sequence counter in verif reporter #44

Merged
muellerr merged 2 commits from verif_reporter_ssc_fix into main 2023-04-26 17:28:10 +02:00
4 changed files with 20 additions and 7 deletions

View File

@ -22,10 +22,11 @@ impl PusTmWithCdsShortHelper {
service: u8, service: u8,
subservice: u8, subservice: u8,
source_data: Option<&'a [u8]>, source_data: Option<&'a [u8]>,
seq_count: u16,
) -> PusTm { ) -> PusTm {
let time_stamp = TimeProvider::from_now_with_u16_days().unwrap(); let time_stamp = TimeProvider::from_now_with_u16_days().unwrap();
time_stamp.write_to_bytes(&mut self.cds_short_buf).unwrap(); time_stamp.write_to_bytes(&mut self.cds_short_buf).unwrap();
self.create_pus_tm_common(service, subservice, source_data) self.create_pus_tm_common(service, subservice, source_data, seq_count)
} }
pub fn create_pus_tm_with_stamp<'a>( pub fn create_pus_tm_with_stamp<'a>(
@ -34,9 +35,10 @@ impl PusTmWithCdsShortHelper {
subservice: u8, subservice: u8,
source_data: Option<&'a [u8]>, source_data: Option<&'a [u8]>,
stamper: &TimeProvider, stamper: &TimeProvider,
seq_count: u16,
) -> PusTm { ) -> PusTm {
stamper.write_to_bytes(&mut self.cds_short_buf).unwrap(); stamper.write_to_bytes(&mut self.cds_short_buf).unwrap();
self.create_pus_tm_common(service, subservice, source_data) self.create_pus_tm_common(service, subservice, source_data, seq_count)
} }
fn create_pus_tm_common<'a>( fn create_pus_tm_common<'a>(
@ -44,8 +46,9 @@ impl PusTmWithCdsShortHelper {
service: u8, service: u8,
subservice: u8, subservice: u8,
source_data: Option<&'a [u8]>, source_data: Option<&'a [u8]>,
seq_count: u16,
) -> PusTm { ) -> PusTm {
let mut reply_header = SpHeader::tm_unseg(self.apid, 0, 0).unwrap(); let mut reply_header = SpHeader::tm_unseg(self.apid, seq_count, 0).unwrap();
let tc_header = PusTmSecondaryHeader::new_simple(service, subservice, &self.cds_short_buf); let tc_header = PusTmSecondaryHeader::new_simple(service, subservice, &self.cds_short_buf);
PusTm::new(&mut reply_header, tc_header, source_data, true) PusTm::new(&mut reply_header, tc_header, source_data, true)
} }

View File

@ -28,7 +28,7 @@ use satrs_core::pus::verification::{
MpscVerifSender, VerificationReporterCfg, VerificationReporterWithSender, MpscVerifSender, VerificationReporterCfg, VerificationReporterWithSender,
}; };
use satrs_core::pus::MpscTmInStoreSender; use satrs_core::pus::MpscTmInStoreSender;
use satrs_core::seq_count::SeqCountProviderSimple; use satrs_core::seq_count::{SeqCountProviderSimple, SeqCountProviderSyncClonable};
use satrs_core::spacepackets::{ use satrs_core::spacepackets::{
time::cds::TimeProvider, time::cds::TimeProvider,
time::TimeWriter, time::TimeWriter,
@ -70,6 +70,9 @@ fn main() {
pool: Arc::new(RwLock::new(Box::new(tc_pool))), pool: Arc::new(RwLock::new(Box::new(tc_pool))),
}; };
let seq_count_provider = SeqCountProviderSyncClonable::default();
let seq_count_provider_verif = seq_count_provider.clone();
let seq_count_provider_tmtc = seq_count_provider.clone();
let sock_addr = SocketAddr::new(IpAddr::V4(OBSW_SERVER_ADDR), SERVER_PORT); let sock_addr = SocketAddr::new(IpAddr::V4(OBSW_SERVER_ADDR), SERVER_PORT);
let (tc_source_tx, tc_source_rx) = channel(); let (tc_source_tx, tc_source_rx) = channel();
let (tm_funnel_tx, tm_funnel_rx) = channel(); let (tm_funnel_tx, tm_funnel_rx) = channel();
@ -82,8 +85,7 @@ fn main() {
); );
let verif_cfg = VerificationReporterCfg::new( let verif_cfg = VerificationReporterCfg::new(
PUS_APID, PUS_APID,
#[allow(clippy::box_default)] Box::new(seq_count_provider_verif),
Box::new(SeqCountProviderSimple::default()),
#[allow(clippy::box_default)] #[allow(clippy::box_default)]
Box::new(SeqCountProviderSimple::default()), Box::new(SeqCountProviderSimple::default()),
1, 1,
@ -135,6 +137,7 @@ fn main() {
event_sender, event_sender,
event_request_tx, event_request_tx,
request_map, request_map,
seq_count_provider: seq_count_provider_tmtc,
}; };
let tc_args = TcArgs { let tc_args = TcArgs {
tc_source, tc_source,

View File

@ -31,6 +31,7 @@ use std::collections::HashMap;
use std::convert::TryFrom; use std::convert::TryFrom;
use std::rc::Rc; use std::rc::Rc;
use std::sync::mpsc::{Receiver, Sender}; use std::sync::mpsc::{Receiver, Sender};
use satrs_core::seq_count::{SeqCountProviderSyncClonable, SequenceCountProvider, SequenceCountProviderCore};
pub struct PusReceiver { pub struct PusReceiver {
pub tm_helper: PusTmWithCdsShortHelper, pub tm_helper: PusTmWithCdsShortHelper,
@ -46,6 +47,8 @@ pub struct PusTmArgs {
pub tm_store: TmStore, pub tm_store: TmStore,
/// All verification reporting is done with this reporter. /// All verification reporting is done with this reporter.
pub verif_reporter: StdVerifReporterWithSender, pub verif_reporter: StdVerifReporterWithSender,
/// Sequence count provider for TMs sent from within pus demultiplexer
pub seq_count_provider: SeqCountProviderSyncClonable,
} }
impl PusTmArgs { impl PusTmArgs {
@ -213,12 +216,13 @@ impl PusReceiver {
.verif_reporter .verif_reporter
.start_success(token, Some(self.stamp_helper.stamp())) .start_success(token, Some(self.stamp_helper.stamp()))
.expect("Error sending start success"); .expect("Error sending start success");
let ping_reply = self.tm_helper.create_pus_tm_timestamp_now(17, 2, None); let ping_reply = self.tm_helper.create_pus_tm_timestamp_now(17, 2, None, self.tm_args.seq_count_provider.get());
let addr = self.tm_args.tm_store.add_pus_tm(&ping_reply); let addr = self.tm_args.tm_store.add_pus_tm(&ping_reply);
self.tm_args self.tm_args
.tm_tx .tm_tx
.send(addr) .send(addr)
.expect("Sending TM to TM funnel failed"); .expect("Sending TM to TM funnel failed");
self.tm_args.seq_count_provider.increment();
self.tm_args self.tm_args
.verif_reporter .verif_reporter
.completion_success(start_token, Some(self.stamp_helper.stamp())) .completion_success(start_token, Some(self.stamp_helper.stamp()))

View File

@ -19,6 +19,7 @@ use satrs_core::pool::{SharedPool, StoreAddr, StoreError};
use satrs_core::pus::event_man::EventRequestWithToken; use satrs_core::pus::event_man::EventRequestWithToken;
use satrs_core::pus::scheduling::{PusScheduler, TcInfo}; use satrs_core::pus::scheduling::{PusScheduler, TcInfo};
use satrs_core::pus::verification::StdVerifReporterWithSender; use satrs_core::pus::verification::StdVerifReporterWithSender;
use satrs_core::seq_count::SeqCountProviderSyncClonable;
use satrs_core::spacepackets::{ecss::PusPacket, tc::PusTc, tm::PusTm, SpHeader}; use satrs_core::spacepackets::{ecss::PusPacket, tc::PusTc, tm::PusTm, SpHeader};
use satrs_core::tmtc::{ use satrs_core::tmtc::{
CcsdsDistributor, CcsdsError, PusServiceProvider, ReceivesCcsdsTc, ReceivesEcssPusTc, CcsdsDistributor, CcsdsError, PusServiceProvider, ReceivesCcsdsTc, ReceivesEcssPusTc,
@ -32,6 +33,7 @@ pub struct OtherArgs {
pub event_sender: Sender<(EventU32, Option<Params>)>, pub event_sender: Sender<(EventU32, Option<Params>)>,
pub event_request_tx: Sender<EventRequestWithToken>, pub event_request_tx: Sender<EventRequestWithToken>,
pub request_map: HashMap<u32, Sender<RequestWithToken>>, pub request_map: HashMap<u32, Sender<RequestWithToken>>,
pub seq_count_provider: SeqCountProviderSyncClonable,
} }
pub struct TmArgs { pub struct TmArgs {
@ -173,6 +175,7 @@ pub fn core_tmtc_task(args: OtherArgs, mut tc_args: TcArgs, tm_args: TmArgs) {
tm_tx: tm_args.tm_sink_sender, tm_tx: tm_args.tm_sink_sender,
tm_store: tm_args.tm_store.clone(), tm_store: tm_args.tm_store.clone(),
verif_reporter: args.verif_reporter, verif_reporter: args.verif_reporter,
seq_count_provider: args.seq_count_provider.clone(),
}; };
let pus_tc_args = PusTcArgs { let pus_tc_args = PusTcArgs {
event_request_tx: args.event_request_tx, event_request_tx: args.event_request_tx,