Closed Koepel closed 6 years ago
Thanks. I inherited that code and didn't know that bit. I'm on vacation but will change it when I can.
Out of curiosity, what board are you using the code on, did you have any issues with it?
I did not use the code. I try to improve the use of the Arduino Wire library, because the wrong use of the Wire library is copied so many times.
It might have negative consequences in a very rare situation. If the Wire.requestFrom() detects a bus error or collision in a multi-master bus, it probably returns that zero bytes have been received. In that case the Wire.available() also returns zero, and that while-loop will halt the sketch.
Fixed by https://github.com/marcmerlin/IoTuz/commit/95f53be6569c68f7fbef491bb36082870f82d629 , soryr for the delay
In the file "IoTuz.cpp", in the function "i2cexp_read()", there is a while-loop after the Wire.requestFrom(). That while-loop can be removed, there is nothing to wait for.
When the Wire.requestFrom() returns, the I2C transaction has completely finished and the received data is waiting in a buffer in the Wire library.