Download WinDriver™ USB User`s Manual - Version 10.1.1

Transcript
USB Transfers
You can also perform single blocking transfers using the DriverWizard utility (which uses the
WDU_Transfer function), as demonstrated in section 5.2 of the manual.
9.3.3 Streaming Data Transfers
In the streaming USB data transfer scheme, data is continuously streamed between the host and
the device, using internal buffers allocated by the host driver – "streams".
Stream transfers allow for a sequential data flow between the host and the device, and can
be used to reduce single blocking transfer overhead, which may occur as a result of multiple
function calls and context switches between user and kernel modes. This is especially relevant
for devices with small data buffers, which might, for example, overwrite data before the host is
able to read it, due to a gap in the data flow between the host and device.
9.3.3.1 Performing Streaming with WinDriver
WinDriver's WDU_StreamXXX functions, described in section B.4.9 of the manual, enable
you to impelment USB streaming data transfers. Note: These functions are currently supported
on Windows and Windows CE.
To begin performing stream transfers, call the WDU_StreamOpen function [B.4.9.1]. When
this function is called, WinDriver creates a new stream object for the specified data pipe. You
can open a stream for any pipe except for the control pipe (Pipe 0). The stream's data transfer
direction – read/write – is derived from the direction of its pipe.
WinDriver supports both blocking and non-blocking stream transfers. The open function's
fBlocking parameter indicates which type of transfer to perform (see explanation below).
Streams that perform blocking transfers will henceforth be referred to as "blocking streams",
and streams that perform non-blocking transfers will be referred to as "non-blocking streams".
The function's dwRxTxTimeout parameter indicates the desired timeout period for transfers
between the stream and the device.
After opening a stream, call WDU_StreamStart [B.4.9.2] to begin data transfers between
the stream's data buffer and the device.
In the case of a read stream, the driver will constantly read data from the device into the
stream's buffer, in blocks of a pre-defined size (as set in the dwRxSize parameter of the
WDU_StreamOpen function [B.4.9.1]. In the case of a write stream, the driver will constantly
check for data in the stream's data buffer and write any data that is found to the device.
To read data from a read stream to the user-mode host application, call
WDU_StreamRead [B.4.9.3].
In case of a blocking stream, the read function blocks until the entire amount of data requested
by the application is transferred from the stream to the application, or until the stream's attempt
to read data from the device times out.
In the case of a non-blocking stream, the function transfers to the application as much of the
requested data as possible, subject to the amount of data currently available in the stream's data
buffer, and returns immediately.
To write data from the user-mode host application to a write the stream, call
WDU_StreamWrite [B.4.9.4].
© Jungo Software Technologies 2005–2010
77