【问题标题】:FTDI FTD2xx_NET detects unknown device. CyclePort failsFTDI FTD2xx_NET 检测到未知设备。 CyclePort 失败
【发布时间】:2021-08-31 06:54:45
【问题描述】:

我想检测连接的 USB 设备(FT232R USB UART,虚拟 com 端口驱动程序)。这通常工作正常,但由于 Windows 更新,我的设备被检测为 FTDI_DEVICE_UNKNOWN。奇怪的行为是,当我第一次插入设备然后启动软件时,一切正常。如果我先启动软件然后插入设备,它就没有被检测到。我尝试使用 CyclePort 重新连接设备,但失败并显示状态 FT_OTHER_ERROR。在 Windows 设备管理器中检测并显示这两种情况下的设备。驱动程序已经更新并手动安装。 关于造成这种情况的任何想法?

这是我的代码:

            List<string> pcdSerials = new List<string>();
            FTDI ftdi = new FTDI(); 
            UInt32 ftdiDeviceCount = 0;
            FTDI.FT_STATUS ftStatus = FTDI.FT_STATUS.FT_OK;

            ftStatus = ftdi.GetNumberOfDevices(ref ftdiDeviceCount);
            if (ftStatus != FTDI.FT_STATUS.FT_OK)
            {
                return pcdSerials;
            }
            FTDI.FT_DEVICE_INFO_NODE[] ftdiDeviceList = new FTDI.FT_DEVICE_INFO_NODE[ftdiDeviceCount];
            ftStatus = ftdi.GetDeviceList(ftdiDeviceList);
            if (ftStatus != FTDI.FT_STATUS.FT_OK)
            {
                return pcdSerials;
            }

            foreach (var info in ftdiDeviceList)
            {                    
                if (info.Type == FTDI.FT_DEVICE.FT_DEVICE_UNKNOWN)
                {
                    if (ftdiDeviceList.Count() == 1)
                    { 
                        // The effect of this function is the same as disconnecting then reconnecting the device from USB. 
                        // Possible use of this function is in situations where a fatal error has occurred and it is difficult, or not possible, to recover without unplugging and replugging the USB cable. This function can also be used after re-programming the EEPROM to force the FTDI device to read the new EEPROM contents which previously required a physical disconnect-reconnect.

                        ftStatus = ftdi.CyclePort();                         
                        if (ftStatus == FTDI.FT_STATUS.FT_OK)
                        {                                
                            // Port has been cycled. Close the handle.
                            ftStatus = ftdi.Close();
                        }
                        else
                        {
                            // FT_CyclePort FAILED!
                        }                        
                        break;                            
                    }
                }                  

                if (info.Description != "FT232R USB UART")
                    continue;
                if (info.Type != FTDI.FT_DEVICE.FT_DEVICE_232R)
                    continue;
               
                pcdSerials.Add(info.SerialNumber);
            }

            return pcdSerials;

【问题讨论】:

    标签: c# winforms serial-port ftdi reconnect


    【解决方案1】:

    这不是答案,而是评论。作为 Stack overflow 的新手,它不会让我简单地为您的问题添加评论,或者我不知道我在做什么。 :) 我有什么听起来像同样的问题。我在 10 多年前编写了一个包装器类,它一直运行良好,直到新的 FTDI 驱动程序 2.12.36.1 在客户端计算机上更新。 FTDI 于 2021 年 6 月 17 日发布了驱动程序版本 2.12.36.2,我希望它能解决问题,但没有。 我发现调用 FT_CreateDeviceInfoList 确实会返回正确数量的连接设备。然后我调用 FT_GetDeviceInfoDetail 来获取设备类型、描述和 FTDI 序列号。设备类型返回值为 0x03,即 FT_Device_Unknown,描述和序列号显示为空。我使用 FTDI 序列号通过序列号打开设备。没有有效的序列号,我无法打开设备。多年来,我一直使用这种方法作为 FTDI 的首选方法,直到现在都没有问题。 希望其他人可以提供答案,因为我有很多客户无法通过他们的 PC 连接到我的产品。 我将联系 FTDI 支持人员,看看他们是否可以解决这个问题。如果我收到回复,我会在这里发帖。

    【讨论】:

    • 感谢您的帖子。我没有解决这个问题,所以如果你有任何进一步的想法,请告诉我。
    【解决方案2】:

    我最近遇到了同样的问题。如果您运行 FT_prog,您可以通过移除加密狗并将其放回原处来复制它。 FT_prog 需要一秒钟左右才能再次识别设备。

    我将检查代码放入一个等待 1 秒的循环中,现在它在第二次尝试时可靠地找到了加密狗。

    【讨论】:

      猜你喜欢
      • 2017-12-16
      • 1970-01-01
      • 2019-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-15
      • 2021-11-09
      • 1970-01-01
      相关资源
      最近更新 更多