如何在 Windows XP 中为 USB 串行加密狗获得稳定的 COM 端口?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13741853/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get stable COM-ports for USB serial dongles in Windows XP?
提问by starblue
I develop embedded systems and need serial ports for communication.
我开发嵌入式系统,需要串口进行通信。
In Windows XP the numbers for USB serial port dongles keep moving around, which makes it hard to use in scripts or makefiles (for example for flash programming NXP controllers via their built-in bootloader, or for controlling a target and two lab devices at the same time).
在 Windows XP 中,USB 串行端口加密狗的数字不断变化,这使得它难以在脚本或 makefile 中使用(例如,通过其内置引导加载程序对 NXP 控制器进行闪存编程,或用于控制目标和两个实验室设备)同时)。
Is there a way to fix the COM-port for such a dongle? In Linux I can do this via udev by matching against the serial number of FTDI dongles (see this answer I just gavewhile searching for an answer to this question).
有没有办法修复这种加密狗的 COM 端口?在 Linux 中,我可以通过 udev 通过匹配 FTDI 加密狗的序列号来执行此操作(请参阅我刚刚在搜索此问题的答案时给出的答案)。
采纳答案by tomlogic
In my experience, plugging the device into the exact same USB port each time results in it getting the same COM port number.
根据我的经验,每次将设备插入完全相同的 USB 端口会导致它获得相同的 COM 端口号。
It's also possible to change the port number assigned to a device (Device Manager, edit Properties of the COM port) if you need to plug it into a different USB port. In the past I have labeled a device with a COM port number, and then plugged it into each USB port on my laptop and reassigned the COM port to be that number, regardless of where it's plugged in.
如果您需要将其插入不同的 USB 端口,也可以更改分配给设备的端口号(设备管理器,编辑 COM 端口的属性)。过去,我用 COM 端口号标记了一个设备,然后将其插入笔记本电脑上的每个 USB 端口,并将 COM 端口重新分配为该编号,无论它插入何处。
回答by djs
The FTDI driver will assign serial ports to the same COM ports by the serial number of the device connected. So, the ports should remain the same regardless of USB port. However, if you plug in a new USB device, it will not reuse the previously assigned COM ports.
FTDI 驱动程序将通过所连接设备的序列号将串行端口分配给相同的 COM 端口。因此,无论 USB 端口如何,端口都应保持不变。但是,如果您插入新的 USB 设备,它将不会重复使用之前分配的 COM 端口。
FTDI has an app noteexplaining the process in more detail.
FTDI 有一个应用说明,更详细地解释了这个过程。
I've had general stability problems with Prolific drivers, so I do not use Prolific USB-to-serial devices and can't comment on their mapping strategy.
我在使用 Prolific 驱动程序时遇到了一般稳定性问题,因此我不使用 Prolific USB 转串口设备,因此无法评论它们的映射策略。
回答by Jimadine
Use ComPortManto bind COM port numbers to devices. Taken from the Help page, here's an example ComPortMan.INI
:
使用ComPortMan将 COM 端口号绑定到设备。取自帮助页面,这是一个示例ComPortMan.INI
:
[ComPorts10]
DeviceID=USB\VID_067B&PID_2517
PortName=COM5
[ComPorts20]
DeviceID=USB\VID_1234&PID_5678
PortName=COM6
Note: I've found that sometimes a *
needs to be appended to the Device ID for this to work.
注意:我发现有时*
需要将a附加到设备 ID 才能使其工作。
回答by John U
The FTDI config tool can, I believe, set fixed COM port numbers and rename devices to show up as being "Your product name", which makes it easier to find the device programmatically if it does move around (you're not just looking for COM ports).
我相信 FTDI 配置工具可以设置固定的 COM 端口号并重命名设备以显示为“您的产品名称”,如果它确实四处移动,则可以更轻松地以编程方式找到设备(您不仅仅是在寻找COM 端口)。
回答by James Chong
for XP
对于 XP
tag the usb port for the usb/com device or visa versa. or put the usb/com device into all usb port one by one, set same setting, so plug into any usb port will get the same.
标记 USB/com 设备的 USB 端口,反之亦然。或者把usb/com设备一一插入所有的usb口,设置相同的设置,这样插入任何一个usb口都是一样的。
beware!
谨防!
advance port setting in hardware device manager for usb will not same as mode status (run cmd, mode) if the setting show or none in the mode status
如果设置在模式状态中显示或无,则 USB 硬件设备管理器中的高级端口设置将与模式状态(运行 cmd、模式)不同
the real 9/25 pins serial port will not show in the mode status, only those USB2serial will be, if got the right setting. if it didn't show up or not show the right speed as for printer will print funny letters, etc.
真正的 9/25 针串口不会在模式状态下显示,只有那些 USB2serial 才会显示,如果设置正确。如果它没有出现或没有显示正确的速度,因为打印机会打印有趣的字母等。
if mode status not match with the device manager setting especially the bauds rate, then device not function. unless your custom software can set the comport in advance before communicating.
如果模式状态与设备管理器设置特别是波特率不匹配,则设备无法运行。除非你的自定义软件可以在通信之前提前设置好comport。
another issue: if have multiple usb2serial even same driver can malfunction because they share the same ser2pl.sys
另一个问题:如果有多个 usb2serial,即使相同的驱动程序也可能发生故障,因为它们共享相同的 ser2pl.sys
using mode to test the usb2serial device: using mode set the com? to hardware or XonXoff, if it show none or it cann't be set, then this device's driver BUGs or device is part faulty. It still work on NONE detection condition,.. that fine if you do not need any detection of the hardware. example: check is the printer online for print, NONE will not provide the offline status,..
using mode to test the usb2serial device: using mode set the com? 对于硬件或XonXoff,如果显示none或无法设置,则该设备的驱动程序BUG或设备部分故障。它仍然适用于 NONE 检测条件,如果您不需要任何硬件检测,那很好。例如:检查打印机是否在线进行打印,NONE 将不提供离线状态,..
for save, I am now only use 1 usb2serial device and get motherboard with 2 onboard or add on serial card for serial port,...
为了节省,我现在只使用 1 个 usb2serial 设备并获得带有 2 个板载的主板或添加用于串口的串口卡,...
not to mention of Pl2303 usb,.. ca-42 & dku-5, have them all for last 3 months each of it can only use on different version of driver,.. most new PC only has USB ports,.. so I found 1 ca-42(com1) for cell phone & 1 usb2serial(com2) for printer. I have facing so much problems. tried use 1 pl2303 & 1 CH340 (different drive) problem too because of the ser2pl.sys look as it not share by 2.
更不用说 Pl2303 usb、.. ca-42 和 dku-5,过去 3 个月都拥有它们,每个都只能在不同版本的驱动程序上使用,.. 大多数新 PC 只有 USB 端口,.. 所以我找到 1 个用于手机的 ca-42(com1) 和 1 个用于打印机的 usb2serial(com2)。我遇到了很多问题。也尝试使用 1 pl2303 和 1 CH340(不同驱动器)问题,因为 ser2pl.sys 看起来没有被 2 共享。
currently, on hand using onboard com1 for printer & usb pl2303 ca-42(com2) for cell phone, so far so good, no problem yet. cross my fingers.
目前,手头上使用板载 com1 打印机和 usb pl2303 ca-42(com2) 手机,到目前为止一切顺利,还没有问题。交叉我的手指。
cheers.
干杯。
回答by hamish
Every FTDI device has a serial number.. in your software, when enumerating (looping) through the available FTDI devices.. yes you can have many multiple FTDI devices plugged in at once.. ask the user to select the approp. device. and save and restore the serial number each time you loop through the available devices..
每个 FTDI 设备都有一个序列号.. 在您的软件中,当枚举(循环)可用的 FTDI 设备时.. 是的,您可以一次插入多个多个 FTDI 设备.. 要求用户选择合适的。设备。并在每次循环访问可用设备时保存和恢复序列号。
回答by sgiebels
Use "FT_INF 2.0.61.242 - Custom INF File Generator" and set "Initial Index" to the first COM port number to be assigned (e.g. 32). Then install the FTDI driver using the newly generated .inf (might require .cat file self-signing)
使用“FT_INF 2.0.61.242 - 自定义 INF 文件生成器”并将“初始索引”设置为要分配的第一个 COM 端口号(例如 32)。然后使用新生成的 .inf 安装 FTDI 驱动程序(可能需要 .cat 文件自签名)
or edit ftdiport.inf: [FtdiPort.NT.AddService.AddReg] HKR,"Parameters\VID_0403&PID_6001","InitialIndex",0x00010001,32
或编辑 ftdiport.inf: [FtdiPort.NT.AddService.AddReg] HKR,"Parameters\VID_0403&PID_6001","InitialIndex",0x00010001,32
回答by Ranmairs
As described in the FTDI following Application Note, edit the Registry and create a REG_BINARY value set to 0x01 as follow:
如FTDI 以下应用说明中所述,编辑注册表并创建一个 REG_BINARY 值设置为 0x01,如下所示:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\UsbFlags\IgnoreHWSerNum{De vice VID, PID and interface}
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\UsbFlags\IgnoreHWSerNum{设备 VID、PID 和接口}
For example:
例如:
IgnoreHWSerNum04030300
忽略HWSerNum04030300
Will ignore the serial number of all USB devices with VID 0403 and PID 0300. All these devices will acquires the same driver and the same COM Port
将忽略所有具有 VID 0403 和 PID 0300 的 USB 设备的序列号。所有这些设备将获得相同的驱动程序和相同的 COM 端口