From cecc5a9d6e7614f94aee6edaaab32fc9a97d1df1 Mon Sep 17 00:00:00 2001 From: Andrey Date: Thu, 25 Aug 2022 19:58:10 -0400 Subject: [PATCH] https://github.com/rusefi/hellen154hyundai/issues/60 extra logging --- firmware/controllers/algo/engine.h | 6 ++---- firmware/controllers/algo/event_registry.h | 2 +- .../controllers/engine_cycle/main_trigger_callback.cpp | 3 +++ firmware/controllers/engine_cycle/spark_logic.cpp | 7 +++++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 639724d534..719e84ba0a 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -260,10 +260,6 @@ public: bool needTdcCallback = true; #endif /* EFI_UNIT_TEST */ - /** - * By the way 32-bit value should hold at least 400 hours of events at 6K RPM x 12 events per revolution - */ - int globalSparkIdCounter = 0; // this is useful at least for real hardware integration testing - maybe a proper solution would be to simply // GND input pins instead of leaving them floating @@ -290,6 +286,7 @@ public: scheduling_s tdcScheduler[2]; #endif /* EFI_ENGINE_CONTROL */ + // todo: move to electronic_throttle something? bool etbAutoTune = false; /** * this is based on engineSnifferRpmThreshold settings and current RPM @@ -320,6 +317,7 @@ public: /** * this is needed by getTimeIgnitionSeconds() and checkShutdown() + * todo: refactor to Timer? */ efitick_t ignitionOnTimeNt = 0; diff --git a/firmware/controllers/algo/event_registry.h b/firmware/controllers/algo/event_registry.h index 52e971c97a..daab70f513 100644 --- a/firmware/controllers/algo/event_registry.h +++ b/firmware/controllers/algo/event_registry.h @@ -119,7 +119,7 @@ public: event_trigger_position_s dwellPosition{}; /** * Sequential number of currently processed spark event - * @see globalSparkIdCounter + * @see engineState.sparkCounter */ int sparkId = 0; /** diff --git a/firmware/controllers/engine_cycle/main_trigger_callback.cpp b/firmware/controllers/engine_cycle/main_trigger_callback.cpp index 85585a38df..47ba951e02 100644 --- a/firmware/controllers/engine_cycle/main_trigger_callback.cpp +++ b/firmware/controllers/engine_cycle/main_trigger_callback.cpp @@ -76,7 +76,10 @@ void endSimultaniousInjection(InjectionEvent *event) { } void InjectorOutputPin::open(efitick_t nowNt) { + // per-output counter for error detection overlappingCounter++; + // global counter for logging + engine->engineState.fuelInjectionCounter++; #if FUEL_MATH_EXTREME_LOGGING if (printFuelDebug) { diff --git a/firmware/controllers/engine_cycle/spark_logic.cpp b/firmware/controllers/engine_cycle/spark_logic.cpp index 4c1d1561ef..da4169b0cd 100644 --- a/firmware/controllers/engine_cycle/spark_logic.cpp +++ b/firmware/controllers/engine_cycle/spark_logic.cpp @@ -309,7 +309,10 @@ static void scheduleSparkEvent(bool limitedSpark, uint32_t trgEventIndex, Igniti return; } - event->sparkId = engine->globalSparkIdCounter++; + /** + * By the way 32-bit value should hold at least 400 hours of events at 6K RPM x 12 events per revolution + */ + event->sparkId = engine->engineState.sparkCounter++; efitick_t chargeTime = 0; @@ -452,7 +455,7 @@ void onTriggerEventSparkLogic(bool limitedSpark, uint32_t trgEventIndex, int rpm // artificial misfire on cylinder #1 for testing purposes // enable artificialMisfire // set_fsio_setting 6 20 - warning(CUSTOM_ARTIFICIAL_MISFIRE, "artificial misfire on cylinder #1 for testing purposes %d", engine->globalSparkIdCounter); + warning(CUSTOM_ARTIFICIAL_MISFIRE, "artificial misfire on cylinder #1 for testing purposes %d", engine->engineState.sparkCounter); continue; } #if EFI_LAUNCH_CONTROL