You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the file "Arduino-SRF/src/SonarSRF.cpp" there is a while (Wire.available() < length); after the Wire.requestFrom(). That line can be removed, because there is nothing to wait for.
When the Wire.requestFrom() returns, the I2C transaction on the bus has completely finished and the received data is waiting in a buffer in the Wire library.
The text was updated successfully, but these errors were encountered:
Really interesting point, I admit I never been really sure to follow strictly the whole I2C process... 😇
Do you have any documentation to support your suggestion?
Anyway, I would love to see a pull request with your suggestion! 🎉
I think we should stick with the official documentation: www.arduino.cc/en/Reference/WireRequestFrom. The Wire.requestFrom() even returns the final number of received bytes.
My "proof" is that I tell others that the waiting or timeout is something that someone has made up and others have copied it.
There are a number of Wire libraries for different processors. You could look into the Wire library for AVR processors and analyze that.
P.S.: It is not a real "bug", but more an "inconvenience". The Wire library can detect a few problems on the I2C bus and might return with zero bytes in the buffer. When that happens, the Wire.available() returns zero and the while-loop would never end.
In the file "Arduino-SRF/src/SonarSRF.cpp" there is a
while (Wire.available() < length);
after the Wire.requestFrom(). That line can be removed, because there is nothing to wait for.When the Wire.requestFrom() returns, the I2C transaction on the bus has completely finished and the received data is waiting in a buffer in the Wire library.
The text was updated successfully, but these errors were encountered: