Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

ViClose takes 15 seconds to return

I've checked the forums and found an equivalent post : http://forums.ni.com/t5/LabWindows-CVI/ViClose-is-taking-15-second-to-close-the-session/m-p/809879

 

Unfortunately, nobody responded to that post so here I am with the same problem. I have 3 sessions opened at the time viClose is called; one to the resource manager, one "Tx" session to a serial instrument, and one "Rx" session to the same serial instrument. I call ViClose on the resource manager to close all of them at once. The following is output from NI Trace

 

1960. viClose (0x00B1FA70)
Process ID: 0x00000FE0 Thread ID: 0x000000D0
Start Time: 19:09:15.718 Call Duration 00:00:15.014
Status: 0 (VI_SUCCESS)

0 Kudos
Message 1 of 4
(3,482 Views)

Hi Jcobb03,

 

Would you be able to explain your application a bit more? More specifically, what is going on in each of these three sessions?

 

If this is related to VISA session there is an "Automatically close VISA sessions" option, as described in the forum post here.

 

I hope this helps!

0 Kudos
Message 2 of 4
(3,422 Views)

Sure. My app is communicating with a single port to an ENET-485. The app is written in C++ and utilizes separate threads to handle Tx traffic to the device (mainly setup and polling commands) and Rx traffic (setup and poll responses). So all three sessions are created in a main thread and then the other two threads use either the "Tx" session to the instrument or the "Rx" session to the instrument. When I want to close this portion of the app, I call ViClose on the RM session which should be cleaning up the Tx and Rx sessions automatically, which it does...it just takes 15 seconds to do so.  

 

I do utilize async reads and writes, and it is almost certain I will attempt a ViClose call during a WaitOnEvent for either session due to the frequency of poll commands sent out. The timeout on the WaitOnEvent for the read call is wayyyyy longer than 15 seconds though. I didn't think that was affecting the ViClose since its consistently taking 15 seconds to finish, no matter what the timeout for WaitOnEvent is (even if its VI_TMO_IMMEDIATE).

0 Kudos
Message 3 of 4
(3,419 Views)

Hi jcobb03,

 

Your description of the timeout on the WaitOnEvent makes it seem like the error may be caused by not closing the Wait On Event.

 

The link here further explains this.

 

Does this help with your long ViClose time?

0 Kudos
Message 4 of 4
(3,388 Views)