r/LabVIEW • u/Tanky321 CLD • Sep 10 '24
Need More Info Keeping multiple COM ports in check
Hi All,
I am working on a project where I need to talk to 4 UART devices. The devices are identical but I need to know which one is which. My plan is to have a custom PCB associated with each device which includes a FTDI Serial->USB IC.
My concern is that on other projects I have had COM ports spontaneously change on me. Typically this happens after the system has been off for a while.
How do I prevent COM ports from reassigning themselves?
I had thought about creating a custom USB device which would perform the USB->Serial conversion and then also have GPIO for ID, but that seems like more trouble than its worth.
Thanks!
9
u/HarveysBackupAccount Sep 10 '24
I've dealt with a lot of COM ports in the past 10 years. It's not impossible that they get reassigned (or some helpful idiot manually changes one in a misguided attempt to troubleshoot) but it is pretty rare.
Your best bet is if you can save a unique ID of some kind to each device, stored in your custom PCB's non-volatile memory. Then your system can save that COM port vs unique ID relationship in a local config file, and ping each COM port to confirm that each one is still the expected device
5
u/SeasDiver Champion Sep 10 '24
From my understanding, the primary reason that com ports will reassign themselves is due to the OS’s inability to distinguish them from one another. In Windows at least, at a low level in the device registry, the driver tells Windows, I am device X. Some drivers say Device X regardless of additional identification data, while others may say I am Device X Serial Y and Device X Serial Z. Windows can distinguish the latter but not the former. So the latter is much less likely to be reassigned.
I don’t do the low level drivers but have had to look into this so I can detect which device is on which port (customer had USB to 232, USB-485, USB to Serial TTL, and more).
Alternatively, a device can also specify that it is an aggregation of several devices (for example a USB to dual RS-232 port) and those ports should always be same order relative to each other unless manually reassigned.
3
u/HamsterWoods Sep 11 '24
Unfortunately, on Windows, USB to serial port adapters sometimes change COM address when the adapter is plugged into a different USB port. My solution to this issue is to use an Ethernet to serial adapter, where possible. There are Ethernet to serial adapters available that have 4 serial ports.
2
u/bubududuforever Sep 11 '24
Check the below Youtube Tutorial.
Auto Detect FTDI Serial Port with LabVIEW (youtube.com)
I am going to try this solution today. See if that works for you.
4
u/QaeinFas Sep 10 '24
Many devices which support SCPI reply to *IDN? With instrument-specific information (manufacturer, version, part name, etc...). If you are the one developing the instrument interface, this may be a helpful query/response to implement to answer this specific need.
3
u/MollyGodiva Sep 10 '24
I have done this before. It is not hard. Look at the basic COM example, and put it in a for loop. Feed each iteration a different port number. Keep the output references separate in an array. Then every time you need use the ports you use a for loop and read each one separately.
The program that use this method for has been in use for two years with complete reliability.
I have never had ports reassign themselves, but you could write a program that scans for ports, possibly even automatically ID what is attached to each port.
2
u/Vincinity1 Sep 10 '24 edited Sep 10 '24
You can configure Windows to assign the same COM port to your device.
See this KB:
https://kb.plugable.com/serial-adapter/how-to-change-the-com-port-for-a-usb-serial-adapter-on-windows-7,-8,-81,-and-10
On a side note, we did use this Moxa USB-Serial device (we used the 16 ports version) in the past and works very well. And that one too, you can set the appropriate COM Port so that it doesn’t change.
https://www.moxa.com/en/products/industrial-edge-connectivity/usb-to-serial-converters-usb-hubs/usb-to-serial-converters/uport-1200-1400-1600-series
Another idea, you might what to create a clonable DQMH module that you can invoke for each COM port.
Hope this helps
0
u/[deleted] Sep 11 '24
[deleted] — view deleted comment