Skip to content

Commit 2458349

Browse files
Fix Wire::available() when ::requestFrom fails (#604)
Avoids returning 2^32 bytes in the case of a requestFrom read fails due to timeout.
1 parent 4ede3ff commit 2458349

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

libraries/Wire/src/Wire.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ size_t TwoWire::requestFrom(uint8_t address, size_t quantity, bool stopBit) {
216216
}
217217

218218
_buffLen = i2c_read_blocking_until(_i2c, address, _buff, quantity, !stopBit, make_timeout_time_ms(_timeout));
219-
if (_buffLen == PICO_ERROR_GENERIC) {
219+
if ((_buffLen == PICO_ERROR_GENERIC) || (_buffLen == PICO_ERROR_TIMEOUT)) {
220220
_buffLen = 0;
221221
}
222222
_buffOff = 0;

0 commit comments

Comments
 (0)