Chapter 7 NI-488.2 Programming Techniques
NI-488.2 User Manual for Windows 7-6 www.natinst.com
because of the way they are used in the application: only a single thread is writing the global values and that thread only adds information (increases the count or adds another reading to the array of floats).int __stdcall MyCallback (int ud, int LocalIbsta, int LocalIberr,
long LocalIbcntl, void *RefData);
int ReadingsTaken = 0;
float Readings[1000];
BOOL DeviceError = FALSE;
char expectedResponse = 0x43;
int main()
{int ud;
// Assign a unique identifier to the device and store it in the
// variable ud. ibdev opens an available device and assigns it to
// access GPIB0 with a primary address of 1, a secondary address of 0,
// a timeout of 10 seconds, the END message enabled, and the EOS mode
// disabled. If ud is less than zero, then print an error message
// that the call failed and exit the program.
ud = ibdev (0,// connect board
1, // primary address of GPIB device
0, // secondary address of GPIB device
T10s, // 10 second I/O timeout
1, // EOT mode turned on
0); // EOS mode disabled
if (ud < 0) {
printf ("ibdev failed.\n");
return 0;
}
// Issue a request to the device to send the data. If the ERR bit
// is set in ibsta, then print an error message that the call failed
// and exit the program.
ibwrt (ud, "SEND DATA", 9L);
if (ibsta & ERR) {
printf ("unable to write to device.\n");
return 0;
}
// set up the asynchronous event notification on RQS
ibnotify (ud, RQS, MyCallback, NULL);