From 10cdf76a6ae80f1322a088e1d355628e7f6d80d5 Mon Sep 17 00:00:00 2001 From: rusefi Date: Fri, 3 Mar 2017 21:49:55 -0500 Subject: [PATCH] improving debug logging --- firmware/controllers/trigger/trigger_decoder.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 02b4a8cb39..57ea0d0de9 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -189,9 +189,9 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no // scheduleMsg(&logger, "from %f to %f %d %d", triggerConfig->syncRatioFrom, triggerConfig->syncRatioTo, currentDuration, shaftPositionState->toothed_previous_duration); // scheduleMsg(&logger, "ratio %f", 1.0 * currentDuration/ shaftPositionState->toothed_previous_duration); #else - if (toothed_previous_duration != 0) { -// printf("ratio %f: cur=%d pref=%d\r\n", 1.0 * currentDuration / shaftPositionState->toothed_previous_duration, -// currentDuration, shaftPositionState->toothed_previous_duration); + if (printTriggerDebug) { + printf("ratio %f: current=%d previous=%d\r\n", 1.0 * currentDuration / toothed_previous_duration, + currentDuration, toothed_previous_duration); } #endif @@ -237,6 +237,16 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no * in case of noise the counter could be above the expected number of events */ int d = engineConfiguration->useOnlyRisingEdgeForTrigger ? 2 : 1; + +#if EFI_UNIT_TEST || defined(__DOXYGEN__) + if (printTriggerDebug) { + printf("sync=%d index=%d size=%d\r\n", + shaft_is_synchronized, + currentCycle.current_index, + TRIGGER_SHAPE(size)); + } +#endif + isSynchronizationPoint = !shaft_is_synchronized || (currentCycle.current_index >= TRIGGER_SHAPE(size) - d); }