【问题标题】:ftd2xx.open creates always the device status FT_INVALID_HANDLEftd2xx.open 始终创建设备状态 FT_INVALID_HANDLE
【发布时间】:2018-10-09 13:01:25
【问题描述】:

我尝试在 Ubuntu 中使用 ftd2xx 库。但总是当我想打开设备时,收到的状态是 FT_INVALID_HANDLE。
在我尝试使用 python 之前,我用 C 编写了一个运行良好的程序。作为这两个程序的库,我使用 libftd2xx.so.1.3.6。

import ftd2xx as ft

g = ft.open(0)
g.status

>> 1  #FT_INVALID_HANDLE

为什么设备状态总是FT_INVALID_HANDLE?

【问题讨论】:

    标签: python python-3.x ftdi


    【解决方案1】:

    状态在类中被声明为 1。 status 仅告诉您设备是否以 1 打开或不以 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())
    

    【讨论】:

      猜你喜欢
      • 2017-03-13
      • 1970-01-01
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 2019-01-17
      • 2019-08-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多