fixes for example
Some checks failed
Rust/sat-rs/pipeline/pr-main There was a failure building this commit
Some checks failed
Rust/sat-rs/pipeline/pr-main There was a failure building this commit
This commit is contained in:
parent
4206c06d48
commit
7f77e8a214
@ -71,6 +71,7 @@ impl<ComInterface: SpiInterface, TmSender: EcssTmSenderCore> MgmHandler<ComInter
|
|||||||
pub fn periodic_operation(&mut self) {
|
pub fn periodic_operation(&mut self) {
|
||||||
self.stamp_helper.update_from_now();
|
self.stamp_helper.update_from_now();
|
||||||
// Handle messages.
|
// Handle messages.
|
||||||
|
// TODO: Put this in loop/seprate function.
|
||||||
match self.composite_request_receiver.try_recv() {
|
match self.composite_request_receiver.try_recv() {
|
||||||
Ok(ref msg) => match &msg.message {
|
Ok(ref msg) => match &msg.message {
|
||||||
CompositeRequest::Hk(hk_req) => match hk_req.variant {
|
CompositeRequest::Hk(hk_req) => match hk_req.variant {
|
||||||
@ -111,8 +112,18 @@ impl<ComInterface: SpiInterface, TmSender: EcssTmSenderCore> MgmHandler<ComInter
|
|||||||
// reply.
|
// reply.
|
||||||
CompositeRequest::Action(_action_req) => {}
|
CompositeRequest::Action(_action_req) => {}
|
||||||
},
|
},
|
||||||
Err(_) => todo!(),
|
|
||||||
|
Err(e) => {
|
||||||
|
if e != mpsc::TryRecvError::Empty {
|
||||||
|
log::warn!(
|
||||||
|
"{}: failed to receive composite request: {:?}",
|
||||||
|
self.dev_str,
|
||||||
|
e
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO: Put this in loop and only allow one set mode request per cycle?
|
||||||
match self.mode_interface.request_rx.try_recv() {
|
match self.mode_interface.request_rx.try_recv() {
|
||||||
Ok(msg) => {
|
Ok(msg) => {
|
||||||
let result = self.handle_mode_request(msg);
|
let result = self.handle_mode_request(msg);
|
||||||
@ -125,7 +136,11 @@ impl<ComInterface: SpiInterface, TmSender: EcssTmSenderCore> MgmHandler<ComInter
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_) => todo!(),
|
Err(e) => {
|
||||||
|
if e != mpsc::TryRecvError::Empty {
|
||||||
|
log::warn!("{}: failed to receive mode request: {:?}", self.dev_str, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@ use std::time::Duration;
|
|||||||
use crate::requests::GenericRequestRouter;
|
use crate::requests::GenericRequestRouter;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
create_verification_reporter, generic_pus_request_timeout_handler, PusTargetedRequestService,
|
create_verification_reporter, generic_pus_request_timeout_handler, HandlingStatus,
|
||||||
TargetedPusService,
|
PusTargetedRequestService, TargetedPusService,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct ActionReplyHandler {
|
pub struct ActionReplyHandler {
|
||||||
@ -291,12 +291,13 @@ impl<TmSender: EcssTmSenderCore, TcInMemConverter: EcssTcInMemConverter> Targete
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll_and_handle_next_reply(&mut self, time_stamp: &[u8]) -> bool {
|
fn poll_and_handle_next_reply(&mut self, time_stamp: &[u8]) -> HandlingStatus {
|
||||||
|
// This only fails if all senders disconnected. Treat it like an empty queue.
|
||||||
self.service
|
self.service
|
||||||
.poll_and_check_next_reply(time_stamp)
|
.poll_and_check_next_reply(time_stamp)
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
warn!("PUS 8: Handling reply failed with error {e:?}");
|
warn!("PUS 8: Handling reply failed with error {e:?}");
|
||||||
false
|
HandlingStatus::Empty
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -536,7 +537,10 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn converter_action_req_no_data() {
|
fn converter_action_req_no_data() {
|
||||||
let mut testbench = PusConverterTestbench::new(TEST_COMPONENT_ID_0.raw(), ActionRequestConverter::default());
|
let mut testbench = PusConverterTestbench::new(
|
||||||
|
TEST_COMPONENT_ID_0.raw(),
|
||||||
|
ActionRequestConverter::default(),
|
||||||
|
);
|
||||||
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||||
let sec_header = PusTcSecondaryHeader::new_simple(8, 128);
|
let sec_header = PusTcSecondaryHeader::new_simple(8, 128);
|
||||||
let action_id = 5_u32;
|
let action_id = 5_u32;
|
||||||
@ -567,7 +571,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn converter_action_req_with_data() {
|
fn converter_action_req_with_data() {
|
||||||
let mut testbench = PusConverterTestbench::new(TEST_COMPONENT_ID_0.id(), ActionRequestConverter::default());
|
let mut testbench =
|
||||||
|
PusConverterTestbench::new(TEST_COMPONENT_ID_0.id(), ActionRequestConverter::default());
|
||||||
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||||
let sec_header = PusTcSecondaryHeader::new_simple(8, 128);
|
let sec_header = PusTcSecondaryHeader::new_simple(8, 128);
|
||||||
let action_id = 5_u32;
|
let action_id = 5_u32;
|
||||||
@ -642,7 +647,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn reply_handling_step_success() {
|
fn reply_handling_step_success() {
|
||||||
let mut testbench = ReplyHandlerTestbench::new(TEST_COMPONENT_ID_0.id(), ActionReplyHandler::default());
|
let mut testbench =
|
||||||
|
ReplyHandlerTestbench::new(TEST_COMPONENT_ID_0.id(), ActionReplyHandler::default());
|
||||||
let action_id = 5_u32;
|
let action_id = 5_u32;
|
||||||
let (req_id, active_req) = testbench.add_tc(TEST_APID, TEST_UNIQUE_ID_0, &[]);
|
let (req_id, active_req) = testbench.add_tc(TEST_APID, TEST_UNIQUE_ID_0, &[]);
|
||||||
let active_action_req =
|
let active_action_req =
|
||||||
|
@ -24,7 +24,7 @@ use std::time::Duration;
|
|||||||
use crate::pus::{create_verification_reporter, generic_pus_request_timeout_handler};
|
use crate::pus::{create_verification_reporter, generic_pus_request_timeout_handler};
|
||||||
use crate::requests::GenericRequestRouter;
|
use crate::requests::GenericRequestRouter;
|
||||||
|
|
||||||
use super::PusTargetedRequestService;
|
use super::{HandlingStatus, PusTargetedRequestService};
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Debug, new)]
|
#[derive(Clone, PartialEq, Debug, new)]
|
||||||
pub struct HkReply {
|
pub struct HkReply {
|
||||||
@ -324,12 +324,13 @@ impl<TmSender: EcssTmSenderCore, TcInMemConverter: EcssTcInMemConverter>
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn poll_and_handle_next_reply(&mut self, time_stamp: &[u8]) -> bool {
|
pub fn poll_and_handle_next_reply(&mut self, time_stamp: &[u8]) -> HandlingStatus {
|
||||||
|
// This only fails if all senders disconnected. Treat it like an empty queue.
|
||||||
self.service
|
self.service
|
||||||
.poll_and_check_next_reply(time_stamp)
|
.poll_and_check_next_reply(time_stamp)
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
warn!("PUS 3: Handling reply failed with error {e:?}");
|
warn!("PUS 3: Handling reply failed with error {e:?}");
|
||||||
false
|
HandlingStatus::Empty
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,7 +341,9 @@ impl<TmSender: EcssTmSenderCore, TcInMemConverter: EcssTcInMemConverter>
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use satrs::pus::test_util::{TEST_COMPONENT_ID_0, TEST_COMPONENT_ID_1, TEST_UNIQUE_ID_0, TEST_UNIQUE_ID_1};
|
use satrs::pus::test_util::{
|
||||||
|
TEST_COMPONENT_ID_0, TEST_COMPONENT_ID_1, TEST_UNIQUE_ID_0, TEST_UNIQUE_ID_1,
|
||||||
|
};
|
||||||
use satrs::request::MessageMetadata;
|
use satrs::request::MessageMetadata;
|
||||||
use satrs::{
|
use satrs::{
|
||||||
hk::HkRequestVariant,
|
hk::HkRequestVariant,
|
||||||
@ -362,7 +365,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hk_converter_one_shot_req() {
|
fn hk_converter_one_shot_req() {
|
||||||
let mut hk_bench = PusConverterTestbench::new(TEST_COMPONENT_ID_0.id(), HkRequestConverter::default());
|
let mut hk_bench =
|
||||||
|
PusConverterTestbench::new(TEST_COMPONENT_ID_0.id(), HkRequestConverter::default());
|
||||||
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||||
let target_id = TEST_UNIQUE_ID_0;
|
let target_id = TEST_UNIQUE_ID_0;
|
||||||
let unique_id = 5_u32;
|
let unique_id = 5_u32;
|
||||||
@ -391,7 +395,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hk_converter_enable_periodic_generation() {
|
fn hk_converter_enable_periodic_generation() {
|
||||||
let mut hk_bench = PusConverterTestbench::new(TEST_COMPONENT_ID_0.id(), HkRequestConverter::default());
|
let mut hk_bench =
|
||||||
|
PusConverterTestbench::new(TEST_COMPONENT_ID_0.id(), HkRequestConverter::default());
|
||||||
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||||
let target_id = TEST_UNIQUE_ID_0;
|
let target_id = TEST_UNIQUE_ID_0;
|
||||||
let unique_id = 5_u32;
|
let unique_id = 5_u32;
|
||||||
@ -429,7 +434,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hk_conversion_disable_periodic_generation() {
|
fn hk_conversion_disable_periodic_generation() {
|
||||||
let mut hk_bench = PusConverterTestbench::new(TEST_COMPONENT_ID_0.id(), HkRequestConverter::default());
|
let mut hk_bench =
|
||||||
|
PusConverterTestbench::new(TEST_COMPONENT_ID_0.id(), HkRequestConverter::default());
|
||||||
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||||
let target_id = TEST_UNIQUE_ID_0;
|
let target_id = TEST_UNIQUE_ID_0;
|
||||||
let unique_id = 5_u32;
|
let unique_id = 5_u32;
|
||||||
@ -467,7 +473,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hk_conversion_modify_interval() {
|
fn hk_conversion_modify_interval() {
|
||||||
let mut hk_bench = PusConverterTestbench::new(TEST_COMPONENT_ID_0.id(), HkRequestConverter::default());
|
let mut hk_bench =
|
||||||
|
PusConverterTestbench::new(TEST_COMPONENT_ID_0.id(), HkRequestConverter::default());
|
||||||
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||||
let target_id = TEST_UNIQUE_ID_0;
|
let target_id = TEST_UNIQUE_ID_0;
|
||||||
let unique_id = 5_u32;
|
let unique_id = 5_u32;
|
||||||
@ -509,7 +516,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hk_reply_handler() {
|
fn hk_reply_handler() {
|
||||||
let mut reply_testbench = ReplyHandlerTestbench::new(TEST_COMPONENT_ID_0.id(), HkReplyHandler::default());
|
let mut reply_testbench =
|
||||||
|
ReplyHandlerTestbench::new(TEST_COMPONENT_ID_0.id(), HkReplyHandler::default());
|
||||||
let sender_id = 2_u64;
|
let sender_id = 2_u64;
|
||||||
let apid_target_id = 3_u32;
|
let apid_target_id = 3_u32;
|
||||||
let unique_id = 5_u32;
|
let unique_id = 5_u32;
|
||||||
@ -528,7 +536,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn reply_handling_unrequested_reply() {
|
fn reply_handling_unrequested_reply() {
|
||||||
let mut testbench = ReplyHandlerTestbench::new(TEST_COMPONENT_ID_1.id(), HkReplyHandler::default());
|
let mut testbench =
|
||||||
|
ReplyHandlerTestbench::new(TEST_COMPONENT_ID_1.id(), HkReplyHandler::default());
|
||||||
let action_reply = HkReply::new(5_u32, HkReplyVariant::Ack);
|
let action_reply = HkReply::new(5_u32, HkReplyVariant::Ack);
|
||||||
let unrequested_reply =
|
let unrequested_reply =
|
||||||
GenericMessage::new(MessageMetadata::new(10_u32, 15_u64), action_reply);
|
GenericMessage::new(MessageMetadata::new(10_u32, 15_u64), action_reply);
|
||||||
@ -540,7 +549,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn reply_handling_reply_timeout() {
|
fn reply_handling_reply_timeout() {
|
||||||
let mut testbench = ReplyHandlerTestbench::new(TEST_COMPONENT_ID_1.id(), HkReplyHandler::default());
|
let mut testbench =
|
||||||
|
ReplyHandlerTestbench::new(TEST_COMPONENT_ID_1.id(), HkReplyHandler::default());
|
||||||
let (req_id, active_request) = testbench.add_tc(TEST_APID, TEST_UNIQUE_ID_1, &[]);
|
let (req_id, active_request) = testbench.add_tc(TEST_APID, TEST_UNIQUE_ID_1, &[]);
|
||||||
let result = testbench.handle_request_timeout(&active_request, &[]);
|
let result = testbench.handle_request_timeout(&active_request, &[]);
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
|
@ -30,6 +30,12 @@ pub mod scheduler;
|
|||||||
pub mod stack;
|
pub mod stack;
|
||||||
pub mod test;
|
pub mod test;
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
|
||||||
|
pub enum HandlingStatus {
|
||||||
|
Empty,
|
||||||
|
HandledOne,
|
||||||
|
}
|
||||||
|
|
||||||
pub fn create_verification_reporter(owner_id: ComponentId, apid: Apid) -> VerificationReporter {
|
pub fn create_verification_reporter(owner_id: ComponentId, apid: Apid) -> VerificationReporter {
|
||||||
let verif_cfg = VerificationReporterCfg::new(apid, 1, 2, 8).unwrap();
|
let verif_cfg = VerificationReporterCfg::new(apid, 1, 2, 8).unwrap();
|
||||||
// Every software component which needs to generate verification telemetry, gets a cloned
|
// Every software component which needs to generate verification telemetry, gets a cloned
|
||||||
@ -150,7 +156,7 @@ impl<TmSender: EcssTmSenderCore> PusReceiver<TmSender> {
|
|||||||
pub trait TargetedPusService {
|
pub trait TargetedPusService {
|
||||||
/// Returns [true] if the packet handling is finished.
|
/// Returns [true] if the packet handling is finished.
|
||||||
fn poll_and_handle_next_tc(&mut self, time_stamp: &[u8]) -> bool;
|
fn poll_and_handle_next_tc(&mut self, time_stamp: &[u8]) -> bool;
|
||||||
fn poll_and_handle_next_reply(&mut self, time_stamp: &[u8]) -> bool;
|
fn poll_and_handle_next_reply(&mut self, time_stamp: &[u8]) -> HandlingStatus;
|
||||||
fn check_for_request_timeouts(&mut self);
|
fn check_for_request_timeouts(&mut self);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,14 +368,17 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn poll_and_check_next_reply(&mut self, time_stamp: &[u8]) -> Result<bool, EcssTmtcError> {
|
pub fn poll_and_check_next_reply(
|
||||||
|
&mut self,
|
||||||
|
time_stamp: &[u8],
|
||||||
|
) -> Result<HandlingStatus, EcssTmtcError> {
|
||||||
match self.reply_receiver.try_recv() {
|
match self.reply_receiver.try_recv() {
|
||||||
Ok(reply) => {
|
Ok(reply) => {
|
||||||
self.handle_reply(&reply, time_stamp)?;
|
self.handle_reply(&reply, time_stamp)?;
|
||||||
Ok(false)
|
Ok(HandlingStatus::HandledOne)
|
||||||
}
|
}
|
||||||
Err(e) => match e {
|
Err(e) => match e {
|
||||||
mpsc::TryRecvError::Empty => Ok(true),
|
mpsc::TryRecvError::Empty => Ok(HandlingStatus::Empty),
|
||||||
mpsc::TryRecvError::Disconnected => Err(EcssTmtcError::Receive(
|
mpsc::TryRecvError::Disconnected => Err(EcssTmtcError::Receive(
|
||||||
GenericReceiveError::TxDisconnected(None),
|
GenericReceiveError::TxDisconnected(None),
|
||||||
)),
|
)),
|
||||||
|
@ -38,8 +38,8 @@ use satrs_example::config::components::PUS_MODE_SERVICE;
|
|||||||
use satrs_example::config::{mode_err, tmtc_err};
|
use satrs_example::config::{mode_err, tmtc_err};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
create_verification_reporter, generic_pus_request_timeout_handler, PusTargetedRequestService,
|
create_verification_reporter, generic_pus_request_timeout_handler, HandlingStatus,
|
||||||
TargetedPusService,
|
PusTargetedRequestService, TargetedPusService,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(new)]
|
#[derive(new)]
|
||||||
@ -302,12 +302,12 @@ impl<TmSender: EcssTmSenderCore, TcInMemConverter: EcssTcInMemConverter> Targete
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll_and_handle_next_reply(&mut self, time_stamp: &[u8]) -> bool {
|
fn poll_and_handle_next_reply(&mut self, time_stamp: &[u8]) -> HandlingStatus {
|
||||||
self.service
|
self.service
|
||||||
.poll_and_check_next_reply(time_stamp)
|
.poll_and_check_next_reply(time_stamp)
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
warn!("PUS action service: Handling reply failed with error {e:?}");
|
warn!("PUS action service: Handling reply failed with error {e:?}");
|
||||||
false
|
HandlingStatus::HandledOne
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,7 +339,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn mode_converter_read_mode_request() {
|
fn mode_converter_read_mode_request() {
|
||||||
let mut testbench = PusConverterTestbench::new(TEST_COMPONENT_ID_0.id(), ModeRequestConverter::default());
|
let mut testbench =
|
||||||
|
PusConverterTestbench::new(TEST_COMPONENT_ID_0.id(), ModeRequestConverter::default());
|
||||||
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||||
let sec_header = PusTcSecondaryHeader::new_simple(200, Subservice::TcReadMode as u8);
|
let sec_header = PusTcSecondaryHeader::new_simple(200, Subservice::TcReadMode as u8);
|
||||||
let mut app_data: [u8; 4] = [0; 4];
|
let mut app_data: [u8; 4] = [0; 4];
|
||||||
@ -354,7 +355,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn mode_converter_set_mode_request() {
|
fn mode_converter_set_mode_request() {
|
||||||
let mut testbench = PusConverterTestbench::new(TEST_COMPONENT_ID_0.id(), ModeRequestConverter::default());
|
let mut testbench =
|
||||||
|
PusConverterTestbench::new(TEST_COMPONENT_ID_0.id(), ModeRequestConverter::default());
|
||||||
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||||
let sec_header = PusTcSecondaryHeader::new_simple(200, Subservice::TcSetMode as u8);
|
let sec_header = PusTcSecondaryHeader::new_simple(200, Subservice::TcSetMode as u8);
|
||||||
let mut app_data: [u8; 4 + ModeAndSubmode::RAW_LEN] = [0; 4 + ModeAndSubmode::RAW_LEN];
|
let mut app_data: [u8; 4 + ModeAndSubmode::RAW_LEN] = [0; 4 + ModeAndSubmode::RAW_LEN];
|
||||||
@ -373,7 +375,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn mode_converter_announce_mode() {
|
fn mode_converter_announce_mode() {
|
||||||
let mut testbench = PusConverterTestbench::new(TEST_COMPONENT_ID_0.id(), ModeRequestConverter::default());
|
let mut testbench =
|
||||||
|
PusConverterTestbench::new(TEST_COMPONENT_ID_0.id(), ModeRequestConverter::default());
|
||||||
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||||
let sec_header = PusTcSecondaryHeader::new_simple(200, Subservice::TcAnnounceMode as u8);
|
let sec_header = PusTcSecondaryHeader::new_simple(200, Subservice::TcAnnounceMode as u8);
|
||||||
let mut app_data: [u8; 4] = [0; 4];
|
let mut app_data: [u8; 4] = [0; 4];
|
||||||
@ -388,7 +391,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn mode_converter_announce_mode_recursively() {
|
fn mode_converter_announce_mode_recursively() {
|
||||||
let mut testbench = PusConverterTestbench::new(TEST_COMPONENT_ID_0.id(), ModeRequestConverter::default());
|
let mut testbench =
|
||||||
|
PusConverterTestbench::new(TEST_COMPONENT_ID_0.id(), ModeRequestConverter::default());
|
||||||
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
let mut sp_header = SpHeader::tc_unseg(TEST_APID, 0, 0).unwrap();
|
||||||
let sec_header =
|
let sec_header =
|
||||||
PusTcSecondaryHeader::new_simple(200, Subservice::TcAnnounceModeRecursive as u8);
|
PusTcSecondaryHeader::new_simple(200, Subservice::TcAnnounceModeRecursive as u8);
|
||||||
@ -404,7 +408,10 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn reply_handling_unrequested_reply() {
|
fn reply_handling_unrequested_reply() {
|
||||||
let mut testbench = ReplyHandlerTestbench::new(TEST_COMPONENT_ID_0.id(), ModeReplyHandler::new(TEST_COMPONENT_ID_0.id()));
|
let mut testbench = ReplyHandlerTestbench::new(
|
||||||
|
TEST_COMPONENT_ID_0.id(),
|
||||||
|
ModeReplyHandler::new(TEST_COMPONENT_ID_0.id()),
|
||||||
|
);
|
||||||
let mode_reply = ModeReply::ModeReply(ModeAndSubmode::new(5, 1));
|
let mode_reply = ModeReply::ModeReply(ModeAndSubmode::new(5, 1));
|
||||||
let unrequested_reply =
|
let unrequested_reply =
|
||||||
GenericMessage::new(MessageMetadata::new(10_u32, 15_u64), mode_reply);
|
GenericMessage::new(MessageMetadata::new(10_u32, 15_u64), mode_reply);
|
||||||
@ -416,7 +423,10 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn reply_handling_reply_timeout() {
|
fn reply_handling_reply_timeout() {
|
||||||
let mut testbench = ReplyHandlerTestbench::new(TEST_COMPONENT_ID_0.id(), ModeReplyHandler::new(TEST_COMPONENT_ID_0.id()));
|
let mut testbench = ReplyHandlerTestbench::new(
|
||||||
|
TEST_COMPONENT_ID_0.id(),
|
||||||
|
ModeReplyHandler::new(TEST_COMPONENT_ID_0.id()),
|
||||||
|
);
|
||||||
let (req_id, active_request) = testbench.add_tc(TEST_APID, TEST_UNIQUE_ID_0, &[]);
|
let (req_id, active_request) = testbench.add_tc(TEST_APID, TEST_UNIQUE_ID_0, &[]);
|
||||||
let result = testbench.handle_request_timeout(&active_request, &[]);
|
let result = testbench.handle_request_timeout(&active_request, &[]);
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
|
@ -7,7 +7,8 @@ use satrs::{
|
|||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
action::ActionServiceWrapper, event::EventServiceWrapper, hk::HkServiceWrapper,
|
action::ActionServiceWrapper, event::EventServiceWrapper, hk::HkServiceWrapper,
|
||||||
scheduler::SchedulingServiceWrapper, test::TestCustomServiceWrapper, TargetedPusService,
|
scheduler::SchedulingServiceWrapper, test::TestCustomServiceWrapper, HandlingStatus,
|
||||||
|
TargetedPusService,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(new)]
|
#[derive(new)]
|
||||||
@ -34,9 +35,10 @@ impl<TmSender: EcssTmSenderCore, TcInMemConverter: EcssTcInMemConverter>
|
|||||||
loop {
|
loop {
|
||||||
let mut nothing_to_do = true;
|
let mut nothing_to_do = true;
|
||||||
let mut is_srv_finished =
|
let mut is_srv_finished =
|
||||||
|tc_handling_done: bool, reply_handling_done: Option<bool>| {
|
|tc_handling_done: bool, reply_handling_done: Option<HandlingStatus>| {
|
||||||
if !tc_handling_done
|
if !tc_handling_done
|
||||||
|| (reply_handling_done.is_some() && !reply_handling_done.unwrap())
|
|| (reply_handling_done.is_some()
|
||||||
|
&& reply_handling_done.unwrap() == HandlingStatus::Empty)
|
||||||
{
|
{
|
||||||
nothing_to_do = false;
|
nothing_to_do = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user