-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add a timeout to busio_i2c_scan #5908
Conversation
Force pushed: changed timeout to 5s. |
We can also reduce the actual I2C timeouts to something much shorter. |
Discussed with dan in discord and there's a lot more work to be done with i2c. |
We can keep this open for discussion now. I will just make it a draft. |
Another possibility is to check for KeyboardInterrupt at each trip through the loop, so that a scan can be ctrl-c'd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make the probe fast instead? https://github.com/adafruit/circuitpython/blob/main/ports/espressif/common-hal/busio/I2C.c#L144
We shouldn't need to wait at all to determine it.
|
This is not working, it looks like |
|
This was a reported as a bug: went back in time, and when TickType_t wait_time = (ticks_to_wait < (I2C_CMD_ALIVE_INTERVAL_TICK) ? ticks_to_wait : (I2C_CMD_ALIVE_INTERVAL_TICK)); (Commented as such here: espressif/esp-idf#4999 (comment)) |
- fix i2c crash - fix usb when enabling wifi Co-authored-by: Jeff Epler <jepler@gmail.com> Co-authored-by: Scott Shawcroft <scott@adafruit.com>
I think the next step here is to submit one or more PR's (depending on versions) to es to fix espressif/esp-idf#4999. We can also patch this in https://github.com/adafruit/esp-idf for now, since we are already using that fork. |
@prplz Shall we close this now that you fixed the pullup problem? I think it's still true that ESP-IDF really needs a fix for #5908 (comment). We could open a separate issue about that. |
Sure |
@UnexpectedMaker recently discovered an annoyance where i2c scan can hang for over a minute on esp32 (#5906).
It goes something like this:
common_hal_busio_i2c_construct
passes most of the time despite floating pinsbusio_i2c_scan
tries to probe 110 addresses, each probe times out after one second (see this comment), making cpy hang for an unacceptably long timeI have added a
twofive second deadline tobusio_i2c_scan
. I hope this will not effect normal operation and will only cover this strange case.Tested on esp32-s3 hardware. With pullups the scan run in about one second, without the pullups it raises an exception after about
two or threefive or six seconds.