Developing Your Application
Chapter 3
NI-488.2M UM for Windows NT
3-10
© National Instruments Corp.
When SRQ has been detected, serial poll the instrument to determine if the measured data
is valid or if a fault condition exists. For IEEE 488.2 instruments, you can find out by
checking the message available (MAV) bit, bit 4 in the status byte that you receive from
the instrument.
ibrsp (ud, &StatusByte);
if (ibsta & ERR) {
gpiberr("ibrsp error");
}
if ( !(StatusByte & MAVbit)) {
gpiberr("Improper Status Byte");
printf(" Status Byte = 0x%x\n", StatusByte);
}
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 using the
ibonl
function.
ibonl (ud, 0);