سؤال

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

هل كانت مفيدة؟

المحلول 2

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.

نصائح أخرى

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.

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.

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

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.

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

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

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top