/// <summary> /// Functionality provided by mainboard to ummount storage devices, given the volume name of the storage device (see <see cref="GetStorageDeviceVolumeNames"/>). /// This should result in a <see cref="Microsoft.SPOT.IO.RemovableMedia.Eject"/> event if successful. /// </summary> public override bool UnmountStorageDevice(string volumeName) { _storage.UnmountFileSystem(); _storage.Dispose(); return(true); }
/// <summary> /// Functionality provided by mainboard to ummount storage devices, given the volume name of the storage device (see <see cref="GetStorageDeviceVolumeNames"/>). /// This should result in a Microsoft.SPOT.IO.RemovableMedia.Eject event if successful. /// </summary> public override bool UnmountStorageDevice(string volumeName) { // implement this if you support storage devices. This should result in a <see cref="Microsoft.SPOT.IO.RemovableMedia.Eject"/> event if successful and return true if the volumeName is supported. _storage.UnmountFileSystem(); _storage.Dispose(); return(true);// volumeName == "SD"; }
public void Dispose() { if (storageType == FileBrowser.StorageType.SD && storage != null) { storage.Dispose(); storage = null; } }
private static void SDMountThread() { const int POLL_TIME = 500; // check every 500 millisecond bool sdExists; while (true) { try // If SD card was removed while mounting, it may throw exceptions { sdExists = sdDetectPin.Read() == false; // make sure it is fully inserted and stable if (sdExists) { Thread.Sleep(50); sdExists = sdDetectPin.Read() == false; } if (sdExists && storage == null) { SetupStorage(); } else if (!sdExists && storage != null) { Trace.CloseTrace(); storage.UnmountFileSystem(); storage.Dispose(); storage = null; } } catch { if (storage != null) { storage.Dispose(); storage = null; } } Thread.Sleep(POLL_TIME); } }
void USBHostController_DeviceDisconnectedEvent(USBH_Device device) { if (device.TYPE == USBH_DeviceType.MassStorage && _usbStorages.Contains(device.ID)) { PersistentStorage usbStorage = (PersistentStorage)_usbStorages[device.ID]; usbStorage.UnmountFileSystem(); usbStorage.Dispose(); _usbStorages.Remove(device.ID); } }
private static void SDWatcher() { const int POLL_TIME = 500; // check every 500 millisecond bool exists; while (true) { try // If SD card was removed while mounting, it may throw exceptions { exists = PersistentStorage.DetectSDCard(); // make sure it is fully inserted and stable if (exists) { Thread.Sleep(50); exists = PersistentStorage.DetectSDCard(); } if (exists && sdCard == null) { sdCard = new PersistentStorage("SD"); sdCard.MountFileSystem(); } else if (!exists && sdCard != null) { sdCard.UnmountFileSystem(); sdCard.Dispose(); sdCard = null; } } catch { if (sdCard != null) { sdCard.Dispose(); sdCard = null; } } Thread.Sleep(POLL_TIME); } }
private void ReleaseCardStorage() { lock (this) { if (_cardStorage != null) { _cardStorage.UnmountFileSystem(); _cardStorage.Dispose(); _cardStorage = null; } } }
/// <summary> /// This method is called when a device is pulled out of the USB host. /// </summary> /// <param name="device">The device pulled out.</param> private static void DeviceDisconnected(USBH_Device device) { ps.UnmountFileSystem(); ps.Dispose(); ps = null; }
public static bool MountSD() { lastErrorMsg = ""; bool returnValue = false; if (PersistentStorage.DetectSDCard() == false) { lastErrorMsg = "SD Card not present."; } else { try { ps = new PersistentStorage("SD"); ps.MountFileSystem(); isMounted = true; returnValue = true; } catch (Exception e) { if (ps != null) { ps.Dispose(); ps = null; } lastErrorMsg = e.Message; } } return returnValue; }