HP Water System HP VXI 사용자 설명서

다운로드
페이지 34
16
Programming the Status System  
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); 
 }
}