USB驱动学习 ---- USB设备每换一个新口,就的重新安装驱动,正常吗?

    技术2023-03-29  81

    USB设备每换一个新口,就的重新安装驱动,正常吗?

    这种情况是因为 USB 设备没有 Serial Number(或Serial Number无效)。所以bus driver 就根据它的位置信息来生成 InstanceID。如果 USB device 指定了有效的 SerialNumber,则系统始终将该设备识别成同一个设备(Instance ID就是SerialNumber)。 参考文档: http://blogs.msdn.com/oldnewthing/archive/2004/11/10/255047.aspx 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.

    最新回复(0)