Chapter 3
Developing Your NI-488.2 Application
Programming Models
Applications That Communicate with a Single GPIB Device
NI-488.2 User Manual for Windows
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 files
and
. The standard Windows header file,
decl-32.h
contains definitions used by
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 device-level traditional
NI-488.2 calls in your application. The NI-488.2 software includes the
source code for an example written in C,
for the example written to use direct entry to access
. The NI-488.2 software also includes a sample program
dlldevquery.c
written in Visual Basic,
Initialization
Step 1. Open a Device
Use
to open a device handle. The
ibdev
following parameters:
•
Connect board index (typically 0, for
•
Primary address for the GPIB instrument (refer to the instrument user
manual or use the
decl-32.h
devquery.c
.
devquery.frm
ibdev
GPIB0
function to dynamically determine the
FindLstn
3-8
windows.h
windows.h
, and
contains
decl-32.h
, and the source code
gpib-32.dll
function requires the
).
www.natinst.com
,
,