From 01fe7ffbcbe14702bef35ebfa2ee303143c49782 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 23 Sep 2026 18:34:35 +0200 Subject: [PATCH] simplify --- satrs-example/src/acs/mgm.rs | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/satrs-example/src/acs/mgm.rs b/satrs-example/src/acs/mgm.rs index 158355f..c73e71a 100644 --- a/satrs-example/src/acs/mgm.rs +++ b/satrs-example/src/acs/mgm.rs @@ -546,14 +546,8 @@ impl MgmHandlerLis3Mdl { self.send_event(mgm::Event::Recovery(RecoveryEvent::ThresholdExceeded)); self.switch_off_faulty_device(); } - FaultResponse::Ignored => { - // Ground changed the health during the recovery, so the device is left as it - // is. The power cycle is not hidden from other components anymore. - if self.mode() != restore_mode { - self.announce_mode(); - self.report_mode_to_parent(); - } - } + // Ground changed the health during the recovery and is in charge now. + FaultResponse::Ignored => (), } } @@ -1301,6 +1295,27 @@ mod tests { )); } + #[test] + fn test_health_command_during_recovery_is_kept() { + let mut testbench = MgmTestbench::new(); + testbench.switch_to_normal(); + testbench.exceed_spi_fault_threshold(); + testbench.test_spi_interface().next_mgm_data = MgmLis3RawValues::default(); + testbench + .tc_tx + .send(create_request_tc( + MgmSelect::_0, + mgm::request::Request::Health(mgm::request::HealthRequest::SetHealth( + HealthState::ExternalControl, + )), + )) + .unwrap(); + + // The power cycle is not cancelled, but it does not override the health set by ground. + testbench.complete_power_cycle(); + assert_eq!(testbench.health(), Some(HealthState::ExternalControl)); + } + #[test] fn test_read_mode_during_power_cycle_returns_restored_mode() { let mut testbench = MgmTestbench::new();