Go Down

Topic: SD.h library - error handling. (Read 601 times) previous topic - next topic

OhMyCod

I've written a library that will write messages to both the screen, and an SD card using the SD.h library.

I've noticed that if I forget to insert the SD card or there's a hardware fault I get the following error....
Quote
10111411411111458329997114100461051101051163210297105108101100
83683210111411411111458321,


I've dug around in SD.h, and it seems that this error comes when the init() method is run on the Sd2Card object.

Fair enough, there's a problem, and the code has generated an error, as it should. However, what I'd like to do is be able to skip and ignore this error. As i said, my library is designed to write messages to both the screen and the SD card, if the SD card isn't available then obviously it my project can't write to it, but I'd still like it to carry on and display to the screen. At the moment I get this error and everything stops, is it possible to just bypass it and continue?

I've not include any code, I beleive the message comes from within SD.h which I believe is now included in the arduino package. (it's also beyond my level of understanding, so I haven't been able to dig into it too far)

thanks

SurferTim

How do you get that error? SD.begin() returns true on success and false on fail.

What device are you using? Is it just an SD card or some other device on the shield also? Any other SPI devices connected to the Arduino?

PaulS

Quote
At the moment I get this error and everything stops

Most likely, because your code tells it to do that.

Quote
is it possible to just bypass it and continue?

Maybe.

Quote
I've not include any code

Oops.

OhMyCod

Quote

Quote
Quote
I've not include any code
Oops.

the message appears to be coming from within SD.h which everyone should already have.

This line (343) appears to be raising the error...
Code: [Select]
  return card.init(SPI_HALF_SPEED, csPin) &&
         volume.init(card) &&
         root.openRoot(volume);


since this is a 'standard' library, I assumed it was a standard error. Obviously I was wrong! I'll try to knock up a quick sketch to illustrate.

Thanks

OhMyCod

Ok, finally realized where the error is coming from.

I've started a new thread for this one...

http://forum.arduino.cc/index.php?topic=170384.0

Go Up