From 01f7e4068d30d7c05373aa7aa0fcc80536a3aa64 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Tue, 11 Apr 2023 16:32:47 -0700 Subject: [PATCH] rename obd_code_e -> ObdCode (cherry picked from commit d6534157a03d19bb2e8aeece301642c053a081d0) --- firmware/bootloader/src/rusefi_stubs.cpp | 2 +- firmware/console/eficonsole.cpp | 2 +- firmware/controllers/algo/engine2.cpp | 4 ++-- firmware/controllers/algo/engine_parts.h | 10 +++++----- firmware/controllers/algo/obd_error_codes.h | 2 +- firmware/controllers/core/error_handling.cpp | 4 ++-- firmware/controllers/core/error_handling.h | 4 ++-- firmware/controllers/gauges/malfunction_central.cpp | 10 +++++----- firmware/controllers/gauges/malfunction_central.h | 8 ++++---- firmware/controllers/global_shared.h | 2 +- firmware/controllers/math/engine_math.cpp | 2 +- firmware/controllers/math/engine_math.h | 2 +- firmware/controllers/sensors/sensor_checker.cpp | 12 ++++++------ firmware/hw_layer/ports/chconf_common.h | 2 +- unit_tests/tests/test_util.cpp | 10 +++++----- 15 files changed, 38 insertions(+), 38 deletions(-) diff --git a/firmware/bootloader/src/rusefi_stubs.cpp b/firmware/bootloader/src/rusefi_stubs.cpp index 75721cdb0d..80f61c7fb2 100644 --- a/firmware/bootloader/src/rusefi_stubs.cpp +++ b/firmware/bootloader/src/rusefi_stubs.cpp @@ -18,7 +18,7 @@ void efiPrintfInternal(const char* /*fmt*/, ...) { } } -void firmwareError(obd_code_e /*code*/, const char* /*fmt*/, ...) { +void firmwareError(ObdCode /*code*/, const char* /*fmt*/, ...) { } Logging::Logging(char const* /*name*/, char* /*buffer*/, int /*bufferSize*/) { diff --git a/firmware/console/eficonsole.cpp b/firmware/console/eficonsole.cpp index 403d2ad404..cc5a35a974 100644 --- a/firmware/console/eficonsole.cpp +++ b/firmware/console/eficonsole.cpp @@ -142,7 +142,7 @@ static void sayHello() { chThdSleepMilliseconds(5); } -void validateStack(const char*msg, obd_code_e code, int desiredStackUnusedSize) { +void validateStack(const char*msg, ObdCode code, int desiredStackUnusedSize) { #if CH_DBG_THREADS_PROFILING && CH_DBG_FILL_THREADS int unusedStack = CountFreeStackSpace(chThdGetSelfX()->wabase); if (unusedStack < desiredStackUnusedSize) { diff --git a/firmware/controllers/algo/engine2.cpp b/firmware/controllers/algo/engine2.cpp index d1eed2805c..8b8f02a137 100644 --- a/firmware/controllers/algo/engine2.cpp +++ b/firmware/controllers/algo/engine2.cpp @@ -37,7 +37,7 @@ void WarningCodeState::clear() { recentWarnings.clear(); } -void WarningCodeState::addWarningCode(obd_code_e code) { +void WarningCodeState::addWarningCode(ObdCode code) { warningCounter++; lastErrorCode = code; @@ -69,7 +69,7 @@ bool WarningCodeState::isWarningNow() const { } // Check whether a particular warning is active -bool WarningCodeState::isWarningNow(obd_code_e code) const { +bool WarningCodeState::isWarningNow(ObdCode code) const { warning_t* warn = recentWarnings.find(code); // No warning found at all diff --git a/firmware/controllers/algo/engine_parts.h b/firmware/controllers/algo/engine_parts.h index e3ea855fdc..3a20f73670 100644 --- a/firmware/controllers/algo/engine_parts.h +++ b/firmware/controllers/algo/engine_parts.h @@ -45,11 +45,11 @@ public: struct warning_t { Timer LastTriggered; - obd_code_e Code = OBD_None; + ObdCode Code = OBD_None; warning_t() { } - explicit warning_t(obd_code_e code) + explicit warning_t(ObdCode code) : Code(code) { } @@ -60,7 +60,7 @@ struct warning_t { } // Compare against a plain OBD code - bool operator ==(const obd_code_e other) const { + bool operator ==(const ObdCode other) const { return other == Code; } }; @@ -70,9 +70,9 @@ typedef static_vector warningBuffer_t; class WarningCodeState { public: WarningCodeState(); - void addWarningCode(obd_code_e code); + void addWarningCode(ObdCode code); bool isWarningNow() const; - bool isWarningNow(obd_code_e code) const; + bool isWarningNow(ObdCode code) const; void clear(); int warningCounter; int lastErrorCode; diff --git a/firmware/controllers/algo/obd_error_codes.h b/firmware/controllers/algo/obd_error_codes.h index 9b8e8f9b9d..7ac4ef92f7 100644 --- a/firmware/controllers/algo/obd_error_codes.h +++ b/firmware/controllers/algo/obd_error_codes.h @@ -2182,7 +2182,7 @@ typedef enum { // as of 2020 preference is with ' __attribute__ ((__packed__))' allowing one-byte enums // this is needed for proper enum size, this matters for malfunction_central Internal_ForceMyEnumIntSize_cranking_obd_code = 2000000000, -} obd_code_e; +} ObdCode; #ifdef __cplusplus } diff --git a/firmware/controllers/core/error_handling.cpp b/firmware/controllers/core/error_handling.cpp index 2d50958c62..673d224a5c 100644 --- a/firmware/controllers/core/error_handling.cpp +++ b/firmware/controllers/core/error_handling.cpp @@ -127,7 +127,7 @@ WarningCodeState unitTestWarningCodeState; * * @returns TRUE in case there were warnings recently */ -bool warning(obd_code_e code, const char *fmt, ...) { +bool warning(ObdCode code, const char *fmt, ...) { if (hasFirmwareErrorFlag) return true; @@ -219,7 +219,7 @@ void onUnlockHook(void) { #include #endif -void firmwareError(obd_code_e code, const char *fmt, ...) { +void firmwareError(ObdCode code, const char *fmt, ...) { #if EFI_PROD_CODE if (hasFirmwareErrorFlag) return; diff --git a/firmware/controllers/core/error_handling.h b/firmware/controllers/core/error_handling.h index 9306fb2416..ba9d53c3fd 100644 --- a/firmware/controllers/core/error_handling.h +++ b/firmware/controllers/core/error_handling.h @@ -22,7 +22,7 @@ extern "C" * * see also firmwareError() */ -bool warning(obd_code_e code, const char *fmt, ...); +bool warning(ObdCode code, const char *fmt, ...); using critical_msg_t = char[CRITICAL_BUFFER_SIZE]; @@ -33,7 +33,7 @@ using critical_msg_t = char[CRITICAL_BUFFER_SIZE]; * * see also warning() */ -void firmwareError(obd_code_e code, const char *fmt, ...); +void firmwareError(ObdCode code, const char *fmt, ...); extern bool hasFirmwareErrorFlag; diff --git a/firmware/controllers/gauges/malfunction_central.cpp b/firmware/controllers/gauges/malfunction_central.cpp index bc4a0d9107..01b2cf7a58 100644 --- a/firmware/controllers/gauges/malfunction_central.cpp +++ b/firmware/controllers/gauges/malfunction_central.cpp @@ -17,7 +17,7 @@ static error_codes_set_s error_codes_set; /** * @return -1 if code not found */ -static int find_position(obd_code_e e_code) // Search if code is present +static int find_position(ObdCode e_code) // Search if code is present { // cycle for searching element equal seaching code for (int t = 0; t < error_codes_set.count; t++) @@ -30,14 +30,14 @@ void clearWarnings(void) { error_codes_set.count = 0; } -void addError(obd_code_e errorCode) { +void addError(ObdCode errorCode) { if (error_codes_set.count < MAX_ERROR_CODES_COUNT && find_position(errorCode) == -1) { error_codes_set.error_codes[error_codes_set.count] = errorCode; error_codes_set.count++; } } -void removeError(obd_code_e errorCode) { +void removeError(ObdCode errorCode) { int pos = find_position(errorCode); if (pos >= 0) { // shift all right elements to one pos left @@ -45,11 +45,11 @@ void removeError(obd_code_e errorCode) { error_codes_set.error_codes[t] = error_codes_set.error_codes[t + 1]; } - error_codes_set.error_codes[--error_codes_set.count] = (obd_code_e)0; // place 0 + error_codes_set.error_codes[--error_codes_set.count] = (ObdCode)0; // place 0 } } -void setError(bool isError, obd_code_e errorCode) { +void setError(bool isError, ObdCode errorCode) { if (isError) { addError(errorCode); } else { diff --git a/firmware/controllers/gauges/malfunction_central.h b/firmware/controllers/gauges/malfunction_central.h index e77fdc1374..881f94fcda 100644 --- a/firmware/controllers/gauges/malfunction_central.h +++ b/firmware/controllers/gauges/malfunction_central.h @@ -14,7 +14,7 @@ struct error_codes_set_s { int count = 0; - obd_code_e error_codes[MAX_ERROR_CODES_COUNT]; + ObdCode error_codes[MAX_ERROR_CODES_COUNT]; }; /** @@ -23,14 +23,14 @@ struct error_codes_set_s { * The error code stays in the data structure till it is removed by 'clearError' * */ -void addError(obd_code_e errorCode); +void addError(ObdCode errorCode); /** * @brief Removed the error code from the set of current errors. * */ -void removeError(obd_code_e errorCode); +void removeError(ObdCode errorCode); -void setError(bool isError, obd_code_e errorCode); +void setError(bool isError, ObdCode errorCode); void clearWarnings(void); /** diff --git a/firmware/controllers/global_shared.h b/firmware/controllers/global_shared.h index 84fb8399e0..c491c77fcd 100644 --- a/firmware/controllers/global_shared.h +++ b/firmware/controllers/global_shared.h @@ -34,4 +34,4 @@ */ EXTERNC int getRemainingStack(thread_t *otp); int CountFreeStackSpace(const void* wabase); -void validateStack(const char*msg, obd_code_e code, int stackUnusedSize); +void validateStack(const char*msg, ObdCode code, int stackUnusedSize); diff --git a/firmware/controllers/math/engine_math.cpp b/firmware/controllers/math/engine_math.cpp index 61df15d683..377b1fea22 100644 --- a/firmware/controllers/math/engine_math.cpp +++ b/firmware/controllers/math/engine_math.cpp @@ -30,7 +30,7 @@ extern bool verboseMode; #endif /* EFI_UNIT_TEST */ -angle_t wrapAngleMethod(angle_t param, const char *msg, obd_code_e code) { +angle_t wrapAngleMethod(angle_t param, const char *msg, ObdCode code) { fixAngle(param, msg, code); return param; } diff --git a/firmware/controllers/math/engine_math.h b/firmware/controllers/math/engine_math.h index 66eb1979d1..e223f8cca3 100644 --- a/firmware/controllers/math/engine_math.h +++ b/firmware/controllers/math/engine_math.h @@ -22,7 +22,7 @@ void setFlatInjectorLag(float value); #define wrapAngle(angle, msg, code) fixAngle(angle, msg, code) // proper method avoids un-wrapped state of variables -angle_t wrapAngleMethod(angle_t param, const char *msg, obd_code_e code); +angle_t wrapAngleMethod(angle_t param, const char *msg, ObdCode code); /** * @return time needed to rotate crankshaft by one degree, in milliseconds. diff --git a/firmware/controllers/sensors/sensor_checker.cpp b/firmware/controllers/sensors/sensor_checker.cpp index eb24f3edfe..d3ffc6a83a 100644 --- a/firmware/controllers/sensors/sensor_checker.cpp +++ b/firmware/controllers/sensors/sensor_checker.cpp @@ -1,7 +1,7 @@ #include "pch.h" // Decode what OBD code we should use for a particular [sensor, code] problem -static obd_code_e getCode(SensorType type, UnexpectedCode code) { +static ObdCode getCode(SensorType type, UnexpectedCode code) { switch (type) { case SensorType::Tps1: case SensorType::Tps1Primary: @@ -114,14 +114,14 @@ static void check(SensorType type) { return; } - obd_code_e code = getCode(type, result.Code); + ObdCode code = getCode(type, result.Code); if (code != OBD_None) { warning(code, "Sensor fault: %s %s", Sensor::getSensorName(type), describeUnexpected(result.Code)); } } -static obd_code_e getCodeForInjector(int idx, brain_pin_diag_e diag) { +static ObdCode getCodeForInjector(int idx, brain_pin_diag_e diag) { if (idx < 0 || idx >= 12) { return OBD_None; } @@ -129,10 +129,10 @@ static obd_code_e getCodeForInjector(int idx, brain_pin_diag_e diag) { // TODO: do something more intelligent with `diag`? UNUSED(diag); - return (obd_code_e)((int)OBD_Injector_Circuit_1 + idx); + return (ObdCode)((int)OBD_Injector_Circuit_1 + idx); } -static obd_code_e getCodeForIgnition(int idx, brain_pin_diag_e diag) { +static ObdCode getCodeForIgnition(int idx, brain_pin_diag_e diag) { if (idx < 0 || idx >= 12) { return OBD_None; } @@ -140,7 +140,7 @@ static obd_code_e getCodeForIgnition(int idx, brain_pin_diag_e diag) { // TODO: do something more intelligent with `diag`? UNUSED(diag); - return (obd_code_e)((int)OBD_Ignition_Circuit_1 + idx); + return (ObdCode)((int)OBD_Ignition_Circuit_1 + idx); } void SensorChecker::onSlowCallback() { diff --git a/firmware/hw_layer/ports/chconf_common.h b/firmware/hw_layer/ports/chconf_common.h index 4e3346c603..7b0bd4c033 100644 --- a/firmware/hw_layer/ports/chconf_common.h +++ b/firmware/hw_layer/ports/chconf_common.h @@ -25,7 +25,7 @@ extern "C" { #endif /* __cplusplus */ #ifndef __ASSEMBLER__ - void firmwareError(obd_code_e code, const char *fmt, ...); + void firmwareError(ObdCode code, const char *fmt, ...); void irqEnterHook(void); void irqExitHook(void); void contextSwitchHook(void); diff --git a/unit_tests/tests/test_util.cpp b/unit_tests/tests/test_util.cpp index 6a8e9147da..9226a4c1fb 100644 --- a/unit_tests/tests/test_util.cpp +++ b/unit_tests/tests/test_util.cpp @@ -156,10 +156,10 @@ static void testMalfunctionCentralRemoveFirstElement() { clearWarnings(); error_codes_set_s localCopy; - obd_code_e firstElement = OBD_TPS1_Correlation; + ObdCode firstElement = OBD_TPS1_Correlation; addError(firstElement); - obd_code_e secondElement = OBD_TPS2_Correlation; + ObdCode secondElement = OBD_TPS2_Correlation; addError(secondElement); getErrorCodes(&localCopy); ASSERT_EQ(2, localCopy.count); @@ -185,7 +185,7 @@ TEST(misc, testMalfunctionCentral) { getErrorCodes(&localCopy); ASSERT_EQ(0, localCopy.count); - obd_code_e code = OBD_TPS1_Correlation; + ObdCode code = OBD_TPS1_Correlation; // let's add one error and validate addError(code); @@ -194,7 +194,7 @@ TEST(misc, testMalfunctionCentral) { ASSERT_EQ(code, localCopy.error_codes[0]); // let's remove value which is not in the collection - removeError((obd_code_e) 22); + removeError((ObdCode) 22); // element not present - nothing to removed ASSERT_EQ(1, localCopy.count); ASSERT_EQ(code, localCopy.error_codes[0]); @@ -205,7 +205,7 @@ TEST(misc, testMalfunctionCentral) { // todo: ASSERT_EQ(2, localCopy.count); for (int code = 0; code < 100; code++) { - addError((obd_code_e) code); + addError((ObdCode) code); } getErrorCodes(&localCopy); ASSERT_EQ(MAX_ERROR_CODES_COUNT, localCopy.count);