Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

why is there a delay after the program has already stopped?

I'm using VISA to communicate via the RS232 port. In my program there is a loop in which I open a VISA session and close it again within this loop. When I end the program (no matter if I do this properly or by interrupting it) there is a considerable delay afterwards. The longer the program has been running, the longer the delay is (a ratio of about 1 minute of program-runnig to 10 sec. of delay). So, the more cycles of the loop, the longer the delay! Why!?
0 Kudos
Message 1 of 2
(2,932 Views)
HighCo:

In general, opening and closing a session in a loop is a bad programming practice because it often unduly affects performance. Consider opening it once and keeping it open for the duration of your program.

Also, there is a known bug in the NI-VISA 2.6.0 release on Win32 (specifically on 2000/NT/XP) where opening and closing a port in a loop can cause a memory leak. Keeping it open will avoid this problem.

Is the delay in a specific VISA call? Or just your program's overall performance? You may be able to use NI Spy to verify if a specific VISA call is taking excessively long.

Dan Mondrik
Senior Software Engineer, NI-VISA
National Instruments
0 Kudos
Message 2 of 2
(2,932 Views)