National Instruments NI-488.2 ユーザーズマニュアル

ページ / 134
Chapter 4
Developing Your NI-488.2 Application
© National Instruments Corporation
4-7
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.
Using Interactive Control to Communicate with Devices
Before you begin writing your application, you might want to use the 
Interactive Control utility to communicate with your instruments 
interactively by typing in commands from the keyboard rather than from 
an application. You can use the Interactive Control utility to learn to 
communicate with your instruments using the NI-488.2 API. For specific 
device communication instructions, refer to the user manual that came with 
your instrument. For information about using the Interactive Control utility 
and detailed examples, refer to Chapter 7, 
Programming Models
Applications That Communicate with a Single GPIB Device
This section describes items you should include in your application and 
provides general program steps with an NI-488.2 example.
Items to Include
Include the following items in your application:
Header files—In a C application, include the header file 
ni488.h
which contains prototypes for the NI-488.2 calls and constants that 
you can use in your application.
Error checking—Check for errors after each NI-488.2 call.
Error handling—Declare and define a function to handle NI-488.2 
errors. This function takes the device offline and closes the application. 
If the function is declared as:
void gpiberr (char * msg); /*function prototype*/
then your application invokes it as follows:
if (ibsta & ERR) {
gpiberr("NI-488.2 error");
}