diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index edbed838a6..a958997437 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -216,7 +216,9 @@ static void triggerInfo(Engine *engine) { scheduleMsg(&logger, "expected duty #0=%f/#1=%f", engineConfiguration2->triggerShape.dutyCycle[0], engineConfiguration2->triggerShape.dutyCycle[1]); - scheduleMsg(&logger, "isError %d", isTriggerDecoderError()); + scheduleMsg(&logger, "isError %d, total errors=%d/total revolutions=%d", isTriggerDecoderError(), + triggerCentral.triggerState.totalTriggerErrorCounter, + triggerCentral.triggerState.getTotalRevolutionCounter()); #endif diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index b50aefc5cc..78865238a7 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -43,7 +43,6 @@ bool printGapRatio = false; Logging logger; #endif - /** * @return TRUE is something is wrong with trigger decoding */ @@ -98,7 +97,6 @@ static trigger_value_e eventType[6] = { TV_LOW, TV_HIGH, TV_LOW, TV_HIGH, TV_LOW #define getCurrentGapDuration(nowUs) \ (isFirstEvent ? 0 : (nowUs) - toothed_previous_time) - /** * @brief Trigger decoding happens here * This method changes the state of trigger_state_s data structure according to the trigger event @@ -152,6 +150,10 @@ void TriggerState::decodeTriggerEvent(trigger_shape_s const*triggerShape, trigge || eventCount[1] != triggerShape->expectedEventCount[1] || eventCount[2] != triggerShape->expectedEventCount[2]; + if (isDecodingError) { + totalTriggerErrorCounter++; + } + errorDetection.add(isDecodingError); if (isTriggerDecoderError()) { diff --git a/firmware/controllers/trigger/trigger_decoder.h b/firmware/controllers/trigger/trigger_decoder.h index d9cfe1ebf8..4883679121 100644 --- a/firmware/controllers/trigger/trigger_decoder.h +++ b/firmware/controllers/trigger/trigger_decoder.h @@ -47,6 +47,7 @@ public: */ uint32_t prevTotalTime[PWM_PHASE_MAX_WAVE_PER_PWM]; int expectedTotalTime[PWM_PHASE_MAX_WAVE_PER_PWM]; + uint32_t totalTriggerErrorCounter; private: void clear(); diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index 90025d6fdf..f22ff705ab 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -118,6 +118,7 @@ TriggerState::TriggerState() { toothed_previous_time = 0; toothed_previous_duration = 0; totalRevolutionCounter = 0; + totalTriggerErrorCounter = 0; clear(); memset(expectedTotalTime, 0, sizeof(expectedTotalTime)); totalEventCountBase = 0;