General program steps and examples, General program steps and examples -10 – National Instruments NI-488.2 User Manual
Page 47

Chapter 4
Developing Your NI-488.2 Application
4-10
ni.com
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 traditional NI-488.2
device-level calls in your application. The NI-488.2 software includes the
devquery
source code example to demonstrate these principles.
Initialization
Step 1. Open a Device
Use
ibdev
to open a device handle. The
ibdev
function requires the
following parameters:
•
Connect board index (typically 0, for
GPIB0
).
•
Primary address for the GPIB instrument (refer to the instrument user
manual or use the
FindLstn
function to dynamically determine the
GPIB address of your GPIB device, as described in
the GPIB Address of Your Device
Multiple Interfaces or Communicate with Multiple GPIB Devices
section later in this chapter).
•
Secondary address for the GPIB instrument (0 if the GPIB instrument
does not use secondary addressing).
•
Timeout period (typically set to T10s, which is 10 seconds).
•
End-of-transfer mode (typically set to 1 so that EOI is asserted with the
last byte of writes).
•
EOS detection mode (typically 0 if the GPIB instrument does not use
EOS characters).
A successful
ibdev
call returns a device handle,
ud
, that is used for all
device-level traditional NI-488.2 calls that communicate with the GPIB
instrument.
Step 2. Clear the Device
Use
ibclr
to clear the device. This resets the device’s internal functions to
the default state.