National Instruments NI-488.2 Benutzerhandbuch

Seite von 134
Chapter 4
Developing Your NI-488.2 Application
© National Instruments Corporation
4-9
Step 3a.
Use 
ibwrt
 to send the 
"*IDN?"
 query command to the device.
Step 3b.
Use 
ibrd
 to read the response from the device.
Continue communicating with the GPIB device until you are finished.
Cleanup
Step 4. Place the Device Offline before Exiting Your Application
Use 
ibonl
 to put the device handle offline before you exit the application.
Applications That Use Multiple Interfaces or Communicate with 
Multiple GPIB Devices
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");
}
General Program Steps and Examples
The following steps show you how to use the multi-device NI-488.2 calls 
in your application. The NI-488.2 software includes the 
4882query
 source 
code examples to demonstrate these principles.