Add redundancy sensor and cleanup
Add fan redundancy sensor and move some class members
into the base class. Asio now protects against setting
the same number twice, allow it now to simplify code.
Change-Id: Idb6b5ff4746da92be62c4756fe442d5a5ed23f4f
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/HwmonTempSensor.cpp b/src/HwmonTempSensor.cpp
index 1d58f07..8510563 100644
--- a/src/HwmonTempSensor.cpp
+++ b/src/HwmonTempSensor.cpp
@@ -37,15 +37,14 @@
boost::asio::io_service &io, const std::string &sensorName,
std::vector<thresholds::Threshold> &&_thresholds,
const std::string &sensorConfiguration) :
- Sensor(),
- path(path), objectType(objectType), configuration(sensorConfiguration),
- objServer(objectServer),
- name(boost::replace_all_copy(sensorName, " ", "_")),
- inputDev(io, open(path.c_str(), O_RDONLY)), waitTimer(io), errCount(0),
+ Sensor(boost::replace_all_copy(sensorName, " ", "_"), path,
+ std::move(_thresholds)),
+ objectType(objectType), configuration(sensorConfiguration),
+ objServer(objectServer), inputDev(io, open(path.c_str(), O_RDONLY)),
+ waitTimer(io), errCount(0),
// todo, get these from config
maxValue(127), minValue(-128)
{
- thresholds = std::move(_thresholds);
sensorInterface = objectServer.add_interface(
"/xyz/openbmc_project/sensors/temperature/" + name,
"xyz.openbmc_project.Sensor.Value");
@@ -113,13 +112,18 @@
}
else
{
- std::cerr << "Failure to read sensor " << name << " at " << path
- << "\n";
errCount++;
}
- // only send value update once
+
+ // only print once
if (errCount == warnAfterErrorCount)
{
+ std::cerr << "Failure to read sensor " << name << " at " << path
+ << " ec:" << err << "\n";
+ }
+
+ if (errCount >= warnAfterErrorCount)
+ {
updateValue(0);
}
responseStream.clear();