Skip to content

Commit d0166fc

Browse files
committed
Fix kChunkSize - 1
1 parent c316bdb commit d0166fc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/sfe_bus.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,16 @@ namespace sfe_KX13X
174174
return -1; // Fail immediately if the transmission isn't successful
175175

176176
// We're chunking in data - keeping the max chunk to kMaxI2CBufferLength
177-
// The register address counts as one byte so limit nChunk to kChunkSize -1
178-
nChunk = numBytes > (kChunkSize - 1) ? (kChunkSize - 1) : numBytes;
177+
nChunk = numBytes > kChunkSize ? kChunkSize : numBytes;
179178

180179
nReturned = _i2cPort->requestFrom((int)addr, (int)nChunk, (int)true); // Always send a stop
181180

182181
// No data returned, no dice
183182
if (nReturned == 0)
184183
return -1; // error
185184

186-
// Check we got back as much data as was requested
185+
// Check we got back as much data as was requested.
186+
// (Fringe case. This should never happen... But, you know, it _could_...)
187187
if (nReturned != nChunk)
188188
failCount++; // Increment the failCount
189189

0 commit comments

Comments
 (0)