From e32816fea583b4b491dabe88f2faa466c904405b Mon Sep 17 00:00:00 2001 From: lkoester Date: Tue, 14 Feb 2023 15:26:02 +0100 Subject: [PATCH 1/2] added enum subservice ids for scheduling --- satrs-example/src/pus.rs | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/satrs-example/src/pus.rs b/satrs-example/src/pus.rs index 68774fa..e0e1741 100644 --- a/satrs-example/src/pus.rs +++ b/satrs-example/src/pus.rs @@ -17,6 +17,7 @@ use satrs_core::{ spacepackets::ecss::PusPacket, spacepackets::tc::PusTc, spacepackets::time::cds::TimeProvider, spacepackets::time::TimeWriter, spacepackets::SpHeader, }; +use satrs_core::spacepackets::ecss::scheduling; use satrs_example::{hk_err, tmtc_err}; use std::cell::RefCell; use std::collections::HashMap; @@ -306,8 +307,26 @@ impl PusReceiver { } self.update_time_stamp(); - match pus_tc.subservice() { - 1 => { + + let subservice: scheduling::Subservice = match pus_tc.subservice().try_into() { + Ok(subservice) => subservice, + Err(_) => { + self.verif_reporter + .start_failure( + token, + FailParams::new( + Some(&self.time_stamp), + &tmtc_err::NOT_ENOUGH_APP_DATA, + None, + ), + ) + .expect("Sending start failure TM failed"); + return; + } + }; + + match subservice { + scheduling::Subservice::TcEnableScheduling => { let start_token = self .verif_reporter .start_success(token, Some(&self.time_stamp)) @@ -324,7 +343,7 @@ impl PusReceiver { } drop(scheduler); } - 2 => { + scheduling::Subservice::TcDisableScheduling => { let start_token = self .verif_reporter .start_success(token, Some(&self.time_stamp)) @@ -341,7 +360,7 @@ impl PusReceiver { } drop(scheduler); } - 3 => { + scheduling::Subservice::TcResetScheduling => { let start_token = self .verif_reporter .start_success(token, Some(&self.time_stamp)) @@ -364,7 +383,7 @@ impl PusReceiver { .completion_success(start_token, Some(&self.time_stamp)) .expect("Error sending completion success"); } - 4 => { + scheduling::Subservice::TcInsertActivity => { let start_token = self .verif_reporter .start_success(token, Some(&self.time_stamp)) @@ -387,16 +406,7 @@ impl PusReceiver { .expect("Error sending completion success"); } _ => { - self.verif_reporter - .start_failure( - token, - FailParams::new( - Some(&self.time_stamp), - &tmtc_err::NOT_ENOUGH_APP_DATA, - None, - ), - ) - .expect("Sending start failure TM failed"); + } } } -- 2.43.0 From 655efb73f709572500e42ba6088b66d1ecd58346 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Feb 2023 16:00:59 +0100 Subject: [PATCH 2/2] cargo fmt + clippy --- satrs-example/src/pus.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/satrs-example/src/pus.rs b/satrs-example/src/pus.rs index e0e1741..0ddf58e 100644 --- a/satrs-example/src/pus.rs +++ b/satrs-example/src/pus.rs @@ -11,13 +11,13 @@ use satrs_core::pus::verification::{ FailParams, StdVerifReporterWithSender, TcStateAccepted, VerificationToken, }; use satrs_core::res_code::ResultU16; +use satrs_core::spacepackets::ecss::scheduling; use satrs_core::tmtc::tm_helper::PusTmWithCdsShortHelper; use satrs_core::tmtc::{AddressableId, PusServiceProvider}; use satrs_core::{ spacepackets::ecss::PusPacket, spacepackets::tc::PusTc, spacepackets::time::cds::TimeProvider, spacepackets::time::TimeWriter, spacepackets::SpHeader, }; -use satrs_core::spacepackets::ecss::scheduling; use satrs_example::{hk_err, tmtc_err}; use std::cell::RefCell; use std::collections::HashMap; @@ -405,9 +405,7 @@ impl PusReceiver { .completion_success(start_token, Some(&self.time_stamp)) .expect("Error sending completion success"); } - _ => { - - } + _ => {} } } } -- 2.43.0