lua-periphery icon indicating copy to clipboard operation
lua-periphery copied to clipboard

i2c:transfer exception

Open guachong133 opened this issue 2 years ago • 0 comments

hi its really a wonderful tool but I meet the following error when running i2c test:


local I2C = require('periphery').I2C
-- Open i2c-0 controller
local i2c = I2C("/dev/i2c-0")

-- Read byte at address 0x100 of EEPROM at 0x50
-- local msgs = { {0xac,0x33,0x00}, {0x00,0x00,0x00,0x00,0x00,0x00,0x00,flags = I2C.I2C_M_RD} }
 local msgs = { {0x01, 0x00}, {0x00, flags = I2C.I2C_M_RD} }
i2c:transfer(0x38, msgs)
print(string.format("0x100: 0x%02x", msgs[2][1]))
i2c:close()

when run ,it returns

$ lua ./api_iic.lua
lua: Error: I2C transfer: Invalid argument [errno 22]

my version is

$ lua -v
Lua 5.3.3  Copyright (C) 1994-2016 Lua.org, PUC-Rio

it will be great thansk if you would help to provide more guide to location the problem thanks~

guachong133 avatar Nov 13 '23 16:11 guachong133