Status System Programming Examples

Handling SRQs

Using MAV to Determine When Data is Available

This section contains two example programs that use the status system and common commands to monitor when data is available from an instrument and when an error has occurred. Both programming examples are written in C and use the Standard Instrument Control Library (SICL) for I/O operations. The example programs use SCPI (Standard Commands for Programmable Instruments) commands to communicate with the status system. Thus, the instruments must either be message-based or have a SCPI interpreter, such as an HP E1405/06 Command Module or the SICL iscpi interface.

The following is a general procedure for handling SRQs:

Define the SRQ handler to do the following:

--Read the Status Byte using ireadstb. ireadstb returns the RQS (request for service) bit in bit 6 of the status byte. After issuing a ireadstb, RQS is cleared indicating that the Service Request is being acknowledged. A new SRQ will not be issued unless RQS is cleared. Using *STB? will return the Master State Summary in bit 6 and does not affect RQS, therefore this should not be used in a SRQ handler.

--Check the status byte to determine which status group(s) requires service.

--For each status group that requires service, read the event register of that status group to determine what caused the SRQ to be generated. It is necessary to clear the event register so that if a new event occurs a new SRQ will be generated.

--Take some action after determining which event caused the SRQ. The action taken is determined by evaluating the contents of the event register.

Enable SRQ Handler in SICL with ionsrq.

Make sure that all the Enable Masks in all the status enable registers are set to the proper values to propagate the summary bit(s) to the status byte. An SRQ is only generated if the MSS (Master State Summary) bit in the status byte is set.

The following example program sets up an SRQ handler to be called when there is data in the output queue. The program then prompts for SCPI commands. If the SCPI command results in data in the output queue (such as a query command), then the SRQ handler is called and the data is printed.

The following summarizes the procedure used:

Chapter 2

Programming the Status System 15

Page 15
Image 15
HP VXI manual Status System Programming Examples, Handling SRQs Using MAV to Determine When Data is Available