Search code examples
pythonpython-3.xftdi

ftd2xx.open creates always the device status FT_INVALID_HANDLE


I try the to use ftd2xx library with Ubuntu. But always when I want to open the device, the received status is FT_INVALID_HANDLE.
Before I tried this with python I wrote a program in C which is working well. As library for both programs I use libftd2xx.so.1.3.6.

import ftd2xx as ft

g = ft.open(0)
g.status

>> 1  #FT_INVALID_HANDLE

Why is the device status always FT_INVALID_HANDLE?


Solution

  • The status is declared as 1 in the class. The status tells you only if the device is open with a 1 or not with a 0.

    class FTD2XX(object):
        """Class for communicating with an FTDI device"""
        def __init__(self, handle, update=True):
            """Create an instance of the FTD2XX class with the given device handle
            and populate the device info in the instance dictionary. Set
            update to False to avoid a slow call to createDeviceInfoList."""
            self.handle = handle
            self.status = 1
            # createDeviceInfoList is slow, only run if update is True
            if update: createDeviceInfoList()
            self.__dict__.update(self.getDeviceInfo())