Custom Trigger Tooth with 1+0 causes endless loop fix #5471
This commit is contained in:
parent
511d9f1fab
commit
f3a5586e36
|
@ -38,6 +38,7 @@ Release template (copy/paste this for new release):
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- simulator: sensor mocking UI #5473
|
- simulator: sensor mocking UI #5473
|
||||||
|
- Custom Trigger Tooth with 1+0 causes endless loop #5471
|
||||||
|
|
||||||
## July 2023 Release "Day 518"
|
## July 2023 Release "Day 518"
|
||||||
|
|
||||||
|
|
|
@ -816,15 +816,15 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
|
||||||
auto nextToothIndex = triggerIndexForListeners;
|
auto nextToothIndex = triggerIndexForListeners;
|
||||||
angle_t nextPhase = 0;
|
angle_t nextPhase = 0;
|
||||||
|
|
||||||
int loopAllowance = 1000000;
|
int loopAllowance = 2 * engineCycleEventCount;
|
||||||
do {
|
do {
|
||||||
// I don't love this.
|
// I don't love this.
|
||||||
nextToothIndex = (nextToothIndex + 1) % engineCycleEventCount;
|
nextToothIndex = (nextToothIndex + 1) % engineCycleEventCount;
|
||||||
nextPhase = getTriggerCentral()->triggerFormDetails.eventAngles[nextToothIndex] - tdcPosition();
|
nextPhase = getTriggerCentral()->triggerFormDetails.eventAngles[nextToothIndex] - tdcPosition();
|
||||||
wrapAngle(nextPhase, "nextEnginePhase", ObdCode::CUSTOM_ERR_6555);
|
wrapAngle(nextPhase, "nextEnginePhase", ObdCode::CUSTOM_ERR_6555);
|
||||||
} while (nextPhase == currentEngineDecodedPhase && --loopAllowance > 0);
|
} while (nextPhase == currentEngineDecodedPhase && --loopAllowance > 0);
|
||||||
if (loopAllowance == 0) {
|
if (nextPhase != 0 && loopAllowance == 0) {
|
||||||
firmwareError(ObdCode::CUSTOM_ERR_TRIGGER_ZERO, "handleShaftSignal endless loop");
|
firmwareError(ObdCode::CUSTOM_ERR_TRIGGER_ZERO, "handleShaftSignal unexpected loop end");
|
||||||
}
|
}
|
||||||
|
|
||||||
float expectNextPhase = nextPhase + tdcPosition();
|
float expectNextPhase = nextPhase + tdcPosition();
|
||||||
|
|
|
@ -8,11 +8,10 @@ TEST(trigger, twoStrokeSingleToothAsSkippedWheel) {
|
||||||
engineConfiguration->trigger.customSkippedToothCount = 0;
|
engineConfiguration->trigger.customSkippedToothCount = 0;
|
||||||
eth.setTriggerType(trigger_type_e::TT_TOOTHED_WHEEL);
|
eth.setTriggerType(trigger_type_e::TT_TOOTHED_WHEEL);
|
||||||
|
|
||||||
EXPECT_FATAL_ERROR(eth.smartFireTriggerEvents2(/*count*/20, /*delay*/ 40));
|
eth.smartFireTriggerEvents2(/*count*/20, /*delay*/ 40);
|
||||||
// todo ASSERT_EQ(750, Sensor::getOrZero(SensorType::Rpm));
|
ASSERT_EQ(750, Sensor::getOrZero(SensorType::Rpm));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(trigger, twoStrokeSingleToothTrigger) {
|
TEST(trigger, twoStrokeSingleToothTrigger) {
|
||||||
EngineTestHelper eth(engine_type_e::TEST_CRANK_ENGINE);
|
EngineTestHelper eth(engine_type_e::TEST_CRANK_ENGINE);
|
||||||
setTwoStrokeOperationMode();
|
setTwoStrokeOperationMode();
|
||||||
|
|
Loading…
Reference in New Issue