16:34:09.617 Read 8 bytes from file pointer 0
16:34:13.022 Transfer data 04 00 00 00 00 00 00 00
16:34:13.022 Read: 00000000 8 bytes returned
16:34:13.022 Read 8 bytes from file pointer 0
16:34:13.112 Transfer data 05 00 00 00 00 00 00 00
16:34:13.112 Read: 00000000 8 bytes returned
16:34:13.112 Read 8 bytes from file pointer 0
16:34:13.222 Transfer data 05 00 63 00 00 00 00 00
16:34:13.222 Read: 00000000 8 bytes returned
16:34:13.292 Read 8 bytes from file pointer 0
16:34:13.993 Transfer data 04 00 00 00 00 00 00 00
16:34:13.993 Read: 00000000 8 bytes returned
Read A, B, C, Esc key presses
16:34:14.023 Read 8 bytes from file pointer 0
16:34:16.757 Transfer data 00 00 04 00 00 00 00 00
16:34:16.757 Read: J0000000 8 bytes returned
16:34:16.777 Read 8 bytes from file pointer 0
16:34:17.128 Transfer data 00 00 05 00 00 00 00 00
16:34:17.128 Read: 00000000 8 bytes returned
16:34:17.158 Read 8 bytes from file pointer 0
16:34:17.609 Transfer data 00 00 06 00 00 00 00 00
16:34:17.609 Read: 00000000 8 bytes returned
16:34:17.639 Read 8 bytes from file pointer 0
16:34:17.859 Transfer data 00 00 29 00 00 00 00 00
16:34:17.859 Read: 00000000 8 bytes returned
Write different bit combinations to flash the keyboard LEDs
16:34:17.969 Write 1 bytes from file pointer 0
16:34:17.969 Sending set report
16:34:17.969 Write: 1 bytes written
16:34:21.124 Write 1 bytes from file pointer 0
16:34:21.124 Sending set report
16:34:21.144 Write: 1 bytes written Get statuses using IOCTL_USBKBD_GET_STATUSES
16:34:21.524 DeviceIoControl: Control code 00222014 InputLength 0 OutputLength 6
16:34:21.524 Getting device status
16:34:21.524 Getting interface status
16:34:21.524 Getting endpoint status
16:34:21.524 DeviceIoControl: 6 bytes written
Read frame length and numbers using IOCTL_USBKBD_GET_FRAME_INFO
16:34:21.524 DeviceIoControl: Control code 00222018 InputLength 0 OutputLength 12
16:34:21.524 Getting current frame number
16:34:21.524 FrameNumber 912595
16:34:21.524 Getting frame info
16:34:21.524 FrameLength 11999 FrameAlterNumber 912595
16:34:21.524 DeviceIoControl: 12 bytes written
CloseHandle
16:34:21.634 Close
16:34:21.634 Deselecting configuration
USBDI Structure Reference
This section provides a reference for the USB Driver Interface (USBDI). The basic URB structure has been covered in enough detail in earlier sections of this chapter. Therefore, I first describe various other USBDI structures. Then, I go on to detail each of the URB function codes, the corresponding URB structures and any useful build routines.
Structures
Device Descriptor
A device descriptor is returned in a USB_DEVICE_DESCRIPTOR structure. Table 21.4 shows the fields of interest in the device descriptor. The device class, subclass, and protocol fields are not used by Windows and are often zeroes. However, they may be used to indicate which new common class specification features are used.
Table 21.4 USB DEVICE DESCRIPTOR fields
bDeviceClass bDeviceSubClass bDeviceProtocol |
The USB class codes |
idVendor idProduct bcdDevice |
Vendor, product, and version numbers |
iManufacturer iProduct iSerialNumber |
Indexes into the string descriptor for the relevant strings |
bMaxPacketSize0 |
The maximum packet size for Endpoint 0 |
bNumConfigurations |
The number of configurations |
Configuration Descriptor
A configuration descriptor is returned in a USB_CONFIGURATION_DESCRIPTOR structure, with fields as shown in Table 21.5.
A request for a configuration descriptor will also get any other descriptors associated with this configuration (interface-, endpoint-, class-, and vendor-defined descriptors), if there is enough room in your buffer. You will usually get the configuration descriptor twice. First, get the basic USB_CONFIGURATION_DESCRIPTOR structure. The wTotalLength field tells you how big a buffer to allocate to retrieve all the descriptors in your next get configuration request.
Table 21.5 USB CONFIGURATION DESCRIPTOR fields
wTotalLength |
Total length of all data for the configuration |
bNumInterfaces |
Number of interfaces |
iConfiguration |
Configuration number |
bmAttributes |
bit 5 set: supports remote wake up |
bit 6 set: self-powered |
bit 7 set: powered from bus |
maxPower |
Maximum power required, in 2mA units |
Interface Descriptor
An interface descriptor is returned in a USB_INTERFACE_DESCRIPTOR structure, with fields shown Table 21.6. Interface descriptors are returned as a part of a get configuration descriptor request.
Table 21.6 USB_INTERFACE DESCRIPTOR fields
bInterfaceNumber |
Interface number |
bAlternateSetting |
Alternate setting |
bNumEndpoints |
Number of endpoints |
bInterfaceClass bInterfaceSubClass bInterfaceProtocol |
USB class codes |
iInterface |
Index of string descriptor describing the interface |
Interface Selection Structures
Various structures are needed when you select a configuration. An array of USB_INTERFACE_LIST_ENTRY structures, shown in Table 21.7, is passed to USBD_CreateConfigurationRequestEx . The InterfaceDescriptor field points to the interface descriptor that you want enabled in the configuration. When the Select Configuration URB has completed, the Interface pointer is valid and refers to valid data.
Table 21.7 USB INTERFACE LIST ENTRY fields
InterfaceDescriptor |
Points to interface descriptor |
Interface |
USB_INTERFACE_INFORMATION pointer |
The Select Configuration URB fills a USB_INTERFACE_INFORMATION structure for each interface that it enables. Table 21.8 shows this structure, whose size increases as there are more pipes.
Table 21.8 USB INTERFACE INFORMATION fields
InterfaceNumber |
Interface number |
AlternateSetting |
Alternate setting |
Class Subclass Protocol |
USB class codes |
NumberOfPipes |
Number of pipes |
PipeInformation |
Array of USB_PIPE_INFORMATION structures |
Table 21.9 shows the USB_PIPE_INFORMATION structure. All fields apart from MaximumTransferSize and PipeFlags fields are filled in by the Select Configuration URB.
Читать дальше