cisnan -> std::isnan

This commit is contained in:
Matthew Kennedy 2024-07-22 12:05:17 -07:00
parent b36474888b
commit 63b07e5d1f
10 changed files with 27 additions and 27 deletions

View File

@ -14,7 +14,7 @@ AirmassResult SpeedDensityAirmass::getAirmass(float rpm, float map, bool postSta
* most of the values are pre-calculated for performance reasons
*/
float tChargeK = engine->engineState.sd.tChargeK;
if (cisnan(tChargeK)) {
if (std::isnan(tChargeK)) {
warning(ObdCode::CUSTOM_ERR_TCHARGE_NOT_READY2, "tChargeK not ready"); // this would happen before we have CLT reading for example
return {};
}
@ -22,7 +22,7 @@ AirmassResult SpeedDensityAirmass::getAirmass(float rpm, float map, bool postSta
float ve = getVe(rpm, map, postState);
float airMass = getAirmassImpl(ve, map, tChargeK);
if (cisnan(airMass)) {
if (std::isnan(airMass)) {
warning(ObdCode::CUSTOM_ERR_6685, "NaN airMass");
return {};
}

View File

@ -171,14 +171,14 @@ void refreshMapAveragingPreCalc() {
if (isValidRpm(rpm)) {
MAP_sensor_config_s * c = &engineConfiguration->map;
angle_t start = interpolate2d(rpm, c->samplingAngleBins, c->samplingAngle);
efiAssertVoid(ObdCode::CUSTOM_ERR_MAP_START_ASSERT, !cisnan(start), "start");
efiAssertVoid(ObdCode::CUSTOM_ERR_MAP_START_ASSERT, !std::isnan(start), "start");
angle_t offsetAngle = engine->triggerCentral.triggerFormDetails.eventAngles[engineConfiguration->mapAveragingSchedulingAtIndex];
efiAssertVoid(ObdCode::CUSTOM_ERR_MAP_AVG_OFFSET, !cisnan(offsetAngle), "offsetAngle");
efiAssertVoid(ObdCode::CUSTOM_ERR_MAP_AVG_OFFSET, !std::isnan(offsetAngle), "offsetAngle");
for (size_t i = 0; i < engineConfiguration->cylindersCount; i++) {
angle_t cylinderOffset = getEngineCycle(getEngineRotationState()->getOperationMode()) * i / engineConfiguration->cylindersCount;
efiAssertVoid(ObdCode::CUSTOM_ERR_MAP_CYL_OFFSET, !cisnan(cylinderOffset), "cylinderOffset");
efiAssertVoid(ObdCode::CUSTOM_ERR_MAP_CYL_OFFSET, !std::isnan(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?
@ -233,7 +233,7 @@ void mapAveragingTriggerCallback(
angle_t samplingEnd = samplingStart + samplingDuration;
if (cisnan(samplingEnd)) {
if (std::isnan(samplingEnd)) {
// todo: when would this happen?
warning(ObdCode::CUSTOM_ERR_6549, "no map angles");
return;

View File

@ -99,7 +99,7 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngleDuration, floatms_
// Offset by this cylinder's position in the cycle
+ getCylinderAngle(event->cylinderIndex, event->cylinderNumber);
efiAssertVoid(ObdCode::CUSTOM_SPARK_ANGLE_1, !cisnan(sparkAngle), "sparkAngle#1");
efiAssertVoid(ObdCode::CUSTOM_SPARK_ANGLE_1, !std::isnan(sparkAngle), "sparkAngle#1");
wrapAngle(sparkAngle, "findAngle#2", ObdCode::CUSTOM_ERR_6550);
event->sparkAngle = sparkAngle;
@ -126,7 +126,7 @@ static void prepareCylinderIgnitionSchedule(angle_t dwellAngleDuration, floatms_
event->cylinderNumber = coilIndex;
angle_t dwellStartAngle = sparkAngle - dwellAngleDuration;
efiAssertVoid(ObdCode::CUSTOM_ERR_6590, !cisnan(dwellStartAngle), "findAngle#5");
efiAssertVoid(ObdCode::CUSTOM_ERR_6590, !std::isnan(dwellStartAngle), "findAngle#5");
assertAngleRange(dwellStartAngle, "findAngle dwellStartAngle", ObdCode::CUSTOM_ERR_6550);
wrapAngle(dwellStartAngle, "findAngle#7", ObdCode::CUSTOM_ERR_6550);
@ -208,7 +208,7 @@ if (engineConfiguration->debugMode == DBG_DWELL_METRIC) {
angle_t dwellAngleDuration = engine->ignitionState.dwellAngle;
floatms_t sparkDwell = engine->ignitionState.sparkDwell;
if (cisnan(dwellAngleDuration) || cisnan(sparkDwell)) {
if (std::isnan(dwellAngleDuration) || std::isnan(sparkDwell)) {
// we are here if engine has just stopped
return;
}
@ -313,11 +313,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) {
if (std::isnan(dwellMs) || dwellMs <= 0) {
warning(ObdCode::CUSTOM_DWELL, "invalid dwell to handle: %.2f at %d", dwellMs, rpm);
return;
}
if (cisnan(sparkAngle)) {
if (std::isnan(sparkAngle)) {
warning(ObdCode::CUSTOM_ADVANCE_SPARK, "NaN advance");
return;
}
@ -362,7 +362,7 @@ static void scheduleSparkEvent(bool limitedSpark, IgnitionEvent *event,
* Spark event is often happening during a later trigger event timeframe
*/
efiAssertVoid(ObdCode::CUSTOM_ERR_6591, !cisnan(sparkAngle), "findAngle#4");
efiAssertVoid(ObdCode::CUSTOM_ERR_6591, !std::isnan(sparkAngle), "findAngle#4");
assertAngleRange(sparkAngle, "findAngle#a5", ObdCode::CUSTOM_ERR_6549);
bool scheduled = engine->module<TriggerScheduler>()->scheduleOrQueue(
@ -399,7 +399,7 @@ void initializeIgnitionActions() {
IgnitionEventList *list = &engine->ignitionEvents;
angle_t dwellAngle = engine->ignitionState.dwellAngle;
floatms_t sparkDwell = engine->ignitionState.sparkDwell;
if (cisnan(engine->engineState.timingAdvance[0]) || cisnan(dwellAngle)) {
if (std::isnan(engine->engineState.timingAdvance[0]) || std::isnan(dwellAngle)) {
// error should already be reported
// need to invalidate previous ignition schedule
list->isReady = false;

View File

@ -80,7 +80,7 @@ floatms_t IgnitionState::getSparkDwell(int rpm) {
if (engine->rpmCalculator.isCranking()) {
dwellMs = engineConfiguration->ignitionDwellForCrankingMs;
} else {
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !cisnan(rpm), "invalid rpm", NAN);
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, !std::isnan(rpm), "invalid rpm", NAN);
baseDwell = interpolate2d(rpm, config->sparkDwellRpmBins, config->sparkDwellValues);
dwellVoltageCorrection = interpolate2d(
@ -97,7 +97,7 @@ floatms_t IgnitionState::getSparkDwell(int rpm) {
dwellMs = baseDwell * dwellVoltageCorrection;
}
if (cisnan(dwellMs) || dwellMs <= 0) {
if (std::isnan(dwellMs) || dwellMs <= 0) {
// this could happen during engine configuration reset
warning(ObdCode::CUSTOM_ERR_DWELL_DURATION, "invalid dwell: %.2f at rpm=%d", dwellMs, rpm);
return 0;

View File

@ -95,7 +95,7 @@ temperature_t IFuelComputer::getTCharge(int rpm, float tps) {
sdTcharge_coff = getTChargeCoefficient(rpm, tps);
if (cisnan(sdTcharge_coff)) {
if (std::isnan(sdTcharge_coff)) {
warning(ObdCode::CUSTOM_ERR_T2_CHARGE, "t2-getTCharge NaN");
return coolantTemp;
}
@ -105,7 +105,7 @@ temperature_t IFuelComputer::getTCharge(int rpm, float tps) {
// 1.0 coefficient -> use IAT (no heat transfer)
float Tcharge = interpolateClamped(0.0f, coolantTemp, 1.0f, airTemp, sdTcharge_coff);
if (cisnan(Tcharge)) {
if (std::isnan(Tcharge)) {
// we can probably end up here while resetting engine state - interpolation would fail
warning(ObdCode::CUSTOM_ERR_TCHARGE_NOT_READY, "getTCharge NaN");
return coolantTemp;

View File

@ -16,7 +16,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) {
if (std::isnan(mapKPa) || mapKPa > 110 || mapKPa < 60) {
warning(ObdCode::OBD_Barometric_Press_Circ, "Invalid start-up baro pressure = %.2fkPa", mapKPa);
return NAN;
}
@ -72,7 +72,7 @@ void initMapDecoder() {
efiPrintf("Get initial baro MAP pressure = %.2fkPa", storedInitialBaroPressure);
// validate if it's within a reasonable range (the engine should not be spinning etc.)
storedInitialBaroPressure = validateBaroMap(storedInitialBaroPressure);
if (!cisnan(storedInitialBaroPressure)) {
if (!std::isnan(storedInitialBaroPressure)) {
efiPrintf("Using this fixed MAP pressure to override the baro correction!");
// TODO: do literally anything other than this

View File

@ -50,7 +50,7 @@ void SimplePwm::setSimplePwmDutyCycle(float dutyCycle) {
// we are here in order to not change pin once PWM stop was requested
return;
}
if (cisnan(dutyCycle)) {
if (std::isnan(dutyCycle)) {
warning(ObdCode::CUSTOM_DUTY_INVALID, "%s spwd:dutyCycle %.2f", m_name, dutyCycle);
return;
} else if (dutyCycle < 0) {

View File

@ -59,7 +59,7 @@ float InstantRpmCalculator::calculateInstantRpm(
// Determine where we currently are in the revolution
angle_t currentAngle = triggerFormDetails->eventAngles[current_index];
efiAssert(ObdCode::OBD_PCM_Processor_Fault, !cisnan(currentAngle), "eventAngles", 0);
efiAssert(ObdCode::OBD_PCM_Processor_Fault, !std::isnan(currentAngle), "eventAngles", 0);
// Hunt for a tooth ~90 degrees ago to compare to the current time
angle_t previousAngle = currentAngle - engineConfiguration->instantRpmRange;

View File

@ -67,7 +67,7 @@ angle_t TriggerCentral::getVVTPosition(uint8_t bankIndex, uint8_t camIndex) {
expected<float> TriggerCentral::getCurrentEnginePhase(efitick_t nowNt) const {
floatus_t oneDegreeUs = engine->rpmCalculator.oneDegreeUs;
if (cisnan(oneDegreeUs)) {
if (std::isnan(oneDegreeUs)) {
return unexpected;
}

View File

@ -360,7 +360,7 @@ int handleActionWithParameter(TokenCallback *current, char *argv[], int argc) {
case FLOAT_PARAMETER:
{
float value = atoff(argv[0]);
if (cisnan(value)) {
if (std::isnan(value)) {
efiPrintf("invalid float [%s]", argv[0]);
return -1;
}
@ -375,7 +375,7 @@ int handleActionWithParameter(TokenCallback *current, char *argv[], int argc) {
float value[2];
for (int i = 0; i < 2; i++) {
value[i] = atoff(argv[i]);
if (cisnan(value[i])) {
if (std::isnan(value[i])) {
efiPrintf("invalid float [%s]", argv[i]);
return -1;
}
@ -394,7 +394,7 @@ int handleActionWithParameter(TokenCallback *current, char *argv[], int argc) {
float value[3];
for (int i = 0; i < 3; i++) {
value[i] = atoff(argv[i]);
if (cisnan(value[i])) {
if (std::isnan(value[i])) {
efiPrintf("invalid float [%s]", argv[i]);
return -1;
}
@ -408,7 +408,7 @@ int handleActionWithParameter(TokenCallback *current, char *argv[], int argc) {
float value[4];
for (int i = 0; i < 4; i++) {
value[i] = atoff(argv[i]);
if (cisnan(value[i])) {
if (std::isnan(value[i])) {
efiPrintf("invalid float [%s]", argv[i]);
return -1;
}
@ -427,7 +427,7 @@ int handleActionWithParameter(TokenCallback *current, char *argv[], int argc) {
return -1;
}
float value2 = atoff(argv[1]);
if (cisnan(value2)) {
if (std::isnan(value2)) {
efiPrintf("invalid float [%s]", argv[1]);
return -1;
}