|
OpenHantek
|
This class handles the USB communication with an usb device that has one in and one out endpoint. More...
#include <scopedevice.h>
Signals | |
| void | deviceDisconnected () |
| The device has been disconnected. More... | |
Public Member Functions | |
| ScopeDevice (DSOModel *model, libusb_device *device, unsigned findIteration=0) | |
| ScopeDevice () | |
| ScopeDevice (const ScopeDevice &)=delete | |
| ~ScopeDevice () | |
| bool | connectDevice (QString &errorMessage) |
| void | disconnectFromDevice () |
| bool | isConnected () |
| Check if the oscilloscope is connected. More... | |
| bool | isRealHW () const |
| Distinguish between real hw or demo device. More... | |
| bool | isDemoDevice () const |
| void | stopSampling () |
| Stop a long running (interruptable) bulk transfer. More... | |
| bool | hasStopped () |
| bool | needsFirmware () |
| unsigned int | getFwVersion () const |
| const QString | getSerialNumber () const |
| getSerialNumber More... | |
| QString | readUSBdescriptor (libusb_device_handle *handle, uint8_t index) |
| readUSBdescriptor More... | |
| void | setFindIteration (unsigned iteration) |
| unsigned | getFindIteration () const |
| int | bulkReadMulti (unsigned char *data, unsigned length, bool captureSmallBlocks, unsigned &received, 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 * | getUSBDevice () 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... | |
Private Member Functions | |
| 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... | |
Private Attributes | |
| bool | realHW = true |
| bool | stopTransfer = false |
| bool | disconnected = true |
| QString | serialNumber = "0000" |
This class handles the USB communication with an usb device that has one in and one out endpoint.
|
explicit |
|
explicit |
|
delete |
| ScopeDevice::~ScopeDevice | ( | ) |
|
inlineprivate |
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 ScopeDevice::bulkReadMulti | ( | unsigned char * | data, |
| unsigned | length, | ||
| bool | captureSmallBlocks, | ||
| unsigned & | received, | ||
| 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. |
| captureSmallBlocks | Capture many small blocks instread of one big block (faster gui update) |
| received | The amount of already captured samples |
| attempts | The number of attempts, that are done on timeouts. |
|
private |
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. |
|
inlineprivate |
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 ScopeDevice::connectDevice | ( | QString & | errorMessage | ) |
|
inline |
Control read to the oscilloscope.
| command | Buffer for the sent/received data. |
| int ScopeDevice::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 ScopeDevice::disconnectFromDevice | ( | ) |
|
inline |
|
inline |
|
inline |
Get the oscilloscope model.
|
inline |
getSerialNumber
|
inline |
|
inline |
|
inline |
| bool ScopeDevice::isConnected | ( | ) |
Check if the oscilloscope is connected.
|
inline |
|
inline |
Distinguish between real hw or demo device.
| bool ScopeDevice::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.
| QString ScopeDevice::readUSBdescriptor | ( | libusb_device_handle * | handle, |
| uint8_t | index | ||
| ) |
readUSBdescriptor
| handle | The device handle |
| index | of requested string |
|
inline |
Keep track of the find iteration on which this device was found
| iteration | The new iteration value |
|
inline |
Stop a long running (interruptable) bulk transfer.
|
protected |
|
protected |
The USB handle for the oscilloscope.
|
private |
|
protected |
|
protected |
|
protected |
Packet length for the IN endpoint.
|
protected |
|
protected |
|
protected |
Packet length for the OUT endpoint.
|
private |
|
private |
|
private |
|
protected |