diff --git a/I2CManager_Wire.h b/I2CManager_Wire.h index 1af1a68..d8add75 100644 --- a/I2CManager_Wire.h +++ b/I2CManager_Wire.h @@ -192,7 +192,11 @@ uint8_t I2CManagerClass::read(I2CAddress address, uint8_t readBuffer[], uint8_t DIAG(F("Wire.available()=%d"),Wire.available()); // while (Wire.available() && nBytes < readSize) while (nBytes < readSize) - readBuffer[nBytes++] = Wire.read(); + if (Wire.available()) { + readBuffer[nBytes++] = Wire.read(); + } else { + delay(1); + } // DIAG(F("nBytes=%d,readBuffer[nBytes]=%d"),nBytes-1,readBuffer[nBytes-1]); if (nBytes < readSize) status = I2C_STATUS_TRUNCATED; DIAG(F("status=%d"),status);