How to get stable COM-ports for USB serial dongles in Windows XP?
Asked Answered
H

8

10

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).

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 gave while searching for an answer to this question).

Haymow answered 6/12, 2012 at 10:40 Comment(2)
This is entirely the responsibility of the driver for the USB device, it picks the port names when it creates them. Some of them add a property page to the Device Manager property sheet let you pick a number but that's not widely implemented. What you've got left is an WMI query for Win32_SerialPort, not ideal either.Lenna
As tomlogic mentioned, the easy solution is to plug your devices into a fixed port or hub, then they won't change. However, on windows you can still dynamically do the detection, you just have to look in the registry instead of udev. You will find your device info including COM port under SYSTEM\CurrentControlSet\Enum\FTDIBUSWellintentioned
T
8

In my experience, plugging the device into the exact same USB port each time results in it getting the same COM port number.

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.

Tolbooth answered 6/12, 2012 at 18:1 Comment(1)
Thanks. The setting under Ports -> USB Serial Port -> Properties -> Port Settings -> Advanced did the trick quite conveniently, I wonder why I didn't find it myself (in german it is Anschlüsse -> USB Serial Port -> Eigenschaften -> Anschlusseinstellungen -> Erweitert).Haymow
O
13

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 has an app note explaining the process in more detail.

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.

Officialese answered 8/12, 2012 at 6:39 Comment(1)
I can confirm the same, FTDI works stable for a long time, but Prolific are unstable and causes also bluescreens and the drivers are a nightmareMisfile
T
8

In my experience, plugging the device into the exact same USB port each time results in it getting the same COM port number.

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.

Tolbooth answered 6/12, 2012 at 18:1 Comment(1)
Thanks. The setting under Ports -> USB Serial Port -> Properties -> Port Settings -> Advanced did the trick quite conveniently, I wonder why I didn't find it myself (in german it is Anschlüsse -> USB Serial Port -> Eigenschaften -> Anschlusseinstellungen -> Erweitert).Haymow
E
3

Use ComPortMan to bind COM port numbers to devices. Taken from the Help page, here's an example 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.

Estrella answered 24/3, 2018 at 10:59 Comment(0)
S
1

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).

Scramble answered 6/12, 2012 at 13:26 Comment(0)
A
1

for 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.

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

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.

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.

another issue: if have multiple usb2serial even same driver can malfunction because they share the same 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,..

for save, I am now only use 1 usb2serial device and get motherboard with 2 onboard or add on serial card for serial port,...

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.

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.

cheers.

Ashil answered 5/9, 2013 at 4:35 Comment(0)
U
1

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..

Undernourished answered 7/7, 2014 at 8:6 Comment(0)
P
0

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)

or edit ftdiport.inf: [FtdiPort.NT.AddService.AddReg] HKR,"Parameters\VID_0403&PID_6001","InitialIndex",0x00010001,32

Puttier answered 13/9, 2016 at 10:11 Comment(0)
L
0

As described in the FTDI following Application Note, edit the Registry and create a REG_BINARY value set to 0x01 as follow:

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

For example:

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

Lipo answered 19/4, 2017 at 11:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.