blob: e0bf6f423d0127a00924bf881b0caf0e0cda67c1 [file] [log] [blame]
#include "utils.hpp"
#include <iostream>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/server.hpp>
namespace openpower
{
namespace vpd
{
namespace inventory
{
auto getPIMService()
{
auto bus = sdbusplus::bus::new_default();
auto mapper =
bus.new_method_call("xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetObject");
mapper.append(pimPath);
mapper.append(std::vector<std::string>({pimIntf}));
auto result = bus.call(mapper);
if (result.is_method_error())
{
throw std::runtime_error("ObjectMapper GetObject failed");
}
std::map<std::string, std::vector<std::string>> response;
result.read(response);
if (response.empty())
{
throw std::runtime_error("ObjectMapper GetObject bad response");
}
return response.begin()->first;
}
void callPIM(ObjectMap&& objects)
{
std::string service;
try
{
service = getPIMService();
auto bus = sdbusplus::bus::new_default();
auto pimMsg =
bus.new_method_call(service.c_str(), pimPath, pimIntf, "Notify");
pimMsg.append(std::move(objects));
auto result = bus.call(pimMsg);
if (result.is_method_error())
{
std::cerr << "PIM Notify() failed\n";
}
}
catch (const std::runtime_error& e)
{
using namespace phosphor::logging;
log<level::ERR>(e.what());
}
}
} // namespace inventory
using namespace openpower::vpd::constants;
LE2ByteData readUInt16LE(Binary::const_iterator iterator)
{
LE2ByteData lowByte = *iterator;
LE2ByteData highByte = *(iterator + 1);
lowByte |= (highByte << 8);
return lowByte;
}
} // namespace vpd
} // namespace openpower