Example of Register-Based Communication
Note You can skip over this section if you are exclusively using GPIB, serial, or Ethernet communication. Register-based programming applies only to VXI, GPIB-VXI, or PXI. |
VISA has two standard methods for accessing registers. The first method uses High-Level Access functions. You can use these functions to specify the address to access; the functions then take care of the necessary details to perform the access, from mapping an I/O window to checking for failures. The drawback to using these functions is the amount of software overhead associated with them.
To reduce the overhead, VISA also has Low-Level Access functions. These functions break down the tasks done by the High-Level Access functions and let the program perform each task itself. The advantage is that you can optimize the sequence of calls based on the style of register I/O you are about to perform. However, you must be more knowledgeable about how register accesses work. In addition, you cannot check for errors easily. The following example shows how to perform register I/O using the High-Level Access functions, which is the method we recommend for new users. If you are an experienced user or understand register I/O concepts, you can use the Low-Level Access Operations.
Example
Note The following example uses bold text to distinguish lines of code that are different from the other introductory programming examples. |
#include "visa.h" int main(void) {
/* Error Initializing VISA...exiting */ } |