Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <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";
        }
Esempio n. 3
0
 public void Dispose()
 {
     if (storageType == FileBrowser.StorageType.SD && storage != null)
     {
         storage.Dispose();
         storage = null;
     }
 }
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
0
 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);
     }
 }
Esempio n. 6
0
        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);
            }
        }
Esempio n. 7
0
 private void ReleaseCardStorage()
 {
     lock (this)
     {
         if (_cardStorage != null)
         {
             _cardStorage.UnmountFileSystem();
             _cardStorage.Dispose();
             _cardStorage = null;
         }
     }
 }
Esempio n. 8
0
 /// <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;
 }
Esempio n. 9
0
        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;
        }