The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
UsbInterface class
Provides information about the USB interface including its endpoints, the number of alternate settings the interface supports, and gets the entire descriptor set for those settings. It also obtains pipes associated with the endpoints that the interface supports.
Syntax
public ref class UsbInterface sealed
Attributes
- [DualApiPartition()]
- [MarshalingBehavior(Agile)]
- [Version(0x06030000)]
Members
The UsbInterface class has these types of members:
Methods
The UsbInterface class inherits methods from the Object class (C#/VB/C++).
Properties
The UsbInterface class has these properties.
Property | Access type | Description |
---|---|---|
Read-only | Gets an array of objects that represent pipes that the host opened to communicate with bulk IN endpoints defined in the current setting of the USB interface setting. | |
Read-only | Gets an array of objects that represent pipes that the host opened to communicate with bulk OUT endpoints defined in the current setting of the USB interface. | |
Read-only | Gets an array of objects that represent descriptors for all alternate settings that are part of this USB interface. | |
Read-only | Gets the interface number that identifies the USB interface. | |
Read-only | Gets an array of objects that represent alternate settings defined for the USB interface. | |
Read-only | Gets an array of objects that represent pipes that the host opened to communicate with interrupt IN endpoints defined in the current setting of the USB interface. | |
Read-only | Gets an array of objects that represent pipes that the host opened to communicate with interrupt OUT endpoints defined in the current setting of the USB interface. |
Examples
This code example shows how to parse descriptors and get pipe objects. The example assumes that the app has previously obtained the UsbDevice object.
using Windows.Devices.Usb; using Windows.Storage.Streams; protected override async void OnLaunched(LaunchActivatedEventArgs args) { UsbDevice device; UInt32 readLen = 8; // Get the UsbDevice object. Not shown. ... UsbInterface myInterface = null; // // Need to find this descriptor after an interface descriptor: // // ===>Class-Specific Video Control Interface Header Descriptor<=== // bLength: 0x0D // bDescriptorType: 0x24 // bDescriptorSubtype:0x01 // bcdVDC: 0x0100 // wTotalLength: 0x00D9 -> Validated // dwClockFreq: 0x02DC6C00 = (48000000) Hz // bInCollection: 0x01 // baInterfaceNr[1]: 0x01 // USB Video Class device: spec version 1.0 // foreach (var interf in device.Configuration.UsbInterfaces) { foreach (var setting in interf.InterfaceSettings) { var descriptors = setting.Descriptors; // First descriptor in the setting must be the interface descriptor if (descriptors.Count >= 2 && UsbInterfaceDescriptor.TryParse(descriptors[0], null) == true && descriptors[1].Length == 0x0D && descriptors[1].DescriptorType == 0x24) { Windows.Storage.Streams.Buffer buffer = new Windows.Storage.Streams.Buffer(readLen); descriptors[1].readDescriptorBuffer(buffer); Windows.Storage.Streams.DataReader reader = Windows.Storage.Streams.DataReader.FromBuffer(buffer); reader.ReadByte(); // bLength reader.ReadByte(); // bDescriptorType byte bDescriptorSubType = reader.ReadByte(); if (bDescriptorSubType == 0x01) { // This is our interface. myInterface = interf; ushort bcdVDC = reader.ReadUInt16(); ushort wTotalLength = reader.ReadUInt16(); byte lsb = reader.ReadByte(); uint dwClockFreq = (reader.ReadUInt16() << 8) + lsb; byte bInCollection = reader.ReadByte(); byte baInterfaceNr1 = reader.ReadByte(); await setting.SelectSettingAsync(); } break; } } if (myInterface != null) { break; } } if (myInterface == null) { ShowError("Video Control Interface descriptor not found"); return; } // Pipes are now available to communicate with endpoints UsbInterruptInPipe interruptIn = myInterface.InterruptInPipes[0]; UsbBulkOutPipe bulkOut = myInterface.BulkOutPipes[0]; }
Requirements
Minimum supported client | Windows 8.1 [Windows Store apps, desktop apps] |
---|---|
Minimum supported server | Windows Server 2012 R2 [Windows Store apps, desktop apps] |
Namespace |
|
Metadata |
|
See also
Show: