Standardize read errors
Each sensor handled read errors their own way,
making it inconsistant. This helps to align them all
in the base class, so that error handling happens the
same for each sensor. It also aligns the power state
change handling.
Tested: Tested DC Cycling and Enabling/Disabling ME to
make sure functional change correctly
Change-Id: I1a191d27629602e1ca3871d933af07b15bf9f331
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/NVMeSensor.cpp b/src/NVMeSensor.cpp
index 8cdf744..d683174 100644
--- a/src/NVMeSensor.cpp
+++ b/src/NVMeSensor.cpp
@@ -229,23 +229,11 @@
constexpr const size_t errorThreshold = 5;
if (errorCode)
{
- sensor->errorCount = 0;
+ // timer cancelled successfully
return;
}
- if (!isPowerOn())
- {
- sensor->errorCount = 0;
- sensor->updateValue(std::numeric_limits<double>::quiet_NaN());
- }
- else if (sensor->errorCount < errorThreshold)
- {
- std::cerr << "MCTP timeout device " << sensor->name << "\n";
- sensor->errorCount++;
- }
- else
- {
- sensor->updateValue(0);
- }
+
+ sensor->incrementError();
// cycle it back
nvmeDevice->sensors.pop_front();
@@ -441,8 +429,9 @@
const int busNumber) :
Sensor(boost::replace_all_copy(sensorName, " ", "_"),
std::move(_thresholds), sensorConfiguration,
- "xyz.openbmc_project.Configuration.NVMe", maxReading, minReading),
- objServer(objectServer), errorCount(0), bus(busNumber)
+ "xyz.openbmc_project.Configuration.NVMe", maxReading, minReading,
+ PowerState::on),
+ objServer(objectServer), bus(busNumber)
{
sensorInterface = objectServer.add_interface(
"/xyz/openbmc_project/sensors/temperature/" + name,
@@ -465,8 +454,6 @@
association::interface);
setInitialProperties(conn);
- // setup match
- setupPowerMatch(conn);
}
NVMeSensor::~NVMeSensor()
@@ -480,9 +467,5 @@
void NVMeSensor::checkThresholds(void)
{
- if (!isPowerOn())
- {
- return;
- }
thresholds::checkThresholds(this);
}