raspberry pi 5 smbus2 BlockingIOError

July 20, 2024, 11:22

neng1

Running the sample code below from smbus2
from smbus2 import SMBus, i2c_msg

# Single transaction writing two bytes then read two at address 80
write = i2c_msg.write(80, [40, 50])
read = i2c_msg.read(80, 2)
with SMBus(1) as bus:
    bus.i2c_rdwr(write, read)
I got error below
Traceback (most recent call last):
  File "/home/example.py", line 62, in <module>
    bus.i2c_rdwr(write, read)
  File "/home/.local/lib/python3.12/site-packages/smbus2/smbus2.py", line 658, in i2c_rdwr
    ioctl(self.fd, I2C_RDWR, ioctl_data)
BlockingIOError: [Errno 11] Resource temporarily unavailable
and checking the i2c device by running
sudo dmesg | grep i2c
i got this message
[22341.795707] i2c_designware 1f00074000.i2c: i2c_dw_handle_tx_abort: lost arbitration