I'm interfacing VL6180X proximity sensor (datasheet is here http://www.st.com/content/ccc/resource/ ... 112632.pdf) and it uses 16-bit address for registers.
As far as I understand python smbus and smbus2 packages use 8-bit address, and i2cdump too.
The workaround that I've found is here:
This code correctly reads chip id from register 0x0000 every time. If I read register 0x00 using packages smbus or smbus2, it returns correct response (0xB4) only after sensor boot and afterwards it returns random bytes.
Code: Select all
import io import fcntl IOCTL_I2C_SLAVE = 0x0703 fr = io.open("/dev/i2c-1", "rb", buffering=0) fcntl.ioctl(fr, IOCTL_I2C_SLAVE, 0x29) fw = io.open("/dev/i2c-1", "wb", buffering=0) fcntl.ioctl(fw, IOCTL_I2C_SLAVE, 0x29) fw.write(bytearray([0x00, 0x00])) v = fr.read(1) print type(v), ord(v), hex(ord(v))