Error Variable-Iberr; Count Variables-Ibcnt And Ibcntl - National Instruments NI-488.2M Software Reference Manual

For os/2
Hide thumbs Also See for NI-488.2M:
Table of Contents

Advertisement

Developing Your Application
Error Variable—iberr
If the ERR bit is set in the status word (ibsta), a GPIB error has occurred.
When an error occurs, the error type is specified by the value in iberr.
Note:
The value in iberr is meaningful as an error type only when the
ERR bit is set, indicating that an error has occurred.
For more information on error codes and solutions, refer to Chapter 4,
Debugging Your Application, or Appendix B, Error Codes and Solutions.
Count Variables—ibcnt and ibcntl
The count variables are updated after each read, write, or command function.
ibcnt is a 16-bit integer and ibcntl is a 32-bit integer. If you are reading
data, the count variables indicate the number of bytes read. If you are sending
data or commands, the count variables reflect the number of bytes sent.
In your application program, you can use the count variables to null-terminate an
ASCII string of data received from an instrument. For example, if data is
received in an array of characters, you can use ibcntl to null-terminate the
array and print the measurement on the screen as follows:
char rdbuf[512];
ibrd (ud, rdbuf, 20L);
if (!(ibsta & ERR)){
rdbuf[ibcntl] = '\0';
printf ("Read:
}
else {
error();
}
ibcntl is the number of bytes received. Data begins in the array at
index 0; therefore, ibcntl is the position for the null character that marks the
end of the string.
NI-488.2M SRM for OS/2
%s\n", rdbuf);
3-6
© National Instruments Corp.
Chapter 3

Advertisement

Table of Contents
loading

Table of Contents