don't duplicate sensor error logic (#2032)

Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
Matthew Kennedy 2020-12-06 14:00:30 -06:00 committed by GitHub
parent 9ccda6bbe7
commit c5e3657d45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 30 deletions

View File

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

View File

@ -48,9 +48,7 @@ static void initFluidPressure(LinearFunc& func, FunctionalSensor& sensor, const
AdcSubscription::SubscribeSensor(sensor, channel, bandwidth); AdcSubscription::SubscribeSensor(sensor, channel, bandwidth);
if (!sensor.Register()) { sensor.Register();
firmwareError(CUSTOM_INVALID_TPS_SETTING, "Duplicate registration for sensor \"%s\"", sensor.getSensorName());
}
} }
void initOilPressure(DECLARE_CONFIG_PARAMETER_SIGNATURE) { void initOilPressure(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
@ -64,9 +62,7 @@ void initOilPressure(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
: SensorType::FuelPressureLow : SensorType::FuelPressureLow
); );
if (!injectorPressure.Register()) { injectorPressure.Register();
firmwareError(OBD_PCM_Processor_Fault, "Duplicate sensor registration");
}
} }
void reconfigureOilPressure(DECLARE_CONFIG_PARAMETER_SIGNATURE) { void reconfigureOilPressure(DECLARE_CONFIG_PARAMETER_SIGNATURE) {

View File

@ -39,7 +39,5 @@ void initLambda(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
} }
#endif #endif
if (!lambdaSensor.Register()) { lambdaSensor.Register();
warning(OBD_PCM_Processor_Fault, "Duplicate lambda sensor registration, ignoring");
}
} }

View File

@ -60,12 +60,9 @@ static void configureTempSensor(FunctionalSensor &sensor,
configTherm(sensor, p, config, isLinear); configTherm(sensor, p, config, isLinear);
AdcSubscription::SubscribeSensor(sensor, channel, 2);
// Register & subscribe // Register & subscribe
if (!sensor.Register()) { AdcSubscription::SubscribeSensor(sensor, channel, 2);
// uhh? sensor.Register();
}
} }
void initThermistors(DECLARE_CONFIG_PARAMETER_SIGNATURE) { void initThermistors(DECLARE_CONFIG_PARAMETER_SIGNATURE) {

View File

@ -80,12 +80,7 @@ static bool initTpsFunc(LinearFunc& func, FunctionalSensor& sensor, adc_channel_
AdcSubscription::SubscribeSensor(sensor, channel, 200); AdcSubscription::SubscribeSensor(sensor, channel, 200);
if (!sensor.Register()) { return sensor.Register();
firmwareError(CUSTOM_INVALID_TPS_SETTING, "Duplicate registration for sensor \"%s\"", sensor.getSensorName());
return false;
}
return true;
} }
static void initTpsFuncAndRedund(RedundantSensor& redund, LinearFunc& func, FunctionalSensor& sensor, adc_channel_e channel, float closed, float open, float min, float max) { static void initTpsFuncAndRedund(RedundantSensor& redund, LinearFunc& func, FunctionalSensor& sensor, adc_channel_e channel, float closed, float open, float min, float max) {
@ -93,9 +88,7 @@ static void initTpsFuncAndRedund(RedundantSensor& redund, LinearFunc& func, Func
redund.configure(5.0f, !hasSecond); redund.configure(5.0f, !hasSecond);
if (!redund.Register()) { redund.Register();
firmwareError(CUSTOM_INVALID_TPS_SETTING, "Duplicate registration for sensor \"%s\"", redund.getSensorName());
}
} }
void initTps(DECLARE_CONFIG_PARAMETER_SIGNATURE) { void initTps(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
@ -122,9 +115,7 @@ void initTps(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
driverIntent.setProxiedSensor(SensorType::Tps1); driverIntent.setProxiedSensor(SensorType::Tps1);
} }
if (!driverIntent.Register()) { driverIntent.Register();
firmwareError(CUSTOM_INVALID_TPS_SETTING, "Duplicate registration for driver acc intent sensor");
}
} }
void reconfigureTps(DECLARE_CONFIG_PARAMETER_SIGNATURE) { void reconfigureTps(DECLARE_CONFIG_PARAMETER_SIGNATURE) {

View File

@ -1,5 +1,6 @@
#include "mock/mock_sensor.h" #include "mock/mock_sensor.h"
#include "stored_value_sensor.h" #include "stored_value_sensor.h"
#include "unit_test_framework.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
@ -49,7 +50,7 @@ TEST_F(SensorBasic, DoubleRegister) {
// And then do it again! // And then do it again!
MockSensor dut2(SensorType::Tps1); MockSensor dut2(SensorType::Tps1);
EXPECT_FALSE(dut2.Register()); EXPECT_FATAL_ERROR(dut2.Register());
// Make sure that we get the first DUT back - not the second // Make sure that we get the first DUT back - not the second
auto shouldBeDut = Sensor::getSensorOfType(SensorType::Tps1); auto shouldBeDut = Sensor::getSensorOfType(SensorType::Tps1);