为什么我无法在 Raspberry Pi 上使用 D2XX 访问我的 FTDI 设备? [英] Why can't I access my FTDI device using D2XX on a Raspberry Pi?

查看:83
本文介绍了为什么我无法在 Raspberry Pi 上使用 D2XX 访问我的 FTDI 设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 FTDI 的 D2XX 驱动程序来访问 Raspberry Pi 3 上的 USB 串行设备.这是我迄今为止所做的:

I'm trying to make use of FTDI's D2XX drivers to access a USB-Serial device on a Raspberry Pi 3. Here's what I've done so far:

  • 我下载了驱动程序的 1.3.6 ARMv6 hard-float 版本(说明它适用于 Raspberry Pi),然后按照自述文件说明将其安装到/usr/local/lib 文件夹中
  • 我按照建议运行了 sudo rmmod ftdi_siosudo rmmod usbserial 命令以卸载默认内核驱动程序
  • 在我的程序中,我做的第一件事是调用 FT_SetVIDPID 函数,以便为我的特定设备正确配置它
  • 在我的程序中,我可以通过 FT_CreateDeviceInfoList 函数验证是否插入了 1 个设备
  • I downloaded the 1.3.6 ARMv6 hard-float version of the driver (which states that it is suitable for a Raspberry Pi), and then followed the Readme instructions to install it into the /usr/local/lib folder
  • I ran the sudo rmmod ftdi_sio and sudo rmmod usbserial commands as advised to unload the default kernel driver
  • In my program, the first thing I do is invoke the FT_SetVIDPID function so that it is properly configured for my particular device
  • In my program, I can verify that there is 1 device plugged in via the FT_CreateDeviceInfoList function

但是,在我的程序中,尝试调用 FT_Open 始终失败并显示 FT_DEVICE_NOT_FOUND (2).我将程序复制到这里以供参考:

However, in my program, trying to call FT_Open consistently fails with FT_DEVICE_NOT_FOUND (2). I'll copy the program here for reference:

#include <stdio.h>
#include "ftd2xx.h"

int main(int argc, char[] argv)
{
    FT_HANDLE ftHandle;
    FT_STATUS ftStatus;
    int iNumDevs = 0;

    ftStatus = FT_SetVIDPID(0x0403, 0x6015);
    if (FT_OK != ftStatus)
    {
        printf("Error: FT_SetPIDVID(%d)\n", (int)ftStatus);
        return 1;
    }

    ftStatus = FT_CreateDeviceInfoList(&iNumDevs);
    if (FT_OK != ftStatus)
    {
        printf("Error: FT_CreateDeviceInfoList(%d)\n", (int)ftStatus);
        return 1;
    }

    printf("Devices: %d\n", iNumDevs);

    ftStatus = FT_Open(0, &ftHandle);
    if (FT_OK != ftStatus)
    {
        printf("Error: FT_Open(%d)\n", (int)ftStatus);
        return 1;
    }

    // ...

    return 0;
}

我从这个小程序中得到的输出是一致的.它总是:

The output I get from this little program is consistent. It is always:

设备:1

错误:FT_Open(2)

Error: FT_Open(2)

我总是用:

gcc -lftd2xx -o test test.c

第一位确实说有一个连接的设备这一事实让我希望我可以让它工作.但基本上任何其他函数(FT_Open、FT_OpenEx 甚至 FT_ListDevices)都失败并出现相同的 #2 错误.我错过了什么?

The fact that the first bit does say there is one connected device gives me hope that I can get this working. But basically any other function at all (FT_Open, FT_OpenEx, and even FT_ListDevices) fails with the same #2 error. What am I missing?

推荐答案

由于 FTDI D2XX 驱动程序只是在后端使用 libusb 才能与设备进行实际对话,因此您需要具有适当的权限才能进行实际对话它.最简单的方法是简单地在 sudo 下运行程序,这样你就拥有完全的 root 权限.

Since the FTDI D2XX drivers simply use libusb on the backend in order to actually talk with the device, you need to have the proper permissions in order to actually talk with it. The easiest way is to simply run the program under sudo so that you will have full root permissions.

或者,应该可以 以非 root 用户身份访问设备,如果由于某种原因您无法在 sudo 下运行程序.

Alternatively, it should be possible to access the device as a non-root user if for some reason you are unable to run the program under sudo.

这篇关于为什么我无法在 Raspberry Pi 上使用 D2XX 访问我的 FTDI 设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆