This class handles the USB communication with an usb device that has one in and one out endpoint.
More...
#include <scopedevice.h>
|
| | ScopeDevice (DSOModel *model, libusb_device *device, unsigned findIteration=0) |
| | ScopeDevice () |
| | ScopeDevice (const ScopeDevice &)=delete |
| | ~ScopeDevice () override |
| bool | connectDevice (QString &errorMessage) |
| void | disconnectFromDevice () |
| bool | isConnected () |
| | Check if the oscilloscope is connected.
|
| bool | isRealHW () const |
| | Distinguish between real hw or demo device.
|
| bool | isDemoDevice () const |
| void | stopSampling () |
| | Stop a long running (interruptible) bulk transfer.
|
| bool | hasStopped () |
| bool | needsFirmware () |
| unsigned int | getFwVersion () const |
| const QString | getSerialNumber () const |
| | getSerialNumber
|
| QString | readUSBdescriptor (libusb_device_handle *handle, uint8_t index) |
| | readUSBdescriptor
|
| 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.
|
| 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.
|
| template<class T> |
| int | controlWrite (const T *command) |
| | Control write to the oscilloscope.
|
| template<class T> |
| int | controlRead (const T *command) |
| | Control read to the oscilloscope.
|
| libusb_device * | getUSBDevice () const |
| UniqueUSBid | getUniqueUSBDeviceID () const |
| const DSOModel * | getModel () const |
| | Get the oscilloscope model.
|
| void | overwriteInPacketLength (unsigned len) |
|
| int | claimInterface (const libusb_interface_descriptor *interfaceDescriptor) |
This class handles the USB communication with an usb device that has one in and one out endpoint.
◆ ScopeDevice() [1/3]
| ScopeDevice::ScopeDevice |
( |
DSOModel * | model, |
|
|
libusb_device * | device, |
|
|
unsigned | findIteration = 0 ) |
|
explicit |
◆ ScopeDevice() [2/3]
| ScopeDevice::ScopeDevice |
( |
| ) |
|
|
explicit |
◆ ScopeDevice() [3/3]
◆ ~ScopeDevice()
| ScopeDevice::~ScopeDevice |
( |
| ) |
|
|
override |
◆ bulkRead()
template<class T>
| int ScopeDevice::bulkRead |
( |
const T * | command, |
|
|
int | attempts = HANTEK_ATTEMPTS ) |
|
inlineprivate |
Bulk read from the oscilloscope.
- Parameters
-
| data | Buffer for the sent/received 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 ScopeDevice::bulkReadMulti |
( |
unsigned char * | data, |
|
|
unsigned | length, |
|
|
bool | captureSmallBlocks, |
|
|
unsigned & | received, |
|
|
int | attempts = HANTEK_ATTEMPTS_MULTI ) |
Multi packet bulk read from the oscilloscope.
- Parameters
-
| data | Buffer for the sent/received data. |
| length | The length of data contained in the packets. |
| captureSmallBlocks | Capture many small blocks instead of one big block (faster gui update) |
| received | The amount of already captured samples |
| attempts | The number of attempts, that are done on timeouts. |
- Returns
- Number of received bytes on success, libusb error code on error.
◆ bulkTransfer()
| int ScopeDevice::bulkTransfer |
( |
unsigned char | endpoint, |
|
|
const unsigned char * | data, |
|
|
unsigned int | length, |
|
|
int | attempts = HANTEK_ATTEMPTS, |
|
|
unsigned int | timeout = HANTEK_TIMEOUT ) |
|
private |
Bulk transfer to/from the oscilloscope.
- Parameters
-
| 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. |
- Returns
- Number of transferred bytes on success, libusb error code on error.
◆ bulkWrite()
| int ScopeDevice::bulkWrite |
( |
const unsigned char * | data, |
|
|
unsigned int | length, |
|
|
int | attempts = HANTEK_ATTEMPTS ) |
|
inlineprivate |
Bulk write to the oscilloscope.
- Parameters
-
| data | Buffer for the sent/received 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.
◆ claimInterface()
| int ScopeDevice::claimInterface |
( |
const libusb_interface_descriptor * | interfaceDescriptor | ) |
|
|
protected |
◆ computeUSBdeviceID()
| UniqueUSBid ScopeDevice::computeUSBdeviceID |
( |
libusb_device * | device | ) |
|
|
static |
ID built from bus, port, VID, PID and FW version
◆ connectDevice()
| bool ScopeDevice::connectDevice |
( |
QString & | errorMessage | ) |
|
◆ controlRead()
template<class T>
| int ScopeDevice::controlRead |
( |
const T * | command | ) |
|
|
inline |
Control read to the oscilloscope.
- Parameters
-
| command | Buffer for the sent/received data. |
- Returns
- Number of received bytes on success, libusb error code on error.
◆ controlTransfer()
| 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.
- Parameters
-
| 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. |
- Returns
- Number of transferred bytes on success, libusb error code on error.
◆ controlWrite()
template<class T>
| int ScopeDevice::controlWrite |
( |
const T * | command | ) |
|
|
inline |
Control write to the oscilloscope.
- Parameters
-
| command | Buffer for the sent/received data. |
- Returns
- Number of sent bytes on success, libusb error code on error.
◆ deviceDisconnected
| void ScopeDevice::deviceDisconnected |
( |
| ) |
|
|
signal |
The device has been disconnected.
◆ disconnectFromDevice()
| void ScopeDevice::disconnectFromDevice |
( |
| ) |
|
◆ getFindIteration()
| unsigned ScopeDevice::getFindIteration |
( |
| ) |
const |
|
inline |
◆ getFwVersion()
| unsigned int ScopeDevice::getFwVersion |
( |
| ) |
const |
|
inline |
- Returns
- Return device version as unsigned int
◆ getModel()
| const DSOModel * ScopeDevice::getModel |
( |
| ) |
const |
|
inline |
Get the oscilloscope model.
- Returns
- The ::Model of the connected Hantek DSO.
◆ getSerialNumber()
| const QString ScopeDevice::getSerialNumber |
( |
| ) |
const |
|
inline |
getSerialNumber
- Returns
- Return serial number string of the device
◆ getUniqueUSBDeviceID()
| UniqueUSBid ScopeDevice::getUniqueUSBDeviceID |
( |
| ) |
const |
|
inline |
◆ getUSBDevice()
| libusb_device * ScopeDevice::getUSBDevice |
( |
| ) |
const |
|
inline |
- Returns
- Returns the raw libusb device
◆ hasStopped()
| bool ScopeDevice::hasStopped |
( |
| ) |
|
|
inline |
◆ isConnected()
| bool ScopeDevice::isConnected |
( |
| ) |
|
Check if the oscilloscope is connected.
- Returns
- true, if a connection is up.
◆ isDemoDevice()
| bool ScopeDevice::isDemoDevice |
( |
| ) |
const |
|
inline |
◆ isRealHW()
| bool ScopeDevice::isRealHW |
( |
| ) |
const |
|
inline |
Distinguish between real hw or demo device.
◆ needsFirmware()
| bool ScopeDevice::needsFirmware |
( |
| ) |
|
- Returns
- Return true if this device needs a firmware first
◆ overwriteInPacketLength()
| void ScopeDevice::overwriteInPacketLength |
( |
unsigned | len | ) |
|
|
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.
◆ readUSBdescriptor()
| QString ScopeDevice::readUSBdescriptor |
( |
libusb_device_handle * | handle, |
|
|
uint8_t | index ) |
readUSBdescriptor
- Parameters
-
| handle | The device handle |
| index | of requested string |
- Returns
- serial number string
◆ setFindIteration()
| void ScopeDevice::setFindIteration |
( |
unsigned | iteration | ) |
|
|
inline |
Keep track of the find iteration on which this device was found
- Parameters
-
| iteration | The new iteration value |
◆ stopSampling()
| void ScopeDevice::stopSampling |
( |
| ) |
|
|
inline |
Stop a long running (interruptible) bulk transfer.
◆ descriptor
| struct libusb_device_descriptor ScopeDevice::descriptor |
|
protected |
◆ device
| libusb_device* ScopeDevice::device |
|
protected |
The USB handle for the oscilloscope.
◆ disconnected
| bool ScopeDevice::disconnected = true |
|
private |
◆ findIteration
| unsigned ScopeDevice::findIteration |
|
protected |
◆ handle
| libusb_device_handle* ScopeDevice::handle = nullptr |
|
protected |
◆ inPacketLength
| unsigned ScopeDevice::inPacketLength |
|
protected |
Packet length for the IN endpoint.
◆ model
◆ nInterface
| int ScopeDevice::nInterface |
|
protected |
◆ outPacketLength
| unsigned ScopeDevice::outPacketLength |
|
protected |
Packet length for the OUT endpoint.
◆ realHW
| bool ScopeDevice::realHW = true |
|
private |
◆ serialNumber
| QString ScopeDevice::serialNumber = "0000" |
|
private |
◆ stopTransfer
| bool ScopeDevice::stopTransfer = false |
|
private |
◆ uniqueUSBdeviceID
The documentation for this class was generated from the following files: