USB RAW Control Communication in Visual C#.NET

Publish Date: Sep 20, 2006 | 0 Ratings | 0.00 out of 5 | Print | Submit your review
This example illustrates simple reads and writes to a USB RAW device as results user events. It is designed to only work with USB RAW devices.

To run this example, install a USB RAW device and configure Measurement & Automation Explorer (MAX) to recognize the USB device (see Tutorial: Using NI-VISA 3.0 to Control Your USB Device at After the USB RAW device is successfully installed and configured, and you have opened a session to the device, you can perform control in and control out functions with the USB RAW device.

This example allows the user to cause USB control pipe transfers to or from a USB device. The values of the data payload in the setup stage of the control transfer are taken as parameters and include bmRequestType, bRequest, wValue, wIndex, and wLength. The value of each in these calls is largely dependant on the USB RAW device, however there are a few standard calls that can be made.

For example, to get the status of a particular device, you could use the following values in a Control In function:
Request Type: 0x80 (Device to Host, Standard Type, Device Recipient)
Request: 0x00 (GET_STATUS)
Value: 0x00
Index: 0x00
Length: 0x02
NOTE: All inputs above are configured to accept a HEXADECIMAL input. This can be changed to accept decimal values by setting the HEXADECIMAL property to FALSE for each input.

The last two bits of the value returned will let you know whether the device is set to remotely wake up (bit 1), and whether the device is self powered (bit 0).

To perform control transfers with another device, close the session to the current device, select another device from the VISA resource name control, and open a session to it.

When complete, close the application to end execution.

Related Links:
Using NI-VISA 3.0 to Control Your USB Device

Back to Top

Bookmark & Share






Rate this document

Answered Your Question?
Yes No