"pmbus:chip_read" is a function that reads specified-length data from a chip with retry logic and error handling.
它依赖 self.psu_chip.Read 方法;
使用 string.char 构造带地址与命令的 buffer;
包含 RETRY_TIMES 和 E_OK 校验;
调用了底层 psu_chip:Read 方法。
表明:真正的协议级读取操作是经过封装、带校验和重试机制的,不是简单地“写完就读”。
2. WriteRead 接口仅用于标准 I2C/SMBus 操作
"WriteRead" is a method primarily associated with the bmc.kepler.Chip.BlockIO interface, designed to perform a sequence of write and read operations on hardware components, most commonly targeting I2C devices.
function custom_chip_read(fd, cmd, crc_enable)
local data = {0xAA, 0x55, 0x01, 0x00}
if crc_enable then
table.insert(data, calculate_crc(data))
end
local ret = fd:WriteRead(data, 8)
return ret
end