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/Utils.hpp b/include/Utils.hpp
index 790bbf8..91b2998 100644
--- a/include/Utils.hpp
+++ b/include/Utils.hpp
@@ -52,7 +52,8 @@
{
on,
biosPost,
- always
+ always,
+ chassisOn
};
std::optional<std::string> openAndRead(const std::string& hwmonFile);
@@ -67,6 +68,7 @@
int symlinkDepth = 1);
bool isPowerOn(void);
bool hasBiosPost(void);
+bool isChassisOn(void);
void setupPowerMatchCallback(
const std::shared_ptr<sdbusplus::asio::connection>& conn,
std::function<void(PowerState type, bool state)>&& callback);
@@ -121,6 +123,16 @@
const static constexpr char* path = "/xyz/openbmc_project/state/host0";
const static constexpr char* property = "CurrentHostState";
} // namespace power
+
+namespace chassis
+{
+const static constexpr char* busname = "xyz.openbmc_project.State.Chassis";
+const static constexpr char* interface = "xyz.openbmc_project.State.Chassis";
+const static constexpr char* path = "/xyz/openbmc_project/state/chassis0";
+const static constexpr char* property = "CurrentPowerState";
+const static constexpr char* sOn = "On";
+} // namespace chassis
+
namespace post
{
const static constexpr char* busname =
@@ -179,6 +191,10 @@
{
val = PowerState::always;
}
+ else if (str == "ChassisOn")
+ {
+ val = PowerState::chassisOn;
+ }
}
inline PowerState getPowerState(const SensorBaseConfigMap& cfg)