Add support for sensor override value
Write support Value property under xyz.openbmc_project.Sensor.Value
interface is added which will be used to do sensor override.
Sensor can be overridden by setting a value, which will be preserved,
till the service is restarted or Value is overridden again with NaN.
Change-Id: Ia606031a97e532cd12d768e36f1feaa4c7350620
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/HwmonTempSensor.cpp b/src/HwmonTempSensor.cpp
index 8510563..48e3fa6 100644
--- a/src/HwmonTempSensor.cpp
+++ b/src/HwmonTempSensor.cpp
@@ -97,8 +97,11 @@
try
{
float nvalue = std::stof(response);
-
nvalue /= sensorScaleFactor;
+ if (!isnan(overriddenValue))
+ {
+ nvalue = overriddenValue;
+ }
if (nvalue != value)
{
updateValue(nvalue);
@@ -135,7 +138,6 @@
}
inputDev.assign(fd);
waitTimer.expires_from_now(boost::posix_time::milliseconds(sensorPollMs));
- ;
waitTimer.async_wait([&](const boost::system::error_code &ec) {
if (ec == boost::asio::error::operation_aborted)
{
@@ -152,7 +154,10 @@
void HwmonTempSensor::updateValue(const double &newValue)
{
+ // Indicate that it is internal set call
+ internalSet = true;
sensorInterface->set_property("Value", newValue);
+ internalSet = false;
value = newValue;
checkThresholds();
}
@@ -163,7 +168,10 @@
// todo, get max and min from configuration
sensorInterface->register_property("MaxValue", maxValue);
sensorInterface->register_property("MinValue", minValue);
- sensorInterface->register_property("Value", value);
+ sensorInterface->register_property(
+ "Value", value, [&](const double &newValue, double &oldValue) {
+ return setSensorValue(newValue, oldValue);
+ });
for (auto &threshold : thresholds)
{