UsbInterface
UsbInterface
UsbInterface
UsbInterface
Class
Definition
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.
public : sealed class UsbInterface : IUsbInterfacepublic sealed class UsbInterface : IUsbInterfacePublic NotInheritable Class UsbInterface Implements IUsbInterface// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
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];
}
Properties
BulkInPipes BulkInPipes BulkInPipes BulkInPipes
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.
public : IVectorView<UsbBulkInPipe> BulkInPipes { get; }public IReadOnlyList<UsbBulkInPipe> BulkInPipes { get; }Public ReadOnly Property BulkInPipes As IReadOnlyList<UsbBulkInPipe>// You can use this property in JavaScript.
- Value
- IVectorView<UsbBulkInPipe> IReadOnlyList<UsbBulkInPipe> IReadOnlyList<UsbBulkInPipe> IReadOnlyList<UsbBulkInPipe>
An array of UsbBulkInPipe objects.
BulkOutPipes BulkOutPipes BulkOutPipes BulkOutPipes
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.
public : IVectorView<UsbBulkOutPipe> BulkOutPipes { get; }public IReadOnlyList<UsbBulkOutPipe> BulkOutPipes { get; }Public ReadOnly Property BulkOutPipes As IReadOnlyList<UsbBulkOutPipe>// You can use this property in JavaScript.
- Value
- IVectorView<UsbBulkOutPipe> IReadOnlyList<UsbBulkOutPipe> IReadOnlyList<UsbBulkOutPipe> IReadOnlyList<UsbBulkOutPipe>
An array of UsbBulkOutPipe objects.
Descriptors Descriptors Descriptors Descriptors
Gets an array of objects that represent descriptors for all alternate settings that are part of this USB interface.
public : IVectorView<UsbDescriptor> Descriptors { get; }public IReadOnlyList<UsbDescriptor> Descriptors { get; }Public ReadOnly Property Descriptors As IReadOnlyList<UsbDescriptor>// You can use this property in JavaScript.
- Value
- IVectorView<UsbDescriptor> IReadOnlyList<UsbDescriptor> IReadOnlyList<UsbDescriptor> IReadOnlyList<UsbDescriptor>
An array of UsbDescriptor objects.
InterfaceNumber InterfaceNumber InterfaceNumber InterfaceNumber
Gets the interface number that identifies the USB interface. This value is the bInterfaceNumber field of a standard USB interface descriptor.
public : byte InterfaceNumber { get; }public byte InterfaceNumber { get; }Public ReadOnly Property InterfaceNumber As byte// You can use this property in JavaScript.
- Value
- byte byte byte byte
The interface number that identifies the USB interface.
InterfaceSettings InterfaceSettings InterfaceSettings InterfaceSettings
Gets an array of objects that represent alternate settings defined for the USB interface.
public : IVectorView<UsbInterfaceSetting> InterfaceSettings { get; }public IReadOnlyList<UsbInterfaceSetting> InterfaceSettings { get; }Public ReadOnly Property InterfaceSettings As IReadOnlyList<UsbInterfaceSetting>// You can use this property in JavaScript.
- Value
- IVectorView<UsbInterfaceSetting> IReadOnlyList<UsbInterfaceSetting> IReadOnlyList<UsbInterfaceSetting> IReadOnlyList<UsbInterfaceSetting>
An array of UsbInterfaceSetting objects.
InterruptInPipes InterruptInPipes InterruptInPipes InterruptInPipes
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.
public : IVectorView<UsbInterruptInPipe> InterruptInPipes { get; }public IReadOnlyList<UsbInterruptInPipe> InterruptInPipes { get; }Public ReadOnly Property InterruptInPipes As IReadOnlyList<UsbInterruptInPipe>// You can use this property in JavaScript.
- Value
- IVectorView<UsbInterruptInPipe> IReadOnlyList<UsbInterruptInPipe> IReadOnlyList<UsbInterruptInPipe> IReadOnlyList<UsbInterruptInPipe>
An array of UsbInterruptInPipe objects. The objects are in the same order as they are defined in the interface descriptor.
InterruptOutPipes InterruptOutPipes InterruptOutPipes InterruptOutPipes
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.
public : IVectorView<UsbInterruptOutPipe> InterruptOutPipes { get; }public IReadOnlyList<UsbInterruptOutPipe> InterruptOutPipes { get; }Public ReadOnly Property InterruptOutPipes As IReadOnlyList<UsbInterruptOutPipe>// You can use this property in JavaScript.
- Value
- IVectorView<UsbInterruptOutPipe> IReadOnlyList<UsbInterruptOutPipe> IReadOnlyList<UsbInterruptOutPipe> IReadOnlyList<UsbInterruptOutPipe>
An array of UsbInterruptOutPipe objects.