Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork101
Add timeout handling for I2C in Wire#497
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Also made the default timeout shorter than the 1000 ms that was hardcoded
CLAassistant commentedOct 8, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
HanzHager commentedOct 8, 2025
This should solve the issue#492 |
HanzHager commentedOct 8, 2025
The actions to reset the hardware in handleTimeout() is not well tested. It would be great if someone who knows better can take a look at it to see if it makes sense and if there should be changes. |
The new logic for the timeout loop in read_from() and write_to() had a bug. It is now fixed.
Adding timeout handling for I2C in Wire according to previously defined solution on other platformsAlso reduced the default timeout from 1000ms to 25ms
HanzHager commentedOct 9, 2025
Fixed a bug in timeout handling in read_from() and write_to() and made the commit cleaner |
HanzHager commentedOct 11, 2025
After some more testing I conclude that I need even more testing to make sure it works as intended. |
per1234 commentedOct 11, 2025
Thanks for your pull request, and for taking the time to provide an update on the situation@HanzHager! I see that one of Arduino's developers also submitted a similar pull request:#494 It would be great if you would review that prior pull request and help us to understand whether your PR provides any advancements when compared to the other, and whether the other might also suffer from any of the potential problems you have identified in testing of this PR. |
HanzHager commentedOct 11, 2025
I looked at this PR and it looks like it is using setTimeout() instead of setWireTimeout() for the implementation. I have tried to make a complete implementation that harmonizes best with this and the AVR implementation. I am quite new in making contributions like this, so I probably need quite some guidance to get it right. |
HanzHager commentedOct 11, 2025
I just noticed that#494 have renamed the setTimeout() to setWireTimeout(). The function sets timeout in milliseconds, but the referred implementationhttps://docs.arduino.cc/language-reference/en/functions/communication/wire/setWireTimeout/ are using microseconds as well as a boolean second parameter that tells the implementation to reset the bus on timeout or not. |
This version has more testing and some refinements for handling of timeoutIt still has some printouts and comments that might be useful for others review and testingWhen reviewed and tested, I will remove thisI have also packaged the same files as an independent library that is easy to download and install as a libraryThis can be found at:https://github.com/HanzHager/Wire
HanzHager commentedOct 13, 2025
I have now updated with a new better tested version, but more testing and review would be great |
Adding timeout handling for I2C in Wire according to previously defined solution on other platforms
Also reduced the default timeout from 1000ms till 25ms
Also created src directory as well as adding keywords.txt and library.properties so that the "Wire" part of the repository can be handled as a separate library