Pages: [1]   Go Down
Author Topic: Why do people still use SD.h  (Read 716 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 6
Posts: 225
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

SD.h is basically and out of date version of sdfatlib but slightly modified to ensure that it wears out the sd and write slower by flushing the buffer after every byte is written. Why not just use the latest version of sdfatlib it is now much better than SD.h. What is the point of even including SD.h when it is clear that they don't keep it in sync with the latest version of sdfatlib. While I am at it seems that non of libraries included with the arduino are really that good for an 8bit microcontroller. I have ditched the arduino ide and now just use avr-gcc.
« Last Edit: July 22, 2013, 10:14:01 am by Mr_arduino » Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 168
Posts: 12430
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Why do people still use SD.h
- backwards compatibility of old sketches
- easier interface
- they do not know other sd libs
- maybe footprint (but I do not know if it is smaller)
- ...
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

0
Offline Offline
Edison Member
*
Karma: 44
Posts: 1471
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think the main reason is that SD.h is the standard SD library included with the IDE.

So these are two reasons:
Quote
- backwards compatibility of old sketches
- they do not know other sd libs

The SdFat API has many more functions than SD.h so it is harder to understand.  Most people use the most basic functionality and don't require much performance so SD.h is fine.

For basic sketches SdFat is smaller and the complexity is about the same as SD.h.

Here is a simple SdFat sketch that writes a line to a file.  It uses 10,736 bytes of flash with the latest version of SdFat and Arduino 1.0.5.
Code:
/*
 * Sketch to compare size of SdFat with Arduino SD library.
 * See SD_Size.ino for Arduino SD sketch.
 *
 */
#include <SdFat.h>

SdFat sd;

SdFile file;
//------------------------------------------------------------------------------
void setup() {
  Serial.begin(9600);
  while (!Serial) {}  // wait for Leonardo

  if (!sd.begin()) {
    Serial.println("begin failed");
    return;
  }
  file.open("SIZE_TST.TXT", O_RDWR | O_CREAT | O_AT_END);

  file.println("Hello");

  file.close();
  Serial.println("Done");
}
//------------------------------------------------------------------------------
void loop() {}

Here is the SD.h version of the sketch.  It uses  13,278 bytes of flash with Arduino 1.0.5.
Code:
/*
 * Sketch to compare size of Arduino SD library with SdFat.
 * See SdFatSize.ino for SdFat sketch.
 */
#include <SPI.h>
#include <SD.h>

File file;
//------------------------------------------------------------------------------
void setup() {
  Serial.begin(9600);
  while (!Serial) {}  // wait for Leonardo

  if (!SD.begin()) {
    Serial.println("begin failed");
    return;
  }
  file = SD.open("TEST_SD.TXT", FILE_WRITE);

  file.println("Hello");

  file.close();
  Serial.println("Done");
}
//------------------------------------------------------------------------------
void loop() {}
Logged

Pages: [1]   Go Up
Jump to: