Fix I2CEEBlockDevice read()

When reading a data block, the returned error codes from the I2C subsystem
are different from normal single byte operations. We have to verify that
the read-function for multiple bytes does return zero, because it
returns "readBytes != expectedLength".

Additionally, sync before trying to read from the eeprom as slow devices
may not yet be ready to return data, especially with low-priced ones
used with fast controllers.
pull/12395/head
Stephan Brunner 2020-02-07 22:35:18 +01:00
parent d847f9f164
commit 97c00f1a22
1 changed files with 3 additions and 1 deletions

View File

@ -68,7 +68,9 @@ int I2CEEBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size)
_i2c->stop();
if (_i2c->read(_i2c_addr, static_cast<char *>(buffer), size) < 0) {
_sync();
if (0 != _i2c->read(_i2c_addr, static_cast<char *>(buffer), size)) {
return BD_ERROR_DEVICE_ERROR;
}