Count function (ibcnt), Programming models, Items to include – National Instruments NI-488.2 User Manual

Page 46: Count function (ibcnt) -9, Items to include -9

Advertising
background image

Chapter 4

Developing Your NI-488.2 Application

© National Instruments Corporation

4-9

NI-488.2 User Manual

Count Function (Ibcnt)

The count function is updated after each read, write, or command function.
In addition,

Ibcnt

is updated after specific 488.2-style functions in certain

error cases. Refer to the NI-488.2 Help function reference for an
explanation of how each function uses the count function.

Ibcnt

is defined to be the type

unsigned long

.

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,

Interactive Control Utility

.

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

ni4882.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*/

Advertising