Why does Windows not recognize my USB device as the same device if I plug it into a different port?

 因为USB设备描述符没有USB SERIAL NUMBER (USB SERIAL NUMBER 没起作用),导致USB设备换口时生成不同INSTANCE ID ,被当作是新的设备,而重新安装.

 

 

 

 

 You may have noticed that if you take a USB device and plug it into your computer, Windows recognizes it and configures it. Then if you unplug it and replug it into a different USB port, Windows gets a bout of amnesia and thinks that it's a completely different device instead of using the settings that applied when you plugged it in last time. Why is that?

The USB device people explained that this happens when the device lacks a USB serial number.

Serial numbers are optional on USB devices. If the device has one, then Windows recognizes the device no matter which USB port you plug it into. But if it doesn't have a serial number, then Windows treats each appearance on a different USB port as if it were a new device.

(I remember that one major manufacturer of USB devices didn't quite understand how serial numbers worked. They gave all of their devices serial numbers, that's great, but they all got the same serial number. Exciting things happened if you plugged two of their devices into a computer at the same time.)

But why does Windows treat it as a different device if it lacks a serial number and shows up on a different port? Why can't it just say, "Oh, there you are, over there on another port."

Because that creates random behavior once you plug in two such devices. Depending on the order in which the devices get enumerated by Plug and Play, the two sets of settings would get assigned seemingly randomly at each boot. Today the settings match up one way, but tomorrow when the devices are enumerated in the other order, the settings are swapped. (You get similarly baffling behavior if you plug in the devices in different order.)

In other words: Things suck because (1) things were already in bad shape—this would not have been a problem if the device had a proper serial number—and (2) once you're in this bad state, the alternative sucks more. The USB stack is just trying to make the best of a bad situation without making it any worse.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
What characters or bytes are valid in a USB serial number?

A USB device has two choices for storing serial numbers in the iSerialNumber field (in the USB device descriptor):

(1) iSerialNumber == 0x00 : The USB device has no serial number.
(2) iSerialNumber != 0x00 : The USB device has a serial number and it is stored at the string index indicated in iSerialNumber.

If the device has a serial number, Microsoft requires that the serial number uniquely identify each instance of the same device. For example, if two device descriptors have identical values for the idVendor, idProduct, and bcdDevice fields, the iSerialNumber field will distinguish one from the other.

Windows Plug and Play requires that serial numbers across multiple buses follow specified rules. Every byte in a USB serial number is checked for correctness. If a single invalid byte is found, the serial number is discarded and the device is treated as if it had no serial number.

Invalid bytes in serial numbers are indicated below:

(1) Byte values less than 0x20 are invalid.
(2) Byte values greater than 0x7F are invalid.
(3) Byte value 0x2C is invalid.

 

你可能感兴趣的:(windows,Microsoft,byte,Descriptor,behavior,Numbers)