diff options
author | Tom Joseph <tomjoseph@in.ibm.com> | 2018-01-24 11:51:29 +0530 |
---|---|---|
committer | Tom Joseph <tomjoseph@in.ibm.com> | 2018-01-30 04:00:55 +0000 |
commit | b0adbcdd5a854702c8eab02a63ff08936103540e (patch) | |
tree | 99326dfa2cf1befedbdf552f49b7998c31996b8b /sensordatahandler.hpp | |
parent | 6fcdc21b16410fa8475417c0ff9bb761da4aed05 (diff) | |
download | phosphor-host-ipmid-b0adbcdd5a854702c8eab02a63ff08936103540e.tar.gz phosphor-host-ipmid-b0adbcdd5a854702c8eab02a63ff08936103540e.zip |
sensor: Add support for multiple sensor naming pattern
Change-Id: Ibf58d4a4f5a2783a9152f4b5f685e28ef527c5e2
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Diffstat (limited to 'sensordatahandler.hpp')
-rw-r--r-- | sensordatahandler.hpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/sensordatahandler.hpp b/sensordatahandler.hpp index 1b05342..01b8e4f 100644 --- a/sensordatahandler.hpp +++ b/sensordatahandler.hpp @@ -49,6 +49,60 @@ ipmi_ret_t updateToDbus(IpmiUpdateData& msg); namespace get { +/** @brief Populate sensor name from the D-Bus property associated with the + * sensor. In the example entry from the yaml, the name of the D-bus + * property "AttemptsLeft" is the sensor name. + * + * 0x07: + * sensorType: 195 + * path: /xyz/openbmc_project/state/host0 + * sensorReadingType: 0x6F + * serviceInterface: org.freedesktop.DBus.Properties + * readingType: readingAssertion + * sensorNamePattern: nameProperty + * interfaces: + * xyz.openbmc_project.Control.Boot.RebootAttempts: + * AttemptsLeft: + * Offsets: + * 0xFF: + * type: uint32_t + * + * + * @param[in] sensorInfo - Dbus info related to sensor. + * + * @return On success return the sensor name for the sensor. + */ +inline SensorName nameProperty(const Info& sensorInfo) +{ + return sensorInfo.propertyInterfaces.begin()->second.begin()->first; +} + +/** @brief Populate sensor name from the D-Bus object associated with the + * sensor. If the object path is /system/chassis/motherboard/dimm0 then + * the leaf dimm0 is considered as the sensor name. + * + * @param[in] sensorInfo - Dbus info related to sensor. + * + * @return On success return the sensor name for the sensor. + */ +inline SensorName nameLeaf(const Info& sensorInfo) +{ + return sensorInfo.sensorPath.substr( + sensorInfo.sensorPath.find_last_of('/') + 1, + sensorInfo.sensorPath.length()); +} + +/** @brief Populate sensor name from the D-Bus object associated with the + * sensor. If the object path is /system/chassis/motherboard/cpu0/core0 + * then the sensor name is cpu0_core0. The leaf and the parent is put + * together to get the sensor name. + * + * @param[in] sensorInfo - Dbus info related to sensor. + * + * @return On success return the sensor name for the sensor. + */ +SensorName nameParentLeaf(const Info& sensorInfo); + /** * @brief Helper function to map the dbus info to sensor's assertion status * for the get sensor reading command. |