Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Are VISA handles opened indefinately?

I have an application which calls VISA instrument drivers. Looking at NI-Spy, it seems that a lot of resources are opened but never closed. That is until you exit the program (at which point viClose is called for the resources).

In actual fact, I am running this code in a TestStand sequence which repeats for many iterations - in fact there is a possibility that TestStand may NEVER be shut down. I have noticed all the open sessions are NOT re-used on subsequent runs of the code. Will NI-VISA keep generating handles forever?

My system does actually crash with a Windows error after a short time, and sometimes NI-VISA tries to close resources that are already closed in an infinite loop when this happens.

Can NI-VISA be forced
to close all it's handles? As I cannot shutdown teststand after each run.
0 Kudos
Message 1 of 2
(3,247 Views)
If you are using NI TestStand and VISA instrument drivers then you have a possibility to start using NI Session Manager, which help you to close all opened sessions(handles) automatically on the end of the sequence or callbacks (See NI Session Manager help file).

Anyhow, you must use this algorithm:

CheckError(viOpenDefaultRM (&io));
CheckError(viOpen (io, name, VI_NULL, VI_NULL, &vi));
.............
here is your subseq.
or code
.............
CheckError(viClose (io));
CheckError(viClose (vi));
"Only a life lived in the service to others is worth living..." - Albert Einstein
0 Kudos
Message 2 of 2
(3,247 Views)