Windows USB question

Some times we want to use a USB port, often through an FTDI serial converter chip, to talk to a device or to a test set. Under Windows, the COMn port seems to come up with random n.

Sometimes we write a program to scan all the comm ports, looking for our target device. That can be messy.

Does anyone know of a way to reserve or nail a USB com port? Apparently that is not a problem with Linux.

--

John Larkin         Highland Technology, Inc 
picosecond timing   precision measurement  

jlarkin att highlandtechnology dott com 
http://www.highlandtechnology.com
Reply to
John Larkin
Loading thread data ...

Den mandag den 13. november 2017 kl. 19.43.51 UTC+1 skrev John Larkin:

formatting link

Reply to
Lasse Langwadt Christensen

No, my experience (with FTDI and windows) is the same as yours. Some random number and I have to find/config the port each time.

George h.

Reply to
George Herold

John, this doesn't answer your question, but scanning the attached port dev ices is not ridiculously messy. I wrote some code that uses the Windows Set upAPI to scan the Ports Device Class, find the desired device by matching t o desired friendly name, then extract the COM port number; a few dozen line s of C code. I can send you the code if you're interested.

With best regards,

MKE

Reply to
Michael Elwood

The code's not that hard, but we plug and unplug cables during tests, and we may get comm errors, so all sorts of locations in a program may have to re-scan the ports. And we may test multiple units, so it would be nice if we knew which unit a physical USB cable connects to.

--

John Larkin         Highland Technology, Inc 
picosecond timing   precision measurement  

jlarkin att highlandtechnology dott com 
http://www.highlandtechnology.com
Reply to
John Larkin

Den mandag den 13. november 2017 kl. 21.51.33 UTC+1 skrev John Larkin:

devices is not ridiculously messy. I wrote some code that uses the Windows SetupAPI to scan the Ports Device Class, find the desired device by matchin g to desired friendly name, then extract the COM port number; a few dozen l ines of C code. I can send you the code if you're interested.

the same ftdi cable should get the same com port number every time you plug it in, it should be based on serial number

Reply to
Lasse Langwadt Christensen

In windows you can get the vender of the comport as you enumerate the test ports..

You can also get basic info by query of the Register.. Each time you plug in the device it appears in the COM and LPT port key. That key will give you info about it.

Btw.. If you use the file method to scan the ports you need to use the "\\.\\" at the start f the name to get ports above 9 etc.

Reply to
M Philbrook

Damn, Windows is a mess.

--

John Larkin         Highland Technology, Inc 
picosecond timing   precision measurement  

jlarkin att highlandtechnology dott com 
http://www.highlandtechnology.com
Reply to
John Larkin

FTDI have a whole host of useful 'fix it' tools for their com port devises...

--
This email has been checked for viruses by Avast antivirus software. 
https://www.avast.com/antivirus
Reply to
TTman

ces is not ridiculously messy. I wrote some code that uses the Windows SetupAPI to scan the Ports Device Class, find the desired device by matching to desired f riendly name, then extract the COM port number; a few dozen lines of C code. I c an send you the code if you're interested.

Indeed. It's all there in the app note that you kindly posted earlier. Several hacks are available that enable users to exercise some control over FTDI's enumeration behavior.

Thank you,

--
Don Kuenz, KB7RPU
Reply to
Don Kuenz

I took one USB-serial adapter and plugged it into all open ports on my PC and its USB hub, one at a time. It started at COM3 and worked its way up one count at a time, independent of where it was plugged, but in time order of plugging in. If I unplugged it, the COMn port disappeared from the device manager. If I then plugged it into any open port, it came up as the com number that it was when I first plugged it in there. A physical USB port was bound to a com number by my plugging-in sequence. I don't now if that binding will survive a reboot... I'll try that.

The first plug-in event created COM3, and I made it up to COM10.

COM10 has to be opened in a program as device "\\.\COM10"

--

John Larkin         Highland Technology, Inc 

lunatic fringe electronics
Reply to
John Larkin

The one FTDI device plugged into the /same/ USB port on the PC will get the same COM number each time. Plug it into a different physical port (or hub), and it can get a different COM number. If this is on a test machine and you use the same FTDI devices each time, some labelling should help get the same devices in the same ports each time. Alternatively, glue is quite a good solution.

There are a couple of ways around this. FTDI had an extra "secret" driver configuration setting that fixes the COM number based on the physical port number. This is designed for production and testing when the cards being produced have FTDI chips. I don't know if this still works on current Windows.

Another way is to forget the COM port drivers. Use the FTDI dll's and their specific functions. They let you easily check for all FTDI devices attached to the PC, and identify them based on device serial number and/or physical port. Then you can open the devices and read and write to them much like a COM port.

Yes, Linux is /massively/ easier in this way. I have a USB hub stuck to my desk, plugged into my Linux machine. When I put an FTDI device into port X on the hub, I have a serial port /dev/ttySerial_X. If the device has two UARTs, I get /dev/ttySerial_X1 and /dev/ttySerial_X2. You can set things up as you want - it's just a couple of lines of udev configuration file.

Reply to
David Brown

My favorite OS, FreeBSD, probably does likewise. The only problem is that most people don't use FreeBSD nor Linux. Most people use some version of Windows. My onsite kit includes an ancient Windows Vista tablet "beater" with a FTDI RS-232 dongle. The dongle perpetually vacillates between COM1 and COM5 whenever it's plugged in. Sleuthing out the latest COM port's more of a nuisance than anything. This thread, along with FTDI Application Note 123, helps me to understand why the vacillations occur. This thread also enhances my appreciation as to the many permutations that a vendor must foresee and accommodate in order to keep USB as seamless as possible for the masses.

Thank you,

--
Don Kuenz, KB7RPU
Reply to
Don Kuenz

I are not a programmist, so I can't answer your question. However, methinks you might find a USB Device View program useful. My XP desktop machine shows 342 USB devices. Perhaps it's time for a cleanup.

--
Jeff Liebermann     jeffl@cruzio.com 
150 Felker St #D    http://www.LearnByDestroying.com 
Santa Cruz CA 95060 http://802.11junk.com 
Skype: JeffLiebermann     AE6KS    831-336-2558
Reply to
Jeff Liebermann

It is not random. It is simply the next available one.

Windows does reserve port numbers for USB devices, but only if the device has a serial number. Windows will remember which serial number has which COM port and assign the same port number to the same device, regardless of which port you plug it in to, or which order you plug them in.

Some USB devices do not have a serial number. In this case, Windows will assign a new port number if you plug the device into a new USB port.

If I remember right, the FT232 does not come with a preprogrammed serial number, while the FT232R does.

If you want to see the assigned COM ports that are not currently in use, and get a chance to delete them (to reclaim the "lost" port numbers), try this:

formatting link

--
RoRo
Reply to
Robert Roland
[snip]

Nice! I only had 20 devices, but one was for a device that was uninstalled a few years ago... didn't work under Win7. So I deleted that port. ...Jim Thompson

-- | James E.Thompson | mens | | Analog Innovations | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | STV, Queen Creek, AZ 85142 Skype: skypeanalog | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at

formatting link
| 1962 | It's what you learn, after you know it all, that counts.

Reply to
Jim Thompson

Read that app note. I think they do that in the absence of an embedded FTDI serial number (e.g. if you reprogram it with your own identifier).

--

John Devereux
Reply to
John Devereux

Once you plug in the serial device and the drivers are installed you can manually change the serial port number in the driver settings and that number will be used any time that type of device is used in that USB port in the future. You will either need to be consistent about the USB port used or you need to go through this procedure with every new USB port you use. No worries!

--

Rick C 

Viewed the eclipse at Wintercrest Farms, 
on the centerline of totality since 1998
Reply to
rickman

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.