LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically determine and select VISA COM Port Binding

Solved!
Go to solution

Hi all,

 

I'm working on an application whereby a user runs an automated test on a device, by comparing values from a reference (sensor) and the DUT. Both the reference and DUT communicate serially via USB Serial Port.

 

When the user clicks on "Connect", I want the program to automatically select the VISA COM ports and open communication in the background. For the reference sensor, since it's unchanging, it is relatively easy to set it (either through hardcoding or throug an ini file). However for the DUT, the port binding is ever increasing. What I mean is when I plug one DUT in, it shows for example, ASRL10 (COM10- USB Serial Port) , and when I disconnect the cable to plug it into the next DUT, it shows COM11 and so on and so forth. I want to avoid the user having a drop down box to select the specific COM port  each time a new test with a new DUT commences.

 

I can easily list all the currently connected instruments and filter the USB Serial Ports out, however, how do I circumvent the port binding? I don't know the finite number of DUTs that will be tested and NI-VISA allows COM numbers until only 256. Is there a way to set the port binding (so I can create an alias like "DUT" or something in MAX)?

 

Thank you for any hints and help!

0 Kudos
Message 1 of 31
(3,205 Views)

Make a short list (e.g. with VISA Find Resource function) and loop over them. Open each one (limit the access mode), and read properties to narrow down to the device (General Settings properties, like manufacturer, USB Settings, like serial number).

0 Kudos
Message 2 of 31
(3,195 Views)

What I have done is get the list of serial ports with the VISA Find Resources.  Then connect the DUT.  Do the find again and filter out the ports that were previously found.  What is left should be the resource for the DUT.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 31
(3,189 Views)

Hello and thank you for your response.

 

Getting the list is not the problem nor the resource for the DUT (using the PC's Device Manager was sufficient). Right now I only have two sample DUTs and what I have noticed that they have different port bindings. And while right now it's easy to say COMXX belongs to DUT 1 and COMYY belongs to DUT 2, my question is what happens when the COM number exceeds 256 (or whatever finite number it can hold)? The communication port from the DUT to USB is through a USB-Mini B cable (I'm assuming a RS232 FTDI connection beyond that but the person I could ask to be sure is unavailable). The test application is meant to last for years and every new DUT will just get a new COM number (or am I mistaken?)... 

0 Kudos
Message 4 of 31
(3,181 Views)

Maybe this will work for you

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 5 of 31
(3,165 Views)

I am assuming the USB/COM port adapter is embedded in the UUT and that is why it gets a new COM port each time?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 31
(3,161 Views)

@nikvl wrote:

while right now it's easy to say COMXX belongs to DUT 1 and COMYY belongs to DUT 2, my question is what happens when the COM number exceeds 256 (or whatever finite number it can hold)? 


This is a Windows issue and all you can do is go into the Windows Device Manager and manually remove the ports marked as "in use" by Windows.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 31
(3,153 Views)

Yes, I think so. Since all I get is the assembled unit and to communicate all I needed was the USB cable. I wonder what would happen once all the COMS are assigned? Would there an error?

0 Kudos
Message 8 of 31
(3,109 Views)

^ the above response was to @billko

0 Kudos
Message 9 of 31
(3,102 Views)

@nikvl wrote:

^ the above response was to @billko


Next time use the quote button 👍:

wiebeCARYA_0-1660810343329.png

 

0 Kudos
Message 10 of 31
(3,090 Views)