Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ericzundel
Copy link

@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