adafruit / Adafruit_CircuitPython_BusDevice

Two helper classes that handle transaction related state for I2C and SPI including locks.
MIT License
105 stars 76 forks source link

Add timeouts to bus devices. #51

Closed TG-Techie closed 4 years ago

TG-Techie commented 4 years ago

I noticed that on some devices (so far only nrf52840s) after many reboots all hardware locking hangs indefinitely. This modification adds timeouts to the bus devices (default of .25 seconds to be generous) where it will only try to lock for up to the specified amount of time. the timeout can be deactivated by passing None as the timeout. if the time runs out an exception of type exception is thrown. this code was tested on hardware similar to the feather nrf52840

dhalbert commented 4 years ago

The I2C bus hangs mentioned in that issue cannot be solved with timeouts in Python; timeouts have to be added in the C code at a low level where the bus status is checked.

kattni commented 4 years ago

This issue needs to be fixed in the CircuitPython core, not the bus_device library. I'm closing this in favor of https://github.com/adafruit/circuitpython/issues/2253