Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Example Program
NI Supported: Yes
Publish Date: Sep 20, 2006


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links - Products and Services

USB RAW Control Communication in Visual C#.NET

0 ratings | 0.00 out of 5
Print

Downloads

Filename: usbrawcontrolcs.zip
Requirements: View

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 www.ni.com). 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

Requirements


Filename: usbrawcontrolcs.zip

Software Requirements


Language(s): C#

 
0 ratings | 0.00 out of 5
Print

Reader Comments | Submit a comment »

 

Legal
This example program (this "program") was developed by a National Instruments ("NI") Applications Engineer. Although technical support of this program may be made available by National Instruments, this program may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this program with each new revision of related products and drivers. THIS EXAMPLE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).