HK reception works

This commit is contained in:
2022-12-21 10:23:32 +01:00
parent b8a0ff1e2d
commit b1342776ae
4 changed files with 32 additions and 22 deletions

View File

@ -4,7 +4,7 @@ mod pus;
mod requests;
mod tmtc;
use crate::requests::Request;
use crate::requests::RequestWithToken;
use crate::tmtc::{core_tmtc_task, CoreTmtcArgs, TmStore, PUS_APID};
use satrs_core::event_man::{
EventManagerWithMpscQueue, MpscEventReceiver, MpscEventU32SendProvider, SendEventProvider,
@ -103,11 +103,12 @@ fn main() {
PusEventDispatcher::new(event_reporter, Box::new(pus_tm_backend));
let (pus_event_man_tx, pus_event_man_rx) = channel();
let pus_event_man_send_provider = MpscEventU32SendProvider::new(1, pus_event_man_tx);
let mut reporter1 = reporter_with_sender_0.clone();
let mut reporter_event_handler = reporter_with_sender_0.clone();
let mut reporter_aocs = reporter_with_sender_0.clone();
event_man.subscribe_all(pus_event_man_send_provider.id());
let mut request_map = HashMap::new();
let (acs_thread_tx, acs_thread_rx) = channel::<Request>();
let (acs_thread_tx, acs_thread_rx) = channel::<RequestWithToken>();
request_map.insert(RequestTargetId::AcsSubsystem as u32, acs_thread_tx);
// Create clones here to allow move for thread 0
@ -146,7 +147,7 @@ fn main() {
let mut sender = EventTmSender::new(tm_store_helper, tm_funnel_tx);
let mut time_provider = TimeProvider::new_with_u16_days(0, 0);
let mut report_completion = |event_req: EventRequestWithToken, timestamp: &[u8]| {
reporter1
reporter_event_handler
.completion_success(event_req.token, timestamp)
.expect("Sending completion success failed");
};
@ -179,19 +180,28 @@ fn main() {
});
println!("Starting AOCS thread");
let jh3 = thread::spawn(move || loop {
match acs_thread_rx.try_recv() {
Ok(request) => {
println!("ACS thread: Received request {:?}", request)
}
Err(e) => match e {
TryRecvError::Empty => {}
TryRecvError::Disconnected => {
println!("ACS thread: Message Queue TX disconnected!")
let jh3 = thread::spawn(move || {
let mut timestamp: [u8; 7] = [0; 7];
let mut time_provider = TimeProvider::new_with_u16_days(0, 0);
loop {
match acs_thread_rx.try_recv() {
Ok(request) => {
println!("ACS thread: Received HK request {:?}", request.0);
update_time(&mut time_provider, &mut timestamp);
let started_token = reporter_aocs.start_success(request.1, &timestamp).unwrap();
reporter_aocs
.completion_success(started_token, &timestamp)
.unwrap();
}
},
Err(e) => match e {
TryRecvError::Empty => {}
TryRecvError::Disconnected => {
println!("ACS thread: Message Queue TX disconnected!")
}
},
}
thread::sleep(Duration::from_millis(500));
}
thread::sleep(Duration::from_millis(500));
});
jh0.join().expect("Joining UDP TMTC server thread failed");