diff --git a/satrs-example/src/pus.rs b/satrs-example/src/pus.rs index 68774fa..0ddf58e 100644 --- a/satrs-example/src/pus.rs +++ b/satrs-example/src/pus.rs @@ -11,6 +11,7 @@ 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::{ @@ -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)) @@ -386,18 +405,7 @@ impl PusReceiver { .completion_success(start_token, Some(&self.time_stamp)) .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"); - } + _ => {} } } }