3

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:

  • 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

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:

Devices: 1

Error: FT_Open(2)

I always build this program with:

gcc -lftd2xx -o test test.c

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?

4

1 回答 1

4

由于 FTDI D2XX 驱动程序只是在后端使用 libusb 来与设备进行实际对话,因此您需要拥有适当的权限才能与它进行实际对话。最简单的方法是简单地运行程序,sudo以便您拥有完整的 root 权限。

或者,如果由于某种原因您无法sudo.

于 2017-02-23T14:47:39.533 回答