title: libusb can't claim device
body: <p>I'm trying to using the libusb-1.0 and QtUsb library for USB Device access. Its simple a bulk-device thats works before I did make a few updates.
  Currently I use</p>
  
  <pre><code>Linux nadhh.fritz.box 4.11.8-200.fc25.x86_64 #1 SMP Thu Jun 29 16:13:56 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  </code></pre>
  
  <p>It doesn't matter if I run as user or root because the device will be set to group users and permission 666 by udev</p>
  
  <pre><code>[timestamp] [threadID] facility level [function call] &lt;message&gt;
  --------------------------------------------------------------------------------
  [ 0.012281] [00000fc6] libusb: error [op_get_configuration] device unconfigured
  Type:1, cat:default, file:../src/qlibusb.cpp, line:114, f:virtual qint32 QUsbDevice::open(), msg:Cannot Claim Interface
  Type:1, cat:default, file:../src/qlibusb.cpp, line:168, f:void QUsbDevice::printUsbError(int), msg:libusb Error: Entity not found
  [ 0.951403] [00000fc6] libusb: warning [libusb_exit] application left some devices open
  </code></pre>
  
  <p>It doesn't matter if I run as user or root because the device will be set to group users and permission 666 by udev
  Any hints are welcome</p>
  
  <p>Sincerely Jürgen</p>
  
  <p>The Code</p>
  
  <p>Taken from </p>
  
  <h1><strong>QtUsb</strong></h1>
  
  <p>
  </p>
  
  <p>A Cross-platform USB Library for Qt.
  Relies on libusb-1.0.</p>
  
  <p><strong>Features</strong></p>
  
  <ul>
  <li>Bulk transfer</li>
  <li>Device insertion/removal detection</li>
  <li>Device search</li>
  </ul>
  
  <p><strong>TODO</strong></p>
  
  <ul>
  <li>Interrupt transfer</li>
  <li>isochronous transfer</li>
  </ul>
  
  <p><strong>Usage</strong></p>
  
  <p>Documentation is not complete yet, you can have a look at the examples in the meanwhile.</p>
  
  <p><strong>Documentation</strong>  </p>
  
  <p>Doxygen documentation can be found here: <a href="http://fpoussin.github.io/doxygen/qtusb/" rel="noreferrer">http://fpoussin.github.io/doxygen/qtusb/</a></p>
  
  <p><strong>Downloads</strong></p>
  
  <p>Ubuntu PPA: <a href="https://launchpad.net/~fpoussin/+archive/ubuntu/ppa" rel="noreferrer">https://launchpad.net/~fpoussin/+archive/ubuntu/ppa</a> 
  Windows libraries are coming soon.</p>
  
  <p>header</p>
  
  <pre><code>    #ifndef USBEXAMPLE_H
      #define USBEXAMPLE_H
  
      #include &lt;QObject&gt;
      #include &lt;QUsb&gt;
  
      const quint8 USB_PIPE_IN = 0x81;   /* Bulk output endpoint for responses */
      const quint8 USB_PIPE_OUT = 0x01;      /* Bulk input endpoint for commands */
      const quint16 USB_TIMEOUT_MSEC = 300;
  
      const quint16 vendor_id = 0x04e3;
      const quint16 product_id= 0x0001;
  
      class UsbExample : public QObject
      {
          Q_OBJECT
      public:
          explicit UsbExample(QObject *parent = 0);
          ~UsbExample(void);
          void setupDevice(void);
          bool openDevice(void);
          bool closeDevice(void);
          void read(QByteArray *buf);
          void write(QByteArray *buf);
  
      signals:
  
      public slots:
  
      private:
          QUsbManager mUsbManager;
          QUsbDevice* mUsbDev;
  
          QtUsb::DeviceFilter mFilter;
          QtUsb::DeviceConfig mConfig;
      };
  
      #endif // USBEXAMPLE_H
  </code></pre>
  
  <p>cpp</p>
  
  <pre><code>    #include &lt;iostream&gt;
      #include "usbexample.h"
  
      using namespace std;
  
      #ifdef interface
      #undef interface
      #endif
  
      UsbExample::UsbExample(QObject *parent) : QObject(parent) {
        this-&gt;setupDevice();
  
        QByteArray send, recv;
  
        send.append(".[]=R00[]=R01[]=R02$");
  
        if (this-&gt;openDevice()) {
          cerr &lt;&lt; "Device open!" &lt;&lt; endl;
          this-&gt;write(&amp;send);
          this-&gt;read(&amp;recv);
        }
      }
  
      UsbExample::~UsbExample() { delete mUsbDev; }
  
      void UsbExample::setupDevice() {
        /* There are 2 ways of identifying devices depending on the platform.
         * You can use both methods, only one will be taken into account.
         */
  
        mUsbDev = new QUsbDevice();
        mUsbDev-&gt;setDebug(true);
  
      #if 1
        // Bus 003 Device 004: ID 04e3:0001 Zilog, Inc.
        mFilter.pid = 0x0001;
        mFilter.vid = 0x04E3;
      #else
        mFilter.vid = 0x0c4b;
        mFilter.pid = 0x0400;
      #endif
  
        //
        mConfig.alternate = 0;
        mConfig.config = 0;
        mConfig.interface = 0;
        mConfig.readEp = 0x81;
        mConfig.writeEp = 0x02;
      }
  
      bool UsbExample::openDevice() {
        cerr &lt;&lt; "Opening" &lt;&lt; endl;
  
        QtUsb::DeviceStatus ds;
  
        ds = mUsbManager.openDevice(mUsbDev, mFilter, mConfig);
  
        if (ds == QtUsb::deviceOK) {
          // Device is open
          return true;
        }
        return false;
      }
  
      bool UsbExample::closeDevice() {
        cerr &lt;&lt; "Closing" &lt;&lt; endl;
        mUsbManager.closeDevice(mUsbDev);
        return false;
      }
  
      void UsbExample::read(QByteArray *buf) { mUsbDev-&gt;read(buf, 1); }
  
      void UsbExample::write(QByteArray *buf) { mUsbDev-&gt;write(buf, buf-&gt;size()); }
  
      #include "usbexample.h"
      #include &lt;QCoreApplication&gt;
      #include &lt;QTimer&gt;
      #include &lt;iostream&gt;
  
  
      void customLogHandler(QtMsgType type, const QMessageLogContext&amp; context,
                            const QString&amp; msg)
      {
         // send the data to log file via the other thread
         // emit writeToFile(type, context, msg);
  
         // now output to debugger console
      #ifdef Q_OS_WIN
          OutputDebugString(text.toStdWString().c_str());
      #else
          std::cerr &lt;&lt; "Type:" &lt;&lt; type &lt;&lt; ", cat:" &lt;&lt; context.category &lt;&lt; ", file:" &lt;&lt; context.file
                        &lt;&lt; ", line:" &lt;&lt; context.line
                        &lt;&lt; ", f:" &lt;&lt; context.function &lt;&lt; ", msg:" &lt;&lt; msg.toStdString() &lt;&lt; std::endl;
      #endif
      }
  
  
      int main(int argc, char *argv[]) {
          qInstallMessageHandler(&amp;customLogHandler);
        QCoreApplication a(argc, argv);
        QTimer timer;
  
        QObject::connect(&amp;timer, SIGNAL(timeout()), &amp;a, SLOT(quit()));
  
        timer.setInterval(1000);
        timer.setSingleShot(true);
        timer.start();
  
        UsbExample example;
  
        return a.exec();
      }
  </code></pre>