summaryrefslogtreecommitdiffstats
path: root/sensordatahandler.hpp
diff options
context:
space:
mode:
authorTom Joseph <tomjoseph@in.ibm.com>2017-09-07 00:09:46 +0530
committerTom Joseph <tomjoseph@in.ibm.com>2017-09-14 18:48:12 +0530
commit295f17e5257774f11d6c05ed6e00e28cb4039dbf (patch)
tree2b5d0f00050896eddad757db1225526b5f5999e3 /sensordatahandler.hpp
parente4014fca76e418e5d7d5c8ce8720913f998cd9de (diff)
downloadphosphor-host-ipmid-295f17e5257774f11d6c05ed6e00e28cb4039dbf.zip
phosphor-host-ipmid-295f17e5257774f11d6c05ed6e00e28cb4039dbf.tar.gz
sensor: Add function to support sensor with readingAssertion type
readingAssertion is special type where the entire assert bitfield serves as the value or reading. Change-Id: Iaddbe846e04d2a53cff69d71670a96ccc66636a8 Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Diffstat (limited to 'sensordatahandler.hpp')
-rw-r--r--sensordatahandler.hpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/sensordatahandler.hpp b/sensordatahandler.hpp
index 010772d..ba496e7 100644
--- a/sensordatahandler.hpp
+++ b/sensordatahandler.hpp
@@ -1,6 +1,8 @@
#pragma once
+#include "sensorhandler.h"
#include "types.hpp"
+#include "utils.hpp"
#include "host-ipmid/ipmid-api.h"
namespace ipmi
@@ -81,6 +83,38 @@ GetSensorResponse assertion(const Info& sensorInfo);
*/
GetSensorResponse eventdata2(const Info& sensorInfo);
+/**
+ * @brief readingAssertion is a case where the entire assertion state field
+ * serves as the sensor value.
+ *
+ * @tparam T - type of the dbus property related to sensor.
+ * @param[in] sensorInfo - Dbus info related to sensor.
+ *
+ * @return Response for get sensor reading command.
+ */
+template<typename T>
+GetSensorResponse readingAssertion(const Info& sensorInfo)
+{
+ sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()};
+ GetSensorResponse response {};
+ auto responseData = reinterpret_cast<GetReadingResponse*>(response.data());
+
+ auto service = ipmi::getService(bus,
+ sensorInfo.sensorInterface,
+ sensorInfo.sensorPath);
+
+ auto propValue = ipmi::getDbusProperty(
+ bus,
+ service,
+ sensorInfo.sensorPath,
+ sensorInfo.propertyInterfaces.begin()->first,
+ sensorInfo.propertyInterfaces.begin()->second.begin()->first);
+
+ setAssertionBytes(static_cast<uint16_t>(propValue.get<T>()), responseData);
+
+ return response;
+}
+
} //namespace get
namespace set
OpenPOWER on IntegriCloud