diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index 6ae9b1c0e4..7b5028f5f6 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -458,11 +458,14 @@ void EtbController::setOutput(expected outputValue) { if (!m_motor) return; - // If output is valid and we aren't paused, output to motor. - if (outputValue && !engineConfiguration->pauseEtbControl) { + // If ETB is allowed, output is valid, and we aren't paused, output to motor. + if (ENGINE(limpManager).allowElectronicThrottle() + && outputValue + && !engineConfiguration->pauseEtbControl) { m_motor->enable(); m_motor->set(ETB_PERCENT_TO_DUTY(outputValue.Value)); } else { + // Otherwise disable the motor. m_motor->disable(); } } diff --git a/unit_tests/tests/test_etb.cpp b/unit_tests/tests/test_etb.cpp index 99d4bcea7c..72723a8866 100644 --- a/unit_tests/tests/test_etb.cpp +++ b/unit_tests/tests/test_etb.cpp @@ -529,6 +529,26 @@ TEST(etb, setOutputPauseControl) { etb.setOutput(25.0f); } +TEST(etb, setOutputLimpHome) { + WITH_ENGINE_TEST_HELPER(TEST_ENGINE); + StrictMock motor; + + // Must have TPS initialized for ETB setup + Sensor::setMockValue(SensorType::Tps1, 0.0f, true); + + EtbController etb; + INJECT_ENGINE_REFERENCE(&etb); + etb.init(ETB_Throttle1, &motor, nullptr, nullptr, true); + + // Should be disabled when in ETB limp mode + EXPECT_CALL(motor, disable()); + + // Trip a fatal error + ENGINE(limpManager).fatalError(); + + etb.setOutput(25.0f); +} + TEST(etb, closedLoopPid) { pid_s pid = {}; pid.pFactor = 5;