title: pyusb - [Error 5] on Linux, but not Windows
body: <p>I'm trying to communicate with an AD9913 evaluation board (Analog Devices), which has a Cypress FX-2 USB controller. I wrote a fully functional Python library which works flawlessly on Windows 7 (using a driver generated through libusb-win32-1.2.6.0's inf-wizard.exe), but now I try to run the same software from a Raspberry Pi 3 with Raspbian Jessie and cannot seem to write or read.</p>
  
  <p>The following minimal example works on Windows 7:</p>
  
  <pre><code>import os
  os.environ['PYUSB_DEBUG'] = 'debug'
  
  import usb.core
  print "usb.core file:", usb.core.__file__
  
  # get device
  dev = usb.core.find(idVendor=0x0456, idProduct=0xEE25)
  if dev is None:
      raise ValueError("Device not found")
  dev.set_configuration()
  
  # get the firmware version
  print "Write: ", dev.write(0x01, [0x00])
  print "Read: ", dev.read(0x81, 7)
  </code></pre>
  
  <p>The ouput here is:</p>
  
  <pre><code>usb.core file: C:\Python27\lib\site-packages\usb\core.pyc
  Write:  1
  Read:  array('B', [1, 0])
  </code></pre>
  
  <p>However, on the Raspberry several problems occur. First, the product ID is 0xEE24 (which I found out through dmesg), and second, the code example above gives</p>
  
  <pre><code>usb.core file: /usr/local/lib/python2.7/dist-packages/usb/core.pyc
  Write:
  Traceback (most recent call last):
      File "usbtesting_minimal_linux.py", line 29, in &lt;module&gt;
        print "Write: ", dev.write(0x01, [0x00])
      File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 948, in write
  self.__get_timeout(timeout)
      File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 824, in bulk_write
  timeout)
      File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 920, in __write
  _check(retval)
      File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 595, in _check
       raise USBError(_strerror(ret), ret, _libusb_errno[ret])
  usb.core.USBError: [Errno 5] Input/Output Error
  </code></pre>
  
  <p>I'm executing the script by calling <code>sudo python minimal_example.py</code>, otherwise (as expected) I get <code>usb.core.USBError: [Errno 13] Access denied (insufficient permissions)</code>. (For the testing described above, I removed the udev rules I added to allow access to my regular user account, and rebooted and replugged the device afterwards.)</p>
  
  <p>I also noticed that on Windows, <code>Configuration 1</code> (which is the only configuration) as revealed by adding</p>
  
  <pre><code>cfg = dev.get_active_configuration()
  </code></pre>
  
  <p>to aforementioned example script, has only one <code>Interface 0</code>, where as on Linux <code>Interface 0</code> has no endpoints, but there are additional interfaces <code>Interface 0, 1</code>, <code>Interface 0, 2</code> and <code>Interface 0,3</code>, the first of which is identical to the sole interface shown by Windows.</p>
  
  <p>Detaching kernel drivers as described <a href="https://stackoverflow.com/questions/23203563/pyusb-device-claimed-detach-kernel-driver-return-entity-not-found">in this post</a> -- which given my current understanding as a USB novice should not be necessary here -- does not resolve the problem.</p>
  
  <p>I suspect that the issue stems from a difference between the Windows/libusb and Linux implementation/backend of the USB communication (already hinted at by the fact that the productID shown is different for the very same piece of hardware attached), which might require some changes to the way I'm writing to the USB endpoint.</p>
  
  <p>I'm happy to provide more information if needed and welcome all hints and suggestions.</p>