|
OpenHantek
|
This class handles the USB communication with an usb device that has one in and one out endpoint. More...
#include <usbdevice.h>
Signals | |
| void | deviceDisconnected () |
| The device has been disconnected. More... | |
Public Member Functions | |
| USBDevice (DSOModel *model, libusb_device *device, unsigned findIteration=0) | |
| USBDevice (const USBDevice &)=delete | |
| ~USBDevice () | |
| bool | connectDevice (QString &errorMessage) |
| void | disconnectFromDevice () |
| bool | isConnected () |
| Check if the oscilloscope is connected. More... | |
| bool | needsFirmware () |
| unsigned int | getFwVersion () const |
| 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 |
| UniqueUSBid | getUniqueUSBDeviceID () const |
| const DSOModel * | getModel () const |
| Get the oscilloscope model. More... | |
| void | overwriteInPacketLength (unsigned len) |
Static Public Member Functions | |
| static UniqueUSBid | computeUSBdeviceID (libusb_device *device) |
Protected Member Functions | |
| int | claimInterface (const libusb_interface_descriptor *interfaceDescriptor) |
Protected Attributes | |
| DSOModel * | model |
| struct libusb_device_descriptor | descriptor |
| libusb_device * | device |
| The USB handle for the oscilloscope. More... | |
| libusb_device_handle * | handle = nullptr |
| unsigned | findIteration |
| const UniqueUSBid | uniqueUSBdeviceID |
| int | nInterface |
| unsigned | outPacketLength |
| Packet length for the OUT endpoint. More... | |
| unsigned | inPacketLength |
| Packet length for the IN endpoint. More... | |
This class handles the USB communication with an usb device that has one in and one out endpoint.
|
explicit |
|
delete |
| USBDevice::~USBDevice | ( | ) |
|
inline |
Bulk read from the oscilloscope.
| data | Buffer for the sent/received data. |
| length | The length of the packet. |
| attempts | The number of attempts, that are done on timeouts. |
| int USBDevice::bulkReadMulti | ( | unsigned char * | data, |
| unsigned | length, | ||
| int | attempts = HANTEK_ATTEMPTS_MULTI |
||
| ) |
Multi packet bulk read from the oscilloscope.
| data | Buffer for the sent/received data. |
| length | The length of data contained in the packets. |
| attempts | The number of attempts, that are done on timeouts. |
| 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.
| endpoint | Endpoint number, also sets the direction of the transfer. |
| data | Buffer for the sent/received data. |
| length | The length of the packet. |
| attempts | The number of attempts, that are done on timeouts. |
| timeout | The timeout in ms. |
|
inline |
Bulk write to the oscilloscope.
| data | Buffer for the sent/received data. |
| length | The length of the packet. |
| attempts | The number of attempts, that are done on timeouts. |
|
protected |
|
static |
ID built from bus, port, VID, PID and FW version
| bool USBDevice::connectDevice | ( | QString & | errorMessage | ) |
|
inline |
Control read to the oscilloscope.
| command | Buffer for the sent/received data. |
| 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.
| type | The request type, also sets the direction of the transfer. |
| request | The request field of the packet. |
| data | Buffer for the sent/received 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. |
|
inline |
Control write to the oscilloscope.
| command | Buffer for the sent/received data. |
|
signal |
The device has been disconnected.
| void USBDevice::disconnectFromDevice | ( | ) |
|
inline |
|
inline |
|
inline |
Get the oscilloscope model.
|
inline |
|
inline |
| bool USBDevice::isConnected | ( | ) |
Check if the oscilloscope is connected.
| bool USBDevice::needsFirmware | ( | ) |
|
inline |
Usually a maximum 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.
|
inline |
Keep track of the find iteration on which this device was found
| iteration | The new iteration value |
|
protected |
|
protected |
The USB handle for the oscilloscope.
|
protected |
|
protected |
|
protected |
Packet length for the IN endpoint.
|
protected |
|
protected |
|
protected |
Packet length for the OUT endpoint.
|
protected |