adding request handling
This commit is contained in:
parent
58d8e66eb4
commit
359402d78d
@ -6,21 +6,39 @@ use satrs_mib::resultcode;
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum GroupId {
|
pub enum GroupId {
|
||||||
Tmtc = 0,
|
Tmtc = 0,
|
||||||
|
Hk = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const OBSW_SERVER_ADDR: Ipv4Addr = Ipv4Addr::UNSPECIFIED;
|
pub const OBSW_SERVER_ADDR: Ipv4Addr = Ipv4Addr::UNSPECIFIED;
|
||||||
pub const SERVER_PORT: u16 = 7301;
|
pub const SERVER_PORT: u16 = 7301;
|
||||||
|
|
||||||
#[resultcode]
|
pub mod tmtc_err {
|
||||||
pub const INVALID_PUS_SERVICE: ResultU16 = ResultU16::const_new(GroupId::Tmtc as u8, 0);
|
use super::*;
|
||||||
#[resultcode]
|
|
||||||
pub const INVALID_PUS_SUBSERVICE: ResultU16 = ResultU16::const_new(GroupId::Tmtc as u8, 1);
|
|
||||||
|
|
||||||
#[resultcode(info = "Not enough data inside the TC application data field")]
|
#[resultcode]
|
||||||
pub const NOT_ENOUGH_APP_DATA: ResultU16 = ResultU16::const_new(GroupId::Tmtc as u8, 2);
|
pub const INVALID_PUS_SERVICE: ResultU16 = ResultU16::const_new(GroupId::Tmtc as u8, 0);
|
||||||
|
#[resultcode]
|
||||||
|
pub const INVALID_PUS_SUBSERVICE: ResultU16 = ResultU16::const_new(GroupId::Tmtc as u8, 1);
|
||||||
|
|
||||||
pub const TMTC_RESULTS: &[ResultU16Info] = &[
|
#[resultcode(info = "Not enough data inside the TC application data field")]
|
||||||
INVALID_PUS_SERVICE_EXT,
|
pub const NOT_ENOUGH_APP_DATA: ResultU16 = ResultU16::const_new(GroupId::Tmtc as u8, 2);
|
||||||
INVALID_PUS_SUBSERVICE_EXT,
|
|
||||||
NOT_ENOUGH_APP_DATA_EXT,
|
pub const TMTC_RESULTS: &[ResultU16Info] = &[
|
||||||
];
|
INVALID_PUS_SERVICE_EXT,
|
||||||
|
INVALID_PUS_SUBSERVICE_EXT,
|
||||||
|
NOT_ENOUGH_APP_DATA_EXT,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod hk_err {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[resultcode]
|
||||||
|
pub const TARGET_ID_MISSING: ResultU16 = ResultU16::const_new(GroupId::Hk as u8, 0);
|
||||||
|
#[resultcode]
|
||||||
|
pub const UNIQUE_ID_MISSING: ResultU16 = ResultU16::const_new(GroupId::Hk as u8, 1);
|
||||||
|
#[resultcode]
|
||||||
|
pub const UNKNOWN_TARGET_ID: ResultU16 = ResultU16::const_new(GroupId::Hk as u8, 2);
|
||||||
|
#[resultcode]
|
||||||
|
pub const COLLECTION_INTERVAL_MISSING: ResultU16 = ResultU16::const_new(GroupId::Hk as u8, 3);
|
||||||
|
}
|
||||||
|
@ -12,7 +12,7 @@ use satrs_core::pus::verification::{
|
|||||||
use satrs_core::res_code::ResultU16;
|
use satrs_core::res_code::ResultU16;
|
||||||
use satrs_core::tmtc::tm_helper::PusTmWithCdsShortHelper;
|
use satrs_core::tmtc::tm_helper::PusTmWithCdsShortHelper;
|
||||||
use satrs_core::tmtc::{AddressableId, PusServiceProvider};
|
use satrs_core::tmtc::{AddressableId, PusServiceProvider};
|
||||||
use satrs_example::{INVALID_PUS_SERVICE, INVALID_PUS_SUBSERVICE, NOT_ENOUGH_APP_DATA};
|
use satrs_example::{hk_err, tmtc_err};
|
||||||
use spacepackets::ecss::PusPacket;
|
use spacepackets::ecss::PusPacket;
|
||||||
use spacepackets::tc::PusTc;
|
use spacepackets::tc::PusTc;
|
||||||
use spacepackets::time::cds::TimeProvider;
|
use spacepackets::time::cds::TimeProvider;
|
||||||
@ -80,7 +80,7 @@ impl PusServiceProvider for PusReceiver {
|
|||||||
self.verif_reporter
|
self.verif_reporter
|
||||||
.start_failure(
|
.start_failure(
|
||||||
accepted_token,
|
accepted_token,
|
||||||
FailParams::new(&self.time_stamp, &INVALID_PUS_SERVICE, None),
|
FailParams::new(&self.time_stamp, &tmtc_err::INVALID_PUS_SERVICE, None),
|
||||||
)
|
)
|
||||||
.expect("Start failure verification failed")
|
.expect("Start failure verification failed")
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ impl PusReceiver {
|
|||||||
self.verif_reporter
|
self.verif_reporter
|
||||||
.start_failure(
|
.start_failure(
|
||||||
token,
|
token,
|
||||||
FailParams::new(&self.time_stamp, &INVALID_PUS_SUBSERVICE, None),
|
FailParams::new(&self.time_stamp, &tmtc_err::INVALID_PUS_SUBSERVICE, None),
|
||||||
)
|
)
|
||||||
.expect("Sending start failure TM failed");
|
.expect("Sending start failure TM failed");
|
||||||
}
|
}
|
||||||
@ -131,30 +131,59 @@ impl PusReceiver {
|
|||||||
self.verif_reporter
|
self.verif_reporter
|
||||||
.start_failure(
|
.start_failure(
|
||||||
token,
|
token,
|
||||||
FailParams::new(&self.time_stamp, &NOT_ENOUGH_APP_DATA, None),
|
FailParams::new(&self.time_stamp, &tmtc_err::NOT_ENOUGH_APP_DATA, None),
|
||||||
)
|
)
|
||||||
.expect("Sending start failure TM failed");
|
.expect("Sending start failure TM failed");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
let user_data = pus_tc.user_data().unwrap();
|
let user_data = pus_tc.user_data().unwrap();
|
||||||
|
if user_data.len() < 8 {
|
||||||
|
let err = if user_data.len() < 4 {
|
||||||
|
&hk_err::TARGET_ID_MISSING
|
||||||
|
} else {
|
||||||
|
&hk_err::UNIQUE_ID_MISSING
|
||||||
|
};
|
||||||
|
self.update_time_stamp();
|
||||||
|
self.verif_reporter
|
||||||
|
.start_failure(token, FailParams::new(&self.time_stamp, err, None))
|
||||||
|
.expect("Sending start failure TM failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let addressable_id = AddressableId::from_raw_be(&user_data).unwrap();
|
||||||
|
if !self.request_map.contains_key(&addressable_id.target_id) {
|
||||||
|
self.update_time_stamp();
|
||||||
|
self.verif_reporter
|
||||||
|
.start_failure(
|
||||||
|
token,
|
||||||
|
FailParams::new(&self.time_stamp, &hk_err::UNKNOWN_TARGET_ID, None),
|
||||||
|
)
|
||||||
|
.expect("Sending start failure TM failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if PusPacket::subservice(pus_tc) == hk::Subservice::TcEnableGeneration as u8 {
|
if PusPacket::subservice(pus_tc) == hk::Subservice::TcEnableGeneration as u8 {
|
||||||
if user_data.len() < 8 {
|
let sender = self.request_map.get(&addressable_id.target_id).unwrap();
|
||||||
self.update_time_stamp();
|
sender
|
||||||
self.verif_reporter
|
.send(Request::HkRequest(HkRequest::Enable(
|
||||||
.start_failure(
|
addressable_id.unique_id,
|
||||||
token,
|
)))
|
||||||
FailParams::new(&self.time_stamp, &NOT_ENOUGH_APP_DATA, None),
|
.expect("Sending HK request failed")
|
||||||
)
|
} else if PusPacket::subservice(pus_tc) == hk::Subservice::TcDisableGeneration as u8 {
|
||||||
.expect("Sending start failure TM failed");
|
let sender = self.request_map.get(&addressable_id.target_id).unwrap();
|
||||||
}
|
sender
|
||||||
let addressable_id = AddressableId::from_raw_be(&user_data).unwrap();
|
.send(Request::HkRequest(HkRequest::Disable(
|
||||||
if self.request_map.contains_key(&addressable_id.target_id) {
|
addressable_id.unique_id,
|
||||||
let sender = self.request_map.get(&addressable_id.target_id).unwrap();
|
)))
|
||||||
sender
|
.expect("Sending HK request failed");
|
||||||
.send(Request::HkRequest(HkRequest::Enable(
|
} else if PusPacket::subservice(pus_tc) == hk::Subservice::TcGenerateOneShotHk as u8 {
|
||||||
addressable_id.unique_id,
|
let sender = self.request_map.get(&addressable_id.target_id).unwrap();
|
||||||
)))
|
sender
|
||||||
.expect("Sending HK request failed")
|
.send(Request::HkRequest(HkRequest::OneShot(
|
||||||
}
|
addressable_id.unique_id,
|
||||||
|
)))
|
||||||
|
.expect("Sending HK request failed");
|
||||||
|
} else if PusPacket::subservice(pus_tc) == hk::Subservice::TcModifyCollectionInterval as u8
|
||||||
|
{
|
||||||
|
if user_data.len() < 12 {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn handle_event_request(&mut self, pus_tc: &PusTc, token: VerificationToken<TcStateAccepted>) {
|
fn handle_event_request(&mut self, pus_tc: &PusTc, token: VerificationToken<TcStateAccepted>) {
|
||||||
@ -180,7 +209,7 @@ impl PusReceiver {
|
|||||||
send_start_failure(
|
send_start_failure(
|
||||||
&mut self.verif_reporter,
|
&mut self.verif_reporter,
|
||||||
&self.time_stamp,
|
&self.time_stamp,
|
||||||
&NOT_ENOUGH_APP_DATA,
|
&tmtc_err::NOT_ENOUGH_APP_DATA,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@ -191,7 +220,7 @@ impl PusReceiver {
|
|||||||
send_start_failure(
|
send_start_failure(
|
||||||
&mut self.verif_reporter,
|
&mut self.verif_reporter,
|
||||||
&self.time_stamp,
|
&self.time_stamp,
|
||||||
&NOT_ENOUGH_APP_DATA,
|
&tmtc_err::NOT_ENOUGH_APP_DATA,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@ -223,7 +252,7 @@ impl PusReceiver {
|
|||||||
send_start_failure(
|
send_start_failure(
|
||||||
&mut self.verif_reporter,
|
&mut self.verif_reporter,
|
||||||
&self.time_stamp,
|
&self.time_stamp,
|
||||||
&INVALID_PUS_SUBSERVICE,
|
&tmtc_err::INVALID_PUS_SUBSERVICE,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user