An example program is in SYS$COMMON:[SYSHLP.EXAMPLES.USB],:
ug_example.c. This program is a simple example of how to
use the UG driver to control a USB device. In this case, it loops
two PL2303 USB to RS232 controllers and exchanges data. Note that
this example does not exercise all the capabilities of the UG driver,
nor does it work on all PL2303-based controllers. Some PL230- based
controllers require additional setup, which is not shown in this example.
To compile the example, copy the programs ug_example.c and ugdef.h from sys$common:[syshlp.examples.usb] to a local directory where you have write access, then compile and
link them; no special switches are needed. To run the program, you
must add both PL2303 devices into the system. To do this, follow the
steps in USB Device Configuration.
The example program follows steps that are the usual ones for
any device you want to control:
Assign a channel to the device or devices.
Find out how many pipes the device has
Verify that you are communicating with the correct
device. The program does this by reading the device descriptor and
checking it against what it expects to find.
Associate an OpenVMS channel to a pipe and obtain
the pipe type and direction.
Perform any required device-specific setup.
6. Exchange data with the device.