Go Down

Topic: SdFat.h incompatible with SD.h? (Read 2785 times) previous topic - next topic



I am working on SD cards and mostly using SdFat.h library. However, I would need some functions from SD.h, I am getting some errors when compiling. Is there a solution for solving this incompatibility between these libraries.

At the moment, I need to have the available size left on SD card. I know how to do it in SD.h but not in SDFat.h




Jul 20, 2012, 04:26 pm Last Edit: Jul 20, 2012, 04:36 pm by fat16lib Reason: 1
If you mean file.available(), SdFat does not provide available() since this function does not always provide the correct result in SD.h. The problem is available() is declared as an int in the Stream class.  Type int is limited to 32767 bytes but files can be much larger, up to 4294967295 bytes.

You can use the following expression in SdFat:
Code: [Select]

 uint32_t bytesLeft;
 bytesLeft = file.fileSize() - file.curPosition();

Too get the correct result with SD.h use this expression instead of available():
Code: [Select]

 uint32_t bytesLeft;
 bytesLeft = file.size() - file.position();


I am having this error as well.  Is there any new versions that make <SdFat.h> (Arduino DUE ver.) compatible with <SD.h>?

Dialup is the future.


I am having this error as well.

This error? Would that be the unspecified errors OP was complaining about? Perhaps YOU could be more specific.
The art of getting good answers lies in asking good questions.


The current version of SdFat has an available() function that returns the correct unsigned 32-bit value on both AVR and ARM.

The Arduino SD.h available() returns the wrong answer for large files on both AVR and ARM.

Go Up