libpldmresponder: Implement GetStateSensorReadings
Register the getStateSensorReadings method and get the state sensor PDR
structure according to the SensorId property.
Tested with JSON file:
https://gist.github.com/lxwinspur/6a40abea7330c25e4d49826e890c4be9
pldmtool raw -d 0x80 0x02 0x21 0x01 0x00 0x01 0x00
Request Message:
08 01 80 02 21 01 00 01 00
Response Message:
08 01 00 02 21 00 01 03 00 00 00
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I4faeb1e85f9fd4a2745f592d37be38c28112f5b9
diff --git a/libpldmresponder/pdr_utils.hpp b/libpldmresponder/pdr_utils.hpp
index c463f1f..9406d46 100644
--- a/libpldmresponder/pdr_utils.hpp
+++ b/libpldmresponder/pdr_utils.hpp
@@ -89,6 +89,26 @@
return Json::parse(jsonFile);
}
+/** @brief Function to get the Bitfield count to 1
+ *
+ * @param[in] bit - Bitfield
+ *
+ * @return - uint8_t return the number of 1
+ */
+inline uint8_t getBitfieldCount(const bitfield8_t bit)
+{
+ uint8_t count = 0;
+ for (uint8_t i = 0; i < 8; ++i)
+ {
+ if (bit.byte & (1 << i))
+ {
+ ++count;
+ }
+ }
+
+ return count;
+}
+
/** @brief Populate the mapping between D-Bus property stateId and attribute
* value for the effecter PDR enumeration attribute.
*