- If the function requestFrom() is executed partially due to internal fault either in the Master or Slave, the value returned by requestFrom() will be less than the value returned by available(). What value will Wire.available() return in this abnormal case?
This is not how I understand it. Wire.requestFrom() and Wire.available() will always show either 0 or the number of bytes requested. The master actually receives all the bytes requested, but some of them will be 0xff if the slave does not send anything.
See this discussion from the git hub issue on Wire.requestFrom().
The I2C protocol does not support a slave refusing to send data. When the onRequestEvent()'s data is exhausted, the TWI code just turns off the hardware until it see a DATA_NAK from the Master. Meanwhile the Master is just receiving 0xFF because no one is driving the SDA line. The documentation should be change to say requestFrom either returns 0, or number of requested bytes. 0 if the Slave NAKed the address or (requested bytes) that might have a bunch of 0xff appended.