more safe parts probably (#1883)

This commit is contained in:
Matthew Kennedy 2020-10-15 19:04:42 -07:00 committed by GitHub
parent a2c23d4a6c
commit 749282c807
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 4 deletions

View File

@ -829,14 +829,15 @@ void doInitElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#endif /* EFI_PROD_CODE */
// If you don't have a pedal we have no business here.
if (!Sensor::hasSensor(SensorType::AcceleratorPedalPrimary)) {
return;
if (Sensor::hasSensor(SensorType::AcceleratorPedalPrimary)) {
engine->etbActualCount = Sensor::hasSensor(SensorType::Tps2) ? 2 : 1;
} else {
engine->etbActualCount = 0;
}
pedal2tpsMap.init(config->pedalToTpsTable, config->pedalToTpsPedalBins, config->pedalToTpsRpmBins);
engine->etbActualCount = Sensor::hasSensor(SensorType::Tps2) ? 2 : 1;
bool mustHaveEtbConfigured = Sensor::hasSensor(SensorType::AcceleratorPedalPrimary);
bool anyEtbConfigured = false;
for (int i = 0 ; i < engine->etbActualCount; i++) {
@ -858,6 +859,16 @@ void doInitElectronicThrottle(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
}
}
if (!anyEtbConfigured) {
// It's not valid to have a PPS without any ETBs - check that at least one ETB was enabled along with the pedal
if (mustHaveEtbConfigured) {
firmwareError(OBD_PCM_Processor_Fault, "A pedal position sensor was configured, but no electronic throttles are configured.");
}
// Don't start the thread if no throttles are in use.
return;
}
#if 0 && ! EFI_UNIT_TEST
percent_t startupThrottlePosition = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE);
if (absF(startupThrottlePosition - engineConfiguration->etbNeutralPosition) > STARTUP_NEUTRAL_POSITION_ERROR_THRESHOLD) {