From 99e74635ef64ce050389814079b7aae414046b38 Mon Sep 17 00:00:00 2001 From: rusefi Date: Wed, 25 Jul 2018 23:30:00 -0400 Subject: [PATCH] step towards more unique codes --- firmware/controllers/algo/advance_map.cpp | 6 ++--- firmware/controllers/algo/fuel_math.cpp | 22 +++++++++---------- firmware/controllers/core/fl_stack.h | 4 ++-- firmware/controllers/core/fsio_core.cpp | 6 ++--- firmware/controllers/core/fsio_impl.cpp | 2 +- firmware/controllers/core/interpolation.cpp | 10 ++++----- firmware/controllers/core/table_helper.h | 2 +- firmware/controllers/error_handling.h | 4 ++-- firmware/controllers/flash_main.cpp | 2 +- firmware/controllers/math/engine_math.cpp | 18 +++++++-------- firmware/controllers/math/speed_density.cpp | 6 ++--- firmware/controllers/sensors/thermistors.cpp | 6 ++--- firmware/controllers/system/event_queue.cpp | 8 +++---- .../system/pwm_generator_logic.cpp | 2 +- .../controllers/trigger/trigger_decoder.cpp | 6 ++--- .../controllers/trigger/trigger_structure.cpp | 2 +- firmware/hw_layer/pin_repository.cpp | 2 +- firmware/hw_layer/trigger_input.cpp | 4 ++-- firmware/util/efilib.cpp | 2 +- firmware/util/histogram.c | 2 +- 20 files changed, 58 insertions(+), 58 deletions(-) diff --git a/firmware/controllers/algo/advance_map.cpp b/firmware/controllers/algo/advance_map.cpp index efd06d81d1..2add034807 100644 --- a/firmware/controllers/algo/advance_map.cpp +++ b/firmware/controllers/algo/advance_map.cpp @@ -74,7 +74,7 @@ static angle_t getRunningAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAME warning(CUSTOM_NAN_ENGINE_LOAD, "NaN engine load"); return NAN; } - efiAssert(!cisnan(engineLoad), "invalid el", NAN); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(engineLoad), "invalid el", NAN); engine->m.beforeZeroTest = GET_TIMESTAMP(); engine->m.zeroTestTime = GET_TIMESTAMP() - engine->m.beforeZeroTest; @@ -144,12 +144,12 @@ angle_t getAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAMETER_SUFFIX) { if (ENGINE(rpmCalculator).isCranking(PASS_ENGINE_PARAMETER_SIGNATURE)) { angle = getCrankingAdvance(rpm, engineLoad PASS_ENGINE_PARAMETER_SUFFIX); assertAngleRange(angle, "crAngle", CUSTOM_ERR_6541); - efiAssert(!cisnan(angle), "crAngleN", 0); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(angle), "crAngleN", 0); if (CONFIG(useAdvanceCorrectionsForCranking)) angle += getAdvanceCorrections(rpm PASS_ENGINE_PARAMETER_SUFFIX); } else { angle = getRunningAdvance(rpm, engineLoad PASS_ENGINE_PARAMETER_SUFFIX); - efiAssert(!cisnan(angle), "rAngleN", 0); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(angle), "rAngleN", 0); angle += getAdvanceCorrections(rpm PASS_ENGINE_PARAMETER_SUFFIX); } angle -= engineConfiguration->ignitionOffset; diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index 39d783b481..39c2177413 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -76,20 +76,20 @@ float getRealMafFuel(float airSpeed, int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { */ floatms_t getBaseFuel(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { floatms_t tpsAccelEnrich = ENGINE(tpsAccelEnrichment.getTpsEnrichment(PASS_ENGINE_PARAMETER_SIGNATURE)); - efiAssert(!cisnan(tpsAccelEnrich), "NaN tpsAccelEnrich", 0); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(tpsAccelEnrich), "NaN tpsAccelEnrich", 0); ENGINE(engineState.tpsAccelEnrich) = tpsAccelEnrich; floatms_t baseFuel; if (CONFIG(fuelAlgorithm) == LM_SPEED_DENSITY) { baseFuel = getSpeedDensityFuel(PASS_ENGINE_PARAMETER_SIGNATURE); - efiAssert(!cisnan(baseFuel), "NaN sd baseFuel", 0); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(baseFuel), "NaN sd baseFuel", 0); } else if (engineConfiguration->fuelAlgorithm == LM_REAL_MAF) { float maf = getRealMaf(PASS_ENGINE_PARAMETER_SIGNATURE) + engine->engineLoadAccelEnrichment.getEngineLoadEnrichment(PASS_ENGINE_PARAMETER_SIGNATURE); baseFuel = getRealMafFuel(maf, rpm PASS_ENGINE_PARAMETER_SUFFIX); - efiAssert(!cisnan(baseFuel), "NaN rm baseFuel", 0); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(baseFuel), "NaN rm baseFuel", 0); } else { baseFuel = engine->engineState.baseTableFuel; - efiAssert(!cisnan(baseFuel), "NaN bt baseFuel", 0); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(baseFuel), "NaN bt baseFuel", 0); } engine->engineState.baseFuel = baseFuel; @@ -109,7 +109,7 @@ angle_t getInjectionOffset(float rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { firmwareError(CUSTOM_ERR_ASSERT, "inj offset#1 %.2f %.2f", rpm, engineLoad); return 0; } - efiAssert(!cisnan(value), "inj offset#1", 0); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(value), "inj offset#1", 0); angle_t result = value + CONFIG(extraInjectionOffset); fixAngle(result, "inj offset#2", CUSTOM_ERR_6553); return result; @@ -161,11 +161,11 @@ floatms_t getInjectionDuration(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { floatms_t fuelPerCycle; if (isCranking) { fuelPerCycle = getCrankingFuel(PASS_ENGINE_PARAMETER_SIGNATURE); - efiAssert(!cisnan(fuelPerCycle), "NaN cranking fuelPerCycle", 0); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(fuelPerCycle), "NaN cranking fuelPerCycle", 0); } else { floatms_t baseFuel = getBaseFuel(rpm PASS_ENGINE_PARAMETER_SUFFIX); fuelPerCycle = getRunningFuel(baseFuel PASS_ENGINE_PARAMETER_SUFFIX); - efiAssert(!cisnan(fuelPerCycle), "NaN fuelPerCycle", 0); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(fuelPerCycle), "NaN fuelPerCycle", 0); #if EFI_PRINTF_FUEL_DETAILS || defined(__DOXYGEN__) printf("baseFuel=%.2f fuelPerCycle=%.2f \t\n", baseFuel, fuelPerCycle); @@ -194,12 +194,12 @@ floatms_t getRunningFuel(floatms_t baseFuel DECLARE_ENGINE_PARAMETER_SUFFIX) { float iatCorrection = ENGINE(engineState.iatFuelCorrection); float cltCorrection = ENGINE(engineState.cltFuelCorrection); float postCrankingFuelCorrection = ENGINE(engineState.postCrankingFuelCorrection); - efiAssert(!cisnan(iatCorrection), "NaN iatCorrection", 0); - efiAssert(!cisnan(cltCorrection), "NaN cltCorrection", 0); - efiAssert(!cisnan(postCrankingFuelCorrection), "NaN postCrankingFuelCorrection", 0); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(iatCorrection), "NaN iatCorrection", 0); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(cltCorrection), "NaN cltCorrection", 0); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(postCrankingFuelCorrection), "NaN postCrankingFuelCorrection", 0); floatms_t runningFuel = baseFuel * iatCorrection * cltCorrection * postCrankingFuelCorrection + ENGINE(engineState.fuelPidCorrection); - efiAssert(!cisnan(runningFuel), "NaN runningFuel", 0); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(runningFuel), "NaN runningFuel", 0); ENGINE(engineState.runningFuel) = runningFuel; return runningFuel; diff --git a/firmware/controllers/core/fl_stack.h b/firmware/controllers/core/fl_stack.h index 4dc6fa56cd..b0c88e9fb8 100644 --- a/firmware/controllers/core/fl_stack.h +++ b/firmware/controllers/core/fl_stack.h @@ -79,7 +79,7 @@ T FLStack::pop() { */ template T FLStack::get(int index) { - efiAssert(index >= 0 && index < MAXSIZE, "FLget", values[0]); + efiAssert(CUSTOM_ERR_ASSERT, index >= 0 && index < MAXSIZE, "FLget", values[0]); return values[index]; } @@ -120,7 +120,7 @@ void ArrayList::reset(void) { template Type * ArrayList::add(void) { - efiAssert(size < Dimention, "add() too many elements", (Type *)NULL); + efiAssert(CUSTOM_ERR_ASSERT, size < Dimention, "add() too many elements", (Type *)NULL); return &elements[size++]; } diff --git a/firmware/controllers/core/fsio_core.cpp b/firmware/controllers/core/fsio_core.cpp index e37c84e38d..76242509c2 100644 --- a/firmware/controllers/core/fsio_core.cpp +++ b/firmware/controllers/core/fsio_core.cpp @@ -139,7 +139,7 @@ void LECalculator::push(le_action_e action, float value) { */ bool LECalculator::processElement(LEElement *element DECLARE_ENGINE_PARAMETER_SUFFIX) { #if EFI_PROD_CODE || defined(__DOXYGEN__) - efiAssert(getRemainingStack(chThdGetSelfX()) > 64, "FSIO logic", false); + efiAssert(CUSTOM_ERR_ASSERT, getRemainingStack(chThdGetSelfX()) > 64, "FSIO logic", false); #endif switch (element->action) { @@ -314,7 +314,7 @@ float LECalculator::getValue(float selfValue DECLARE_ENGINE_PARAMETER_SUFFIX) { int counter = 0; while (element != NULL) { - efiAssert(counter < 200, "FSIOcount", NAN); // just in case + efiAssert(CUSTOM_ERR_ASSERT, counter < 200, "FSIOcount", NAN); // just in case if (element->action == LE_METHOD_SELF) { push(element->action, selfValue); @@ -379,7 +379,7 @@ const char *getNextToken(const char *line, char *buffer, const int bufferSize) { // no space - the whole remaining line is the token tokenLen = strlen(line); } - efiAssert(tokenLen < bufferSize, "token overflow", NULL); + efiAssert(CUSTOM_ERR_ASSERT, tokenLen < bufferSize, "token overflow", NULL); strncpy(buffer, line, tokenLen); buffer[tokenLen] = 0; line += tokenLen; diff --git a/firmware/controllers/core/fsio_impl.cpp b/firmware/controllers/core/fsio_impl.cpp index 8589233392..a4af2bf05d 100644 --- a/firmware/controllers/core/fsio_impl.cpp +++ b/firmware/controllers/core/fsio_impl.cpp @@ -94,7 +94,7 @@ EXTERN_ENGINE static Logging *logger; float getEngineValue(le_action_e action DECLARE_ENGINE_PARAMETER_SUFFIX) { - efiAssert(engine!=NULL, "getLEValue", NAN); + efiAssert(CUSTOM_ERR_ASSERT, engine!=NULL, "getLEValue", NAN); switch (action) { case LE_METHOD_FAN: return enginePins.fanRelay.getLogicValue(); diff --git a/firmware/controllers/core/interpolation.cpp b/firmware/controllers/core/interpolation.cpp index 3fa9cba3b6..210d6b1a95 100644 --- a/firmware/controllers/core/interpolation.cpp +++ b/firmware/controllers/core/interpolation.cpp @@ -140,15 +140,15 @@ float interpolateClamped(float x1, float y1, float x2, float y2, float x) { * Another implementation, which one is faster? */ int findIndex2(const float array[], unsigned size, float value) { - efiAssert(!cisnan(value), "NaN in findIndex2", 0); - efiAssert(size > 1, "size in findIndex", 0); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(value), "NaN in findIndex2", 0); + efiAssert(CUSTOM_ERR_ASSERT, size > 1, "size in findIndex", 0); // if (size <= 1) // return size && *array <= value ? 0 : -1; signed i = 0; //unsigned b = 1 << int(log(float(size) - 1) / 0.69314718055994530942); unsigned b = size >> 1; // in our case size is always a power of 2 - efiAssert(b + b == size, "Size not power of 2", -1); + efiAssert(CUSTOM_ERR_ASSERT, b + b == size, "Size not power of 2", -1); for (; b; b >>= 1) { unsigned j = i | b; /** @@ -156,7 +156,7 @@ int findIndex2(const float array[], unsigned size, float value) { * "if (j < size && array[j] <= value)" * but in our case size is always power of 2 thus size is always more then j */ - // efiAssert(j < size, "size", 0); + // efiAssert(CUSTOM_ERR_ASSERT, j < size, "size", 0); if (array[j] <= value) i = j; } @@ -199,7 +199,7 @@ int findIndexMsg(const char *msg, const float array[], int size, float value) { #if 0 // that's an assertion to make sure we do not loop here size--; - efiAssert(size > 0, "Unexpected state in binary search", 0); + efiAssert(CUSTOM_ERR_ASSERT, size > 0, "Unexpected state in binary search", 0); #endif // todo: compare current implementation with diff --git a/firmware/controllers/core/table_helper.h b/firmware/controllers/core/table_helper.h index 3d28304a06..054a554764 100644 --- a/firmware/controllers/core/table_helper.h +++ b/firmware/controllers/core/table_helper.h @@ -87,7 +87,7 @@ void Map3D::init(vType table[RPM_BIN_SIZE][L template float Map3D::getValue(float xRpm, float y) { - efiAssert(initialized, "map not initialized", NAN); + efiAssert(CUSTOM_ERR_ASSERT, initialized, "map not initialized", NAN); if (cisnan(y)) { warning(CUSTOM_PARAM_RANGE, "%s: y is NaN", name); return NAN; diff --git a/firmware/controllers/error_handling.h b/firmware/controllers/error_handling.h index d60d1e7194..ac2028d2df 100644 --- a/firmware/controllers/error_handling.h +++ b/firmware/controllers/error_handling.h @@ -55,10 +55,10 @@ int getRusEfiVersion(void); * is stopped. Please use firmwareWarning() instead */ #if EFI_ENABLE_ASSERTS - #define efiAssert(condition, message, result) { if (!(condition)) { firmwareError(CUSTOM_ERR_ASSERT, message); return result; } } + #define efiAssert(code, condition, message, result) { if (!(condition)) { firmwareError(code, message); return result; } } #define efiAssertVoid(code, condition, message) { if (!(condition)) { firmwareError(code, message); return; } } #else /* EFI_ENABLE_ASSERTS */ - #define efiAssert(condition, message, result) { } + #define efiAssert(code, condition, message, result) { } #define efiAssertVoid(code, condition, message) { } #endif /* EFI_ENABLE_ASSERTS */ diff --git a/firmware/controllers/flash_main.cpp b/firmware/controllers/flash_main.cpp index 81abb6dfbf..fcbd42f287 100644 --- a/firmware/controllers/flash_main.cpp +++ b/firmware/controllers/flash_main.cpp @@ -131,7 +131,7 @@ static persisted_configuration_state_e doReadConfiguration(flashaddr_t address, * connectivity so no console output here */ persisted_configuration_state_e readConfiguration(Logging * logger) { - efiAssert(getRemainingStack(chThdGetSelfX()) > 256, "read f", PC_ERROR); + efiAssert(CUSTOM_ERR_ASSERT, getRemainingStack(chThdGetSelfX()) > 256, "read f", PC_ERROR); persisted_configuration_state_e result = doReadConfiguration(FLASH_ADDR, logger); if (result != PC_OK) { printMsg(logger, "Reading second configuration copy"); diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index 7a0946efb7..2898e3133d 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -57,8 +57,8 @@ floatms_t getCrankshaftRevolutionTimeMs(int rpm) { * */ float getEngineLoadT(DECLARE_ENGINE_PARAMETER_SIGNATURE) { - efiAssert(engine!=NULL, "engine 2NULL", NAN); - efiAssert(engineConfiguration!=NULL, "engineConfiguration 2NULL", NAN); + efiAssert(CUSTOM_ERR_ASSERT, engine!=NULL, "engine 2NULL", NAN); + efiAssert(CUSTOM_ERR_ASSERT, engineConfiguration!=NULL, "engineConfiguration 2NULL", NAN); switch (engineConfiguration->fuelAlgorithm) { case LM_PLAIN_MAF: if (!hasMafSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) { @@ -111,7 +111,7 @@ void FuelSchedule::clear() { * @returns false in case of error, true if success */ bool FuelSchedule::addFuelEventsForCylinder(int i DECLARE_ENGINE_PARAMETER_SUFFIX) { - efiAssert(engine!=NULL, "engine is NULL", false); + efiAssert(CUSTOM_ERR_ASSERT, engine!=NULL, "engine is NULL", false); floatus_t oneDegreeUs = ENGINE(rpmCalculator.oneDegreeUs); // local copy if (cisnan(oneDegreeUs)) { @@ -128,9 +128,9 @@ bool FuelSchedule::addFuelEventsForCylinder(int i DECLARE_ENGINE_PARAMETER_SUFF * engineState.injectionOffset is calculated from the same utility timer should we more that logic here? */ floatms_t fuelMs = ENGINE(injectionDuration); - efiAssert(!cisnan(fuelMs), "NaN fuelMs", false); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(fuelMs), "NaN fuelMs", false); angle_t injectionDuration = MS2US(fuelMs) / oneDegreeUs; - efiAssert(!cisnan(injectionDuration), "NaN injectionDuration", false); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(injectionDuration), "NaN injectionDuration", false); assertAngleRange(injectionDuration, "injectionDuration_r", CUSTOM_ERR_6542); floatus_t injectionOffset = ENGINE(engineState.injectionOffset); if (cisnan(injectionOffset)) { @@ -138,7 +138,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i DECLARE_ENGINE_PARAMETER_SUFF return false; } angle_t baseAngle = injectionOffset - injectionDuration; - efiAssert(!cisnan(baseAngle), "NaN baseAngle", false); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(baseAngle), "NaN baseAngle", false); assertAngleRange(baseAngle, "baseAngle_r", CUSTOM_ERR_6554); int injectorIndex; @@ -205,7 +205,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i DECLARE_ENGINE_PARAMETER_SUFF return false; } - efiAssert(!cisnan(angle), "findAngle#3", false); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(angle), "findAngle#3", false); assertAngleRange(angle, "findAngle#a33", CUSTOM_ERR_6544); TRIGGER_SHAPE(findTriggerPosition(&ev->injectionStart, angle PASS_ENGINE_PARAMETER_SUFFIX)); #if EFI_UNIT_TEST || defined(__DOXYGEN__) @@ -247,7 +247,7 @@ floatms_t getSparkDwell(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { if (ENGINE(rpmCalculator).isCranking(PASS_ENGINE_PARAMETER_SIGNATURE)) { dwellMs = getCrankingSparkDwell(PASS_ENGINE_PARAMETER_SIGNATURE); } else { - efiAssert(!cisnan(rpm), "invalid rpm", NAN); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(rpm), "invalid rpm", NAN); dwellMs = interpolate2d("dwell", rpm, engineConfiguration->sparkDwellRpmBins, engineConfiguration->sparkDwellValues, DWELL_CURVE_SIZE); } @@ -266,7 +266,7 @@ floatms_t getSparkDwell(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { int TriggerShape::findAngleIndex(float target DECLARE_ENGINE_PARAMETER_SUFFIX) { int engineCycleEventCount = TRIGGER_SHAPE(getLength()); - efiAssert(engineCycleEventCount > 0, "engineCycleEventCount", 0); + efiAssert(CUSTOM_ERR_ASSERT, engineCycleEventCount > 0, "engineCycleEventCount", 0); uint32_t left = 0; uint32_t right = engineCycleEventCount - 1; diff --git a/firmware/controllers/math/speed_density.cpp b/firmware/controllers/math/speed_density.cpp index bf7ceeb41c..a951fd8c56 100644 --- a/firmware/controllers/math/speed_density.cpp +++ b/firmware/controllers/math/speed_density.cpp @@ -103,13 +103,13 @@ floatms_t getSpeedDensityFuel(DECLARE_ENGINE_PARAMETER_SIGNATURE) { return 0; } float map = getMap(); - efiAssert(!cisnan(map), "NaN map", 0); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(map), "NaN map", 0); float adjustedMap = map + engine->engineLoadAccelEnrichment.getEngineLoadEnrichment(PASS_ENGINE_PARAMETER_SIGNATURE); - efiAssert(!cisnan(adjustedMap), "NaN adjustedMap", 0); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(adjustedMap), "NaN adjustedMap", 0); float airMass = getCylinderAirMass(engineConfiguration, ENGINE(engineState.currentVE), adjustedMap, tChargeK); - efiAssert(!cisnan(airMass), "NaN airMass", 0); + efiAssert(CUSTOM_ERR_ASSERT, !cisnan(airMass), "NaN airMass", 0); #if EFI_PRINTF_FUEL_DETAILS || defined(__DOXYGEN__) printf("map=%.2f adjustedMap=%.2f airMass=%.2f\t\n", map, adjustedMap, engine->engineState.airMass); diff --git a/firmware/controllers/sensors/thermistors.cpp b/firmware/controllers/sensors/thermistors.cpp index 0747ca3451..1b68a321dd 100644 --- a/firmware/controllers/sensors/thermistors.cpp +++ b/firmware/controllers/sensors/thermistors.cpp @@ -70,7 +70,7 @@ float convertKelvinToFahrenheit(float kelvin) { } float getResistance(ThermistorConf *config, float voltage) { - efiAssert(config != NULL, "thermistor config is null", NAN); + efiAssert(CUSTOM_ERR_ASSERT, config != NULL, "thermistor config is null", NAN); thermistor_conf_s *tc = &config->config; float resistance = getR2InVoltageDividor(voltage, _5_VOLTS, tc->bias_resistor); @@ -122,7 +122,7 @@ float getCoolantTemperature(DECLARE_ENGINE_PARAMETER_SIGNATURE) { float temperature = getTemperatureC(&engineConfiguration->clt, &engine->engineState.cltCurve, engineConfiguration->useLinearCltSensor); if (!isValidCoolantTemperature(temperature)) { - efiAssert(engineConfiguration!=NULL, "NULL engineConfiguration", NAN); + efiAssert(CUSTOM_ERR_ASSERT, engineConfiguration!=NULL, "NULL engineConfiguration", NAN); warning(OBD_Engine_Coolant_Temperature_Circuit_Malfunction, "unrealistic CLT %.2f", temperature); engine->isCltBroken = true; return LIMPING_MODE_CLT_TEMPERATURE; @@ -203,7 +203,7 @@ float getIntakeAirTemperature(DECLARE_ENGINE_PARAMETER_SIGNATURE) { float temperature = getTemperatureC(&engineConfiguration->iat, &engine->engineState.iatCurve, engineConfiguration->useLinearIatSensor); if (!isValidIntakeAirTemperature(temperature)) { - efiAssert(engineConfiguration!=NULL, "NULL engineConfiguration", NAN); + efiAssert(CUSTOM_ERR_ASSERT, engineConfiguration!=NULL, "NULL engineConfiguration", NAN); #if EFI_PROD_CODE || EFI_UNIT_TEST || defined(__DOXYGEN__) warning(OBD_Intake_Air_Temperature_Circuit_Malfunction, "unrealistic IAT %.2f", temperature); #endif /* EFI_PROD_CODE */ diff --git a/firmware/controllers/system/event_queue.cpp b/firmware/controllers/system/event_queue.cpp index 7e08f95b3b..c094052b75 100644 --- a/firmware/controllers/system/event_queue.cpp +++ b/firmware/controllers/system/event_queue.cpp @@ -42,7 +42,7 @@ bool EventQueue::insertTask(scheduling_s *scheduling, efitime_t timeX, schfunc_t #if EFI_UNIT_TEST || defined(__DOXYGEN__) assertListIsSorted(); #endif /* EFI_UNIT_TEST */ - efiAssert(callback != NULL, "NULL callback", false); + efiAssert(CUSTOM_ERR_ASSERT, callback != NULL, "NULL callback", false); // please note that simulator does not use this code at all - simulator uses signal_executor_sleep @@ -129,14 +129,14 @@ int EventQueue::executeAll(efitime_t now) { // we need safe iteration because we are removing elements inside the loop LL_FOREACH_SAFE(head, current, tmp) { - efiAssert(current->callback != NULL, "callback==null1", 0); + efiAssert(CUSTOM_ERR_ASSERT, current->callback != NULL, "callback==null1", 0); if (++listIterationCounter > QUEUE_LENGTH_LIMIT) { firmwareError(CUSTOM_LIST_LOOP, "Is this list looped?"); return false; } if (current->momentX <= now) { executionCounter++; - efiAssert(head == current, "removing from head", -1); + efiAssert(CUSTOM_ERR_ASSERT, head == current, "removing from head", -1); //LL_DELETE(head, current); head = head->next; if (executionList == NULL) { @@ -164,7 +164,7 @@ int EventQueue::executeAll(efitime_t now) { */ LL_FOREACH_SAFE(executionList, current, tmp) { - efiAssert(current->callback != NULL, "callback==null2", 0); + efiAssert(CUSTOM_ERR_ASSERT, current->callback != NULL, "callback==null2", 0); uint32_t before = GET_TIMESTAMP(); current->isScheduled = false; uint32_t howFarOff = now - current->momentX; diff --git a/firmware/controllers/system/pwm_generator_logic.cpp b/firmware/controllers/system/pwm_generator_logic.cpp index e5240ab547..4a12733795 100644 --- a/firmware/controllers/system/pwm_generator_logic.cpp +++ b/firmware/controllers/system/pwm_generator_logic.cpp @@ -59,7 +59,7 @@ void SimplePwm::setSimplePwmDutyCycle(float dutyCycle) { } static efitimeus_t getNextSwitchTimeUs(PwmConfig *state) { - efiAssert(state->safe.phaseIndex < PWM_PHASE_MAX_COUNT, "phaseIndex range", 0); + efiAssert(CUSTOM_ERR_ASSERT, state->safe.phaseIndex < PWM_PHASE_MAX_COUNT, "phaseIndex range", 0); int iteration = state->safe.iteration; float switchTime = state->multiWave.getSwitchTime(state->safe.phaseIndex); float periodNt = state->safe.periodNt; diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 94c707722d..f9035e24d3 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -672,11 +672,11 @@ static void onFindIndexCallback(TriggerState *state) { uint32_t findTriggerZeroEventIndex(TriggerState *state, TriggerShape * shape, trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_SUFFIX) { #if EFI_PROD_CODE || defined(__DOXYGEN__) - efiAssert(getRemainingStack(chThdGetSelfX()) > 128, "findPos", -1); + efiAssert(CUSTOM_ERR_ASSERT, getRemainingStack(chThdGetSelfX()) > 128, "findPos", -1); #endif isInitializingTrigger = true; errorDetection.clear(); - efiAssert(state != NULL, "NULL state", -1); + efiAssert(CUSTOM_ERR_ASSERT, state != NULL, "NULL state", -1); state->reset(); @@ -692,7 +692,7 @@ uint32_t findTriggerZeroEventIndex(TriggerState *state, TriggerShape * shape, isInitializingTrigger = false; return syncIndex; } - efiAssert(state->getTotalRevolutionCounter() == 1, "findZero_revCounter", EFI_ERROR_CODE); + efiAssert(CUSTOM_ERR_ASSERT, state->getTotalRevolutionCounter() == 1, "findZero_revCounter", EFI_ERROR_CODE); #if EFI_UNIT_TEST || defined(__DOXYGEN__) if (printTriggerDebug) { diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index 73faeb2751..2e94e18a91 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -301,7 +301,7 @@ angle_t TriggerShape::getAngle(int index) const { * See also trigger_central.cpp * See also getEngineCycleEventCount() */ - efiAssert(size != 0, "shapeSize=0", NAN); + efiAssert(CUSTOM_ERR_ASSERT, size != 0, "shapeSize=0", NAN); int crankCycle = index / size; int remainder = index % size; diff --git a/firmware/hw_layer/pin_repository.cpp b/firmware/hw_layer/pin_repository.cpp index ae18740256..6bdc2816dc 100644 --- a/firmware/hw_layer/pin_repository.cpp +++ b/firmware/hw_layer/pin_repository.cpp @@ -37,7 +37,7 @@ PinRepository::PinRepository() { } static int getPortIndex(ioportid_t port) { - efiAssert(port != NULL, "null port", -1); + efiAssert(CUSTOM_ERR_ASSERT, port != NULL, "null port", -1); if (port == GPIOA) return 0; if (port == GPIOB) diff --git a/firmware/hw_layer/trigger_input.cpp b/firmware/hw_layer/trigger_input.cpp index 82c9428998..d0c53e6513 100644 --- a/firmware/hw_layer/trigger_input.cpp +++ b/firmware/hw_layer/trigger_input.cpp @@ -121,8 +121,8 @@ static ICUDriver *turnOnTriggerInputPin(const char *msg, brain_pin_e hwPin, ICUC efiIcuStart(driver, icucfg); if (driver->state == ICU_READY) { - efiAssert(driver != NULL, "ti: driver is NULL", NULL); - efiAssert(driver->state == ICU_READY, "ti: driver not ready", NULL); + efiAssert(CUSTOM_ERR_ASSERT, driver != NULL, "ti: driver is NULL", NULL); + efiAssert(CUSTOM_ERR_ASSERT, driver->state == ICU_READY, "ti: driver not ready", NULL); icuStartCapture(driver); // this would change state from READY to WAITING icuEnableNotifications(driver); } else { diff --git a/firmware/util/efilib.cpp b/firmware/util/efilib.cpp index 7541af49d4..3fad609592 100644 --- a/firmware/util/efilib.cpp +++ b/firmware/util/efilib.cpp @@ -34,7 +34,7 @@ float efiFloor(float value, float precision) { * @param precision for example '0.1' for one digit fractional part */ float efiRound(float value, float precision) { - efiAssert(precision != 0, "zero precision", NAN); + efiAssert(CUSTOM_ERR_ASSERT, precision != 0, "zero precision", NAN); float a = rintf (value / precision); return a * precision; } diff --git a/firmware/util/histogram.c b/firmware/util/histogram.c index 5c89c4a8f1..cb8d38c800 100644 --- a/firmware/util/histogram.c +++ b/firmware/util/histogram.c @@ -59,7 +59,7 @@ void initHistogramsModule(void) { * @brief This internal method is only public so that we can test it. */ int histogramGetIndex(int64_t value) { - efiAssert(initialized, "histo initialized", 0); + efiAssert(CUSTOM_ERR_ASSERT, initialized, "histo initialized", 0); if (value < 0) return 0; if (value < SBI_SIZE)