Developing Your Application
Chapter 3
NI-488.2M SRM for OS/2
3-12
© National Instruments Corp.
Step 6. Read the Measurement
If the data is valid, read the measurement from the instrument.
(
AsciiToFloat
is a function that takes a null-terminated string as input and
outputs the floating point number it represents.)
ibrd (ud, rdbuf, 10L);
if (ibsta & ERR) {
gpiberr("ibrd error");
}
rdbuf[ibcntl] = '\0';
printf("Read: %s\n", rdbuf);
/* Output ==> Read: +10.98E-3 */
sum += AsciiToFloat(rdbuf);
Step 7. Process the Data
Repeat Steps 4 through 6 in a loop until 10 measurements have been read, then
print the average of the readings as shown:
printf("The average of the 10 readings is %f\n",
sum/10.0);
Step 8. Place the Device Offline
As a final step, take the device offline by using the
ibonl
function.
ibonl (ud, 0);