Main Site Documentation

PersistentStorage.MountFileSystem() should be a blocking call


#1

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);
        sdCard.MountFileSystem();
        Thread.Sleep(100);
    }               
}

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.


#2

Very interesting!

Could you please post the error you get without the

Thread.Sleep(100);

Thank you for sharing!

Stefano.


#3

[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
[/quote]

Not much to go on I’m afraid


#4

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.


#5

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.


#6

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.


#7

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.
http://www.ghielectronics.com/downloads/NETMF/Library%20Documentation/html/54b37f26-0981-f721-57fe-1cefaf27a246.htm


#8

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