我的 Windows7 上 FT4222 的 USB 位置地址错误

问题描述

我有一台带有 3 个 USB 端口的 Windows 7 笔记本电脑(Sony pcg 81113M),当我连接 2 * Ft 4222HQ 并运行“Getting start code for the Ft4222”(C++ Qtcreator)时,我得到了一个错误的 USB 位置0x00。当我在特定的 2 个端口中只连接一个时也是如此。

enter image description here

我正在使用软件 USBview 验证连接的 FTDI 的 USB 位置。

enter image description here

我在我的程序中使用“按位置连接”,如果我同时连接两个,它会将其视为一台设备(因为位置 ID 相同)

FTDI 驱动程序是最新版本,我在设备管理器中看到所有接口

enter image description here

注意:第三个 USB 端口工作正常,我得到了正确的位置 ID:

enter image description here

enter image description here

操作系统是win7 64位,FTDI代码在32位上运行(我用64位也得到相同的结果)

有人对此有什么想法吗?是否有其他一些测试可以让我找出问题所在?

这是 FTDI 入门代码

[来源] https://www.ftdichip.com/Support/SoftwareExamples/LibFT4222-v1.4.4.zip

void ListFtUsbDevices()
{
    FT_STATUS ftStatus = 0;

    DWORD numOfDevices = 0;
    ftStatus = FT_CreateDeviceInfoList(&numOfDevices);

    for(DWORD iDev=0; iDev<numOfDevices; ++iDev)
    {
        FT_DEVICE_LIST_INFO_NODE devInfo;
        memset(&devInfo,sizeof(devInfo));

        ftStatus = FT_GetDeviceInfoDetail(iDev,&devInfo.Flags,&devInfo.Type,&devInfo.ID,&devInfo.Locid,devInfo.SerialNumber,devInfo.Description,&devInfo.ftHandle);

        if (FT_OK == ftStatus)
        {
            printf("Dev %d:\n",iDev);
            printf("  Flags= 0x%x,(%s)\n",devInfo.Flags,DeviceFlagToString(devInfo.Flags).c_str());
            printf("  Type= 0x%x\n",devInfo.Type);
            printf("  ID= 0x%x\n",devInfo.ID);
            printf("  Locid= 0x%x\n",devInfo.Locid);
            printf("  SerialNumber= %s\n",devInfo.SerialNumber);
            printf("  Description= %s\n",devInfo.Description);
            printf("  ftHandle= 0x%x\n",devInfo.ftHandle);

            const std::string desc = devInfo.Description;
            if(desc == "FT4222" || desc == "FT4222 A")
            {
                g_FT4222DevList.push_back(devInfo);
            }
        }
    }
}

主程序:

int main(int argc,char const *argv[])
{
    ListFtUsbDevices();   

    if(g_FT4222DevList.empty()) {
        printf("No FT4222 device is found!\n");
        return 0;
    }


    ftStatus = FT_OpenEx((PVOID)g_FT4222DevList[0].Locid,FT_OPEN_BY_LOCATION,&ftHandle);
    if (FT_OK != ftStatus)
    {
        printf("Open a FT4222 device Failed!\n");
        return 0;
    }
    
    printf("\n\n");
    printf("Init FT4222 as SPI master\n");
    ftStatus = FT4222_SPIMaster_Init(ftHandle,SPI_IO_SINGLE,CLK_DIV_4,CLK_IDLE_LOW,CLK_LEADING,0x01);
    if (FT_OK != ftStatus)
    {
        printf("Init FT4222 as SPI master device Failed!\n");
        return 0;
    }

    printf("Todo ...\n");
    printf("\n");


    printf("UnInitialize FT4222\n");
    FT4222_UnInitialize(ftHandle);

    printf("Close FT device\n");
    FT_Close(ftHandle);
    
    return 0;
}

解决方法

https://ftdichip.com/wp-content/uploads/2020/08/TN_152_USB_3.0_Compatibility_Issues_Explained.pdf 部分 2.1.2 位置 ID 返回为 0

LocationID 并不是严格意义上的 USB 规范的一部分 由 FTDI 提供。该功能是作为附加选项添加到 通过索引、序列号或备份识别和打开端口 产品描述字符串。

当连接到 USB 2.0 端口时,位置是根据 设备连接到的 USB 端口。这些值是 派生自特定的注册表项。作为 3rd 的注册表树 方 USB 3.0 主机驱动程序与 Microsoft 通用驱动程序不同 无法计算位置 ID。

目前没有解决此问题的方法,因此设备 应按索引、序列号或产品列出和打开 描述字符串。

所以这是已知的行为。顺便说一句,Win 7 EOL 日期是 2020 年 1 月。强烈建议更改操作系统。