From 385f4b12e803debffe9e3a2c592ee0e665ad0f2f Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 19 Apr 2020 23:55:27 -0400 Subject: [PATCH] Better handling in case of ETB idle without ETB #1332 --- firmware/controllers/actuators/idle_thread.cpp | 7 +++++++ firmware/controllers/core/error_handling.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/firmware/controllers/actuators/idle_thread.cpp b/firmware/controllers/actuators/idle_thread.cpp index 502f6c2b8a..7427200925 100644 --- a/firmware/controllers/actuators/idle_thread.cpp +++ b/firmware/controllers/actuators/idle_thread.cpp @@ -154,6 +154,13 @@ static void applyIACposition(percent_t position) { float duty = PERCENT_TO_DUTY(position); if (CONFIG(useETBforIdleControl)) { + + if (!Sensor::hasSensor(SensorType::AcceleratorPedal)) { + firmwareError(CUSTOM_NO_ETB_FOR_IDLE, "No ETB to use for idle"); + return; + } + + engine->engineState.idle.etbIdleAddition = duty * CONFIG(etbIdleThrottleRange); #if ! EFI_UNIT_TEST } if (CONFIG(useStepperIdle)) { diff --git a/firmware/controllers/core/error_handling.h b/firmware/controllers/core/error_handling.h index f5bf9e3d31..bca7435b04 100644 --- a/firmware/controllers/core/error_handling.h +++ b/firmware/controllers/core/error_handling.h @@ -26,6 +26,8 @@ bool warning(obd_code_e code, const char *fmt, ...); typedef uint8_t critical_msg_t[ERROR_BUFFER_SIZE]; /** * Something really bad had happened - firmware cannot function, we cannot run the engine + * We definitely use this critical error approach in case of invalid configuration. If user sets a self-contradicting + * configuration we have to just put a hard stop on this. * * see also warning() */