150 Chapter 3
ProgrammingExamples
Status RegisterDetermine When a Measurement is Done
/* SENS:AVER:STAT ON */
/* - Trigger a measurement, and se t OPC bit when done */
/* INIT:IMM */
/* *OPC */
/* - Wait for the SRQ */
/* - When an interrupt occurs, pol l all instruments */
/* - Report the nature of the inte rrupt on the ESA analyzer */
/* - Clear the status register ena ble */
/* *SRE 0 */
/* - Clear the status byte of the ESA */
/* *CLS */
/* - Close the session */
/********************************* ***************************/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>
#include <windows.h>
#include "visa.h"
#define hpESA_IDN_E4401B "Hewlet t-Packard, E4401B"
#define hpESA_IDN_E4411B "Hewlet t-Packard, E4411B"
#define hpEMC_IDN_E7401A "Hewlett-P ackard, E7401A"
#define YIELD Sleep(10)
ViSession defaultRM, viESA;
ViStatus errStatus;
ViChar cIdBuff[256] = {0};
ViAddr iAddress;
char cEnter =0;
int iResult =0;
int iSrqOccurred=0;
char cBuf[3]={0};
/*Wait until SRQ is generated and for the handler to be called. Prin t
something while waiting. When in terrupt occurs it will be handled by
interrupt handler*/
void WaitForSRQ()
{
long lCount = 0L;
iSrqOccurred =0;