diff --git a/satrs-example/src/acs.rs b/satrs-example/src/acs.rs index 2974b32..30ae8e4 100644 --- a/satrs-example/src/acs.rs +++ b/satrs-example/src/acs.rs @@ -1,6 +1,7 @@ use std::sync::mpsc::{self, TryRecvError}; use log::{info, warn}; +use satrs_core::executable::{Executable, OpResult}; use satrs_core::pus::verification::VerificationReporterWithSender; use satrs_core::pus::{EcssTmSender, PusTmWrapper}; use satrs_core::spacepackets::ecss::hk::Subservice as HkSubservice; @@ -62,14 +63,14 @@ impl AcsTask { } // TODO: Verification failure for invalid unique IDs. } - pub fn periodic_operation(&mut self) { + + pub fn try_reading_one_request(&mut self) -> bool { match self.request_rx.try_recv() { Ok(request) => { info!( "ACS thread: Received HK request {:?}", request.targeted_request ); - update_time(&mut self.time_provider, &mut self.timestamp); match request.targeted_request.request { Request::Hk(hk_req) => match hk_req { HkRequest::OneShot(unique_id) => self.handle_hk_request( @@ -94,13 +95,24 @@ impl AcsTask { self.verif_reporter .completion_success(started_token, Some(&self.timestamp)) .expect("Sending completion success failed"); + true } Err(e) => match e { - TryRecvError::Empty => {} + TryRecvError::Empty => false, TryRecvError::Disconnected => { - warn!("ACS thread: Message Queue TX disconnected!") + warn!("ACS thread: Message Queue TX disconnected!"); + false } }, } } + + pub fn periodic_operation(&mut self) { + update_time(&mut self.time_provider, &mut self.timestamp); + loop { + if !self.try_reading_one_request() { + break; + } + } + } }