power-utils: Initially use i2c in updater
Create I2CDevice in updater and invoke read() in doUpdate(), that could
be used in future.
Use mocked I2CInterface in updater's unit test case.
Tested: Manually verify on Witherspoon that the i2c device is opened
and closed during PSU code update.
Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: Ie3d9f0565a2ceb000f489647a58ca967a2ef0c38
diff --git a/tools/power-utils/updater.hpp b/tools/power-utils/updater.hpp
index befa4fb..f22f663 100644
--- a/tools/power-utils/updater.hpp
+++ b/tools/power-utils/updater.hpp
@@ -15,10 +15,14 @@
*/
#pragma once
+#include "i2c_interface.hpp"
+
#include <filesystem>
#include <sdbusplus/bus.hpp>
#include <string>
+class TestUpdater;
+
namespace updater
{
@@ -37,6 +41,7 @@
class Updater
{
public:
+ friend TestUpdater;
Updater() = delete;
Updater(const Updater&) = delete;
Updater& operator=(const Updater&) = delete;
@@ -80,6 +85,13 @@
*/
int doUpdate();
+ /** @brief Create I2C device
+ *
+ * Creates the I2C device based on the device name.
+ * e.g. It opens busId 3, address 0x68 for "3-0068"
+ */
+ void createI2CDevice();
+
private:
/** @brief The sdbusplus DBus bus connection */
sdbusplus::bus::bus bus;
@@ -110,6 +122,9 @@
* /sys/bus/i2c/drivers/ibm-cffps
*/
fs::path driverPath;
+
+ /** @brief The i2c device interface */
+ std::unique_ptr<i2c::I2CInterface> i2c;
};
} // namespace updater