eblot / pyftdi

FTDI device driver written in pure Python
Other
509 stars 212 forks source link

0.55 Operation not supported or unimplemented on this platform (FT4232HA) Windows #350

Closed MSOcu closed 1 year ago

MSOcu commented 1 year ago

Hi! First, let me thank you for the overall great working library! I used the pyftdi together with the FT4232H mini module and it worked like a charm. I made a custom board based on the FT4232H(A) variant since it was the only available version at the time. I've seen, that support for this device was added recently with version 0.55. The device is detected correctly, but I receive the error message: "Error: Operation not supported or unimplemented on this platform" when using the ftdi_urls.py. To emulate the behavior of the FT4232H I programmed the EEPROM of the FT4232HA device to match the VID of the standard one. The issue is still present. Additional information: My machine is running Windows 11. I'm using the libusb-1.2.7.3 driver. When using my code, which is working with the FT4232H I received some more information:

Traceback (most recent call last):
  File "c:\Users\Hidden\Documents\Testsystem\Testsystem_SW\Python\I2C_Test\PCA9548.py", line 8, in <module>
    i2c.configure('ftdi://ftdi:4232:5:a/2', frequency = 10000)
  File "C:\Users\Hidden\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyftdi-0.55.0-py3.11.egg\pyftdi\i2c.py", line 498, in configure
  File "C:\Users\Hidden\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyftdi-0.55.0-py3.11.egg\pyftdi\ftdi.py", line 633, in open_mpsse_from_url
  File "C:\Users\Hidden\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyftdi-0.55.0-py3.11.egg\pyftdi\ftdi.py", line 399, in get_identifiers
  File "C:\Users\Hidden\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyftdi-0.55.0-py3.11.egg\pyftdi\usbtools.py", line 312, in parse_url
  File "C:\Users\Hidden\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyftdi-0.55.0-py3.11.egg\pyftdi\usbtools.py", line 417, in enumerate_candidates
  File "C:\Users\Hidden\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyftdi-0.55.0-py3.11.egg\pyftdi\usbtools.py", line 100, in find_all
  File "C:\Users\Hidden\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyftdi-0.55.0-py3.11.egg\pyftdi\usbtools.py", line 556, in get_string
  File "C:\Users\Hidden\AppData\Local\Programs\Python\Python311\Lib\site-packages\usb\util.py", line 311, in get_string
    langids = dev.langids
              ^^^^^^^^^^^
  File "C:\Users\Hidden\AppData\Local\Programs\Python\Python311\Lib\site-packages\usb\core.py", line 851, in langids
    self._langids = util.get_langids(self)
                    ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Hidden\AppData\Local\Programs\Python\Python311\Lib\site-packages\usb\util.py", line 266, in get_langids
    buf = get_descriptor(
          ^^^^^^^^^^^^^^^
  File "C:\Users\Hidden\AppData\Local\Programs\Python\Python311\Lib\site-packages\usb\control.py", line 172, in get_descriptor
    desc = dev.ctrl_transfer(
           ^^^^^^^^^^^^^^^^^^
  File "C:\Users\Hidden\AppData\Local\Programs\Python\Python311\Lib\site-packages\usb\core.py", line 1071, in ctrl_transfer
    self._ctx.managed_open()
  File "C:\Users\Hidden\AppData\Local\Programs\Python\Python311\Lib\site-packages\usb\core.py", line 113, in wrapper
    return f(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Hidden\AppData\Local\Programs\Python\Python311\Lib\site-packages\usb\core.py", line 131, in managed_open
    self.handle = self.backend.open_device(self.dev)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Hidden\AppData\Local\Programs\Python\Python311\Lib\site-packages\usb\backend\libusb1.py", line 804, in open_device
    return _DeviceHandle(dev)
           ^^^^^^^^^^^^^^^^^^
  File "C:\Users\Hidden\AppData\Local\Programs\Python\Python311\Lib\site-packages\usb\backend\libusb1.py", line 652, in __init__
    _check(_lib.libusb_open(self.devid, byref(self.handle)))
  File "C:\Users\Hidden\AppData\Local\Programs\Python\Python311\Lib\site-packages\usb\backend\libusb1.py", line 600, in _check
    raise NotImplementedError(_strerror(ret))

Thank you in advance!

MSOcu commented 1 year ago

Solved: Issue was, that two different FTDI devices where connected simultaniously. One using the standard windows driver (necessary to funtion properly with third party software) and the target device using libusb. Device was instanciated through the URL. During initalization pyusb tries to communicate with the device through incopatible drivers and throws a exception, even if it is not the device which should be connectes. Fix: Create pyftdi object with an usb.core device object, called by VID:PID.