Add support for setting threshold comparison status
Currently threshold comparison status for sensor is always
reported as "ok" even if the actual value is out of threshold
bounds.
Add support for setting threshold comparison status based
on the boolean flags from the "Sensor.Threshold.Critical"/
"Sensor.Threshold.Warning" interfaces.
Example:
Before:
```
$ ipmitool sensor get 5_DUAL
Locating sensor record...
Sensor ID : 5_DUAL (0x43)
Entity ID : 7.0
Sensor Type (Threshold) : Voltage
Sensor Reading : 3.570 (+/- 0) Volts
Status : ok
Lower Non-Recoverable : na
Lower Critical : 4.500
Lower Non-Critical : na
Upper Non-Critical : na
Upper Critical : 5.490
Upper Non-Recoverable : na
Positive Hysteresis : Unspecified
Negative Hysteresis : Unspecified
```
After:
```
$ ipmitool sensor get 5_DUAL
Sensor ID : 5_DUAL (0x43)
Entity ID : 7.0
Sensor Type (Threshold) : Voltage
Sensor Reading : 3.570 (+/- 0) Volts
Status : Lower Critical
Lower Non-Recoverable : na
Lower Critical : 4.500
Lower Non-Critical : na
Upper Non-Critical : na
Upper Critical : 5.490
Upper Non-Recoverable : na
Positive Hysteresis : Unspecified
Negative Hysteresis : Unspecified
```
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
Change-Id: I8d6acc15507050981c8ac8a2915f466019bac613
diff --git a/sensordatahandler.hpp b/sensordatahandler.hpp
index e4eed41..4ab0e87 100644
--- a/sensordatahandler.hpp
+++ b/sensordatahandler.hpp
@@ -275,6 +275,59 @@
response.readingOrStateUnavailable = 1;
}
+ bool critAlarmHigh;
+ try
+ {
+ critAlarmHigh = std::get<bool>(ipmi::getDbusProperty(
+ bus, service, sensorInfo.sensorPath,
+ "xyz.openbmc_project.Sensor.Threshold.Critical",
+ "CriticalAlarmHigh"));
+ }
+ catch (const std::exception& e)
+ {
+ critAlarmHigh = false;
+ }
+ bool critAlarmLow;
+ try
+ {
+ critAlarmLow = std::get<bool>(ipmi::getDbusProperty(
+ bus, service, sensorInfo.sensorPath,
+ "xyz.openbmc_project.Sensor.Threshold.Critical",
+ "CriticalAlarmLow"));
+ }
+ catch (const std::exception& e)
+ {
+ critAlarmLow = false;
+ }
+ bool warningAlarmHigh;
+ try
+ {
+ warningAlarmHigh = std::get<bool>(ipmi::getDbusProperty(
+ bus, service, sensorInfo.sensorPath,
+ "xyz.openbmc_project.Sensor.Threshold.Warning",
+ "WarningAlarmHigh"));
+ }
+ catch (const std::exception& e)
+ {
+ warningAlarmHigh = false;
+ }
+ bool warningAlarmLow;
+ try
+ {
+ warningAlarmLow = std::get<bool>(ipmi::getDbusProperty(
+ bus, service, sensorInfo.sensorPath,
+ "xyz.openbmc_project.Sensor.Threshold.Warning", "WarningAlarmlow"));
+ }
+ catch (const std::exception& e)
+ {
+ warningAlarmLow = false;
+ }
+ response.thresholdLevelsStates =
+ (static_cast<uint8_t>(critAlarmHigh) << 4) |
+ (static_cast<uint8_t>(warningAlarmHigh) << 3) |
+ (static_cast<uint8_t>(warningAlarmLow) << 2) |
+ (static_cast<uint8_t>(critAlarmLow) << 1);
+
return response;
}