This class handles the USB communication with an usb device that has one in and one out endpoint.
More...
#include <usbdevice.h>
|
|
| USBDevice (DSOModel *model, libusb_device *device, unsigned findIteration=0) |
| |
|
| USBDevice (const USBDevice &)=delete |
| |
|
bool | connectDevice (QString &errorMessage) |
| |
|
void | disconnectFromDevice () |
| |
| bool | isConnected () |
| | Check if the oscilloscope is connected. More...
|
| |
| bool | needsFirmware () |
| |
| void | setFindIteration (unsigned iteration) |
| |
|
unsigned | getFindIteration () const |
| |
| int | bulkTransfer (unsigned char endpoint, const unsigned char *data, unsigned int length, int attempts=HANTEK_ATTEMPTS, unsigned int timeout=HANTEK_TIMEOUT) |
| | Bulk transfer to/from the oscilloscope. More...
|
| |
| int | bulkWrite (const unsigned char *data, unsigned int length, int attempts=HANTEK_ATTEMPTS) |
| | Bulk write to the oscilloscope. More...
|
| |
| template<class T > |
| int | bulkRead (const T *command, int attempts=HANTEK_ATTEMPTS) |
| | Bulk read from the oscilloscope. More...
|
| |
| int | bulkReadMulti (unsigned char *data, unsigned length, int attempts=HANTEK_ATTEMPTS_MULTI) |
| | Multi packet bulk read from the oscilloscope. More...
|
| |
| int | controlTransfer (unsigned char type, unsigned char request, unsigned char *data, unsigned int length, int value, int index, int attempts=HANTEK_ATTEMPTS) |
| | Control transfer to the oscilloscope. More...
|
| |
| template<class T > |
| int | controlWrite (const T *command) |
| | Control write to the oscilloscope. More...
|
| |
| template<class T > |
| int | controlRead (const T *command) |
| | Control read to the oscilloscope. More...
|
| |
| libusb_device * | getRawDevice () const |
| |
| unsigned long | getUniqueUSBDeviceID () const |
| |
| const DSOModel * | getModel () const |
| | Get the oscilloscope model. More...
|
| |
| void | overwriteInPacketLength (int len) |
| |
|
|
int | claimInterface (const libusb_interface_descriptor *interfaceDescriptor, int endpointOut, int endPointIn) |
| |
|
|
DSOModel * | model |
| |
|
struct libusb_device_descriptor | descriptor |
| |
|
libusb_device * | device |
| | The USB handle for the oscilloscope.
|
| |
|
libusb_device_handle * | handle = nullptr |
| |
|
unsigned | findIteration |
| |
|
const unsigned long | uniqueUSBdeviceID |
| |
|
int | interface |
| |
|
int | outPacketLength |
| | Packet length for the OUT endpoint.
|
| |
|
int | inPacketLength |
| | Packet length for the IN endpoint.
|
| |
This class handles the USB communication with an usb device that has one in and one out endpoint.
◆ bulkRead()
template<class T >
| int USBDevice::bulkRead |
( |
const T * |
command, |
|
|
int |
attempts = HANTEK_ATTEMPTS |
|
) |
| |
|
inline |
Bulk read from the oscilloscope.
- Parameters
-
| data | Buffer for the sent/recieved data. |
| length | The length of the packet. |
| attempts | The number of attempts, that are done on timeouts. |
- Returns
- Number of received bytes on success, libusb error code on error.
◆ bulkReadMulti()
| int USBDevice::bulkReadMulti |
( |
unsigned char * |
data, |
|
|
unsigned |
length, |
|
|
int |
attempts = HANTEK_ATTEMPTS_MULTI |
|
) |
| |
Multi packet bulk read from the oscilloscope.
- Parameters
-
| data | Buffer for the sent/recieved data. |
| length | The length of data contained in the packets. |
| attempts | The number of attempts, that are done on timeouts. |
- Returns
- Number of received bytes on success, libusb error code on error.
◆ bulkTransfer()
| int USBDevice::bulkTransfer |
( |
unsigned char |
endpoint, |
|
|
const unsigned char * |
data, |
|
|
unsigned int |
length, |
|
|
int |
attempts = HANTEK_ATTEMPTS, |
|
|
unsigned int |
timeout = HANTEK_TIMEOUT |
|
) |
| |
Bulk transfer to/from the oscilloscope.
- Parameters
-
| endpoint | Endpoint number, also sets the direction of the transfer. |
| data | Buffer for the sent/recieved data. |
| length | The length of the packet. |
| attempts | The number of attempts, that are done on timeouts. |
| timeout | The timeout in ms. |
- Returns
- Number of transferred bytes on success, libusb error code on error.
◆ bulkWrite()
| int USBDevice::bulkWrite |
( |
const unsigned char * |
data, |
|
|
unsigned int |
length, |
|
|
int |
attempts = HANTEK_ATTEMPTS |
|
) |
| |
|
inline |
Bulk write to the oscilloscope.
- Parameters
-
| data | Buffer for the sent/recieved data. |
| length | The length of the packet. |
| attempts | The number of attempts, that are done on timeouts. |
- Returns
- Number of sent bytes on success, libusb error code on error.
◆ computeUSBdeviceID()
| UniqueUSBid USBDevice::computeUSBdeviceID |
( |
libusb_device * |
device | ) |
|
|
static |
The USB bus is organised in a tree hierarchy. A device is connected to a port on a bus device, which is connected to a port on another bus device etc up to the root usb device.
The USB 3.0 standard allows up to 7 levels with 256 devices on each level (1 Byte). We generate a unique number for the connected device.
◆ controlRead()
template<class T >
| int USBDevice::controlRead |
( |
const T * |
command | ) |
|
|
inline |
Control read to the oscilloscope.
- Parameters
-
| command | Buffer for the sent/recieved data. |
- Returns
- Number of received bytes on success, libusb error code on error.
◆ controlTransfer()
| int USBDevice::controlTransfer |
( |
unsigned char |
type, |
|
|
unsigned char |
request, |
|
|
unsigned char * |
data, |
|
|
unsigned int |
length, |
|
|
int |
value, |
|
|
int |
index, |
|
|
int |
attempts = HANTEK_ATTEMPTS |
|
) |
| |
Control transfer to the oscilloscope.
- Parameters
-
| type | The request type, also sets the direction of the transfer. |
| request | The request field of the packet. |
| data | Buffer for the sent/recieved data. |
| length | The length field of the packet. |
| value | The value field of the packet. |
| index | The index field of the packet. |
| attempts | The number of attempts, that are done on timeouts. |
- Returns
- Number of transferred bytes on success, libusb error code on error.
◆ controlWrite()
template<class T >
| int USBDevice::controlWrite |
( |
const T * |
command | ) |
|
|
inline |
Control write to the oscilloscope.
- Parameters
-
| command | Buffer for the sent/recieved data. |
- Returns
- Number of sent bytes on success, libusb error code on error.
◆ getModel()
| const DSOModel* USBDevice::getModel |
( |
| ) |
const |
|
inline |
Get the oscilloscope model.
- Returns
- The ::Model of the connected Hantek DSO.
◆ getRawDevice()
| libusb_device* USBDevice::getRawDevice |
( |
| ) |
const |
|
inline |
- Returns
- Returns the raw libusb device
◆ getUniqueUSBDeviceID()
| unsigned long USBDevice::getUniqueUSBDeviceID |
( |
| ) |
const |
|
inline |
◆ isConnected()
| bool USBDevice::isConnected |
( |
| ) |
|
Check if the oscilloscope is connected.
- Returns
- true, if a connection is up.
◆ needsFirmware()
| bool USBDevice::needsFirmware |
( |
| ) |
|
- Returns
- Return true if this device needs a firmware first
◆ overwriteInPacketLength()
| void USBDevice::overwriteInPacketLength |
( |
int |
len | ) |
|
|
inline |
Usually a maximaum packet length for in and outgoing packets is determined by the underlying implementation and usb specification. E.g. the roll buffer mode uses the maximum in length for transfer. Some devices do not support that much data though and need an artification restriction.
◆ setFindIteration()
| void USBDevice::setFindIteration |
( |
unsigned |
iteration | ) |
|
|
inline |
Keep track of the find iteration on which this device was found
- Parameters
-
| iteration | The new iteration value |
The documentation for this class was generated from the following files: