08-17-2022 09:04 AM
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!
Solved! Go to Solution.
08-17-2022 09:21 AM
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).
08-17-2022 09:30 AM
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.
08-17-2022 09:43 AM
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?)...
08-17-2022 11:07 AM
Maybe this will work for you
08-17-2022 11:16 AM
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?
08-17-2022 11:52 AM - edited 08-17-2022 12:14 PM
@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.
08-17-2022 11:40 PM
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?
08-18-2022 12:45 AM
^ the above response was to @billko
08-18-2022 03:13 AM