PersistentStorage.MountFileSystem() should be a blocking call

Not sure if this is in the .NET framework or the GHI SDK,
but consider the following snippet:

public static void Mount()
    if (sdCard == null)
        sdCard = new PersistentStorage(DEVICE_ID);

If you remove the Thread.Sleep(100), you will always get an exception,
if you try to access the SD card right away.
So something tells me, the mount requires a little time,
but MountFileSystem does not block until everything is ready.

Very interesting!

Could you please post the error you get without the


Thank you for sharing!


[quote]#### Exception System.IO.IOException - CLR_E_FILE_IO (4) ####
#### Message:
#### Microsoft.SPOT.IO.VolumeInfo::.ctor [IP: 0000] ####
#### Microsoft.SPOT.IO.RemovableMedia::MessageHandler [IP: 0022] ####
A first chance exception of type ‘System.IO.IOException’ occurred in Microsoft.SPOT.IO.dll
An unhandled exception of type ‘System.IO.IOException’ occurred in Microsoft.SPOT.IO.dll

Not much to go on I’m afraid

it does take a while for the SD to be recognized. there is a. method to check if the SD is present. use it before mounting.

I know…
Basically it requires a “while not ready just sleep”

That’s why I put it in suggestions, my suggestion is this should be a blocking call.

I see cases when you will need it, but I rather leave it as is. I mount the file system as the first thing, and do other initializations before I use any file io. By the time I am done, it is mounted and ready for me. The point is you can do other things instead of wasting cpu cycles waiting.

It only returns when it is done. The exception is in the InsertEvent thread. I think you are unmounting right after this call too fast…
Try the SD code here. It accesses the SD card in the InsertEvent so you will not get an exception.

I’m not unmounting at any point in that code.