Fix occ-control terminations
1. Ensure PowerMode object created before attempting to use
2. Only call setChassisAssociation after getting successful temperature
reading.
Tested on Everest hw
Change-Id: I308c072cf5ab0235086c136ba7644125de0a8c6a
Signed-off-by: Chris Cain <cjcain@us.ibm.com>
diff --git a/powermode.hpp b/powermode.hpp
index 5342c77..0ec22a5 100644
--- a/powermode.hpp
+++ b/powermode.hpp
@@ -159,9 +159,8 @@
* @param[in] managerRef -
* @param[in] path -
*/
- explicit PowerMode(Manager& managerRef, const char* path) :
- manager(managerRef), path(path), occInstance(this->path.back() - '0'),
- occCmd(occInstance, path),
+ explicit PowerMode(const Manager& managerRef) :
+ manager(managerRef), occInstance(0),
pmodeMatch(utils::getBus(),
sdbusplus::bus::match::rules::propertiesChanged(
PMODE_PATH, PMODE_INTERFACE),
@@ -170,7 +169,7 @@
sdbusplus::bus::match::rules::propertiesChanged(
PIPS_PATH, PIPS_INTERFACE),
[this](auto& msg) { this->ipsChanged(msg); }),
- masterActive(false){};
+ masterOccSet(false), masterActive(false){};
bool setMode(const SysPwrMode newMode, const uint16_t modedata);
@@ -184,6 +183,12 @@
*/
CmdStatus sendIpsData();
+ /** @brief Set the master OCC path
+ *
+ * @param[in] occPath - hwmon path for master OCC
+ */
+ void setMasterOcc(const std::string& occPath);
+
/** @brief Notify object of master OCC state. If not acitve, no
* commands will be sent to the master OCC
*
@@ -205,7 +210,7 @@
int occInstance;
/** @brief Object to send commands to the OCC */
- OccCommand occCmd;
+ std::unique_ptr<open_power::occ::OccCommand> occCmd;
/** @brief Used to subscribe to dbus pmode property changes **/
sdbusplus::bus::match_t pmodeMatch;
@@ -215,6 +220,10 @@
OccPersistData persistedData;
+ /** @brief True when the master OCC has been established */
+ bool masterOccSet;
+
+ /** @brief True when the master OCC is active */
bool masterActive;
/** @brief Callback for pmode setting changes