From e984e7a0c4e070c0d62e4d4d1659a9e284122850 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Mon, 10 Oct 2016 14:02:17 -0400 Subject: [PATCH] auto-sync --- firmware/chibios/os/kernel/src/chdebug.c | 2 -- firmware/console/binary/tunerstudio.cpp | 4 ++-- firmware/console/console_io.cpp | 4 ++-- firmware/console/eficonsole.cpp | 2 +- firmware/controllers/algo/engine.cpp | 2 +- firmware/controllers/algo/engine_configuration.cpp | 6 +++--- firmware/controllers/algo/error_handling.h | 6 +++--- firmware/controllers/algo/fuel_math.cpp | 2 +- firmware/controllers/core/EfiWave.cpp | 4 ++-- firmware/controllers/core/fl_stack.h | 4 ++-- firmware/controllers/core/fsio_core.cpp | 2 +- firmware/controllers/core/interpolation.cpp | 2 +- firmware/controllers/lcd_controller.cpp | 2 +- firmware/controllers/map_averaging.cpp | 2 +- firmware/controllers/math/engine_math.h | 2 +- firmware/controllers/sensors/ego.cpp | 2 +- firmware/controllers/sensors/map.cpp | 4 ++-- firmware/controllers/sensors/thermistors.cpp | 4 ++-- .../controllers/system/SingleTimerExecutor.cpp | 4 ++-- firmware/controllers/system/event_queue.cpp | 2 +- firmware/controllers/system/event_queue.h | 2 +- .../controllers/system/pwm_generator_logic.cpp | 4 ++-- .../controllers/system/signal_executor_sleep.cpp | 2 +- .../controllers/trigger/main_trigger_callback.cpp | 2 +- firmware/controllers/trigger/trigger_decoder.cpp | 2 +- firmware/controllers/trigger/trigger_simulator.cpp | 4 ++-- firmware/controllers/trigger/trigger_structure.cpp | 8 ++++---- firmware/hw_layer/adc_inputs.cpp | 14 +++++++------- firmware/hw_layer/digital_input_hw.cpp | 8 ++++---- firmware/hw_layer/gpio_helper.cpp | 2 +- firmware/hw_layer/hardware.cpp | 2 +- firmware/hw_layer/io_pins.cpp | 4 ++-- firmware/hw_layer/joystick.cpp | 2 +- firmware/hw_layer/lcd/lcd_HD44780.cpp | 2 +- firmware/hw_layer/microsecond_timer.cpp | 4 ++-- firmware/hw_layer/pin_repository.cpp | 8 ++++---- firmware/hw_layer/trigger_input.cpp | 2 +- firmware/rusefi.cpp | 4 ++-- firmware/util/datalogging.cpp | 6 +++--- firmware/util/histogram.c | 2 +- unit_tests/main.cpp | 2 +- unit_tests/test_logic_expression.cpp | 2 +- .../simulator/rusEfiFunctionalTest.cpp | 2 +- 43 files changed, 75 insertions(+), 77 deletions(-) diff --git a/firmware/chibios/os/kernel/src/chdebug.c b/firmware/chibios/os/kernel/src/chdebug.c index c0003ef939..b6197a56b4 100644 --- a/firmware/chibios/os/kernel/src/chdebug.c +++ b/firmware/chibios/os/kernel/src/chdebug.c @@ -154,8 +154,6 @@ void dbg_check_unlock_from_isr(void) { dbg_leave_lock(); } -void firmwareError(const char *fmt, ...); - extern int maxNesting; /** diff --git a/firmware/console/binary/tunerstudio.cpp b/firmware/console/binary/tunerstudio.cpp index 95c3e9ac5f..d8bc5888ca 100644 --- a/firmware/console/binary/tunerstudio.cpp +++ b/firmware/console/binary/tunerstudio.cpp @@ -788,10 +788,10 @@ int tunerStudioHandleCrcCommand(ts_channel_s *tsChannel, char *data, int incomin void startTunerStudioConnectivity(void) { if (sizeof(persistent_config_s) != getTunerStudioPageSize(0)) - firmwareError("TS page size mismatch: %d/%d", sizeof(persistent_config_s), getTunerStudioPageSize(0)); + firmwareError(OBD_PCM_Processor_Fault, "TS page size mismatch: %d/%d", sizeof(persistent_config_s), getTunerStudioPageSize(0)); if (sizeof(TunerStudioOutputChannels) != TS_OUTPUT_SIZE) - firmwareError("TS outputs size mismatch: %d/%d", sizeof(TunerStudioOutputChannels), TS_OUTPUT_SIZE); + firmwareError(OBD_PCM_Processor_Fault, "TS outputs size mismatch: %d/%d", sizeof(TunerStudioOutputChannels), TS_OUTPUT_SIZE); memset(&tsState, 0, sizeof(tsState)); syncTunerStudioCopy(); diff --git a/firmware/console/console_io.cpp b/firmware/console/console_io.cpp index b87f312657..19e1a7c125 100644 --- a/firmware/console/console_io.cpp +++ b/firmware/console/console_io.cpp @@ -82,7 +82,7 @@ static bool getConsoleLine(BaseSequentialStream *chp, char *line, unsigned size) ; if (flags & SD_OVERRUN_ERROR) { -// firmwareError("serial overrun"); +// firmwareError(OBD_PCM_Processor_Fault, "serial overrun"); } } @@ -229,7 +229,7 @@ void consoleOutputBuffer(const uint8_t *buf, int size) { #if !EFI_UART_ECHO_TEST_MODE lastWriteActual = chnWriteTimeout(getConsoleChannel(), buf, size, CONSOLE_WRITE_TIMEOUT); // if (r != size) -// firmwareError("Partial console write"); +// firmwareError(OBD_PCM_Processor_Fault, "Partial console write"); #endif /* EFI_UART_ECHO_TEST_MODE */ } diff --git a/firmware/console/eficonsole.cpp b/firmware/console/eficonsole.cpp index 5e1df9f731..6494b17caa 100644 --- a/firmware/console/eficonsole.cpp +++ b/firmware/console/eficonsole.cpp @@ -36,7 +36,7 @@ static void myfatal(void) { } static void myerror(void) { - firmwareError("firmwareError: %d", getRusEfiVersion()); + firmwareError(OBD_PCM_Processor_Fault, "firmwareError: %d", getRusEfiVersion()); } static void sayNothing(void) { diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index fc03bede50..5b31220cdd 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -288,7 +288,7 @@ void Engine::watchdog() { return; if (!isSpinning) { if (!isRunningBenchTest() && stopPins()) { - firmwareError("Some pins were turned off by 2nd pass watchdog"); + firmwareError(OBD_PCM_Processor_Fault, "Some pins were turned off by 2nd pass watchdog"); } return; } diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index e205dfe8da..c5e80c22b2 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -990,7 +990,7 @@ void resetConfigurationExt(Logging * logger, engine_type_e engineType DECLARE_EN applyNonPersistentConfiguration(logger PASS_ENGINE_PARAMETER); // todo: eliminate triggerShape.operationMode? if (engineConfiguration->operationMode != engine->triggerShape.getOperationMode()) - firmwareError("operationMode/trigger mismatch"); + firmwareError(OBD_PCM_Processor_Fault, "operationMode/trigger mismatch"); #if EFI_TUNER_STUDIO syncTunerStudioCopy(); @@ -1015,11 +1015,11 @@ void applyNonPersistentConfiguration(Logging * logger DECLARE_ENGINE_PARAMETER_S engine->triggerShape.initializeTriggerShape(logger PASS_ENGINE_PARAMETER); #endif if (engine->triggerShape.getSize() == 0) { - firmwareError("triggerShape size is zero"); + firmwareError(OBD_PCM_Processor_Fault, "triggerShape size is zero"); return; } if (engine->triggerShape.getSize() == 0) { - firmwareError("shaftPositionEventCount is zero"); + firmwareError(OBD_PCM_Processor_Fault, "shaftPositionEventCount is zero"); return; } engine->engineCycleEventCount = engine->triggerShape.getLength(); diff --git a/firmware/controllers/algo/error_handling.h b/firmware/controllers/algo/error_handling.h index 1181eacca0..3a6db1bce4 100644 --- a/firmware/controllers/algo/error_handling.h +++ b/firmware/controllers/algo/error_handling.h @@ -34,7 +34,7 @@ bool isWarningNow(efitimesec_t now, bool forIndicator); * * todo: better method name? */ -void firmwareError(const char *fmt, ...); +void firmwareError(obd_code_e code, const char *fmt, ...); #define hasFirmwareError() hasFirmwareErrorFlag @@ -63,8 +63,8 @@ int getRusEfiVersion(void); * is stopped. Please use firmwareWarning() instead */ #if EFI_ENABLE_ASSERTS - #define efiAssert(condition, message, result) { if (!(condition)) { firmwareError(message); return result; } } - #define efiAssertVoid(condition, message) { if (!(condition)) { firmwareError(message); return; } } + #define efiAssert(condition, message, result) { if (!(condition)) { firmwareError(OBD_PCM_Processor_Fault, message); return result; } } + #define efiAssertVoid(condition, message) { if (!(condition)) { firmwareError(OBD_PCM_Processor_Fault, message); return; } } #else /* EFI_ENABLE_ASSERTS */ #define efiAssert(condition, message, result) { } #define efiAssertVoid(condition, message) { } diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index b63ef8d5e4..0e9494335b 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -105,7 +105,7 @@ int getNumberOfInjections(injection_mode_e mode DECLARE_ENGINE_PARAMETER_S) { case IM_BATCH: return 2; default: - firmwareError("Unexpected getFuelMultiplier %d", mode); + firmwareError(OBD_PCM_Processor_Fault, "Unexpected getFuelMultiplier %d", mode); return 1; } } diff --git a/firmware/controllers/core/EfiWave.cpp b/firmware/controllers/core/EfiWave.cpp index 77ecd73ad6..7ae584988b 100644 --- a/firmware/controllers/core/EfiWave.cpp +++ b/firmware/controllers/core/EfiWave.cpp @@ -51,12 +51,12 @@ float multi_wave_s::getSwitchTime(int index) const { void checkSwitchTimes2(int size, float *switchTimes) { if (switchTimes[size - 1] != 1) { - firmwareError("last switch time has to be 1 not %f", switchTimes[size - 1]); + firmwareError(OBD_PCM_Processor_Fault, "last switch time has to be 1 not %f", switchTimes[size - 1]); return; } for (int i = 0; i < size - 1; i++) { if (switchTimes[i] >= switchTimes[i + 1]) { - firmwareError("invalid switchTimes @%d: %f/%f", i, switchTimes[i], switchTimes[i + 1]); + firmwareError(OBD_PCM_Processor_Fault, "invalid switchTimes @%d: %f/%f", i, switchTimes[i], switchTimes[i + 1]); } } } diff --git a/firmware/controllers/core/fl_stack.h b/firmware/controllers/core/fl_stack.h index 252d484f54..566af2d494 100644 --- a/firmware/controllers/core/fl_stack.h +++ b/firmware/controllers/core/fl_stack.h @@ -59,7 +59,7 @@ bool FLStack::remove(T value) { template void FLStack::push(T value) { if (currentSize >= MAXSIZE) { - firmwareError("FLstack overflow"); + firmwareError(OBD_PCM_Processor_Fault, "FLstack overflow"); return; //warning() } @@ -69,7 +69,7 @@ void FLStack::push(T value) { template T FLStack::pop() { if (currentSize == 0) { - firmwareError("FLStack is empty"); + firmwareError(OBD_PCM_Processor_Fault, "FLStack is empty"); } return values[--currentSize]; } diff --git a/firmware/controllers/core/fsio_core.cpp b/firmware/controllers/core/fsio_core.cpp index cec315b8c1..92e353f89b 100644 --- a/firmware/controllers/core/fsio_core.cpp +++ b/firmware/controllers/core/fsio_core.cpp @@ -353,7 +353,7 @@ int LEElementPool::getSize() { LEElement *LEElementPool::next() { if (index >= size) { // todo: this should not be a fatal error, just an error - firmwareError("LE_ELEMENT_POOL_SIZE overflow"); + firmwareError(OBD_PCM_Processor_Fault, "LE_ELEMENT_POOL_SIZE overflow"); return NULL; } LEElement *result = &pool[index++]; diff --git a/firmware/controllers/core/interpolation.cpp b/firmware/controllers/core/interpolation.cpp index 8678eafcc7..8ab9cc5e0a 100644 --- a/firmware/controllers/core/interpolation.cpp +++ b/firmware/controllers/core/interpolation.cpp @@ -81,7 +81,7 @@ FastInterpolation::FastInterpolation(float x1, float y1, float x2, float y2) { void FastInterpolation::init(float x1, float y1, float x2, float y2) { if (x1 == x2) { - firmwareError("init: Same x1 and x2 in interpolate: %f/%f", x1, x2); + firmwareError(OBD_PCM_Processor_Fault, "init: Same x1 and x2 in interpolate: %f/%f", x1, x2); return; } a = INTERPOLATION_A(x1, y1, x2, y2); diff --git a/firmware/controllers/lcd_controller.cpp b/firmware/controllers/lcd_controller.cpp index 2d0491b58d..c0a2d8d0d3 100644 --- a/firmware/controllers/lcd_controller.cpp +++ b/firmware/controllers/lcd_controller.cpp @@ -142,7 +142,7 @@ static const char* idleModeStr[] = { "I:A", "I:M" }; // case O2_HEATER: // return "O2H"; // default: -// firmwareError("No short name for %d", (int) pin); +// firmwareError(OBD_PCM_Processor_Fault, "No short name for %d", (int) pin); // return ""; // } //} diff --git a/firmware/controllers/map_averaging.cpp b/firmware/controllers/map_averaging.cpp index 9d2ddb75cd..b6d5c20503 100644 --- a/firmware/controllers/map_averaging.cpp +++ b/firmware/controllers/map_averaging.cpp @@ -193,7 +193,7 @@ static void mapAveragingCallback(trigger_event_e ckpEventType, angle_t samplingDuration = ENGINE(engineState.mapAveragingDuration); if (samplingDuration <= 0) { - firmwareError("map sampling angle should be positive"); + firmwareError(OBD_PCM_Processor_Fault, "map sampling angle should be positive"); return; } diff --git a/firmware/controllers/math/engine_math.h b/firmware/controllers/math/engine_math.h index a61288e198..606db3d3b7 100644 --- a/firmware/controllers/math/engine_math.h +++ b/firmware/controllers/math/engine_math.h @@ -23,7 +23,7 @@ void initializeIgnitionActions(angle_t advance, angle_t dwellAngle, IgnitionEventList *list DECLARE_ENGINE_PARAMETER_S); #if EFI_ENABLE_ASSERTS -#define assertAngleRange(angle) if(angle > 10000000 || angle < -10000000) { firmwareError("angle range");angle = 0;} +#define assertAngleRange(angle) if(angle > 10000000 || angle < -10000000) { firmwareError(OBD_PCM_Processor_Fault, "angle range");angle = 0;} #else #define assertAngleRange(angle) {} #endif diff --git a/firmware/controllers/sensors/ego.cpp b/firmware/controllers/sensors/ego.cpp index 3799456d86..927fcb45f8 100644 --- a/firmware/controllers/sensors/ego.cpp +++ b/firmware/controllers/sensors/ego.cpp @@ -56,7 +56,7 @@ static void initEgoSensor(afr_sensor_s *sensor, ego_sensor_e type) { sensor->value2 = 14; break; default: - firmwareError("Unexpected EGO %d", type); + firmwareError(OBD_PCM_Processor_Fault, "Unexpected EGO %d", type); break; } } diff --git a/firmware/controllers/sensors/map.cpp b/firmware/controllers/sensors/map.cpp index 5fceb748e4..3ae2239877 100644 --- a/firmware/controllers/sensors/map.cpp +++ b/firmware/controllers/sensors/map.cpp @@ -88,7 +88,7 @@ float decodePressure(float voltage, air_pressure_sensor_config_s * mapConfig DEC case MT_MPX4100: return mpx4100.getValue(voltage); default: - firmwareError("Unknown MAP type: %d", mapConfig->type); + firmwareError(OBD_PCM_Processor_Fault, "Unknown MAP type: %d", mapConfig->type); return NAN; } } @@ -159,7 +159,7 @@ static FastInterpolation *getDecoder(air_pressure_sensor_type_e type) { case MT_GM_3_BAR: return &gm3bar; default: - firmwareError("Unknown MAP type: %d", type); + firmwareError(OBD_PCM_Processor_Fault, "Unknown MAP type: %d", type); return &customMap; } } diff --git a/firmware/controllers/sensors/thermistors.cpp b/firmware/controllers/sensors/thermistors.cpp index abb8e3b7c0..4f2d4a9d0a 100644 --- a/firmware/controllers/sensors/thermistors.cpp +++ b/firmware/controllers/sensors/thermistors.cpp @@ -82,7 +82,7 @@ float getResistance(ThermistorConf *config) { float getTemperatureC(ThermistorConf *config, ThermistorMath *tm) { if (!initialized) { - firmwareError("thermstr not initialized"); + firmwareError(OBD_PCM_Processor_Fault, "thermstr not initialized"); return NAN; } float resistance = getResistance(config); @@ -137,7 +137,7 @@ static void prepareThermistorCurve(thermistor_conf_s *tc, thermistor_curve_s * c float L1 = logf(tc->resistance_1); if (L1 == tc->resistance_1) { - firmwareError("log is broken?"); + firmwareError(OBD_PCM_Processor_Fault, "log is broken?"); } float L2 = logf(tc->resistance_2); float L3 = logf(tc->resistance_3); diff --git a/firmware/controllers/system/SingleTimerExecutor.cpp b/firmware/controllers/system/SingleTimerExecutor.cpp index 626008a1df..cf0a0fae98 100644 --- a/firmware/controllers/system/SingleTimerExecutor.cpp +++ b/firmware/controllers/system/SingleTimerExecutor.cpp @@ -62,7 +62,7 @@ Executor::Executor() { void Executor::scheduleByTime(const bool monitorReuse, scheduling_s *scheduling, efitimeus_t timeUs, schfunc_t callback, void *param) { // if (delayUs < 0) { -// firmwareError("Negative delayUs %s: %d", prefix, delayUs); +// firmwareError(OBD_PCM_Processor_Fault, "Negative delayUs %s: %d", prefix, delayUs); // return; // } // if (delayUs == 0) { @@ -117,7 +117,7 @@ void Executor::doExecute() { } lastExecutionCount = totalExecuted; if (!isLocked()) { - firmwareError("Someone has stolen my lock"); + firmwareError(OBD_PCM_Processor_Fault, "Someone has stolen my lock"); return; } reentrantFlag = false; diff --git a/firmware/controllers/system/event_queue.cpp b/firmware/controllers/system/event_queue.cpp index 1a873140bd..c38a0b80bb 100644 --- a/firmware/controllers/system/event_queue.cpp +++ b/firmware/controllers/system/event_queue.cpp @@ -134,7 +134,7 @@ int EventQueue::executeAll(efitime_t now) { { efiAssert(current->callback != NULL, "callback==null1", 0); if (++listIterationCounter > QUEUE_LENGTH_LIMIT) { - firmwareError("Is this list looped?"); + firmwareError(OBD_PCM_Processor_Fault, "Is this list looped?"); return false; } if (current->momentX <= now) { diff --git a/firmware/controllers/system/event_queue.h b/firmware/controllers/system/event_queue.h index 7b3637a691..b945c6dc34 100644 --- a/firmware/controllers/system/event_queue.h +++ b/firmware/controllers/system/event_queue.h @@ -26,7 +26,7 @@ bool assertNotInList(T *head, T*element) { LL_FOREACH(head, current) { if (++counter > QUEUE_LENGTH_LIMIT) { - firmwareError("Looped queue?"); + firmwareError(OBD_PCM_Processor_Fault, "Looped queue?"); return false; } if (current == element) { diff --git a/firmware/controllers/system/pwm_generator_logic.cpp b/firmware/controllers/system/pwm_generator_logic.cpp index 95fffd809b..0c4461433e 100644 --- a/firmware/controllers/system/pwm_generator_logic.cpp +++ b/firmware/controllers/system/pwm_generator_logic.cpp @@ -182,11 +182,11 @@ void PwmConfig::weComplexInit(const char *msg, int phaseCount, float *switchTime efiAssertVoid(periodNt != 0, "period is not initialized"); if (phaseCount == 0) { - firmwareError("signal length cannot be zero"); + firmwareError(OBD_PCM_Processor_Fault, "signal length cannot be zero"); return; } if (phaseCount > PWM_PHASE_MAX_COUNT) { - firmwareError("too many phases in PWM"); + firmwareError(OBD_PCM_Processor_Fault, "too many phases in PWM"); return; } efiAssertVoid(waveCount > 0, "waveCount should be positive"); diff --git a/firmware/controllers/system/signal_executor_sleep.cpp b/firmware/controllers/system/signal_executor_sleep.cpp index 0fad1d225c..bcc118a348 100644 --- a/firmware/controllers/system/signal_executor_sleep.cpp +++ b/firmware/controllers/system/signal_executor_sleep.cpp @@ -71,7 +71,7 @@ void scheduleTask(const bool monitorReuse, const char *prefix, scheduling_s *sch if (monitorReuse) { // for (int i = 0;i<100;i++) printf("%s: isArmed? why? sch=%d cb=%d p=%d\r\n", prefix, (int) scheduling, (int)callback, (int)param); - firmwareError("armored\r\n"); + firmwareError(OBD_PCM_Processor_Fault, "armored\r\n"); } #endif /* EFI_SIMULATOR */ chVTResetI(&scheduling->timer); diff --git a/firmware/controllers/trigger/main_trigger_callback.cpp b/firmware/controllers/trigger/main_trigger_callback.cpp index fdc65faf0f..5f362babcb 100644 --- a/firmware/controllers/trigger/main_trigger_callback.cpp +++ b/firmware/controllers/trigger/main_trigger_callback.cpp @@ -440,7 +440,7 @@ static ALWAYS_INLINE void ignitionMathCalc(int rpm DECLARE_ENGINE_PARAMETER_S) { float dwellMs = ENGINE(engineState.sparkDwell); if (cisnan(dwellMs) || dwellMs < 0) { - firmwareError("invalid dwell: %f at %d", dwellMs, rpm); + firmwareError(OBD_PCM_Processor_Fault, "invalid dwell: %f at %d", dwellMs, rpm); return; } } diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 9201229001..0fddfd43d3 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -599,7 +599,7 @@ void TriggerShape::initializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMET break; default: - firmwareError("initializeTriggerShape() not implemented: %d", triggerConfig->type); + firmwareError(OBD_PCM_Processor_Fault, "initializeTriggerShape() not implemented: %d", triggerConfig->type); return; } wave.checkSwitchTimes(getSize()); diff --git a/firmware/controllers/trigger/trigger_simulator.cpp b/firmware/controllers/trigger/trigger_simulator.cpp index 87171324fc..4e341663dc 100644 --- a/firmware/controllers/trigger/trigger_simulator.cpp +++ b/firmware/controllers/trigger/trigger_simulator.cpp @@ -62,7 +62,7 @@ void TriggerStimulatorHelper::assertSyncPositionAndSetDutyCycle(uint32_t index, nextStep(state, shape, i, triggerConfig PASS_ENGINE_PARAMETER); } if (state->getTotalRevolutionCounter() != 3) { - firmwareError("sync failed/wrong gap parameters trigger=%s", getTrigger_type_e(engineConfiguration->trigger.type)); + firmwareError(OBD_PCM_Processor_Fault, "sync failed/wrong gap parameters trigger=%s", getTrigger_type_e(engineConfiguration->trigger.type)); return; } @@ -79,6 +79,6 @@ uint32_t TriggerStimulatorHelper::doFindTrigger(TriggerShape * shape, if (state->shaft_is_synchronized) return i; } - firmwareError("findTriggerZeroEventIndex() failed"); + firmwareError(OBD_PCM_Processor_Fault, "findTriggerZeroEventIndex() failed"); return EFI_ERROR_CODE; } diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index 85a34ca984..df1766dbfd 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -303,7 +303,7 @@ void TriggerShape::addEvent(angle_t angle, trigger_wheel_e const waveIndex, trig efiAssertVoid(angle > 0, "angle should be positive"); if (size > 0) { if (angle <= previousAngle) { - firmwareError("invalid angle order: %f and %f, size=%d", angle, previousAngle, size); + firmwareError(OBD_PCM_Processor_Fault, "invalid angle order: %f and %f, size=%d", angle, previousAngle, size); return; } } @@ -314,7 +314,7 @@ void TriggerShape::addEvent(angle_t angle, trigger_wheel_e const waveIndex, trig single_wave_s *wave = &this->wave.waves[i]; if (wave->pinStates == NULL) { - firmwareError("wave pinStates is NULL"); + firmwareError(OBD_PCM_Processor_Fault, "wave pinStates is NULL"); return; } wave->pinStates[0] = initialState[i]; @@ -328,7 +328,7 @@ void TriggerShape::addEvent(angle_t angle, trigger_wheel_e const waveIndex, trig int exactMatch = wave.findAngleMatch(angle, size); if (exactMatch != EFI_ERROR_CODE) { - firmwareError("same angle: not supported"); + firmwareError(OBD_PCM_Processor_Fault, "same angle: not supported"); return; } @@ -346,7 +346,7 @@ void TriggerShape::addEvent(angle_t angle, trigger_wheel_e const waveIndex, trig isFrontEvent[index] = TV_RISE == stateParam; if (index != size) { - firmwareError("are we ever here?"); + firmwareError(OBD_PCM_Processor_Fault, "are we ever here?"); } // int index = size; diff --git a/firmware/hw_layer/adc_inputs.cpp b/firmware/hw_layer/adc_inputs.cpp index 98beab7cdf..0dd5790673 100644 --- a/firmware/hw_layer/adc_inputs.cpp +++ b/firmware/hw_layer/adc_inputs.cpp @@ -161,7 +161,7 @@ void doSlowAdc(void) { if (ADC_SLOW_DEVICE.state != ADC_READY && ADC_SLOW_DEVICE.state != ADC_COMPLETE && ADC_SLOW_DEVICE.state != ADC_ERROR) { - // todo: why and when does this happen? firmwareError("ADC slow not ready?"); + // todo: why and when does this happen? firmwareError(OBD_PCM_Processor_Fault, "ADC slow not ready?"); slowAdc.errorsCount++; chSysUnlockFromIsr() ; @@ -194,7 +194,7 @@ static void pwmpcb_fast(PWMDriver *pwmp) { ADC_FAST_DEVICE.state != ADC_COMPLETE && ADC_FAST_DEVICE.state != ADC_ERROR) { fastAdc.errorsCount++; - // todo: when? why? firmwareError("ADC fast not ready?"); + // todo: when? why? firmwareError(OBD_PCM_Processor_Fault, "ADC fast not ready?"); chSysUnlockFromIsr() ; return; @@ -333,7 +333,7 @@ ioportid_t getAdcChannelPort(adc_channel_e hwChannel) { case ADC_CHANNEL_IN15: return GPIOC; default: - firmwareError("Unknown hw channel %d", hwChannel); + firmwareError(OBD_PCM_Processor_Fault, "Unknown hw channel %d", hwChannel); return NULL; } } @@ -384,7 +384,7 @@ int getAdcChannelPin(adc_channel_e hwChannel) { case ADC_CHANNEL_IN15: return 5; default: - firmwareError("Unknown hw channel %d", hwChannel); + firmwareError(OBD_PCM_Processor_Fault, "Unknown hw channel %d", hwChannel); return -1; } } @@ -512,7 +512,7 @@ static void addChannel(const char *name, adc_channel_e setting, adc_channel_mode } if (adcHwChannelEnabled[setting] != ADC_OFF) { getPinNameByAdcChannel(setting, errorMsgBuff); - firmwareError("ADC mapping error: input %s for %s already used by %s?", errorMsgBuff, name, adcHwChannelUsage[setting]); + firmwareError(OBD_PCM_Processor_Fault, "ADC mapping error: input %s for %s already used by %s?", errorMsgBuff, name, adcHwChannelUsage[setting]); } adcHwChannelUsage[setting] = name; @@ -547,9 +547,9 @@ static void configureInputs(void) { void initAdcInputs(bool boardTestMode) { printMsg(&logger, "initAdcInputs()"); if (ADC_BUF_DEPTH_FAST > MAX_ADC_GRP_BUF_DEPTH) - firmwareError("ADC_BUF_DEPTH_FAST too high"); + firmwareError(OBD_PCM_Processor_Fault, "ADC_BUF_DEPTH_FAST too high"); if (ADC_BUF_DEPTH_SLOW > MAX_ADC_GRP_BUF_DEPTH) - firmwareError("ADC_BUF_DEPTH_SLOW too high"); + firmwareError(OBD_PCM_Processor_Fault, "ADC_BUF_DEPTH_SLOW too high"); configureInputs(); diff --git a/firmware/hw_layer/digital_input_hw.cpp b/firmware/hw_layer/digital_input_hw.cpp index 0d7b3284fb..ceb0e1cecc 100644 --- a/firmware/hw_layer/digital_input_hw.cpp +++ b/firmware/hw_layer/digital_input_hw.cpp @@ -34,7 +34,7 @@ static digital_input_s * finddigital_input_s(ICUDriver *driver) { return ®isteredIcus.elements[i]; } } - firmwareError("reader not found"); + firmwareError(OBD_PCM_Processor_Fault, "reader not found"); return (digital_input_s *) NULL; } @@ -60,7 +60,7 @@ static void icuPeriordCallBack(ICUDriver *driver) { static uint32_t getAlternateFunctions(ICUDriver *driver) { if (driver == NULL) { - firmwareError("getAlternateFunctions(NULL)"); + firmwareError(OBD_PCM_Processor_Fault, "getAlternateFunctions(NULL)"); return 0xffffffff; } #if STM32_ICU_USE_TIM1 @@ -88,7 +88,7 @@ static uint32_t getAlternateFunctions(ICUDriver *driver) { return GPIO_AF_TIM9; } #endif - firmwareError("No such driver"); + firmwareError(OBD_PCM_Processor_Fault, "No such driver"); return 0xffffffff; } @@ -107,7 +107,7 @@ icuchannel_t getInputCaptureChannel(brain_pin_e hwPin) { case GPIOE_11: return ICU_CHANNEL_2; default: - firmwareError("Unexpected hw pin in getInputCaptureChannel %d", hwPin); + firmwareError(OBD_PCM_Processor_Fault, "Unexpected hw pin in getInputCaptureChannel %d", hwPin); return ICU_CHANNEL_1; } } diff --git a/firmware/hw_layer/gpio_helper.cpp b/firmware/hw_layer/gpio_helper.cpp index 935c46eb7c..e5275256df 100644 --- a/firmware/hw_layer/gpio_helper.cpp +++ b/firmware/hw_layer/gpio_helper.cpp @@ -36,7 +36,7 @@ void initOutputPinExt(const char *msg, OutputPin *outputPin, ioportid_t port, ui * here we check if another physical pin is already assigned to this logical output */ // todo: need to clear '&outputs' in io_pins.c - firmwareError("outputPin [%s] already assigned to %x%d", msg, outputPin->port, outputPin->pin); + firmwareError(OBD_PCM_Processor_Fault, "outputPin [%s] already assigned to %x%d", msg, outputPin->port, outputPin->pin); return; } outputPin->currentLogicValue = INITIAL_PIN_STATE; diff --git a/firmware/hw_layer/hardware.cpp b/firmware/hw_layer/hardware.cpp index a3cb4d2118..8a8230bc91 100644 --- a/firmware/hw_layer/hardware.cpp +++ b/firmware/hw_layer/hardware.cpp @@ -106,7 +106,7 @@ SPIDriver * getSpiDevice(spi_device_e spiDevice) { return &SPID3; } #endif - firmwareError("Unexpected SPI device: %d", spiDevice); + firmwareError(OBD_PCM_Processor_Fault, "Unexpected SPI device: %d", spiDevice); return NULL; } #endif diff --git a/firmware/hw_layer/io_pins.cpp b/firmware/hw_layer/io_pins.cpp index 4eff26f34f..efd4e8362d 100644 --- a/firmware/hw_layer/io_pins.cpp +++ b/firmware/hw_layer/io_pins.cpp @@ -64,7 +64,7 @@ ioportid_t getHwPort(brain_pin_e brainPin) { if (brainPin == GPIO_UNASSIGNED) return GPIO_NULL; if (brainPin > GPIO_UNASSIGNED || brainPin < 0) { - firmwareError("Invalid brain_pin_e: %d", brainPin); + firmwareError(OBD_PCM_Processor_Fault, "Invalid brain_pin_e: %d", brainPin); return GPIO_NULL; } return PORTS[brainPin / PORT_SIZE]; @@ -74,7 +74,7 @@ ioportmask_t getHwPin(brain_pin_e brainPin) { if (brainPin == GPIO_UNASSIGNED) return EFI_ERROR_CODE; if (brainPin > GPIO_UNASSIGNED || brainPin < 0) { - firmwareError("Invalid brain_pin_e: %d", brainPin); + firmwareError(OBD_PCM_Processor_Fault, "Invalid brain_pin_e: %d", brainPin); return EFI_ERROR_CODE; } return brainPin % PORT_SIZE; diff --git a/firmware/hw_layer/joystick.cpp b/firmware/hw_layer/joystick.cpp index 49ec928b25..427445e4aa 100644 --- a/firmware/hw_layer/joystick.cpp +++ b/firmware/hw_layer/joystick.cpp @@ -116,7 +116,7 @@ static uint32_t getExtMode(ioportid_t port) { } else if (port == GPIOF) { return EXT_MODE_GPIOF; } - firmwareError("Unsupported %d", port); + firmwareError(OBD_PCM_Processor_Fault, "Unsupported %d", port); return 0; } diff --git a/firmware/hw_layer/lcd/lcd_HD44780.cpp b/firmware/hw_layer/lcd/lcd_HD44780.cpp index 30fb34fd25..d717012799 100644 --- a/firmware/hw_layer/lcd/lcd_HD44780.cpp +++ b/firmware/hw_layer/lcd/lcd_HD44780.cpp @@ -180,7 +180,7 @@ void lcd_HD44780_init(Logging *sharedLogger) { addConsoleAction("lcdinfo", lcdInfo); if (engineConfiguration->displayMode > DM_HD44780_OVER_PCF8574) { - firmwareError("Unexpected displayMode %d", engineConfiguration->displayMode); + firmwareError(OBD_PCM_Processor_Fault, "Unexpected displayMode %d", engineConfiguration->displayMode); return; } diff --git a/firmware/hw_layer/microsecond_timer.cpp b/firmware/hw_layer/microsecond_timer.cpp index b82e230941..2d3f42e535 100644 --- a/firmware/hw_layer/microsecond_timer.cpp +++ b/firmware/hw_layer/microsecond_timer.cpp @@ -76,7 +76,7 @@ static void callback(GPTDriver *gptp) { (void)gptp; timerCallbackCounter++; if (globalTimerCallback == NULL) { - firmwareError("NULL globalTimerCallback"); + firmwareError(OBD_PCM_Processor_Fault, "NULL globalTimerCallback"); return; } isTimerPending = false; @@ -97,7 +97,7 @@ static void usTimerWatchDog(void) { if (getTimeNowNt() >= lastSetTimerTimeNt + 2 * CORE_CLOCK) { strcpy(buff, "no_event"); itoa10(&buff[8], lastSetTimerValue); - firmwareError(buff); + firmwareError(OBD_PCM_Processor_Fault, buff); return; } diff --git a/firmware/hw_layer/pin_repository.cpp b/firmware/hw_layer/pin_repository.cpp index fecd5af553..efd5a5a29f 100644 --- a/firmware/hw_layer/pin_repository.cpp +++ b/firmware/hw_layer/pin_repository.cpp @@ -80,7 +80,7 @@ static int getPortIndex(ioportid_t port) { if (port == GPIOH) return 6; #endif /* defined(STM32F4XX) */ - firmwareError("unknown port"); + firmwareError(OBD_PCM_Processor_Fault, "unknown port"); return -1; } @@ -197,7 +197,7 @@ const char * getPinFunction(brain_input_pin_e brainPin) { */ void mySetPadMode(const char *msg, ioportid_t port, ioportmask_t pin, iomode_t mode) { if (!initialized) { - firmwareError("repository not initialized"); + firmwareError(OBD_PCM_Processor_Fault, "repository not initialized"); return; } if (port == GPIO_NULL) @@ -216,7 +216,7 @@ void mySetPadMode(const char *msg, ioportid_t port, ioportmask_t pin, iomode_t m * connected, so the warning is never displayed on the console and that's quite a problem! */ // warning(OBD_PCM_Processor_Fault, "%s%d req by %s used by %s", portname(port), pin, msg, PIN_USED[index]); - firmwareError("%s%d req by %s used by %s", portname(port), pin, msg, PIN_USED[index]); + firmwareError(OBD_PCM_Processor_Fault, "%s%d req by %s used by %s", portname(port), pin, msg, PIN_USED[index]); return; } markUsed(index, msg); @@ -250,7 +250,7 @@ void registedFundamentralIoPin(char *msg, ioportid_t port, ioportmask_t pin, iom if (PIN_USED[index] != NULL) { print("!!!!!!!!!!!!! Already used [%s] %d\r\n", msg, pin); print("!!!!!!!!!!!!! Already used by [%s]\r\n", PIN_USED[index]); - firmwareError("pin already used"); + firmwareError(OBD_PCM_Processor_Fault, "pin already used"); return; } markUsed(index, msg); diff --git a/firmware/hw_layer/trigger_input.cpp b/firmware/hw_layer/trigger_input.cpp index ad7514073d..3d3d280bb5 100644 --- a/firmware/hw_layer/trigger_input.cpp +++ b/firmware/hw_layer/trigger_input.cpp @@ -114,7 +114,7 @@ static ICUDriver *turnOnTriggerInputPin(brain_pin_e hwPin, ICUConfig *icucfg) { icuEnable(driver); } else { // we would be here for example if same pin is used for multiple input capture purposes - firmwareError("ICU unexpected state [%s]", hwPortname(hwPin)); + firmwareError(OBD_PCM_Processor_Fault, "ICU unexpected state [%s]", hwPortname(hwPin)); } } return driver; diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 01edad7b6b..21e548d01f 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -260,7 +260,7 @@ void chDbgStackOverflowPanic(Thread *otp) { } // todo: why is this method here and not in error_handling.cpp ? -void firmwareError(const char *errorMsg, ...) { +void firmwareError(obd_code_e code, const char *errorMsg, ...) { if (hasFirmwareErrorFlag) return; ON_FATAL_ERROR() @@ -293,5 +293,5 @@ int getRusEfiVersion(void) { return 123; // this is here to make the compiler happy about the unused array if (UNUSED_CCM_SIZE[0] * 0 != 0) return 3211; // this is here to make the compiler happy about the unused array - return 20161009; + return 20161010; } diff --git a/firmware/util/datalogging.cpp b/firmware/util/datalogging.cpp index 7436f9a33a..e9a4a51b54 100644 --- a/firmware/util/datalogging.cpp +++ b/firmware/util/datalogging.cpp @@ -51,7 +51,7 @@ static bool intermediateLoggingBufferInited = false; */ static ALWAYS_INLINE bool validateBuffer(Logging *logging, uint32_t extraLen) { if (logging->buffer == NULL) { - firmwareError("Logging not initialized: %s", logging->name); + firmwareError(OBD_PCM_Processor_Fault, "Logging not initialized: %s", logging->name); return true; } @@ -116,7 +116,7 @@ static void vappendPrintfI(Logging *logging, const char *fmt, va_list arg) { void vappendPrintf(Logging *logging, const char *fmt, va_list arg) { efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "lowstck#5b"); if (!intermediateLoggingBufferInited) { - firmwareError("intermediateLoggingBufferInited not inited!"); + firmwareError(OBD_PCM_Processor_Fault, "intermediateLoggingBufferInited not inited!"); return; } int wasLocked = lockAnyContext(); @@ -240,7 +240,7 @@ void appendMsgPostfix(Logging *logging) { void resetLogging(Logging *logging) { char *buffer = logging->buffer; if (buffer == NULL) { - firmwareError("Null buffer: %s", logging->name); + firmwareError(OBD_PCM_Processor_Fault, "Null buffer: %s", logging->name); return; } logging->linePointer = buffer; diff --git a/firmware/util/histogram.c b/firmware/util/histogram.c index eb4d252322..54314d762c 100644 --- a/firmware/util/histogram.c +++ b/firmware/util/histogram.c @@ -83,7 +83,7 @@ int histogramGetIndex(int64_t value) { */ void initHistogram(histogram_s *h, const char *name) { if (efiStrlen(name) > sizeof(h->name) - 1) { - firmwareError("Histogram name [%s] too long", name); + firmwareError(OBD_PCM_Processor_Fault, "Histogram name [%s] too long", name); } strcpy(h->name, name); h->total_value = 0; diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp index a81fa83a52..b0fb9349fe 100644 --- a/unit_tests/main.cpp +++ b/unit_tests/main.cpp @@ -183,7 +183,7 @@ int warning(obd_code_e code, const char *fmt, ...) { bool hasFirmwareErrorFlag = false; -void firmwareError(const char *fmt, ...) { +void firmwareError(obd_code_e code, const char *fmt, ...) { printf(fmt); exit(-1); } diff --git a/unit_tests/test_logic_expression.cpp b/unit_tests/test_logic_expression.cpp index cb623f5c76..e555d10efc 100644 --- a/unit_tests/test_logic_expression.cpp +++ b/unit_tests/test_logic_expression.cpp @@ -34,7 +34,7 @@ float getLEValue(Engine *engine, calc_stack_t *s, le_action_e action) { case LE_METHOD_FAN_OFF_SETTING: return 0; default: - firmwareError("No mock value for %d", action); + firmwareError(OBD_PCM_Processor_Fault, "No mock value for %d", action); return NAN; } } diff --git a/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp b/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp index 920ccd2d82..0cc514eb01 100644 --- a/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp +++ b/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp @@ -136,7 +136,7 @@ void logMsg(const char *format, ...) { // fclose(fp); } -void firmwareError(const char *fmt, ...) { +void firmwareError(obd_code_e code, const char *fmt, ...) { printf("firmwareError [%s]\r\n", fmt); va_list ap;