UsbInterface クラス

定義

エンドポイント、インターフェイスがサポートする代替設定の数など、USB インターフェイスに関する情報を提供し、それらの設定の記述子セット全体を取得します。 また、インターフェイスがサポートするエンドポイントに関連付けられているパイプも取得します。

public ref class UsbInterface sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class UsbInterface final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class UsbInterface
Public NotInheritable Class UsbInterface
継承
Object Platform::Object IInspectable UsbInterface
属性

Windows の要件

デバイス ファミリ
Windows 10 (10.0.10240.0 で導入)
API contract
Windows.Foundation.UniversalApiContract (v1.0 で導入)

このコード例では、記述子を解析し、パイプ オブジェクトを取得する方法を示します。 この例では、アプリが以前に UsbDevice オブジェクトを取得していることを前提としています。

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];

}

プロパティ

BulkInPipes

USB インターフェイス設定の現在の設定で定義されている一括 IN エンドポイントと通信するためにホストが開いたパイプを表す オブジェクトの配列を取得します。

BulkOutPipes

USB インターフェイスの現在の設定で定義されている一括 OUT エンドポイントと通信するためにホストが開いたパイプを表す オブジェクトの配列を取得します。

Descriptors

この USB インターフェイスの一部であるすべての代替設定の記述子を表す オブジェクトの配列を取得します。

InterfaceNumber

USB インターフェイスを識別するインターフェイス番号を取得します。 この値は、標準の USB インターフェイス記述子の bInterfaceNumber フィールドです。

InterfaceSettings

USB インターフェイスに定義されている代替設定を表す オブジェクトの配列を取得します。

InterruptInPipes

USB インターフェイスの現在の設定で定義されている割り込み IN エンドポイントと通信するためにホストが開いたパイプを表す オブジェクトの配列を取得します。

InterruptOutPipes

USB インターフェイスの現在の設定で定義されている割り込み OUT エンドポイントと通信するためにホストが開いたパイプを表す オブジェクトの配列を取得します。

適用対象