UsbInterface Kelas

Definisi

Menyediakan informasi tentang antarmuka USB termasuk titik akhirnya, jumlah pengaturan alternatif yang didukung antarmuka, dan mendapatkan seluruh deskriptor yang diatur untuk pengaturan tersebut. Ini juga mendapatkan pipa yang terkait dengan titik akhir yang didukung antarmuka.

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
Warisan
Object Platform::Object IInspectable UsbInterface
Atribut

Persyaratan Windows

Rangkaian perangkat
Windows 10 (diperkenalkan dalam 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v1.0)

Contoh

Contoh kode ini menunjukkan cara mengurai deskriptor dan mendapatkan objek pipa. Contohnya mengasumsikan bahwa aplikasi sebelumnya telah mendapatkan objek 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];

}

Properti

BulkInPipes

Mendapatkan array objek yang mewakili pipa yang dibuka host untuk berkomunikasi dengan titik akhir IN massal yang ditentukan dalam pengaturan pengaturan antarmuka USB saat ini.

BulkOutPipes

Mendapatkan array objek yang mewakili pipa yang dibuka host untuk berkomunikasi dengan titik akhir OUT massal yang ditentukan dalam pengaturan antarmuka USB saat ini.

Descriptors

Mendapatkan array objek yang mewakili deskriptor untuk semua pengaturan alternatif yang merupakan bagian dari antarmuka USB ini.

InterfaceNumber

Mendapatkan nomor antarmuka yang mengidentifikasi antarmuka USB. Nilai ini adalah bidang bInterfaceNumber dari deskriptor antarmuka USB standar.

InterfaceSettings

Mendapatkan array objek yang mewakili pengaturan alternatif yang ditentukan untuk antarmuka USB.

InterruptInPipes

Mendapatkan array objek yang mewakili pipa yang dibuka host untuk berkomunikasi dengan titik akhir IN yang didefinisikan dalam pengaturan antarmuka USB saat ini.

InterruptOutPipes

Mendapatkan array objek yang mewakili pipa yang dibuka host untuk berkomunikasi dengan titik akhir OUT yang didefinisikan dalam pengaturan antarmuka USB saat ini.

Berlaku untuk