USB Device Problems

USB connection
USB drive
USB ports
Can someone please explain to me, from a developers point of view, how a device is recognized when connected via USB?  Is the o/s constantly scanning or does the device provide some sort of output to tell the port that its active?

Software/Hardware used:
USB, Universal Serial Bus Device

Answer Wiki

Thanks. We'll let you know when a new response is added.

<b>Taken from</b>

The USB bus is physically designed so that the act of inserting (and removing) a plug can be recognized by the host controller. When this “plug” event happens, the host controller informs its device driver which scans the bus and asks each device to identify itself.

All USB devices contain a collection of information about the device, called the descriptors. Device descriptors are retrieved from all devices with the same command. This allows a device driver for the USB bus itself to effectively ask a newly connected device what it is, and expect to get a reasonable response.

Of all the descriptors, only a few are directly used to match drivers to most devices. This is because USB defines classes of devices, and usually the system driver for each device class is sufficient to handle any devices that claim to be in that class.

All keyboards will claim to be in the HID (Human Interface) class, as will mice, tablets, and game controllers, for example. The HID class has several subclasses (keyboards, mice, etc.), so each gets handled in the expected way.

Most disk-like devices will claim to be in the Mass Storage class, and the system driver just works for those as well.

In addition to the class and subclass, the descriptors also include a vendor ID (VID), product ID (PID), and revision. The vendor IDs are assigned by the standards committee (mostly in order of issue but some companies got special requests: intel is 0x8086, for example). Product IDs are assigned by each vendor, and the combination of VID and PID must be unique to each released product.

When a device is first installed, the VID, PID, revision, class and subclass are used in a predictable way to choose the device driver that is loaded. Having vendor and product specific names makes it possible for a vendor to customize a device that might otherwise be handled (nearly) correctly by the stock system driver.

Another important descriptor is the device serial number. If a device has a serial number, then it can be recognized and treated the same when plugged in again even if a different physical USB port is used. This is important for storage devices so that they get the same drive letter assigned, and for devices like serial port adapters and modems so that they are given the same COM port designation.

This whole process is documented at MSDN, but the details are spread out among a variety of places.

Discuss This Question: 2  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Gabe9527
    and for more information
    11,095 pointsBadges:
  • LinuxCiscoman
    Thanks Gabe. I'm actually working with a proprietary device that, when connected to a Win PC, presents itself as both as a usb device and a usb network interface. After a software update, the device is no longer recognized by Windows. This device has a recovery mode which appears to be working correctly but Windows no longer recognizes it upon connection. Any ideas? This device does have a bios which i would imagine contains basic information like serial number etc.
    860 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: