continue HK code

This commit is contained in:
2022-12-20 15:33:00 +01:00
parent 53ac1e05f4
commit 58d8e66eb4
6 changed files with 76 additions and 26 deletions

View File

@ -1,3 +1,4 @@
#![allow(dead_code)]
pub type CollectionIntervalFactor = u32;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
@ -8,6 +9,7 @@ pub enum AcsHkIds {
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum HkRequest {
OneShot(u32),
Enable(u32, CollectionIntervalFactor),
Disable(u32, CollectionIntervalFactor),
Enable(u32),
Disable(u32),
ModifyCollectionInterval(CollectionIntervalFactor),
}

View File

@ -31,6 +31,7 @@ use std::net::{IpAddr, SocketAddr};
use std::sync::mpsc::channel;
use std::sync::{mpsc, Arc, RwLock};
use std::thread;
use std::time::Duration;
struct TmFunnel {
tm_funnel_rx: mpsc::Receiver<StoreAddr>,
@ -176,9 +177,19 @@ fn main() {
}
});
println!("Starting AOCS thread");
let jh3 = thread::spawn(move || loop {
match acs_thread_rx.try_recv() {
Ok(_) => {}
Err(_) => {}
}
thread::sleep(Duration::from_millis(500));
});
jh0.join().expect("Joining UDP TMTC server thread failed");
jh1.join().expect("Joining TM Funnel thread failed");
jh2.join().expect("Joining Event Manager thread failed");
jh3.join().expect("Joining AOCS thread failed");
}
pub fn update_time(time_provider: &mut TimeProvider, timestamp: &mut [u8]) {

View File

@ -1,15 +1,17 @@
use crate::hk::HkRequest;
use crate::requests::Request;
use crate::tmtc::TmStore;
use satrs_core::events::EventU32;
use satrs_core::pool::StoreAddr;
use satrs_core::pus::event::Subservices;
use satrs_core::pus::event_man::{EventRequest, EventRequestWithToken};
use satrs_core::pus::hk;
use satrs_core::pus::verification::{
FailParams, StdVerifReporterWithSender, TcStateAccepted, VerificationToken,
};
use satrs_core::res_code::ResultU16;
use satrs_core::tmtc::tm_helper::PusTmWithCdsShortHelper;
use satrs_core::tmtc::PusServiceProvider;
use satrs_core::tmtc::{AddressableId, PusServiceProvider};
use satrs_example::{INVALID_PUS_SERVICE, INVALID_PUS_SUBSERVICE, NOT_ENOUGH_APP_DATA};
use spacepackets::ecss::PusPacket;
use spacepackets::tc::PusTc;
@ -17,7 +19,6 @@ 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 {
@ -89,7 +90,7 @@ impl PusServiceProvider for PusReceiver {
impl PusReceiver {
fn handle_test_service(&mut self, pus_tc: &PusTc, token: VerificationToken<TcStateAccepted>) {
if pus_tc.subservice() == 1 {
if PusPacket::subservice(pus_tc) == 1 {
println!("Received PUS ping command TC[17,1]");
println!("Sending ping reply PUS TM[17,2]");
let ping_reply = self.tm_helper.create_pus_tm_timestamp_now(17, 2, None);
@ -124,7 +125,38 @@ impl PusReceiver {
.expect("Writing timestamp failed");
}
fn handle_hk_request(&mut self, pus_tc: &PusTc, token: VerificationToken<TcStateAccepted>) {}
fn handle_hk_request(&mut self, pus_tc: &PusTc, token: VerificationToken<TcStateAccepted>) {
if pus_tc.user_data().is_none() {
self.update_time_stamp();
self.verif_reporter
.start_failure(
token,
FailParams::new(&self.time_stamp, &NOT_ENOUGH_APP_DATA, None),
)
.expect("Sending start failure TM failed");
}
let user_data = pus_tc.user_data().unwrap();
if PusPacket::subservice(pus_tc) == hk::Subservice::TcEnableGeneration as u8 {
if user_data.len() < 8 {
self.update_time_stamp();
self.verif_reporter
.start_failure(
token,
FailParams::new(&self.time_stamp, &NOT_ENOUGH_APP_DATA, None),
)
.expect("Sending start failure TM failed");
}
let addressable_id = AddressableId::from_raw_be(&user_data).unwrap();
if self.request_map.contains_key(&addressable_id.target_id) {
let sender = self.request_map.get(&addressable_id.target_id).unwrap();
sender
.send(Request::HkRequest(HkRequest::Enable(
addressable_id.unique_id,
)))
.expect("Sending HK request failed")
}
}
}
fn handle_event_request(&mut self, pus_tc: &PusTc, token: VerificationToken<TcStateAccepted>) {
let send_start_failure = |verif_reporter: &mut StdVerifReporterWithSender,
timestamp: &[u8; 7],

View File

@ -9,7 +9,6 @@ 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;