Instrument Control (GPIB, Serial, VISA, IVI)

Showing results for 
Search instead for 
Did you mean: 

Close all open IVI sessions

When debugging a program it is common for me to abort the the program from within the Block diagram. However in doing this is I will prevent my program from entering my "Exit" state where I close all my IVI sessions. What I find is that I'll either have to open a new block diagram and manually close all the IVI sesssions or restart labview if I want my program to execute without errors.


I've found a great tool in the \LabVIEW\Vi.lib\Utility\visa.llb. called Open VISA Session


I'm curious if there is something similar for IVI dirvers? If not how would i go about querying all open IVI sessions?

0 Kudos
Message 1 of 10

Hey Patrick.


               Have you tried seeing if your IVI resources are shown in the Open VISA Session Since IVI is built on top of VISA, its likely that there is a you could close the corresponding VISA references. The block diagram for how the VISA sessions are actually found is password protected so it might not be as simple as the vi makes it seem. Let me know if that works for you.


Luke W

0 Kudos
Message 2 of 10

I'm controlling PXI cards with IVI and i'm using the built in Labview sub VIs for them. I have checked and they do not show up in the Open VISA Session

0 Kudos
Message 3 of 10

Hey Patrick


                Which IVI drivers and vi's are you using? Also, could you explain you application a little more?




Luke W

0 Kudos
Message 4 of 10

Sure thing,

I'm using a String Driven Queued State Machine. I have an “Initialize” state where I initialize PXI Power Supplies, DMMS, SMUs, & ARBs. While debugging the program I will highlight execution and watch the results. Often I’ll get errors or incorrect results. In a situation like this it is common for me to abort the execution from the block diagram. This leaves open IVI session handles to my modular instruments, because the program did not go to the “Exit” state where I close all the session handles. If i make an edit and then run the program again I’ll get an error while configuring one of the modular instruments.


Currently, my way around this is to open a new block diagram and close all the open session handles. This is annoying and time consuming. The only other alternative I have found is to close LabVIEW. This will kill all instrument session handles.


I'm interested in creating a LabVIEW developer’s tool which will query all open instrument drivers sessions (IVI or VISA) and kill/close them. This way I will have a quick way to kill all session handles without doing it manually.




0 Kudos
Message 5 of 10

Hey Patrick,


                 I found a previous instance of someone trying to accomplish this same task. The Product Support Engineer responsible for IVI reported that at this moment the IVI drivers do not have a querying function. Similar functionality has been acheived from the LabVIEW side of things by keeping track of the initializing and closing of IVI sessions. For example, when the program encounters an initialize command, it stores the resulting handle in an array of strings. Every time this occurs, the handle is appended to the array of handles. When the resources are closed, they are removed from the array. The end result is an array of the open IVI session handles. IVI Foundation. This is a good resource if you happen to have any other IVI related questions




Luke W

0 Kudos
Message 6 of 10

I know this thread may be old but was a solution ever found?

I am developing an app and find it fustrating to reboot the PC just to close an IVI driver session which was left open after a previous run of the application.

0 Kudos
Message 7 of 10

Hi Jacob,


There still doesn't appear to be a built-in function that automatically closes out all IVI references; however you could try doing what Patrick suggested and create another VI that closes all the open sessions.

0 Kudos
Message 8 of 10

How to close all open IVI sessions. Please help. PRogramatically from LabVIEW how to to get open sessions in memory.

Thanks in advance

0 Kudos
Message 9 of 10



I would suggest taking a look at the following documents. The first one is from the IVI Foundation and is a getting started guide and the next two are NI Tutorials that outline how to use IVI Drivers in LabVIEW.


IVI Foundation Getting Started Guide


Using IVI Drivers in LabVIEW


Getting Started with IVI Drivers in LabVIEW


I hope this helps!

Megan T.

Technical Support Engineer

National Instruments

0 Kudos
Message 10 of 10