rename obd_code_e -> ObdCode

(cherry picked from commit d6534157a0)
This commit is contained in:
Matthew Kennedy 2023-04-11 16:32:47 -07:00 committed by rusefillc
parent fd4b66f5a1
commit 01f7e4068d
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*/) {

View File

@ -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) {

View File

@ -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

View File

@ -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<warning_t, 8> 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;

View File

@ -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
}

View File

@ -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 <stdexcept>
#endif
void firmwareError(obd_code_e code, const char *fmt, ...) {
void firmwareError(ObdCode code, const char *fmt, ...) {
#if EFI_PROD_CODE
if (hasFirmwareErrorFlag)
return;

View File

@ -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;

View File

@ -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 {

View File

@ -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);
/**

View File

@ -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);

View File

@ -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;
}

View File

@ -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.

View File

@ -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() {

View File

@ -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);

View File

@ -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);