我 Windows7 上 FT4222 的 USB Location 地址错误

Wrong USB Location address of the FT4222 on my Windows7

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

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

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

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

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

os是win7 64bit,FTDI代码运行s在32bit上(我用64bit也是一样的结果)

有人对此有想法吗?我可以做一些其他测试来解决问题吗?

这是 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, 0, 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

LocationIDs are not strictly part of the USB spec in the format provided by FTDI. The feature was added as an additional option to back up identifying and opening ports by index, serial number or product description strings.

When connected to a USB 2.0 port the location is provided on the basis of the USB port that the device is connected to. These values are derived from specific registry keys. As the registry tree for 3rd party USB 3.0 host drivers is different to the Microsoft generic driver the Location ID cannot be calculated.

There is no workaround to this current issue and as such devices should be listed and opened by index, serial number or product description strings.

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