Add timeout checks for i2cdetect and smbus calls #14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
When a I2C buss is not functioning correctly the i2cdetect tool takes a long time(several minutes) to go through all addresses and locks the UI until it finishes. Similar with the smbus.SMBus.write_quick(). Since nothing is displayed during the process and no message is shown in the end it's hard to troubleshoot.
Fix
Notes
The timeout value is set to 1 second (hard-coded) for both the calls, smbus locks for longer anyhow tho. Feel free to change this if necessary.
But this should be plenty of margin, assuming:
127 Addresses, 100 kbit/s, total frame of 3 bytes should take 3 milliseconds, not accounting for delays between the transfers.
Replicate
Issue can be replicated by shorting SCL and SDA pins on the I2C bus when using the MacArthur Hat and ICM-20948 module.
Tested
Tested on:
RPi-4B installed with OpenPlotter
OS: Debian 12 (bookworm)
Kernel: 6.12.47+rpt-rpi-v8
Arch: arm64
Idk if this is of interest.
Noticed this due to a faulty sensor board that had a solder bridge between the SCL and SDA pins on the component.