error code into angle validation

This commit is contained in:
rusefi 2018-07-23 21:03:20 -04:00
parent 806ad1abf3
commit 74bd1d7e10
7 changed files with 28 additions and 16 deletions

View File

@ -143,7 +143,7 @@ angle_t getAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAMETER_SUFFIX) {
angle_t angle;
if (ENGINE(rpmCalculator).isCranking(PASS_ENGINE_PARAMETER_SIGNATURE)) {
angle = getCrankingAdvance(rpm, engineLoad PASS_ENGINE_PARAMETER_SUFFIX);
assertAngleRange(angle, "crAngle");
assertAngleRange(angle, "crAngle", CUSTOM_ERR_6541);
efiAssert(!cisnan(angle), "crAngleN", 0);
if (CONFIG(useAdvanceCorrectionsForCranking))
angle += getAdvanceCorrections(rpm PASS_ENGINE_PARAMETER_SUFFIX);

View File

@ -1908,6 +1908,18 @@ typedef enum {
CUSTOM_ERR_6548 = 6548,
CUSTOM_ERR_6549 = 6549,
CUSTOM_ERR_6550 = 6550,
CUSTOM_ERR_6551 = 6551,
CUSTOM_ERR_6552 = 6552,
CUSTOM_ERR_6553 = 6553,
CUSTOM_ERR_6554 = 6554,
CUSTOM_ERR_6555 = 6555,
CUSTOM_ERR_6556 = 6556,
CUSTOM_ERR_6557 = 6557,
CUSTOM_ERR_6558 = 6557,
CUSTOM_ERR_6559 = 6559,
// this is needed for proper enum size, this matters for malfunction_central
Internal_ForceMyEnumIntSize_cranking_obd_code = ENUM_32_BITS,
} obd_code_e;

View File

@ -733,5 +733,5 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0)
return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 20180617;
return 20180721;
}

View File

@ -131,7 +131,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i DECLARE_ENGINE_PARAMETER_SUFF
efiAssert(!cisnan(fuelMs), "NaN fuelMs", false);
angle_t injectionDuration = MS2US(fuelMs) / oneDegreeUs;
efiAssert(!cisnan(injectionDuration), "NaN injectionDuration", false);
assertAngleRange(injectionDuration, "injectionDuration_r");
assertAngleRange(injectionDuration, "injectionDuration_r", CUSTOM_ERR_6542);
floatus_t injectionOffset = ENGINE(engineState.injectionOffset);
if (cisnan(injectionOffset)) {
// injection offset map not ready - we are not ready to schedule fuel events
@ -139,7 +139,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i DECLARE_ENGINE_PARAMETER_SUFF
}
angle_t baseAngle = injectionOffset - injectionDuration;
efiAssert(!cisnan(baseAngle), "NaN baseAngle", false);
assertAngleRange(baseAngle, "baseAngle_r");
assertAngleRange(baseAngle, "baseAngle_r", CUSTOM_ERR_6554);
int injectorIndex;
@ -159,7 +159,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i DECLARE_ENGINE_PARAMETER_SUFF
bool isSimultanious = mode == IM_SIMULTANEOUS;
assertAngleRange(baseAngle, "addFbaseAngle");
assertAngleRange(baseAngle, "addFbaseAngle", CUSTOM_ERR_6543);
int cylindersCount = CONFIG(specs.cylindersCount);
if (cylindersCount < 1) {
@ -206,7 +206,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i DECLARE_ENGINE_PARAMETER_SUFF
}
efiAssert(!cisnan(angle), "findAngle#3", false);
assertAngleRange(angle, "findAngle#a33");
assertAngleRange(angle, "findAngle#a33", CUSTOM_ERR_6544);
TRIGGER_SHAPE(findTriggerPosition(&ev->injectionStart, angle PASS_ENGINE_PARAMETER_SUFFIX));
#if EFI_UNIT_TEST || defined(__DOXYGEN__)
printf("registerInjectionEvent angle=%.2f trgIndex=%d inj %d\r\n", angle, ev->injectionStart.eventIndex, injectorIndex);
@ -293,13 +293,13 @@ int TriggerShape::findAngleIndex(float target DECLARE_ENGINE_PARAMETER_SUFFIX) {
void TriggerShape::findTriggerPosition(event_trigger_position_s *position, angle_t angleOffset DECLARE_ENGINE_PARAMETER_SUFFIX) {
efiAssertVoid(!cisnan(angleOffset), "findAngle#1");
assertAngleRange(angleOffset, "findAngle#a1");
assertAngleRange(angleOffset, "findAngle#a1", CUSTOM_ERR_6545);
efiAssertVoid(!cisnan(ENGINE(triggerCentral.triggerShape.tdcPosition)), "tdcPos#1")
assertAngleRange(ENGINE(triggerCentral.triggerShape.tdcPosition), "tdcPos#a1");
assertAngleRange(ENGINE(triggerCentral.triggerShape.tdcPosition), "tdcPos#a1", CUSTOM_ERR_6546);
efiAssertVoid(!cisnan(CONFIG(globalTriggerAngleOffset)), "tdcPos#2")
assertAngleRange(CONFIG(globalTriggerAngleOffset), "tdcPos#a2");
assertAngleRange(CONFIG(globalTriggerAngleOffset), "tdcPos#a2", CUSTOM_ERR_6547);
// convert engine cycle angle into trigger cycle angle
angleOffset += tdcPosition();

View File

@ -20,9 +20,9 @@ void setAlgorithm(engine_load_mode_e algo DECLARE_ENGINE_PARAMETER_SUFFIX);
#if EFI_ENABLE_ASSERTS
#define assertAngleRange(angle, msg) if(angle > 10000000 || angle < -10000000) { firmwareError(ERROR_ANGLE_RANGE, "angle range %s %.2f", msg, angle);angle = 0;}
#define assertAngleRange(angle, msg, code) if(angle > 10000000 || angle < -10000000) { firmwareError(code, "angle range %s %.2f", msg, angle);angle = 0;}
#else
#define assertAngleRange(angle, msg) {}
#define assertAngleRange(angle, msg, code) {}
#endif
void setFlatInjectorLag(float value DECLARE_ENGINE_PARAMETER_SUFFIX);
@ -38,7 +38,7 @@ void setFlatInjectorLag(float value DECLARE_ENGINE_PARAMETER_SUFFIX);
firmwareError(CUSTOM_ERR_ANGLE, "angle NaN %s", msg); \
angle = 0; \
} \
assertAngleRange(angle, msg); \
assertAngleRange(angle, msg, CUSTOM_ERR_6548); \
float engineCycleDurationLocalCopy = ENGINE(engineCycle); \
/* todo: split this method into 'fixAngleUp' and 'fixAngleDown'*/ \
/* as a performance optimization?*/ \

View File

@ -174,7 +174,7 @@ static ALWAYS_INLINE void handleSparkEvent(bool limitedSpark, uint32_t trgEventI
*/
float advance = iEvent->advance;
efiAssertVoid(!cisnan(advance), "findAngle#4");
assertAngleRange(advance, "findAngle#a5");
assertAngleRange(advance, "findAngle#a5", CUSTOM_ERR_6549);
TRIGGER_SHAPE(findTriggerPosition(&iEvent->sparkPosition, advance PASS_ENGINE_PARAMETER_SUFFIX));
#if EFI_UNIT_TEST || defined(__DOXYGEN__)
@ -249,7 +249,7 @@ void prepareIgnitionSchedule(IgnitionEvent *event DECLARE_ENGINE_PARAMETER_SUFFI
angle_t a = localAdvance - dwellAngle;
efiAssertVoid(!cisnan(a), "findAngle#5");
assertAngleRange(a, "findAngle#a6");
assertAngleRange(a, "findAngle#a6", CUSTOM_ERR_6550);
TRIGGER_SHAPE(findTriggerPosition(&event->dwellPosition, a PASS_ENGINE_PARAMETER_SUFFIX));
#if FUEL_MATH_EXTREME_LOGGING || defined(__DOXYGEN__)

View File

@ -64,7 +64,7 @@ void TriggerShape::calculateTriggerSynchPoint(TriggerState *state DECLARE_ENGINE
}
float firstAngle = getAngle(triggerShapeSynchPointIndex);
assertAngleRange(triggerShapeSynchPointIndex, "firstAngle");
assertAngleRange(triggerShapeSynchPointIndex, "firstAngle", CUSTOM_ERR_6551);
int frontOnlyIndex = 0;
@ -76,7 +76,7 @@ void TriggerShape::calculateTriggerSynchPoint(TriggerState *state DECLARE_ENGINE
eventAngles[1] = 0;
frontOnlyIndexes[0] = 0;
} else {
assertAngleRange(triggerShapeSynchPointIndex, "triggerShapeSynchPointIndex");
assertAngleRange(triggerShapeSynchPointIndex, "triggerShapeSynchPointIndex", CUSTOM_ERR_6552);
int triggerDefinitionCoordinate = (triggerShapeSynchPointIndex + eventIndex) % engine->engineCycleEventCount;
efiAssertVoid(engine->engineCycleEventCount != 0, "zero engineCycleEventCount");
int triggerDefinitionIndex = triggerDefinitionCoordinate >= size ? triggerDefinitionCoordinate - size : triggerDefinitionCoordinate;