Class for dynamic loading of winusb.
Definition at line 72 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 |
XsLibraryLoader * | m_libraryLoader |
|
private |
|
private |
XsWinUsb::XsWinUsb | ( | void | ) |
Definition at line 17 of file xswinusb.cpp.
References initLibrary(), and m_libraryLoader.
XsWinUsb::~XsWinUsb | ( | void | ) |
Definition at line 23 of file xswinusb.cpp.
References m_libraryLoader.
XsWinUsb::XsWinUsb | ( | void | ) |
XsWinUsb::~XsWinUsb | ( | void | ) |
|
private |
Definition at line 24 of file xswinusb.cpp.
References XsWinUsb::_WINUSB_API::AbortPipe, XsWinUsb::_WINUSB_API::ControlTransfer, XsWinUsb::_WINUSB_API::FlushPipe, XsWinUsb::_WINUSB_API::Free, XsWinUsb::_WINUSB_API::GetAssociatedInterface, XsWinUsb::_WINUSB_API::GetCurrentAlternateSetting, XsWinUsb::_WINUSB_API::GetDescriptor, XsWinUsb::_WINUSB_API::GetOverlappedResult, XsWinUsb::_WINUSB_API::GetPipePolicy, XsWinUsb::_WINUSB_API::GetPowerPolicy, XsWinUsb::_WINUSB_API::Initialize, m_libraryLoader, m_winUsb, XsWinUsb::_WINUSB_API::QueryDeviceInformation, XsWinUsb::_WINUSB_API::QueryInterfaceSettings, XsWinUsb::_WINUSB_API::QueryPipe, XsWinUsb::_WINUSB_API::ReadPipe, XsWinUsb::_WINUSB_API::ResetPipe, XsWinUsb::_WINUSB_API::SetCurrentAlternateSetting, XsWinUsb::_WINUSB_API::SetPipePolicy, XsWinUsb::_WINUSB_API::SetPowerPolicy, and XsWinUsb::_WINUSB_API::WritePipe.
Referenced by XsWinUsb().
|
private |
BOOL XsWinUsb::AbortPipe |
Aborts all of the pending transfers for a pipe.
[in] | InterfaceHandle | An initialized usb handle, see Initialize. |
[in] | PipeID | An 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 getextended error information. |
Definition at line 93 of file xsens/xswinusb.h.
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.
\param[in] InterfaceHandle A valid winUSB interface handle returned by: - Initialize - GetAssociatedInterface \param[in] SetupPacket The 8-byte setup packet of type WINUSB_SETUP_PACKET. \param[in,out] Buffer A caller-allocated buffer that contains the data
to transfer.
[in] | BufferLength | The 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] | LengthTransferred | A 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] | Overlapped | An 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 getextended 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 91 of file xsens/xswinusb.h.
BOOL XsWinUsb::FlushPipe |
Discards any data that is cached in a pipe.
[in] | InterfaceHandle | An initialized usb handle, see Initialize. |
[in] | PipeID | An 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 getextended error information. |
Definition at line 94 of file xsens/xswinusb.h.
BOOL XsWinUsb::Free |
Frees a WinUsb interface handle.
[in] | InterfaceHandle | Handle 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 79 of file xsens/xswinusb.h.
BOOL XsWinUsb::GetAssociatedInterface |
Retrieves a handle for an associated interface.
[in] | InterfaceHandle | An initialized usb handle, see Initialize. |
[in] | AssociatedInterfaceIndex | An 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] | AssociatedInterfaceHandle | A 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 getextended error information. |
Definition at line 80 of file xsens/xswinusb.h.
BOOL XsWinUsb::GetCurrentAlternateSetting |
Gets the current alternate interface setting for an interface. Gets the active bAlternateSetting for the current/default interface.
[in] | InterfaceHandle | An initialized usb handle, see Initialize. |
[out] | AltSettingNumber | A pointer to an unsigned character that receives an integer that indicates the current alternate setting. \returns On success, TRUE. Otherwise FALSE. Use GetLastError() to getextended error information. |
Definition at line 85 of file xsens/xswinusb.h.
BOOL XsWinUsb::GetDescriptor |
Gets the requested descriptor. This is a synchronous operation.
[in] | InterfaceHandle | An initialized usb handle, see Initialize. |
[in] | DescriptorType | A 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] | Index | The descriptor index. For an explanation of the descriptor index, see the Universal Serial Bus specification (www.usb.org). |
[in] | LanguageID | A value that specifies the language identifier, if the requested descriptor is a string descriptor. |
[out] | Buffer | A caller-allocated buffer that receives the requested descriptor. |
[in] | BufferLength | The length, in bytes, of Buffer. |
[out] | LengthTransferred | The number of bytes that were copied into Buffer. \returns On success, TRUE. Otherwise FALSE. Use GetLastError() to getextended error information. |
Definition at line 81 of file xsens/xswinusb.h.
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
nullptr, 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.
\param[in] InterfaceHandle An initialized usb handle, see \a Initialize \param[in] Overlapped A pointer to a standard windows OVERLAPPED
structure that was specified when the overlapped operation was started.
[out] | lpNumberOfBytesTransferred | A pointer to a variable that receives the number of bytes that were actually transferred by a read or write operation. |
[in] | bWait | If 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 getextended error information. |
Definition at line 97 of file xsens/xswinusb.h.
BOOL XsWinUsb::GetPipePolicy |
Gets the policy for a specific pipe (endpoint).
[in] | InterfaceHandle | An initialized usb handle, see Initialize. |
[in] | PipeID | An 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] | PolicyType | A UINT variable that specifies the policy parameter to retrieve. The current value for the policy parameter is retrieved the Value parameter. |
[in,out] | ValueLength | A 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] | Value | A pointer to a buffer that receives the specified pipe policy value. \returns On success, TRUE. Otherwise FALSE. Use GetLastError() to getextended error information. |
Definition at line 88 of file xsens/xswinusb.h.
BOOL XsWinUsb::GetPowerPolicy |
Gets the power policy for a device.
[in] | InterfaceHandle | An initialized usb handle, see Initialize |
[in] | PolicyType | A value that specifies the power policy parameter to retrieve in Value. The following table describes symbolic constants that are valid.
|
[in,out] | ValueLength | A 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] | Value | A buffer that receives the specified power policy parameter. For more information, see PolicyType. \returns On success, TRUE. Otherwise FALSE. Use GetLastError() to getextended error information. |
Definition at line 96 of file xsens/xswinusb.h.
BOOL XsWinUsb::Initialize |
Creates/opens a WinUsb interface handle from the device list.
\param[out] InterfaceHandle Receives 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] | DevInfo | The device list element to open. |
Definition at line 78 of file xsens/xswinusb.h.
|
private |
Definition at line 125 of file xsens/xswinusb.h.
Referenced by initLibrary(), XsWinUsb(), and ~XsWinUsb().
|
private |
Definition at line 124 of file xsens/xswinusb.h.
Referenced by initLibrary().
BOOL XsWinUsb::QueryDeviceInformation |
Retrieves information about the physical device that is associated with a WinUSB handle.
[in] | InterfaceHandle | An initialized usb handle, see Initialize. |
[in] | InformationType | A value that specifies which interface information value to retrieve. On input, InformationType must have the following value: DEVICE_SPEED (0x01). |
[in,out] | BufferLength | The 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] | Buffer | A caller-allocated buffer that receives the requested value. On output, Buffer indicates the device speed: (0x01) low/full speed device. (0x03) high speed device. |
Definition at line 83 of file xsens/xswinusb.h.
BOOL XsWinUsb::QueryInterfaceSettings |
Retrieves the interface descriptor for the specified alternate interface settings for a particular interface handle.
The \a 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.
\param[in] InterfaceHandle An initialized usb handle, see \a Initialize. \param[in] AltSettingIndex A 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] | UsbAltInterfaceDescriptor | A 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 getextended error information. |
Definition at line 82 of file xsens/xswinusb.h.
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.
\param[in] InterfaceHandle An initialized usb handle, see \a Initialize. \param[in] AltSettingNumber A value that specifies the alternate
interface to return the information for.
[in] | PipeIndex | A 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] | PipeInformation | A pointer, on output, to a caller-allocated WINUSB_PIPE_INFORMATION structure that contains pipe information. \returns On success, TRUE. Otherwise FALSE. Use GetLastError() to getextended error information. |
Definition at line 86 of file xsens/xswinusb.h.
BOOL XsWinUsb::ReadPipe |
Reads data from the specified pipe.
[in] | InterfaceHandle | An initialized usb handle, see Initialize. |
[in] | PipeID | An 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] | Buffer | A caller-allocated buffer that receives the data that is read. |
[in] | BufferLength | The maximum number of bytes to read. This number must be less than or equal to the size, in bytes, of Buffer. |
[out] | LengthTransferred | A pointer to a UINT variable that receives the actual number of bytes that were copied into Buffer. For more information, see Remarks. |
[in] | Overlapped | An 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 getextended error information. |
Definition at line 89 of file xsens/xswinusb.h.
BOOL XsWinUsb::ResetPipe |
Resets the data toggle and clears the stall condition on a pipe.
[in] | InterfaceHandle | An initialized usb handle, see Initialize. |
[in] | PipeID | An 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 getextended error information. |
Definition at line 92 of file xsens/xswinusb.h.
BOOL XsWinUsb::SetCurrentAlternateSetting |
Sets the alternate setting of an interface. Sets the active bAlternateSetting for the current/default interface.
[in] | InterfaceHandle | An initialized usb handle, see Initialize. |
[in] | AltSettingNumber | The 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 getextended error information. \sa QueryInterfaceSettings |
Definition at line 84 of file xsens/xswinusb.h.
BOOL XsWinUsb::SetPipePolicy |
Sets the policy for a specific pipe associated with an endpoint on the device. This is a synchronous operation.
[in] | InterfaceHandle | An initialized usb handle, see Initialize. |
[in] | PipeID | An 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] | PolicyType | A 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] | ValueLength | The size, in bytes, of the buffer at Value. |
[in] | Value | The 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 acaller-allocated UCHAR variable set to TRUE (nonzero).
|
\returns On success, TRUE. Otherwise FALSE. Use GetLastError() to get
extended error information.
Definition at line 87 of file xsens/xswinusb.h.
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.
\param[in] InterfaceHandle An initialized usb handle, see \a Initialize. \param[in] PolicyType A value that specifies the power policy to set.The following table describes symbolic constants.
- SUSPEND_DELAY (0x83) - Specifies the suspend-delay policy type; the power policyparameter must be specified by the caller in the Value parameter.
\param[in] ValueLength The size, in bytes, of the buffer at Value. \param[in] Value The new value for the power policy parameter. Datatype 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 getextended error information.
Definition at line 95 of file xsens/xswinusb.h.
BOOL XsWinUsb::WritePipe |
Writes data to a pipe.
[in] | InterfaceHandle | An initialized usb handle, see Initialize. |
[in] | PipeID | An 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] | Buffer | A caller-allocated buffer the data is written from. |
[in] | BufferLength | The maximum number of bytes to write. This number must be less than or equal to the size, in bytes, of Buffer. |
[out] | LengthTransferred | A pointer to a UINT variable that receives the actual number of bytes that were transferred from Buffer. |
[in] | Overlapped | An 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 getextended error information. |
Definition at line 90 of file xsens/xswinusb.h.
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST |