Pages: [1]   Go Down
Author Topic: SdFat.h incompatible with SD.h?  (Read 1613 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 10
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

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

Regards,

Fatih
Logged

0
Offline Offline
Edison Member
*
Karma: 67
Posts: 1656
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
 uint32_t bytesLeft;
  bytesLeft = file.fileSize() - file.curPosition();

Too get the correct result with SD.h use this expression instead of available():
Code:
 uint32_t bytesLeft;
  bytesLeft = file.size() - file.position();

« Last Edit: July 20, 2012, 09:36:40 am by fat16lib » Logged

London, ON
Offline Offline
Jr. Member
**
Karma: 0
Posts: 94
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Daniel
Logged

Dialup is the future.

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 640
Posts: 50335
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

0
Offline Offline
Edison Member
*
Karma: 67
Posts: 1656
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: