Main MRPT website > C++ reference for MRPT 1.5.9
List of all members | Classes | Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes
XsWinUsb Class Reference

Detailed Description

Class for dynamic loading of winusb.

Definition at line 38 of file xsens/xswinusb.h.

#include <xSens_MT4/xcommunication/include/xsens/xswinusb.h>

Classes

struct  _WINUSB_API
 

Public Member Functions

 XsWinUsb (void)
 
 ~XsWinUsb (void)
 
 XsWinUsb (void)
 
 ~XsWinUsb (void)
 

Public Attributes

WinUSB_Initialize Initialize
 Creates/opens a WinUsb interface handle from the device list. More...
 
WinUSB_Free Free
 Frees a WinUsb interface handle. More...
 
WinUSB_GetAssociatedInterface GetAssociatedInterface
 Retrieves a handle for an associated interface. More...
 
WinUSB_GetDescriptor GetDescriptor
 Gets the requested descriptor. This is a synchronous operation. More...
 
WinUSB_QueryInterfaceSettings QueryInterfaceSettings
 Retrieves the interface descriptor for the specified alternate interface settings for a particular interface handle. More...
 
WinUSB_QueryDeviceInformation QueryDeviceInformation
 Retrieves information about the physical device that is associated with a WinUSB handle. More...
 
WinUSB_SetCurrentAlternateSetting SetCurrentAlternateSetting
 Sets the alternate setting of an interface. Sets the active bAlternateSetting for the current/default interface. More...
 
WinUSB_GetCurrentAlternateSetting GetCurrentAlternateSetting
 Gets the current alternate interface setting for an interface. Gets the active bAlternateSetting for the current/default interface. More...
 
WinUSB_QueryPipe QueryPipe
 Retrieves information about a pipe that is associated with an interface. The QueryPipe function does not retrieve information about the control pipe. More...
 
WinUSB_SetPipePolicy SetPipePolicy
 Sets the policy for a specific pipe associated with an endpoint on the device. This is a synchronous operation. More...
 
WinUSB_GetPipePolicy GetPipePolicy
 Gets the policy for a specific pipe (endpoint). More...
 
WinUSB_ReadPipe ReadPipe
 Reads data from the specified pipe. More...
 
WinUSB_WritePipe WritePipe
 Writes data to a pipe. More...
 
WinUSB_ControlTransfer ControlTransfer
 Transmits control data over a default control endpoint. A ControlTransfer is never cached. These requests always go directly to the usb device. More...
 
WinUSB_ResetPipe ResetPipe
 Resets the data toggle and clears the stall condition on a pipe. More...
 
WinUSB_AbortPipe AbortPipe
 Aborts all of the pending transfers for a pipe. More...
 
WinUSB_FlushPipe FlushPipe
 Discards any data that is cached in a pipe. More...
 
WinUSB_SetPowerPolicy SetPowerPolicy
 Sets the power policy for a device. The following list summarizes the effects of changes to power management states: More...
 
WinUSB_GetPowerPolicy GetPowerPolicy
 Gets the power policy for a device. More...
 
WinUSB_GetOverlappedResult GetOverlappedResult
 Retrieves the results of an overlapped operation on the specified winUSB handle. More...
 

Private Types

typedef struct XsWinUsb::_WINUSB_API WINUSB_API
 
typedef struct XsWinUsb::_WINUSB_API WINUSB_API
 

Private Member Functions

void initLibrary ()
 
void initLibrary ()
 

Private Attributes

WINUSB_API m_winUsb
 
XsLibraryLoaderm_libraryLoader
 

Member Typedef Documentation

◆ WINUSB_API [1/2]

◆ WINUSB_API [2/2]

Constructor & Destructor Documentation

◆ XsWinUsb() [1/2]

XsWinUsb::XsWinUsb ( void  )

Definition at line 17 of file xswinusb.cpp.

References initLibrary(), and m_libraryLoader.

◆ ~XsWinUsb() [1/2]

XsWinUsb::~XsWinUsb ( void  )

Definition at line 23 of file xswinusb.cpp.

References m_libraryLoader.

◆ XsWinUsb() [2/2]

XsWinUsb::XsWinUsb ( void  )

◆ ~XsWinUsb() [2/2]

XsWinUsb::~XsWinUsb ( void  )

Member Function Documentation

◆ initLibrary() [1/2]

void XsWinUsb::initLibrary ( )
private

◆ initLibrary() [2/2]

void XsWinUsb::initLibrary ( )
private

Member Data Documentation

◆ AbortPipe

BOOL XsWinUsb::AbortPipe

Aborts all of the pending transfers for a pipe.

Parameters
[in]InterfaceHandleAn initialized usb handle, see Initialize.
[in]PipeIDAn 8-bit value that consists of a 7-bit address and a direction bit. This parameter corresponds to the bEndpointAddress field in the endpoint descriptor.
\returns On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Definition at line 59 of file xsens/xswinusb.h.

◆ ControlTransfer

BOOL XsWinUsb::ControlTransfer

Transmits control data over a default control endpoint. A ControlTransfer is never cached. These requests always go directly to the usb device.

Parameters
[in]InterfaceHandleA valid winUSB interface handle returned by:
  • Initialize
  • GetAssociatedInterface
[in]SetupPacketThe 8-byte setup packet of type WINUSB_SETUP_PACKET.
[in,out]BufferA caller-allocated buffer that contains the data to transfer.
[in]BufferLengthThe number of bytes to transfer, not including the setup packet. This number must be less than or equal to the size, in bytes, of Buffer.
[out]LengthTransferredA pointer to a UINT variable that receives the actual number of transferred bytes. If the application does not expect any data to be transferred during the data phase (BufferLength is zero), LengthTransferred can be NULL.
[in]OverlappedAn optional pointer to an OVERLAPPED structure, which is used for asynchronous operations. If this parameter is specified, ControlTransfer immediately returns, and the event is signaled when the operation is complete. If Overlapped is not supplied, the ControlTransfer function transfers data synchronously.
\returns On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information. If an Overlapped member is supplied and the operation succeeds this function returns FALSE and sets last error to ERROR_IO_PENDING.

Definition at line 57 of file xsens/xswinusb.h.

◆ FlushPipe

BOOL XsWinUsb::FlushPipe

Discards any data that is cached in a pipe.

Parameters
[in]InterfaceHandleAn initialized usb handle, see Initialize.
[in]PipeIDAn 8-bit value that consists of a 7-bit address and a direction bit. This parameter corresponds to the bEndpointAddress field in the endpoint descriptor.
\returns On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Definition at line 60 of file xsens/xswinusb.h.

◆ Free

BOOL XsWinUsb::Free

Frees a WinUsb interface handle.

Parameters
[in]InterfaceHandleHandle to an interface on the device. This handle must be created by a previous call to see Initialize or GetAssociatedInterface.
\returns TRUE

\sa GetAssociatedInterface.

Definition at line 45 of file xsens/xswinusb.h.

◆ GetAssociatedInterface

BOOL XsWinUsb::GetAssociatedInterface

Retrieves a handle for an associated interface.

Parameters
[in]InterfaceHandleAn initialized usb handle, see Initialize.
[in]AssociatedInterfaceIndexAn index that specifies the associated interface to retrieve. A value of 0 indicates the first associated interface, a value of 1 indicates the second associated interface, and so on.
[out]AssociatedInterfaceHandleA handle for the associated interface. Callers must pass this interface handle to WinUsb Functions exposed by WinUsb.dll. To close this handle, call Free.
\returns On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Definition at line 46 of file xsens/xswinusb.h.

◆ GetCurrentAlternateSetting

BOOL XsWinUsb::GetCurrentAlternateSetting

Gets the current alternate interface setting for an interface. Gets the active bAlternateSetting for the current/default interface.

Parameters
[in]InterfaceHandleAn initialized usb handle, see Initialize.
[out]AltSettingNumberA pointer to an unsigned character that receives an integer that indicates the current alternate setting.
\returns On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Definition at line 51 of file xsens/xswinusb.h.

◆ GetDescriptor

BOOL XsWinUsb::GetDescriptor

Gets the requested descriptor. This is a synchronous operation.

Parameters
[in]InterfaceHandleAn initialized usb handle, see Initialize.
[in]DescriptorTypeA value that specifies the type of descriptor to return. This parameter corresponds to the bDescriptorType field of a standard device descriptor, whose values are described in the Universal Serial Bus specification.
[in]IndexThe descriptor index. For an explanation of the descriptor index, see the Universal Serial Bus specification (www.usb.org).
[in]LanguageIDA value that specifies the language identifier, if the requested descriptor is a string descriptor.
[out]BufferA caller-allocated buffer that receives the requested descriptor.
[in]BufferLengthThe length, in bytes, of Buffer.
[out]LengthTransferredThe number of bytes that were copied into Buffer.
\returns On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Definition at line 47 of file xsens/xswinusb.h.

◆ GetOverlappedResult

BOOL XsWinUsb::GetOverlappedResult

Retrieves the results of an overlapped operation on the specified winUSB handle.

This function is like the Win32 API routine, GetOverlappedResult, with one difference; instead of passing a file handle that is returned from CreateFile, the caller passes an interface handle that is returned from Initialize, or GetAssociatedInterface. The caller can use either API routine, if the appropriate handle is passed. The GetOverlappedResult function extracts the file handle from the interface handle and then calls GetOverlappedResult. The results that are reported by the GetOverlappedResult function are those from the specified handle's last overlapped operation to which the specified standard windows OVERLAPPED structure was provided, and for which the operation's results were pending. A pending operation is indicated when the function that started the operation returns FALSE, and the GetLastError routine returns ERROR_IO_PENDING. When an I/O operation is pending, the function that started the operation resets the hEvent member of the standard windows OVERLAPPED structure to the nonsignaled state. Then when the pending operation has been completed, the system sets the event object to the signaled state. The caller can specify that an event object is manually reset in the standard windows OVERLAPPED structure. If an automatic reset event object is used, the event handle must not be specified in any other wait operation in the interval between starting the overlapped operation and the call to GetOverlappedResult. For example, the event object is sometimes specified in one of the wait routines to wait for the operation to be completed. When the wait routine returns, the system sets an auto-reset event's state to nonsignaled, and a successive call to GetOverlappedResult with the bWait parameter set to TRUE causes the function to be blocked indefinitely. If the bWait parameter is TRUE, GetOverlappedResult determines whether the pending operation has been completed by waiting for the event object to be in the signaled state.

If the hEvent member of the standard windows OVERLAPPED structure is NULL, the system uses the state of the file handle to signal when the operation has been completed. Do not use file handles for this purpose. It is better to use an event object because of the confusion that can occur when multiple concurrent overlapped operations are performed on the same file. In this situation, you cannot know which operation caused the state of the object to be signaled.

Parameters
[in]InterfaceHandleAn initialized usb handle, see Initialize
[in]OverlappedA pointer to a standard windows OVERLAPPED structure that was specified when the overlapped operation was started.
[out]lpNumberOfBytesTransferredA pointer to a variable that receives the number of bytes that were actually transferred by a read or write operation.
[in]bWaitIf this parameter is TRUE, the function does not return until the operation has been completed. If this parameter is FALSE and the operation is still pending, the function returns FALSE and the GetLastError function returns ERROR_IO_INCOMPLETE.
\returns On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Definition at line 63 of file xsens/xswinusb.h.

◆ GetPipePolicy

BOOL XsWinUsb::GetPipePolicy

Gets the policy for a specific pipe (endpoint).

Parameters
[in]InterfaceHandleAn initialized usb handle, see Initialize.
[in]PipeIDAn 8-bit value that consists of a 7-bit address and a direction bit. This parameter corresponds to the bEndpointAddress field in the endpoint descriptor.
[in]PolicyTypeA UINT variable that specifies the policy parameter to retrieve. The current value for the policy parameter is retrieved the Value parameter.
[in,out]ValueLengthA pointer to the size, in bytes, of the buffer that Value points to. On output, ValueLength receives the size, in bytes, of the data that was copied into the Value buffer.
[out]ValueA pointer to a buffer that receives the specified pipe policy value.
\returns On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Definition at line 54 of file xsens/xswinusb.h.

◆ GetPowerPolicy

BOOL XsWinUsb::GetPowerPolicy

Gets the power policy for a device.

Parameters
[in]InterfaceHandleAn initialized usb handle, see Initialize
[in]PolicyTypeA value that specifies the power policy parameter to retrieve in Value. The following table describes symbolic constants that are valid.
  • AUTO_SUSPEND (0x81)
    • If the caller specifies a power policy of AUTO_SUSPEND, GetPowerPolicy returns the value of the auto suspend policy parameter in the Value parameter.
    • If Value is TRUE (that is, nonzero), the USB stack suspends the device when no transfers are pending or the only transfers pending are IN transfers on an interrupt or bulk endpoint.
    • The value of the DefaultIdleState registry value determines the default value of the auto suspend policy parameter.
    • The Value parameter must point to a UCHAR variable.
  • SUSPEND_DELAY (0x83)
    • If the caller specifies a power policy of SUSPEND_DELAY, GetPowerPolicy returns the value of the suspend delay policy parameter in Value.
    • The suspend delay policy parameter specifies the minimum amount of time, in milliseconds, that the driver must wait after any transfer before it can suspend the device.
    • Value must point to a UINT variable.
[in,out]ValueLengthA pointer to the size of the buffer that Value. On output, ValueLength receives the size of the data that was copied into the Value buffer.
[out]ValueA buffer that receives the specified power policy parameter. For more information, see PolicyType.
\returns On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Definition at line 62 of file xsens/xswinusb.h.

◆ Initialize

BOOL XsWinUsb::Initialize

Creates/opens a WinUsb interface handle from the device list.

Parameters
[out]InterfaceHandleReceives a handle configured to the first (default) interface on the device. This handle is required by other WinUsb routines that perform operations on the default interface. The handle is opaque. To release this handle, call the Free function.
[in]DevInfoThe device list element to open.
\returns On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Definition at line 44 of file xsens/xswinusb.h.

◆ m_libraryLoader

XsLibraryLoader * XsWinUsb::m_libraryLoader
private

Definition at line 92 of file xsens/xswinusb.h.

Referenced by initLibrary(), XsWinUsb(), and ~XsWinUsb().

◆ m_winUsb

WINUSB_API XsWinUsb::m_winUsb
private

Definition at line 91 of file xsens/xswinusb.h.

Referenced by initLibrary().

◆ QueryDeviceInformation

BOOL XsWinUsb::QueryDeviceInformation

Retrieves information about the physical device that is associated with a WinUSB handle.

Parameters
[in]InterfaceHandleAn initialized usb handle, see Initialize.
[in]InformationTypeA value that specifies which interface information value to retrieve. On input, InformationType must have the following value: DEVICE_SPEED (0x01).
[in,out]BufferLengthThe maximum number of bytes to read. This number must be less than or equal to the size, in bytes, of Buffer. On output, BufferLength is set to the actual number of bytes that were copied into Buffer.
[in,out]BufferA caller-allocated buffer that receives the requested value. On output, Buffer indicates the device speed: (0x01) low/full speed device. (0x03) high speed device.
Returns
On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Definition at line 49 of file xsens/xswinusb.h.

◆ QueryInterfaceSettings

BOOL XsWinUsb::QueryInterfaceSettings

Retrieves the interface descriptor for the specified alternate interface settings for a particular interface handle.

The QueryInterfaceSettings call searches the current/default interface array for the alternate interface specified by the caller in the AltSettingIndex. If the specified alternate interface is found, the function populates the caller-allocated USB_INTERFACE_DESCRIPTOR structure. If the specified alternate interface is not found, then the call fails with the ERROR_NO_MORE_ITEMS code.

Parameters
[in]InterfaceHandleAn initialized usb handle, see Initialize.
[in]AltSettingIndexA value that indicates which alternate setting index to return. A value of 0 indicates the first alternate setting, a value of 1 indicates the second alternate setting, and so on.
[out]UsbAltInterfaceDescriptorA pointer to a caller-allocated USB_INTERFACE_DESCRIPTOR structure that contains information about the interface that AltSettingNumber specified.
\returns On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Definition at line 48 of file xsens/xswinusb.h.

◆ QueryPipe

BOOL XsWinUsb::QueryPipe

Retrieves information about a pipe that is associated with an interface. The QueryPipe function does not retrieve information about the control pipe.

Each interface on the USB device can have multiple endpoints. To communicate with each of these endpoints, the bus driver creates pipes for each endpoint on the interface. The pipe indices are zero-based. Therefore for n number of endpoints, the pipes' indices are set from n-1. QueryPipe parses the configuration descriptor to get the interface specified by the caller. It searches the interface descriptor for the endpoint descriptor associated with the caller-specified pipe. If the endpoint is found, the function populates the caller-allocated WINUSB_PIPE_INFORMATION structure with information from the endpoint descriptor.

Parameters
[in]InterfaceHandleAn initialized usb handle, see Initialize.
[in]AltSettingNumberA value that specifies the alternate interface to return the information for.
[in]PipeIndexA value that specifies the pipe to return information about. This value is not the same as the bEndpointAddress field in the endpoint descriptor. A PipeIndex value of 0 signifies the first endpoint that is associated with the interface, a value of 1 signifies the second endpoint, and so on. PipeIndex must be less than the value in the bNumEndpoints field of the interface descriptor.
[out]PipeInformationA pointer, on output, to a caller-allocated WINUSB_PIPE_INFORMATION structure that contains pipe information.
\returns On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Definition at line 52 of file xsens/xswinusb.h.

◆ ReadPipe

BOOL XsWinUsb::ReadPipe

Reads data from the specified pipe.

Parameters
[in]InterfaceHandleAn initialized usb handle, see Initialize.
[in]PipeIDAn 8-bit value that consists of a 7-bit address and a direction bit. This parameter corresponds to the bEndpointAddress field in the endpoint descriptor.
[out]BufferA caller-allocated buffer that receives the data that is read.
[in]BufferLengthThe maximum number of bytes to read. This number must be less than or equal to the size, in bytes, of Buffer.
[out]LengthTransferredA pointer to a UINT variable that receives the actual number of bytes that were copied into Buffer. For more information, see Remarks.
[in]OverlappedAn optional pointer to an overlapped structure for asynchronous operations. This can be a KOVL_HANDLE or a pointer to a standard windows OVERLAPPED structure. If this parameter is specified, ReadPipe returns immediately rather than waiting synchronously for the operation to complete before returning. An event is signaled when the operation is complete.
Returns
On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Definition at line 55 of file xsens/xswinusb.h.

◆ ResetPipe

BOOL XsWinUsb::ResetPipe

Resets the data toggle and clears the stall condition on a pipe.

Parameters
[in]InterfaceHandleAn initialized usb handle, see Initialize.
[in]PipeIDAn 8-bit value that consists of a 7-bit address and a direction bit. This parameter corresponds to the bEndpointAddress field in the endpoint descriptor.
\returns On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Definition at line 58 of file xsens/xswinusb.h.

◆ SetCurrentAlternateSetting

BOOL XsWinUsb::SetCurrentAlternateSetting

Sets the alternate setting of an interface. Sets the active bAlternateSetting for the current/default interface.

Parameters
[in]InterfaceHandleAn initialized usb handle, see Initialize.
[in]AltSettingNumberThe value that is contained in the bAlternateSetting member of the USB_INTERFACE_DESCRIPTOR structure. This structure can be populated by the QueryInterfaceSettings routine.
\returns On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

\sa QueryInterfaceSettings

Definition at line 50 of file xsens/xswinusb.h.

◆ SetPipePolicy

BOOL XsWinUsb::SetPipePolicy

Sets the policy for a specific pipe associated with an endpoint on the device. This is a synchronous operation.

Parameters
[in]InterfaceHandleAn initialized usb handle, see Initialize.
[in]PipeIDAn 8-bit value that consists of a 7-bit address and a direction bit. This parameter corresponds to the bEndpointAddress field in the endpoint descriptor.
[in]PolicyTypeA UINT variable that specifies the policy parameter to change. The Value parameter contains the new value for the policy parameter. See the remarks section for information about each of the pipe policies and the resulting behavior.
[in]ValueLengthThe size, in bytes, of the buffer at Value.
[in]ValueThe new value for the policy parameter that PolicyType specifies. The size of this input parameter depends on the policy to change. For information about the size of this parameter, see the description of the PolicyType parameter.
\remarks
The following list describes symbolic constants for \a PolicyType

- SHORT_PACKET_TERMINATE (0x01)
    - The default value is FALSE.
    - To enable SHORT_PACKET_TERMINATE, in Value pass the address of a caller-allocated UCHAR variable set to TRUE (nonzero).
    - Enabling SHORT_PACKET_TERMINATE causes the driver to send a zero-length packet at the end of every write request to the host controller.

- AUTO_CLEAR_STALL (0x02)
    - The default value is FALSE. To enable AUTO_CLEAR_STALL, in Value pass the address of a caller-allocated UCHAR variable set to TRUE (nonzero).
    - Enabling AUTO_CLEAR_STALL causes winUSB to reset the pipe in order to automatically clear the stall condition. Data continues to flow on the bulk and interrupt IN endpoints again as soon as a new or a queued transfer arrives on the endpoint. This policy parameter does not affect control pipes.
    - Disabling AUTO_CLEAR_STALL causes all transfers (that arrive to the endpoint after the stalled transfer) to fail until the caller manually resets the endpoint's pipe by calling ResetPipe.

- PIPE_TRANSFER_TIMEOUT (0x03)
    - The default value is zero. To set a time-out value, in Value pass the address of a caller-allocated UINT variable that contains the time-out interval.
    - The PIPE_TRANSFER_TIMEOUT value specifies the time-out interval, in milliseconds. The host controller cancels transfers that do not complete within the specified time-out interval.
    - A value of zero (default) indicates that transfers do not time out because the host controller never cancels the transfer.

- IGNORE_SHORT_PACKETS (0x04)
    - The default value is FALSE. To enable IGNORE_SHORT_PACKETS, in Value pass the address of a caller-allocated UCHAR variable set to TRUE (nonzero).
    - Enabling IGNORE_SHORT_PACKETS causes the host controller to not complete a read operation after it receives a short packet. Instead, the host controller completes the operation only after the host has read the specified number of bytes.
    - Disabling IGNORE_SHORT_PACKETS causes the host controller to complete a read operation when either the host has read the specified number of bytes or the host has received a short packet.

- ALLOW_PARTIAL_READS (0x05)
    - The default value is TRUE (nonzero). To disable ALLOW_PARTIAL_READS, in Value pass the address of a caller-allocated UCHAR variable set to FALSE (zero).
    - Disabling ALLOW_PARTIAL_READS causes the read requests to fail whenever the device returns more data (on bulk and interrupt IN endpoints) than the caller requested.
    - Enabling ALLOW_PARTIAL_READS causes winUSB to save or discard the extra data when the device returns more data (on bulk and interrupt IN endpoints) than the caller requested. This behavior is defined by setting the AUTO_FLUSH value.

- AUTO_FLUSH (0x06)
    - The default value is FALSE (zero). To enable AUTO_FLUSH, in Value pass the address of a caller-allocated UCHAR variable set to TRUE (nonzero).
    - AUTO_FLUSH must be used with ALLOW_PARTIAL_READS enabled. If ALLOW_PARTIAL_READS is TRUE, the value of AUTO_FLUSH determines the action taken by winUSB when the device returns more data than the caller requested.
    - Disabling ALLOW_PARTIAL_READS causes winUSB to ignore the AUTO_FLUSH value.
    - Disabling AUTO_FLUSH with ALLOW_PARTIAL_READS enabled causes winUSB to save the extra data, add the data to the beginning of the caller's next read request, and send it to the caller in the next read operation.
    - Enabling AUTO_FLUSH with ALLOW_PARTIAL_READS enabled causes winUSB to discard the extra data remaining from the read request.

- RAW_IO (0x07)
    - The default value is FALSE (zero). To enable RAW_IO, in Value pass the address of a caller-allocated UCHAR variable set to TRUE (nonzero).
    - Enabling RAW_IO causes winUSB to send data directly to the USB driver stack, bypassing winUSB's queuing and error handling mechanism.
    - The buffers that are passed to \a ReadPipe must be configured by the caller as follows:
    - The buffer length must be a multiple of the maximum endpoint packet size.
    - The length must be less than or equal to the value of MAXIMUM_TRANSFER_SIZE retrieved by GetPipePolicy.
    - Disabling RAW_IO (FALSE) does not impose any restriction on the buffers that are passed to \a ReadPipe.

- RESET_PIPE_ON_RESUME (0x09)
    - The default value is FALSE (zero). To enable RESET_PIPE_ON_RESUME, in Value pass the address of a caller-allocated UCHAR variable set to TRUE (nonzero).
    - TRUE (or a nonzero value) indicates that on resume from suspend, winUSB resets the endpoint before it allows the caller to send new requests to the endpoint.


\returns On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Definition at line 53 of file xsens/xswinusb.h.

◆ SetPowerPolicy

BOOL XsWinUsb::SetPowerPolicy

Sets the power policy for a device. The following list summarizes the effects of changes to power management states:

  • All pipe handles, interface handles, locks, and alternate settings are preserved across power management events.
  • Any transfers that are in progress are suspended when a device transfers to a low power state, and they are resumed when the device is restored to a working state.
  • The device and system must be in a working state before the client can restore a device-specific configuration. Clients can determine whether the device and system are in a working state from the WM_POWERBROADCAST message.
  • The client can indicate that an interface is idle by calling SetPowerPolicy.
Parameters
[in]InterfaceHandleAn initialized usb handle, see Initialize.
[in]PolicyTypeA value that specifies the power policy to set. The following table describes symbolic constants.
  • AUTO_SUSPEND (0x81)
    • Specifies the auto-suspend policy type; the power policy parameter must be specified by the caller in the Value parameter.
    • For auto-suspend, the Value parameter must point to a UCHAR variable.
    • If Value is TRUE (nonzero), the USB stack suspends the device if the device is idle. A device is idle if there are no transfers pending, or if the only pending transfers are IN transfers to interrupt or bulk endpoints.
    • The default value is determined by the value set in the DefaultIdleState registry setting. By default, this value is TRUE.
  • SUSPEND_DELAY (0x83)
    • Specifies the suspend-delay policy type; the power policy parameter must be specified by the caller in the Value parameter.
    • For suspend-delay, Value must point to a UINT variable.
    • Value specifies the minimum amount of time, in milliseconds, that the driver must wait post transfer before it can suspend the device.
    • The default value is determined by the value set in the DefaultIdleTimeout registry setting. By default, this value is five seconds.
[in]ValueLengthThe size, in bytes, of the buffer at Value.
[in]ValueThe new value for the power policy parameter. Data type and value for Value depends on the type of power policy passed in PolicyType. For more information, see PolicyType.
\returns On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Definition at line 61 of file xsens/xswinusb.h.

◆ WritePipe

BOOL XsWinUsb::WritePipe

Writes data to a pipe.

Parameters
[in]InterfaceHandleAn initialized usb handle, see Initialize.
[in]PipeIDAn 8-bit value that consists of a 7-bit address and a direction bit. This parameter corresponds to the bEndpointAddress field in the endpoint descriptor.
[in]BufferA caller-allocated buffer the data is written from.
[in]BufferLengthThe maximum number of bytes to write. This number must be less than or equal to the size, in bytes, of Buffer.
[out]LengthTransferredA pointer to a UINT variable that receives the actual number of bytes that were transferred from Buffer.
[in]OverlappedAn optional pointer to an overlapped structure for asynchronous operations. This can be a KOVL_HANDLE or a pointer to a standard windows OVERLAPPED structure. If this parameter is specified, WritePipe returns immediately rather than waiting synchronously for the operation to complete before returning. An event is signaled when the operation is complete.
Returns
On success, TRUE. Otherwise FALSE. Use GetLastError() to get extended error information.

Definition at line 56 of file xsens/xswinusb.h.




Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020