summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Joseph <tomjoseph@in.ibm.com>2017-09-06 23:57:36 +0530
committerTom Joseph <tomjoseph@in.ibm.com>2017-09-14 18:48:09 +0530
commite4014fca76e418e5d7d5c8ce8720913f998cd9de (patch)
treecdb5174b44f19cdadf443a462290fd8e1c1fe154
parent816e92b59fa52dcd997099a81e2f43a3512fca1e (diff)
downloadphosphor-host-ipmid-e4014fca76e418e5d7d5c8ce8720913f998cd9de.zip
phosphor-host-ipmid-e4014fca76e418e5d7d5c8ce8720913f998cd9de.tar.gz
sensor: Add function to map dbus info to reading field
For sensor's with reading type eventData2, the eventdata2 field is mapped to the reading field in the get sensor reading command response. Change-Id: I9ad85ddb48d6c273a22e476e29ea9bbb34c13e24 Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
-rw-r--r--sensordatahandler.cpp36
-rw-r--r--sensordatahandler.hpp10
-rw-r--r--sensorhandler.h11
3 files changed, 57 insertions, 0 deletions
diff --git a/sensordatahandler.cpp b/sensordatahandler.cpp
index 231822b..aca81c7 100644
--- a/sensordatahandler.cpp
+++ b/sensordatahandler.cpp
@@ -154,6 +154,42 @@ GetSensorResponse assertion(const Info& sensorInfo)
sensorInfo.sensorInterface);
}
+GetSensorResponse eventdata2(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);
+
+ const auto& interfaceList = sensorInfo.propertyInterfaces;
+
+ for (const auto& interface : interfaceList)
+ {
+ for (const auto& property : interface.second)
+ {
+ auto propValue = ipmi::getDbusProperty(bus,
+ service,
+ sensorInfo.sensorPath,
+ interface.first,
+ property.first);
+
+ for (const auto& value : property.second)
+ {
+ if (propValue == value.second.assert)
+ {
+ setReading(value.first, responseData);
+ break;
+ }
+ }
+ }
+ }
+
+ return response;
+}
+
} //namespace get
namespace set
diff --git a/sensordatahandler.hpp b/sensordatahandler.hpp
index 3a66f48..010772d 100644
--- a/sensordatahandler.hpp
+++ b/sensordatahandler.hpp
@@ -71,6 +71,16 @@ GetSensorResponse mapDbusToAssertion(const Info& sensorInfo,
*/
GetSensorResponse assertion(const Info& sensorInfo);
+/**
+ * @brief Maps the Dbus info to the reading field in the Get sensor reading
+ * command response.
+ *
+ * @param[in] sensorInfo - Dbus info related to sensor.
+ *
+ * @return Response for get sensor reading command.
+ */
+GetSensorResponse eventdata2(const Info& sensorInfo);
+
} //namespace get
namespace set
diff --git a/sensorhandler.h b/sensorhandler.h
index 576c803..a078693 100644
--- a/sensorhandler.h
+++ b/sensorhandler.h
@@ -499,6 +499,17 @@ inline void setOffset(uint8_t offset, ipmi::sensor::GetReadingResponse* resp)
}
}
+/**
+ * @brief Set the reading field in the response.
+ *
+ * @param[in] offset - offset number.
+ * @param[in/out] resp - get sensor reading response.
+ */
+inline void setReading(uint8_t value, ipmi::sensor::GetReadingResponse* resp)
+{
+ resp->reading = value;
+}
+
} // namespace sensor
} // namespace ipmi
OpenPOWER on IntegriCloud