Agilent Technologies 8166A User Manual

Page of 274
How to Measure Power using FETCh and READ
VISA Programming Examples
Agilent 8163A/B, 8164A/B & 8166A/B Mainframes, Fifth Edition
195
How to Measure Power using 
FETCh and READ
The example shows the difference between a "FETCh" and a "READ" 
command. 
Install a power meter in Slot 1, before executing this example. 
   
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <visa.h>
/* function prototypes for this examples */
/* function for a simple error handling explained in example 1 */
void checkError(ViSession session, ViStatus err_status );
void main (void)
    {
    ViStatus              errStatus;          /*  returned  error  code  from  visa  call  */
    ViSession            defaultRM;          /*  default  visa  resource  manager 
variable */
    ViSession            vi;                        /*  current  session  handle  */
    ViChar                  replyBuf[256];  /*  buffer  holding  answers  of  the 
instrument*/
  ViChar         compBuf[256];  /* buffer used for comparsion */
    ViChar                  c;                          /*  used  in  the  keyboard  wait  loop  */
    ViReal64              averagingTime;  /*  averaging  time  */
    ViInt32                i;                          /*  loop  counter  */
    errStatus = viOpenDefaultRM (&defaultRM);
        if(errStatus  <  VI_SUCCESS)
            {
                printf("Failed  to  open  VISA  Resource  manager\n");
                exit(errStatus);
            }
    errStatus = viOpen (defaultRM, "GPIB::20::INSTR", 
VI_NULL,VI_NULL,&vi);
        if(errStatus  <  VI_SUCCESS)
            {
                printf("Failed  to  open  instrument\n");
                exit(errStatus);