Unable to Detect USB

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...");
    }

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 [url]http://www.fezzer.com/project/164/usb-discovery-helper/[/url].

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

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.

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 ?

Maybe you have insufficient power. Try a power pack.

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.

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