title: How can I comunicate with this device using pyusb?
body: <p>I have a Netware uniFlow device. When I plug it in it shows up in dmesg:</p>
  
  <pre><code>[ 2962.369905] usb 2-1.4: new full-speed USB device number 11 using ehci-pci
  [ 2962.463867] usb 2-1.4: New USB device found, idVendor=171b, idProduct=2001
  [ 2962.463871] usb 2-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
  [ 2962.463874] usb 2-1.4: Product: USB Keyboard
  [ 2962.463876] usb 2-1.4: Manufacturer: RFIDeas
  [ 2962.465361] input: RFIDeas USB Keyboard as /devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4:1.0/0003:171B:2001.0008/input/input17
  [ 2962.465481] hid-generic 0003:171B:2001.0008: input,hidraw3: USB HID v1.10 Keyboard [RFIDeas USB Keyboard] on usb-0000:00:1d.0-1.4/input0
  </code></pre>
  
  <p>It also appears in the listed USB devices, with the <code>lsusb</code> command:</p>
  
  <pre><code>Bus 002 Device 011: ID 171b:2001
  </code></pre>
  
  <p>Correct me if I am wrong here, but I think I need to unbind the device, so that I may use pyusb to to communicate with the device. When I try to run my code, I get resource busy errors.</p>
  
  <p>So then I cd'd down to /sys/bus/usb/devices/usb2/2-1/2-1.4 (taken form dmesg) and then tried to unbind the device using</p>
  
  <pre><code>sudo sh -c echo "2-1.4:1.0 &gt; unbind"
  </code></pre>
  
  <p>But I got permission denied. So I logged in as root, but I still got permission denied.</p>
  
  <p>Here is my source code that I am trying to use to communicate with the device:</p>
  
  <pre><code>#!/usr/bin/env python
  import usb.core
  import usb.util
  import sys
  
  # Find our device from lsusb
  # Vendor : Product     171b:2001
  dev = usb.core.find(idVendor=0x171b, idProduct=0x2001)
  
  # Was it found?
  if dev is None:
      raise ValueError('Device not found')
  
      # Set the active configuration. With no arguments, the first
      # configuration will be the active one
  dev.set_configuration()
  
      # Let's fuzz around!
  
      # Let's start by reading one byte from the device using different requests
      # bRequest is a byte so there are 255 different values
  for bRequest in range(255):
      try:
          ret = dev.ctrl_transfer(0xC0, bRequest, 0, 0, 1)
          print "bRequest ",bRequest
          print ret
      except:
         # Failed to get data for this request
           pass
  </code></pre>
  
  <p>And here are the errors, I get when I try to run the program:</p>
  
  <pre><code>$ sudo python usbhax.py
  Traceback (most recent call last):
    File "usbhax.py", line 16, in &lt;module&gt;
      dev.set_configuration()
    File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 799, in set_configuration
      self._ctx.managed_set_configuration(self, configuration)
    File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 128, in managed_set_configuration
      self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
    File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 730, in set_configuration
      _check(self.lib.libusb_set_configuration(dev_handle.handle, config_value))
    File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 552, in _check
      raise USBError(_strerror(ret), ret, _libusb_errno[ret])
  usb.core.USBError: [Errno 16] Resource busy
  </code></pre>
  
  <p>What am I doing wrong? What can I do to communicate with this device?</p>
  
  <p>Yes, I have libusb installed, and pyusb. I am working from a Ubuntu environment.</p>