C/c++ example – National Instruments NI-VXI User Manual

Page 31

Advertising
background image

Chapter 2 Introduction to the NI-VXI Functions

NI-VXI User Manual

2-12

© National Instruments Corporation

For example, all VXI devices have at least one logical address by
which they can be accessed. However, it is simple to change the logical
address of most devices. Therefore, any program that uses a constant as
a logical address of a particular device can fail if that device is
reassigned to a different logical address. Programmers can use the
NI-VXI function

FindDevLA()

to input information about the

device—such as the manufacturer ID and model code—and receive the
device’s current logical address.

Consider the case of wanting to locate a device with manufacturer’s
code ABCh and model number 123h. You could use the following code
to determine the logical address.

C/C++ Example

:

main() {

INT16 ret, la;

ret = InitVXIlibrary();

/* -1 and empty quotes are used for don't cares */
ret = FindDevLA("", 0xABC, 0x123, -1, -1, -1, -1, &la);
if (ret < 0)

printf("No such device found.\n");

else

printf("The logical address is %d\n", la);

ret = CloseVXIlibrary();

}

In a similar fashion, the function

GetDevInfo()

can return a wide

assortment of information on a device, such as the manufacturer name
and number, the base and size of A24/32 memory, and the protocols
that the device supports. This information can be returned in either a
piecemeal fashion or in one large data structure. Notice that this data
structure is a user-defined type,

UserLAEntry

, which is defined in the

devinfo.h

header file.

For VME devices, this information cannot be determined by the
VXIbus Resource manager. However, you can enter this information
into the Non-VXI Device Editor in

VXIedit

or

VXItedit

. This will

allow you to use these functions to retrieve information about the
devices at run-time.

Advertising