From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Determine if USB-GPIB port is in use

Is there any way to determine if a VISA resource is in use programmatically?
 
I have a situation where I will be running two copies of the same application on one system.  This application communicates via GPIB with a Spectrum Analyzer.  There are times when we will be wanting to collect data from two separate analyzers, and due to space constrictions, can only use a single computer.  Thus I need to run the compiled application twice at the same time.  My main question is, is there a way to have the program determine if its default VISA resource is already in use, and thus to use the secondary?  ie.  Program launches, and checks the VISA alias HPSpecAn1, and if it is not in use, starts to communicate with the spectrum analyzer referenced in the alias, but if another program has already claimed that resource (either that alias or another device on that GPIB bus.) it will go to the VISA alias HPSpecAn2 etc.
Jon D
Certified LabVIEW Developer.
0 Kudos
Message 1 of 3
(2,418 Views)
I think you can use the VISA Lock functions. At the beginning of where the instrument is required, you would do a VISA Lock Async set to a small timeout. If it returns with no error, the resource is available. If it does return an error, then open a reference to the other instrument. Don't forget to add a VISA Unlock when you are done.
Message 2 of 3
(2,407 Views)
That is basically what I ended up doing after some experimentation.  Thank you for confirming it as a good method.

Jon D
Certified LabVIEW Developer.
0 Kudos
Message 3 of 3
(2,389 Views)