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/sensors/src/CPUSensor.cpp b/sensors/src/CPUSensor.cpp
index 236dd81..eda9a3b 100644
--- a/sensors/src/CPUSensor.cpp
+++ b/sensors/src/CPUSensor.cpp
@@ -35,16 +35,15 @@
boost::asio::io_service &io, const std::string &sensorName,
std::vector<thresholds::Threshold> &&_thresholds,
const std::string &sensorConfiguration) :
- Sensor(),
- path(path), objectType(objectType), objServer(objectServer),
- name(boost::replace_all_copy(sensorName, " ", "_")), dbusConnection(conn),
+ Sensor(boost::replace_all_copy(sensorName, " ", "_"), path,
+ std::move(_thresholds)),
+ objectType(objectType), objServer(objectServer), dbusConnection(conn),
configuration(sensorConfiguration),
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");
@@ -117,14 +116,17 @@
errCount++;
}
- // only send value update once
- if (errCount == warnAfterErrorCount)
+ if (errCount >= warnAfterErrorCount)
{
// only an error if power is on
if (isPowerOn(dbusConnection))
{
- std::cerr << "Failure to read sensor " << name << " at " << path
- << "\n";
+ // only print once
+ if (errCount == warnAfterErrorCount)
+ {
+ std::cerr << "Failure to read sensor " << name << " at " << path
+ << "\n";
+ }
updateValue(0);
errCount++;
}