Share via


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 엔드포인트와 통신하기 위해 연 파이프를 나타내는 개체의 배열을 가져옵니다.

적용 대상