diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 1b5a1c377a..368952ad1c 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -284,6 +284,7 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index) { TriggerState *vvtState = &tc->vvtState[bankIndex][camIndex]; vvtState->decodeTriggerEvent( + "vvt", tc->vvtShape[camIndex], nullptr, nullptr, @@ -617,7 +618,9 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta /** * This invocation changes the state of triggerState */ - triggerState.decodeTriggerEvent(triggerShape, + triggerState.decodeTriggerEvent( + "trigger", + triggerShape, nullptr, engine, engine->primaryTriggerConfiguration, diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 724cb20fb7..53b1a8c301 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -477,6 +477,7 @@ void TriggerState::onShaftSynchronization( * @param nowNt current time */ void TriggerState::decodeTriggerEvent( + const char *msg, const TriggerWaveform& triggerShape, const TriggerStateCallback triggerCycleCallback, TriggerStateListener* triggerStateListener, @@ -513,7 +514,7 @@ void TriggerState::decodeTriggerEvent( currentCycle.eventCount[triggerWheel]++; if (toothed_previous_time > nowNt) { - firmwareError(CUSTOM_OBD_93, "toothed_previous_time after nowNt %d %d", toothed_previous_time, nowNt); + firmwareError(CUSTOM_OBD_93, "[%s] toothed_previous_time after nowNt prev=%d now=%d", msg, toothed_previous_time, nowNt); } efitick_t currentDurationLong = isFirstEvent ? 0 : nowNt - toothed_previous_time; diff --git a/firmware/controllers/trigger/trigger_decoder.h b/firmware/controllers/trigger/trigger_decoder.h index 35a8ce7396..9dbccc9a6b 100644 --- a/firmware/controllers/trigger/trigger_decoder.h +++ b/firmware/controllers/trigger/trigger_decoder.h @@ -91,6 +91,7 @@ public: efitime_t getTotalEventCounter() const; void decodeTriggerEvent( + const char *msg, const TriggerWaveform& triggerShape, const TriggerStateCallback triggerCycleCallback, TriggerStateListener* triggerStateListener, diff --git a/firmware/controllers/trigger/trigger_simulator.cpp b/firmware/controllers/trigger/trigger_simulator.cpp index 2f4963d5e6..63345d4555 100644 --- a/firmware/controllers/trigger/trigger_simulator.cpp +++ b/firmware/controllers/trigger/trigger_simulator.cpp @@ -80,7 +80,9 @@ void TriggerStimulatorHelper::feedSimulatedEvent( pin_state_t currentValue = multiChannelStateSequence.getChannelState(/*phaseIndex*/i, stateIndex); trigger_event_e event = (currentValue ? riseEvents : fallEvents)[i]; if (isUsefulSignal(event, triggerConfiguration)) { - state.decodeTriggerEvent(shape, + state.decodeTriggerEvent( + "sim", + shape, triggerCycleCallback, /* override */ nullptr, triggerConfiguration, diff --git a/unit_tests/tests/trigger/test_trigger_decoder.cpp b/unit_tests/tests/trigger/test_trigger_decoder.cpp index d87746d5cf..0b8333a6fd 100644 --- a/unit_tests/tests/trigger/test_trigger_decoder.cpp +++ b/unit_tests/tests/trigger/test_trigger_decoder.cpp @@ -120,28 +120,28 @@ TEST(trigger, testSomethingWeird) { ASSERT_FALSE(sta->shaft_is_synchronized) << "shaft_is_synchronized"; int r = 10; - sta->decodeTriggerEvent(engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_FALLING, r); + sta->decodeTriggerEvent("t", engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_FALLING, r); ASSERT_FALSE(sta->shaft_is_synchronized) << "shaft_is_synchronized"; // still no synchronization - sta->decodeTriggerEvent(engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_RISING, ++r); + sta->decodeTriggerEvent("t", engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_RISING, ++r); ASSERT_TRUE(sta->shaft_is_synchronized); // first signal rise synchronize ASSERT_EQ(0, sta->getCurrentIndex()); - sta->decodeTriggerEvent(engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_FALLING, r++); + sta->decodeTriggerEvent("t", engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_FALLING, r++); ASSERT_EQ(1, sta->getCurrentIndex()); for (int i = 2; i < 10;) { - sta->decodeTriggerEvent(engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_RISING, r++); + sta->decodeTriggerEvent("t", engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_RISING, r++); assertEqualsM("even", i++, sta->getCurrentIndex()); - sta->decodeTriggerEvent(engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_FALLING, r++); + sta->decodeTriggerEvent("t", engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_FALLING, r++); assertEqualsM("odd", i++, sta->getCurrentIndex()); } - sta->decodeTriggerEvent(engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_RISING, r++); + sta->decodeTriggerEvent("test", engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_RISING, r++); ASSERT_EQ(10, sta->getCurrentIndex()); - sta->decodeTriggerEvent(engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_FALLING, r++); + sta->decodeTriggerEvent("test", engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_FALLING, r++); ASSERT_EQ(11, sta->getCurrentIndex()); - sta->decodeTriggerEvent(engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_RISING, r++); + sta->decodeTriggerEvent("test", engine->triggerCentral.triggerShape, nullptr, /* override */ nullptr, triggerConfiguration, SHAFT_PRIMARY_RISING, r++); ASSERT_EQ(0, sta->getCurrentIndex()); // new revolution }