Skip to content

Commit 3a1339c

Browse files
committed
Fix I2C init error on BeagleBone Black
This init method verifies that a device exists at the given address. It was writing a zero byte value to the bus. This triggered a bug in the Linux kernel I2C bus OMAP2 driver for the BeagleBone. The driver returns an invalid write error when msg->len is 0: https://github.com/beagleboard/linux/blob/4.14/drivers/i2c/busses/i2c-omap.c#L665 The solution is to write the value 'x' instead of ''. Refer to Adafruit_Blinka PR #42 for more information: adafruit/Adafruit_Blinka#42 (comment)
1 parent d86fc7e commit 3a1339c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

adafruit_bus_device/i2c_device.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ class I2CDevice:
5757
device.write(bytes_read)
5858
"""
5959
def __init__(self, i2c, device_address):
60-
# Verify that a device with that address exists.
60+
# write non-zero byte value to verify device exists at address
6161
while not i2c.try_lock():
6262
pass
6363
try:
64-
i2c.writeto(device_address, b'')
64+
i2c.writeto(device_address, b'x')
6565
except OSError:
6666
raise ValueError("No I2C device at address: %x" % device_address)
6767
finally:

0 commit comments

Comments
 (0)