change ObdCode to enum class builds firmware

This commit is contained in:
Matthew Kennedy 2023-04-11 20:01:34 -04:00 committed by rusefillc
parent 01f7e4068d
commit 61e5b4b1ad
120 changed files with 401 additions and 425 deletions

View File

@ -92,7 +92,7 @@ float HellenBoardIdSolver::solve(float Tc1, float Tc2, float x0, float y, float
// since we had https://github.com/rusefi/rusefi/issues/4084 let's add paranoia check
// All real cases seem to converge in <= 5 iterations, so we don't need to try more than 20.
if (!result) {
firmwareError(OBD_PCM_Processor_Fault, "hellen boardID is broken");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "hellen boardID is broken");
return 0;
}

View File

@ -211,7 +211,7 @@ int CanStreamerState::sendDataTimeout(const uint8_t *txbuf, int numBytes, can_sy
#ifdef SERIAL_CAN_DEBUG
PRINT("*** ERROR: CAN Flow Control frame not received" PRINT_EOL);
#endif /* SERIAL_CAN_DEBUG */
//warning(CUSTOM_ERR_CAN_COMMUNICATION, "CAN Flow Control frame not received");
//warning(ObdCode::CUSTOM_ERR_CAN_COMMUNICATION, "CAN Flow Control frame not received");
return 0;
}
receiveFrame(&rxmsg, nullptr, 0, timeout);
@ -225,7 +225,7 @@ int CanStreamerState::sendDataTimeout(const uint8_t *txbuf, int numBytes, can_sy
#ifdef SERIAL_CAN_DEBUG
efiPrintf("*** ERROR: CAN Flow Control mode not supported");
#endif /* SERIAL_CAN_DEBUG */
//warning(CUSTOM_ERR_CAN_COMMUNICATION, "CAN Flow Control mode not supported");
//warning(ObdCode::CUSTOM_ERR_CAN_COMMUNICATION, "CAN Flow Control mode not supported");
return 0;
}
int blockSize = rxmsg.data8[1];
@ -235,7 +235,7 @@ int CanStreamerState::sendDataTimeout(const uint8_t *txbuf, int numBytes, can_sy
#ifdef SERIAL_CAN_DEBUG
efiPrintf("*** ERROR: CAN Flow Control fields not supported");
#endif /* SERIAL_CAN_DEBUG */
//warning(CUSTOM_ERR_CAN_COMMUNICATION, "CAN Flow Control fields not supported");
//warning(ObdCode::CUSTOM_ERR_CAN_COMMUNICATION, "CAN Flow Control fields not supported");
}
break;
}
@ -316,7 +316,7 @@ can_msg_t CanStreamerState::streamAddToTxTimeout(size_t *np, const uint8_t *txbu
can_msg_t CanStreamerState::streamFlushTx(can_sysinterval_t timeout) {
int numSent = sendDataTimeout((const uint8_t *)txFifoBuf.getElements(), txFifoBuf.getCount(), timeout);
if (numSent != txFifoBuf.getCount()) {
//warning(CUSTOM_ERR_CAN_COMMUNICATION, "CAN sendDataTimeout() problems");
//warning(ObdCode::CUSTOM_ERR_CAN_COMMUNICATION, "CAN sendDataTimeout() problems");
}
txFifoBuf.clear();
@ -367,7 +367,7 @@ void CanTsListener::decodeFrame(const CANRxFrame& frame, efitick_t /*nowNt*/) {
PRINT("*** INFO: CanTsListener decodeFrame %d" PRINT_EOL, isoTpPacketCounter++);
}
if (!rxFifo.put(msg)) {
warning(CUSTOM_ERR_CAN_COMMUNICATION, "CAN sendDataTimeout() problems");
warning(ObdCode::CUSTOM_ERR_CAN_COMMUNICATION, "CAN sendDataTimeout() problems");
}
}

View File

@ -156,7 +156,7 @@ void ReturnToothLoggerBuffer(CompositeBuffer* buffer) {
chibios_rt::CriticalSectionLocker csl;
msg_t msg = freeBuffers.postI(buffer);
efiAssertVoid(OBD_PCM_Processor_Fault, msg == MSG_OK, "Composite logger post to free buffer fail");
efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, msg == MSG_OK, "Composite logger post to free buffer fail");
// If the used list is empty, clear the ready flag
if (filledBuffers.getUsedCountI() == 0) {

View File

@ -40,12 +40,12 @@ public:
void CanTsChannel::start() {
if (!getIsCanEnabled()) {
warning(CUSTOM_ERR_CAN_CONFIGURATION, "CAN not enabled");
warning(ObdCode::CUSTOM_ERR_CAN_CONFIGURATION, "CAN not enabled");
return;
}
if (!engineConfiguration->canReadEnabled || !engineConfiguration->canWriteEnabled) {
warning(CUSTOM_ERR_CAN_CONFIGURATION, "CAN read or write not enabled");
warning(ObdCode::CUSTOM_ERR_CAN_CONFIGURATION, "CAN read or write not enabled");
}
}

View File

@ -458,7 +458,7 @@ bool TunerStudio::handlePlainCommand(TsChannelBase* tsChannel, uint8_t command)
TunerStudio tsInstance;
static int tsProcessOne(TsChannelBase* tsChannel) {
validateStack("communication", STACK_USAGE_COMMUNICATION, 128);
validateStack("communication", ObdCode::STACK_USAGE_COMMUNICATION, 128);
if (!tsChannel->isReady()) {
chThdSleepMilliseconds(10);

View File

@ -23,7 +23,7 @@ size_t TsChannelBase::read(uint8_t* buffer, size_t size) {
void TsChannelBase::copyAndWriteSmallCrcPacket(uint8_t responseCode, const uint8_t* buf, size_t size) {
// don't transmit too large a buffer
efiAssertVoid(OBD_PCM_Processor_Fault, !isBigPacket(size), "copyAndWriteSmallCrcPacket tried to transmit too large a packet")
efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, !isBigPacket(size), "copyAndWriteSmallCrcPacket tried to transmit too large a packet")
// If transmitting data, copy it in to place in the scratch buffer
// We want to prevent the data changing itself (higher priority threads could write
@ -37,7 +37,7 @@ void TsChannelBase::copyAndWriteSmallCrcPacket(uint8_t responseCode, const uint8
}
void TsChannelBase::crcAndWriteBuffer(uint8_t responseCode, size_t size) {
efiAssertVoid(OBD_PCM_Processor_Fault, !isBigPacket(size), "crcAndWriteBuffer tried to transmit too large a packet")
efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, !isBigPacket(size), "crcAndWriteBuffer tried to transmit too large a packet")
// Index 0/1 = packet size (big endian)
*(uint16_t*)scratchBuffer = SWAP_UINT16(size + 1);
@ -92,7 +92,7 @@ TsChannelBase::TsChannelBase(const char *name) {
void TsChannelBase::assertPacketSize(size_t size, bool allowLongPackets) {
if (isBigPacket(size) && !allowLongPackets) {
firmwareError(OBD_PCM_Processor_Fault, "[USE PROPER CONSOLE VERSION ] disallowed long packet of size %d", size);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "[USE PROPER CONSOLE VERSION ] disallowed long packet of size %d", size);
}
}

View File

@ -723,9 +723,9 @@ DcHardware *getdcHardware();
#endif
tsOutputChannels->warningCounter = engine->engineState.warnings.warningCounter;
tsOutputChannels->lastErrorCode = engine->engineState.warnings.lastErrorCode;
tsOutputChannels->lastErrorCode = static_cast<uint16_t>(engine->engineState.warnings.lastErrorCode);
for (int i = 0; i < 8;i++) {
tsOutputChannels->recentErrorCode[i] = engine->engineState.warnings.recentWarnings.get(i).Code;
tsOutputChannels->recentErrorCode[i] = static_cast<uint16_t>(engine->engineState.warnings.recentWarnings.get(i).Code);
}
tsOutputChannels->starterState = enginePins.starterControl.getLogicValue();

View File

@ -65,7 +65,7 @@ expected<float> BoostController::getSetpoint() {
return unexpected;
}
efiAssert(OBD_PCM_Processor_Fault, m_closedLoopTargetMap != nullptr, "boost closed loop target", unexpected);
efiAssert(ObdCode::OBD_PCM_Processor_Fault, m_closedLoopTargetMap != nullptr, "boost closed loop target", unexpected);
return m_closedLoopTargetMap->getValue(rpm, driverIntent.Value) * luaTargetMult + luaTargetAdd;
}
@ -83,7 +83,7 @@ expected<percent_t> BoostController::getOpenLoop(float target) {
return unexpected;
}
efiAssert(OBD_PCM_Processor_Fault, m_openLoopMap != nullptr, "boost open loop", unexpected);
efiAssert(ObdCode::OBD_PCM_Processor_Fault, m_openLoopMap != nullptr, "boost open loop", unexpected);
openLoopPart = luaOpenLoopAdd + m_openLoopMap->getValue(rpm, driverIntent.Value);

View File

@ -37,7 +37,7 @@
int clampedFrequency = maxI(100, frequency);
if (clampedFrequency > ETB_HW_MAX_FREQUENCY) {
firmwareError(OBD_PCM_Processor_Fault, "Electronic throttle frequency too high, maximum %d hz", ETB_HW_MAX_FREQUENCY);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Electronic throttle frequency too high, maximum %d hz", ETB_HW_MAX_FREQUENCY);
return;
}

View File

@ -191,7 +191,7 @@ bool EtbController::init(dc_function_e function, DcMotor *motor, pid_s *pidParam
if (!Sensor::isRedundant(m_positionSensor)) {
firmwareError(
OBD_TPS_Configuration,
ObdCode::OBD_TPS_Configuration,
"Use of electronic throttle requires %s to be redundant.",
Sensor::getSensorName(m_positionSensor)
);
@ -202,7 +202,7 @@ bool EtbController::init(dc_function_e function, DcMotor *motor, pid_s *pidParam
if (!Sensor::isRedundant(SensorType::AcceleratorPedal)) {
firmwareError(
OBD_TPS_Configuration,
ObdCode::OBD_TPS_Configuration,
"Use of electronic throttle requires accelerator pedal to be redundant."
);
etbErrorCode = (int8_t)TpsState::Redundancy;
@ -748,7 +748,7 @@ struct EtbImpl final : public TBase {
// Check that the calibrate actually moved the throttle
if (absF(primaryMax - primaryMin) < 0.5f) {
firmwareError(OBD_TPS_Configuration, "Auto calibrate failed, check your wiring!\r\nClosed voltage: %.1fv Open voltage: %.1fv", primaryMin, primaryMax);
firmwareError(ObdCode::OBD_TPS_Configuration, "Auto calibrate failed, check your wiring!\r\nClosed voltage: %.1fv Open voltage: %.1fv", primaryMin, primaryMax);
TBase::m_isAutocal = false;
return;
}
@ -1061,7 +1061,7 @@ void doInitElectronicThrottle() {
if (!engineConfiguration->etb1configured && !engineConfiguration->etb2configured) {
// It's not valid to have a PPS without any ETBs - check that at least one ETB was enabled along with the pedal
if (hasPedal) {
firmwareError(OBD_PCM_Processor_Fault, "A pedal position sensor was configured, but no electronic throttles are configured.");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "A pedal position sensor was configured, but no electronic throttles are configured.");
}
}
@ -1071,7 +1071,7 @@ void doInitElectronicThrottle() {
/**
* Unexpected electronic throttle start-up position is worth a critical error
*/
firmwareError(OBD_Throttle_Actuator_Control_Range_Performance_Bank_1, "startup ETB position %.2f not %d",
firmwareError(ObdCode::OBD_Throttle_Actuator_Control_Range_Performance_Bank_1, "startup ETB position %.2f not %d",
startupThrottlePosition,
engineConfiguration->etbNeutralPosition);
startupPositionError = true;

View File

@ -78,14 +78,14 @@ float GppwmChannel::setOutput(float result) {
}
if (m_usePwm) {
efiAssert(OBD_PCM_Processor_Fault, m_usePwm, "m_usePwm null", 0);
efiAssert(ObdCode::OBD_PCM_Processor_Fault, m_usePwm, "m_usePwm null", 0);
m_pwm->setSimplePwmDutyCycle(clampF(0, result / 100.0f, 1));
return result;
} else {
efiAssert(OBD_PCM_Processor_Fault, m_output, "m_output null", 0);
efiAssert(ObdCode::OBD_PCM_Processor_Fault, m_output, "m_output null", 0);
if (m_config->offBelowDuty > m_config->onAboveDuty) {
firmwareError(CUSTOM_ERR_6122, "You can't have off below %d greater than on above %d",
firmwareError(ObdCode::CUSTOM_ERR_6122, "You can't have off below %d greater than on above %d",
m_config->offBelowDuty,
m_config->onAboveDuty);
}

View File

@ -155,7 +155,7 @@ void initIdleHardware() {
if (engineConfiguration->isDoubleSolenoidIdle) {
if (!isBrainPinValid(engineConfiguration->secondSolenoidPin)) {
firmwareError(OBD_PCM_Processor_Fault, "Second idle pin should be configured for double solenoid mode.");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Second idle pin should be configured for double solenoid mode.");
return;
}

View File

@ -40,11 +40,11 @@ static angle_t getRunningAdvance(int rpm, float engineLoad) {
}
if (cisnan(engineLoad)) {
warning(CUSTOM_NAN_ENGINE_LOAD, "NaN engine load");
warning(ObdCode::CUSTOM_NAN_ENGINE_LOAD, "NaN engine load");
return NAN;
}
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(engineLoad), "invalid el", NAN);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !cisnan(engineLoad), "invalid el", NAN);
// compute base ignition angle from main table
float advanceAngle = interpolate3d(
@ -163,13 +163,13 @@ angle_t getAdvance(int rpm, float engineLoad) {
bool isCranking = engine->rpmCalculator.isCranking();
if (isCranking) {
angle = getCrankingAdvance(rpm, engineLoad);
assertAngleRange(angle, "crAngle", CUSTOM_ERR_ANGLE_CR);
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(angle), "cr_AngleN", 0);
assertAngleRange(angle, "crAngle", ObdCode::CUSTOM_ERR_ANGLE_CR);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !cisnan(angle), "cr_AngleN", 0);
} else {
angle = getRunningAdvance(rpm, engineLoad);
if (cisnan(angle)) {
warning(CUSTOM_ERR_6610, "NaN angle from table");
warning(ObdCode::CUSTOM_ERR_6610, "NaN angle from table");
return 0;
}
}
@ -186,8 +186,8 @@ angle_t getAdvance(int rpm, float engineLoad) {
}
}
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(angle), "_AngleN5", 0);
fixAngle(angle, "getAdvance", CUSTOM_ERR_ADCANCE_CALC_ANGLE);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !cisnan(angle), "_AngleN5", 0);
fixAngle(angle, "getAdvance", ObdCode::CUSTOM_ERR_ADCANCE_CALC_ANGLE);
return angle;
#else
return 0;

View File

@ -15,7 +15,7 @@ float AirmassVeModelBase::getVeLoadAxis(float passedLoad) const {
}
float AirmassVeModelBase::getVe(int rpm, float load) const {
efiAssert(OBD_PCM_Processor_Fault, m_veTable != nullptr, "VE table null", 0);
efiAssert(ObdCode::OBD_PCM_Processor_Fault, m_veTable != nullptr, "VE table null", 0);
// Override the load value if necessary
load = getVeLoadAxis(load);

View File

@ -9,7 +9,7 @@ AirmassResult SpeedDensityAirmass::getAirmass(int rpm) {
*/
float tChargeK = engine->engineState.sd.tChargeK;
if (cisnan(tChargeK)) {
warning(CUSTOM_ERR_TCHARGE_NOT_READY2, "tChargeK not ready"); // this would happen before we have CLT reading for example
warning(ObdCode::CUSTOM_ERR_TCHARGE_NOT_READY2, "tChargeK not ready"); // this would happen before we have CLT reading for example
return {};
}
@ -19,7 +19,7 @@ AirmassResult SpeedDensityAirmass::getAirmass(int rpm) {
float airMass = getAirmassImpl(ve, map, tChargeK);
if (cisnan(airMass)) {
warning(CUSTOM_ERR_6685, "NaN airMass");
warning(ObdCode::CUSTOM_ERR_6685, "NaN airMass");
return {};
}
#if EFI_PRINTF_FUEL_DETAILS

View File

@ -53,7 +53,7 @@ float getInitialAdvance(int rpm, float map, float advanceMax) {
*/
static void buildTimingMap(float advanceMax) {
if (engineConfiguration->fuelAlgorithm != LM_SPEED_DENSITY) {
warning(CUSTOM_WRONG_ALGORITHM, "wrong algorithm for MAP-based timing");
warning(ObdCode::CUSTOM_WRONG_ALGORITHM, "wrong algorithm for MAP-based timing");
return;
}
/**

View File

@ -101,7 +101,7 @@ trigger_type_e getVvtTriggerType(vvt_mode_e vvtMode) {
case VVT_MITSUBISHI_4G63:
return TT_MITSU_4G63_CAM;
default:
firmwareError(OBD_PCM_Processor_Fault, "getVvtTriggerType for %s", getVvt_mode_e(vvtMode));
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "getVvtTriggerType for %s", getVvt_mode_e(vvtMode));
return TT_ONE; // we have to return something for the sake of -Werror=return-type
}
}
@ -411,7 +411,7 @@ void Engine::efiWatchdog() {
if (!getTriggerCentral()->isSpinningJustForWatchdog) {
if (!isRunningBenchTest() && enginePins.stopPins()) {
// todo: make this a firmwareError assuming functional tests would run
warning(CUSTOM_ERR_2ND_WATCHDOG, "Some pins were turned off by 2nd pass watchdog");
warning(ObdCode::CUSTOM_ERR_2ND_WATCHDOG, "Some pins were turned off by 2nd pass watchdog");
}
return;
}

View File

@ -33,7 +33,7 @@ WarningCodeState::WarningCodeState() {
void WarningCodeState::clear() {
warningCounter = 0;
lastErrorCode = 0;
lastErrorCode = ObdCode::None;
recentWarnings.clear();
}
@ -114,7 +114,7 @@ void EngineState::periodicFastCallback() {
#if EFI_ENGINE_CONTROL
if (!engine->slowCallBackWasInvoked) {
warning(CUSTOM_SLOW_NOT_INVOKED, "Slow not invoked yet");
warning(ObdCode::CUSTOM_SLOW_NOT_INVOKED, "Slow not invoked yet");
}
efitick_t nowNt = getTimeNowNt();
@ -255,7 +255,7 @@ bool isLockedFromUser() {
int lock = engineConfiguration->tuneHidingKey;
bool isLocked = lock > 0;
if (isLocked) {
firmwareError(OBD_PCM_Processor_Fault, "password protected");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "password protected");
}
return isLocked;
}

View File

@ -250,7 +250,7 @@ static void initTemperatureCurve(float *bins, float *values, int size, float def
}
void prepareVoidConfiguration(engine_configuration_s *engineConfiguration) {
efiAssertVoid(OBD_PCM_Processor_Fault, engineConfiguration != NULL, "ec NULL");
efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, engineConfiguration != NULL, "ec NULL");
efi::clear(engineConfiguration);
engineConfiguration->clutchDownPinMode = PI_PULLUP;
@ -1003,7 +1003,7 @@ void resetConfigurationExt(configuration_callback_t boardCallback, engine_type_e
break;
#endif //HW_SUBARU_EG33
default:
firmwareError(CUSTOM_UNEXPECTED_ENGINE_TYPE, "Unexpected engine type: %d", engineType);
firmwareError(ObdCode::CUSTOM_UNEXPECTED_ENGINE_TYPE, "Unexpected engine type: %d", engineType);
}
applyNonPersistentConfiguration();
}
@ -1025,7 +1025,7 @@ void validateConfiguration() {
void applyNonPersistentConfiguration() {
#if EFI_PROD_CODE
efiAssertVoid(CUSTOM_APPLY_STACK, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "apply c");
efiAssertVoid(ObdCode::CUSTOM_APPLY_STACK, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "apply c");
efiPrintf("applyNonPersistentConfiguration()");
#endif

View File

@ -45,7 +45,7 @@ public:
struct warning_t {
Timer LastTriggered;
ObdCode Code = OBD_None;
ObdCode Code = ObdCode::None;
warning_t() { }
@ -75,7 +75,7 @@ public:
bool isWarningNow(ObdCode code) const;
void clear();
int warningCounter;
int lastErrorCode;
ObdCode lastErrorCode = ObdCode::None;
Timer timeSinceLastWarning;

View File

@ -57,7 +57,7 @@ expected<float> InjectorModel::getAbsoluteRailPressure() const {
return engineConfiguration->fuelReferencePressure + Sensor::get(SensorType::BarometricPressure).value_or(101.325f);
case ICM_SensedRailPressure:
if (!Sensor::hasSensor(SensorType::FuelPressureInjector)) {
firmwareError(OBD_PCM_Processor_Fault, "Fuel pressure compensation is set to use a pressure sensor, but none is configured.");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Fuel pressure compensation is set to use a pressure sensor, but none is configured.");
return unexpected;
}
@ -77,7 +77,7 @@ float InjectorModel::getInjectorFlowRatio() {
if (referencePressure < 50) {
// impossibly low fuel ref pressure
firmwareError(OBD_PCM_Processor_Fault, "Impossible fuel reference pressure: %f", referencePressure);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Impossible fuel reference pressure: %f", referencePressure);
return 1.0f;
}

View File

@ -65,7 +65,7 @@ float getCrankingFuel3(
bool alreadyWarned = false;
if (e0Mult <= 0.1f) {
warning(CUSTOM_ERR_ZERO_E0_MULT, "zero e0 multiplier");
warning(ObdCode::CUSTOM_ERR_ZERO_E0_MULT, "zero e0 multiplier");
alreadyWarned = true;
}
@ -73,7 +73,7 @@ float getCrankingFuel3(
auto e85Mult = interpolate2d(clt, config->crankingFuelBins, config->crankingFuelCoefE100);
if (e85Mult <= 0.1f) {
warning(CUSTOM_ERR_ZERO_E85_MULT, "zero e85 multiplier");
warning(ObdCode::CUSTOM_ERR_ZERO_E85_MULT, "zero e85 multiplier");
alreadyWarned = true;
}
@ -105,7 +105,7 @@ float getCrankingFuel3(
// don't re-warn for zero fuel when we already warned for a more specific problem
if (!alreadyWarned && crankingFuel <= 0) {
warning(CUSTOM_ERR_ZERO_CRANKING_FUEL, "Cranking fuel value %f", crankingFuel);
warning(ObdCode::CUSTOM_ERR_ZERO_CRANKING_FUEL, "Cranking fuel value %f", crankingFuel);
}
return crankingFuel;
}
@ -123,9 +123,9 @@ float getRunningFuel(float baseFuel) {
float baroCorrection = engine->engineState.baroCorrection;
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);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !cisnan(iatCorrection), "NaN iatCorrection", 0);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !cisnan(cltCorrection), "NaN cltCorrection", 0);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !cisnan(postCrankingFuelCorrection), "NaN postCrankingFuelCorrection", 0);
float correction = baroCorrection * iatCorrection * cltCorrection * postCrankingFuelCorrection;
@ -143,7 +143,7 @@ float getRunningFuel(float baseFuel) {
float runningFuel = baseFuel * correction;
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(runningFuel), "NaN runningFuel", 0);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !cisnan(runningFuel), "NaN runningFuel", 0);
engine->fuelComputer.running.fuel = runningFuel * 1000;
@ -166,7 +166,7 @@ AirmassModelBase* getAirmassModel(engine_load_mode_e mode) {
case LM_MOCK: return engine->mockAirmassModel;
#endif
default:
firmwareError(CUSTOM_ERR_ASSERT, "Invalid airmass mode %d", engineConfiguration->fuelAlgorithm);
firmwareError(ObdCode::CUSTOM_ERR_ASSERT, "Invalid airmass mode %d", engineConfiguration->fuelAlgorithm);
return nullptr;
}
}
@ -177,7 +177,7 @@ static float getBaseFuelMass(int rpm) {
// airmass modes - get airmass first, then convert to fuel
auto model = getAirmassModel(engineConfiguration->fuelAlgorithm);
efiAssert(CUSTOM_ERR_ASSERT, model != nullptr, "Invalid airmass mode", 0.0f);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, model != nullptr, "Invalid airmass mode", 0.0f);
auto airmass = model->getAirmass(rpm);
@ -224,12 +224,12 @@ angle_t getInjectionOffset(float rpm, float load) {
if (cisnan(value)) {
// we could be here while resetting configuration for example
// huh? what? when do we have RPM while resetting configuration? is that CI edge case? shall we fix CI?
warning(CUSTOM_ERR_6569, "phase map not ready");
warning(ObdCode::CUSTOM_ERR_6569, "phase map not ready");
return 0;
}
angle_t result = value;
fixAngle(result, "inj offset#2", CUSTOM_ERR_6553);
fixAngle(result, "inj offset#2", ObdCode::CUSTOM_ERR_6553);
return result;
}
@ -247,7 +247,7 @@ int getNumberOfInjections(injection_mode_e mode) {
case IM_SEQUENTIAL:
return 1;
default:
firmwareError(CUSTOM_ERR_INVALID_INJECTION_MODE, "Unexpected injection_mode_e %d", mode);
firmwareError(ObdCode::CUSTOM_ERR_INVALID_INJECTION_MODE, "Unexpected injection_mode_e %d", mode);
return 1;
}
}
@ -272,7 +272,7 @@ float getInjectionModeDurationMultiplier() {
case IM_BATCH:
return 0.5f;
default:
firmwareError(CUSTOM_ERR_INVALID_INJECTION_MODE, "Unexpected injection_mode_e %d", mode);
firmwareError(ObdCode::CUSTOM_ERR_INVALID_INJECTION_MODE, "Unexpected injection_mode_e %d", mode);
return 0;
}
}
@ -308,7 +308,7 @@ float getInjectionMass(int rpm) {
bool isCranking = engine->rpmCalculator.isCranking();
float cycleFuelMass = getCycleFuelMass(isCranking, baseFuelMass);
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(cycleFuelMass), "NaN cycleFuelMass", 0);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !cisnan(cycleFuelMass), "NaN cycleFuelMass", 0);
if (engine->module<DfcoController>()->cutFuel()) {
// If decel fuel cut, zero out fuel
@ -322,7 +322,7 @@ float getInjectionMass(int rpm) {
engine->module<InjectorModel>()->prepare();
floatms_t tpsAccelEnrich = engine->tpsAccelEnrichment.getTpsEnrichment();
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(tpsAccelEnrich), "NaN tpsAccelEnrich", 0);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !cisnan(tpsAccelEnrich), "NaN tpsAccelEnrich", 0);
engine->engineState.tpsAccelEnrich = tpsAccelEnrich;
// For legacy reasons, the TPS accel table is in units of milliseconds, so we have to convert BACK to mass
@ -387,7 +387,7 @@ float getBaroCorrection() {
);
if (cisnan(correction) || correction < 0.01) {
warning(OBD_Barometric_Press_Circ_Range_Perf, "Invalid baro correction %f", correction);
warning(ObdCode::OBD_Barometric_Press_Circ_Range_Perf, "Invalid baro correction %f", correction);
return 1;
}

View File

@ -15,14 +15,14 @@ void GearDetector::onConfigurationChange(engine_configuration_s const * /*previo
}
if (gearCount > GEARS_COUNT) {
firmwareError(OBD_PCM_Processor_Fault, "too many gears");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "too many gears");
return;
}
// validate gears
for (size_t i = 0; i < gearCount; i++) {
if (engineConfiguration->gearRatio[i] <= 0) {
firmwareError(OBD_PCM_Processor_Fault, "Invalid gear ratio for #%d", i + 1);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Invalid gear ratio for #%d", i + 1);
return;
}
}
@ -33,7 +33,7 @@ void GearDetector::onConfigurationChange(engine_configuration_s const * /*previo
float gearIplusOne = engineConfiguration->gearRatio[i + 1];
if (gearI <= gearIplusOne) {
firmwareError(OBD_PCM_Processor_Fault, "Invalid gear ordering near gear #%d", i + 1);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Invalid gear ordering near gear #%d", i + 1);
}
m_gearThresholds[i] = geometricMean(gearI, gearIplusOne);

View File

@ -10,15 +10,10 @@
#pragma once
// this header should not depend on anything - actually chconf.h usually depends on this header
#include <cstdint>
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
typedef enum {
OBD_None = 0,
enum class ObdCode : uint32_t {
None = 0,
//P0001 Fuel Volume Regulator Control Circuit/Open
//P0002 Fuel Volume Regulator Control Circuit Range/Performance
//P0003 Fuel Volume Regulator Control Circuit Low
@ -2069,7 +2064,7 @@ typedef enum {
CUSTOM_VVT_SYNC_POSITION = 6675,
CUSTOM_STACK_ADC = 6676,
CUSTOM_IH_STACK = 6677,
CUSTOM_EC_NULL = 6678,
CUSTOM_ERR_6678 = 6678,
CUSTOM_ERR6679 = 6679,
CUSTOM_ERR_ANGLE_CR = 6680,
@ -2120,7 +2115,7 @@ typedef enum {
CUSTOM_NO_ETB_FOR_IDLE = 6723,
CUSTOM_ERR_TLE8888_RESPONSE = 6724,
CUSTOM_ERR_CJ125_DIAG = 6725,
NO_LONGER_USED_CUSTOM_ERR_VVT_OUT_OF_RANGE = 6726,
CUSTOM_6726 = 6726,
CUSTOM_VVT_MODE_NOT_SELECTED = 6727,
CUSTOM_ERR_6728 = 6728,
CUSTOM_ARTIFICIAL_MISFIRE = 6729,
@ -2139,7 +2134,7 @@ typedef enum {
WATCH_DOG_SECONDS = 8901,
CUSTOM_ERR_CUSTOM_GAPS_BAD = 8999,
CUSTOM_ERR_CUSTOM_GAPS_BAD = 8999,
CUSTOM_ERR_TRIGGER_SYNC = 9000,
CUSTOM_OBD_TRIGGER_WAVEFORM = 9001,
@ -2174,17 +2169,4 @@ typedef enum {
* Commanded fuel exceeds your fuel injector flow
*/
CUSTOM_TOO_LONG_FUEL_INJECTION = 9013,
// Back in the day we wanted enums to be 32 bit integers.
// 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,
} ObdCode;
#ifdef __cplusplus
}
#endif /* __cplusplus */
};

View File

@ -83,7 +83,7 @@ static void runBench(brain_pin_e brainPin, OutputPin *output, float startDelayMs
int offTimeUs = MS2US(maxF(0.1, offTimeMs));
if (onTimeUs > TOO_FAR_INTO_FUTURE_US) {
firmwareError(CUSTOM_ERR_BENCH_PARAM, "onTime above limit %dus", TOO_FAR_INTO_FUTURE_US);
firmwareError(ObdCode::CUSTOM_ERR_BENCH_PARAM, "onTime above limit %dus", TOO_FAR_INTO_FUTURE_US);
return;
}
@ -280,7 +280,7 @@ private:
UNUSED(nowNt);
setPeriod(50 /* ms */);
validateStack("Bench", STACK_USAGE_BENCH, 128);
validateStack("Bench", ObdCode::STACK_USAGE_BENCH, 128);
// naive inter-thread communication - waiting for a flag
if (isBenchTestPending) {
@ -334,7 +334,7 @@ static void handleBenchCategory(uint16_t index) {
fan2Bench();
return;
default:
firmwareError(OBD_PCM_Processor_Fault, "Unexpected bench function %d", index);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Unexpected bench function %d", index);
}
}
@ -412,7 +412,7 @@ static void handleCommandX14(uint16_t index) {
sys_dual_bank();
rebootNow();
#else
firmwareError(OBD_PCM_Processor_Fault, "Unexpected dbank command", index);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Unexpected dbank command", index);
#endif
return;
case 0x15:
@ -422,7 +422,7 @@ static void handleCommandX14(uint16_t index) {
#endif // EFI_PROD_CODE
return;
default:
firmwareError(OBD_PCM_Processor_Fault, "Unexpected bench x14 %d", index);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Unexpected bench x14 %d", index);
}
}
@ -430,7 +430,7 @@ extern bool rebootForPresetPending;
static void fatalErrorForPresetApply() {
rebootForPresetPending = true;
firmwareError(OBD_PCM_Processor_Fault,
firmwareError(ObdCode::OBD_PCM_Processor_Fault,
"\n\nTo complete preset apply:\n"
" 1. Close TunerStudio\n"
" 2. Power cycle ECU\n"
@ -526,7 +526,7 @@ void executeTSCommand(uint16_t subsystem, uint16_t index) {
#endif
default:
firmwareError(OBD_PCM_Processor_Fault, "Unexpected bench subsystem %d %d", subsystem, index);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Unexpected bench subsystem %d %d", subsystem, index);
}
}

View File

@ -170,7 +170,7 @@ void updateDash(CanCycle cycle) {
canDashboardAim(cycle);
break;
default:
firmwareError(OBD_PCM_Processor_Fault, "Nothing for canNbcType %s", getCan_nbc_e(engineConfiguration->canNbcType));
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Nothing for canNbcType %s", getCan_nbc_e(engineConfiguration->canNbcType));
break;
}
}

View File

@ -39,7 +39,7 @@ struct Status {
static void populateFrame(Status& msg) {
msg.warningCounter = engine->engineState.warnings.warningCounter;
msg.lastErrorCode = engine->engineState.warnings.lastErrorCode;
msg.lastErrorCode = static_cast<uint16_t>(engine->engineState.warnings.lastErrorCode);
msg.revLimit = Sensor::getOrZero(SensorType::Rpm) > engineConfiguration->rpmHardLimit;
msg.mainRelay = enginePins.mainRelay.getLogicValue();

View File

@ -26,7 +26,7 @@ expected<uint16_t> look_up_can_id(can_vss_nbc_e type) {
case LUA:
return 0; // a bit of a hack
default:
firmwareError(OBD_Vehicle_Speed_SensorB, "Wrong Can DBC selected: %d", type);
firmwareError(ObdCode::OBD_Vehicle_Speed_SensorB, "Wrong Can DBC selected: %d", type);
return unexpected;
}
}

View File

@ -76,7 +76,7 @@ static void obdSendPacket(int mode, int PID, int numBytes, uint32_t iValue, size
#define _1_MODE 1
static void obdSendValue(int mode, int PID, int numBytes, float value, size_t busIndex) {
efiAssertVoid(CUSTOM_ERR_6662, numBytes <= 2, "invalid numBytes");
efiAssertVoid(ObdCode::CUSTOM_ERR_6662, numBytes <= 2, "invalid numBytes");
int iValue = (int)efiRound(value, 1.0f);
// clamp to uint8_t (0..255) or uint16_t (0..65535)
iValue = maxI(minI(iValue, (numBytes == 1) ? 255 : 65535), 0);
@ -174,7 +174,7 @@ static void handleGetDataRequest(const CANRxFrame& rx, size_t busIndex) {
}
}
static void handleDtcRequest(int numCodes, int *dtcCode) {
static void handleDtcRequest(int numCodes, ObdCode* dtcCode) {
// TODO: this appears to be unfinished?
UNUSED(numCodes);
UNUSED(dtcCode);

View File

@ -124,7 +124,7 @@ void setWidebandOffset(uint8_t index) {
}
if (!waitAck()) {
firmwareError(OBD_PCM_Processor_Fault, "Wideband index set failed: no controller detected!");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Wideband index set failed: no controller detected!");
}
waitingBootloaderThread = nullptr;

View File

@ -94,7 +94,7 @@ void chDbgPanic3(const char *msg, const char * file, int line) {
exit(-1);
#else // EFI_PROD_CODE
firmwareError(OBD_PCM_Processor_Fault, "assert fail %s %s:%d", msg, file, line);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "assert fail %s %s:%d", msg, file, line);
// If on the main thread, longjmp back to the init process so we can keep USB alive
if (chThdGetSelfX()->threadId == 0) {
@ -123,7 +123,7 @@ WarningCodeState unitTestWarningCodeState;
#endif /* EFI_SIMULATOR || EFI_PROD_CODE */
/**
* OBD_PCM_Processor_Fault is the general error code for now
* ObdCode::OBD_PCM_Processor_Fault is the general error code for now
*
* @returns TRUE in case there were warnings recently
*/

View File

@ -10,7 +10,7 @@
#include "trigger_structure.h"
void MultiChannelStateSequence::checkSwitchTimes(const float scale) const {
efiAssertVoid(CUSTOM_ERR_WAVE_1, phaseCount > 0, "StateSequence cannot be empty");
efiAssertVoid(ObdCode::CUSTOM_ERR_WAVE_1, phaseCount > 0, "StateSequence cannot be empty");
if (getSwitchTime(phaseCount - 1) != 1) {
#if EFI_UNIT_TEST
for (int index = 0;index < phaseCount;index ++) {
@ -18,7 +18,7 @@ void MultiChannelStateSequence::checkSwitchTimes(const float scale) const {
}
#endif // EFI_UNIT_TEST
firmwareError(CUSTOM_ERR_WAVE_1, "[count=%d] last switch time has to be 1/%f not %.2f/%f",
firmwareError(ObdCode::CUSTOM_ERR_WAVE_1, "[count=%d] last switch time has to be 1/%f not %.2f/%f",
phaseCount,
scale, getSwitchTime(phaseCount - 1),
scale * getSwitchTime(phaseCount - 1));
@ -26,7 +26,7 @@ void MultiChannelStateSequence::checkSwitchTimes(const float scale) const {
}
for (int i = 0; i < phaseCount - 1; i++) {
if (getSwitchTime(i) >= getSwitchTime(i + 1)) {
firmwareError(CUSTOM_ERR_WAVE_2, "invalid switchTimes @%d: %.2f/%.2f",
firmwareError(ObdCode::CUSTOM_ERR_WAVE_2, "invalid switchTimes @%d: %.2f/%.2f",
i, getSwitchTime(i), getSwitchTime(i + 1));
}
}

View File

@ -81,7 +81,7 @@ public:
pin_state_t getChannelState(int channelIndex, int phaseIndex) const override {
if (channelIndex >= waveCount) {
// todo: would be nice to get this asserting working
//firmwareError(OBD_PCM_Processor_Fault, "channel index %d/%d", channelIndex, waveCount);
//firmwareError(ObdCode::OBD_PCM_Processor_Fault, "channel index %d/%d", channelIndex, waveCount);
}
return ((waveForm[phaseIndex] >> channelIndex) & 1) ? TriggerValue::RISE : TriggerValue::FALL;
}
@ -97,7 +97,7 @@ public:
void setChannelState(const int channelIndex, const int phaseIndex, pin_state_t state) {
if (channelIndex >= waveCount) {
// todo: would be nice to get this asserting working
//firmwareError(OBD_PCM_Processor_Fault, "channel index %d/%d", channelIndex, waveCount);
//firmwareError(ObdCode::OBD_PCM_Processor_Fault, "channel index %d/%d", channelIndex, waveCount);
}
uint8_t & ref = waveForm[phaseIndex];
ref = (ref & ~(1U << channelIndex)) | ((state == TriggerValue::RISE ? 1 : 0) << channelIndex);

View File

@ -176,7 +176,7 @@ static void resetAccel() {
static void doPeriodicSlowCallback() {
#if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
efiAssertVoid(CUSTOM_ERR_6661, getCurrentRemainingStack() > 64, "lowStckOnEv");
efiAssertVoid(ObdCode::CUSTOM_ERR_6661, getCurrentRemainingStack() > 64, "lowStckOnEv");
slowStartStopButtonCallback();
@ -490,7 +490,7 @@ void commonInitEngineController() {
// Returns false if there's an obvious problem with the loaded configuration
bool validateConfig() {
if (engineConfiguration->cylindersCount > MAX_CYLINDER_COUNT) {
firmwareError(OBD_PCM_Processor_Fault, "Invalid cylinder count: %d", engineConfiguration->cylindersCount);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Invalid cylinder count: %d", engineConfiguration->cylindersCount);
return false;
}

View File

@ -55,11 +55,11 @@ static float getInjectionAngleCorrection(float fuelMs, float oneDegreeUs) {
return 0;
}
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(fuelMs), "NaN fuelMs", false);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !cisnan(fuelMs), "NaN fuelMs", false);
angle_t injectionDurationAngle = MS2US(fuelMs) / oneDegreeUs;
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(injectionDurationAngle), "NaN injectionDurationAngle", false);
assertAngleRange(injectionDurationAngle, "injectionDuration_r", CUSTOM_INJ_DURATION);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !cisnan(injectionDurationAngle), "NaN injectionDurationAngle", false);
assertAngleRange(injectionDurationAngle, "injectionDuration_r", ObdCode::CUSTOM_INJ_DURATION);
if (mode == InjectionTimingMode::Center) {
// Center of injection is half-corrected for duration
@ -96,15 +96,15 @@ expected<float> InjectionEvent::computeInjectionAngle(int cylinderIndex) const {
}
angle_t openingAngle = injectionOffset - injectionDurationAngle;
assertAngleRange(openingAngle, "openingAngle_r", CUSTOM_ERR_6554);
assertAngleRange(openingAngle, "openingAngle_r", ObdCode::CUSTOM_ERR_6554);
// Convert from cylinder-relative to cylinder-1-relative
openingAngle += getPerCylinderFiringOrderOffset(cylinderIndex, cylinderNumber);
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(openingAngle), "findAngle#3", false);
assertAngleRange(openingAngle, "findAngle#a33", CUSTOM_ERR_6544);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !cisnan(openingAngle), "findAngle#3", false);
assertAngleRange(openingAngle, "findAngle#a33", ObdCode::CUSTOM_ERR_6544);
wrapAngle2(openingAngle, "addFuel#2", CUSTOM_ERR_6555, getEngineCycle(getEngineRotationState()->getOperationMode()));
wrapAngle2(openingAngle, "addFuel#2", ObdCode::CUSTOM_ERR_6555, getEngineCycle(getEngineRotationState()->getOperationMode()));
#if EFI_UNIT_TEST
printf("registerInjectionEvent openingAngle=%.2f inj %d\r\n", openingAngle, cylinderNumber);
@ -155,7 +155,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i) {
// Loop over the first half of the firing order twice
injectorIndex = i % (engineConfiguration->cylindersCount / 2);
} else {
firmwareError(CUSTOM_OBD_UNEXPECTED_INJECTION_MODE, "Unexpected injection mode %d", mode);
firmwareError(ObdCode::CUSTOM_OBD_UNEXPECTED_INJECTION_MODE, "Unexpected injection mode %d", mode);
injectorIndex = 0;
}

View File

@ -162,7 +162,7 @@ void HpfpController::onFastCallback() {
m_deadtime = 0;
} else {
#if EFI_PROD_CODE && EFI_SHAFT_POSITION_INPUT
efiAssertVoid(OBD_PCM_Processor_Fault, engine->triggerCentral.triggerShape.getSize() > engineConfiguration->hpfpCamLobes * 6, "Too few trigger tooth for this number of HPFP lobes");
efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, engine->triggerCentral.triggerShape.getSize() > engineConfiguration->hpfpCamLobes * 6, "Too few trigger tooth for this number of HPFP lobes");
#endif // EFI_PROD_CODE
// Convert deadtime from ms to degrees based on current RPM
float deadtime_ms = interpolate2d(

View File

@ -103,7 +103,7 @@ void InjectionEvent::onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase
*/
int numberOfInjections = isCranking ? getNumberOfInjections(engineConfiguration->crankingInjectionMode) : getNumberOfInjections(engineConfiguration->injectionMode);
if (injectionDuration * numberOfInjections > getEngineCycleDuration(rpm)) {
warning(CUSTOM_TOO_LONG_FUEL_INJECTION, "Too long fuel injection %.2fms", injectionDuration);
warning(ObdCode::CUSTOM_TOO_LONG_FUEL_INJECTION, "Too long fuel injection %.2fms", injectionDuration);
}
getEngineState()->fuelConsumption.consumeFuel(injectionMassGrams * numberOfInjections, nowNt);
@ -113,11 +113,11 @@ void InjectionEvent::onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase
}
if (cisnan(injectionDuration)) {
warning(CUSTOM_OBD_NAN_INJECTION, "NaN injection pulse");
warning(ObdCode::CUSTOM_OBD_NAN_INJECTION, "NaN injection pulse");
return;
}
if (injectionDuration < 0) {
warning(CUSTOM_OBD_NEG_INJECTION, "Negative injection pulse %.2f", injectionDuration);
warning(ObdCode::CUSTOM_OBD_NEG_INJECTION, "Negative injection pulse %.2f", injectionDuration);
return;
}
@ -141,7 +141,7 @@ void InjectionEvent::onTriggerTooth(int rpm, efitick_t nowNt, float currentPhase
if (engine->prevOutputName == outputName
&& engineConfiguration->injectionMode != IM_SIMULTANEOUS
&& engineConfiguration->injectionMode != IM_SINGLE_POINT) {
warning(CUSTOM_OBD_SKIPPED_FUEL, "looks like skipped fuel event revCounter=%d %s", getRevolutionCounter(), outputName);
warning(ObdCode::CUSTOM_OBD_SKIPPED_FUEL, "looks like skipped fuel event revCounter=%d %s", getRevolutionCounter(), outputName);
}
engine->prevOutputName = outputName;
}
@ -203,7 +203,7 @@ if (isScheduled) {
static void handleFuel(int rpm, efitick_t nowNt, float currentPhase, float nextPhase) {
ScopePerf perf(PE::HandleFuel);
efiAssertVoid(CUSTOM_STACK_6627, getCurrentRemainingStack() > 128, "lowstck#3");
efiAssertVoid(ObdCode::CUSTOM_STACK_6627, getCurrentRemainingStack() > 128, "lowstck#3");
LimpState limitedFuelState = getLimpManager()->allowInjection();
@ -258,7 +258,7 @@ void mainTriggerCallback(uint32_t trgEventIndex, efitick_t edgeTimestamp, angle_
return;
}
if (rpm == NOISY_RPM) {
warning(OBD_Crankshaft_Position_Sensor_A_Circuit_Malfunction, "noisy trigger");
warning(ObdCode::OBD_Crankshaft_Position_Sensor_A_Circuit_Malfunction, "noisy trigger");
// TODO: add 'pin shutdown' invocation somewhere - coils might be still open here!
return;
}

View File

@ -59,7 +59,7 @@ static void endAveraging(MapAverager* arg);
static size_t currentMapAverager = 0;
static void startAveraging(scheduling_s *endAveragingScheduling) {
efiAssertVoid(CUSTOM_ERR_6649, getCurrentRemainingStack() > 128, "lowstck#9");
efiAssertVoid(ObdCode::CUSTOM_ERR_6649, getCurrentRemainingStack() > 128, "lowstck#9");
// TODO: set currentMapAverager based on cylinder bank
auto& averager = getMapAvg(currentMapAverager);
@ -114,7 +114,7 @@ void MapAverager::stop() {
setValidValue(minPressure, getTimeNowNt());
} else {
warning(CUSTOM_UNEXPECTED_MAP_VALUE, "No MAP values");
warning(ObdCode::CUSTOM_UNEXPECTED_MAP_VALUE, "No MAP values");
}
}
@ -126,13 +126,13 @@ void MapAverager::stop() {
* as fast as possible
*/
void mapAveragingAdcCallback(float instantVoltage) {
efiAssertVoid(CUSTOM_ERR_6650, getCurrentRemainingStack() > 128, "lowstck#9a");
efiAssertVoid(ObdCode::CUSTOM_ERR_6650, getCurrentRemainingStack() > 128, "lowstck#9a");
SensorResult mapResult = getMapAvg(currentMapAverager).submit(instantVoltage);
if (!mapResult) {
// hopefully this warning is not too much CPU consumption for fast ADC callback
warning(CUSTOM_INSTANT_MAP_DECODING, "Invalid MAP at %f", instantVoltage);
warning(ObdCode::CUSTOM_INSTANT_MAP_DECODING, "Invalid MAP at %f", instantVoltage);
}
float instantMap = mapResult.value_or(0);
@ -170,19 +170,19 @@ void refreshMapAveragingPreCalc() {
if (isValidRpm(rpm)) {
MAP_sensor_config_s * c = &engineConfiguration->map;
angle_t start = interpolate2d(rpm, c->samplingAngleBins, c->samplingAngle);
efiAssertVoid(CUSTOM_ERR_MAP_START_ASSERT, !cisnan(start), "start");
efiAssertVoid(ObdCode::CUSTOM_ERR_MAP_START_ASSERT, !cisnan(start), "start");
angle_t offsetAngle = engine->triggerCentral.triggerFormDetails.eventAngles[engineConfiguration->mapAveragingSchedulingAtIndex];
efiAssertVoid(CUSTOM_ERR_MAP_AVG_OFFSET, !cisnan(offsetAngle), "offsetAngle");
efiAssertVoid(ObdCode::CUSTOM_ERR_MAP_AVG_OFFSET, !cisnan(offsetAngle), "offsetAngle");
for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
angle_t cylinderOffset = getEngineCycle(getEngineRotationState()->getOperationMode()) * i / engineConfiguration->cylindersCount;
efiAssertVoid(CUSTOM_ERR_MAP_CYL_OFFSET, !cisnan(cylinderOffset), "cylinderOffset");
efiAssertVoid(ObdCode::CUSTOM_ERR_MAP_CYL_OFFSET, !cisnan(cylinderOffset), "cylinderOffset");
// part of this formula related to specific cylinder offset is never changing - we can
// move the loop into start-up calculation and not have this loop as part of periodic calculation
// todo: change the logic as described above in order to reduce periodic CPU usage?
float cylinderStart = start + cylinderOffset - offsetAngle + tdcPosition();
fixAngle(cylinderStart, "cylinderStart", CUSTOM_ERR_6562);
fixAngle(cylinderStart, "cylinderStart", ObdCode::CUSTOM_ERR_6562);
engine->engineState.mapAveragingStart[i] = cylinderStart;
}
engine->engineState.mapAveragingDuration = interpolate2d(rpm, c->samplingWindowBins, c->samplingWindow);
@ -224,9 +224,9 @@ void mapAveragingTriggerCallback(
angle_t samplingDuration = engine->engineState.mapAveragingDuration;
// todo: this assertion could be moved out of trigger handler
assertAngleRange(samplingDuration, "samplingDuration", CUSTOM_ERR_6563);
assertAngleRange(samplingDuration, "samplingDuration", ObdCode::CUSTOM_ERR_6563);
if (samplingDuration <= 0) {
warning(CUSTOM_MAP_ANGLE_PARAM, "map sampling angle should be positive");
warning(ObdCode::CUSTOM_MAP_ANGLE_PARAM, "map sampling angle should be positive");
return;
}
@ -234,12 +234,12 @@ void mapAveragingTriggerCallback(
if (cisnan(samplingEnd)) {
// todo: when would this happen?
warning(CUSTOM_ERR_6549, "no map angles");
warning(ObdCode::CUSTOM_ERR_6549, "no map angles");
return;
}
// todo: pre-calculate samplingEnd for each cylinder
fixAngle(samplingEnd, "samplingEnd", CUSTOM_ERR_6563);
fixAngle(samplingEnd, "samplingEnd", ObdCode::CUSTOM_ERR_6563);
// only if value is already prepared
int structIndex = getRevolutionCounter() % 2;

View File

@ -378,7 +378,7 @@ void tdcMarkCallback(
if (isValidRpm(rpm)) {
angle_t tdcPosition = tdcPosition();
// we need a positive angle offset here
fixAngle(tdcPosition, "tdcPosition", CUSTOM_ERR_6553);
fixAngle(tdcPosition, "tdcPosition", ObdCode::CUSTOM_ERR_6553);
scheduleByAngle(&engine->tdcScheduler[revIndex2], edgeTimestamp, tdcPosition, onTdcCallback);
}
}

View File

@ -139,13 +139,13 @@ int eraseAndFlashCopy(flashaddr_t storageAddress, const TStorage& data) {
auto err = intFlashErase(storageAddress, sizeof(TStorage));
if (FLASH_RETURN_SUCCESS != err) {
firmwareError(OBD_PCM_Processor_Fault, "Failed to erase flash at 0x%08x: %d", storageAddress, err);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Failed to erase flash at 0x%08x: %d", storageAddress, err);
return err;
}
err = intFlashWrite(storageAddress, reinterpret_cast<const char*>(&data), sizeof(TStorage));
if (FLASH_RETURN_SUCCESS != err) {
firmwareError(OBD_PCM_Processor_Fault, "Failed to write flash at 0x%08x: %d", storageAddress, err);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Failed to write flash at 0x%08x: %d", storageAddress, err);
return err;
}
@ -312,7 +312,7 @@ void readFromFlash() {
switch (result) {
case FlashState::CrcFailed:
warning(CUSTOM_ERR_FLASH_CRC_FAILED, "flash CRC failed");
warning(ObdCode::CUSTOM_ERR_FLASH_CRC_FAILED, "flash CRC failed");
efiPrintf("Need to reset flash to default due to CRC mismatch");
[[fallthrough]];
case FlashState::BlankChip:

View File

@ -84,7 +84,7 @@ private:
void PeriodicTask(efitick_t nowNt) override {
UNUSED(nowNt);
validateStack("MIL", STACK_USAGE_MIL, 128);
validateStack("MIL", ObdCode::STACK_USAGE_MIL, 128);
#if EFI_SHAFT_POSITION_INPUT
if (nowNt - engine->triggerCentral.triggerState.mostRecentSyncTime < MS2NT(500)) {
enginePins.checkEnginePin.setValue(1);
@ -97,7 +97,7 @@ private:
getErrorCodes(&localErrorCopy);
for (int p = 0; p < localErrorCopy.count; p++) {
// Calculate how many digits in this integer and display error code from start to end
int code = localErrorCopy.error_codes[p];
int code = (int)localErrorCopy.error_codes[p];
DisplayErrorCode(DigitLength(code), code);
}
#endif // EFI_SHAFT_POSITION_INPUT
@ -108,8 +108,8 @@ static MILController instance;
#if TEST_MIL_CODE
static void testMil() {
addError(OBD_Engine_Coolant_Temperature_Circuit_Malfunction);
addError(OBD_Intake_Air_Temperature_Circuit_Malfunction);
addError(ObdCode::OBD_Engine_Coolant_Temperature_Circuit_Malfunction);
addError(ObdCode::OBD_Intake_Air_Temperature_Circuit_Malfunction);
}
#endif /* TEST_MIL_CODE */

View File

@ -38,7 +38,7 @@ void tachSignalCallback() {
int periods = engineConfiguration->tachPulsePerRev;
if (periods == 0 || periods > 10) {
firmwareError(CUSTOM_ERR_6709, "Invalid tachometer pulse per rev: %d", periods);
firmwareError(ObdCode::CUSTOM_ERR_6709, "Invalid tachometer pulse per rev: %d", periods);
return;
}

View File

@ -28,7 +28,7 @@ void resetLuaCanRx() {
void addLuaCanRxFilter(int32_t eid, uint32_t mask, int bus, int callback) {
if (filterCount >= maxFilterCount) {
firmwareError(OBD_PCM_Processor_Fault, "Too many Lua CAN RX filters");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Too many Lua CAN RX filters");
}
efiPrintf("Added Lua CAN RX filter id 0x%x mask 0x%x with%s custom function", eid, mask, (callback == -1 ? "out" : ""));

View File

@ -47,7 +47,7 @@ public:
}
void reinit(char *buffer, size_t size) {
efiAssertVoid(OBD_PCM_Processor_Fault, m_memoryUsed == 0, "Too late to reinit Lua heap");
efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, m_memoryUsed == 0, "Too late to reinit Lua heap");
m_size = size;
m_buffer = buffer;
@ -161,13 +161,13 @@ static LuaHandle setupLuaState(lua_Alloc alloc) {
LuaHandle ls = lua_newstate(alloc, NULL);
if (!ls) {
firmwareError(OBD_PCM_Processor_Fault, "Failed to start Lua interpreter");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Failed to start Lua interpreter");
return nullptr;
}
lua_atpanic(ls, [](lua_State* l) {
firmwareError(OBD_PCM_Processor_Fault, "Lua panic: %s", lua_tostring(l, -1));
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Lua panic: %s", lua_tostring(l, -1));
// hang the lua thread
while (true) ;

View File

@ -122,7 +122,7 @@ bool doOneLuaCanRx(LuaHandle& ls) {
// We're done, return this frame to the free list
msg = freeBuffers.post(data, TIME_IMMEDIATE);
efiAssert(OBD_PCM_Processor_Fault, msg == MSG_OK, "lua can post to free buffer fail", false);
efiAssert(ObdCode::OBD_PCM_Processor_Fault, msg == MSG_OK, "lua can post to free buffer fail", false);
// We processed a frame so we should check again
return true;

View File

@ -66,7 +66,7 @@ float IFuelComputer::getTChargeCoefficient(int rpm, float tps) {
engineConfiguration->tchargeValues
);
} else {
firmwareError(OBD_PCM_Processor_Fault, "Unexpected tChargeMode: %d", engineConfiguration->tChargeMode);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Unexpected tChargeMode: %d", engineConfiguration->tChargeMode);
return 0;
}
}
@ -98,7 +98,7 @@ temperature_t IFuelComputer::getTCharge(int rpm, float tps) {
sdTcharge_coff = getTChargeCoefficient(rpm, tps);
if (cisnan(sdTcharge_coff)) {
warning(CUSTOM_ERR_T2_CHARGE, "t2-getTCharge NaN");
warning(ObdCode::CUSTOM_ERR_T2_CHARGE, "t2-getTCharge NaN");
return coolantTemp;
}
@ -109,7 +109,7 @@ temperature_t IFuelComputer::getTCharge(int rpm, float tps) {
if (cisnan(Tcharge)) {
// we can probably end up here while resetting engine state - interpolation would fail
warning(CUSTOM_ERR_TCHARGE_NOT_READY, "getTCharge NaN");
warning(ObdCode::CUSTOM_ERR_TCHARGE_NOT_READY, "getTCharge NaN");
return coolantTemp;
}

View File

@ -37,7 +37,7 @@ public:
// If there's somebody already here - a consumer tried to double-register a sensor
if (m_sensor && m_sensor != sensor) {
// This sensor has already been registered. Don't re-register it.
firmwareError(CUSTOM_OBD_26, "Duplicate registration for sensor \"%s\"", sensor->getSensorName());
firmwareError(ObdCode::CUSTOM_OBD_26, "Duplicate registration for sensor \"%s\"", sensor->getSensorName());
return false;
} else {
// Put the sensor in the registry

View File

@ -85,7 +85,7 @@ void AemXSeriesWideband::decodeRusefiStandard(const CANRxFrame& frame, efitick_t
auto data = reinterpret_cast<const wbo::StandardData*>(&frame.data8[0]);
if (data->Version != RUSEFI_WIDEBAND_VERSION) {
firmwareError(OBD_WB_FW_Mismatch, "Wideband controller index %d has wrong firmware version, please update!", m_sensorIndex);
firmwareError(ObdCode::OBD_WB_FW_Mismatch, "Wideband controller index %d has wrong firmware version, please update!", m_sensorIndex);
return;
}
@ -117,7 +117,7 @@ void AemXSeriesWideband::decodeRusefiDiag(const CANRxFrame& frame) {
faultCode = static_cast<uint8_t>(data->Status);
if (data->Status != wbo::Fault::None) {
auto code = m_sensorIndex == 0 ? Wideband_1_Fault : Wideband_2_Fault;
auto code = m_sensorIndex == 0 ? ObdCode::Wideband_1_Fault : ObdCode::Wideband_2_Fault;
warning(code, "Wideband #%d fault: %s", (m_sensorIndex + 1), wbo::describeFault(data->Status));
}
}

View File

@ -163,7 +163,7 @@ static void initEgoSensor(afr_sensor_s *sensor, ego_sensor_e type) {
sensor->value2 = 14;
break;
default:
firmwareError(CUSTOM_EGO_TYPE, "Unexpected EGO %d", type);
firmwareError(ObdCode::CUSTOM_EGO_TYPE, "Unexpected EGO %d", type);
break;
}
}

View File

@ -17,7 +17,7 @@ static float validateBaroMap(float mapKPa) {
// Highest interstate is the Eisenhower Tunnel at 11158 feet -> 66 kpa
// Lowest point is the Dead Sea, -1411 feet -> 106 kpa
if (cisnan(mapKPa) || mapKPa > 110 || mapKPa < 60) {
warning(OBD_Barometric_Press_Circ, "Invalid start-up baro pressure = %.2fkPa", mapKPa);
warning(ObdCode::OBD_Barometric_Press_Circ, "Invalid start-up baro pressure = %.2fkPa", mapKPa);
return NAN;
}
return mapKPa;

View File

@ -6,86 +6,86 @@ static ObdCode getCode(SensorType type, UnexpectedCode code) {
case SensorType::Tps1:
case SensorType::Tps1Primary:
switch (code) {
case UnexpectedCode::Timeout: return OBD_TPS1_Primary_Timeout;
case UnexpectedCode::Low: return OBD_TPS1_Primary_Low;
case UnexpectedCode::High: return OBD_TPS1_Primary_High;
case UnexpectedCode::Inconsistent: return OBD_TPS1_Correlation;
case UnexpectedCode::Timeout: return ObdCode::OBD_TPS1_Primary_Timeout;
case UnexpectedCode::Low: return ObdCode::OBD_TPS1_Primary_Low;
case UnexpectedCode::High: return ObdCode::OBD_TPS1_Primary_High;
case UnexpectedCode::Inconsistent: return ObdCode::OBD_TPS1_Correlation;
default: break;
} break;
case SensorType::Tps1Secondary:
switch (code) {
case UnexpectedCode::Timeout: return OBD_TPS1_Secondary_Timeout;
case UnexpectedCode::Low: return OBD_TPS1_Secondary_Low;
case UnexpectedCode::High: return OBD_TPS1_Secondary_High;
case UnexpectedCode::Timeout: return ObdCode::OBD_TPS1_Secondary_Timeout;
case UnexpectedCode::Low: return ObdCode::OBD_TPS1_Secondary_Low;
case UnexpectedCode::High: return ObdCode::OBD_TPS1_Secondary_High;
default: break;
} break;
case SensorType::Tps2:
case SensorType::Tps2Primary:
switch (code) {
case UnexpectedCode::Timeout: return OBD_TPS2_Primary_Timeout;
case UnexpectedCode::Low: return OBD_TPS2_Primary_Low;
case UnexpectedCode::High: return OBD_TPS2_Primary_High;
case UnexpectedCode::Inconsistent: return OBD_TPS2_Correlation;
case UnexpectedCode::Timeout: return ObdCode::OBD_TPS2_Primary_Timeout;
case UnexpectedCode::Low: return ObdCode::OBD_TPS2_Primary_Low;
case UnexpectedCode::High: return ObdCode::OBD_TPS2_Primary_High;
case UnexpectedCode::Inconsistent: return ObdCode::OBD_TPS2_Correlation;
default: break;
} break;
case SensorType::Tps2Secondary:
switch (code) {
case UnexpectedCode::Timeout: return OBD_TPS2_Secondary_Timeout;
case UnexpectedCode::Low: return OBD_TPS2_Secondary_Low;
case UnexpectedCode::High: return OBD_TPS2_Secondary_High;
case UnexpectedCode::Timeout: return ObdCode::OBD_TPS2_Secondary_Timeout;
case UnexpectedCode::Low: return ObdCode::OBD_TPS2_Secondary_Low;
case UnexpectedCode::High: return ObdCode::OBD_TPS2_Secondary_High;
default: break;
} break;
case SensorType::AcceleratorPedal:
case SensorType::AcceleratorPedalPrimary:
switch (code) {
case UnexpectedCode::Timeout: return OBD_PPS_Primary_Timeout;
case UnexpectedCode::Low: return OBD_PPS_Primary_Low;
case UnexpectedCode::High: return OBD_PPS_Primary_High;
case UnexpectedCode::Inconsistent: return OBD_PPS_Correlation;
case UnexpectedCode::Timeout: return ObdCode::OBD_PPS_Primary_Timeout;
case UnexpectedCode::Low: return ObdCode::OBD_PPS_Primary_Low;
case UnexpectedCode::High: return ObdCode::OBD_PPS_Primary_High;
case UnexpectedCode::Inconsistent: return ObdCode::OBD_PPS_Correlation;
default: break;
} break;
case SensorType::AcceleratorPedalSecondary:
switch (code) {
case UnexpectedCode::Timeout: return OBD_PPS_Secondary_Timeout;
case UnexpectedCode::Low: return OBD_PPS_Secondary_Low;
case UnexpectedCode::High: return OBD_PPS_Secondary_High;
case UnexpectedCode::Timeout: return ObdCode::OBD_PPS_Secondary_Timeout;
case UnexpectedCode::Low: return ObdCode::OBD_PPS_Secondary_Low;
case UnexpectedCode::High: return ObdCode::OBD_PPS_Secondary_High;
default: break;
} break;
case SensorType::Map:
switch (code) {
case UnexpectedCode::Timeout: return OBD_Map_Timeout;
case UnexpectedCode::Low: return OBD_Map_Low;
case UnexpectedCode::High: return OBD_Map_High;
case UnexpectedCode::Timeout: return ObdCode::OBD_Map_Timeout;
case UnexpectedCode::Low: return ObdCode::OBD_Map_Low;
case UnexpectedCode::High: return ObdCode::OBD_Map_High;
default: break;
} break;
case SensorType::Clt:
switch (code) {
case UnexpectedCode::Timeout: return OBD_Clt_Timeout;
case UnexpectedCode::Low: return OBD_Clt_Low;
case UnexpectedCode::High: return OBD_Clt_High;
case UnexpectedCode::Timeout: return ObdCode::OBD_Clt_Timeout;
case UnexpectedCode::Low: return ObdCode::OBD_Clt_Low;
case UnexpectedCode::High: return ObdCode::OBD_Clt_High;
default: break;
} break;
case SensorType::Iat:
switch (code) {
case UnexpectedCode::Timeout: return OBD_Iat_Timeout;
case UnexpectedCode::Low: return OBD_Iat_Low;
case UnexpectedCode::High: return OBD_Iat_High;
case UnexpectedCode::Timeout: return ObdCode::OBD_Iat_Timeout;
case UnexpectedCode::Low: return ObdCode::OBD_Iat_Low;
case UnexpectedCode::High: return ObdCode::OBD_Iat_High;
default: break;
} break;
case SensorType::FuelEthanolPercent:
switch (code) {
case UnexpectedCode::Timeout: return OBD_FlexSensor_Timeout;
case UnexpectedCode::Low: return OBD_FlexSensor_Low;
case UnexpectedCode::High: return OBD_FlexSensor_High;
case UnexpectedCode::Timeout: return ObdCode::OBD_FlexSensor_Timeout;
case UnexpectedCode::Low: return ObdCode::OBD_FlexSensor_Low;
case UnexpectedCode::High: return ObdCode::OBD_FlexSensor_High;
default: break;
} break;
default:
break;
}
return OBD_None;
return ObdCode::None;
}
inline const char* describeUnexpected(UnexpectedCode code) {
@ -116,31 +116,31 @@ static void check(SensorType type) {
ObdCode code = getCode(type, result.Code);
if (code != OBD_None) {
if (code != ObdCode::None) {
warning(code, "Sensor fault: %s %s", Sensor::getSensorName(type), describeUnexpected(result.Code));
}
}
static ObdCode getCodeForInjector(int idx, brain_pin_diag_e diag) {
if (idx < 0 || idx >= 12) {
return OBD_None;
return ObdCode::None;
}
// TODO: do something more intelligent with `diag`?
UNUSED(diag);
return (ObdCode)((int)OBD_Injector_Circuit_1 + idx);
return (ObdCode)((int)ObdCode::OBD_Injector_Circuit_1 + idx);
}
static ObdCode getCodeForIgnition(int idx, brain_pin_diag_e diag) {
if (idx < 0 || idx >= 12) {
return OBD_None;
return ObdCode::None;
}
// TODO: do something more intelligent with `diag`?
UNUSED(diag);
return (ObdCode)((int)OBD_Ignition_Circuit_1 + idx);
return (ObdCode)((int)ObdCode::OBD_Ignition_Circuit_1 + idx);
}
void SensorChecker::onSlowCallback() {

View File

@ -265,7 +265,7 @@ static void setCrankingFuel(float timeMs) {
static void setGlobalTriggerAngleOffset(float value) {
if (cisnan(value)) {
warning(CUSTOM_ERR_SGTP_ARGUMENT, "Invalid argument");
warning(ObdCode::CUSTOM_ERR_SGTP_ARGUMENT, "Invalid argument");
return;
}
engineConfiguration->globalTriggerAngleOffset = value;

View File

@ -79,7 +79,7 @@ private:
chThdSleepUntilWindowed(before, before + m_period);
}
firmwareError(OBD_PCM_Processor_Fault, "Thread died: %s", this->m_name);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Thread died: %s", this->m_name);
}
public:

View File

@ -76,7 +76,7 @@ bool EventQueue::insertTask(scheduling_s *scheduling, efitick_t timeX, action_s
#if EFI_UNIT_TEST
assertListIsSorted();
#endif /* EFI_UNIT_TEST */
efiAssert(CUSTOM_ERR_ASSERT, action.getCallback() != NULL, "NULL callback", false);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, action.getCallback() != NULL, "NULL callback", false);
// please note that simulator does not use this code at all - simulator uses signal_executor_sleep
@ -148,11 +148,11 @@ void EventQueue::remove(scheduling_s* scheduling) {
// Walked off the end, this is an error since this *should* have been scheduled
if (!current) {
firmwareError(OBD_PCM_Processor_Fault, "EventQueue::remove didn't find element");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "EventQueue::remove didn't find element");
return;
}
efiAssertVoid(OBD_PCM_Processor_Fault, current == scheduling, "current not equal to scheduling");
efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, current == scheduling, "current not equal to scheduling");
// Link around the removed item
prev->nextScheduling_s = current->nextScheduling_s;
@ -286,7 +286,7 @@ int EventQueue::size(void) const {
void EventQueue::assertListIsSorted() const {
scheduling_s *current = head;
while (current != NULL && current->nextScheduling_s != NULL) {
efiAssertVoid(CUSTOM_ERR_6623, current->momentX <= current->nextScheduling_s->momentX, "list order");
efiAssertVoid(ObdCode::CUSTOM_ERR_6623, current->momentX <= current->nextScheduling_s->momentX, "list order");
current = current->nextScheduling_s;
}
}

View File

@ -20,7 +20,7 @@
int counter = 0; \
LL_FOREACH2(head, current, field) { \
if (++counter > QUEUE_LENGTH_LIMIT) { \
firmwareError(CUSTOM_ERR_LOOPED_QUEUE, "Looped queue?"); \
firmwareError(ObdCode::CUSTOM_ERR_LOOPED_QUEUE, "Looped queue?"); \
return false; \
} \
if (current == element) { \
@ -29,7 +29,7 @@
* was not scheduled by angle but was scheduled by time. In case of scheduling \
* by time with slow RPM the whole next fast revolution might be within the wait period \
*/ \
warning(CUSTOM_RE_ADDING_INTO_EXECUTION_QUEUE, "re-adding element into event_queue"); \
warning(ObdCode::CUSTOM_RE_ADDING_INTO_EXECUTION_QUEUE, "re-adding element into event_queue"); \
return true; \
} \
} \

View File

@ -53,13 +53,13 @@ void SimplePwm::setSimplePwmDutyCycle(float dutyCycle) {
return;
}
if (cisnan(dutyCycle)) {
warning(CUSTOM_DUTY_INVALID, "%s spwd:dutyCycle %.2f", name, dutyCycle);
warning(ObdCode::CUSTOM_DUTY_INVALID, "%s spwd:dutyCycle %.2f", name, dutyCycle);
return;
} else if (dutyCycle < 0) {
warning(CUSTOM_DUTY_TOO_LOW, "%s dutyCycle too low %.2f", name, dutyCycle);
warning(ObdCode::CUSTOM_DUTY_TOO_LOW, "%s dutyCycle too low %.2f", name, dutyCycle);
dutyCycle = 0;
} else if (dutyCycle > 1) {
warning(CUSTOM_PWM_DUTY_TOO_HIGH, "%s duty too high %.2f", name, dutyCycle);
warning(ObdCode::CUSTOM_PWM_DUTY_TOO_HIGH, "%s duty too high %.2f", name, dutyCycle);
dutyCycle = 1;
}
@ -93,7 +93,7 @@ void SimplePwm::setSimplePwmDutyCycle(float dutyCycle) {
* returns absolute timestamp of state change
*/
static efitick_t getNextSwitchTimeNt(PwmConfig *state) {
efiAssert(CUSTOM_ERR_ASSERT, state->safe.phaseIndex < PWM_PHASE_MAX_COUNT, "phaseIndex range", 0);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, state->safe.phaseIndex < PWM_PHASE_MAX_COUNT, "phaseIndex range", 0);
int iteration = state->safe.iteration;
// we handle PM_ZERO and PM_FULL separately
float switchTime = state->mode == PM_NORMAL ? state->multiChannelStateSequence->getSwitchTime(state->safe.phaseIndex) : 1;
@ -134,7 +134,7 @@ void PwmConfig::stop() {
void PwmConfig::handleCycleStart() {
if (safe.phaseIndex != 0) {
// https://github.com/rusefi/rusefi/issues/1030
firmwareError(CUSTOM_PWM_CYCLE_START, "handleCycleStart %d", safe.phaseIndex);
firmwareError(ObdCode::CUSTOM_PWM_CYCLE_START, "handleCycleStart %d", safe.phaseIndex);
return;
}
@ -151,8 +151,8 @@ void PwmConfig::handleCycleStart() {
uint32_t iterationLimit = minI(iterationLimitInt32, iterationLimitFloat);
efiAssertVoid(CUSTOM_ERR_6580, periodNt != 0, "period not initialized");
efiAssertVoid(CUSTOM_ERR_6580, iterationLimit > 0, "iterationLimit invalid");
efiAssertVoid(ObdCode::CUSTOM_ERR_6580, periodNt != 0, "period not initialized");
efiAssertVoid(ObdCode::CUSTOM_ERR_6580, iterationLimit > 0, "iterationLimit invalid");
if (forceCycleStart || safe.periodNt != periodNt || safe.iteration == iterationLimit) {
/**
* period length has changed - we need to reset internal state
@ -250,7 +250,7 @@ static void timerCallback(PwmConfig *state) {
ScopePerf perf(PE::PwmGeneratorCallback);
state->dbgNestingLevel++;
efiAssertVoid(CUSTOM_ERR_6581, state->dbgNestingLevel < 25, "PWM nesting issue");
efiAssertVoid(ObdCode::CUSTOM_ERR_6581, state->dbgNestingLevel < 25, "PWM nesting issue");
efitick_t switchTimeNt = state->togglePwmState();
if (switchTimeNt == 0) {
@ -258,7 +258,7 @@ static void timerCallback(PwmConfig *state) {
return;
}
if (state->executor == nullptr) {
firmwareError(CUSTOM_NULL_EXECUTOR, "exec on %s", state->name);
firmwareError(ObdCode::CUSTOM_NULL_EXECUTOR, "exec on %s", state->name);
return;
}
@ -288,16 +288,16 @@ void PwmConfig::weComplexInit(const char *msg, ExecutorInterface *executor,
this->executor = executor;
isStopRequested = false;
efiAssertVoid(CUSTOM_ERR_6582, periodNt != 0, "period is not initialized");
efiAssertVoid(ObdCode::CUSTOM_ERR_6582, periodNt != 0, "period is not initialized");
if (seq->phaseCount == 0) {
firmwareError(CUSTOM_ERR_PWM_1, "signal length cannot be zero");
firmwareError(ObdCode::CUSTOM_ERR_PWM_1, "signal length cannot be zero");
return;
}
if (seq->phaseCount > PWM_PHASE_MAX_COUNT) {
firmwareError(CUSTOM_ERR_PWM_2, "too many phases in PWM");
firmwareError(ObdCode::CUSTOM_ERR_PWM_2, "too many phases in PWM");
return;
}
efiAssertVoid(CUSTOM_ERR_6583, seq->waveCount > 0, "waveCount should be positive");
efiAssertVoid(ObdCode::CUSTOM_ERR_6583, seq->waveCount > 0, "waveCount should be positive");
this->pwmCycleCallback = pwmCycleCallback;
this->stateChangeCallback = stateChangeCallback;
@ -314,10 +314,10 @@ void PwmConfig::weComplexInit(const char *msg, ExecutorInterface *executor,
void startSimplePwm(SimplePwm *state, const char *msg, ExecutorInterface *executor,
OutputPin *output, float frequency, float dutyCycle) {
efiAssertVoid(CUSTOM_ERR_PWM_STATE_ASSERT, state != NULL, "state");
efiAssertVoid(CUSTOM_ERR_PWM_DUTY_ASSERT, dutyCycle >= 0 && dutyCycle <= 1, "dutyCycle");
efiAssertVoid(ObdCode::CUSTOM_ERR_PWM_STATE_ASSERT, state != NULL, "state");
efiAssertVoid(ObdCode::CUSTOM_ERR_PWM_DUTY_ASSERT, dutyCycle >= 0 && dutyCycle <= 1, "dutyCycle");
if (frequency < 1) {
warning(CUSTOM_OBD_LOW_FREQUENCY, "low frequency %.2f %s", frequency, msg);
warning(ObdCode::CUSTOM_OBD_LOW_FREQUENCY, "low frequency %.2f %s", frequency, msg);
return;
}
@ -379,8 +379,8 @@ void applyPinState(int stateIndex, PwmConfig *state) /* pwm_gen_callback */ {
}
#endif // EFI_PROD_CODE
efiAssertVoid(CUSTOM_ERR_6663, stateIndex < PWM_PHASE_MAX_COUNT, "invalid stateIndex");
efiAssertVoid(CUSTOM_ERR_6664, state->multiChannelStateSequence->waveCount <= PWM_PHASE_MAX_WAVE_PER_PWM, "invalid waveCount");
efiAssertVoid(ObdCode::CUSTOM_ERR_6663, stateIndex < PWM_PHASE_MAX_COUNT, "invalid stateIndex");
efiAssertVoid(ObdCode::CUSTOM_ERR_6664, state->multiChannelStateSequence->waveCount <= PWM_PHASE_MAX_WAVE_PER_PWM, "invalid waveCount");
for (int channelIndex = 0; channelIndex < state->multiChannelStateSequence->waveCount; channelIndex++) {
OutputPin *output = state->outputPins[channelIndex];
TriggerValue value = state->multiChannelStateSequence->getChannelState(channelIndex, stateIndex);

View File

@ -8,7 +8,7 @@
#include "scheduler.h"
void action_s::execute() {
efiAssertVoid(CUSTOM_ERR_ASSERT, callback != NULL, "callback==null1");
efiAssertVoid(ObdCode::CUSTOM_ERR_ASSERT, callback != NULL, "callback==null1");
callback(param);
}

View File

@ -34,7 +34,7 @@
uint32_t hwSetTimerDuration;
void globalTimerCallback() {
efiAssertVoid(CUSTOM_ERR_6624, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#2y");
efiAssertVoid(ObdCode::CUSTOM_ERR_6624, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "lowstck#2y");
___engine.executor.onTimerCallback();
}
@ -72,7 +72,7 @@ void SingleTimerExecutor::scheduleByTimestampNt(const char *msg, scheduling_s* s
if (deltaTimeNt >= TOO_FAR_INTO_FUTURE_NT) {
// we are trying to set callback for too far into the future. This does not look right at all
int32_t intDeltaTimeNt = (int32_t)deltaTimeNt;
firmwareError(CUSTOM_ERR_TASK_TIMER_OVERFLOW, "scheduleByTimestampNt() too far: %d %s", intDeltaTimeNt, msg);
firmwareError(ObdCode::CUSTOM_ERR_TASK_TIMER_OVERFLOW, "scheduleByTimestampNt() too far: %d %s", intDeltaTimeNt, msg);
return;
}
#endif
@ -137,7 +137,7 @@ void SingleTimerExecutor::executeAllPendingActions() {
// if we're stuck in a loop executing lots of events, panic!
if (executeCounter++ == 500) {
firmwareError(CUSTOM_ERR_LOCK_ISSUE, "Maximum scheduling run length exceeded - CPU load too high");
firmwareError(ObdCode::CUSTOM_ERR_LOCK_ISSUE, "Maximum scheduling run length exceeded - CPU load too high");
}
} while (didExecute);
@ -145,7 +145,7 @@ void SingleTimerExecutor::executeAllPendingActions() {
maxExecuteCounter = maxI(maxExecuteCounter, executeCounter);
if (!isLocked()) {
firmwareError(CUSTOM_ERR_LOCK_ISSUE, "Someone has stolen my lock");
firmwareError(ObdCode::CUSTOM_ERR_LOCK_ISSUE, "Someone has stolen my lock");
return;
}
reentrantFlag = false;
@ -167,7 +167,7 @@ void SingleTimerExecutor::scheduleTimerCallback() {
return; // no pending events in the queue
}
efiAssertVoid(CUSTOM_ERR_6625, nextEventTimeNt.Value > nowNt, "setTimer constraint");
efiAssertVoid(ObdCode::CUSTOM_ERR_6625, nextEventTimeNt.Value > nowNt, "setTimer constraint");
setHardwareSchedulerTimer(nowNt, nextEventTimeNt.Value);
}

View File

@ -151,7 +151,7 @@ AngleBasedEvent * TriggerScheduler::getElementAtIndexForUnitTest(int index) {
return current;
index--;
}
firmwareError(OBD_PCM_Processor_Fault, "getElementAtIndexForUnitText: null");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "getElementAtIndexForUnitText: null");
return nullptr;
}
#endif /* EFI_UNIT_TEST */

View File

@ -33,7 +33,7 @@
#define wrapAngle2(angle, msg, code, engineCycle) \
{ \
if (cisnan(angle)) { \
firmwareError(CUSTOM_ERR_ANGLE, "a NaN %s", msg); \
firmwareError(ObdCode::CUSTOM_ERR_ANGLE, "a NaN %s", msg); \
angle = 0; \
} \
assertAngleRange(angle, msg, code); \

View File

@ -18,8 +18,8 @@ angle_t getEngineCycle(operation_mode_e operationMode) {
void addSkippedToothTriggerEvents(TriggerWheel wheel, TriggerWaveform *s, int totalTeethCount, int skippedCount,
float toothWidth, float offset, float engineCycle, float filterLeft, float filterRight) {
efiAssertVoid(CUSTOM_ERR_6586, totalTeethCount > 0, "total count");
efiAssertVoid(CUSTOM_ERR_6587, skippedCount >= 0, "skipped count");
efiAssertVoid(ObdCode::CUSTOM_ERR_6586, totalTeethCount > 0, "total count");
efiAssertVoid(ObdCode::CUSTOM_ERR_6587, skippedCount >= 0, "skipped count");
for (int i = 0; i < totalTeethCount - skippedCount - 1; i++) {
float angleDown = engineCycle / totalTeethCount * (i + (1 - toothWidth));
@ -37,11 +37,11 @@ void addSkippedToothTriggerEvents(TriggerWheel wheel, TriggerWaveform *s, int to
void initializeSkippedToothTrigger(TriggerWaveform *s, int totalTeethCount, int skippedCount,
operation_mode_e operationMode, SyncEdge syncEdge) {
if (totalTeethCount <= 0) {
firmwareError(CUSTOM_OBD_TRIGGER_WAVEFORM, "Invalid total tooth count for missing tooth decoder: %d", totalTeethCount);
firmwareError(ObdCode::CUSTOM_OBD_TRIGGER_WAVEFORM, "Invalid total tooth count for missing tooth decoder: %d", totalTeethCount);
s->setShapeDefinitionError(true);
return;
}
efiAssertVoid(CUSTOM_NULL_SHAPE, s != NULL, "TriggerWaveform is NULL");
efiAssertVoid(ObdCode::CUSTOM_NULL_SHAPE, s != NULL, "TriggerWaveform is NULL");
s->initialize(operationMode, syncEdge);

View File

@ -265,7 +265,7 @@ void hwHandleVvtCamSignal(TriggerValue front, efitick_t nowNt, int index) {
tc->vvtEventFallCounter[index]++;
}
if (engineConfiguration->vvtMode[camIndex] == VVT_INACTIVE) {
warning(CUSTOM_VVT_MODE_NOT_SELECTED, "VVT: event on %d but no mode", camIndex);
warning(ObdCode::CUSTOM_VVT_MODE_NOT_SELECTED, "VVT: event on %d but no mode", camIndex);
}
#if VR_HW_CHECK_MODE
@ -385,7 +385,7 @@ void hwHandleVvtCamSignal(TriggerValue front, efitick_t nowNt, int index) {
* wrong order due to belt flex or else
* https://github.com/rusefi/rusefi/issues/3269
*/
warning(CUSTOM_VVT_SYNC_POSITION, "VVT sync position too close to trigger sync");
warning(ObdCode::CUSTOM_VVT_SYNC_POSITION, "VVT sync position too close to trigger sync");
}
} else {
// Not using this cam for engine sync, just wrap the value in to the reasonable range
@ -687,7 +687,7 @@ bool TriggerCentral::isToothExpectedNow(efitick_t timestamp) {
// #2 will be ignored
// We're not sure which edge was the "real" one, but they were close enough
// together that it doesn't really matter.
warning(CUSTOM_PRIMARY_DOUBLED_EDGE, "doubled trigger edge after %.2f deg at #%d", angleSinceLastTooth, triggerState.currentCycle.current_index);
warning(ObdCode::CUSTOM_PRIMARY_DOUBLED_EDGE, "doubled trigger edge after %.2f deg at #%d", angleSinceLastTooth, triggerState.currentCycle.current_index);
return false;
}
@ -698,7 +698,7 @@ bool TriggerCentral::isToothExpectedNow(efitick_t timestamp) {
// TODO: configurable threshold
if (isRpmEnough && absError > 10 && absError < 180) {
// This tooth came at a very unexpected time, ignore it
warning(CUSTOM_PRIMARY_BAD_TOOTH_TIMING, "tooth #%d error of %.1f", triggerState.currentCycle.current_index, angleError);
warning(ObdCode::CUSTOM_PRIMARY_BAD_TOOTH_TIMING, "tooth #%d error of %.1f", triggerState.currentCycle.current_index, angleError);
// TODO: this causes issues with some real engine logs, should it?
// return false;
@ -718,7 +718,7 @@ bool TriggerCentral::isToothExpectedNow(efitick_t timestamp) {
void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timestamp) {
if (triggerShape.shapeDefinitionError) {
// trigger is broken, we cannot do anything here
warning(CUSTOM_ERR_UNEXPECTED_SHAFT_EVENT, "Shaft event while trigger is mis-configured");
warning(ObdCode::CUSTOM_ERR_UNEXPECTED_SHAFT_EVENT, "Shaft event while trigger is mis-configured");
// magic value to indicate a problem
hwEventCounters[0] = 155;
return;
@ -744,7 +744,7 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
m_lastEventTimer.reset(timestamp);
int eventIndex = (int) signal;
efiAssertVoid(CUSTOM_TRIGGER_EVENT_TYPE, eventIndex >= 0 && eventIndex < HW_EVENT_TYPES, "signal type");
efiAssertVoid(ObdCode::CUSTOM_TRIGGER_EVENT_TYPE, eventIndex >= 0 && eventIndex < HW_EVENT_TYPES, "signal type");
hwEventCounters[eventIndex]++;
// Decode the trigger!
@ -773,7 +773,7 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
auto currentPhaseFromSyncPoint = getTriggerCentral()->triggerFormDetails.eventAngles[triggerIndexForListeners];
// Adjust so currentPhase is in engine-space angle, not trigger-space angle
currentEngineDecodedPhase = wrapAngleMethod(currentPhaseFromSyncPoint - tdcPosition(), "currentEnginePhase", CUSTOM_ERR_6555);
currentEngineDecodedPhase = wrapAngleMethod(currentPhaseFromSyncPoint - tdcPosition(), "currentEnginePhase", ObdCode::CUSTOM_ERR_6555);
// Record precise time and phase of the engine. This is used for VVT decode, and to check that the
// trigger pattern selected matches reality (ie, we check the next tooth is where we think it should be)
@ -813,11 +813,11 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
// I don't love this.
nextToothIndex = (nextToothIndex + 1) % engineCycleEventCount;
nextPhase = getTriggerCentral()->triggerFormDetails.eventAngles[nextToothIndex] - tdcPosition();
wrapAngle(nextPhase, "nextEnginePhase", CUSTOM_ERR_6555);
wrapAngle(nextPhase, "nextEnginePhase", ObdCode::CUSTOM_ERR_6555);
} while (nextPhase == currentEngineDecodedPhase);
float expectNextPhase = nextPhase + tdcPosition();
wrapAngle(expectNextPhase, "nextEnginePhase", CUSTOM_ERR_6555);
wrapAngle(expectNextPhase, "nextEnginePhase", ObdCode::CUSTOM_ERR_6555);
expectedNextPhase = expectNextPhase;
#if EFI_CDM_INTEGRATION
@ -1023,7 +1023,7 @@ void TriggerCentral::validateCamVvtCounters() {
vvtCamCounter = 0;
} else if (camVvtValidationIndex == 0xFE && vvtCamCounter < 60) {
// magic logic: we expect at least 60 CAM/VVT events for each 256 trigger cycles, otherwise throw a code
warning(OBD_Camshaft_Position_Sensor_Circuit_Range_Performance, "No Camshaft Position Sensor signals");
warning(ObdCode::OBD_Camshaft_Position_Sensor_Circuit_Range_Performance, "No Camshaft Position Sensor signals");
}
}
/**
@ -1035,20 +1035,20 @@ static void calculateTriggerSynchPoint(
TriggerDecoderBase& initState) {
#if EFI_PROD_CODE
efiAssertVoid(CUSTOM_TRIGGER_STACK, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "calc s");
efiAssertVoid(ObdCode::CUSTOM_TRIGGER_STACK, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "calc s");
#endif
shape.initializeSyncPoint(initState, primaryTriggerConfiguration);
if (shape.getSize() >= PWM_PHASE_MAX_COUNT) {
// todo: by the time we are here we had already modified a lot of RAM out of bounds!
firmwareError(CUSTOM_ERR_TRIGGER_WAVEFORM_TOO_LONG, "Trigger length above maximum: %d", shape.getSize());
firmwareError(ObdCode::CUSTOM_ERR_TRIGGER_WAVEFORM_TOO_LONG, "Trigger length above maximum: %d", shape.getSize());
shape.setShapeDefinitionError(true);
return;
}
if (shape.getSize() == 0) {
firmwareError(CUSTOM_ERR_TRIGGER_ZERO, "triggerShape size is zero");
firmwareError(ObdCode::CUSTOM_ERR_TRIGGER_ZERO, "triggerShape size is zero");
}
}
@ -1088,7 +1088,7 @@ void TriggerCentral::updateWaveform() {
int length = triggerShape.getLength();
engineCycleEventCount = length;
efiAssertVoid(CUSTOM_SHAPE_LEN_ZERO, length > 0, "shapeLength=0");
efiAssertVoid(ObdCode::CUSTOM_SHAPE_LEN_ZERO, length > 0, "shapeLength=0");
triggerErrorDetection.clear();
@ -1135,11 +1135,11 @@ bool TriggerCentral::isTriggerConfigChanged() {
void validateTriggerInputs() {
if (!isBrainPinValid(engineConfiguration->triggerInputPins[0]) && isBrainPinValid(engineConfiguration->triggerInputPins[1])) {
firmwareError(OBD_PCM_Processor_Fault, "First trigger channel is missing");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "First trigger channel is missing");
}
if (!isBrainPinValid(engineConfiguration->camInputs[0]) && isBrainPinValid(engineConfiguration->camInputs[2])) {
firmwareError(OBD_PCM_Processor_Fault, "First bank cam input is required if second bank specified");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "First bank cam input is required if second bank specified");
}
}

View File

@ -127,7 +127,7 @@ void TriggerFormDetails::prepareEventAngles(TriggerWaveform *shape) {
return;
}
angle_t firstAngle = shape->getAngle(triggerShapeSynchPointIndex);
assertAngleRange(firstAngle, "firstAngle", CUSTOM_TRIGGER_SYNC_ANGLE);
assertAngleRange(firstAngle, "firstAngle", ObdCode::CUSTOM_TRIGGER_SYNC_ANGLE);
int riseOnlyIndex = 0;
@ -138,8 +138,8 @@ void TriggerFormDetails::prepareEventAngles(TriggerWaveform *shape) {
// this may be <length for some triggers like symmetrical crank Miata NB
size_t triggerShapeLength = shape->getSize();
assertAngleRange(shape->triggerShapeSynchPointIndex, "triggerShapeSynchPointIndex", CUSTOM_TRIGGER_SYNC_ANGLE2);
efiAssertVoid(CUSTOM_TRIGGER_CYCLE, getTriggerCentral()->engineCycleEventCount != 0, "zero engineCycleEventCount");
assertAngleRange(shape->triggerShapeSynchPointIndex, "triggerShapeSynchPointIndex", ObdCode::CUSTOM_TRIGGER_SYNC_ANGLE2);
efiAssertVoid(ObdCode::CUSTOM_TRIGGER_CYCLE, getTriggerCentral()->engineCycleEventCount != 0, "zero engineCycleEventCount");
for (size_t eventIndex = 0; eventIndex < length; eventIndex++) {
if (eventIndex == 0) {
@ -158,12 +158,12 @@ void TriggerFormDetails::prepareEventAngles(TriggerWaveform *shape) {
// Compute the relative angle of this tooth to the sync point's tooth
float angle = shape->getAngle(wrappedIndex) - firstAngle;
efiAssertVoid(CUSTOM_TRIGGER_CYCLE, !cisnan(angle), "trgSyncNaN");
efiAssertVoid(ObdCode::CUSTOM_TRIGGER_CYCLE, !cisnan(angle), "trgSyncNaN");
// Wrap the angle back in to [0, 720)
fixAngle(angle, "trgSync", CUSTOM_TRIGGER_SYNC_ANGLE_RANGE);
fixAngle(angle, "trgSync", ObdCode::CUSTOM_TRIGGER_SYNC_ANGLE_RANGE);
if (shape->useOnlyRisingEdges) {
efiAssertVoid(OBD_PCM_Processor_Fault, triggerDefinitionIndex < triggerShapeLength, "trigger shape fail");
efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, triggerDefinitionIndex < triggerShapeLength, "trigger shape fail");
assertIsInBounds(triggerDefinitionIndex, shape->isRiseEvent, "isRise");
// In case this is a rising event, replace the following fall event with the rising as well
@ -221,7 +221,7 @@ int TriggerDecoderBase::getCurrentIndex() const {
}
angle_t PrimaryTriggerDecoder::syncEnginePhase(int divider, int remainder, angle_t engineCycle) {
efiAssert(OBD_PCM_Processor_Fault, remainder < divider, "syncEnginePhase", false);
efiAssert(ObdCode::OBD_PCM_Processor_Fault, remainder < divider, "syncEnginePhase", false);
angle_t totalShift = 0;
while (getCrankSynchronizationCounter() % divider != remainder) {
/**
@ -253,7 +253,7 @@ void PrimaryTriggerDecoder::onTriggerError() {
}
void PrimaryTriggerDecoder::onNotEnoughTeeth(int /*actual*/, int /*expected*/) {
warning(CUSTOM_PRIMARY_NOT_ENOUGH_TEETH, "primary trigger error: not enough teeth between sync points: expected %d/%d got %d/%d",
warning(ObdCode::CUSTOM_PRIMARY_NOT_ENOUGH_TEETH, "primary trigger error: not enough teeth between sync points: expected %d/%d got %d/%d",
getTriggerCentral()->triggerShape.getExpectedEventCount(TriggerWheel::T_PRIMARY),
getTriggerCentral()->triggerShape.getExpectedEventCount(TriggerWheel::T_SECONDARY),
currentCycle.eventCount[0],
@ -261,7 +261,7 @@ void PrimaryTriggerDecoder::onNotEnoughTeeth(int /*actual*/, int /*expected*/) {
}
void PrimaryTriggerDecoder::onTooManyTeeth(int /*actual*/, int /*expected*/) {
warning(CUSTOM_PRIMARY_TOO_MANY_TEETH, "primary trigger error: too many teeth between sync points: expected %d/%d got %d/%d",
warning(ObdCode::CUSTOM_PRIMARY_TOO_MANY_TEETH, "primary trigger error: too many teeth between sync points: expected %d/%d got %d/%d",
getTriggerCentral()->triggerShape.getExpectedEventCount(TriggerWheel::T_PRIMARY),
getTriggerCentral()->triggerShape.getExpectedEventCount(TriggerWheel::T_SECONDARY),
currentCycle.eventCount[0],
@ -292,11 +292,11 @@ case TriggerValue::RISE:
}
void VvtTriggerDecoder::onNotEnoughTeeth(int actual, int expected) {
warning(CUSTOM_CAM_NOT_ENOUGH_TEETH, "cam %s trigger error: not enough teeth between sync points: actual %d expected %d", name, actual, expected);
warning(ObdCode::CUSTOM_CAM_NOT_ENOUGH_TEETH, "cam %s trigger error: not enough teeth between sync points: actual %d expected %d", name, actual, expected);
}
void VvtTriggerDecoder::onTooManyTeeth(int actual, int expected) {
warning(CUSTOM_CAM_TOO_MANY_TEETH, "cam %s trigger error: too many teeth between sync points: %d > %d", name, actual, expected);
warning(ObdCode::CUSTOM_CAM_TOO_MANY_TEETH, "cam %s trigger error: too many teeth between sync points: %d > %d", name, actual, expected);
}
bool TriggerDecoderBase::validateEventCounters(const TriggerWaveform& triggerShape) const {
@ -392,7 +392,7 @@ expected<TriggerDecodeResult> TriggerDecoderBase::decodeTriggerEvent(
bool useOnlyRisingEdgeForTrigger = triggerShape.useOnlyRisingEdges;
efiAssert(CUSTOM_TRIGGER_UNEXPECTED, signal <= SHAFT_SECONDARY_RISING, "unexpected signal", unexpected);
efiAssert(ObdCode::CUSTOM_TRIGGER_UNEXPECTED, signal <= SHAFT_SECONDARY_RISING, "unexpected signal", unexpected);
TriggerWheel triggerWheel = eventIndex[signal];
TriggerValue type = eventType[signal];
@ -407,7 +407,7 @@ expected<TriggerDecodeResult> TriggerDecoderBase::decodeTriggerEvent(
currentCycle.eventCount[(int)triggerWheel]++;
if (toothed_previous_time > nowNt) {
firmwareError(CUSTOM_OBD_93, "[%s] toothed_previous_time after nowNt prev=%d now=%d", msg, toothed_previous_time, nowNt);
firmwareError(ObdCode::CUSTOM_OBD_93, "[%s] toothed_previous_time after nowNt prev=%d now=%d", msg, toothed_previous_time, nowNt);
}
efitick_t currentDurationLong = isFirstEvent ? 0 : nowNt - toothed_previous_time;
@ -694,7 +694,7 @@ uint32_t TriggerDecoderBase::findTriggerZeroEventIndex(
TriggerWaveform& shape,
const TriggerConfiguration& triggerConfiguration) {
#if EFI_PROD_CODE
efiAssert(CUSTOM_ERR_ASSERT, getCurrentRemainingStack() > 128, "findPos", -1);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, getCurrentRemainingStack() > 128, "findPos", -1);
#endif
@ -712,7 +712,7 @@ uint32_t TriggerDecoderBase::findTriggerZeroEventIndex(
}
// Assert that we found the sync point on the very first revolution
efiAssert(CUSTOM_ERR_ASSERT, getCrankSynchronizationCounter() == 0, "findZero_revCounter", EFI_ERROR_CODE);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, getCrankSynchronizationCounter() == 0, "findZero_revCounter", EFI_ERROR_CODE);
#if EFI_UNIT_TEST
if (printTriggerDebug) {

View File

@ -42,7 +42,7 @@ void TriggerStimulatorHelper::feedSimulatedEvent(
const TriggerWaveform& shape,
int i
) {
efiAssertVoid(CUSTOM_ERR_6593, shape.getSize() > 0, "size not zero");
efiAssertVoid(ObdCode::CUSTOM_ERR_6593, shape.getSize() > 0, "size not zero");
int stateIndex = i % shape.getSize();
int time = getSimulatedEventTime(shape, i);
@ -108,7 +108,7 @@ void TriggerStimulatorHelper::assertSyncPosition(
int revolutionCounter = state.getCrankSynchronizationCounter();
if (revolutionCounter != TEST_REVOLUTIONS) {
warning(CUSTOM_OBD_TRIGGER_WAVEFORM, "sync failed/wrong gap parameters trigger=%s revolutionCounter=%d",
warning(ObdCode::CUSTOM_OBD_TRIGGER_WAVEFORM, "sync failed/wrong gap parameters trigger=%s revolutionCounter=%d",
getTrigger_type_e(triggerConfiguration.TriggerType.type),
revolutionCounter);
shape.setShapeDefinitionError(true);
@ -141,9 +141,9 @@ expected<uint32_t> TriggerStimulatorHelper::findTriggerSyncPoint(
shape.setShapeDefinitionError(true);
if (engineConfiguration->overrideTriggerGaps) {
firmwareError(CUSTOM_ERR_CUSTOM_GAPS_BAD, "Your custom trigger gaps are not good.");
firmwareError(ObdCode::CUSTOM_ERR_CUSTOM_GAPS_BAD, "Your custom trigger gaps are not good.");
} else {
firmwareError(CUSTOM_ERR_TRIGGER_SYNC, "findTriggerZeroEventIndex() failed");
firmwareError(ObdCode::CUSTOM_ERR_TRIGGER_SYNC, "findTriggerZeroEventIndex() failed");
}
return unexpected;
}

View File

@ -175,13 +175,13 @@ void WaveChart::addEvent3(const char *name, const char * msg) {
return;
}
#endif
efiAssertVoid(CUSTOM_ERR_6651, name!=NULL, "WC: NULL name");
efiAssertVoid(ObdCode::CUSTOM_ERR_6651, name!=NULL, "WC: NULL name");
#if EFI_PROD_CODE
efiAssertVoid(CUSTOM_ERR_6652, getCurrentRemainingStack() > 32, "lowstck#2c");
efiAssertVoid(ObdCode::CUSTOM_ERR_6652, getCurrentRemainingStack() > 32, "lowstck#2c");
#endif /* EFI_PROD_CODE */
efiAssertVoid(CUSTOM_ERR_6653, isInitialized, "chart not initialized");
efiAssertVoid(ObdCode::CUSTOM_ERR_6653, isInitialized, "chart not initialized");
#if DEBUG_WAVE
efiPrintf("current", chart->counter);
#endif /* DEBUG_WAVE */

View File

@ -73,7 +73,7 @@ static void riseCallback(WaveReader *reader) {
efitick_t nowUs = getTimeNowUs();
reader->riseEventCounter++;
reader->lastActivityTimeUs = nowUs;
assertIsrContext(CUSTOM_ERR_6670);
assertIsrContext(ObdCode::CUSTOM_ERR_6670);
addEngineSnifferLogicAnalyzerEvent(reader->laIndex, FrontDirection::UP);
uint32_t width = nowUs - reader->periodEventTimeUs;
@ -87,7 +87,7 @@ void WaveReader::onFallEvent() {
efitick_t nowUs = getTimeNowUs();
fallEventCounter++;
lastActivityTimeUs = nowUs;
assertIsrContext(CUSTOM_ERR_6670);
assertIsrContext(ObdCode::CUSTOM_ERR_6670);
addEngineSnifferLogicAnalyzerEvent(laIndex, FrontDirection::DOWN);
efitick_t width = nowUs - widthEventTimeUs;
@ -129,7 +129,7 @@ void logicAnalyzerCallback(void* arg, efitick_t /*stamp*/) {
static void initWave(size_t index) {
brain_pin_e brainPin = engineConfiguration->logicAnalyzerPins[index];
efiAssertVoid(CUSTOM_ERR_6655, index < efi::size(readers), "too many ICUs");
efiAssertVoid(ObdCode::CUSTOM_ERR_6655, index < efi::size(readers), "too many ICUs");
WaveReader *reader = &readers[index];
if (!isBrainPinValid(brainPin)) {
@ -218,7 +218,7 @@ static void reportWave(Logging *logging, int index) {
logging->appendPrintf("advance%d%s", index, LOG_DELIMITER);
float angle = (offsetUs / oneDegreeUs) - tdcPosition();
fixAngle(angle, "waveAn", CUSTOM_ERR_6564);
fixAngle(angle, "waveAn", ObdCode::CUSTOM_ERR_6564);
logging->appendFloat(angle, 3);
logging->appendPrintf("%s", LOG_DELIMITER);
}

View File

@ -164,7 +164,7 @@ static void fast_adc_callback(GPTDriver*) {
ADC_FAST_DEVICE.state != ADC_COMPLETE &&
ADC_FAST_DEVICE.state != ADC_ERROR) {
fastAdc.errorsCount++;
// todo: when? why? firmwareError(OBD_PCM_Processor_Fault, "ADC fast not ready?");
// todo: when? why? firmwareError(ObdCode::OBD_PCM_Processor_Fault, "ADC fast not ready?");
chSysUnlockFromISR()
;
return;
@ -186,7 +186,7 @@ float getMCUInternalTemperature() {
int getInternalAdcValue(const char *msg, adc_channel_e hwChannel) {
if (!isAdcChannelValid(hwChannel)) {
warning(CUSTOM_OBD_ANALOG_INPUT_NOT_CONFIGURED, "ADC: %s input is not configured", msg);
warning(ObdCode::CUSTOM_OBD_ANALOG_INPUT_NOT_CONFIGURED, "ADC: %s input is not configured", msg);
return -1;
}
@ -260,7 +260,7 @@ bool AdcDevice::isHwUsed(adc_channel_e hwChannelIndex) const {
void AdcDevice::enableChannel(adc_channel_e hwChannel) {
if ((channelCount + 1) >= ADC_MAX_CHANNELS_COUNT) {
firmwareError(OBD_PCM_Processor_Fault, "Too many ADC channels configured");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Too many ADC channels configured");
return;
}

View File

@ -71,7 +71,7 @@ static AdcSubscriptionEntry* findEntry() {
// Ensure that a free entry was found
if (!entry) {
firmwareError(CUSTOM_INVALID_ADC, "too many ADC subscriptions subscribing %s", name);
firmwareError(ObdCode::CUSTOM_INVALID_ADC, "too many ADC subscriptions subscribing %s", name);
return;
}

View File

@ -42,7 +42,7 @@ void efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, Exti
return;
}
efiAssertVoid(OBD_PCM_Processor_Fault, msg, "efiExtiEnablePin msg must not be null");
efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, msg, "efiExtiEnablePin msg must not be null");
ioportid_t port = getHwPort(msg, brainPin);
if (port == NULL) {
@ -61,7 +61,7 @@ void efiExtiEnablePin(const char *msg, brain_pin_e brainPin, uint32_t mode, Exti
/* is this index already used? */
if (channel.Callback) {
firmwareError(CUSTOM_ERR_PIN_ALREADY_USED_2, "%s: pin %s/index %d: exti index already used by %s",
firmwareError(ObdCode::CUSTOM_ERR_PIN_ALREADY_USED_2, "%s: pin %s/index %d: exti index already used by %s",
msg,
hwPortname(brainPin),
index,
@ -253,7 +253,7 @@ CH_FAST_IRQ_HANDLER(VectorE0) {
// TODO: non-stm32 exti
void efiExtiInit() {
firmwareError(OBD_PCM_Processor_Fault, "exti not supported");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "exti not supported");
}
void efiExtiEnablePin(const char *, brain_pin_e, uint32_t, ExtiCallback, void *) { }

View File

@ -91,7 +91,7 @@ static int turnOnTriggerInputPin(const char *msg, int index, bool isTriggerShaft
return 0;
}
firmwareError(CUSTOM_ERR_NOT_INPUT_PIN, "%s: Not input pin %s", msg, hwPortname(brainPin));
firmwareError(ObdCode::CUSTOM_ERR_NOT_INPUT_PIN, "%s: Not input pin %s", msg, hwPortname(brainPin));
return -1;
}

View File

@ -292,7 +292,7 @@ void startCanPins() {
// todo: smarter online change of settings, kill isCanEnabled with fire
return;
}
firmwareError(CUSTOM_OBD_70, "invalid CAN TX %s", hwPortname(engineConfiguration->canTxPin));
firmwareError(ObdCode::CUSTOM_OBD_70, "invalid CAN TX %s", hwPortname(engineConfiguration->canTxPin));
return;
}
@ -301,7 +301,7 @@ void startCanPins() {
// todo: smarter online change of settings, kill isCanEnabled with fire
return;
}
firmwareError(CUSTOM_OBD_70, "invalid CAN RX %s", hwPortname(engineConfiguration->canRxPin));
firmwareError(ObdCode::CUSTOM_OBD_70, "invalid CAN RX %s", hwPortname(engineConfiguration->canRxPin));
return;
}
@ -355,7 +355,7 @@ void initCan() {
// Devices can't be the same!
if (device1 == device2) {
firmwareError(OBD_PCM_Processor_Fault, "CAN pins must be set to different devices");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "CAN pins must be set to different devices");
return;
}

View File

@ -54,7 +54,7 @@ CanTxMessage::~CanTxMessage() {
auto device = s_devices[busIndex];
if (!device) {
warning(CUSTOM_ERR_CAN_CONFIGURATION, "Send: CAN configuration issue %d", busIndex);
warning(ObdCode::CUSTOM_ERR_CAN_CONFIGURATION, "Send: CAN configuration issue %d", busIndex);
return;
}

View File

@ -733,7 +733,7 @@ int L9779::deinit()
int l9779_add(brain_pin_e base, unsigned int index, const l9779_config *cfg) {
efiAssert(OBD_PCM_Processor_Fault, cfg != NULL, "L9779CFG", 0)
efiAssert(ObdCode::OBD_PCM_Processor_Fault, cfg != NULL, "L9779CFG", 0)
/* no config or no such chip */
if ((!cfg) || (!cfg->spi_bus) || (index >= BOARD_L9779_COUNT))

View File

@ -1235,7 +1235,7 @@ int Tle8888::deinit()
int tle8888_add(brain_pin_e base, unsigned int index, const tle8888_config *cfg) {
efiAssert(OBD_PCM_Processor_Fault, cfg != NULL, "8888CFG", 0)
efiAssert(ObdCode::OBD_PCM_Processor_Fault, cfg != NULL, "8888CFG", 0)
/* no config or no such chip */
if ((!cfg) || (!cfg->spi_bus) || (index >= BOARD_TLE8888_COUNT))

View File

@ -73,12 +73,12 @@ void initAuxSerial(void) {
// Validate pins
if (isSerialTXEnabled && !isValidSerialTxPin(engineConfiguration->auxSerialTxPin)) {
firmwareError(OBD_PCM_Processor_Fault, "unexpected aux TX pin");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "unexpected aux TX pin");
return;
}
if (isSerialRXEnabled && !isValidSerialRxPin(engineConfiguration->auxSerialRxPin)) {
firmwareError(OBD_PCM_Processor_Fault, "unexpected aux RX pin");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "unexpected aux RX pin");
return;
}

View File

@ -80,7 +80,7 @@ extern bool isSpiInitialized[5];
* Only one consumer can use SPI bus at a given time
*/
void lockSpi(spi_device_e device) {
efiAssertVoid(CUSTOM_STACK_SPI, getCurrentRemainingStack() > 128, "lockSpi");
efiAssertVoid(ObdCode::CUSTOM_STACK_SPI, getCurrentRemainingStack() > 128, "lockSpi");
spiAcquireBus(getSpiDevice(device));
}
@ -131,7 +131,7 @@ SPIDriver * getSpiDevice(spi_device_e spiDevice) {
return &SPID4;
}
#endif
firmwareError(CUSTOM_ERR_UNEXPECTED_SPI, "Unexpected SPI device: %d", spiDevice);
firmwareError(ObdCode::CUSTOM_ERR_UNEXPECTED_SPI, "Unexpected SPI device: %d", spiDevice);
return NULL;
}
#endif
@ -177,7 +177,7 @@ void onFastAdcComplete(adcsample_t*) {
/**
* this callback is executed 10 000 times a second, it needs to be as fast as possible
*/
efiAssertVoid(CUSTOM_STACK_ADC, getCurrentRemainingStack() > 128, "lowstck#9b");
efiAssertVoid(ObdCode::CUSTOM_STACK_ADC, getCurrentRemainingStack() > 128, "lowstck#9b");
#if EFI_SENSOR_CHART && EFI_SHAFT_POSITION_INPUT
if (getEngineState()->sensorChartMode == SC_AUX_FAST1) {
@ -370,9 +370,7 @@ void setBor(int borValue) {
// This function initializes hardware that can do so before configuration is loaded
void initHardwareNoConfig() {
efiAssertVoid(CUSTOM_IH_STACK, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "init h");
efiAssertVoid(CUSTOM_EC_NULL, engineConfiguration!=NULL, "engineConfiguration");
efiAssertVoid(ObdCode::CUSTOM_IH_STACK, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "init h");
efiPrintf("initHardware()");

View File

@ -15,7 +15,7 @@
// mode >= 0 is always true since that's an unsigned
#define assertOMode(mode) { \
efiAssertVoid(CUSTOM_INVALID_MODE_SETTING, mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e"); \
efiAssertVoid(ObdCode::CUSTOM_INVALID_MODE_SETTING, mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e"); \
}
#define efiSetPadModeIfConfigurationChanged(msg, pin, mode) \

View File

@ -50,7 +50,7 @@ static bool hwStarted = false;
* This function should be invoked under kernel lock which would disable interrupts.
*/
void setHardwareSchedulerTimer(efitick_t nowNt, efitick_t setTimeNt) {
efiAssertVoid(OBD_PCM_Processor_Fault, hwStarted, "HW.started");
efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, hwStarted, "HW.started");
// How many ticks in the future is this event?
auto timeDeltaNt = setTimeNt - nowNt;
@ -63,7 +63,7 @@ void setHardwareSchedulerTimer(efitick_t nowNt, efitick_t setTimeNt) {
*/
if (timeDeltaNt <= 0) {
timerFreezeCounter++;
warning(CUSTOM_OBD_LOCAL_FREEZE, "local freeze cnt=%d", timerFreezeCounter);
warning(ObdCode::CUSTOM_OBD_LOCAL_FREEZE, "local freeze cnt=%d", timerFreezeCounter);
}
// We need the timer to fire after we return - 1 doesn't work as it may actually schedule in the past
@ -73,7 +73,7 @@ void setHardwareSchedulerTimer(efitick_t nowNt, efitick_t setTimeNt) {
if (timeDeltaNt >= TOO_FAR_INTO_FUTURE_NT) {
// we are trying to set callback for too far into the future. This does not look right at all
firmwareError(CUSTOM_ERR_TIMER_OVERFLOW, "setHardwareSchedulerTimer() too far: %d", timeDeltaNt);
firmwareError(ObdCode::CUSTOM_ERR_TIMER_OVERFLOW, "setHardwareSchedulerTimer() too far: %d", timeDeltaNt);
return;
}
@ -108,13 +108,13 @@ class MicrosecondTimerWatchdogController : public PeriodicTimerController {
void PeriodicTask() override {
efitick_t nowNt = getTimeNowNt();
if (nowNt >= lastSetTimerTimeNt + 2 * CORE_CLOCK) {
firmwareError(CUSTOM_ERR_SCHEDULING_ERROR, "watchdog: no events since %d", lastSetTimerTimeNt);
firmwareError(ObdCode::CUSTOM_ERR_SCHEDULING_ERROR, "watchdog: no events since %d", lastSetTimerTimeNt);
return;
}
msg = isTimerPending ? "No_cb too long" : "Timer not awhile";
// 2 seconds of inactivity would not look right
efiAssertVoid(CUSTOM_TIMER_WATCHDOG, nowNt < lastSetTimerTimeNt + 2 * CORE_CLOCK, msg);
efiAssertVoid(ObdCode::CUSTOM_TIMER_WATCHDOG, nowNt < lastSetTimerTimeNt + 2 * CORE_CLOCK, msg);
}
int getPeriodMs() override {
@ -143,7 +143,7 @@ static void timerValidationCallback(void*) {
efitimems_t actualTimeSinceScheduling = (getTimeNowMs() - testSchedulingStart);
if (absI(actualTimeSinceScheduling - TEST_CALLBACK_DELAY) > TEST_CALLBACK_DELAY * TIMER_PRECISION_THRESHOLD) {
firmwareError(CUSTOM_ERR_TIMER_TEST_CALLBACK_WRONG_TIME, "hwTimer broken precision: %ld ms", actualTimeSinceScheduling);
firmwareError(ObdCode::CUSTOM_ERR_TIMER_TEST_CALLBACK_WRONG_TIME, "hwTimer broken precision: %ld ms", actualTimeSinceScheduling);
}
}
@ -162,7 +162,7 @@ static void validateHardwareTimer() {
chThdSleepMilliseconds(TEST_CALLBACK_DELAY + 2);
if (!testSchedulingHappened) {
firmwareError(CUSTOM_ERR_TIMER_TEST_CALLBACK_NOT_HAPPENED, "hwTimer not alive");
firmwareError(ObdCode::CUSTOM_ERR_TIMER_TEST_CALLBACK_NOT_HAPPENED, "hwTimer not alive");
}
}

View File

@ -12,7 +12,7 @@ void portSetHardwareSchedulerTimer(efitick_t nowNt, efitick_t setTimeNt) {
}
if (GPTDEVICE.state != GPT_READY) {
firmwareError(CUSTOM_HW_TIMER, "HW timer state %d", GPTDEVICE.state);
firmwareError(ObdCode::CUSTOM_HW_TIMER, "HW timer state %d", GPTDEVICE.state);
return;
}
@ -34,7 +34,7 @@ static constexpr GPTConfig gpt5cfg = { 1000000, /* 1 MHz timer clock.*/
void portInitMicrosecondTimer() {
gptStart(&GPTDEVICE, &gpt5cfg);
efiAssertVoid(CUSTOM_ERR_TIMER_STATE, GPTDEVICE.state == GPT_READY, "hw state");
efiAssertVoid(ObdCode::CUSTOM_ERR_TIMER_STATE, GPTDEVICE.state == GPT_READY, "hw state");
}
#endif // EFI_PROD_CODE

View File

@ -204,7 +204,7 @@ static void createLogFile() {
FRESULT err = f_open(&FDLogFile, logName, FA_OPEN_ALWAYS | FA_WRITE); // Create new file
if (err != FR_OK && err != FR_EXIST) {
sdStatus = SD_STATE_OPEN_FAILED;
warning(CUSTOM_ERR_SD_MOUNT_FAILED, "SD: mount failed");
warning(ObdCode::CUSTOM_ERR_SD_MOUNT_FAILED, "SD: mount failed");
printError("FS mount failed", err); // else - show error
return;
}
@ -212,7 +212,7 @@ static void createLogFile() {
err = f_lseek(&FDLogFile, f_size(&FDLogFile)); // Move to end of the file to append data
if (err) {
sdStatus = SD_STATE_SEEK_FAILED;
warning(CUSTOM_ERR_SD_SEEK_FAILED, "SD: seek failed");
warning(ObdCode::CUSTOM_ERR_SD_SEEK_FAILED, "SD: seek failed");
printError("Seek error", err);
return;
}

View File

@ -63,7 +63,7 @@ bool brain_pin_markUsed(brain_pin_e brainPin, const char *msg) {
if (getBrainUsedPin(index) != NULL) {
/* TODO: get readable name of brainPin... */
firmwareError(CUSTOM_ERR_PIN_ALREADY_USED_1, "Pin \"%s\" required by \"%s\" but is used by \"%s\" %s",
firmwareError(ObdCode::CUSTOM_ERR_PIN_ALREADY_USED_1, "Pin \"%s\" required by \"%s\" but is used by \"%s\" %s",
hwPortname(brainPin),
msg,
getBrainUsedPin(index),
@ -281,8 +281,8 @@ bool gpio_pin_markUsed(ioportid_t port, ioportmask_t pin, const char *msg) {
* todo: the problem is that this warning happens before the console is even
* 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, getBrainUsedPin(index));
firmwareError(CUSTOM_ERR_PIN_ALREADY_USED_1, "%s%d req by %s used by %s", portname(port), pin, msg, getBrainUsedPin(index));
// warning(ObdCode::OBD_PCM_Processor_Fault, "%s%d req by %s used by %s", portname(port), pin, msg, getBrainUsedPin(index));
firmwareError(ObdCode::CUSTOM_ERR_PIN_ALREADY_USED_1, "%s%d req by %s used by %s", portname(port), pin, msg, getBrainUsedPin(index));
return true;
}
getBrainUsedPin(index) = msg;

View File

@ -16,16 +16,12 @@
#define CHPRINTF_USE_FLOAT TRUE
#if !defined(_FROM_ASM_)
#include "obd_error_codes.h"
#endif /* _FROM_ASM_ */
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
#ifndef __ASSEMBLER__
void firmwareError(ObdCode code, const char *fmt, ...);
// void firmwareError(ObdCode code, const char *fmt, ...);
void irqEnterHook(void);
void irqExitHook(void);
void contextSwitchHook(void);

View File

@ -95,7 +95,7 @@ brain_pin_e getAdcChannelBrainPin(const char *msg, adc_channel_e hwChannel) {
case EFI_ADC_31:
return Gpio::C2;
default:
firmwareError(CUSTOM_ERR_ADC_UNKNOWN_CHANNEL, "Unknown hw channel %d [%s]", hwChannel, msg);
firmwareError(ObdCode::CUSTOM_ERR_ADC_UNKNOWN_CHANNEL, "Unknown hw channel %d [%s]", hwChannel, msg);
return Gpio::Invalid;
}
}

View File

@ -64,7 +64,7 @@ const char *portname(ioportid_t GPIOx) {
}
static int getPortIndex(ioportid_t port) {
efiAssert(CUSTOM_ERR_ASSERT, port != NULL, "null port", -1);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, port != NULL, "null port", -1);
if (port == GPIOA)
return 0;
if (port == GPIOB)
@ -87,7 +87,7 @@ static int getPortIndex(ioportid_t port) {
return 9;
if (port == GPIOK)
return 10;
firmwareError(CUSTOM_ERR_UNKNOWN_PORT, "unknown port");
firmwareError(ObdCode::CUSTOM_ERR_UNKNOWN_PORT, "unknown port");
return -1;
}
@ -106,7 +106,7 @@ int getBrainPinIndex(ioportid_t port, ioportmask_t pin) {
ioportid_t getHwPort(const char *msg, brain_pin_e brainPin) {
if (!isBrainPinValid(brainPin)) {
firmwareError(CUSTOM_ERR_INVALID_PIN, "%s: Invalid Gpio: %d", msg, brainPin);
firmwareError(ObdCode::CUSTOM_ERR_INVALID_PIN, "%s: Invalid Gpio: %d", msg, brainPin);
return GPIO_NULL;
}
return ports[(brainPin - Gpio::A0) / PORT_SIZE];
@ -123,7 +123,7 @@ ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin)
if (brain_pin_is_onchip(brainPin))
return getBrainPinIndex(brainPin);
firmwareError(CUSTOM_ERR_INVALID_PIN, "%s: Invalid on-chip brain_pin_e: %d", msg, brainPin);
firmwareError(ObdCode::CUSTOM_ERR_INVALID_PIN, "%s: Invalid on-chip brain_pin_e: %d", msg, brainPin);
return EFI_ERROR_CODE;
}

View File

@ -65,7 +65,7 @@ brain_pin_e getAdcChannelBrainPin(const char *msg, adc_channel_e hwChannel) {
case EFI_ADC_15:
return Gpio::C17;
default:
firmwareError(CUSTOM_ERR_ADC_UNKNOWN_CHANNEL, "Unknown hw channel %d [%s]", hwChannel, msg);
firmwareError(ObdCode::CUSTOM_ERR_ADC_UNKNOWN_CHANNEL, "Unknown hw channel %d [%s]", hwChannel, msg);
return Gpio::Invalid;
}
}

View File

@ -39,7 +39,7 @@ const char *portname(ioportid_t GPIOx) {
}
static int getPortIndex(ioportid_t port) {
efiAssert(CUSTOM_ERR_ASSERT, port != NULL, "null port", -1);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, port != NULL, "null port", -1);
if (port == GPIOA)
return 0;
if (port == GPIOB)
@ -50,7 +50,7 @@ static int getPortIndex(ioportid_t port) {
return 3;
if (port == GPIOE)
return 4;
firmwareError(CUSTOM_ERR_UNKNOWN_PORT, "unknown port");
firmwareError(ObdCode::CUSTOM_ERR_UNKNOWN_PORT, "unknown port");
return -1;
}
@ -69,7 +69,7 @@ int getPortPinIndex(ioportid_t port, ioportmask_t pin) {
ioportid_t getHwPort(const char *msg, brain_pin_e brainPin) {
if (!isBrainPinValid(brainPin)) {
firmwareError(CUSTOM_ERR_INVALID_PIN, "%s: Invalid Gpio: %d", msg, brainPin);
firmwareError(ObdCode::CUSTOM_ERR_INVALID_PIN, "%s: Invalid Gpio: %d", msg, brainPin);
return GPIO_NULL;
}
return ports[(brainPin - Gpio::A0) / PORT_SIZE];
@ -86,7 +86,7 @@ ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin)
if (brain_pin_is_onchip(brainPin))
return getBrainPinIndex(brainPin);
firmwareError(CUSTOM_ERR_INVALID_PIN, "%s: Invalid on-chip Gpio: %d", msg, brainPin);
firmwareError(ObdCode::CUSTOM_ERR_INVALID_PIN, "%s: Invalid on-chip Gpio: %d", msg, brainPin);
return EFI_ERROR_CODE;
}

View File

@ -21,7 +21,7 @@ uint32_t backupRamLoad(backup_ram_e idx) {
// case DFU_JUMP_REQUESTED:
// return RTCD1.rtc->BKP4R;
default:
firmwareError(OBD_PCM_Processor_Fault, "Invalid backup ram idx %d", idx);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Invalid backup ram idx %d", idx);
return 0;
}
#else
@ -49,7 +49,7 @@ void backupRamSave(backup_ram_e idx, uint32_t value) {
RTCD1.rtc->BKP4R = value;
break;
default:
firmwareError(OBD_PCM_Processor_Fault, "Invalid backup ram idx %d, value 0x08x", idx, value);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Invalid backup ram idx %d, value 0x08x", idx, value);
break;
}
#endif /* HAL_USE_RTC */

View File

@ -105,7 +105,7 @@ float getMcuTemperature() {
if (degrees > 150.0f || degrees < -50.0f) {
/*
* we have a sporadic issue with this check todo https://github.com/rusefi/rusefi/issues/2552
firmwareError(OBD_PCM_Processor_Fault, "Invalid CPU temperature measured %f", degrees);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Invalid CPU temperature measured %f", degrees);
*/
}

View File

@ -92,7 +92,7 @@ brain_pin_e getAdcChannelBrainPin(const char *msg, adc_channel_e hwChannel) {
default:
/* todo: what is upper range ADC is used while lower range ADC is not used? how do we still mark pin used?
external muxes for internal ADC #3350
firmwareError(CUSTOM_ERR_ADC_UNKNOWN_CHANNEL, "Unknown hw channel %d [%s]", hwChannel, msg);
firmwareError(ObdCode::CUSTOM_ERR_ADC_UNKNOWN_CHANNEL, "Unknown hw channel %d [%s]", hwChannel, msg);
*/
return Gpio::Invalid;
}
@ -135,7 +135,7 @@ adc_channel_e getAdcChannel(brain_pin_e pin) {
case Gpio::Unassigned:
return EFI_ADC_NONE;
default:
firmwareError(OBD_PCM_Processor_Fault, "getAdcChannel %d", pin);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "getAdcChannel %d", pin);
return EFI_ADC_ERROR;
}
}
@ -181,14 +181,14 @@ public:
// These timers are only 16 bit - don't risk overflow
if (m_period > 0xFFF0) {
firmwareError(CUSTOM_OBD_LOW_FREQUENCY, "PWM Frequency too low %f hz on pin \"%s\"", frequency, msg);
firmwareError(ObdCode::CUSTOM_OBD_LOW_FREQUENCY, "PWM Frequency too low %f hz on pin \"%s\"", frequency, msg);
return;
}
// If we have too few usable bits, we run out of resolution, so don't allow that either.
// 200 counts = 0.5% resolution
if (m_period < 200) {
firmwareError(CUSTOM_OBD_HIGH_FREQUENCY, "PWM Frequency too high %d hz on pin \"%s\"", frequency, msg);
firmwareError(ObdCode::CUSTOM_OBD_HIGH_FREQUENCY, "PWM Frequency too high %d hz on pin \"%s\"", frequency, msg);
return;
}
@ -215,7 +215,7 @@ public:
void setDuty(float duty) override {
if (!m_driver) {
firmwareError(OBD_PCM_Processor_Fault, "Attempted to set duty on null hard PWM device");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Attempted to set duty on null hard PWM device");
return;
}
@ -309,7 +309,7 @@ stm32_hardware_pwm* getNextPwmDevice() {
}
}
firmwareError(OBD_PCM_Processor_Fault, "Run out of hardware PWM devices!");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Run out of hardware PWM devices!");
return nullptr;
}
@ -706,7 +706,7 @@ CANDriver* detectCanDevice(brain_pin_e pinRx, brain_pin_e pinTx) {
if (isValidCan2RxPin(pinRx) && isValidCan2TxPin(pinTx))
return &CAND2;
#endif
firmwareError(OBD_PCM_Processor_Fault, "invalid CAN pins tx %s and rx %s", hwPortname(pinTx), hwPortname(pinRx));
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "invalid CAN pins tx %s and rx %s", hwPortname(pinTx), hwPortname(pinRx));
return nullptr;
}

View File

@ -99,7 +99,7 @@ const char *portname(ioportid_t GPIOx) {
}
static int getPortIndex(ioportid_t port) {
efiAssert(CUSTOM_ERR_ASSERT, port != NULL, "null port", -1);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, port != NULL, "null port", -1);
if (port == GPIOA)
return 0;
if (port == GPIOB)
@ -136,7 +136,7 @@ static int getPortIndex(ioportid_t port) {
if (port == GPIOK)
return 10;
#endif /* STM32_HAS_GPIOK */
firmwareError(CUSTOM_ERR_UNKNOWN_PORT, "unknown port");
firmwareError(ObdCode::CUSTOM_ERR_UNKNOWN_PORT, "unknown port");
return -1;
}
@ -159,7 +159,7 @@ ioportid_t getHwPort(const char *msg, brain_pin_e brainPin) {
if (!isBrainPinValid(brainPin)) {
/*
* https://github.com/dron0gus please help
firmwareError(CUSTOM_ERR_INVALID_PIN, "%s: Invalid Gpio: %d", msg, brainPin);
firmwareError(ObdCode::CUSTOM_ERR_INVALID_PIN, "%s: Invalid Gpio: %d", msg, brainPin);
*/
return GPIO_NULL;
}
@ -177,7 +177,7 @@ ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin)
if (brain_pin_is_onchip(brainPin))
return getBrainPinIndex(brainPin);
firmwareError(CUSTOM_ERR_INVALID_PIN, "%s: Invalid on-chip Gpio: %d", msg, brainPin);
firmwareError(ObdCode::CUSTOM_ERR_INVALID_PIN, "%s: Invalid on-chip Gpio: %d", msg, brainPin);
return EFI_ERROR_CODE;
}

View File

@ -39,14 +39,14 @@ static DeviceType determineDevice() {
} else {
if (fs == 1024) {
// Unsupported scenario! Not enough space for program plus two config copies
firmwareError(OBD_PCM_Processor_Fault, "1MB single bank MCU detected: please clear nDBANK option bit and reinstall FW.");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "1MB single bank MCU detected: please clear nDBANK option bit and reinstall FW.");
return DeviceType::SingleBank1MB;
} else if (fs == 2048) {
return DeviceType::SingleBank2MB;
}
}
firmwareError(OBD_PCM_Processor_Fault, "Unrecognized flash memory layout db=%d, size=%d", db, fs);
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Unrecognized flash memory layout db=%d, size=%d", db, fs);
return DeviceType::Unknown;
}

View File

@ -91,7 +91,7 @@ RTCDateTime convertRtcDateTimeFromEfi(efidatetime_t const * const dateTime) {
static void put2(int offset, char *lcd_str, int value) {
static char buff[_MAX_FILLER];
efiAssertVoid(CUSTOM_ERR_6666, value >=0 && value <100, "value");
efiAssertVoid(ObdCode::CUSTOM_ERR_6666, value >=0 && value <100, "value");
itoa10(buff, value);
if (value < 10) {
lcd_str[offset] = '0';

View File

@ -221,7 +221,7 @@ void initSmartGpio() {
tle6240.spi_bus = getSpiDevice(engineConfiguration->tle6240spiDevice);
int ret = tle6240_add(Gpio::TLE6240_PIN_1, 0, &tle6240);
efiAssertVoid(OBD_PCM_Processor_Fault, ret == (int)Gpio::TLE6240_PIN_1, "tle6240");
efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, ret == (int)Gpio::TLE6240_PIN_1, "tle6240");
}
#endif /* (BOARD_TLE6240_COUNT > 0) */
@ -234,7 +234,7 @@ void initSmartGpio() {
// todo: propogate 'basePinOffset' parameter
int ret = mc33972_add(Gpio::MC33972_PIN_1, 0, &mc33972);
efiAssertVoid(OBD_PCM_Processor_Fault, ret == (int)Gpio::MC33972_PIN_1, "mc33972");
efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, ret == (int)Gpio::MC33972_PIN_1, "mc33972");
}
#endif /* (BOARD_MC33972_COUNT > 0) */
@ -247,7 +247,7 @@ void initSmartGpio() {
// todo: propogate 'basePinOffset' parameter
int ret = l9779_add(Gpio::L9779_IGN_1, 0, &l9779_cfg);
efiAssertVoid(OBD_PCM_Processor_Fault, ret == (int)Gpio::L9779_IGN_1, "l9779");
efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, ret == (int)Gpio::L9779_IGN_1, "l9779");
}
#endif /* (BOARD_L9779_COUNT > 0) */
@ -264,7 +264,7 @@ void initSmartGpio() {
/* spi_bus == null checked in _add function */
int ret = tle8888_add(Gpio::TLE8888_PIN_1, 0, &tle8888_cfg);
efiAssertVoid(OBD_PCM_Processor_Fault, ret == (int)Gpio::TLE8888_PIN_1, "tle8888");
efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, ret == (int)Gpio::TLE8888_PIN_1, "tle8888");
}
#endif /* (BOARD_TLE8888_COUNT > 0) */
@ -275,7 +275,7 @@ void initSmartGpio() {
drv8860.spi_bus = getSpiDevice(engineConfiguration->drv8860spiDevice);
int ret = drv8860_add(Gpio::DRV8860_PIN_1, 0, &drv8860);
efiAssertVoid(OBD_PCM_Processor_Fault, ret == (int)Gpio::DRV8860_PIN_1, "drv8860");
efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, ret == (int)Gpio::DRV8860_PIN_1, "drv8860");
}
#endif /* (BOARD_DRV8860_COUNT > 0) */

View File

@ -41,7 +41,7 @@ void DualHBridgeStepper::initialize(DcMotor* motorPhaseA, DcMotor* motorPhaseB,
m_motorPhaseA = motorPhaseA;
m_motorPhaseB = motorPhaseB;
efiAssertVoid(CUSTOM_ERR_ASSERT, engineConfiguration->stepperNumMicroSteps <= maxNumSteps, "stepperNumMicroSteps");
efiAssertVoid(ObdCode::CUSTOM_ERR_ASSERT, engineConfiguration->stepperNumMicroSteps <= maxNumSteps, "stepperNumMicroSteps");
}
bool DualHBridgeStepper::step(bool positive) {

View File

@ -50,7 +50,7 @@ void initLambda() {
#if EFI_CAN_SUPPORT
if (engineConfiguration->enableAemXSeries) {
if (!engineConfiguration->canWriteEnabled || !engineConfiguration->canReadEnabled) {
firmwareError(OBD_PCM_Processor_Fault, "CAN read and write are required to use CAN wideband.");
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "CAN read and write are required to use CAN wideband.");
return;
}

View File

@ -68,7 +68,7 @@ static MapCfg getMapCfg(air_pressure_sensor_type_e sensorType) {
case MT_MPXH6400:
return {0.2, 20, 4.8, 400};
default:
firmwareError(CUSTOM_ERR_MAP_TYPE, "Unknown MAP type: decoder %d", sensorType);
firmwareError(ObdCode::CUSTOM_ERR_MAP_TYPE, "Unknown MAP type: decoder %d", sensorType);
// falls through to custom
return {};
case MT_CUSTOM: {

View File

@ -26,7 +26,7 @@ static FuncPair fclt, fiat, faux1, faux2;
static void validateThermistorConfig(const char *msg, thermistor_conf_s& cfg) {
if (cfg.tempC_1 >= cfg.tempC_2 ||
cfg.tempC_2 >= cfg.tempC_3) {
firmwareError(OBD_ThermistorConfig, "Invalid thermistor %s configuration: please check that temperatures are in the ascending order %f %f %f",
firmwareError(ObdCode::OBD_ThermistorConfig, "Invalid thermistor %s configuration: please check that temperatures are in the ascending order %f %f %f",
msg,
cfg.tempC_1,
cfg.tempC_2,

View File

@ -70,7 +70,7 @@ private:
// If the voltage for closed vs. open is very near, something is wrong with your calibration
if (split < 0.5f) {
firmwareError(OBD_TPS_Configuration, "\"%s\" problem: open %.2f/closed %.2f cal values are too close together. Check your calibration and wiring!", name(),
firmwareError(ObdCode::OBD_TPS_Configuration, "\"%s\" problem: open %.2f/closed %.2f cal values are too close together. Check your calibration and wiring!", name(),
cfg.open,
cfg.closed);
return false;
@ -116,7 +116,7 @@ public:
bool tooCloseOpen = absF(primary.open - secondary.open) < 0.2f;
if (hasBothSensors && tooCloseClosed && tooCloseOpen) {
firmwareError(OBD_TPS_Configuration, "Configuration for redundant pair %s/%s are too similar - did you wire one sensor to both inputs...?", m_pri.name(), m_sec.name());
firmwareError(ObdCode::OBD_TPS_Configuration, "Configuration for redundant pair %s/%s are too similar - did you wire one sensor to both inputs...?", m_pri.name(), m_sec.name());
return;
}
}
@ -189,7 +189,7 @@ bool isDigitalTps1() {
}
void initTps() {
efiAssertVoid(OBD_PCM_Processor_Fault, engineConfiguration != nullptr, "null engineConfiguration");
efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, engineConfiguration != nullptr, "null engineConfiguration");
percent_t min = engineConfiguration->tpsErrorDetectionTooLow;
percent_t max = engineConfiguration->tpsErrorDetectionTooHigh;

View File

@ -44,16 +44,16 @@ static void doAddAction(const char *token, action_type_e type, Void callback, vo
for (uint32_t i = 0; i < efiStrlen(token);i++) {
char ch = token[i];
if (isupper(ch)) {
firmwareError(CUSTOM_ERR_COMMAND_LOWER_CASE_EXPECTED, "lowerCase expected [%s]", token);
firmwareError(ObdCode::CUSTOM_ERR_COMMAND_LOWER_CASE_EXPECTED, "lowerCase expected [%s]", token);
}
}
for (int i = 0; i < consoleActionCount; i++) {
if (strcmp(token, consoleActions[i].token) == 0 /* zero result means strings are equal */) {
firmwareError(CUSTOM_SAME_TWICE, "Same action twice [%s]", token);
firmwareError(ObdCode::CUSTOM_SAME_TWICE, "Same action twice [%s]", token);
}
}
efiAssertVoid(CUSTOM_CONSOLE_TOO_MANY, consoleActionCount < CONSOLE_MAX_ACTIONS, "Too many console actions");
efiAssertVoid(ObdCode::CUSTOM_CONSOLE_TOO_MANY, consoleActionCount < CONSOLE_MAX_ACTIONS, "Too many console actions");
TokenCallback *current = &consoleActions[consoleActionCount++];
current->token = token;
current->parameterType = type;

View File

@ -57,7 +57,7 @@ bool FLStack<T, MAXSIZE>::remove(T value) {
template<typename T, int MAXSIZE>
void FLStack<T, MAXSIZE>::push(T value) {
if (currentSize >= MAXSIZE) {
firmwareError(ERROR_FL_STACK_OVERFLOW, "FLstack overflow");
firmwareError(ObdCode::ERROR_FL_STACK_OVERFLOW, "FLstack overflow");
return;
//warning()
}
@ -67,7 +67,7 @@ void FLStack<T, MAXSIZE>::push(T value) {
template<typename T, int MAXSIZE>
T FLStack<T, MAXSIZE>::pop() {
if (currentSize == 0) {
firmwareError(CUSTOM_FLSTACK, "FLStack is empty");
firmwareError(ObdCode::CUSTOM_FLSTACK, "FLStack is empty");
}
return values[--currentSize];
}
@ -77,7 +77,7 @@ T FLStack<T, MAXSIZE>::pop() {
*/
template<typename T, int MAXSIZE>
T FLStack<T, MAXSIZE>::get(int index) {
efiAssert(CUSTOM_ERR_ASSERT, index >= 0 && index < MAXSIZE, "FLget", values[0]);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, index >= 0 && index < MAXSIZE, "FLget", values[0]);
return values[index];
}
@ -105,7 +105,7 @@ ArrayList<Type, Dimention>::ArrayList(void) {
template<class Type, int Dimention>
void ArrayList<Type, Dimention>::removeAt(int index) {
efiAssertVoid(CUSTOM_ERR_ARRAY_REMOVE, index >= 0 && index < size, "invalid index");
efiAssertVoid(ObdCode::CUSTOM_ERR_ARRAY_REMOVE, index >= 0 && index < size, "invalid index");
memcpy(&elements[index], &elements[size - 1], sizeof(Type));
memset(&elements[size - 1], 0, sizeof(Type));
size--;
@ -118,6 +118,6 @@ void ArrayList<Type, Dimention>::reset(void) {
template<class Type, int Dimention>
Type * ArrayList<Type, Dimention>::add(void) {
efiAssert(CUSTOM_ERR_ASSERT, size < Dimention, "add() too many elements", (Type *)NULL);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, size < Dimention, "add() too many elements", (Type *)NULL);
return &elements[size++];
}

Some files were not shown because too many files have changed in this diff Show More