Skip to content

solve issues #69 I2C init bug Jetson #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions adafruit_bus_device/i2c_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,11 @@ def __probe_for_device(self):
while not self.i2c.try_lock():
pass
try:
self.i2c.writeto(self.device_address, b"")
result = bytearray(1)
self.i2c.readfrom_into(self.device_address, result)
except OSError:
# some OS's dont like writing an empty bytesting...
# Retry by reading a byte
try:
result = bytearray(1)
self.i2c.readfrom_into(self.device_address, result)
except OSError:
# pylint: disable=raise-missing-from
raise ValueError("No I2C device at address: 0x%x" % self.device_address)
# pylint: enable=raise-missing-from
# pylint: disable=raise-missing-from
raise ValueError("No I2C device at address: 0x%x" % self.device_address)
# pylint: enable=raise-missing-from
finally:
self.i2c.unlock()