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
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

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

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 IVectorView<UsbBulkInPipe> BulkInPipes { get; }Public ReadOnly Property BulkInPipes As IVectorView<UsbBulkInPipe>
Value

An array of UsbBulkInPipe objects.

Attributes

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 IVectorView<UsbBulkOutPipe> BulkOutPipes { get; }Public ReadOnly Property BulkOutPipes As IVectorView<UsbBulkOutPipe>
Value

An array of UsbBulkOutPipe objects.

Attributes

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 IVectorView<UsbDescriptor> Descriptors { get; }Public ReadOnly Property Descriptors As IVectorView<UsbDescriptor>
Value

An array of UsbDescriptor objects.

Attributes

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
Value
byte byte byte

The interface number that identifies the USB interface.

Attributes

InterfaceSettings InterfaceSettings InterfaceSettings

Gets an array of objects that represent alternate settings defined for the USB interface.

public IVectorView<UsbInterfaceSetting> InterfaceSettings { get; }public IVectorView<UsbInterfaceSetting> InterfaceSettings { get; }Public ReadOnly Property InterfaceSettings As IVectorView<UsbInterfaceSetting>
Value

An array of UsbInterfaceSetting objects.

Attributes

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 IVectorView<UsbInterruptInPipe> InterruptInPipes { get; }Public ReadOnly Property InterruptInPipes As IVectorView<UsbInterruptInPipe>
Value

An array of UsbInterruptInPipe objects. The objects are in the same order as they are defined in the interface descriptor.

Attributes

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 IVectorView<UsbInterruptOutPipe> InterruptOutPipes { get; }Public ReadOnly Property InterruptOutPipes As IVectorView<UsbInterruptOutPipe>
Value

An array of UsbInterruptOutPipe objects.

Attributes