Pages: [1]   Go Down
Author Topic: SD.h library - error handling.  (Read 573 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 1
Posts: 221
What could possibly go wrong?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 149
Posts: 6117
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 637
Posts: 50299
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Full Member
***
Karma: 1
Posts: 221
What could possibly go wrong?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Full Member
***
Karma: 1
Posts: 221
What could possibly go wrong?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: