Shift to boost asio library
This commit shifts vpd manager from sdbusplus event loop to
boost io_context event loop.
The shift was done to have a more flexible way to perform
async Dbus calls.
For example read/write of vpd data can be performed
asynchronously.
It also removes dependency of Manager class on the interface
class created as a part of Phosphor-Dbus-Interface repo.
Test:
- Introspect com.ibm.VPD.Manager /com/ibm/VPD/Manager to ensure
that all the methods exposed under com.ibm.VPD.Manager interface
matches to the ones documented under PDI repo.
- Make DBus call to each of the exposed api to ensure that the
funcation calls are working fine.
-To ensure bios handler call back is working.
Stop vpd-manager service.
Stop pldm service.
Start vpd-manager service
Start pldm service.
Should recieve callback.
-To ensure gpio call back
std::cout were added to callback function being trigerred on
timer expiration and the same were verified in journal.
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
Change-Id: I00640f64de487d5244e8be2e7a3f3d63a013644e
diff --git a/vpd-manager/gpioMonitor.hpp b/vpd-manager/gpioMonitor.hpp
index 66c049d..58fbf91 100644
--- a/vpd-manager/gpioMonitor.hpp
+++ b/vpd-manager/gpioMonitor.hpp
@@ -1,8 +1,9 @@
#pragma once
+#include "types.hpp"
-#include "manager.hpp"
-
-#include <sdeventplus/event.hpp>
+#include <boost/asio/steady_timer.hpp>
+#include <nlohmann/json.hpp>
+#include <sdbusplus/asio/connection.hpp>
namespace openpower
{
@@ -29,13 +30,13 @@
GpioEventHandler(std::string& presPin, Byte& presValue, std::string& outPin,
Byte& outValue, std::string& devAddr, std::string& driver,
std::string& bus, std::string& objPath,
- sdeventplus::Event& event) :
+ std::shared_ptr<boost::asio::io_context>& ioCon) :
presencePin(presPin),
presenceValue(presValue), outputPin(outPin), outputValue(outValue),
devNameAddr(devAddr), driverType(driver), busType(bus),
objectPath(objPath)
{
- doEventAndTimerSetup(event);
+ doEventAndTimerSetup(ioCon);
}
private:
@@ -88,11 +89,20 @@
/** @brief This function runs a timer , which keeps checking for if an event
* happened, if event occured then takes action.
- * @param[in] timer- Shared pointer of Timer to do event setup for each
- * object.
- * @param[in] event- Event which needs to be tagged with the timer.
+ *
+ * @param[in] ioContext - Pointer to io context object.
*/
- void doEventAndTimerSetup(sdeventplus::Event& event);
+ void doEventAndTimerSetup(
+ std::shared_ptr<boost::asio::io_context>& ioContext);
+
+ /**
+ * @brief Api to handle timer expiry.
+ *
+ * @param ec - Error code.
+ * @param timer - Pointer to timer object.
+ */
+ void handleTimerExpiry(const boost::system::error_code& ec,
+ std::shared_ptr<boost::asio::steady_timer>& timer);
};
/** @class GpioMonitor
@@ -109,9 +119,11 @@
GpioMonitor(GpioMonitor&&) = delete;
GpioMonitor& operator=(GpioMonitor&&) = delete;
- GpioMonitor(nlohmann::json& js, sdeventplus::Event& event) : jsonFile(js)
+ GpioMonitor(nlohmann::json& js,
+ std::shared_ptr<boost::asio::io_context>& ioCon) :
+ jsonFile(js)
{
- initGpioInfos(event);
+ initGpioInfos(ioCon);
}
private:
@@ -122,14 +134,10 @@
/** @brief This function will extract the gpio informations from vpd json
* and store it in GpioEventHandler's private variables
- * @param[in] gpioObj - shared object to initialise it's data and it's
- * Timer setup
- * @param[in] requestedGpioPin - Which GPIO's informations need to be
- * stored
- * @param[in] timer - shared object of timer to do the event setup
- * @param[in] event - event to be tagged with timer.
+ *
+ * @param[in] ioContext - Pointer to io context object.
*/
- void initGpioInfos(sdeventplus::Event& event);
+ void initGpioInfos(std::shared_ptr<boost::asio::io_context>& ioContext);
};
} // namespace manager