Detecting Error Conditions
Example: Detecting
Error Conditions
(BASIC)
Example: Detecting
Error Conditions
(Turbo C)
Chapter 2
The SYSTem:ERRor? query requests a value from an instrument's error
register. This register contains an integer in the range [-32,768 to 32,767].
The response takes the form <err_number>,<err_message> where
<err_number> is the value of the instrument's error and <err_message>
is a short description of the error.
This BASIC program attempts an illegal channel closure and polls for an
error message.
10 DIM Err_num$[256]
20 OUTPUT 70915; "CLOS (@135)"
30 OUTPUT 70915; "SYST:ERR?"
40 ENTER 70915; Err_num$
50 PRINT Err_num$
60 END
This Turbo C program attempts an illegal channel closure and polls for an
error message. If no error occurs, the switchbox responds with 0, "No error".
If there has been more than one error, the instrument will respond with the
first error in its error queue. Subsequent queries continue to read the error
queue until it is empty. The maximum <err_message> string length is 255
characters.
#include stdio.h
#include chpib.h
#define ISC 7L
#define FORMC 70915L
#define TASK1 "CLOSE (@135)" /*Command for illegal switch closure*/
#define TASK2 "SYST:ERR?"
main( )
{
char into[257];
int length = 256;
/*Output commands to Form C*/
error_handler (IOTIMEOUT (7L,5.0), "TIMEOUT");
error_handler (IOOUTPUTS (FORMC, TASK1, 12), "OUTPUT command");
error_handler (IOOUTPUTS (FORMC, TASK2, 9), "OUTPUT command");
/*Enter from Form C*/
error_handler (IOENTERS (FORMC, into, &length), "ENTER command");
printf("Print the errors: %s",into);
return;
}
!Dimension a string variable for
256 characters
!Try to close an illegal channel
!Query for a system error
!Print error +2001, "Invalid
channel number"
/*Include file for GPIB*/
/*Form C default address*/
/*Command for system error*/
Using the Form C Switch 45