Main Site Documentation

Unable to Detect USB


#1

I am using the code below, I was hoping to get the events but nothing happended. Any thing I am doing wrong?


public static void Main()
{
    // Subscribe to RemovableMedia events
    RemovableMedia.Insert += RemovableMedia_Insert;
    RemovableMedia.Eject += RemovableMedia_Eject;
    // Subscribe to USB events
    USBHostController.DeviceConnectedEvent += DeviceConnectedEvent;
    // Sleep forever
    Thread.Sleep(Timeout.Infinite);
}
    static void DeviceConnectedEvent(USBH_Device device)
    {
        if (device.TYPE == USBH_DeviceType.MassStorage)
        {
            Debug.Print("USB Mass Storage detected...");
            //....
            //....
        }
    }

    static void RemovableMedia_Insert (
     Object sender,
     MediaEventArgs e)
    {
         Debug.Print("USB Mass Storage Inserted...");
    }

    static void RemovableMedia_Eject(
     Object sender,
     MediaEventArgs e)
    {
         Debug.Print("USB Mass Storage Ejected...");
    }


#2

What events do get fired? What of your debug statements actually get registered?

there’s a great helper code out on Fezzer for this - Mark’s USB Discovery Helper http://www.fezzer.com/project/164/usb-discovery-helper/.

That will tell you the device type and class of device when you connect something.


#3

Thanks Brett!!

Some how 4 GB USB did not work, when I plugged 2 GB, it was detected.
I was also able to detect mouse, keyboard and ipod.

Thanks for your help.


#4

there’s nothing special about 4gb capacity as far as I know. It is more likely that specific device is implementing something “special”. Did it report anything from the handler when it connected ?


#5

Maybe you have insufficient power. Try a power pack.


#6

I have test out the USB Mass Storage capability with a 4G and 8G stick, they works flawlessly. My board do not need extra power just regular USB cable.


#7

Your 4G stick draws maybe 20mA… a modem draws 200mA or more!