it's going to be painful
This commit is contained in:
parent
ea43e867c0
commit
51d0f6e347
|
@ -33,7 +33,7 @@ static void testCritical() {
|
|||
}
|
||||
|
||||
static void myerror() {
|
||||
firmwareError(CUSTOM_ERR_TEST_ERROR, "firmwareError: %d", getRusEfiVersion());
|
||||
firmwareError(ObdCode::CUSTOM_ERR_TEST_ERROR, "firmwareError: %d", getRusEfiVersion());
|
||||
}
|
||||
|
||||
static void sayHello() {
|
||||
|
@ -77,7 +77,7 @@ static void sayHello() {
|
|||
|
||||
int flashSize = TM_ID_GetFlashSize();
|
||||
if (flashSize < MIN_FLASH_SIZE) {
|
||||
firmwareError(OBD_PCM_Processor_Fault, "rusEFI expected at least %dK of flash", MIN_FLASH_SIZE);
|
||||
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "rusEFI expected at least %dK of flash", MIN_FLASH_SIZE);
|
||||
}
|
||||
|
||||
// todo: bug, at the moment we report 1MB on dual-bank F7
|
||||
|
@ -183,7 +183,7 @@ static void cmd_threads() {
|
|||
efiPrintf("%s\t%08x\t%lu\t%d", tp->name, tp->wabase, tp->time, freeBytes);
|
||||
|
||||
if (freeBytes < 100) {
|
||||
firmwareError(OBD_PCM_Processor_Fault, "Ran out of stack on thread %s, %d bytes remain", tp->name, freeBytes);
|
||||
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Ran out of stack on thread %s, %d bytes remain", tp->name, freeBytes);
|
||||
}
|
||||
|
||||
tp = chRegNextThread(tp);
|
||||
|
|
|
@ -125,7 +125,7 @@ void Engine::updateTriggerWaveform() {
|
|||
#if ANALOG_HW_CHECK_MODE
|
||||
static void assertCloseTo(const char* msg, float actual, float expected) {
|
||||
if (actual < 0.95f * expected || actual > 1.05f * expected) {
|
||||
firmwareError(OBD_PCM_Processor_Fault, "%s validation failed actual=%f vs expected=%f", msg, actual, expected);
|
||||
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "%s validation failed actual=%f vs expected=%f", msg, actual, expected);
|
||||
}
|
||||
}
|
||||
#endif // ANALOG_HW_CHECK_MODE
|
||||
|
@ -401,7 +401,7 @@ void Engine::efiWatchdog() {
|
|||
if (mostRecentMs != 0) {
|
||||
efitimems_t gapInMs = msNow - mostRecentMs;
|
||||
if (gapInMs > 500) {
|
||||
firmwareError(WATCH_DOG_SECONDS, "gap in time: now=%d mS, was %d mS, gap=%dmS",
|
||||
firmwareError(ObdCode::WATCH_DOG_SECONDS, "gap in time: now=%d mS, was %d mS, gap=%dmS",
|
||||
msNow, mostRecentMs, gapInMs);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ __attribute__((weak)) void boardOnConfigurationChange(engine_configuration_s* /*
|
|||
*/
|
||||
void incrementGlobalConfigurationVersion(const char * msg) {
|
||||
if (!hasRememberedConfiguration) {
|
||||
firmwareError(OBD_PCM_Processor_Fault, "too early to invoke incrementGlobalConfigurationVersion %s", msg);
|
||||
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "too early to invoke incrementGlobalConfigurationVersion %s", msg);
|
||||
}
|
||||
engine->globalConfigurationVersion++;
|
||||
#if EFI_DEFAILED_LOGGING
|
||||
|
|
|
@ -39,7 +39,7 @@ void auxPlainPinTurnOn(AuxActor *current) {
|
|||
|
||||
angle_t duration = engine->engineState.auxValveEnd - engine->engineState.auxValveStart;
|
||||
|
||||
fixAngle(duration, "duration", CUSTOM_ERR_6557);
|
||||
fixAngle(duration, "duration", ObdCode::CUSTOM_ERR_6557);
|
||||
|
||||
engine->module<TriggerScheduler>()->schedule(¤t->close,
|
||||
current->extra + engine->engineState.auxValveEnd,
|
||||
|
@ -53,7 +53,7 @@ void initAuxValves() {
|
|||
}
|
||||
|
||||
if (!Sensor::hasSensor(SensorType::DriverThrottleIntent)) {
|
||||
firmwareError(CUSTOM_OBD_91, "No TPS for Aux Valves");
|
||||
firmwareError(ObdCode::CUSTOM_OBD_91, "No TPS for Aux Valves");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ void recalculateAuxValveTiming() {
|
|||
|
||||
if (engine->engineState.auxValveStart >= engine->engineState.auxValveEnd) {
|
||||
// this is a fatal error to make this really visible
|
||||
firmwareError(CUSTOM_AUX_OUT_OF_ORDER, "out of order at %.2f %.2f %.2f", tps,
|
||||
firmwareError(ObdCode::CUSTOM_AUX_OUT_OF_ORDER, "out of order at %.2f %.2f %.2f", tps,
|
||||
engine->engineState.auxValveStart,
|
||||
engine->engineState.auxValveEnd);
|
||||
}
|
||||
|
|
|
@ -186,7 +186,7 @@ bool FuelSchedule::addFuelEventsForCylinder(int i) {
|
|||
|
||||
if (!isSimultaneous && !output->isInitialized()) {
|
||||
// todo: extract method for this index math
|
||||
warning(CUSTOM_OBD_INJECTION_NO_PIN_ASSIGNED, "no_pin_inj #%s", output->name);
|
||||
warning(ObdCode::CUSTOM_OBD_INJECTION_NO_PIN_ASSIGNED, "no_pin_inj #%s", output->name);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -54,7 +54,7 @@ static void fireSparkBySettingPinLow(IgnitionEvent *event, IgnitionOutputPin *ou
|
|||
output->signalFallSparkId = event->sparkId;
|
||||
|
||||
if (!output->currentLogicValue && !event->wasSparkLimited) {
|
||||
warning(CUSTOM_OUT_OF_ORDER_COIL, "out-of-order coil off %s", output->getName());
|
||||
warning(ObdCode::CUSTOM_OUT_OF_ORDER_COIL, "out-of-order coil off %s", output->getName());
|
||||
output->outOfOrder = true;
|
||||
}
|
||||
output->setLow();
|
||||
|
@ -62,7 +62,7 @@ static void fireSparkBySettingPinLow(IgnitionEvent *event, IgnitionOutputPin *ou
|
|||
|
||||
static void assertPinAssigned(IgnitionOutputPin* output) {
|
||||
if (!output->isInitialized()) {
|
||||
warning(CUSTOM_OBD_COIL_PIN_NOT_ASSIGNED, "Pin Not Assigned check configuration #%s", output->getName()); \
|
||||
warning(ObdCode::CUSTOM_OBD_COIL_PIN_NOT_ASSIGNED, "Pin Not Assigned check configuration #%s", output->getName()); \
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ static int getIgnitionPinForIndex(int cylinderIndex, ignition_mode_e ignitionMod
|
|||
return cylinderIndex % 2;
|
||||
|
||||
default:
|
||||
firmwareError(CUSTOM_OBD_IGNITION_MODE, "Invalid ignition mode getIgnitionPinForIndex(): %d", engineConfiguration->ignitionMode);
|
||||
firmwareError(ObdCode::CUSTOM_OBD_IGNITION_MODE, "Invalid ignition mode getIgnitionPinForIndex(): %d", engineConfiguration->ignitionMode);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngleDuration, floatms_
|
|||
// Offset by this cylinder's position in the cycle
|
||||
+ getPerCylinderFiringOrderOffset(event->cylinderIndex, event->cylinderNumber);
|
||||
|
||||
efiAssertVoid(CUSTOM_SPARK_ANGLE_1, !cisnan(sparkAngle), "sparkAngle#1");
|
||||
efiAssertVoid(ObdCode::CUSTOM_SPARK_ANGLE_1, !cisnan(sparkAngle), "sparkAngle#1");
|
||||
|
||||
auto ignitionMode = getCurrentIgnitionMode();
|
||||
|
||||
|
@ -135,17 +135,17 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngleDuration, floatms_
|
|||
event->outputs[0] = output;
|
||||
event->outputs[1] = secondOutput;
|
||||
|
||||
wrapAngle2(sparkAngle, "findAngle#2", CUSTOM_ERR_6550, getEngineCycle(getEngineRotationState()->getOperationMode()));
|
||||
wrapAngle2(sparkAngle, "findAngle#2", ObdCode::CUSTOM_ERR_6550, getEngineCycle(getEngineRotationState()->getOperationMode()));
|
||||
event->sparkAngle = sparkAngle;
|
||||
// Stash which cylinder we're scheduling so that knock sensing knows which
|
||||
// cylinder just fired
|
||||
event->cylinderNumber = coilIndex;
|
||||
|
||||
angle_t dwellStartAngle = sparkAngle - dwellAngleDuration;
|
||||
efiAssertVoid(CUSTOM_ERR_6590, !cisnan(dwellStartAngle), "findAngle#5");
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_6590, !cisnan(dwellStartAngle), "findAngle#5");
|
||||
|
||||
assertAngleRange(dwellStartAngle, "findAngle dwellStartAngle", CUSTOM_ERR_6550);
|
||||
wrapAngle2(dwellStartAngle, "findAngle#7", CUSTOM_ERR_6550, getEngineCycle(getEngineRotationState()->getOperationMode()));
|
||||
assertAngleRange(dwellStartAngle, "findAngle dwellStartAngle", ObdCode::CUSTOM_ERR_6550);
|
||||
wrapAngle2(dwellStartAngle, "findAngle#7", ObdCode::CUSTOM_ERR_6550, getEngineCycle(getEngineRotationState()->getOperationMode()));
|
||||
event->dwellAngle = dwellStartAngle;
|
||||
|
||||
#if FUEL_MATH_EXTREME_LOGGING
|
||||
|
@ -269,7 +269,7 @@ static void startDwellByTurningSparkPinHigh(IgnitionEvent *event, IgnitionOutput
|
|||
if (Sensor::getOrZero(SensorType::Rpm) > 2 * engineConfiguration->cranking.rpm) {
|
||||
const char *outputName = output->getName();
|
||||
if (prevSparkName == outputName && getCurrentIgnitionMode() != IM_ONE_COIL) {
|
||||
warning(CUSTOM_OBD_SKIPPED_SPARK, "looks like skipped spark event %d %s", getRevolutionCounter(), outputName);
|
||||
warning(ObdCode::CUSTOM_OBD_SKIPPED_SPARK, "looks like skipped spark event %d %s", getRevolutionCounter(), outputName);
|
||||
}
|
||||
prevSparkName = outputName;
|
||||
}
|
||||
|
@ -324,11 +324,11 @@ static void scheduleSparkEvent(bool limitedSpark, IgnitionEvent *event,
|
|||
angle_t sparkAngle = event->sparkAngle;
|
||||
const floatms_t dwellMs = engine->ignitionState.sparkDwell;
|
||||
if (cisnan(dwellMs) || dwellMs <= 0) {
|
||||
warning(CUSTOM_DWELL, "invalid dwell to handle: %.2f at %d", dwellMs, rpm);
|
||||
warning(ObdCode::CUSTOM_DWELL, "invalid dwell to handle: %.2f at %d", dwellMs, rpm);
|
||||
return;
|
||||
}
|
||||
if (cisnan(sparkAngle)) {
|
||||
warning(CUSTOM_ADVANCE_SPARK, "NaN advance");
|
||||
warning(ObdCode::CUSTOM_ADVANCE_SPARK, "NaN advance");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -372,8 +372,8 @@ static void scheduleSparkEvent(bool limitedSpark, IgnitionEvent *event,
|
|||
* Spark event is often happening during a later trigger event timeframe
|
||||
*/
|
||||
|
||||
efiAssertVoid(CUSTOM_ERR_6591, !cisnan(sparkAngle), "findAngle#4");
|
||||
assertAngleRange(sparkAngle, "findAngle#a5", CUSTOM_ERR_6549);
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_6591, !cisnan(sparkAngle), "findAngle#4");
|
||||
assertAngleRange(sparkAngle, "findAngle#a5", ObdCode::CUSTOM_ERR_6549);
|
||||
|
||||
bool scheduled = engine->module<TriggerScheduler>()->scheduleOrQueue(
|
||||
&event->sparkEvent, edgeTimestamp, sparkAngle,
|
||||
|
@ -415,7 +415,7 @@ void initializeIgnitionActions() {
|
|||
list->isReady = false;
|
||||
return;
|
||||
}
|
||||
efiAssertVoid(CUSTOM_ERR_6592, engineConfiguration->cylindersCount > 0, "cylindersCount");
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_6592, engineConfiguration->cylindersCount > 0, "cylindersCount");
|
||||
|
||||
for (size_t cylinderIndex = 0; cylinderIndex < engineConfiguration->cylindersCount; cylinderIndex++) {
|
||||
list->elements[cylinderIndex].cylinderIndex = cylinderIndex;
|
||||
|
@ -442,10 +442,10 @@ static void prepareIgnitionSchedule() {
|
|||
}
|
||||
|
||||
if (engine->ignitionState.dwellAngle == 0) {
|
||||
warning(CUSTOM_ZERO_DWELL, "dwell is zero?");
|
||||
warning(ObdCode::CUSTOM_ZERO_DWELL, "dwell is zero?");
|
||||
}
|
||||
if (engine->ignitionState.dwellAngle > maxAllowedDwellAngle) {
|
||||
warning(CUSTOM_DWELL_TOO_LONG, "dwell angle too long: %.2f", engine->ignitionState.dwellAngle);
|
||||
warning(ObdCode::CUSTOM_DWELL_TOO_LONG, "dwell angle too long: %.2f", engine->ignitionState.dwellAngle);
|
||||
}
|
||||
|
||||
// todo: add some check for dwell overflow? like 4 times 6 ms while engine cycle is less then that
|
||||
|
@ -491,7 +491,7 @@ void onTriggerEventSparkLogic(int rpm, efitick_t edgeTimestamp, float currentPha
|
|||
// artificial misfire on cylinder #1 for testing purposes
|
||||
// enable artificialMisfire
|
||||
// set_fsio_setting 6 20
|
||||
warning(CUSTOM_ARTIFICIAL_MISFIRE, "artificial misfire on cylinder #1 for testing purposes %d", engine->engineState.sparkCounter);
|
||||
warning(ObdCode::CUSTOM_ARTIFICIAL_MISFIRE, "artificial misfire on cylinder #1 for testing purposes %d", engine->engineState.sparkCounter);
|
||||
continue;
|
||||
}
|
||||
#if EFI_LAUNCH_CONTROL
|
||||
|
@ -537,7 +537,7 @@ int getNumberOfSparks(ignition_mode_e mode) {
|
|||
case IM_WASTED_SPARK:
|
||||
return 2;
|
||||
default:
|
||||
firmwareError(CUSTOM_ERR_IGNITION_MODE, "Unexpected ignition_mode_e %d", mode);
|
||||
firmwareError(ObdCode::CUSTOM_ERR_IGNITION_MODE, "Unexpected ignition_mode_e %d", mode);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ floatms_t IgnitionState::getSparkDwell(int rpm) {
|
|||
if (engine->rpmCalculator.isCranking()) {
|
||||
dwellMs = engineConfiguration->ignitionDwellForCrankingMs;
|
||||
} else {
|
||||
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(rpm), "invalid rpm", NAN);
|
||||
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !cisnan(rpm), "invalid rpm", NAN);
|
||||
|
||||
baseDwell = interpolate2d(rpm, config->sparkDwellRpmBins, config->sparkDwellValues);
|
||||
dwellVoltageCorrection = interpolate2d(
|
||||
|
@ -104,7 +104,7 @@ floatms_t IgnitionState::getSparkDwell(int rpm) {
|
|||
|
||||
if (cisnan(dwellMs) || dwellMs <= 0) {
|
||||
// this could happen during engine configuration reset
|
||||
warning(CUSTOM_ERR_DWELL_DURATION, "invalid dwell: %.2f at rpm=%d", dwellMs, rpm);
|
||||
warning(ObdCode::CUSTOM_ERR_DWELL_DURATION, "invalid dwell: %.2f at rpm=%d", dwellMs, rpm);
|
||||
return 0;
|
||||
}
|
||||
return dwellMs;
|
||||
|
@ -227,7 +227,7 @@ static size_t getFiringOrderLength() {
|
|||
return 16;
|
||||
|
||||
default:
|
||||
firmwareError(CUSTOM_OBD_UNKNOWN_FIRING_ORDER, "Invalid firing order: %d", engineConfiguration->firingOrder);
|
||||
firmwareError(ObdCode::CUSTOM_OBD_UNKNOWN_FIRING_ORDER, "Invalid firing order: %d", engineConfiguration->firingOrder);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -319,7 +319,7 @@ static const uint8_t* getFiringOrderTable()
|
|||
return order_1_14_9_4_7_12_15_6_13_8_3_16_11_2_5_10;
|
||||
|
||||
default:
|
||||
firmwareError(CUSTOM_OBD_UNKNOWN_FIRING_ORDER, "Invalid firing order: %d", engineConfiguration->firingOrder);
|
||||
firmwareError(ObdCode::CUSTOM_OBD_UNKNOWN_FIRING_ORDER, "Invalid firing order: %d", engineConfiguration->firingOrder);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -333,18 +333,18 @@ size_t getCylinderId(size_t index) {
|
|||
const size_t firingOrderLength = getFiringOrderLength();
|
||||
|
||||
if (firingOrderLength < 1 || firingOrderLength > MAX_CYLINDER_COUNT) {
|
||||
firmwareError(CUSTOM_FIRING_LENGTH, "fol %d", firingOrderLength);
|
||||
firmwareError(ObdCode::CUSTOM_FIRING_LENGTH, "fol %d", firingOrderLength);
|
||||
return 1;
|
||||
}
|
||||
if (engineConfiguration->cylindersCount != firingOrderLength) {
|
||||
// May 2020 this somehow still happens with functional tests, maybe race condition?
|
||||
firmwareError(CUSTOM_OBD_WRONG_FIRING_ORDER, "Wrong cyl count for firing order, expected %d cylinders", firingOrderLength);
|
||||
firmwareError(ObdCode::CUSTOM_OBD_WRONG_FIRING_ORDER, "Wrong cyl count for firing order, expected %d cylinders", firingOrderLength);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (index >= firingOrderLength) {
|
||||
// May 2020 this somehow still happens with functional tests, maybe race condition?
|
||||
warning(CUSTOM_ERR_6686, "firing order index %d", index);
|
||||
warning(ObdCode::CUSTOM_ERR_6686, "firing order index %d", index);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -423,7 +423,7 @@ angle_t getPerCylinderFiringOrderOffset(uint8_t cylinderIndex, uint8_t cylinderN
|
|||
// We get a cylinder every n-th of an engine cycle where N is the number of cylinders
|
||||
auto firingOrderOffset = engine->engineState.engineCycle * cylinderIndex / engineConfiguration->cylindersCount;
|
||||
|
||||
assertAngleRange(firingOrderOffset, "getPerCylinderFiringOrderOffset", CUSTOM_ERR_6566);
|
||||
assertAngleRange(firingOrderOffset, "getPerCylinderFiringOrderOffset", ObdCode::CUSTOM_ERR_6566);
|
||||
|
||||
return firingOrderOffset;
|
||||
}
|
||||
|
|
|
@ -461,7 +461,7 @@ bool OutputPin::getAndSet(int logicValue) {
|
|||
void OutputPin::setOnchipValue(int electricalValue) {
|
||||
if (brainPin == Gpio::Unassigned || brainPin == Gpio::Invalid) {
|
||||
// todo: make 'setOnchipValue' or 'reportsetOnchipValueError' virtual and override for NamedOutputPin?
|
||||
warning(CUSTOM_ERR_6586, "attempting to change unassigned pin");
|
||||
warning(ObdCode::CUSTOM_ERR_6586, "attempting to change unassigned pin");
|
||||
return;
|
||||
}
|
||||
palWritePad(port, pin, electricalValue);
|
||||
|
@ -491,9 +491,9 @@ void OutputPin::setValue(int logicValue) {
|
|||
return;
|
||||
}
|
||||
|
||||
efiAssertVoid(CUSTOM_ERR_6621, modePtr!=NULL, "pin mode not initialized");
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_6621, modePtr!=NULL, "pin mode not initialized");
|
||||
pin_output_mode_e mode = *modePtr;
|
||||
efiAssertVoid(CUSTOM_ERR_6622, mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e");
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_6622, mode <= OM_OPENDRAIN_INVERTED, "invalid pin_output_mode_e");
|
||||
int electricalValue = getElectricalValue(logicValue, mode);
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
|
@ -576,12 +576,12 @@ void OutputPin::initPin(const char *msg, brain_pin_e brainPin, const pin_output_
|
|||
// Check that this OutputPin isn't already assigned to another pin (reinit is allowed to change mode)
|
||||
// To avoid this error, call deInit() first
|
||||
if (isBrainPinValid(this->brainPin) && this->brainPin != brainPin) {
|
||||
firmwareError(CUSTOM_OBD_PIN_CONFLICT, "outputPin [%s] already assigned, cannot reassign without unregister first", msg);
|
||||
firmwareError(ObdCode::CUSTOM_OBD_PIN_CONFLICT, "outputPin [%s] already assigned, cannot reassign without unregister first", msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (*outputMode > OM_OPENDRAIN_INVERTED) {
|
||||
firmwareError(CUSTOM_INVALID_MODE_SETTING, "%s invalid pin_output_mode_e %d %s",
|
||||
firmwareError(ObdCode::CUSTOM_INVALID_MODE_SETTING, "%s invalid pin_output_mode_e %d %s",
|
||||
msg,
|
||||
*outputMode,
|
||||
hwPortname(brainPin)
|
||||
|
@ -602,7 +602,7 @@ void OutputPin::initPin(const char *msg, brain_pin_e brainPin, const pin_output_
|
|||
|
||||
// Validate port
|
||||
if (port == GPIO_NULL) {
|
||||
firmwareError(OBD_PCM_Processor_Fault, "OutputPin::initPin got invalid port for pin idx %d", static_cast<int>(brainPin));
|
||||
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "OutputPin::initPin got invalid port for pin idx %d", static_cast<int>(brainPin));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -640,7 +640,7 @@ void OutputPin::initPin(const char *msg, brain_pin_e brainPin, const pin_output_
|
|||
#ifndef DISABLE_PIN_STATE_VALIDATION
|
||||
// if the pin was set to logical 1, then set an error and disable the pin so that things don't catch fire
|
||||
if (logicalValue) {
|
||||
firmwareError(OBD_PCM_Processor_Fault, "HARDWARE VALIDATION FAILED %s: unexpected startup pin state %s actual value=%d logical value=%d mode=%s", msg, hwPortname(brainPin), actualValue, logicalValue, getPin_output_mode_e(*outputMode));
|
||||
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "HARDWARE VALIDATION FAILED %s: unexpected startup pin state %s actual value=%d logical value=%d mode=%s", msg, hwPortname(brainPin), actualValue, logicalValue, getPin_output_mode_e(*outputMode));
|
||||
OutputPin::deInit();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -123,7 +123,7 @@ bool TriggerWaveform::needsDisambiguation() const {
|
|||
case TWO_STROKE:
|
||||
return false;
|
||||
default:
|
||||
firmwareError(OBD_PCM_Processor_Fault, "bad operationMode() in needsDisambiguation");
|
||||
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "bad operationMode() in needsDisambiguation");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ angle_t TriggerWaveform::getAngle(int index) const {
|
|||
* See also trigger_central.cpp
|
||||
* See also getEngineCycleEventCount()
|
||||
*/
|
||||
efiAssert(CUSTOM_ERR_ASSERT, wave.phaseCount != 0, "shapeSize=0", NAN);
|
||||
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, wave.phaseCount != 0, "shapeSize=0", NAN);
|
||||
int crankCycle = index / wave.phaseCount;
|
||||
int remainder = index % wave.phaseCount;
|
||||
|
||||
|
@ -192,7 +192,7 @@ void TriggerWaveform::calculateExpectedEventCounts() {
|
|||
if (!useOnlyRisingEdges) {
|
||||
for (size_t i = 0; i < efi::size(expectedEventCount); i++) {
|
||||
if (getExpectedEventCount((TriggerWheel)i) % 2 != 0) {
|
||||
firmwareError(ERROR_TRIGGER_DRAMA, "Trigger: should be even number of events index=%d count=%d", i, getExpectedEventCount((TriggerWheel)i));
|
||||
firmwareError(ObdCode::ERROR_TRIGGER_DRAMA, "Trigger: should be even number of events index=%d count=%d", i, getExpectedEventCount((TriggerWheel)i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -200,13 +200,13 @@ void TriggerWaveform::calculateExpectedEventCounts() {
|
|||
bool isSingleToothOnPrimaryChannel = useOnlyRisingEdges ? getExpectedEventCount(TriggerWheel::T_PRIMARY) == 1 : getExpectedEventCount(TriggerWheel::T_PRIMARY) == 2;
|
||||
// todo: next step would be to set 'isSynchronizationNeeded' automatically based on the logic we have here
|
||||
if (!shapeWithoutTdc && isSingleToothOnPrimaryChannel != !isSynchronizationNeeded) {
|
||||
firmwareError(ERROR_TRIGGER_DRAMA, "shapeWithoutTdc isSynchronizationNeeded isSingleToothOnPrimaryChannel constraint violation");
|
||||
firmwareError(ObdCode::ERROR_TRIGGER_DRAMA, "shapeWithoutTdc isSynchronizationNeeded isSingleToothOnPrimaryChannel constraint violation");
|
||||
}
|
||||
if (isSingleToothOnPrimaryChannel) {
|
||||
useOnlyPrimaryForSync = true;
|
||||
} else {
|
||||
if (getExpectedEventCount(TriggerWheel::T_SECONDARY) == 0 && useOnlyPrimaryForSync) {
|
||||
firmwareError(ERROR_TRIGGER_DRAMA, "why would you set useOnlyPrimaryForSync with only one trigger wheel?");
|
||||
firmwareError(ObdCode::ERROR_TRIGGER_DRAMA, "why would you set useOnlyPrimaryForSync with only one trigger wheel?");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,7 +225,7 @@ void TriggerWaveform::addEvent720(angle_t angle, TriggerValue const state, Trigg
|
|||
}
|
||||
|
||||
void TriggerWaveform::addEvent360(angle_t angle, TriggerValue const state, TriggerWheel const channelIndex) {
|
||||
efiAssertVoid(CUSTOM_OMODE_UNDEF, operationMode == FOUR_STROKE_CAM_SENSOR || operationMode == FOUR_STROKE_CRANK_SENSOR, "Not a mode for 360");
|
||||
efiAssertVoid(ObdCode::CUSTOM_OMODE_UNDEF, operationMode == FOUR_STROKE_CAM_SENSOR || operationMode == FOUR_STROKE_CRANK_SENSOR, "Not a mode for 360");
|
||||
addEvent(CRANK_MODE_MULTIPLIER * angle / FOUR_STROKE_CYCLE_DURATION, state, channelIndex);
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ void TriggerWaveform::addEventAngle(angle_t angle, TriggerValue const state, Tri
|
|||
}
|
||||
|
||||
void TriggerWaveform::addEvent(angle_t angle, TriggerValue const state, TriggerWheel const channelIndex) {
|
||||
efiAssertVoid(CUSTOM_OMODE_UNDEF, operationMode != OM_NONE, "operationMode not set");
|
||||
efiAssertVoid(ObdCode::CUSTOM_OMODE_UNDEF, operationMode != OM_NONE, "operationMode not set");
|
||||
|
||||
if (channelIndex == TriggerWheel:: T_SECONDARY) {
|
||||
needSecondTriggerInput = true;
|
||||
|
@ -261,12 +261,12 @@ void TriggerWaveform::addEvent(angle_t angle, TriggerValue const state, TriggerW
|
|||
}
|
||||
|
||||
if (angle <= 0 || angle > 1) {
|
||||
firmwareError(CUSTOM_ERR_6599, "angle should be positive not above 1: index=%d angle %f", channelIndex, angle);
|
||||
firmwareError(ObdCode::CUSTOM_ERR_6599, "angle should be positive not above 1: index=%d angle %f", channelIndex, angle);
|
||||
return;
|
||||
}
|
||||
if (wave.phaseCount > 0) {
|
||||
if (angle <= previousAngle) {
|
||||
warning(CUSTOM_ERR_TRG_ANGLE_ORDER, "invalid angle order %s %s: new=%.2f/%f and prev=%.2f/%f, size=%d",
|
||||
warning(ObdCode::CUSTOM_ERR_TRG_ANGLE_ORDER, "invalid angle order %s %s: new=%.2f/%f and prev=%.2f/%f, size=%d",
|
||||
getTriggerWheel(channelIndex),
|
||||
getTrigger_value_e(state),
|
||||
angle, angle * getCycleDuration(),
|
||||
|
@ -290,7 +290,7 @@ void TriggerWaveform::addEvent(angle_t angle, TriggerValue const state, TriggerW
|
|||
}
|
||||
|
||||
if (wave.findAngleMatch(angle)) {
|
||||
warning(CUSTOM_ERR_SAME_ANGLE, "same angle: not supported");
|
||||
warning(ObdCode::CUSTOM_ERR_SAME_ANGLE, "same angle: not supported");
|
||||
setShapeDefinitionError(true);
|
||||
return;
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ void TriggerWaveform::addEvent(angle_t angle, TriggerValue const state, TriggerW
|
|||
isRiseEvent[index] = TriggerValue::RISE == state;
|
||||
|
||||
if ((unsigned)index != wave.phaseCount) {
|
||||
firmwareError(ERROR_TRIGGER_DRAMA, "are we ever here?");
|
||||
firmwareError(ObdCode::ERROR_TRIGGER_DRAMA, "are we ever here?");
|
||||
}
|
||||
|
||||
wave.phaseCount++;
|
||||
|
@ -336,7 +336,7 @@ void TriggerWaveform::setTriggerSynchronizationGap2(float syncRatioFrom, float s
|
|||
|
||||
void TriggerWaveform::setTriggerSynchronizationGap3(int gapIndex, float syncRatioFrom, float syncRatioTo) {
|
||||
isSynchronizationNeeded = true;
|
||||
efiAssertVoid(OBD_PCM_Processor_Fault, gapIndex >= 0 && gapIndex < GAP_TRACKING_LENGTH, "gapIndex out of range");
|
||||
efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, gapIndex >= 0 && gapIndex < GAP_TRACKING_LENGTH, "gapIndex out of range");
|
||||
syncronizationRatioFrom[gapIndex] = syncRatioFrom;
|
||||
syncronizationRatioTo[gapIndex] = syncRatioTo;
|
||||
if (gapIndex == 0) {
|
||||
|
@ -356,7 +356,7 @@ void TriggerWaveform::setTriggerSynchronizationGap3(int gapIndex, float syncRati
|
|||
uint16_t TriggerWaveform::findAngleIndex(TriggerFormDetails *details, angle_t targetAngle) const {
|
||||
size_t engineCycleEventCount = getLength();
|
||||
|
||||
efiAssert(CUSTOM_ERR_ASSERT, engineCycleEventCount != 0 && engineCycleEventCount <= 0xFFFF,
|
||||
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, engineCycleEventCount != 0 && engineCycleEventCount <= 0xFFFF,
|
||||
"engineCycleEventCount", 0);
|
||||
|
||||
uint32_t left = 0;
|
||||
|
@ -408,7 +408,7 @@ void TriggerWaveform::setThirdTriggerSynchronizationGap(float syncRatio) {
|
|||
void TriggerWaveform::initializeTriggerWaveform(operation_mode_e triggerOperationMode, const trigger_config_s &triggerType) {
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
efiAssertVoid(CUSTOM_ERR_6641, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "init t");
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_6641, getCurrentRemainingStack() > EXPECTED_REMAINING_STACK, "init t");
|
||||
efiPrintf("initializeTriggerWaveform(%s/%d)", getTrigger_type_e(triggerType.type), (int)triggerType.type);
|
||||
#endif
|
||||
|
||||
|
@ -720,7 +720,7 @@ void TriggerWaveform::initializeTriggerWaveform(operation_mode_e triggerOperatio
|
|||
|
||||
default:
|
||||
setShapeDefinitionError(true);
|
||||
warning(CUSTOM_ERR_NO_SHAPE, "initializeTriggerWaveform() not implemented: %d", triggerType.type);
|
||||
warning(ObdCode::CUSTOM_ERR_NO_SHAPE, "initializeTriggerWaveform() not implemented: %d", triggerType.type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -54,11 +54,11 @@ float InstantRpmCalculator::calculateInstantRpm(
|
|||
|
||||
// Determine where we currently are in the revolution
|
||||
angle_t currentAngle = triggerFormDetails->eventAngles[current_index];
|
||||
efiAssert(OBD_PCM_Processor_Fault, !cisnan(currentAngle), "eventAngles", 0);
|
||||
efiAssert(ObdCode::OBD_PCM_Processor_Fault, !cisnan(currentAngle), "eventAngles", 0);
|
||||
|
||||
// Hunt for a tooth ~90 degrees ago to compare to the current time
|
||||
angle_t previousAngle = currentAngle - 90;
|
||||
fixAngle(previousAngle, "prevAngle", CUSTOM_ERR_TRIGGER_ANGLE_RANGE);
|
||||
fixAngle(previousAngle, "prevAngle", ObdCode::CUSTOM_ERR_TRIGGER_ANGLE_RANGE);
|
||||
int prevIndex = triggerShape.findAngleIndex(triggerFormDetails, previousAngle);
|
||||
|
||||
// now let's get precise angle for that event
|
||||
|
@ -77,7 +77,7 @@ float InstantRpmCalculator::calculateInstantRpm(
|
|||
angle_t angleDiff = currentAngle - prevIndexAngle;
|
||||
|
||||
// Wrap the angle in to the correct range (ie, could be -630 when we want +90)
|
||||
fixAngle(angleDiff, "angleDiff", CUSTOM_ERR_6561);
|
||||
fixAngle(angleDiff, "angleDiff", ObdCode::CUSTOM_ERR_6561);
|
||||
|
||||
// just for safety, avoid divide-by-0
|
||||
if (time == 0) {
|
||||
|
@ -137,4 +137,4 @@ void InstantRpmCalculator::updateInstantRpm(
|
|||
#endif /* EFI_SENSOR_CHART */
|
||||
}
|
||||
|
||||
#endif // EFI_SHAFT_POSITION_INPUT
|
||||
#endif // EFI_SHAFT_POSITION_INPUT
|
||||
|
|
|
@ -969,7 +969,7 @@ static void resetRunningTriggerCounters() {
|
|||
void onConfigurationChangeTriggerCallback() {
|
||||
bool changed = false;
|
||||
// todo: how do we static_assert here?
|
||||
efiAssertVoid(OBD_PCM_Processor_Fault, efi::size(engineConfiguration->camInputs) == efi::size(engineConfiguration->vvtOffsets), "sizes");
|
||||
efiAssertVoid(ObdCode::OBD_PCM_Processor_Fault, efi::size(engineConfiguration->camInputs) == efi::size(engineConfiguration->vvtOffsets), "sizes");
|
||||
|
||||
for (size_t camIndex = 0; camIndex < efi::size(engineConfiguration->camInputs); camIndex++) {
|
||||
changed |= isConfigurationChanged(camInputs[camIndex]);
|
||||
|
|
|
@ -69,7 +69,7 @@ MCP3208_CS_PIN,
|
|||
};
|
||||
|
||||
static void createRequest(McpAdcState *state, int channel) {
|
||||
efiAssertVoid(CUSTOM_ERR_6680, channel < 8, "Invalid ADC channel");
|
||||
efiAssertVoid(ObdCode::CUSTOM_ERR_6680, channel < 8, "Invalid ADC channel");
|
||||
|
||||
state->requestedChannel = channel;
|
||||
|
||||
|
|
|
@ -9,8 +9,7 @@
|
|||
|
||||
#if EFI_PROD_CODE
|
||||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include "pch.h"
|
||||
|
||||
#include "sent.h"
|
||||
#include "sent_hw_icu.h"
|
||||
|
@ -62,7 +61,7 @@ void startSent() {
|
|||
|
||||
if (getIcuParams(sentPin, &pinAF, &icu, &cfg->channel, &baseClock) != true) {
|
||||
/* this pin has no ICU functionality, of ICU driver is not enabled for TIM on this pin */
|
||||
firmwareError(OBD_PCM_Processor_Fault, "No ICU on selected SENT pin");
|
||||
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "No ICU on selected SENT pin");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -481,7 +481,7 @@ static int getSpiAf(SPIDriver *driver) {
|
|||
return EFI_SPI3_AF;
|
||||
}
|
||||
#endif
|
||||
firmwareError(OBD_PCM_Processor_Fault, "SPI AF not available");
|
||||
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "SPI AF not available");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -542,7 +542,7 @@ void turnOnSpi(spi_device_e device) {
|
|||
engineConfiguration->spi1MosiMode,
|
||||
engineConfiguration->spi1MisoMode);
|
||||
#else
|
||||
firmwareError(OBD_PCM_Processor_Fault, "SPI1 not available in this binary");
|
||||
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "SPI1 not available in this binary");
|
||||
#endif /* STM32_SPI_USE_SPI1 */
|
||||
}
|
||||
if (device == SPI_DEVICE_2) {
|
||||
|
@ -555,7 +555,7 @@ void turnOnSpi(spi_device_e device) {
|
|||
engineConfiguration->spi2MosiMode,
|
||||
engineConfiguration->spi2MisoMode);
|
||||
#else
|
||||
firmwareError(OBD_PCM_Processor_Fault, "SPI2 not available in this binary");
|
||||
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "SPI2 not available in this binary");
|
||||
#endif /* STM32_SPI_USE_SPI2 */
|
||||
}
|
||||
if (device == SPI_DEVICE_3) {
|
||||
|
@ -568,7 +568,7 @@ void turnOnSpi(spi_device_e device) {
|
|||
engineConfiguration->spi3MosiMode,
|
||||
engineConfiguration->spi3MisoMode);
|
||||
#else
|
||||
firmwareError(OBD_PCM_Processor_Fault, "SPI3 not available in this binary");
|
||||
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "SPI3 not available in this binary");
|
||||
#endif /* STM32_SPI_USE_SPI3 */
|
||||
}
|
||||
if (device == SPI_DEVICE_4) {
|
||||
|
@ -577,7 +577,7 @@ void turnOnSpi(spi_device_e device) {
|
|||
/* there are no configuration fields for SPI4 in engineConfiguration, rely on board init code
|
||||
* it should set proper functions for SPI4 pins */
|
||||
#else
|
||||
firmwareError(OBD_PCM_Processor_Fault, "SPI4 not available in this binary");
|
||||
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "SPI4 not available in this binary");
|
||||
#endif /* STM32_SPI_USE_SPI4 */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -397,7 +397,7 @@ static int hip_init() {
|
|||
|
||||
ret = hip_testAdvMode();
|
||||
if (ret) {
|
||||
warning(CUSTOM_OBD_KNOCK_PROCESSOR, "TPIC/HIP does not support advanced mode");
|
||||
warning(ObdCode::CUSTOM_OBD_KNOCK_PROCESSOR, "TPIC/HIP does not support advanced mode");
|
||||
instance.adv_mode = false;
|
||||
}
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ static msg_t hipThread(void *arg) {
|
|||
/* retry until success */
|
||||
ret = hip_init();
|
||||
if (ret) {
|
||||
warning(CUSTOM_OBD_KNOCK_PROCESSOR, "TPIC/HIP does not respond: %d", ret);
|
||||
warning(ObdCode::CUSTOM_OBD_KNOCK_PROCESSOR, "TPIC/HIP does not respond: %d", ret);
|
||||
chThdSleepMilliseconds(10 * 1000);
|
||||
}
|
||||
} while (ret);
|
||||
|
|
|
@ -143,7 +143,7 @@ void HIP9011::setAngleWindowWidth(DEFINE_HIP_PARAMS) {
|
|||
GET_CONFIG_VALUE(knockDetectionWindowStart);
|
||||
if (new_angleWindowWidth < 0) {
|
||||
#if EFI_PROD_CODE
|
||||
warning(CUSTOM_KNOCK_WINDOW, "invalid knock window");
|
||||
warning(ObdCode::CUSTOM_KNOCK_WINDOW, "invalid knock window");
|
||||
#endif
|
||||
new_angleWindowWidth = 0;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ void deInitIfValid(const char* msg, adc_channel_e channel) {
|
|||
|
||||
static void initOldAnalogInputs() {
|
||||
if (isAdcChannelValid(engineConfiguration->afr.hwChannel) && engineConfiguration->enableAemXSeries) {
|
||||
firmwareError(OBD_PCM_Processor_Fault, "Please pick either analog AFR or CAN AFR input not both.");
|
||||
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Please pick either analog AFR or CAN AFR input not both.");
|
||||
}
|
||||
initIfValid("AFR", engineConfiguration->afr.hwChannel);
|
||||
initIfValid("AUXF#1", engineConfiguration->auxFastSensor1_adcChannel);
|
||||
|
|
|
@ -88,7 +88,7 @@ int histogramGetIndex(int64_t value) {
|
|||
*/
|
||||
void initHistogram(histogram_s *h, const char *name) {
|
||||
if (efiStrlen(name) > sizeof(h->name) - 1) {
|
||||
firmwareError(ERROR_HISTO_NAME, "Histogram name [%s] too long", name);
|
||||
firmwareError(ObdCode::ERROR_HISTO_NAME, "Histogram name [%s] too long", name);
|
||||
}
|
||||
strcpy(h->name, name);
|
||||
h->total_value = 0;
|
||||
|
|
|
@ -103,7 +103,7 @@ float interpolateMsg(const char *msg, float x1, float y1, float x2, float y2, fl
|
|||
|
||||
float interpolateClampedWithValidation(float x1, float y1, float x2, float y2, float x) {
|
||||
if (x1 >= x2) {
|
||||
firmwareError(OBD_PCM_Processor_Fault, "interpolateClamped %f has to be smaller than %f", x1, x2);
|
||||
firmwareError(ObdCode::OBD_PCM_Processor_Fault, "interpolateClamped %f has to be smaller than %f", x1, x2);
|
||||
}
|
||||
return interpolateClamped(x1, y1, x2, y2, x);
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -239,7 +239,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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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; \
|
||||
} \
|
||||
} \
|
||||
|
|
|
@ -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 = (currentTimeMillis() - 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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -144,8 +144,8 @@ void PwmConfig::handleCycleStart() {
|
|||
// Compute the maximum number of iterations without overflowing a uint32_t worth of timestamp
|
||||
uint32_t iterationLimit = (0xFFFFFFFF / periodNt) - 2;
|
||||
|
||||
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
|
||||
|
@ -243,7 +243,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) {
|
||||
|
@ -251,7 +251,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;
|
||||
}
|
||||
|
||||
|
@ -281,16 +281,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;
|
||||
|
@ -307,10 +307,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;
|
||||
}
|
||||
|
||||
|
@ -372,8 +372,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];
|
||||
int value = state->multiChannelStateSequence->getChannelState(channelIndex, stateIndex);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
@ -71,7 +71,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
|
||||
firmwareError(CUSTOM_ERR_TASK_TIMER_OVERFLOW, "scheduleByTimestampNt() too far: %d %s", deltaTimeNt, msg);
|
||||
firmwareError(ObdCode::CUSTOM_ERR_TASK_TIMER_OVERFLOW, "scheduleByTimestampNt() too far: %d %s", deltaTimeNt, msg);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -136,7 +136,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);
|
||||
|
@ -144,7 +144,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;
|
||||
|
@ -166,7 +166,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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue