다음을 통해 공유


USB 디바이스 설명자

디바이스 설명자에는 USB 디바이스에 대한 전체 정보가 포함되어 있습니다. This article describes the USB_DEVICE_DESCRIPTOR structure and includes information about how a client driver can send a get-descriptor request to obtain the device descriptor.

모든 USB(유니버설 직렬 버스) 디바이스는 디바이스에 대한 관련 정보를 포함하는 단일 디바이스 설명자를 제공할 수 있어야 합니다. The USB_DEVICE_DESCRIPTOR structure describes a device descriptor. Windows는 이 정보를 사용하여 다양한 정보 집합을 파생합니다. For example, the idVendor and idProduct fields specify vendor and product identifiers, respectively. Windows uses those field values to construct a hardware ID for the device. 특정 디바이스의 하드웨어 ID를 보려면 다음을 수행합니다.

  1. Open Device Manager.
  2. Right-click on the USB device and select Properties.
  3. Select the Details tab in the properties dialog box.
  4. Drop down the Property list.
  5. Select the Hardware Ids property

The values indicate the hardware IDs ("USB\XXX") that Windows generates.

The bcdUSB field of the USB_DEVICE_DESCRIPTOR structure indicates the version of the USB specification to which the device conforms. 예를 들어 0x0200 디바이스가 USB 2.0 사양에 따라 설계되었음을 나타냅니다. The bcdDevice value indicates the device-defined revision number.

The USB driver stack uses bcdDevice, along with idVendor and idProduct, to generate hardware and compatible IDs for the device. You can view those identifiers in Device Manager. 또한 디바이스 설명자는 디바이스에서 지원하는 총 구성 수를 나타냅니다.

디바이스가 최고 속도 용량으로 연결할 때와는 다른 빠른 용량으로 호스트 컴퓨터에 연결할 때 디바이스 설명자에 다른 정보를 보고할 수 있습니다. 전원 상태 변경 중을 포함하여 연결 수명 동안 디바이스 설명자에 포함된 정보를 디바이스에서 변경해서는 안 됩니다.

호스트는 제어 전송을 통해 디바이스 설명자를 가져옵니다. 전송에서 요청 유형은 GET DESCRIPTOR이고 받는 사람은 디바이스입니다. 클라이언트 드라이버는 프레임워크 USB 대상 디바이스 개체를 사용하거나 요청 정보와 함께 URB를 전송하는 두 가지 방법 중 하나로 전송을 시작할 수 있습니다.

디바이스 설명자 가져오기

WDF(Windows 드라이버 프레임워크) 클라이언트 드라이버는 프레임워크 USB 대상 디바이스 개체를 만든 후에만 디바이스 설명자를 가져올 수 있습니다.

A Kernel-Mode Driver Framework (KMDF) driver must obtain a WDFUSBDEVICE handle to the USB target device object by calling WdfUsbTargetDeviceCreate. Typically, a client driver calls WdfUsbTargetDeviceCreate in the driver's EvtDevicePrepareHardware callback implementation. After that, the client driver must call the WdfUsbTargetDeviceGetDeviceDescriptor method. After the call completes, the device descriptor is received in the caller-allocated USB_DEVICE_DESCRIPTOR structure.

A User-Mode Driver Framework (UMDF) driver must query the framework device object for an IWDFUsbTargetDevice pointer and then call the IWDFUsbTargetDevice::RetrieveDescriptor method and specify USB_DEVICE_DESCRIPTOR_TYPE as the descriptor type.

호스트는 URB를 전송하여 디바이스 설명자를 가져올 수도 있습니다. 이 메서드는 커널 모드 드라이버에만 적용됩니다. 그러나 드라이버가 WDM(Windows 드라이버 모델)을 기반으로 하지 않는 한 클라이언트 드라이버는 이러한 유형의 요청에 대해 URB를 보낼 필요가 없습니다. Such a driver must allocate an URB structure and then call the UsbBuildGetDescriptorRequest macro to specify format the URB for the request. 그런 다음 드라이버는 URB를 USB 드라이버 스택에 제출하여 요청을 보낼 수 있습니다. 자세한 내용은 URB를 제출하는 방법을 참조하세요.

이 코드 예제에서는 적절한 URB를 사용하여 pURB가 가리키는 버퍼의 형식을 지정하는 UsbBuildGetDescriptorRequest 호출을 보여 줍니다.

UsbBuildGetDescriptorRequest(
    pURB,                                                 // Points to the URB to be formatted
    sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
    USB_DEVICE_DESCRIPTOR_TYPE,
    0,                                                    // Not used for device descriptors
    0,                                                    // Not used for device descriptors
    pDescriptor,                                          // Points to a USB_DEVICE_DESCRIPTOR structure
    NULL,
    sizeof(USB_DEVICE_DESCRIPTOR),
    NULL
);

샘플 디바이스 설명자

이 예제에서는 USBView 애플리케이션을 사용하여 가져온 USB 웹캠 디바이스의 디바이스 설명자(USB 디바이스 레이아웃 참조)를 보여줍니다.

Device Descriptor:
bcdUSB:             0x0200
bDeviceClass:         0xEF
bDeviceSubClass:      0x02
bDeviceProtocol:      0x01
bMaxPacketSize0:      0x40 (64)
idVendor:           0x045E (Microsoft Corporation)
idProduct:          0x0728
bcdDevice:          0x0100
iManufacturer:        0x01
0x0409: "Microsoft"
iProduct:             0x02
0x0409: "Microsoft LifeCam VX-5000"
0x0409: "Microsoft LifeCam VX-5000"
iSerialNumber:        0x00
bNumConfigurations:   0x01

앞의 예제에서 디바이스는 USB 사양 버전 2.0에 따라 개발되었습니다. Note the bDeviceClass, bDeviceSubClass, and bDeviceProtocol values. 이러한 값은 디바이스에 함수당 여러 인터페이스를 그룹화하는 데 사용할 수 있는 하나 이상의 USB 인터페이스 연결 설명자가 포함되어 있음을 나타냅니다. 자세한 내용은 USB 인터페이스 연결 설명자를 참조 하세요.

Next, see the value of bMaxPacketSize0. 이 값은 기본 엔드포인트의 최대 패킷 크기를 나타냅니다. 이 샘플 디바이스는 기본 엔드포인트를 통해 최대 64바이트의 데이터를 전송할 수 있습니다.

일반적으로 디바이스를 구성하기 위해 클라이언트 드라이버는 디바이스 설명자를 받은 후 디바이스에서 지원되는 구성에 대한 정보를 가져옵니다. To determine the number of configurations that the device supports, inspect the bNumConfigurations member of the returned structure. 이 디바이스는 하나의 구성을 지원합니다. USB 구성에 대한 정보를 얻으려면 드라이버에서 USB 구성 설명자를 가져와야 합니다.