From 8f5abb88afcf81eab91109412c3018b10a505337 Mon Sep 17 00:00:00 2001 From: rusefi Date: Wed, 26 Oct 2022 17:33:10 -0400 Subject: [PATCH] GM SENT ETB bench test in NJ #4688 --- .../actuators/electronic_throttle.cpp | 34 +++++++++---------- .../actuators/electronic_throttle.h | 1 + firmware/controllers/lua/lua_hooks.cpp | 2 +- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/firmware/controllers/actuators/electronic_throttle.cpp b/firmware/controllers/actuators/electronic_throttle.cpp index 6b5fd4fdfc..e08325843c 100644 --- a/firmware/controllers/actuators/electronic_throttle.cpp +++ b/firmware/controllers/actuators/electronic_throttle.cpp @@ -951,23 +951,7 @@ static pid_s* getEtbPidForFunction(etb_function_e function) { } } -static void doInitElectronicThrottle() { - efiAssertVoid(OBD_PCM_Processor_Fault, engine->etbControllers != NULL, "etbControllers NULL"); -#if EFI_PROD_CODE - addConsoleAction("ethinfo", showEthInfo); - addConsoleAction("etbreset", etbReset); - addConsoleActionI("etb_freq", setEtbFrequency); - - // this command is useful for real hardware test with known cheap hardware - addConsoleAction("etb_test_hw", [](){ - set18919_AM810_pedal_position_sensor(); - }); - -#endif /* EFI_PROD_CODE */ - - pedal2tpsMap.init(config->pedalToTpsTable, config->pedalToTpsPedalBins, config->pedalToTpsRpmBins); - throttle2TrimTable.init(config->throttle2TrimTable, config->throttle2TrimTpsBins, config->throttle2TrimRpmBins); - +void doInitElectronicThrottle() { bool shouldInitThrottles = Sensor::hasSensor(SensorType::AcceleratorPedalPrimary); bool anyEtbConfigured = false; @@ -1034,6 +1018,22 @@ void initElectronicThrottle() { } #endif + efiAssertVoid(OBD_PCM_Processor_Fault, engine->etbControllers != NULL, "etbControllers NULL"); +#if EFI_PROD_CODE + addConsoleAction("ethinfo", showEthInfo); + addConsoleAction("etbreset", etbReset); + addConsoleActionI("etb_freq", setEtbFrequency); + + // this command is useful for real hardware test with known cheap hardware + addConsoleAction("etb_test_hw", [](){ + set18919_AM810_pedal_position_sensor(); + }); + +#endif /* EFI_PROD_CODE */ + + pedal2tpsMap.init(config->pedalToTpsTable, config->pedalToTpsPedalBins, config->pedalToTpsRpmBins); + throttle2TrimTable.init(config->throttle2TrimTable, config->throttle2TrimTpsBins, config->throttle2TrimRpmBins); + doInitElectronicThrottle(); } diff --git a/firmware/controllers/actuators/electronic_throttle.h b/firmware/controllers/actuators/electronic_throttle.h index 09eceb1c2a..de4818e813 100644 --- a/firmware/controllers/actuators/electronic_throttle.h +++ b/firmware/controllers/actuators/electronic_throttle.h @@ -12,6 +12,7 @@ #include "engine_configuration.h" void initElectronicThrottle(); +void doInitElectronicThrottle(); void setEtbIdlePosition(percent_t pos); void setEtbWastegatePosition(percent_t pos); diff --git a/firmware/controllers/lua/lua_hooks.cpp b/firmware/controllers/lua/lua_hooks.cpp index f9154b9272..ce98b272cd 100644 --- a/firmware/controllers/lua/lua_hooks.cpp +++ b/firmware/controllers/lua/lua_hooks.cpp @@ -725,7 +725,7 @@ void configureRusefiLuaHooks(lua_State* l) { lua_register(l, "restartEtb", [](lua_State* l) { // this is about Lua sensor acting in place of real analog PPS sensor // todo: smarter implementation - initElectronicThrottle(); + doInitElectronicThrottle(); return 0; }); #endif // EFI_PROD_CODE