NI I/O Trace Shows Unexpected viClose

Updated Apr 28, 2023

Reported In

Software

  • I/O Trace

Driver

  • NI-VISA

Issue Details

I connected an instrument, that uses NI VISA driver, to my PC and ran LabVIEW code that communicates with this instrument.
I run NI I/O Trace at the same time to monitor program performance.
As you can see at the following image captured from the I/O Trace, viClose appears after each call to viWrite and viRead, even though in the code I call the VISA Close function only once, at the end of the program.
This behavior does not affect the performance of the program. What means the additional viClose?



IO Trace KB.png
 

Solution

The viClose's seen in NI I/O Trace are indeed not errors.

As it seen in the attached NI I/O Trace, there are two types of viClose, viClose that closes out the session with the instrument (the last viClose at the attached I/O Trace) and others (all the other viClose) that close out events with the instrument.
The program uses asynchronous write and read functions. Each time the program calls VISA Write or VISA Read, it waits for an answer from the device. To prevent memory leaks, the program should close out the events, therefore when the answer arrives from the device the NI I/O Trace shows, using viClose, that it completed the desired action of reading/writing events from/to the instrument.




 

Additional Information

These asynchronous communication events with instruments are done automatically in LabVIEW rather than in ANSI C where it must be done manually.
VISA defines a common mechanism to notify an application when certain conditions occur. These conditions or occurrences are referred to as events. An event is a means of communication between a VISA resource and its applications.
For more information please check NI-VISA™ User Manual - chapter 7.