Main Site Documentation

Persistent Storage - Always unmount and dispose?


#1

Hi all, first post!

Quick question regarding the PersistentStorage object. I am writing a logging application which will be writing various information to a text file located on my SD card at regular intervals.

The question is, do I need to UnMount the SD card after each write or can I just mount the card once on application startup and then leave it mounted?

Regards
Adrian


#2

It should be mounted once the card is inserted (or at startup if already inserted) and unmounted when the card is removed.


#3

Great, thanks for the reply. In our environment the SD card should never be removed unless the device is powered down so shouldn’t be an issue.


#4

In this case, a flush on the filestream after each write should keep the data intact (in case of a power loss or other things).


#5

Another quick question regarding PS, can I have both the SD card and the USB mounted at the same time? I just tried the following code from the beginners guide:

static void DeviceConnected(USBH_Device device)
{
Debug.Print(“USB Mass Storage detected…”);
usbPS = new PersistentStorage(device);
usbPS.MountFileSystem();
}

and it threw an exception when trying to initalize the new PersistentStorage object using the ‘device’ var.


#6

Scratch that, for some reason it’s not detecting my WD passport drive as a Mass Storage device.


#7

You should be able to have both mounted at the same time.
You should only mount it if it’s a mass storage device. How many times does the DeviceConnected(USBH_Device device) gets triggered?