summaryrefslogtreecommitdiffstats
path: root/libqdb
diff options
context:
space:
mode:
authorKari Oikarinen <kari.oikarinen@qt.io>2016-10-20 16:37:38 +0300
committerKari Oikarinen <kari.oikarinen@qt.io>2016-11-07 07:18:11 +0000
commita6bfa840aeab17d565030920422000861615e6e6 (patch)
tree0e73a314f073d526e33252bc371a57fab524198a /libqdb
parent6e15f80aed27e87e9727568ee8d968641a9ed913 (diff)
Handle plugged and unplugged USB devices
Looking for inserted and removed devices is done by polling once a second. libusb hotplug events are not used since they are not supported on Windows and not available in the libusb version in RHEL 7.2. If the IP address is not available for the device on the first check, the device will be checked again after a short delay until the information is complete. In the meanwhile the incomplete information is exposed to the client when asked. Parts that use libusb were moved from libqdb to the host part, since they are only used on the host. Task-number: QTBUG-56067 Change-Id: I0cfbd3659001982609a7d4a77cb1266a7dc6ce8c Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
Diffstat (limited to 'libqdb')
-rw-r--r--libqdb/libqdb.pro19
-rw-r--r--libqdb/usb/devicemanagement.cpp136
-rw-r--r--libqdb/usb/devicemanagement.h30
-rw-r--r--libqdb/usb/libusbcontext.cpp51
-rw-r--r--libqdb/usb/usbcommon.h37
-rw-r--r--libqdb/usb/usbconnection.cpp154
-rw-r--r--libqdb/usb/usbconnection.h69
-rw-r--r--libqdb/usb/usbconnectionreader.cpp56
-rw-r--r--libqdb/usb/usbconnectionreader.h47
-rw-r--r--libqdb/usb/usbdevice.h60
10 files changed, 1 insertions, 658 deletions
diff --git a/libqdb/libqdb.pro b/libqdb/libqdb.pro
index 383d365..205a86e 100644
--- a/libqdb/libqdb.pro
+++ b/libqdb/libqdb.pro
@@ -1,16 +1,8 @@
-QT -= gui
+QT -= gui
TARGET = qdb
TEMPLATE = lib
-unix {
- CONFIG += link_pkgconfig
- PKGCONFIG += libusb-1.0
-}
-win32 {
- LIBS += -llibusb-1.0
-}
-
DEFINES += LIBQDB_LIBRARY
SOURCES += \
@@ -20,10 +12,6 @@ SOURCES += \
protocol/qdbtransport.cpp \
stream.cpp \
streampacket.cpp \
- usb/devicemanagement.cpp \
- usb/libusbcontext.cpp \
- usb/usbconnection.cpp \
- usb/usbconnectionreader.cpp \
HEADERS += \
abstractconnection.h \
@@ -38,11 +26,6 @@ HEADERS += \
protocol/services.h \
stream.h \
streampacket.h \
- usb/devicemanagement.h \
- usb/usbcommon.h \
- usb/usbconnection.h \
- usb/usbconnectionreader.h \
- usb/usbdevice.h \
unix {
target.path = $$[QT_INSTALL_LIBS]
diff --git a/libqdb/usb/devicemanagement.cpp b/libqdb/usb/devicemanagement.cpp
deleted file mode 100644
index 8e7ad38..0000000
--- a/libqdb/usb/devicemanagement.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/******************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Debug Bridge.
-**
-** $QT_BEGIN_LICENSE:COMM$
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** $QT_END_LICENSE$
-**
-******************************************************************************/
-#include "devicemanagement.h"
-#include "scopeguard.h"
-#include "usbcommon.h"
-#include "usbconnection.h"
-#include "qdbconstants.h"
-
-#include <QtCore/qdebug.h>
-
-#include <libusb.h>
-
-bool isQdbInterface(const libusb_interface &interface)
-{
- const libusb_interface_descriptor *descriptor = &interface.altsetting[0];
- return descriptor->bInterfaceClass == qdbUsbClassId && descriptor->bInterfaceSubClass == qdbUsbSubclassId;
-}
-
-std::pair<bool, UsbInterfaceInfo> findQdbInterface(libusb_device *device)
-{
- libusb_config_descriptor *config;
- const int ret = libusb_get_active_config_descriptor(device, &config);
- if (ret) {
- qCritical() << "Could not get config descriptor" << libusb_error_name(ret);
- return std::make_pair(false, UsbInterfaceInfo{});
- }
- ScopeGuard configGuard = [&]() {
- libusb_free_config_descriptor(config);
- };
-
- const auto last = config->interface + config->bNumInterfaces;
- const auto qdbInterface = std::find_if(config->interface, last, isQdbInterface);
- if (qdbInterface == last) {
- return std::make_pair(false, UsbInterfaceInfo{});;
- }
-
- const int inEndpointIndex = 1;
- const int outEndpointIndex = 0;
-
- const libusb_interface_descriptor *interface = &qdbInterface->altsetting[0];
- const auto interfaceNumber = interface->bInterfaceNumber;
- const auto inAddress = interface->endpoint[inEndpointIndex].bEndpointAddress;
- const auto outAddress = interface->endpoint[outEndpointIndex].bEndpointAddress;
- const UsbInterfaceInfo info{interfaceNumber, inAddress, outAddress};
- return std::make_pair(true, info);
-}
-
-QString getSerialNumber(libusb_device *device, libusb_device_handle *handle)
-{
- QString serial{"???"};
-
- libusb_device_descriptor desc;
- int ret = libusb_get_device_descriptor(device, &desc);
- if (ret) {
- qCritical() << "Could not get device descriptor" << libusb_error_name(ret);
- return serial;
- }
- auto serialIndex = desc.iSerialNumber;
-
- const uint16_t englishUsLangId = 0x409;
- const int bufferSize = 255; // USB string descriptor size field is a single byte
- unsigned char buffer[bufferSize];
- int length = libusb_get_string_descriptor(handle, serialIndex, englishUsLangId, buffer, bufferSize);
- if (length <= 0) {
- qWarning() << "Could not get string descriptor of serial number:" << libusb_error_name(length);
- return serial;
- }
- // length is the length in bytes and UTF-16 characters consist of two bytes
- Q_ASSERT(length % 2 == 0);
- serial = QString::fromUtf16(reinterpret_cast<unsigned short*>(buffer), length / 2);
- return serial;
-}
-
-std::vector<UsbDevice> listUsbDevices()
-{
- if (!libUsbContext()) {
- qDebug() << "Not initialized libusb in DeviceManager";
- return std::vector<UsbDevice>{};
- }
-
- libusb_device **devicesParam;
- ssize_t deviceCount = libusb_get_device_list(libUsbContext(), &devicesParam);
- std::shared_ptr<libusb_device *> devices{devicesParam,
- [](libusb_device **pointer) {
- libusb_free_device_list(pointer, 1);
- }};
-
- if (deviceCount < 0) {
- qCritical() << "USB devices could not be listed:" << libusb_error_name(deviceCount);
- return std::vector<UsbDevice>{};
- }
-
- std::vector<UsbDevice> qdbDevices;
- for (int i = 0; i < deviceCount; ++i) {
- libusb_device *device = devices.get()[i];
-
- const auto interfaceResult = findQdbInterface(device);
- if (!interfaceResult.first) {
- // No QDB interface found, not a QDB device
- continue;
- }
-
- libusb_device_handle *handle;
- int ret = libusb_open(device, &handle);
- if (ret) {
- qDebug() << "Could not open USB device for checking serial number:" << libusb_error_name(ret);
- continue;
- }
- ScopeGuard deviceGuard = [=]() {
- libusb_close(handle);
- };
- const auto serial = getSerialNumber(device, handle);
-
- const UsbDevice usbDevice{serial, LibUsbDevice{devices, i}, interfaceResult.second};
- qdbDevices.push_back(usbDevice);
- }
- return qdbDevices;
-}
diff --git a/libqdb/usb/devicemanagement.h b/libqdb/usb/devicemanagement.h
deleted file mode 100644
index 52ac688..0000000
--- a/libqdb/usb/devicemanagement.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/******************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Debug Bridge.
-**
-** $QT_BEGIN_LICENSE:COMM$
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** $QT_END_LICENSE$
-**
-******************************************************************************/
-#ifndef DEVICEMANAGER_H
-#define DEVICEMANAGER_H
-
-#include "usbdevice.h"
-
-#include <vector>
-
-std::vector<UsbDevice> listUsbDevices();
-
-#endif // DEVICEMANAGER_H
diff --git a/libqdb/usb/libusbcontext.cpp b/libqdb/usb/libusbcontext.cpp
deleted file mode 100644
index 6976e4e..0000000
--- a/libqdb/usb/libusbcontext.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/******************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Debug Bridge.
-**
-** $QT_BEGIN_LICENSE:COMM$
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** $QT_END_LICENSE$
-**
-******************************************************************************/
-#include "usbcommon.h"
-
-#include <QtGlobal>
-
-#include <libusb.h>
-
-struct LibUsbContext
-{
- LibUsbContext()
- : context{nullptr}
- {
- int ret = libusb_init(&context);
- if (ret) {
- qCritical("Could not initialize libusb");
- }
- }
-
- ~LibUsbContext()
- {
- if (context)
- libusb_exit(context);
- }
-
- libusb_context* context;
-};
-
-libusb_context *libUsbContext()
-{
- static LibUsbContext context;
- return context.context;
-}
diff --git a/libqdb/usb/usbcommon.h b/libqdb/usb/usbcommon.h
deleted file mode 100644
index 4a6d024..0000000
--- a/libqdb/usb/usbcommon.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/******************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Debug Bridge.
-**
-** $QT_BEGIN_LICENSE:COMM$
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** $QT_END_LICENSE$
-**
-******************************************************************************/
-#ifndef USBCOMMON_H
-#define USBCOMMON_H
-
-#include <cstdint>
-
-struct libusb_context;
-
-libusb_context *libUsbContext();
-
-struct UsbInterfaceInfo
-{
- uint8_t number;
- uint8_t inAddress;
- uint8_t outAddress;
-};
-
-#endif // USBCOMMON_H
diff --git a/libqdb/usb/usbconnection.cpp b/libqdb/usb/usbconnection.cpp
deleted file mode 100644
index f159d19..0000000
--- a/libqdb/usb/usbconnection.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-/******************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Debug Bridge.
-**
-** $QT_BEGIN_LICENSE:COMM$
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** $QT_END_LICENSE$
-**
-******************************************************************************/
-#include "usbconnection.h"
-
-#include "make_unique.h"
-#include "protocol/protocol.h"
-#include "scopeguard.h"
-#include "usbcommon.h"
-#include "usbconnectionreader.h"
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qthread.h>
-
-#include <libusb.h>
-
-UsbConnection::UsbConnection(const UsbDevice &device)
- : m_device{device.usbDevice},
- m_handle{nullptr},
- m_interfaceInfo(device.interfaceInfo), // uniform initialization with {} fails with GCC 4.9
- m_detachedKernel{false},
- m_readThread{nullptr},
- m_reader{nullptr},
- m_reads{}
-{
-}
-
-UsbConnection::~UsbConnection()
-{
- if (m_readThread) {
- m_readThread->quit();
- m_readThread->wait();
- }
- if (m_handle) {
- libusb_release_interface(m_handle, m_interfaceInfo.number);
- if (m_detachedKernel)
- libusb_attach_kernel_driver(m_handle, m_interfaceInfo.number);
- libusb_close(m_handle);
- }
-}
-
-bool UsbConnection::open(OpenMode mode)
-{
- Q_ASSERT(mode == (QIODevice::ReadWrite | QIODevice::Unbuffered));
- QIODevice::open(mode);
-
- libusb_config_descriptor *config;
- int ret = libusb_get_active_config_descriptor(m_device.pointer(), &config);
- if (ret) {
- qDebug("could not get config descriptor: %s\n",
- libusb_error_name(ret));
- return false;
- }
- ScopeGuard configGuard = [&]() {
- libusb_free_config_descriptor(config);
- };
-
- ret = libusb_open(m_device.pointer(), &m_handle);
- if (ret) {
- qDebug("cannot open device: %s\n", libusb_error_name(ret));
- return false;
- }
-
- if (libusb_kernel_driver_active(m_handle, m_interfaceInfo.number) == 1) {
- qDebug() << "Detached kernel driver";
- m_detachedKernel = true;
- libusb_detach_kernel_driver(m_handle, m_interfaceInfo.number);
- }
-
- ret = libusb_claim_interface(m_handle, m_interfaceInfo.number);
- if (ret) {
- qDebug("cannot claim interface: %s", libusb_error_name(ret));
- return false;
- }
- qDebug("claimed interface %d", m_interfaceInfo.number);
-
- startReader(m_handle, m_interfaceInfo.inAddress);
-
- return true;
-}
-
-qint64 UsbConnection::readData(char *data, qint64 maxSize)
-{
- if (m_reads.isEmpty()) {
- qDebug() << "UsbConnection read queue empty in readData";
- return -1;
- }
- QByteArray read = m_reads.dequeue();
- Q_ASSERT(read.size() <= maxSize); // TODO: handle too big reads
- std::copy(read.begin(), read.end(), data);
-
- return read.size();
-}
-
-qint64 UsbConnection::writeData(const char *data, qint64 maxSize)
-{
- // Send header as a separate transfer to allow separate read on device side
- int size = maxSize > qdbHeaderSize ? qdbHeaderSize : maxSize;
-
- int transferred = 0;
- int ret = libusb_bulk_transfer(m_handle, m_interfaceInfo.outAddress, (unsigned char*)data, size, &transferred, 0);
- if (ret) {
- qDebug() << "writeData error:" << libusb_error_name(ret);
- return -1;
- }
- Q_ASSERT(transferred == size); // TODO: handle partial transfers of header
- transferred = 0;
-
- if (size < maxSize) {
- int rest = maxSize - size;
- int ret = libusb_bulk_transfer(m_handle, m_interfaceInfo.outAddress, (unsigned char*)data + size, rest, &transferred, 0);
- if (ret) {
- qDebug() << "writeData error:" << libusb_error_name(ret);
- return -1;
- }
- }
- return size + transferred;
-}
-
-void UsbConnection::dataRead(QByteArray data)
-{
- m_reads.enqueue(data);
- emit readyRead();
-}
-
-void UsbConnection::startReader(libusb_device_handle *handle, uint8_t inAddress)
-{
- m_readThread = make_unique<QThread>();
- m_reader = make_unique<UsbConnectionReader>(handle, inAddress);
-
- connect(m_reader.get(), &UsbConnectionReader::newRead, this, &UsbConnection::dataRead);
- connect(m_readThread.get(), &QThread::started, m_reader.get(), &UsbConnectionReader::executeRead);
- m_reader->moveToThread(m_readThread.get());
-
- m_readThread->setObjectName("UsbConnectionReader");
- m_readThread->start();
-}
diff --git a/libqdb/usb/usbconnection.h b/libqdb/usb/usbconnection.h
deleted file mode 100644
index 9f2bd95..0000000
--- a/libqdb/usb/usbconnection.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/******************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Debug Bridge.
-**
-** $QT_BEGIN_LICENSE:COMM$
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** $QT_END_LICENSE$
-**
-******************************************************************************/
-#ifndef USBMANAGER_H
-#define USBMANAGER_H
-
-#include "../libqdb_global.h"
-#include "usbdevice.h"
-
-class UsbConnectionReader;
-
-#include <QtCore/qbytearray.h>
-#include <QtCore/qiodevice.h>
-#include <QtCore/qqueue.h>
-QT_BEGIN_NAMESPACE
-class QThread;
-QT_END_NAMESPACE
-
-#include <memory>
-
-struct libusb_device;
-struct libusb_device_handle;
-
-class LIBQDBSHARED_EXPORT UsbConnection : public QIODevice
-{
- Q_OBJECT
-public:
- UsbConnection(const UsbDevice &device);
- ~UsbConnection();
-
- bool open(QIODevice::OpenMode mode) override;
-
-protected:
- qint64 readData(char *data, qint64 maxSize) override;
- qint64 writeData(const char *data, qint64 maxSize) override;
-
-private slots:
- void dataRead(QByteArray data);
-
-private:
- void startReader(libusb_device_handle *handle, uint8_t inAddress);
-
- LibUsbDevice m_device;
- libusb_device_handle *m_handle;
- UsbInterfaceInfo m_interfaceInfo;
- bool m_detachedKernel;
- std::unique_ptr<QThread> m_readThread;
- std::unique_ptr<UsbConnectionReader> m_reader;
- QQueue<QByteArray> m_reads;
-};
-
-#endif // USBMANAGER_H
diff --git a/libqdb/usb/usbconnectionreader.cpp b/libqdb/usb/usbconnectionreader.cpp
deleted file mode 100644
index 9313514..0000000
--- a/libqdb/usb/usbconnectionreader.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/******************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Debug Bridge.
-**
-** $QT_BEGIN_LICENSE:COMM$
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** $QT_END_LICENSE$
-**
-******************************************************************************/
-#include "usbconnectionreader.h"
-
-#include "protocol/protocol.h"
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qthread.h>
-#include <QtCore/qtimer.h>
-
-#include <libusb.h>
-
-// Amount of milliseconds between yielding control to the event loop of the reading thread
-static const int quitCheckingTimeout = 500;
-
-UsbConnectionReader::UsbConnectionReader(libusb_device_handle *handle, uint8_t inAddress)
- : m_handle{handle},
- m_inAddress{inAddress}
-{
-
-}
-
-void UsbConnectionReader::executeRead()
-{
- QByteArray buffer{qdbMessageSize, '\0'};
- int transferred = 0;
- int ret = libusb_bulk_transfer(m_handle, m_inAddress, reinterpret_cast<unsigned char *>(buffer.data()),
- buffer.size(), &transferred, quitCheckingTimeout);
- if (ret) {
- // TODO: report errors?
- if (ret != LIBUSB_ERROR_TIMEOUT)
- qDebug() << "UsbConnectionReader error:" << libusb_error_name(ret);
- } else {
- buffer.resize(transferred);
- emit newRead(buffer);
- }
- QTimer::singleShot(0, this, &UsbConnectionReader::executeRead);
-}
diff --git a/libqdb/usb/usbconnectionreader.h b/libqdb/usb/usbconnectionreader.h
deleted file mode 100644
index 3798e6c..0000000
--- a/libqdb/usb/usbconnectionreader.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/******************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Debug Bridge.
-**
-** $QT_BEGIN_LICENSE:COMM$
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** $QT_END_LICENSE$
-**
-******************************************************************************/
-#ifndef USBCONNECTIONREADER_H
-#define USBCONNECTIONREADER_H
-
-#include <QtCore/qobject.h>
-
-#include <stdint.h>
-
-struct libusb_device_handle;
-
-class UsbConnectionReader : public QObject
-{
- Q_OBJECT
-public:
- UsbConnectionReader(libusb_device_handle *handle, uint8_t inAddress);
-
-signals:
- void newRead(QByteArray data);
-
-public slots:
- void executeRead();
-
-private:
- libusb_device_handle *m_handle;
- uint8_t m_inAddress;
-};
-
-#endif // USBCONNECTIONREADER_H
diff --git a/libqdb/usb/usbdevice.h b/libqdb/usb/usbdevice.h
deleted file mode 100644
index 5e8c1a9..0000000
--- a/libqdb/usb/usbdevice.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/******************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Debug Bridge.
-**
-** $QT_BEGIN_LICENSE:COMM$
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** $QT_END_LICENSE$
-**
-******************************************************************************/
-#ifndef USBDEVICE_H
-#define USBDEVICE_H
-
-#include "usbcommon.h"
-
-#include <QtCore/qstring.h>
-
-#include <cstdint>
-#include <memory>
-
-struct libusb_device;
-
-class LibUsbDevice {
-public:
- LibUsbDevice(std::shared_ptr<libusb_device *> devices, int index)
- : m_deviceList{devices},
- m_index{index}
-
- {
- }
-
- libusb_device *pointer()
- {
- return m_deviceList.get()[m_index];
- }
-
-private:
- std::shared_ptr<libusb_device *> m_deviceList;
- int m_index;
-
-};
-
-struct UsbDevice
-{
- QString serial;
- LibUsbDevice usbDevice;
- UsbInterfaceInfo interfaceInfo;
-};
-
-#endif // USBDEVICE_H