Add support to mark sensors unavailable
This marks sensors unavailable when they respond
with nan, or when the available interface says
they are not available.
Tested:
ipmitool sensor list showed sensors as unavailable
SSB Temp | na | degrees C | na | na | 0.000
| 5.000 | 98.000 | 103.000 | na
Change-Id: I6a4f8ee14864e9d9330a58d83f71dde90cc23dbe
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/sensorcommands.cpp b/src/sensorcommands.cpp
index 811cd91..a226cb9 100644
--- a/src/sensorcommands.cpp
+++ b/src/sensorcommands.cpp
@@ -433,6 +433,31 @@
static_cast<uint8_t>(IPMISensorReadingByte2::sensorScanningEnable);
operation |=
static_cast<uint8_t>(IPMISensorReadingByte2::eventMessagesEnable);
+ bool notReading = std::isnan(reading);
+
+ if (!notReading)
+ {
+ auto availableObject =
+ sensorMap.find("xyz.openbmc_project.State.Decorator.Availability");
+ if (availableObject != sensorMap.end())
+ {
+ auto findAvailable = availableObject->second.find("Available");
+ if (findAvailable != availableObject->second.end())
+ {
+ bool* available = std::get_if<bool>(&(findAvailable->second));
+ if (available && !(*available))
+ {
+ notReading = true;
+ }
+ }
+ }
+ }
+
+ if (notReading)
+ {
+ operation |= static_cast<uint8_t>(
+ IPMISensorReadingByte2::readingStateUnavailable);
+ }
uint8_t thresholds = 0;