简体   繁体   English

如何在Windows XP中获得USB串口加密狗的稳定COM端口?

[英]How to get stable COM-ports for USB serial dongles in Windows XP?

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? 有没有办法修复这种加密狗的COM端口? In Linux I can do this via udev by matching against the serial number of FTDI dongles (see this answer I just gave while searching for an answer to this question). 在Linux中,我可以通过匹配FTDI加密狗的序列号来通过udev完成此操作(请参阅在搜索此问题的答案时给出的答案)。

The FTDI driver will assign serial ports to the same COM ports by the serial number of the device connected. FTDI驱动程序将通过所连接设备的序列号将串行端口分配给相同的COM端口。 So, the ports should remain the same regardless of USB port. 因此,无论USB端口如何,端口都应保持不变。 However, if you plug in a new USB device, it will not reuse the previously assigned COM ports. 但是,如果您插入新的USB设备,它将不会重复使用以前分配的COM端口。

FTDI has an app note explaining 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转串口设备,也无法对其映射策略发表评论。

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. 如果需要将其插入另一个USB端口,也可以更改分配给设备的端口号(设备管理器,编辑COM端口的属性)。 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. 在过去,我已经标记了一个带有COM端口号的设备,然后将其插入笔记本电脑上的每个USB端口,并将COM端口重新分配为该号码,无论它插在何处。

Use ComPortMan to bind COM port numbers to devices. 使用ComPortMan将COM端口号绑定到设备。 Taken from the Help page , here's an example ComPortMan.INI : 摘自“ 帮助”页面 ,这是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. 注意:我发现有时需要将*附加到设备ID才能使其正常工作。

我相信,FTDI配置工具可以设置固定的COM端口号并重命名设备以显示为“您的产品名称”,这样可以更容易地以编程方式找到设备(如果它确实移动)(您不仅仅是在寻找COM端口)。

for XP 对于XP

tag the usb port for the usb/com device or visa versa. 标记usb / com设备的usb端口,反之亦然。 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端口都会得到相同的。

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. 如果设置正确,真正的9/25引脚串口将不会显示在模式状态,只有那些USB2串口。 if it didn't show up or not show the right speed as for printer will print funny letters, etc. 如果它没有显示或没有显示正确的速度,打印机将打印有趣的字母等。

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? 使用模式测试usb2serial设备:使用模式设置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. 对于硬件或XonXoff,如果它没有显示或者无法设置,则该设备的驱动程序BUG或设备是部分故障。 It still work on NONE detection condition,.. that fine if you do not need any detection of the hardware. 它仍然适用于NONE检测条件,如果您不需要任何硬件检测,那就没问题了。 example: check is the printer online for print, NONE will not provide the offline status,.. 例如:检查打印机是否在线打印,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. 更不用说Pl2303 usb,... ca-42&dku-5,最近3个月都有它们每个只能用于不同版本的驱动程序,...大多数新PC只有USB端口,所以我找到1 ca-42(com1)用于手机和1 usb2serial(com2)用于打印机。 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. 尝试使用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. 目前,手头使用板载com1用于打印机&usb pl2303 ca-42(com2)用于手机,到目前为止一直这么好,还没有问题。 cross my fingers. 交叉我的手指。

cheers. 干杯。

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. 每个FTDI设备都有一个序列号..在您的软件中,通过可用的FTDI设备枚举(循环)..是的,您可以同时插入多个多个FTDI设备..请用户选择approp。 device. 设备。 and save and restore the serial number each time you loop through the available devices.. 每次循环可用设备时保存并恢复序列号..

Use "FT_INF 2.0.61.242 - Custom INF File Generator" and set "Initial Index" to the first COM port number to be assigned (eg 32). 使用“FT_INF 2.0.61.242 - 自定义INF文件生成器”并将“初始索引”设置为要分配的第一个COM端口号(例如32)。 Then install the FTDI driver using the newly generated .inf (might require .cat file self-signing) 然后使用新生成的.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

As described in the FTDI following Application Note , edit the Registry and create a REG_BINARY value set to 0x01 as follow: 应用说明中的FTDI所述,编辑注册表并创建一个设置为0x01的REG_BINARY值,如下所示:

HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\UsbFlags\\IgnoreHWSerNum{De vice VID, PID and interface} HKEY_LOCAL_MACHINE \\ SYSTEM \\ CurrentControlSet \\ Control \\ UsbFlags \\ IgnoreHWSerNum {De vice VID,PID and interface}

For example: 例如:

IgnoreHWSerNum04030300 IgnoreHWSerNum04030300

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端口

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM