File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -163,10 +163,10 @@ namespace sfe_KX13X
163
163
if (!_i2cPort)
164
164
return -1 ;
165
165
166
- int i; // counter in loop
166
+ int i; // counter in loop
167
167
int failCount = 0 ; // Keep track of how many times nReturned is != nChunk
168
168
169
- while ((numBytes > 0 ) && (failCount < 5 )) // Give up after 5 bad requests
169
+ while ((numBytes > 0 ) && (failCount < 2 )) // Give up after 2 bad requests
170
170
{
171
171
_i2cPort->beginTransmission (addr);
172
172
_i2cPort->write (reg); // Write the register address we want to read from
@@ -175,7 +175,7 @@ namespace sfe_KX13X
175
175
176
176
// We're chunking in data - keeping the max chunk to kMaxI2CBufferLength
177
177
// The register address counts as one byte so limit nChunk to kChunkSize -1
178
- nChunk = numBytes > (kChunkSize -1 ) ? (kChunkSize -1 ) : numBytes;
178
+ nChunk = numBytes > (kChunkSize - 1 ) ? (kChunkSize - 1 ) : numBytes;
179
179
180
180
nReturned = _i2cPort->requestFrom ((int )addr, (int )nChunk, (int )true ); // Always send a stop
181
181
@@ -201,7 +201,7 @@ namespace sfe_KX13X
201
201
202
202
} // end while
203
203
204
- return 0 ; // Success
204
+ return (numBytes == 0 ? 0 : - 1 ) ; // 0 = success (all bytes read), -1 = error
205
205
}
206
206
207
207
// ////////////////////////////////////////////////////////////////////////////////////////////////
You can’t perform that action at this time.
0 commit comments