|
Module for thread assisted USB pipe streaming transfers. More...
Data Structures | |
struct | KSTM_XFER_CONTEXT |
Stream transfer context structure. More... | |
struct | KSTM_INFO |
Stream information structure. More... | |
struct | KSTM_CALLBACK |
Stream callback structure. More... | |
Typedefs | |
typedef KSTM_XFER_CONTEXT * | PKSTM_XFER_CONTEXT |
Pointer to a KSTM_XFER_CONTEXT structure. | |
typedef KSTM_INFO * | PKSTM_INFO |
Pointer to a KSTM_INFO structure. | |
typedef KSTM_CALLBACK * | PKSTM_CALLBACK |
Pointer to a KSTM_CALLBACK structure. | |
Enumerations | |
enum | KSTM_FLAG { KSTM_FLAG_NONE = 0L } |
Stream config flags. More... | |
enum | KSTM_COMPLETE_RESULT { KSTM_COMPLETE_RESULT_VALID = 0L, KSTM_COMPLETE_RESULT_INVALID } |
Stream config flags. More... | |
Functions | |
KUSB_EXP BOOL KUSB_API | StmK_Init (_out KSTM_HANDLE *StreamHandle, _in KUSB_HANDLE UsbHandle, _in UCHAR PipeID, _in INT MaxTransferSize, _in INT MaxPendingTransfers, _in INT MaxPendingIO, _inopt PKSTM_CALLBACK Callbacks, _inopt KSTM_FLAG Flags) |
Initializes a new uni-directional pipe stream. More... | |
KUSB_EXP BOOL KUSB_API | StmK_Free (_in KSTM_HANDLE StreamHandle) |
Frees resources allocated by a stream handle. More... | |
KUSB_EXP BOOL KUSB_API | StmK_Start (_in KSTM_HANDLE StreamHandle) |
Starts the internal stream thread. More... | |
KUSB_EXP BOOL KUSB_API | StmK_Stop (_in KSTM_HANDLE StreamHandle, _in INT TimeoutCancelMS) |
Stops the internal stream thread. More... | |
KUSB_EXP BOOL KUSB_API | StmK_Read (_in KSTM_HANDLE StreamHandle, _out PUCHAR Buffer, _in INT Offset, _in INT Length, _out PUINT TransferredLength) |
Reads data from the stream buffer. More... | |
KUSB_EXP BOOL KUSB_API | StmK_Write (_in KSTM_HANDLE StreamHandle, _in PUCHAR Buffer, _in INT Offset, _in INT Length, _out PUINT TransferredLength) |
Writes data to the stream buffer. More... | |
INT KUSB_API | KSTM_ERROR_CB (_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _in INT ErrorCode) |
Function definition for an optional user-defined callback; executed when a transfer error occurs. | |
INT KUSB_API | KSTM_SUBMIT_CB (_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _in LPOVERLAPPED Overlapped) |
Function definition for an optional user-defined callback; executed to submit a transfer. | |
INT KUSB_API | KSTM_STARTED_CB (_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex) |
Function definition for an optional user-defined callback; executed for each transfer context when the stream is started with StmK_Start. | |
INT KUSB_API | KSTM_STOPPED_CB (_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex) |
Function definition for an optional user-defined callback; executed for each transfer context when the stream is stopped with StmK_Stop. | |
INT KUSB_API | KSTM_COMPLETE_CB (_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _in INT ErrorCode) |
Function definition for an optional user-defined callback; executed when a valid transfer completes. | |
KSTM_COMPLETE_RESULT KUSB_API | KSTM_BEFORE_COMPLETE_CB (_in PKSTM_INFO StreamInfo, _in PKSTM_XFER_CONTEXT XferContext, _in INT XferContextIndex, _ref PINT ErrorCode) |
Function definition for an optional user-defined callback; executed immediately after a transfer completes. More... | |
Module for thread assisted USB pipe streaming transfers.
enum KSTM_FLAG |
enum KSTM_COMPLETE_RESULT |
KUSB_EXP BOOL KUSB_API StmK_Init | ( | _out KSTM_HANDLE * | StreamHandle, |
_in KUSB_HANDLE | UsbHandle, | ||
_in UCHAR | PipeID, | ||
_in INT | MaxTransferSize, | ||
_in INT | MaxPendingTransfers, | ||
_in INT | MaxPendingIO, | ||
_inopt PKSTM_CALLBACK | Callbacks, | ||
_inopt KSTM_FLAG | Flags | ||
) |
Initializes a new uni-directional pipe stream.
[out] | StreamHandle | On success, receives the new stream handle. |
[in] | UsbHandle | Usb handle to associate with this stream. |
[in] | PipeID | Endpoint address of USB pipe to associate with this stream. |
[in] | MaxTransferSize | Maximum number of bytes transferred at once. Larger transfers committed with the stream read/write functions are automatically split into multiple smaller chunks. |
[in] | MaxPendingTransfers | Maximum number of transfers allowed to be outstanding and the total number of transfer contexts that are allocated to the stream. |
[in] | MaxPendingIO | Maximum number of I/O requests the internal stream thread is allowed to have submit at any given time. (Pending I/O) |
[in] | Callbacks | Optional user callback functions. If specified, these callback functions will be executed in real time (from within the context of the internal stream thread) as transfers go through the various states. |
[in] | Flags | Additional stream flags. |
GetLastError()
to get extended error information.KUSB_EXP BOOL KUSB_API StmK_Free | ( | _in KSTM_HANDLE | StreamHandle | ) |
Frees resources allocated by a stream handle.
[in] | StreamHandle | The stream handle to free. |
If the stream is currently started it is automatically stopped before its resources are freed.
KUSB_EXP BOOL KUSB_API StmK_Start | ( | _in KSTM_HANDLE | StreamHandle | ) |
Starts the internal stream thread.
[in] | StreamHandle | The stream to start. A stream handle is created with StmK_Init. |
GetLastError()
to get extended error information.KUSB_EXP BOOL KUSB_API StmK_Stop | ( | _in KSTM_HANDLE | StreamHandle, |
_in INT | TimeoutCancelMS | ||
) |
Stops the internal stream thread.
[in] | StreamHandle | The stream to stop. |
[in] | TimeoutCancelMS | Number of milliseconds the internal stream thread should wait for pending I/O to complete before cancelling all pending requests. |
GetLastError()
to get extended error information. KUSB_EXP BOOL KUSB_API StmK_Read | ( | _in KSTM_HANDLE | StreamHandle, |
_out PUCHAR | Buffer, | ||
_in INT | Offset, | ||
_in INT | Length, | ||
_out PUINT | TransferredLength | ||
) |
Reads data from the stream buffer.
[in] | StreamHandle | The stream to read. |
[out] | Buffer | A caller-allocated buffer that receives the data that is read. |
[in] | Offset | Read start offset of Buffer . |
[in] | Length | Size of Buffer . |
[out] | TransferredLength | On success, receives the actual number of bytes that were copied into Buffer . |
GetLastError()
to get extended error information.MaxPendingIO
, the stream completes the oldest PendingTransfer and moves it into a FIFO complete where it awaits user processing via the StmK_Read function.KUSB_EXP BOOL KUSB_API StmK_Write | ( | _in KSTM_HANDLE | StreamHandle, |
_in PUCHAR | Buffer, | ||
_in INT | Offset, | ||
_in INT | Length, | ||
_out PUINT | TransferredLength | ||
) |
Writes data to the stream buffer.
[in] | StreamHandle | The stream to write. |
[in] | Buffer | A caller-allocated buffer the data is written from. |
[in] | Offset | Write start offset of Buffer . |
[in] | Length | Number of bytes to copy into the stream buffer. |
[out] | TransferredLength | On success, receives the actual number of bytes that were copied into the stream buffer. |
GetLastError()
to get extended error information.KSTM_COMPLETE_RESULT KUSB_API KSTM_BEFORE_COMPLETE_CB | ( | _in PKSTM_INFO | StreamInfo, |
_in PKSTM_XFER_CONTEXT | XferContext, | ||
_in INT | XferContextIndex, | ||
_ref PINT | ErrorCode | ||
) |
Function definition for an optional user-defined callback; executed immediately after a transfer completes.
This callback function allows the user to accept or reject the transfer: