2-10
Sample Programs
C Programming Examples
*/
void initialize ( )
{
write_IO ("*RST"); /* reset scope - initialize to known state */
write_IO ("*CLS"); /* clear status registers and output queue */
write_IO (":SYSTem:HEADer OFF"); /* turn off system headers */
write_IO (":AUToscale"); /* perform autoscale */
} /* end initialize ( ) */
/*
* Function name: setup_SRQ
* Parameters: none
* Return value: none
* Description: This routine initializes the device to generate Service
* Requests. It sets the Service Request Enable Register Event Status Bit
* and the Standard Event Status Enable Register to allow SRQs on Command
* or Query errors.
*/
void setup_SRQ ( )
{
/* Enable Service Request Enable Register - Event Status Bit */
write_IO ("*SRE 32");
/* Enable Standard Event Status Enable Register enable Command Error - bit 4 - value 32 Query Error - bit 1 - value 4 */
write_IO ("*ESE 36");
} /* end setup_SRQ ( ) */
/*
* 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?");