Events and Attributes
Events are special occurrences that require attention from your application. Event types include Service Requests (SRQs), interrupts, and hardware triggers. Events will not be delivered unless the appropriate events are enabled.
![]() |
VISA cannot call back to a Visual Basic function. Thus, you can only use the queuing mechanism in viEnableEvent. There is no way to install a VISA event handler in Visual Basic. |
Event Notification
There are two ways you can receive notification that an event has occurred:
- Install an event handler with viInstallHandler, and enable one or several events with viEnableEvent. If the event was enabled with a handler, the specified event handler will be called when the specified event occurs. This is called a callback.
![]() |
VISA cannot call back to a Visual Basic function. This means that you can only use the VI_QUEUE mechanism in viEnableEvent. There is no way to install a VISA event handler in Visual Basic. |
- Enable one or several events with viEnableEvent and call the viWaitOnEvent function. The viWaitOnEvent function will suspend the program execution until the specified event occurs or the specified timeout period is reached. This is called queuing.
The queuing and callback mechanisms are suitable for different programming styles. The queuing mechanism is generally useful for non-critical events that do not need immediate servicing. The callback mechanism is useful when immediate responses are needed. These mechanisms work independently of each other, so both can be enabled at the same time. By default, a session is not enabled to receive any events by either mechanism.
The viEnableEvent operation can be used to enable a session to respond to a specified event type using either the queuing mechanism, the callback mechanism, or both. Similarly, the viDisableEvent operation can be used to disable one or both mechanisms. Because the two methods work independently of each other, one can be enabled or disabled regardless of the current state of the other.
Events That Can Be Enabled
![]() |
This version of the IO Libraries Suite supports Windows and Linux. Available utilities, APIs, help files and features vary by operating system. Variations are flagged in help with these icons: |
Once the application has received an event, information about that event can be obtained by using the viGetAttribute function on that particular event context. Use the VISA viReadSTB function to read the status byte of the service request.
The events that are implemented for Keysight VISA for each resource class are:
-
Instrument Control (INSTR) Resource Events (VXI and PXI are Windows only.)
- Memory Access (MEMACC) Resource Event
- GPIB Bus Interface (INTFC) Resource Events
-
Backplane (BACKPLANE) Resource Events
-
TCPIP Socket (SOCKET) Resource Event
![]() |
Some resource classes/events, such as the SERVANT class, are not implemented by Keysight VISA and are not described in this help. |
Example: Reading Event Attributes
Once you have decided which attribute to check, you can read the attribute using the viGetAttribute function. The following example shows one way you could check which trigger line fired when the VI_EVENT_TRIG event was delivered.
Note that the context parameter is either the event context passed to your event handler, or the outcontext specified when doing a wait on event. See VISA Attributes for more information on reading attribute states.
ViInt16 state;
.
.
viGetAttribute(context, VI_ATTR_RECV_TRIG_ID, &state)