HP OpenVMS Systems Documentation

Content starts here E.6 Example
HP OpenVMS I/O User’s Reference Manual: OpenVMS Version 8.4 > Appendix E Programming USB Generic Drivers

E.6 Example

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:

  1. Assign a channel to the device or devices.

  2. Find out how many pipes the device has

  3. 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.

  4. Associate an OpenVMS channel to a pipe and obtain the pipe type and direction.

  5. Perform any required device-specific setup.

  6. 6. Exchange data with the device.