Arduino SD library, SD.begin and ejecting the card

Hi everyone. Tried various searches and found a couple of threads that were close to my situation, but not quite.

The library is the SD library that comes with the Arduino IDE (1.0.1).

I have a system with an Arduino MEGA controlling all sorts of things. The instructions come from a text file on an SD card that the controller reads when I push a button. But, once I have completed one set of instructions, I have to eject the card and go to my computer with it to rewrite new instructions on it. Then I'll return to my Arduino, insert the card and press that button to get it going again. Arduino will not (and can not) reset in between.

But, the library tutorials don't say a word on what I should do in this kind of situation, the usual instructions just assume the card is mounted till power down.

So, when I press the button to activate reading from the card, should I always call SD.begin() to initialize the inserted card?

All I know is that the opened file have to be closed before ejecting, but as there is no SD.eject() to deinitialize the card I had to ask this.

Thank you for you time.

Anyone, please?

Have you tried to run an experiment like ejecting a crd many times to see if it all still works?

You could also look at the library to see what begin actually does and decide if you need to call it for each ejection.

marco_c:
Have you tried to run an experiment like ejecting a crd many times to see if it all still works?

You could also look at the library to see what begin actually does and decide if you need to call it for each ejection.

Don't have an Arduino to play with (yet), but I do need to code for it, so testing is out at the moment.

I'll take a look at the library to see if I can figure it out.

Unfortunately the Arduino SD library, SD.h, has a bug that prevents initialization of a new card by calling SD.begin().

SdFat allows begin() to be called multiple times. There is no end() call, you only need to close all files before removing the card.

Once the new card is inserted, call begin() to initialize the new card.