HP VXI manual Example Program

Page 16

Define an 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.

--Check if the MAV bit (bit 4) is set to indicate that a message is available. If the MAV bit is set, then a message is available and the SRQ handler can process the message. In this example, the output queue is read using iscanf.

Enable SRQ Handler in SICL with ionsrq.

Enable MAV bit (Message Available Bit) in the Status Byte Enable Register (e.g. *SRE 16). This will cause an SRQ to arrive when there is a message in the output queue (i.e. data is available to be read)

Example Program

/* status1.c *

*The following program provides an interactive command line interface

*to send SCPI commands to SCPI compatible instruments.

*This utilizes the MAV bit of the Status Byte in order to determine if

*the instrument is returning any output. */

#include <sicl.h> #include <stdio.h>

/* Theses are Masks for the Status Byte */ /* all bits start at bit 0 */

#define

MAV_MASK 0x10

/* MAV - bit 4 */

/* This

is the SRQ handler to check for Message Available (MAV) */

void srq_hdlr( INST id) {

 

unsigned char stb;

 

char buf[255];

 

int

esr;

 

int

errnum;

 

char errmsg[100];

/* read the status byte to determine what caused the SRQ.

*Note: use ireadstb instead of *STB? because you want to

*clear RQS instead of reading the MSS bit in the status byte.*/ ireadstb(id, &stb);

/* check if MAV caused the SRQ */ if( MAV_MASK == (stb & MAV_MASK))

{

/* message is available so read in the result. */ iscanf( id, "%t", buf);

printf("%s", buf);

}

}

16 Programming the Status System

Chapter 2

Image 16
Contents Contents Comments Example QUEStionableEVENt? Printing History This Page Intentionally Left Blank Introduction Introduction Chapter About this Chapter General Status Register ModelCondition Register Transition Filter Event Register An Example SequencePage Required Status Groups Status Byte Register Standard Event Group Status Byte Bit DefinitionsStandard Operation Status Group Questionable Data Group Handling SRQs Using MAV to Determine When Data is Available Status System Programming ExamplesExample Program SRQ Icloseid Example Program Deverrmask Qryerrmask Chapter Programming the Status System Programming the Status System Chapter Command Reference STATus OPERationENABleOPERation CONDition? OPERationENABle? PRESetOPERationEVENt? QUEStionable CONDition?QUEStionableENABle? QUEStionableENABleQUEStionableEVENt? STATQUESEVEN? Common Command Reference CLSEMC? ESE maskESE? ESR?LMC? IDN?LRN? OPC OPC?PMC RSTSRE mask SRE?STB? TST?WAI Command Reference Chapter