Any resources for understanding/coding w/ the SdFat library?

Hello all,
I'm new to all this, but I think I've got a fairly decent understanding of how to code an Arduino. The basic terminology and functions etc., although arithmetic was never one of my stronger characteristics but I manage. Arduino Playground - HomePage has been like a bible to me lately.

Now I'm digging into the SdFat library. I have a SeeedStudio SD Shield V3 but I'm having a lot of trouble trying to code it. As of now, its seems like they went with "Here is there examples, GOOD LUCK SUCKERS! They don't help me understand the terminology at all. I haven't found any good resources online. cout? bout? ofstream? AHHHH! XD What is this << :: >>? XD sdlog, end1 Where are you getting all this from!? XD

Thank you,

(EVENT LOG SAMPLE)

  1. void logEvent(const char *msg) {
    // create dir if needed
  2. sd.mkdir("LOGS/2011/JAN");

// create or open a file for append
3. ofstream sdlog("LOGS/2011/JAN/LOGFILE.TXT", ios::out | ios::app);

(MY INTERPRETATION)

  1. Now were just making up voids().

  2. sd. is the object, mkdir = make directory (Linux :D). Not too bad here.

  3. Is that French? / WHAT? / ("directory") / what / what is :: / out must append the file / |=or / app isn't an integer or announced anywhere else in the code so... sure?.

/*
 * Append a line to a file - demo of pathnames and streams
 */
#include <SdFat.h>

// SD chip select pin
const uint8_t chipSelect = SS;

// file system object
SdFat sd;

// define a serial output stream
ArduinoOutStream cout(Serial);
//------------------------------------------------------------------------------
/*
 * Append a line to LOGFILE.TXT
 */
void logEvent(const char *msg) {
  // create dir if needed
  sd.mkdir("LOGS/2011/JAN");

  // create or open a file for append
  ofstream sdlog("LOGS/2011/JAN/LOGFILE.TXT", ios::out | ios::app);

  // append a line to the file
  sdlog << msg << endl;

  // check for errors
  if (!sdlog) sd.errorHalt("append failed");

  // file will be closed when sdlog goes out of scope
}
//------------------------------------------------------------------------------
void setup() {
  Serial.begin(9600);

  // pstr stores strings in flash to save RAM
  cout << pstr("Type any character to start\n");
  while (Serial.read() < 0) {}

  // initialize the SD card at SPI_HALF_SPEED to avoid bus errors with
  // breadboards.  use SPI_FULL_SPEED for better performance.
  if (!sd.begin(chipSelect, SPI_HALF_SPEED)) sd.initErrorHalt();

  // append a line to the logfile
  logEvent("Another line for the logfile");

  cout << "Done - check /LOGS/2011/JAN/LOGFILE.TXT on the SD" << endl;
}
//------------------------------------------------------------------------------
void loop() {}

I haven't found any good resources online.

If you can't find something online that shows how to use cout, or what it is, turn your computer off and forget it.

  1. Now were just making up voids().

You haven't even got a grasp on the basics. They are FUNCTIONS. The return type is void!

  1. sd. is the object

The, calling the method would be sd..mkdir(). The object is sd (not sd.).

mkdir = make directory (Linux :D)

Windows, too. Not to mention OSX.

  1. Is that French?

No, it's Swahili.

what is ::

It's called a scope resolution operator.

out must append the file

And app makes it an output file? Wrong. out means that it is an output file. The app part appends to an existing file, instead of overwriting it.

app isn't an integer or announced anywhere else in the code so... sure?.

You did not look in the right place. Perhaps you should google how to use google better. Or, as hint, google ios::app rather than app by itself.

That sure was helpful in pointing me in the right direction Paul. I don't have time nor effort for negativity.

dritchie0042:
// create or open a file for append
3. ofstream sdlog("LOGS/2011/JAN/LOGFILE.TXT", ios::out | ios::app);
...
3. Is that French? / WHAT? / ("directory") / what / what is :: / out must append the file / |=or / app isn't an integer or announced anywhere else in the code so... sure?.

http://www.lmgtfy.com/?q=ofstream (129,000 results)

Sorry, but you have to do a bit of research for yourself.

http://www.lmgtfy.com/?q=ios%3A%3Aout (821 millions results, probably not all relevant)

When I said "I searched online, but found nothing", perhaps that wasn't put in to the right context.

Sure you can the definitions for anything you wish on the web. Whats the point though when you can't understand it. The amount of work going term through term in that manner isn't very efficient.

For example:
"C++98C++11
In terms of static initialization order, cout is guaranteed to be properly constructed and initialized no later than the first time an object of type ios_base::Init is constructed."

Is that how you guys learned C++? Many,many hours upon headaches? lol We all have to start somewhere, I'm surprised there isn't a more user friendly version or method for learning an SD Shield.

It took me about 10 seconds to find this by searching for arduino sd shield tutorial
http://www.ladyada.net/products/microsd/

It looks very helpful to me

Is that how you guys learned C++?

No. I bought a book, which seems to be something you are trying to avoid doing.

Google is great for looking up what a function does, but the trick is to know what to look up. You seem to be trying yo look up what the arguments to the function mean, without looking up what the function does.

Not surprisingly, if you look up ofstream, you'll find that it creates an output stream, and from there you'll find what the constructor does (that is what is being called there), and from there what the arguments are/mean.

Of course, looking up ofstream in the index of the book you didn't buy would give you a lot more background on ofstream, fstream, streams, etc.

Is that how you guys learned C++? Many,many hours upon headaches?

In my case, yes. i even had to translate all those technical terms to dutch.

but in the end, i'd say it well worth it!

nick

EDIT: my brother told me to edit my post. and i had to tell you it weren't many many hours..
he said i had to tell you it were many many months!

Get the BOOKS AND USE THEM instead of asking others to think for you... and GET OFF THE PITY POT...
I'm a 67 year old retired electronics engineer learning C++ for the first time...
And enjoying the challenge immensely. You??

Doc

nickn4:
EDIT: my brother told me to edit my post. and i had to tell you it weren't many many hours..
he said i had to tell you it were many many months!

Yep, I didn't learn C++ in a few hours. It look a lot longer.

My advice is to start with simple examples and build on those.