2-14
Sample Programs
Sample C Programs
Generating a Service Request
The following function is demonstrated in the “gen_srq.c” sample program.
/*
* Function name: create_SRQ
* Parameters: none
* Return value: none
* Description: This routine sends two illegal commands to the scope which will
* generate an SRQ and will place two error strings in the error queue. The scope
* ID is requested to allow time for the SRQ to be generated. The ID string
* will contain a leading character which is the response placed in the output
* queue by the interrupted query.
*/
void create_SRQ ( )
{
char buf [256] = { 0 }; //read buffer for id string
int bytes_read = 0;
int srq_asserted;
/* Generate query error (interrupted query)*/
/* send legal query followed by another command other than a read query response */
write_IO (":CHANnel2:DISPlay?");
write_IO (":CHANnel2:DISPlay OFF");
/* Generate command error - send illegal header */
write_IO (":CHANnel:DISPlay OFF");
/* get instrument ID - allow time for SRQ to set */
write_IO ("*IDN?");
bytes_read = read_IO (buf,256L);
/* add NULL to end of string */
buf [bytes_read] = '\0';
printf ( "%s\n", buf);
srq_asserted = check_SRQ ( );
if ( srq_asserted )
srq_handler ( );
} /* end create_SRQ ( ) */