From 816e92b59fa52dcd997099a81e2f43a3512fca1e Mon Sep 17 00:00:00 2001 From: Tom Joseph Date: Wed, 6 Sep 2017 19:23:00 +0530 Subject: sensor: Add function to map dbus info to assertion status Change-Id: I30aae9abd7905ae3299856d798d41e10859fed7f Signed-off-by: Tom Joseph --- sensordatahandler.cpp | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) (limited to 'sensordatahandler.cpp') diff --git a/sensordatahandler.cpp b/sensordatahandler.cpp index b9ef5e2..231822b 100644 --- a/sensordatahandler.cpp +++ b/sensordatahandler.cpp @@ -1,9 +1,12 @@ #include +#include #include #include #include "xyz/openbmc_project/Common/error.hpp" #include "types.hpp" +#include "sensorhandler.h" #include "sensordatahandler.hpp" +#include "utils.hpp" namespace ipmi { @@ -104,6 +107,55 @@ ipmi_ret_t updateToDbus(IpmiUpdateData& msg) return IPMI_CC_OK; } +namespace get +{ + +GetSensorResponse mapDbusToAssertion(const Info& sensorInfo, + const InstancePath& path, + const DbusInterface& interface) +{ + sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; + GetSensorResponse response {}; + auto responseData = reinterpret_cast(response.data()); + + auto service = ipmi::getService(bus, interface, path); + + const auto& interfaceList = sensorInfo.propertyInterfaces; + + for (const auto& interface : interfaceList) + { + for (const auto& property : interface.second) + { + auto propValue = ipmi::getDbusProperty(bus, + service, + path, + interface.first, + property.first); + + for (const auto& value : property.second) + { + if (propValue == value.second.assert) + { + setOffset(value.first, responseData); + break; + } + + } + } + } + + return response; +} + +GetSensorResponse assertion(const Info& sensorInfo) +{ + return mapDbusToAssertion(sensorInfo, + sensorInfo.sensorPath, + sensorInfo.sensorInterface); +} + +} //namespace get + namespace set { @@ -252,6 +304,30 @@ ipmi_ret_t assertion(const SetSensorReadingReq& cmdData, msg.append(std::move(objects)); return updateToDbus(msg); } + }//namespace notify + +namespace inventory +{ + +namespace get +{ + +GetSensorResponse assertion(const Info& sensorInfo) +{ + namespace fs = std::experimental::filesystem; + + fs::path path{ipmi::sensor::inventoryRoot}; + path += sensorInfo.sensorPath; + + return ipmi::sensor::get::mapDbusToAssertion( + sensorInfo, + path.string(), + sensorInfo.propertyInterfaces.begin()->first); +} + +} //namespace get + +} // namespace inventory }//namespace sensor }//namespace ipmi -- cgit v1.2.1