USB 匯流排的核心模式靜態影像驅動程式支援單一控制端點,以及多個中斷、大量輸入和大量輸出端點。 The control and interrupt endpoints are accessible using I/O control codes and DeviceIoControl. The bulk endpoints are accessible using ReadFile and WriteFile.
Before calling DeviceIoControl, ReadFile, or WriteFile, you must call CreateFile (all described in the Microsoft Windows SDK documentation) to obtain a device handle. For devices that support no more than one of each endpoint type (control, interrupt, bulk IN, bulk OUT), a single call to CreateFile opens transfer pipes to each endpoint.
For devices that support multiple interrupt or bulk endpoints, a single call to CreateFile opens transfer pipes to the highest-numbered endpoint of each type. 如果您想要使用不同的端點,則必須執行下列動作:
Call DeviceIoControl, specifying an I/O control code of IOCTL_GET_PIPE_CONFIGURATION, to determine a port's endpoint index numbers (that is, indexes into the returned USBSCAN_PIPE_INFORMATION structure array). Note that these index numbers are not the endpoint numbers described in the Universal Serial Bus Specification.
Append a backslash and the endpoint's index number to the port name returned by IStiDeviceControl::GetMyDevicePortName when calling CreateFile.
例如,假設裝置 (連接埠名稱為 “usbscan0”) 每種類型都有兩個端點 (中斷、大量輸入、大量輸出),索引號碼如下:
| Index | 類型 | Endpoint# |
|---|---|---|
| 0 | Interrupt | 0x01 |
| 1 | Bulk IN | 0x82 |
| 2 | Bulk IN | 0x83 |
| 3 | Bulk OUT | 0x04 |
| 4 | Bulk OUT | 0x05 |
| 5 | Interrupt | 0x06 |
If you call CreateFile with a port name of "usbscan0", the function opens transfer pipes to endpoints with index values of 2, 4, and 5, as well as the control endpoint.
If you call CreateFile with a port name of "usbscan0\1", the function opens transfer pipes to endpoints with index values of 1, 4, and 5, as well as the control endpoint.
For this device, if you want to use interrupt endpoint 0, bulk IN endpoint 1, and bulk OUT endpoint 3, call CreateFile three times, specifying port names of "usbscan0\0", "usbscan0\1", and "usbscan0\3". 這會建立三個裝置控制碼。 Whenever a subsequent call to DeviceIoControl, ReadFile, or WriteFile is made, the device handle associated with the desired pipe should be specified.
Because only one control endpoint is supported, specifying any I/O control code that uses the control pipe causes the driver to use the proper endpoint, regardless of which endpoint (if any) was specified to CreateFile.
如需所有 I/O 控制代碼的描述,請參閱 USB 靜態影像 I/O 控制代碼。
核心模式 USB 驅動程式不會實作套件或訊息通訊協定。 讀取作業不需要任何特定的封包對齊方式,但如果讀取要求與封包大小界限上限對齊,則可以達到更好的效能。 The maximum packet size can be obtained using the IOCTL_GET_CHANNEL_ALIGN_RQST I/O control code.