rename obd_code_e -> ObdCode

This commit is contained in:
Matthew Kennedy 2023-04-11 16:32:47 -07:00
parent df56562708
commit d6534157a0
15 changed files with 38 additions and 38 deletions

View File

@ -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*/) { Logging::Logging(char const* /*name*/, char* /*buffer*/, int /*bufferSize*/) {

View File

@ -91,7 +91,7 @@ static void sayHello() {
chThdSleepMilliseconds(5); 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 #if CH_DBG_THREADS_PROFILING && CH_DBG_FILL_THREADS
int unusedStack = CountFreeStackSpace(chThdGetSelfX()->wabase); int unusedStack = CountFreeStackSpace(chThdGetSelfX()->wabase);
if (unusedStack < desiredStackUnusedSize) { if (unusedStack < desiredStackUnusedSize) {

View File

@ -33,7 +33,7 @@ void WarningCodeState::clear() {
recentWarnings.clear(); recentWarnings.clear();
} }
void WarningCodeState::addWarningCode(obd_code_e code) { void WarningCodeState::addWarningCode(ObdCode code) {
warningCounter++; warningCounter++;
lastErrorCode = code; lastErrorCode = code;
@ -65,7 +65,7 @@ bool WarningCodeState::isWarningNow() const {
} }
// Check whether a particular warning is active // 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); warning_t* warn = recentWarnings.find(code);
// No warning found at all // No warning found at all

View File

@ -45,11 +45,11 @@ public:
struct warning_t { struct warning_t {
Timer LastTriggered; Timer LastTriggered;
obd_code_e Code = OBD_None; ObdCode Code = OBD_None;
warning_t() { } warning_t() { }
explicit warning_t(obd_code_e code) explicit warning_t(ObdCode code)
: Code(code) : Code(code)
{ {
} }
@ -60,7 +60,7 @@ struct warning_t {
} }
// Compare against a plain OBD code // Compare against a plain OBD code
bool operator ==(const obd_code_e other) const { bool operator ==(const ObdCode other) const {
return other == Code; return other == Code;
} }
}; };
@ -70,9 +70,9 @@ typedef static_vector<warning_t, 8> warningBuffer_t;
class WarningCodeState { class WarningCodeState {
public: public:
WarningCodeState(); WarningCodeState();
void addWarningCode(obd_code_e code); void addWarningCode(ObdCode code);
bool isWarningNow() const; bool isWarningNow() const;
bool isWarningNow(obd_code_e code) const; bool isWarningNow(ObdCode code) const;
void clear(); void clear();
int warningCounter; int warningCounter;
int lastErrorCode; int lastErrorCode;

View File

@ -2182,7 +2182,7 @@ typedef enum {
// as of 2020 preference is with ' __attribute__ ((__packed__))' allowing one-byte enums // as of 2020 preference is with ' __attribute__ ((__packed__))' allowing one-byte enums
// this is needed for proper enum size, this matters for malfunction_central // this is needed for proper enum size, this matters for malfunction_central
Internal_ForceMyEnumIntSize_cranking_obd_code = 2000000000, Internal_ForceMyEnumIntSize_cranking_obd_code = 2000000000,
} obd_code_e; } ObdCode;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -127,7 +127,7 @@ WarningCodeState unitTestWarningCodeState;
* *
* @returns TRUE in case there were warnings recently * @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) if (hasFirmwareErrorFlag)
return true; return true;
@ -219,7 +219,7 @@ void onUnlockHook(void) {
#include <stdexcept> #include <stdexcept>
#endif #endif
void firmwareError(obd_code_e code, const char *fmt, ...) { void firmwareError(ObdCode code, const char *fmt, ...) {
#if EFI_PROD_CODE #if EFI_PROD_CODE
if (hasFirmwareErrorFlag) if (hasFirmwareErrorFlag)
return; return;

View File

@ -22,7 +22,7 @@ extern "C"
* *
* see also firmwareError() * see also firmwareError()
*/ */
bool warning(obd_code_e code, const char *fmt, ...); bool warning(ObdCode code, const char *fmt, ...);
using critical_msg_t = char[ERROR_BUFFER_SIZE]; using critical_msg_t = char[ERROR_BUFFER_SIZE];
@ -33,7 +33,7 @@ using critical_msg_t = char[ERROR_BUFFER_SIZE];
* *
* see also warning() * see also warning()
*/ */
void firmwareError(obd_code_e code, const char *fmt, ...); void firmwareError(ObdCode code, const char *fmt, ...);
extern bool hasFirmwareErrorFlag; extern bool hasFirmwareErrorFlag;

View File

@ -17,7 +17,7 @@ static error_codes_set_s error_codes_set;
/** /**
* @return -1 if code not found * @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 // cycle for searching element equal seaching code
for (int t = 0; t < error_codes_set.count; t++) for (int t = 0; t < error_codes_set.count; t++)
@ -30,14 +30,14 @@ void clearWarnings(void) {
error_codes_set.count = 0; 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) { 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.error_codes[error_codes_set.count] = errorCode;
error_codes_set.count++; error_codes_set.count++;
} }
} }
void removeError(obd_code_e errorCode) { void removeError(ObdCode errorCode) {
int pos = find_position(errorCode); int pos = find_position(errorCode);
if (pos >= 0) { if (pos >= 0) {
// shift all right elements to one pos left // 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[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) { if (isError) {
addError(errorCode); addError(errorCode);
} else { } else {

View File

@ -14,7 +14,7 @@
struct error_codes_set_s { struct error_codes_set_s {
int count = 0; 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' * 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. * @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); void clearWarnings(void);
/** /**

View File

@ -34,4 +34,4 @@
*/ */
EXTERNC int getRemainingStack(thread_t *otp); EXTERNC int getRemainingStack(thread_t *otp);
int CountFreeStackSpace(const void* wabase); 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);

View File

@ -30,7 +30,7 @@
extern bool verboseMode; extern bool verboseMode;
#endif /* EFI_UNIT_TEST */ #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); fixAngle(param, msg, code);
return param; return param;
} }

View File

@ -22,7 +22,7 @@ void setFlatInjectorLag(float value);
#define wrapAngle(angle, msg, code) fixAngle(angle, msg, code) #define wrapAngle(angle, msg, code) fixAngle(angle, msg, code)
// proper method avoids un-wrapped state of variables // 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. * @return time needed to rotate crankshaft by one degree, in milliseconds.

View File

@ -1,7 +1,7 @@
#include "pch.h" #include "pch.h"
// Decode what OBD code we should use for a particular [sensor, code] problem // 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) { switch (type) {
case SensorType::Tps1: case SensorType::Tps1:
case SensorType::Tps1Primary: case SensorType::Tps1Primary:
@ -114,14 +114,14 @@ static void check(SensorType type) {
return; return;
} }
obd_code_e code = getCode(type, result.Code); ObdCode code = getCode(type, result.Code);
if (code != OBD_None) { if (code != OBD_None) {
warning(code, "Sensor fault: %s %s", Sensor::getSensorName(type), describeUnexpected(result.Code)); 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) { if (idx < 0 || idx >= 12) {
return OBD_None; 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`? // TODO: do something more intelligent with `diag`?
UNUSED(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) { if (idx < 0 || idx >= 12) {
return OBD_None; 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`? // TODO: do something more intelligent with `diag`?
UNUSED(diag); UNUSED(diag);
return (obd_code_e)((int)OBD_Ignition_Circuit_1 + idx); return (ObdCode)((int)OBD_Ignition_Circuit_1 + idx);
} }
void SensorChecker::onSlowCallback() { void SensorChecker::onSlowCallback() {

View File

@ -25,7 +25,7 @@ extern "C"
{ {
#endif /* __cplusplus */ #endif /* __cplusplus */
#ifndef __ASSEMBLER__ #ifndef __ASSEMBLER__
void firmwareError(obd_code_e code, const char *fmt, ...); void firmwareError(ObdCode code, const char *fmt, ...);
void irqEnterHook(void); void irqEnterHook(void);
void irqExitHook(void); void irqExitHook(void);
void contextSwitchHook(void); void contextSwitchHook(void);

View File

@ -155,10 +155,10 @@ static void testMalfunctionCentralRemoveFirstElement() {
clearWarnings(); clearWarnings();
error_codes_set_s localCopy; error_codes_set_s localCopy;
obd_code_e firstElement = OBD_TPS1_Correlation; ObdCode firstElement = OBD_TPS1_Correlation;
addError(firstElement); addError(firstElement);
obd_code_e secondElement = OBD_TPS2_Correlation; ObdCode secondElement = OBD_TPS2_Correlation;
addError(secondElement); addError(secondElement);
getErrorCodes(&localCopy); getErrorCodes(&localCopy);
ASSERT_EQ(2, localCopy.count); ASSERT_EQ(2, localCopy.count);
@ -184,7 +184,7 @@ TEST(misc, testMalfunctionCentral) {
getErrorCodes(&localCopy); getErrorCodes(&localCopy);
ASSERT_EQ(0, localCopy.count); ASSERT_EQ(0, localCopy.count);
obd_code_e code = OBD_TPS1_Correlation; ObdCode code = OBD_TPS1_Correlation;
// let's add one error and validate // let's add one error and validate
addError(code); addError(code);
@ -193,7 +193,7 @@ TEST(misc, testMalfunctionCentral) {
ASSERT_EQ(code, localCopy.error_codes[0]); ASSERT_EQ(code, localCopy.error_codes[0]);
// let's remove value which is not in the collection // let's remove value which is not in the collection
removeError((obd_code_e) 22); removeError((ObdCode) 22);
// element not present - nothing to removed // element not present - nothing to removed
ASSERT_EQ(1, localCopy.count); ASSERT_EQ(1, localCopy.count);
ASSERT_EQ(code, localCopy.error_codes[0]); ASSERT_EQ(code, localCopy.error_codes[0]);
@ -204,7 +204,7 @@ TEST(misc, testMalfunctionCentral) {
// todo: ASSERT_EQ(2, localCopy.count); // todo: ASSERT_EQ(2, localCopy.count);
for (int code = 0; code < 100; code++) { for (int code = 0; code < 100; code++) {
addError((obd_code_e) code); addError((ObdCode) code);
} }
getErrorCodes(&localCopy); getErrorCodes(&localCopy);
ASSERT_EQ(MAX_ERROR_CODES_COUNT, localCopy.count); ASSERT_EQ(MAX_ERROR_CODES_COUNT, localCopy.count);