Skip to content

Commit 5089bd1

Browse files
authored
solve issues #69 I2C init bug Jetson
exact description of the error and solution here: #69
1 parent b869a4a commit 5089bd1

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

adafruit_bus_device/i2c_device.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,11 @@ def __probe_for_device(self):
151151
while not self.i2c.try_lock():
152152
pass
153153
try:
154-
self.i2c.writeto(self.device_address, b"")
154+
result = bytearray(1)
155+
self.i2c.readfrom_into(self.device_address, result)
155156
except OSError:
156-
# some OS's dont like writing an empty bytesting...
157-
# Retry by reading a byte
158-
try:
159-
result = bytearray(1)
160-
self.i2c.readfrom_into(self.device_address, result)
161-
except OSError:
162-
# pylint: disable=raise-missing-from
163-
raise ValueError("No I2C device at address: 0x%x" % self.device_address)
164-
# pylint: enable=raise-missing-from
157+
# pylint: disable=raise-missing-from
158+
raise ValueError("No I2C device at address: 0x%x" % self.device_address)
159+
# pylint: enable=raise-missing-from
165160
finally:
166161
self.i2c.unlock()

0 commit comments

Comments
 (0)