
Configuration Example
The following program segment demonstrates how to read the module identification string and the configuration. The configuration integers are bit manipulated using the C operator for bit shifting result = result <<1 (a one bit shift to the left).
∙
∙
∙
/** FUNCTION PROTOTYPES **/ |
|
|
void main (void); |
|
|
void err_handler(ViSession vi, ViStatus x); | /* VTL error routine | */ |
void sys_err(ViSession resource); | /* Checks for SCPI programming errors */ |
/** GLOBAL **/ ViStatus err;
ViSession defaultRM, cmd, dac;
∙
∙
∙
void main (void)
{
int i,num_chan,result = {0},config [6]={0}; char buf[256] = { 0 };
/*** Check the module identification | ***/ |
|
|
err=viPrintf(dac, “*IDN?\n”); | /* request id from the module */ | ||
err=viScanf(dac, “%t”, &buf); | /* enter string returned | */ | |
printf (“Module is identified as a %s\n”, buf); | /* print the result | */ | |
/*** Get the module configuration | ***/ |
|
|
err=viPrintf(dac, “DIAG:CONF?\n”); | /* request module configuration */ | ||
err=viScanf(dac, “%,6d”, &config); | /* returns six integers | */ |
/* Decode the first integer */
result=config[0]; /* Expansion board */ if (result < 7)
{
printf (“Module is a 16 channel device\n”); num_chan = 16;
}
else
{
printf (“Module is an 8 channel device\n”); num_chan=8;
}
42 Programming Examples | Chapter 2 |