LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scanning for COM ports

I am porting an application from Labview 6.1 to 7.1 under Windowds 2000, and the serial VIs have all changed.   The system-generated "equivalent" VIs that run under 7.1 and look like the old serial VIs seem to do just fine most of the time, but now I am having problems with USB serial adapters etc.  Time for me to rebuild these processes from scratch. 
 
I need to scan the serial ports on application startup (was originally just using iteration counter as a port number) until I find my device.  Now, the VISA serial function wants a VISA resource name instead of a port number.  What is the best way to cycle through all possible (or even better, all available) VISA resource names?  I can assemble the string ASRLnn::INSTR, but how do I go from that to a VISA resource name?  Alternatively, how do I cycle through all available VISA resource names and skip the ones that are invalid?
 
Thanks!
0 Kudos
Message 1 of 5
(3,594 Views)
A nice solution was given here by Dan Mondrick to my first post to this forum.
Chilly Charly    (aka CC)

         E-List Master - Kudos glutton - Press the yellow button on the left...
        
Message 2 of 5
(3,585 Views)
If the USB adapters are plugged in after the computer has booted, see this thread to read available comm ports from the registry.
 
Message 3 of 5
(3,579 Views)
CC beat me to the punch with what I was going to say so let me suggest a couple of other ideas. Assembling a string will also work. You can wire a string to the VISA Resource Name input and it will work just fine. You could also read the file c:\VXIpnp\WinNT\NIvisa\visaconf.ini. That file has a section called ALIASES. MAX will assign the aliases Com1, Com2, etc. to ASRL1::INSTR, ASRL2::INSTR, etc. so you could search the file for all "com" aliases". The advantage to that is the printer port is also an ASRL resource and you could eliminate trying to write to the printer.
Message 4 of 5
(3,576 Views)

Five stars to everyone!  The first VI from chillycharlie unlocked my main mystery: why was my Keyspan USB adapter (plugged in after booting, and created COM4 on my system) being successfully accessed in Labview under VISA resource name ASRL11::INSTR??  To me, it was like seeing COM4 turning into COM11.  The VISA resource bindings completely cleared that up...the ASRL number 11 had COM4 in the binding, so now I know it is NOT equivalent to the COM number, where USB adapters are involved.

The second reply (plus the bindings list) explained why my connection routine bogged down horribly on ASRL10::INSTR, which turned out to be my printer, and was timing out rather than responding.

The next VI, from unclebump, looked in my registry and correctly identified the presence of the a serial device (Keyspan driver) on COM4...but I am not sure yet whether I would be able to use a VISA utility to connect to it as COM4 rather than ASRL11::INSTR.

I haven't tried rebooting yet....that would probably clear everything up.  In any case, I know I can sort out the confusion now and run much more efficiently in my software with this help.  Now, if only the port settings for the devices were delivered to me on a silver platter...but the trial-and-error method is still working OK...

Soon I will try just connecting to USB drivers directly (after all, I did upgrade my software, and there are USB versions of my readers now).

Thanks again!

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