Closed
Description
Hi, I noticed that you wait with a timeout after a Wire.requestFrom(). It is in five files.
However, there is no such thing as waiting for data, with or without a timeout. That is a myth.
Explanation: Common-mistakes#1
If you want to return -1 when the I2C devices was not found (or if there was a I2C bus problem), then you can do this:
// Request 2 bytes from CMPS10
Wire.requestFrom(_i2cAddress , TWO_BYTES);
// Check if the same amount of bytes was received as was requested
if( Wire.available() != TWO_BYTES)
return -1;
Written in a shorter and nice way:
// Request 2 bytes from CMPS10
auto n = Wire.requestFrom(_i2cAddress , TWO_BYTES);
if( n != TWO_BYTES)
return -1;
Or in a short and ugly way:
if( Wire.requestFrom(_i2cAddress , TWO_BYTES) != TWO_BYTES) return -1;
Metadata
Metadata
Assignees
Labels
No labels