DCMI: Read power value from the configured D-Bus object path
1) Parse the power_reading JSON configuration file to get
the D-Bus object path for the power reading.
2) Read the power reading value from the specified D-Bus object.
Change-Id: I4b9f0703318e8db2c86d0b337e524eee6da33d08
Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
diff --git a/dcmihandler.hpp b/dcmihandler.hpp
index bd2c6e1..4e95eba 100644
--- a/dcmihandler.hpp
+++ b/dcmihandler.hpp
@@ -14,6 +14,7 @@
{
// Get capability bits
GET_CAPABILITIES = 0x01,
+ GET_POWER_READING = 0x02,
GET_POWER_LIMIT = 0x03,
SET_POWER_LIMIT = 0x04,
APPLY_POWER_LIMIT = 0x05,
@@ -427,6 +428,47 @@
uint8_t instanceStart);
}
+/** @brief Read power reading from power reading sensor object
+ *
+ * @param[in] bus - dbus connection
+ *
+ * @return total power reading
+ */
+int64_t getPowerReading(sdbusplus::bus::bus& bus);
+
+/** @struct GetPowerReadingRequest
+ *
+ * DCMI Get Power Reading command request.
+ * Refer DCMI specification Version 1.1 Section 6.6.1
+ */
+struct GetPowerReadingRequest
+{
+ uint8_t groupID; //!< Group extension identification.
+ uint8_t mode; //!< Mode
+ uint8_t modeAttribute; //!< Mode Attributes
+} __attribute__((packed));
+
+/** @struct GetPowerReadingResponse
+ *
+ * DCMI Get Power Reading command response.
+ * Refer DCMI specification Version 1.1 Section 6.6.1
+ */
+struct GetPowerReadingResponse
+{
+ uint8_t groupID; //!< Group extension identification.
+ uint16_t currentPower; //!< Current power in watts
+ uint16_t minimumPower; //!< Minimum power over sampling duration
+ //!< in watts
+ uint16_t maximumPower; //!< Maximum power over sampling duration
+ //!< in watts
+ uint16_t averagePower; //!< Average power over sampling duration
+ //!< in watts
+ uint32_t timeStamp; //!< IPMI specification based time stamp
+ uint32_t timeFrame; //!< Statistics reporting time period in milli
+ //!< seconds.
+ uint8_t powerReadingState; //!< Power Reading State
+} __attribute__((packed));
+
} // namespace dcmi
#endif