7 #include <libusb-1.0/libusb.h> 10 #include "usbdevicedefinitions.h" 14 typedef unsigned long UniqueUSBid;
20 QString libUsbErrorString(
int error);
31 bool connectDevice(QString &errorMessage);
32 void disconnectFromDevice();
48 inline unsigned getFindIteration()
const {
return findIteration; }
58 int bulkTransfer(
unsigned char endpoint,
const unsigned char *data,
unsigned int length,
int attempts = HANTEK_ATTEMPTS,
59 unsigned int timeout = HANTEK_TIMEOUT);
66 inline int bulkWrite(
const unsigned char *data,
unsigned int length,
int attempts = HANTEK_ATTEMPTS) {
67 return bulkTransfer(HANTEK_EP_OUT, data, length, attempts);
76 inline int bulkRead(
const T *command,
int attempts = HANTEK_ATTEMPTS) {
77 return bulkTransfer(HANTEK_EP_IN, command->data(), command->size(), attempts);
85 int bulkReadMulti(
unsigned char *data,
unsigned length,
int attempts = HANTEK_ATTEMPTS_MULTI);
96 int controlTransfer(
unsigned char type,
unsigned char request,
unsigned char *data,
unsigned int length,
int value,
97 int index,
int attempts = HANTEK_ATTEMPTS);
104 return controlTransfer(LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT, (uint8_t)command->code,
105 (
unsigned char *)command->data(), (unsigned)command->size(), command->value, 0,
114 return controlTransfer(LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_IN, (uint8_t)command->code,
115 (
unsigned char *)command->data(), (unsigned)command->size(), command->value, 0,
148 int claimInterface(
const libusb_interface_descriptor *interfaceDescriptor,
int endpointOut,
int endPointIn);
154 struct libusb_device_descriptor descriptor;
156 libusb_device_handle *handle =
nullptr;
157 unsigned findIteration;
158 const unsigned long uniqueUSBdeviceID;
int inPacketLength
Packet length for the IN endpoint.
Definition: usbdevice.h:161
libusb_device * device
The USB handle for the oscilloscope.
Definition: usbdevice.h:155
libusb_device * getRawDevice() const
Definition: usbdevice.h:122
const DSOModel * getModel() const
Get the oscilloscope model.
Definition: usbdevice.h:139
int bulkRead(const T *command, int attempts=HANTEK_ATTEMPTS)
Bulk read from the oscilloscope.
Definition: usbdevice.h:76
int controlRead(const T *command)
Control read to the oscilloscope.
Definition: usbdevice.h:113
Describes a device This is the central class to describe a hantek compatible DSO. It contains all usb...
Definition: dsomodel.h:17
void overwriteInPacketLength(int len)
Definition: usbdevice.h:146
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.
Definition: usbdevice.cpp:192
int controlWrite(const T *command)
Control write to the oscilloscope.
Definition: usbdevice.h:103
void setFindIteration(unsigned iteration)
Definition: usbdevice.h:47
int outPacketLength
Packet length for the OUT endpoint.
Definition: usbdevice.h:160
int bulkWrite(const unsigned char *data, unsigned int length, int attempts=HANTEK_ATTEMPTS)
Bulk write to the oscilloscope.
Definition: usbdevice.h:66
int bulkReadMulti(unsigned char *data, unsigned length, int attempts=HANTEK_ATTEMPTS_MULTI)
Multi packet bulk read from the oscilloscope.
Definition: usbdevice.cpp:174
bool needsFirmware()
Definition: usbdevice.cpp:153
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.
Definition: usbdevice.cpp:157
This class handles the USB communication with an usb device that has one in and one out endpoint...
Definition: usbdevice.h:24
unsigned long getUniqueUSBDeviceID() const
Definition: usbdevice.h:127
static UniqueUSBid computeUSBdeviceID(libusb_device *device)
Definition: usbdevice.cpp:48
bool isConnected()
Check if the oscilloscope is connected.
Definition: usbdevice.cpp:151
void deviceDisconnected()
The device has been disconnected.