
SCPI error checking is illustrated in the following program example. The SCPI error routine is named sys_error. Errors found are reported to the standard output device.
∙
∙
∙
/** FUNCTION PROTOTYPES **/ |
|
|
void main (void); |
|
|
void err_handler(ViSession vi, ViStatus x); | /* VTL error routine | */ |
void sys_err(ViSession resource); | /* SCPI error routine | */ |
∙ |
|
|
∙ |
|
|
∙ |
|
|
/** GLOBAL **/ |
|
|
ViStatus err; |
|
|
ViSession defaultRM, cmd, dac; |
|
|
∙ |
|
|
∙ |
|
|
∙ |
|
|
void main (void)
{
/*** Open the resource manager, command module, and dac sessions ***/
viOpenDefaultRM (&defaultRM);
viOpen (defaultRM, CMD_ADDRESS, VI_NULL, VI_NULL, &cmd); viOpen(defaultRM, DAC_ADDRESS, VI_NULL, VI_NULL, &dac);
/*** Set the timeout for the dac ***/
viSetAttribute(dac, VI_ATTR_TMO_VALUE, 10000); /* 10 second timeout */
err=viPrintf(dac, “*RST\n”);/* reset the dac */ if(err < VI_SUCCESS) err_handler(dac, err); /* VTL error check */
sys_err (dac); | /* SCPI error check */ |
∙
∙
∙
}
/***VTL Error handling function ***/
void err_handler (ViSession dac, ViStatus err)
{
char buf[1024]={0}; viStatusDesc(dac,err,buf); printf(“VTL ERROR = %s\n”, buf); return;
}
/***End of VTL error handler ***/
48 Programming Examples | Chapter 2 |