From 03d2aae6810b7b20ef1a6af0d90d3e59758d6068 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 26 Jan 2020 06:35:51 -0500 Subject: [PATCH] reducing code duplication --- firmware/controllers/trigger/trigger_decoder.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index c6ffb037c9..e947f52637 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -337,16 +337,18 @@ void TriggerState::onSynchronizationLost(DECLARE_ENGINE_PARAMETER_SIGNATURE) { } bool TriggerState::validateEventCounters(TriggerWaveform *triggerShape) const { - bool isDecodingError = currentCycle.eventCount[0] != triggerShape->expectedEventCount[0] - || currentCycle.eventCount[1] != triggerShape->expectedEventCount[1] - || currentCycle.eventCount[2] != triggerShape->expectedEventCount[2]; + bool isDecodingError = false; + for (int i = 0;i < GAP_TRACKING_LENGTH;i++) { + isDecodingError |= currentCycle.eventCount[i] != triggerShape->expectedEventCount[i]; + } + #if EFI_UNIT_TEST printf("sync point: isDecodingError=%d\r\n", isDecodingError); if (isDecodingError) { - printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[0], triggerShape->expectedEventCount[0]); - printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[1], triggerShape->expectedEventCount[1]); - printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[2], triggerShape->expectedEventCount[2]); + for (int i = 0;i < GAP_TRACKING_LENGTH;i++) { + printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[i], triggerShape->expectedEventCount[i]); + } } #endif /* EFI_UNIT_TEST */