This commit is contained in:
Robin Mueller
2026-09-23 18:34:35 +02:00
parent a8353a56bc
commit 01fe7ffbcb
+23 -8
View File
@@ -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();