i2c: Implement write function
Implement I2CDevice::write() by invoking i2c_smbus_write_xxx() APIs.
The code is referenced from i2c-tools' i2cset.c:
https://github.com/ev3dev/i2c-tools/blob/ev3dev-stretch/tools/i2cset.c
Tested: Verify on Witherspoon that it writes the PSU unlock upgrade
command and boot flag successfully.
Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: I9fb014c787ef3ebb2f7793a0d012b1d652ef069f
diff --git a/tools/power-utils/test/test_updater.cpp b/tools/power-utils/test/test_updater.cpp
index d2dfd11..e1b6a2e 100644
--- a/tools/power-utils/test/test_updater.cpp
+++ b/tools/power-utils/test/test_updater.cpp
@@ -24,6 +24,7 @@
using ::testing::_;
using ::testing::An;
+using ::testing::Pointee;
namespace updater
{
@@ -95,10 +96,10 @@
updater = std::make_unique<Updater>(psuInventoryPath, devPath, imageDir);
updater->createI2CDevice();
auto& i2c = getMockedI2c();
- EXPECT_CALL(i2c, read(An<uint8_t&>()));
- EXPECT_CALL(i2c, read(_, An<uint8_t&>()));
- EXPECT_CALL(i2c, read(_, An<uint16_t&>()));
- EXPECT_CALL(i2c, read(_, An<uint8_t&>(), _));
+
+ EXPECT_CALL(i2c, write(0xf0, 12, _));
+ EXPECT_CALL(i2c, write(0xf1, An<uint8_t>()));
+ EXPECT_CALL(i2c, read(0xf1, An<uint8_t&>()));
updater->doUpdate();
}