National Instruments NI-488.2 Time Clock User Manual


 
Chapter 3 Developing Your Application
© National Instruments Corp. 3-5 NI-488.2 User Manual for Windows
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: %s\n", rdbuf);
}
else {
error();
}
ibcntl is the number of bytes received. Data begins in the array at index zero (0);
therefore, ibcntl is the position for the null character that marks the end of the string.
Using wibic to Communicate with Devices
Before you begin writing your application program, you might want to use the wibic
utility. With wibic (Windows Interface Bus Interactive Control), you communicate
with your instruments from the keyboard rather than from an application program. You
can use wibic to learn to communicate with your instruments using the NI-488
functions or NI-488.2 routines. For specific device communication instructions, refer to
the user manual that came with your instrument. For information about using wibic
and for detailed examples, refer to Chapter 5, wibic–Windows Interface Bus Interactive
Control Utility.
After you have learned how to communicate with your devices in wibic, you are ready
to begin writing your application program.