Specifications

Chapter 16 183
ESA/PSA Programming Examples
Using C and Service Request (SRQ) to Determine When a Measurement is
Complete
ESA/PSA Programming Examples
***************************************************************************/
#include <stdio.h>
#include <windows.h>
#include "visa.h"
ViSessiondefaultRM, viSA;
ViStatuserrStatus;
ViAddr iAddress;
int iSrqOccurred=0;
char cBuf[3]={0};
/*Wait until SRQ is generated and for the handler to be called. Print
something while waiting. When interrupt occurs it will be handled by
interrupt handler*/
void WaitForSRQ()
{
long lCount = 0L;
iSrqOccurred =0;
for (lCount =0;(lCount<10) && (iSrqOccurred ==0); lCount++)
{
long lCount2 =0;
printf(".");
while ((lCount2++ < 100) && (iSrqOccurred ==0))
{
Sleep(10);
}
}
}
/*Interrupt handler,trigger event handler */
ViStatus _VI_FUNCH mySrqHdlr(ViSession viSA, ViEventType eventType, ViEvent
ctx,ViAddr userHdlr)
{
ViUInt16 iStatusByte;