ftd2xx icon indicating copy to clipboard operation
ftd2xx copied to clipboard

listDevices returns exception DEVICE_NOT_OPENED

Open pylogger-html opened this issue 2 years ago • 1 comments

Describe the bug I have 3 FTDI devices plugged into my machine and for some reason one of them triggers this issue with listDevices. The initial call with LIST_NUMBERS_ONLY works, but the subsequent LIST_ALL command returns an error.

import ftd2xx as d2
d2.listDevices()
DEBUG:ftd2xx:Found 3 devices
Traceback (most recent call last):
  File "C:\Users\pmulligan\AppData\Local\Programs\Python\Python39\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "C:\Users\xx\PycharmProjects\xx2\venv\lib\site-packages\ftd2xx\ftd2xx.py", line 155, in listDevices
    call_ft(_ft.FT_ListDevices, ba, c.byref(n), _ft.DWORD(defines.LIST_ALL | flags))
  File "C:\Users\xx\PycharmProjects\xx2\venv\lib\site-packages\ftd2xx\ftd2xx.py", line 133, in call_ft
    raise DeviceError(status)
ftd2xx.ftd2xx.DeviceError: DEVICE_NOT_OPENED

To Reproduce One of the FTDI devices is quite old, so it may be difficult to reproduce this issue (it's the LogicPort by Intronix). I'm trying to open a connection to the FTDI device with description "abc". Here is what the detailed device info returns:

d2.getDeviceInfoDetail(0)
{'index': 0, 'flags': 1, 'type': 3, 'id': 0, 'location': 0, 'serial': b'', 'description': b'', 'handle': c_void_p(None)}
d2.getDeviceInfoDetail(1)
{'index': 1, 'flags': 0, 'type': 9, 'id': 67330049, 'location': 4916, 'serial': b'0079ALP1', 'description': b'abc', 'handle': c_void_p(None)}
d2.getDeviceInfoDetail(2)
{'index': 2, 'flags': 1, 'type': 3, 'id': 0, 'location': 0, 'serial': b'', 'description': b'', 'handle': c_void_p(None)}

USB Device info (adding in the final device triggers the bug) vID=0x0403, pID=0x6001, sn=0079ALP1, fw_rev=10.0 vID=0x0403, pID=0x6001, sn=FTC1TI89, fw_rev=6.00 vID=0x0403, pID=0xDC48, sn=92700463, fw_rev=4.00

Expected behavior listDevices should return a number. You should be able to run this command before opening a device.

Logs See above.

Desktop (please complete the following information):

  • OS: windows
  • OS Version: window 10
  • Python Version: python 3.9
  • FTDI driver version: 2.12.36.4, although the logicport seems to use 2.8.24.0

pylogger-html avatar Sep 19 '22 18:09 pylogger-html

FTDI has a FAQ on this subject. I guess we could add a listDeviceCount that bypasses collecting the description strings.

snmishra avatar Sep 20 '22 02:09 snmishra