(QRY_ERR_MASK == (esr & QRY_ERR_MASK )) )

{

/* an error occurred, read the error queue to get the error */ errnum = -1;

while( errnum != 0)

{

ipromptf( id, "SYST:ERR?\n", "%d,%t", &errnum, errmsg); if( errnum != 0)

printf("%d,%s", errnum, errmsg);

}

}

}

}

void main()

{

INST id;

char addr[80]; char cmd[255]; int opc;

int idx;

printf("This program provides an interactive environment for SCPI \n"); printf("compatible instruments. \n\n");

printf("Enter the SICL address of the instrument to open.\n"); printf("for example: iscpi,24)\n");

gets(addr);

/* install error handler */ ionerror( I_ERROR_EXIT);

/* open the

instrument specified by the user */

id

= iopen(addr);

 

itimeout(

id,

20000);

/* 20 second timeout */

/*

set up

SRQ

handler */

 

ionsrq( id,

srq_hdlr);

 

/* enable MAV (bit 4) and Standard Event Status Summary (bit 5) * in status byte to cause an SRQ */

iprintf( id, "*SRE %d\n", MAV_MASK ESR_MASK);

/* enable ERROR Bits to generate a ESR summary message */ iprintf( id, "*ESE %d\n", CMD_ERR_MASK EXE_ERR_MASK

DEV_ERR_MASK QRY_ERR_MASK);

/* make sure *SRE and *ESE finished */

 

ipromptf( id, "*OPC?\n", "%d", &opc);

/* opc value not used */

printf("\nEnter SCPI Commands/Queries to Instrument at %s\n", addr); printf(" (press return to exit)\n\n");

while(1)

 

 

{

 

 

while(0 == gets(cmd));

 

if( 0

== strlen(cmd))

 

 

break;

/* quit sending SCPI Commands */

20 Programming the Status System

Chapter 2