basic HK reply TM packing and handling

This commit is contained in:
Robin Müller 2022-12-22 09:15:59 +01:00
parent 49c5f3eda2
commit 27c1a9850c
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
2 changed files with 29 additions and 3 deletions

View File

@ -142,6 +142,15 @@ class PusHandler(SpecificApidHandlerBase):
self.verif_wrapper.log_to_console(tm_packet, res) self.verif_wrapper.log_to_console(tm_packet, res)
self.verif_wrapper.log_to_file(tm_packet, res) self.verif_wrapper.log_to_file(tm_packet, res)
dedicated_handler = True dedicated_handler = True
if service == 3:
LOGGER.info("No handling for HK packets implemented")
LOGGER.info(f"Raw packet: 0x[{packet.hex(sep=',')}]")
pus_tm = PusTelemetry.unpack(packet)
if pus_tm.subservice == 25:
if len(pus_tm.source_data) < 8:
raise ValueError("No addressable ID in HK packet")
json_str = pus_tm.source_data[8:]
dedicated_handler = True
if service == 5: if service == 5:
tm_packet = Service5Tm.unpack(packet) tm_packet = Service5Tm.unpack(packet)
if service == 17: if service == 17:

View File

@ -17,6 +17,7 @@ use satrs_core::pus::event_man::{
DefaultPusMgmtBackendProvider, EventReporter, EventRequest, EventRequestWithToken, DefaultPusMgmtBackendProvider, EventReporter, EventRequest, EventRequestWithToken,
PusEventDispatcher, PusEventDispatcher,
}; };
use satrs_core::pus::hk::Subservice;
use satrs_core::pus::verification::{ use satrs_core::pus::verification::{
MpscVerifSender, VerificationReporterCfg, VerificationReporterWithSender, MpscVerifSender, VerificationReporterCfg, VerificationReporterWithSender,
}; };
@ -25,7 +26,8 @@ use satrs_core::seq_count::SimpleSeqCountProvider;
use satrs_example::{RequestTargetId, OBSW_SERVER_ADDR, SERVER_PORT}; use satrs_example::{RequestTargetId, OBSW_SERVER_ADDR, SERVER_PORT};
use spacepackets::time::cds::TimeProvider; use spacepackets::time::cds::TimeProvider;
use spacepackets::time::TimeWriter; use spacepackets::time::TimeWriter;
use spacepackets::tm::PusTm; use spacepackets::tm::{PusTm, PusTmSecondaryHeader};
use spacepackets::{SequenceFlags, SpHeader};
use std::collections::HashMap; use std::collections::HashMap;
use std::net::{IpAddr, SocketAddr}; use std::net::{IpAddr, SocketAddr};
use std::sync::mpsc::{channel, TryRecvError}; use std::sync::mpsc::{channel, TryRecvError};
@ -81,11 +83,12 @@ fn main() {
let tc_store = TcStore { let tc_store = TcStore {
pool: Arc::new(RwLock::new(Box::new(tc_pool))), pool: Arc::new(RwLock::new(Box::new(tc_pool))),
}; };
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();
let (tm_server_tx, tm_server_rx) = channel(); let (tm_server_tx, tm_server_rx) = channel();
let sender = MpscVerifSender::new(tm_store.pool.clone(), tm_funnel_tx.clone()); let verif_sender = MpscVerifSender::new(tm_store.pool.clone(), tm_funnel_tx.clone());
let verif_cfg = VerificationReporterCfg::new( let verif_cfg = VerificationReporterCfg::new(
PUS_APID, PUS_APID,
#[allow(clippy::box_default)] #[allow(clippy::box_default)]
@ -95,7 +98,7 @@ fn main() {
8, 8,
) )
.unwrap(); .unwrap();
let verif_reporter = VerificationReporterWithSender::new(&verif_cfg, Box::new(sender)); let verif_reporter = VerificationReporterWithSender::new(&verif_cfg, Box::new(verif_sender));
// Create event handling components // Create event handling components
let (event_request_tx, event_request_rx) = channel::<EventRequestWithToken>(); let (event_request_tx, event_request_rx) = channel::<EventRequestWithToken>();
@ -139,6 +142,9 @@ fn main() {
tm_server_rx, tm_server_rx,
}; };
let aocs_to_funnel = tm_funnel_tx.clone();
let mut aocs_tm_store = tm_store.clone();
println!("Starting TMTC task"); println!("Starting TMTC task");
let jh0 = thread::spawn(move || { let jh0 = thread::spawn(move || {
core_tmtc_task(core_args, tc_args, tm_args); core_tmtc_task(core_args, tc_args, tm_args);
@ -195,6 +201,7 @@ fn main() {
.generate_pus_event_tm_generic(&mut sender, &timestamp, event, None) .generate_pus_event_tm_generic(&mut sender, &timestamp, event, None)
.expect("Sending TM as event failed"); .expect("Sending TM as event failed");
} }
thread::sleep(Duration::from_millis(400));
} }
}); });
@ -207,6 +214,16 @@ fn main() {
Ok(request) => { Ok(request) => {
println!("ACS thread: Received HK request {:?}", request.0); println!("ACS thread: Received HK request {:?}", request.0);
update_time(&mut time_provider, &mut timestamp); update_time(&mut time_provider, &mut timestamp);
let mut sp_header =
SpHeader::tc(PUS_APID, SequenceFlags::Unsegmented, 0, 0).unwrap();
let sec_header = PusTmSecondaryHeader::new_simple(
3,
Subservice::TmHkPacket as u8,
&timestamp,
);
let pus_tm = PusTm::new(&mut sp_header, sec_header, None, true);
let addr = aocs_tm_store.add_pus_tm(&pus_tm);
aocs_to_funnel.send(addr).expect("Sending HK TM failed");
let started_token = reporter_aocs let started_token = reporter_aocs
.start_success(request.1, &timestamp) .start_success(request.1, &timestamp)
.expect("Sending start success failed"); .expect("Sending start success failed");