forked from ganzziani/xscopes-qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
libusbdevice.h
72 lines (66 loc) · 1.94 KB
/
libusbdevice.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef LIBUSBDEVICE_H
#define LIBUSBDEVICE_H
#include <QObject>
#include <QFuture>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#include <QtConcurrent/QtConcurrent>
#else
#include <QtConcurrentRun>
#endif
#include "libusb.h"
#include "libusbdeviceinfo.h"
#include <QDebug>
#include "serialportconnection.h"
typedef uint8_t byte;
class LibUsbDevice : public QObject
{
Q_OBJECT
public:
explicit LibUsbDevice(QObject *parent = 0);
void initializeDevice();
void openDevice(QString="");
void closeDevice();
void eventThread();
bool controlReadTransfer(uint8_t command, uint16_t value = 0, uint16_t index = 0);
void asyncBulkReadTransfer();
void awgBulkWriteTransfer();
void controlWriteTransfer(uint16_t index, uint8_t value);
QString requestFirmwareVersion();
void stopScope();
void startScope();
void forceTrigger();
void autoSetup();
void saveAWG();
void saveDeviceSettings();
void restoreSettings();
QString getStringFromUnsignedChar( unsigned char *,int);
void reset();
int requestMM(unsigned char * buffer);
public slots:
void newDataAvailable(int);
void turnOnAutoMode();
void turnOffAutoMode();
void clearData();
public:
bool isDeviceConnected,isInitialiazed;
QString cstatus;
libusb_device **devs;
libusb_device *deviceFound;
libusb_device *dev;
libusb_device_descriptor deviceDesc;
libusb_device_handle *deviceHandle;
libusb_context *context;
libusb_hotplug_callback_handle hotplugHandle[2];
struct libusb_transfer *pcToUsbDeviceTransfer;
struct libusb_transfer *usbDeviceToPcTransfer;
bool dataAvailable;
int count, dataLength;
uint8_t chData[LEN_BULK_IN_BUFFER];
byte inBuffer[LEN_CONTROL_BUFFER];
byte awgBuffer[256];
bool enableEventThread,hasHotPlugSupport;
QFuture<void> future;
SerialPortConnection serial;
bool wayOfConnecting; //0 - usb, 1 - serial port
};
#endif // LIBUSBDEVICE_H