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_sioandsudo rmmod usbserialcommands as advised to unload the default kernel driver - In my program, the first thing I do is invoke the
FT_SetVIDPIDfunction 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_CreateDeviceInfoListfunction
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?
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
sudoso that you will have full root permissions.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.