Support value "ChassisOn" for "powerState" option
There are some sensors need to be read when the chassis power is On
regardless the boot state of host. Even when the host is failed to
boot the values of these sensors can be used to debug the failure in
power rails.
The current code of dbus-sensors only supports the values "On",
"BiosPost" and "Always" for "powerState" option which can not used
for these kinds of sensors.
This commit adds "ChassisOn" value for "powerState" sensor option.
This value will be used for sensors which will only be read when the
CurrentPowerState is On.
Tested:
1. Add setting PowerState="ChassisOn" to some sensors.
2. Force the CurrentPowerState to
xyz.openbmc_project.State.Chassis.PowerState.Off.
3. The value D-Bus properties of those sensors should be nan.
4. Force the CurrentPowerState to
xyz.openbmc_project.State.Chassis.PowerState.On.
5. The value D-Bus properties of those sensors should be the real
sensor values.
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Change-Id: Icdb9d9cf1ac77c891113fa9b69b33b8bfdb082f7
diff --git a/include/sensor.hpp b/include/sensor.hpp
index 290b78b..4578935 100644
--- a/include/sensor.hpp
+++ b/include/sensor.hpp
@@ -252,7 +252,8 @@
const std::string& label = std::string(),
size_t thresholdSize = 0)
{
- if (readState == PowerState::on || readState == PowerState::biosPost)
+ if (readState == PowerState::on || readState == PowerState::biosPost ||
+ readState == PowerState::chassisOn)
{
setupPowerMatch(dbusConnection);
}
@@ -431,7 +432,10 @@
{
return false;
}
-
+ if (readState == PowerState::chassisOn && !isChassisOn())
+ {
+ return false;
+ }
return true;
}