From e876fd21154e3e66f87ec1e0513fae702673d769 Mon Sep 17 00:00:00 2001 From: rusefi Date: Wed, 19 Apr 2017 07:58:22 -0400 Subject: [PATCH] better startup handling --- firmware/controllers/algo/engine.cpp | 4 +--- firmware/controllers/algo/fuel_math.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 329107ea6c..01d43c2d14 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -75,9 +75,7 @@ void Engine::updateSlowSensors(DECLARE_ENGINE_PARAMETER_F) { } sensors.vBatt = hasVBatt(PASS_ENGINE_PARAMETER_F) ? getVBatt(PASS_ENGINE_PARAMETER_F) : 12; - floatms_t injectorLag = getInjectorLag(sensors.vBatt PASS_ENGINE_PARAMETER); - efiAssertVoid(!cisnan(injectorLag), "NaN injectorLag"); - engineState.injectorLag = injectorLag; + engineState.injectorLag = getInjectorLag(sensors.vBatt PASS_ENGINE_PARAMETER); } void Engine::onTriggerEvent(efitick_t nowNt) { diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index 028593f58a..14042e5433 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -137,6 +137,7 @@ floatms_t getInjectionDuration(int rpm DECLARE_ENGINE_PARAMETER_S) { engineConfiguration->crankingInjectionMode : engineConfiguration->injectionMode PASS_ENGINE_PARAMETER); if (numberOfCylinders == 0) { + warning(CUSTOM_ERR_6509, "config not ready"); return 0; // we can end up here during configuration reset } if (isCranking) { @@ -152,7 +153,12 @@ floatms_t getInjectionDuration(int rpm DECLARE_ENGINE_PARAMETER_S) { baseFuel, fuelPerCycle, theoreticalInjectionLength); #endif /*EFI_PRINTF_FUEL_DETAILS */ } - return theoreticalInjectionLength + ENGINE(engineState.injectorLag); + floatms_t injectorLag = ENGINE(engineState.injectorLag); + if (cisnan(injectorLag)) { + warning(CUSTOM_ERR_6539, "injectorLah not ready"); + return 0; // we can end up here during configuration reset + } + return theoreticalInjectionLength + injectorLag; } floatms_t getRunningFuel(floatms_t baseFuel DECLARE_ENGINE_PARAMETER_S) {