Programming Example
Programming in C using the VTL
34
Example Program
This example program queries a USB device for an
identification string and prints the results. Note that you
must change the address if something other than the default
USB address value is required.
/*idn.c - program filename */
#include "visa.h"
#include <stdio.h>
void main ()
{
char buf[300]
ViSession viN9322C
ViStatus viSatus;
ViSession defaultRM;
/*Open session to USB device */
viOpenDefaultRM(&defaultRM);
viWrite
This function synchronously sends the data pointed to by
buf
to the
device specified by
vi
. Only one synchronous write operation van occur
at any one time.
viWrite(vi, buf, count, &retCount)
viRead
This function synchronously reads raw data from the session specified
by the
vi
parameter and stores the result in location where
buf
is
pointing. Only one synchronous read operation can occur at any one
time.
viRead(vi, buf, count, &retCount)
viClose
This function must be used to close each session. When you close a
device session, all data structures that had been allocated for the
session will be set free. If you close the default resource manager
session, all sessions opened using that resource manager session will be
closed.
viClose(vi);
viClose(defaultRM)