Skip to content

Fix for issue #6, problem for test of reading SDHC cards (32GB or larger)#7

Open
ericzundel wants to merge 1 commit intoadafruit:masterfrom
ericzundel:zundel/fix-SdReadTest
Open

Fix for issue #6, problem for test of reading SDHC cards (32GB or larger)#7
ericzundel wants to merge 1 commit intoadafruit:masterfrom
ericzundel:zundel/fix-SdReadTest

Conversation

@ericzundel
Copy link
Copy Markdown

@ericzundel ericzundel commented Oct 15, 2022

Adds a missing cast in SdReader.h for the size() method. Added new error value for reading a card with unsupported header.

This is a minor change to SdReader.h and SdReader.cpp that fixes a bug in reading the size
of large SD cards. I imagine most code that uses the library doesn't depend on this function,
but the SdReadTest unit test does.

See the equivalent code in https://github.com/greiman/SdFat/blob/master/src/SdCard/SdCardInfo.h#L326

I ran all examples in the WaveHC library. I discovered this when vetting my change for fixing issue #3 and decided to break it out into a separate PR.

Before this fix, the card size reported by the test was insanely large, probably caused by the top bit being set in a 16 bit int implicitly used when 'mid' is not cast:

card size: 4290192384 (512 byte blocks)

After this fix, the SdReader test reports a sane card size:

card size: 62333952 (512 byte blocks)

Add missing cast in SdReader.h for the size() method.
Added new error value for reading a card with unsupported header.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant