Custom Trigger Tooth with 1+0 causes endless loop fix #5471

This commit is contained in:
Andrey 2023-08-05 12:59:11 -04:00
parent 511d9f1fab
commit f3a5586e36
3 changed files with 6 additions and 6 deletions

View File

@ -38,6 +38,7 @@ Release template (copy/paste this for new release):
### Fixed
- simulator: sensor mocking UI #5473
- Custom Trigger Tooth with 1+0 causes endless loop #5471
## July 2023 Release "Day 518"

View File

@ -816,15 +816,15 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
auto nextToothIndex = triggerIndexForListeners;
angle_t nextPhase = 0;
int loopAllowance = 1000000;
int loopAllowance = 2 * engineCycleEventCount;
do {
// I don't love this.
nextToothIndex = (nextToothIndex + 1) % engineCycleEventCount;
nextPhase = getTriggerCentral()->triggerFormDetails.eventAngles[nextToothIndex] - tdcPosition();
wrapAngle(nextPhase, "nextEnginePhase", ObdCode::CUSTOM_ERR_6555);
} while (nextPhase == currentEngineDecodedPhase && --loopAllowance > 0);
if (loopAllowance == 0) {
firmwareError(ObdCode::CUSTOM_ERR_TRIGGER_ZERO, "handleShaftSignal endless loop");
if (nextPhase != 0 && loopAllowance == 0) {
firmwareError(ObdCode::CUSTOM_ERR_TRIGGER_ZERO, "handleShaftSignal unexpected loop end");
}
float expectNextPhase = nextPhase + tdcPosition();

View File

@ -8,11 +8,10 @@ TEST(trigger, twoStrokeSingleToothAsSkippedWheel) {
engineConfiguration->trigger.customSkippedToothCount = 0;
eth.setTriggerType(trigger_type_e::TT_TOOTHED_WHEEL);
EXPECT_FATAL_ERROR(eth.smartFireTriggerEvents2(/*count*/20, /*delay*/ 40));
// todo ASSERT_EQ(750, Sensor::getOrZero(SensorType::Rpm));
eth.smartFireTriggerEvents2(/*count*/20, /*delay*/ 40);
ASSERT_EQ(750, Sensor::getOrZero(SensorType::Rpm));
}
TEST(trigger, twoStrokeSingleToothTrigger) {
EngineTestHelper eth(engine_type_e::TEST_CRANK_ENGINE);
setTwoStrokeOperationMode();