Chapter 8 NI-488.2 Programming Techniques
© National Instruments Corporation 8-9 NI-488.2 User Manual
// Convert the data into a numeric value.
sscanf (ReadBuffer, "%f", &Readings[ReadingsTaken]);
// Display the data.
printf(“Reading : %f\n”, Readings[ReadingsTaken]);
ReadingsTaken += 1;
if (ReadingsTaken >= 1000) {
return 0;
}
else {
// Issue a request to the device to send the data and rearm
// callback on RQS.
LocalIbsta = ibwrt (LocalUd, "SEND DATA", 9L);
if (LocalIbsta & ERR) {
printf ("ibwrt failed. No more callbacks.\n");
DeviceError = TRUE;
return 0;
}
else {
return RQS;
}
}
}
Writing Multithreaded NI-488.2 Applications
If you are writing a multithreaded NI-488.2 application and you plan
to make all of your NI-488.2 calls from a single thread, you can safely
continue to use the traditional NI-488.2 global variables (ibsta, iberr,
ibcnt, ibcntl). The NI-488.2 global variables are defined on a
per-process basis, so each process accesses its own copy of the NI-488.2
globals.
If you are writing a multithreaded NI-488.2 application and you plan to
make NI-488.2 calls from more than a single thread, you cannot safely
continue to use the traditional NI-488.2 global variables without some form
of synchronization (for example, semaphores, mutexes, critical sections).
To understand why, refer to the following example.