sensordatahandler: Set data unavailable if value is NaN
Currently if sensor value is NaN ipmid will report it as 0.
There is a special bit in "Get Sensor Reading Command" that
should be used to indicate not available state:
1b = reading/state unavailable
The bit is also used to indicate when a reading/state
is unavailable because the management controller cannot
obtain a valid reading or state for the monitored entity,
typically because the entity is not present.
Utilize this bit to add support for not available (na) state.
Example:
Before:
$ ipmitool sdr
CPU0 | 0 degrees C | ok
$ ipmitool sensor
CPU0 | 0.000 | degrees C | ...
After:
$ ipmitool sdr
CPU0 | no reading | ns
$ ipmitool sensor
CPU0 | na | degrees C | ...
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Change-Id: I05dec5baf7ef33929dd782ddeed0db83855f8bf0
diff --git a/sensordatahandler.hpp b/sensordatahandler.hpp
index 5cad58c..f263636 100644
--- a/sensordatahandler.hpp
+++ b/sensordatahandler.hpp
@@ -230,6 +230,11 @@
sensorInfo.coefficientM);
setReading(rawData, &response);
+ if (!std::isfinite(value))
+ {
+ response.readingOrStateUnavailable = 1;
+ }
+
return response;
}