Move i2c WR api into libipmid
Move the low-level i2c write-read api into libipmid,
to allow provider libraries access to i2c without duplicating this code.
Tested:
I2c master write read command still works:
ipmitool i2c bus=2 0x9c 8 0
Signed-off-by: Yong Li <yong.b.li@linux.intel.com>
Change-Id: I0d5f82cf46ecf871eebb47aae25537b5da1f2e6a
diff --git a/include/ipmid/utils.hpp b/include/ipmid/utils.hpp
index 9ef1488..45c9c1a 100644
--- a/include/ipmid/utils.hpp
+++ b/include/ipmid/utils.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <chrono>
+#include <ipmid/api-types.hpp>
#include <ipmid/types.hpp>
#include <optional>
#include <sdbusplus/server.hpp>
@@ -305,4 +306,14 @@
uint32_t getVLAN(const std::string& path);
} // namespace network
+
+/** @brief Perform the low-level i2c bus write-read.
+ * @param[in] i2cBus - i2c bus device node name, such as /dev/i2c-2.
+ * @param[in] slaveAddr - i2c device slave address.
+ * @param[in] writeData - The data written to i2c device.
+ * @param[out] readBuf - Data read from the i2c device.
+ */
+ipmi::Cc i2cWriteRead(std::string i2cBus, const uint8_t slaveAddr,
+ std::vector<uint8_t> writeData,
+ std::vector<uint8_t>& readBuf);
} // namespace ipmi