|
To enable applications to get and set an endpoint pipe's default policy parameters, libusbK.dll exposes the UsbK_GetPipePolicy function to retrieve the pipe's default policy. The UsbK_SetPipePolicy function allows an application to set the policy parameter to a new value.
libusbK allows you to modify its default behavior by applying policies to an endpoint's pipe. By using these policies, you can configure libusbK to best match your device to its capabilities. The following table provides a list of the pipe policies that are supported by libusbK.
Policy number | Policy name | Description | Endpoint (direction) | Default |
---|---|---|---|---|
0x01 | SHORT_PACKET_TERMINATE | Terminates every write request with a zero-length packet. | Bulk (OUT) Interrupt (OUT) |
Off |
0x02 | AUTO_CLEAR_STALL | Automatically clears a stalled pipe without stopping the data flow. | Bulk (IN) Interrupt (IN) |
Off |
0x03 | PIPE_TRANSFER_TIMEOUT | Waits for a time-out interval before canceling the request. | Bulk (IN) Bulk (OUT) Interrupt (IN) Interrupt (OUT) |
5 seconds for control; 0 for others |
0x04 | IGNORE_SHORT_PACKETS | Completes a read request based on the number of bytes read. | Bulk (IN) Interrupt (IN) |
Off |
0x05 | ALLOW_PARTIAL_READS | Allows read requests from a device that returns more data than requested by the caller. | Bulk (IN) Interrupt (IN) |
On |
0x06 | AUTO_FLUSH | Saves the excess data from the read request and adds it to the next read request or discards the excess data. | Bulk (IN) Interrupt (IN) |
Off |
0x07 | RAW_IO | Bypasses queuing and error handling to boost performance for multiple read requests. | Bulk (IN) Interrupt (IN) |
Off |
0x08 | MAXIMUM_TRANSFER_SIZE | Gets the maximum size of a USB transfer supported by libusbK. This is a read-only policy that can be retrieved by calling WinUsb_GetPipePolicy. | Bulk (IN) Bulk (OUT) Interrupt (IN) Interrupt (OUT) |
|
0x09 | RESET_PIPE_ON_RESUME | Resets the endpoint's pipe after resuming from suspend before accepting new requests. | Bulk (IN) Bulk (OUT) Interrupt (IN) Interrupt (OUT) |
Off |
0x30 | SIMUL_PARALLEL_REQUESTS | Maximum number of transfers that can be asynchronously delivered at a time. Available in version 1.9 and later versions of KMDF. Requires \b RAW_IO. http://msdn.microsoft.com/en-us/library/windows/hardware/ff552359%28v=vs.85%29.aspx. | Bulk (IN) Bulk (OUT) Interrupt (IN) Interrupt (OUT) ISO (IN) ISO (OUT) |
Unlimited |
0x20 | ISO_START_LATENCY | TODO: | ISO (IN) ISO (OUT) |
8 for full speed, 32 for high speed |
0x21 | ISO_ALWAYS_START_ASAP | TODO: | ISO (IN) ISO (OUT) |
On for OUT endpoints, Off for IN endpoints |
0x22 | ISO_NUM_FIXED_PACKETS | TODO: | ISO (OUT) | 0 (disabled) |
Policy | Enable if... | Behavior |
---|---|---|
SHORT_PACKET_TERMINATE | The device requires the OUT transfers to be terminated with a zero-length packet. Most devices do not have this requirement. |
If enabled (policy parameter value is TRUE or nonzero), every write request is followed
by a zero-length packet to the endpoint's pipe.
After sending all of the requested data to the host controller, libusbK sends a write request with a zero-length packet and then completes the request that was created by UsbK_WritePipe. |
AUTO_CLEAR_STALL | You do not want the failed transfers to leave the endpoint in a stalled state. This policy is useful only when you have multiple pending read requests to the endpoint when RAW_IO is disabled. |
|
PIPE_TRANSFER_TIMEOUT | You expect transfers to an endpoint to complete within a specific time. |
In Windows Vista, for all transfers (except transfers with RAW_IO enabled), libusbK queues the request until all previous transfers on the destination endpoint have been completed. The host controller does not include the queuing time in the calculation of the time-out interval. With RAW_IO enabled, libusbK does not queue the request. Instead, it passes the request directly to the USB stack, whether or not the USB stack is busy processing previous transfers. If the USB stack is busy, it can delay processing the new request. Note that this can cause a time-out. |
IGNORE_SHORT_PACKETS | RAW_IO is disabled and you do not want short packets to complete the read requests. |
|
ALLOW_PARTIAL_READS |
The device can send more data than requested. This is possible if the size of your
request buffer is a multiple of the maximum endpoint packet size.
Use if your application wants to read a few bytes to determine how many total bytes to read. |
|
AUTO_FLUSH |
ALLOW_PARTIAL _READS policy is enabled.
The device can send more data than was requested, and your application does not require any additional data. This is possible if the size of your request buffer is a multiple of the maximum endpoint packet size. |
AUTO_FLUSH defines libusbK's behavior when ALLOW_PARTIAL_READS is enabled. If ALLOW_PARTIAL_READS
is disabled, the AUTO_FLUSH value is ignored by libusbK.
libusbK can either discard the remaining data or send it with the caller's next read request.
|
RAW_IO |
Performance is a priority and the application submits simultaneous read requests
to the same endpoint.
RAW_IO imposes certain restrictions on the buffer that is passed by the caller in UsbK_ReadPipe:
|
If enabled, transfers bypass queuing and error handling to boost performance for
multiple read requests. libusbK handles read requests as follows:
|
RESET_PIPE_ON_RESUME | The device does not preserve its data toggle state across suspend. | On resume from suspend, libusbK resets the endpoint before it allows the caller to send new requests to the endpoint. |
SIMUL_PARALLEL_REQUESTS | TODO: | TODO: |
ISO_START_LATENCY | TODO: | TODO: |
ISO_ALWAYS_START_ASAP | TODO: | TODO: |
ISO_NUM_FIXED_PACKETS | TODO: | TODO: |