From a5ba9d54dc47af5166394c15983b3b44fd463e4f Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Thu, 26 Nov 2020 16:21:42 -0800 Subject: [PATCH] fix etb unit test idle hardware (#1991) * move check to etb * give it a sensor to read --- firmware/controllers/actuators/electronic_throttle.cpp | 5 +++++ firmware/controllers/actuators/idle_hardware.cpp | 8 -------- unit_tests/engine_test_helper.h | 2 ++ unit_tests/tests/test_start_stop.cpp | 3 ++- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index d34ed62a23..0c441c0247 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -910,6 +910,11 @@ void initElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE) { } void setEtbIdlePosition(percent_t pos DECLARE_ENGINE_PARAMETER_SUFFIX) { + if (!Sensor::hasSensor(SensorType::AcceleratorPedal)) { + firmwareError(CUSTOM_NO_ETB_FOR_IDLE, "No ETB to use for idle"); + return; + } + for (int i = 0; i < ETB_COUNT; i++) { if (auto etb = engine->etbControllers[i]) { etb->setIdlePosition(pos); diff --git a/firmware/controllers/actuators/idle_hardware.cpp b/firmware/controllers/actuators/idle_hardware.cpp index ef4fb2fb5c..9f1cbb024f 100644 --- a/firmware/controllers/actuators/idle_hardware.cpp +++ b/firmware/controllers/actuators/idle_hardware.cpp @@ -55,14 +55,6 @@ void applyIACposition(percent_t position DECLARE_ENGINE_PARAMETER_SUFFIX) { float duty = PERCENT_TO_DUTY(position); if (CONFIG(useETBforIdleControl)) { - if (!Sensor::hasSensor(SensorType::AcceleratorPedal)) { -//todo: something is wrong here in unit test mode? -#if !EFI_UNIT_TEST - firmwareError(CUSTOM_NO_ETB_FOR_IDLE, "No ETB to use for idle"); -#endif - return; - } - #if EFI_ELECTRONIC_THROTTLE_BODY setEtbIdlePosition(position PASS_ENGINE_PARAMETER_SUFFIX); #endif // EFI_ELECTRONIC_THROTTLE_BODY diff --git a/unit_tests/engine_test_helper.h b/unit_tests/engine_test_helper.h index 9778e590d4..00f9d61824 100644 --- a/unit_tests/engine_test_helper.h +++ b/unit_tests/engine_test_helper.h @@ -17,6 +17,8 @@ #include "sensor.h" #include "mocks.h" +#include + extern EnginePins enginePins; class EngineTestHelperBase diff --git a/unit_tests/tests/test_start_stop.cpp b/unit_tests/tests/test_start_stop.cpp index 661bfea3a5..165e5bdc96 100644 --- a/unit_tests/tests/test_start_stop.cpp +++ b/unit_tests/tests/test_start_stop.cpp @@ -9,7 +9,8 @@ #include "engine_controller.h" TEST(start, startStop) { - WITH_ENGINE_TEST_HELPER(BMW_M73_PROTEUS); + std::unordered_map sensorVals = {{ SensorType::AcceleratorPedal, 0 }}; + WITH_ENGINE_TEST_HELPER_SENS(BMW_M73_PROTEUS, sensorVals); eth.smartMoveTimeForwardSeconds(1); // '0' time has special meaning for implementation so let's move forward // this is a pull-up, so 'true' on start-up