reducing code duplication

This commit is contained in:
rusefi 2020-01-26 06:35:51 -05:00
parent 98c6198f1d
commit 35e60bf607
1 changed files with 8 additions and 6 deletions

View File

@ -337,16 +337,18 @@ void TriggerState::onSynchronizationLost(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
} }
bool TriggerState::validateEventCounters(TriggerWaveform *triggerShape) const { bool TriggerState::validateEventCounters(TriggerWaveform *triggerShape) const {
bool isDecodingError = currentCycle.eventCount[0] != triggerShape->expectedEventCount[0] bool isDecodingError = false;
|| currentCycle.eventCount[1] != triggerShape->expectedEventCount[1] for (int i = 0;i < GAP_TRACKING_LENGTH;i++) {
|| currentCycle.eventCount[2] != triggerShape->expectedEventCount[2]; isDecodingError |= currentCycle.eventCount[i] != triggerShape->expectedEventCount[i];
}
#if EFI_UNIT_TEST #if EFI_UNIT_TEST
printf("sync point: isDecodingError=%d\r\n", isDecodingError); printf("sync point: isDecodingError=%d\r\n", isDecodingError);
if (isDecodingError) { if (isDecodingError) {
printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[0], triggerShape->expectedEventCount[0]); for (int i = 0;i < GAP_TRACKING_LENGTH;i++) {
printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[1], triggerShape->expectedEventCount[1]); printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[i], triggerShape->expectedEventCount[i]);
printf("count: cur=%d exp=%d\r\n", currentCycle.eventCount[2], triggerShape->expectedEventCount[2]); }
} }
#endif /* EFI_UNIT_TEST */ #endif /* EFI_UNIT_TEST */