-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Wire library has no timeout functionality (meaning it is blocking). #83
Comments
Also interested to hear if this also affects the megaavr. I spotted a while loop in the source, so it seems likely. Do note however that this is a (good) mitigation to try to reduce the impact of underlying issues. So we are supposed to look into those regardless of this change as we can still see other serious issues due to root cause. See arduino/reference-en#895 |
Hi, from looking into the wire library code, it seems to me that the logic is very different from arduinocore-avr. The only place where a "while" loop occurs is in function TWI_MasterWriteRead():
ArduinoCore-megaavr/libraries/Wire/src/utility/twi.c Lines 327 to 335 in c31614b
In contrast to the avr core, the main work is performed by hardware and an ISR. So the first question is- is it possible that the ISR never updates the status? I saw that there are error codes for "bus error" and "arbitration lost". Please also consider that there could be another infitite loop in case of repeated TWIM_RESULT_ARBITRATION_LOST. |
+1 I find the I2C bus on my Uno wifi rev2 randomly freezing with 2 devices on it, and this feature would probably help a lot |
In trying to solve some I2C issues I've been having, I came across this thread (and a great many others), which indicate the Wire libraries don't have any timeout capabilities, particularly making
Wire .endTransmission ()
blocking. This has since been solved and merged into ArduinoCore-avr and has appeared in my libraries locally. To the best of my knowledge (and my own experience), the ArduinoCore-megaavr Wire library is also blocking. I haven't been able to find this fix in the ArduinoCore-megaavr version of Wire, and I haven't found any other issues relating to this, so I'm raising one now.I'm not aware of the development relationship between the two cores, so if this already on its way, that's great. If not (and it's appropriate to do so), I'd like to see the functionality added to ArduinoCore-avr added here too. Particularly, I'd like to see functionality added that's similar to that provided by the new functions
setWireTimeout()
,getWireTimeoutFlag()
,clearWireTimeoutFlag()
.The text was updated successfully, but these errors were encountered: