LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

determining which COM port is the "right one"

I have an LV application that works using a built-in COM port on the PC.  Customer wants me to change to a USB-to-RS485 converter.  I installed the Windows driver for the converter, then plugged the converter into USB port on the PC.  Windows and MAX both see the new port.  What I'm not sure of is the best way to have the LV app find the converter.  This application will be used on a variety of PCs so the COM port will be likely to change from PC to PC.  Or even on the same PC, sometimes another USB device might get plugged in before the converter.

So the question is this:  The converter will always have the same vendor ID.  Is there a way for LabVIEW to look at the USB devices and pick the one with the correct ID ?  Or maybe this is overkill... the Windows driver makes the converter look like a serial port (COM4 on my PC).  The original app that worked with com1 used the VISA Configure Serial function with ASRL1:INSTR. 

I can modify the LV app to force the user to pick from the available COM ports, but would prefer to make this happen automatically.

Any suggestions ?

0 Kudos
Message 1 of 5
(3,885 Views)

Typically, USB & Ethernet to Serial devices appear as normal serial port within windows and within MAX.  It will assign a serial port id (COM3, COM4, etc).  When this happens, you can use a program like Hyperterminal and access the new ports as you would with the regular COM port.

Same is true for LabVIEW.  It will use the port as it would use any regular port.  So what you could do is to detect valid ports.  There should be examples of how this is done within the forum.  If you can communicate with the target devices and do a query, then you may be able to assign which port(s) the target(s) is connected to.  And to keep it that simple.

R

Message 2 of 5
(3,881 Views)
Here's the code that I used to find the COM port number of my USB to RS232 converter.
My instrument name came up as "USB Serial Port", yours might be different.


_______________________________________
Systems Test Engineer
Certified LabVIEW Architect (CLA)
Message 3 of 5
(3,862 Views)
Thanx karissa for sharing the code. Very useful way  to get the port number(by seeing it).Wil run and give you the feedback
0 Kudos
Message 4 of 5
(3,826 Views)

Wow - your VI worked for me "right out of the box".

Thanks for the info.

Rick

0 Kudos
Message 5 of 5
(3,824 Views)