HP VXI manual Status System Programming Examples

Page 15

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

Image 15
Contents Contents Comments Example QUEStionableEVENt? Printing History This Page Intentionally Left Blank Introduction Introduction Chapter General Status Register Model About this ChapterAn Example Sequence Condition Register Transition Filter Event RegisterPage Required Status Groups Status Byte Register Status Byte Bit Definitions Standard Event GroupStandard Operation Status Group Questionable Data Group Status System Programming Examples Handling SRQs Using MAV to Determine When Data is AvailableExample Program SRQ Icloseid Example Program Deverrmask Qryerrmask Chapter Programming the Status System Programming the Status System Chapter Command Reference OPERationENABle STATusOPERation CONDition? QUEStionable CONDition? OPERationENABle?PRESet OPERationEVENt?QUEStionableENABle QUEStionableENABle?QUEStionableEVENt? STATQUESEVEN? CLS Common Command ReferenceESR? EMC?ESE mask ESE?IDN? LMC?LRN? RST OPCOPC? PMCTST? SRE maskSRE? STB?WAI Command Reference Chapter