HP (Hewlett-Packard) HP VXI Water System User Manual


 
Programming the Status System 17Chapter 2
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) in status byte to cause an SRQ */
iprintf( id, "*SRE %d\n", MAV_MASK );
/* make sure *SRE 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 */
/* send command */
iprintf(id, "%s\n", cmd);
/* check cmd for a ’?’, if found assume it is a query */
for(idx=0; idx<strlen(cmd); idx++)
if( ’?’ == cmd[idx])
{
/* wait up to 1 minute for srq handler */
if( 0 != iwaithdlr(60000))
{
printf("ERROR: Failed to process Query\n");
}
break;
}
}/* while - there are commands to send */
/* remove the handler */
ionsrq( id, 0);
/* close the session */
printf("\nClosing Instrument at %s\n", addr);