mirror of
https://github.com/jankae/LibreVNA.git
synced 2025-12-06 07:12:10 +01:00
42 lines
865 B
C++
42 lines
865 B
C++
#ifndef USBINBUFFER_H
|
|
#define USBINBUFFER_H
|
|
|
|
#include <qglobal.h>
|
|
|
|
#ifdef Q_OS_MACOS
|
|
#include <libusb.h>
|
|
#else
|
|
#include <libusb-1.0/libusb.h>
|
|
#endif
|
|
#include <condition_variable>
|
|
|
|
#include <QObject>
|
|
|
|
class USBInBuffer : public QObject {
|
|
Q_OBJECT
|
|
public:
|
|
USBInBuffer(libusb_device_handle *handle, unsigned char endpoint, int buffer_size);
|
|
~USBInBuffer();
|
|
|
|
void removeBytes(int handled_bytes);
|
|
int getReceived() const;
|
|
uint8_t *getBuffer() const;
|
|
|
|
signals:
|
|
void DataReceived();
|
|
void TransferError();
|
|
|
|
private:
|
|
void Callback(libusb_transfer *transfer);
|
|
static void LIBUSB_CALL CallbackTrampoline(libusb_transfer *transfer);
|
|
libusb_transfer *transfer;
|
|
unsigned char *buffer;
|
|
int buffer_size;
|
|
int received_size;
|
|
bool inCallback;
|
|
bool cancelling;
|
|
std::condition_variable cv;
|
|
};
|
|
|
|
#endif // USBINBUFFER_H
|