UsbInterface UsbInterface UsbInterface 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

Declaration

public sealed class UsbInterfacepublic sealed class UsbInterfacePublic NotInheritable Class UsbInterfacepublic sealed class UsbInterface

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 summary

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.

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.

Gets an array of objects that represent descriptors for all alternate settings that are part of this USB interface.

Gets the interface number that identifies the USB interface. This value is the bInterfaceNumber field of a standard USB interface descriptor.

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

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.

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.

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

    Property Value

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

    Property Value

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

    Property Value

  • 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 bytepublic byte InterfaceNumber { get; }

    Property 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 IVectorView<UsbInterfaceSetting> InterfaceSettings { get; }Public ReadOnly Property InterfaceSettings As IVectorView<UsbInterfaceSetting>public IVectorView<UsbInterfaceSetting> InterfaceSettings { get; }

    Property Value

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

    Property Value

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

    Property Value

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.DualApiPartitionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute

Details

Assembly

Windows.Devices.Usb.dll