Main Site Documentation

Long Delays in Windows Allowing Access to SD Card


#1

A problem I have in getting a clean customer interface because of long delays in switching between mass storage and CDC VCOM.

The guides and many posts in this forum refer to the ease with which you can switch between mass storage and CDC VCOM when needed. When I implement one of the code examples provided I find that there is a long delay in windows allowing access to the files on the mass storage device.

When the USB is plugged in the mass storage device quickly shows up in Device Manager along with a generic volume, but it takes upwards of 30 seconds or more for an explorer window to pop up allowing actual access to the files.

If I try to shorten this delay by starting explorer window to open one of the files on the SD card, explorer crashes. However if I wait for the Windows popup, I can get at the files just fine.

The complete full code I’m using is in this thread http://www.tinyclr.com/forum/2/3265/ , but essentially I’m using one of the code examples described in the GHI .NET reference http://www.ghielectronics.com/downloads/NETMF/Library%20Documentation/html/54b37f26-0981-f721-57fe-1cefaf27a246.htm Specifically this example:

// Start MS
            USBC_MassStorage ms = USBClientController.StandardDevices.StartMassStorage();

            // Assume SD card is connected
            PersistentStorage sd;
            try
            {
                sd = new PersistentStorage("SD");
            }
            catch
            {
                throw new Exception("SD card not detected");
            }
            ms.AttachLun(0, sd, " ", " ");


            // enable host access 
            ms.EnableLun(0);

            Thread.Sleep(Timeout.Infinite);

Should I be using one of the other examples for accessing and switching between the CDC options? Thanks for any suggestions.


#2

If you try our exmaple as-is, is it faster?
format the sd card and then try, is it faster?
put one file in it, does it slow down?


#3

OK, Mike I tried what you said and here are the results. For the record I’m using both Dominos and Panda II’s to test this, I’ve tried it on both Windows 7 and XP, and I did a long (not quick) reformat on the SanDisk 4G SD card. The exact code used is from the GHI Persistant Storage Class page and is posted at the end of this note. I also tried it with a PNY card. Thanks for any help you can give.

In short the problem is still there and is even a bit worse in that it may take several plug ins before the board is recognized. When it is recognized it takes about 10 seconds for mass storage to show up in device manager, and about 30 to 60 seconds for an explorer window to pop up listing the disk and files. If I try to open a separate explorer window before this popup and open a file the window crashes.

I also tried a PNY 4G blank formatted card with the same results. Here is the code as taken from

http://www.ghielectronics.com/downloads/NETMF/Library%20Documentation/html/54b37f26-0981-f721-57fe-1cefaf27a246.htm

using System;
using System.Threading;

using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.IO;

using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.USBClient;
using GHIElectronics.NETMF.IO;
using GHIElectronics.NETMF.Hardware;

namespace D_PS_GHI_MSsimple
{
    public class Program
    {
        public static void Main()
        {
            // Check debug interface
            if (Configuration.DebugInterface.GetCurrent() == Configuration.DebugInterface.Port.USB1)
                throw new InvalidOperationException("Current debug interface is USB. It must be changed to something else before proceeding. Refer to your platform user manual to change the debug interface.");
            // Start MS
            USBC_MassStorage ms = USBClientController.StandardDevices.StartMassStorage();
            // Assume SD card is connected
            PersistentStorage sd;
            try
            {
                sd = new PersistentStorage("SD");
            }
            catch
            {
                throw new Exception("SD card not detected");
            }
            ms.AttachLun(0, sd, " ", " ");
            // enable host access 
            ms.EnableLun(0);
            Thread.Sleep(Timeout.Infinite);
        }
    }
}