Skip to content
This repository was archived by the owner on Mar 16, 2026. It is now read-only.

Commit 3d59aa6

Browse files
authored
Merge pull request #1149 from masayuki0812/fix_sd_read_in_crc_calculation
Fix SD read in CRC calculation
2 parents bca41eb + 484afff commit 3d59aa6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Cart_Reader/Cart_Reader.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,10 +419,10 @@ uint32_t calculateCRC(const byte* buffer, size_t length) {
419419
}
420420

421421
uint32_t calculateCRC(FsFile& infile) {
422-
uint32_t byte_count;
422+
int32_t byte_count;
423423
uint32_t crc = 0xFFFFFFFF;
424424

425-
while ((byte_count = infile.read(sdBuffer, sizeof(sdBuffer))) != 0) {
425+
while ((byte_count = infile.read(sdBuffer, sizeof(sdBuffer))) > 0) {
426426
crc = updateCRC(sdBuffer, byte_count, crc);
427427
}
428428
return ~crc;

0 commit comments

Comments
 (0)