From dd0a83196488322066f43a3dd6533c6e7e29b1c8 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Thu, 24 Sep 2015 22:02:47 -0400 Subject: [PATCH] auto-sync --- firmware/controllers/trigger/trigger_central.cpp | 8 +------- firmware/controllers/trigger/trigger_decoder.cpp | 8 ++++++++ firmware/controllers/trigger/trigger_decoder.h | 1 + java_console/autotest/src/com/rusefi/AutoTest.java | 8 ++++++++ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 91868958cc..19daee0f1b 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -132,9 +132,6 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal DECLARE_ENGINE_PAR nowNt = getTimeNowNt(); - efiAssertVoid(engine->engineConfiguration!=NULL, "engineConfiguration"); - efiAssertVoid(engine->engineConfiguration2!=NULL, "engineConfiguration2"); - engine->onTriggerEvent(nowNt); #if EFI_HISTOGRAMS && EFI_PROD_CODE @@ -178,10 +175,7 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal DECLARE_ENGINE_PAR return; } - if (triggerState.currentCycle.current_index >= TRIGGER_SHAPE(size)) { - warning(OBD_PCM_Processor_Fault, "unexpected eventIndex=%d while size %d", triggerState.currentCycle.current_index, TRIGGER_SHAPE(size)); - } else { - + if (triggerState.isValidIndex(PASS_ENGINE_PARAMETER_F)) { /** * Here we invoke all the listeners - the main engine control logic is inside these listeners */ diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index b45e89a1a2..1712194388 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -67,6 +67,10 @@ bool_t isTriggerDecoderError(void) { return errorDetection.sum(6) > 4; } +bool_t TriggerState::isValidIndex(DECLARE_ENGINE_PARAMETER_F) { + return currentCycle.current_index < TRIGGER_SHAPE(size); +} + float TriggerState::getTriggerDutyCycle(int index) { float time = prevTotalTime[index]; @@ -276,6 +280,10 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no toothed_previous_duration = currentDuration; toothed_previous_time = nowNt; } + if (!isValidIndex(PASS_ENGINE_PARAMETER_F)) { + warning(OBD_PCM_Processor_Fault, "unexpected eventIndex=%d while size %d", currentCycle.current_index, TRIGGER_SHAPE(size)); + } + if (boardConfiguration->sensorChartMode == SC_RPM_ACCEL || boardConfiguration->sensorChartMode == SC_DETAILED_RPM) { angle_t currentAngle = TRIGGER_SHAPE(eventAngles[currentCycle.current_index]); // todo: make this '90' depend on cylinder count? diff --git a/firmware/controllers/trigger/trigger_decoder.h b/firmware/controllers/trigger/trigger_decoder.h index ba7c56e3ab..3e1b7f81ef 100644 --- a/firmware/controllers/trigger/trigger_decoder.h +++ b/firmware/controllers/trigger/trigger_decoder.h @@ -53,6 +53,7 @@ public: efitime_t getStartOfRevolutionIndex(); void decodeTriggerEvent(trigger_event_e const signal, efitime_t nowUs DECLARE_ENGINE_PARAMETER_S); + bool_t isValidIndex(DECLARE_ENGINE_PARAMETER_F); float getTriggerDutyCycle(int index); TriggerStateCallback cycleCallback; diff --git a/java_console/autotest/src/com/rusefi/AutoTest.java b/java_console/autotest/src/com/rusefi/AutoTest.java index 1769f6496c..ef75b2e899 100644 --- a/java_console/autotest/src/com/rusefi/AutoTest.java +++ b/java_console/autotest/src/com/rusefi/AutoTest.java @@ -143,6 +143,14 @@ public class AutoTest { assertWave(true, msg, chart, EngineChart.INJECTOR_2, 0.1553333333333329, 0.01, 0.1, x + 180); assertWave(true, msg, chart, EngineChart.INJECTOR_3, 0.1553333333333329, 0.01, 0.1, x + 540); assertWave(true, msg, chart, EngineChart.INJECTOR_4, 0.1553333333333329, 0.01, 0.1, x); + + sendCommand("enable trigger_only_front"); + chart = nextChart(); + x = 124.12; + assertWave(true, msg, chart, EngineChart.INJECTOR_1, 0.1553333333333329, 0.02, 0.1, x + 360); + assertWave(true, msg, chart, EngineChart.INJECTOR_2, 0.1553333333333329, 0.02, 0.1, x + 180); + assertWave(true, msg, chart, EngineChart.INJECTOR_3, 0.1553333333333329, 0.02, 0.1, x + 540); + assertWave(true, msg, chart, EngineChart.INJECTOR_4, 0.1553333333333329, 0.02, 0.1, x); } private static void testMazdaProtege() {