Modify set sensor reading command
The Set Sensor handling code is modified to use generated code
for CPU, Core & DIMM sensors with Presence & Functional
offset.
Change-Id: I3b7fa4da870b745873da4732d457d793f5549ada
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/utils.cpp b/utils.cpp
new file mode 100644
index 0000000..1823819
--- /dev/null
+++ b/utils.cpp
@@ -0,0 +1,38 @@
+#include "utils.hpp"
+
+namespace ipmi
+{
+
+std::string getService(sdbusplus::bus::bus& bus,
+ const std::string& intf,
+ const std::string& path)
+{
+ auto mapperCall = bus.new_method_call("xyz.openbmc_project.ObjectMapper",
+ "/xyz/openbmc_project/ObjectMapper",
+ "xyz.openbmc_project.ObjectMapper",
+ "GetObject");
+
+ mapperCall.append(path);
+ mapperCall.append(std::vector<std::string>({intf}));
+
+ auto mapperResponseMsg = bus.call(mapperCall);
+
+ if (mapperResponseMsg.is_method_error())
+ {
+ throw std::runtime_error("ERROR in mapper call");
+ }
+
+ std::map<std::string, std::vector<std::string>> mapperResponse;
+ mapperResponseMsg.read(mapperResponse);
+
+ if (mapperResponse.begin() == mapperResponse.end())
+ {
+ throw std::runtime_error("ERROR in reading the mapper response");
+ }
+
+ return mapperResponse.begin()->first;
+}
+
+} // namespace ipmi
+
+