Callbacks

NI-VISA

Callbacks

The VISA event model also allows applications to install functions that can be called back when a particular event type is received. You need to install a handler before enabling a session to sense events through the callback mechanism. Refer to userHandle Parameter for more information. The procedure works as follows:

  1. Use the viInstallHandler() operation to install handlers to receive events.
  2. Use the viEnableEvent() operation to enable the session for the callback mechanism as described in Enabling and Disabling Events.
  3. The VISA driver invokes the handler on every occurrence of the specified event.
  4. VISA provides the event object in the eventContext parameter of viEventHandler(). The event context is like a data structure, and contains information about the specific occurrence of the event. Refer to The Life of the Event Context for more information on event context.

You can now have multiple handlers per session in the current revision of VISA. If you have multiple handlers installed for the same event type on the same session, each handler is invoked on every occurrence of that event type. The handlers are invoked in reverse order of installation; that is, in Last In First Out (LIFO) order. For a given handler to prevent other handlers on the same session from being executed, it should return the value VI_SUCCESS_NCHAIN rather than VI_SUCCESS. This does not affect the invocation of event handlers on other sessions or in other processes.