diff options
| author | Andrew Geissler <andrewg@us.ibm.com> | 2016-12-13 20:39:04 -0600 |
|---|---|---|
| committer | Andrew Geissler <andrewg@us.ibm.com> | 2017-01-13 15:22:02 -0600 |
| commit | dff50ed66b5bd930f0f9777cf52fe28ae0b6667e (patch) | |
| tree | 4f88a0d17de82119f8bf61207df793ef04274364 | |
| parent | a90a31a966863ad9abb537c4cccfa07db5533f51 (diff) | |
| download | phosphor-state-manager-dff50ed66b5bd930f0f9777cf52fe28ae0b6667e.tar.gz phosphor-state-manager-dff50ed66b5bd930f0f9777cf52fe28ae0b6667e.zip | |
Determine chassis power state on application startup
Change-Id: I406b2a6c7af1e4c26af0e43a432a130c967d84bc
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
| -rw-r--r-- | chassis_state_manager.cpp | 35 | ||||
| -rw-r--r-- | chassis_state_manager.hpp | 18 |
2 files changed, 50 insertions, 3 deletions
diff --git a/chassis_state_manager.cpp b/chassis_state_manager.cpp index c146087..91a35d0 100644 --- a/chassis_state_manager.cpp +++ b/chassis_state_manager.cpp @@ -13,6 +13,41 @@ namespace server = sdbusplus::xyz::openbmc_project::State::server; using namespace phosphor::logging; +// TODO - Will be rewritten once sdbusplus client bindings are in place +// and persistent storage design is in place and sdbusplus +// has read property function +void Chassis::determineInitialState() +{ + sdbusplus::message::variant<int> pgood = -1; + auto method = this->bus.new_method_call("org.openbmc.control.Power", + "/org/openbmc/control/power0", + "org.freedesktop.DBus.Properties", + "Get"); + + method.append("org.openbmc.control.Power", "pgood"); + auto reply = this->bus.call(method); + reply.read(pgood); + + if(pgood == 1) + { + log<level::INFO>("Initial Chassis State will be On", + entry("CHASSIS_CURRENT_POWER_STATE=%s", + convertForMessage(PowerState::On).c_str())); + server::Chassis::currentPowerState(PowerState::On); + server::Chassis::requestedPowerTransition(Transition::On); + } + else + { + log<level::INFO>("Initial Chassis State will be Off", + entry("CHASSIS_CURRENT_POWER_STATE=%s", + convertForMessage(PowerState::Off).c_str())); + server::Chassis::currentPowerState(PowerState::Off); + server::Chassis::requestedPowerTransition(Transition::Off); + } + + return; +} + Chassis::Transition Chassis::requestedPowerTransition(Transition value) { diff --git a/chassis_state_manager.hpp b/chassis_state_manager.hpp index f3df078..af3445d 100644 --- a/chassis_state_manager.hpp +++ b/chassis_state_manager.hpp @@ -21,8 +21,12 @@ class Chassis : public sdbusplus::server::object::object< public: /** @brief Constructs Chassis State Manager * + * @note This constructor passes 'true' to the base class in order to + * defer dbus object registration until we can run + * determineInitialState() and set our properties + * * @param[in] bus - The Dbus bus object - * @param[in] busName - The Dbus name to own + * @param[in] instance - The instance of this object * @param[in] objPath - The Dbus object path */ Chassis(sdbusplus::bus::bus& bus, @@ -30,9 +34,17 @@ class Chassis : public sdbusplus::server::object::object< const char* objPath) : sdbusplus::server::object::object< sdbusplus::xyz::openbmc_project::State::server::Chassis>( - bus, objPath), + bus, objPath, true), bus(bus) - {} + { + determineInitialState(); + + // We deferred this until we could get our property correct + this->emit_object_added(); + } + + /** @brief Determine initial chassis state and set internally */ + void determineInitialState(); /** @brief Set value of RequestedPowerTransition */ Transition requestedPowerTransition(Transition value) override; |

