add first basic HK packet support
This commit is contained in:
parent
322620131f
commit
c591092881
13
satrs-example/src/hk.rs
Normal file
13
satrs-example/src/hk.rs
Normal file
@ -0,0 +1,13 @@
|
||||
pub type CollectionIntervalFactor = u32;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub enum AcsHkIds {
|
||||
TestMgmSet = 1,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub enum HkRequest {
|
||||
OneShot(u32),
|
||||
Enable(u32, CollectionIntervalFactor),
|
||||
Disable(u32, CollectionIntervalFactor),
|
||||
}
|
@ -1,8 +1,11 @@
|
||||
mod ccsds;
|
||||
mod hk;
|
||||
mod pus;
|
||||
mod requests;
|
||||
mod tmtc;
|
||||
|
||||
use crate::tmtc::{core_tmtc_task, CoreTmtcArgs, TmStore, PUS_APID};
|
||||
use crate::requests::Request;
|
||||
use crate::tmtc::{core_tmtc_task, CoreTmtcArgs, RequestTargetId, TmStore, PUS_APID};
|
||||
use satrs_core::event_man::{
|
||||
EventManagerWithMpscQueue, MpscEventReceiver, MpscEventU32SendProvider, SendEventProvider,
|
||||
};
|
||||
@ -23,6 +26,7 @@ use satrs_example::{OBSW_SERVER_ADDR, SERVER_PORT};
|
||||
use spacepackets::time::cds::TimeProvider;
|
||||
use spacepackets::time::TimeWriter;
|
||||
use spacepackets::tm::PusTm;
|
||||
use std::collections::HashMap;
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
use std::sync::mpsc::channel;
|
||||
use std::sync::{mpsc, Arc, RwLock};
|
||||
@ -100,12 +104,17 @@ fn main() {
|
||||
let mut reporter1 = 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>();
|
||||
request_map.insert(RequestTargetId::AcsSubsystem as u32, acs_thread_tx);
|
||||
|
||||
// Create clones here to allow move for thread 0
|
||||
let core_args = CoreTmtcArgs {
|
||||
tm_store: tm_store_helper.clone(),
|
||||
tm_sender: tm_funnel_tx.clone(),
|
||||
event_sender,
|
||||
event_request_tx,
|
||||
request_map,
|
||||
};
|
||||
|
||||
println!("Starting TMTC task");
|
||||
|
@ -1,3 +1,4 @@
|
||||
use crate::requests::Request;
|
||||
use crate::tmtc::TmStore;
|
||||
use satrs_core::events::EventU32;
|
||||
use satrs_core::pool::StoreAddr;
|
||||
@ -15,14 +16,17 @@ use spacepackets::tc::PusTc;
|
||||
use spacepackets::time::cds::TimeProvider;
|
||||
use spacepackets::time::TimeWriter;
|
||||
use spacepackets::SpHeader;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::mpsc;
|
||||
use std::sync::mpsc::Sender;
|
||||
|
||||
pub struct PusReceiver {
|
||||
pub tm_helper: PusTmWithCdsShortHelper,
|
||||
pub tm_tx: mpsc::Sender<StoreAddr>,
|
||||
pub tm_tx: Sender<StoreAddr>,
|
||||
pub tm_store: TmStore,
|
||||
pub verif_reporter: StdVerifReporterWithSender,
|
||||
event_request_tx: mpsc::Sender<EventRequestWithToken>,
|
||||
event_request_tx: Sender<EventRequestWithToken>,
|
||||
request_map: HashMap<u32, Sender<Request>>,
|
||||
stamper: TimeProvider,
|
||||
time_stamp: [u8; 7],
|
||||
}
|
||||
@ -30,10 +34,11 @@ pub struct PusReceiver {
|
||||
impl PusReceiver {
|
||||
pub fn new(
|
||||
apid: u16,
|
||||
tm_tx: mpsc::Sender<StoreAddr>,
|
||||
tm_tx: Sender<StoreAddr>,
|
||||
tm_store: TmStore,
|
||||
verif_reporter: StdVerifReporterWithSender,
|
||||
event_request_tx: mpsc::Sender<EventRequestWithToken>,
|
||||
event_request_tx: Sender<EventRequestWithToken>,
|
||||
request_map: HashMap<u32, Sender<Request>>,
|
||||
) -> Self {
|
||||
Self {
|
||||
tm_helper: PusTmWithCdsShortHelper::new(apid),
|
||||
@ -41,6 +46,7 @@ impl PusReceiver {
|
||||
tm_store,
|
||||
verif_reporter,
|
||||
event_request_tx,
|
||||
request_map,
|
||||
stamper: TimeProvider::default(),
|
||||
time_stamp: [0; 7],
|
||||
}
|
||||
@ -65,7 +71,9 @@ impl PusServiceProvider for PusReceiver {
|
||||
if service == 17 {
|
||||
self.handle_test_service(pus_tc, accepted_token);
|
||||
} else if service == 5 {
|
||||
self.handle_event_service(pus_tc, accepted_token);
|
||||
self.handle_event_request(pus_tc, accepted_token);
|
||||
} else if service == 3 {
|
||||
self.handle_hk_request(pus_tc, accepted_token);
|
||||
} else {
|
||||
self.update_time_stamp();
|
||||
self.verif_reporter
|
||||
@ -116,7 +124,8 @@ impl PusReceiver {
|
||||
.expect("Writing timestamp failed");
|
||||
}
|
||||
|
||||
fn handle_event_service(&mut self, pus_tc: &PusTc, token: VerificationToken<TcStateAccepted>) {
|
||||
fn handle_hk_request(&mut self, pus_tc: &PusTc, token: VerificationToken<TcStateAccepted>) {}
|
||||
fn handle_event_request(&mut self, pus_tc: &PusTc, token: VerificationToken<TcStateAccepted>) {
|
||||
let send_start_failure = |verif_reporter: &mut StdVerifReporterWithSender,
|
||||
timestamp: &[u8; 7],
|
||||
failure_code: &ResultU16,
|
||||
|
6
satrs-example/src/requests.rs
Normal file
6
satrs-example/src/requests.rs
Normal file
@ -0,0 +1,6 @@
|
||||
use crate::hk::HkRequest;
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||
pub enum Request {
|
||||
HkRequest(HkRequest),
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
use satrs_core::events::EventU32;
|
||||
use satrs_core::hal::host::udp_server::{ReceiveResult, UdpTcServer};
|
||||
use satrs_core::params::Params;
|
||||
use std::collections::HashMap;
|
||||
use std::net::SocketAddr;
|
||||
use std::sync::mpsc;
|
||||
use std::sync::mpsc::Sender;
|
||||
@ -8,7 +9,9 @@ use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::ccsds::CcsdsReceiver;
|
||||
use crate::hk::HkRequest;
|
||||
use crate::pus::PusReceiver;
|
||||
use crate::requests::Request;
|
||||
use crate::UdpTmtcServer;
|
||||
use satrs_core::pool::{SharedPool, StoreAddr};
|
||||
use satrs_core::pus::event_man::EventRequestWithToken;
|
||||
@ -18,11 +21,17 @@ use spacepackets::tm::PusTm;
|
||||
|
||||
pub const PUS_APID: u16 = 0x02;
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||
pub enum RequestTargetId {
|
||||
AcsSubsystem = 1,
|
||||
}
|
||||
|
||||
pub struct CoreTmtcArgs {
|
||||
pub tm_store: TmStore,
|
||||
pub tm_sender: Sender<StoreAddr>,
|
||||
pub event_sender: Sender<(EventU32, Option<Params>)>,
|
||||
pub event_request_tx: Sender<EventRequestWithToken>,
|
||||
pub request_map: HashMap<u32, Sender<Request>>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -53,6 +62,7 @@ pub fn core_tmtc_task(
|
||||
args.tm_store.clone(),
|
||||
verif_reporter,
|
||||
args.event_request_tx,
|
||||
args.request_map,
|
||||
);
|
||||
let pus_distributor = PusDistributor::new(Box::new(pus_receiver));
|
||||
let ccsds_receiver = CcsdsReceiver {
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit b9cd08cefe662bb77dd8ae116b65a6f3a05fd91e
|
||||
Subproject commit 2756670efed153f74be57e4942295c9ee09a3c96
|
Loading…
Reference in New Issue
Block a user