For some reason D2XX won't open a FT4232H device on Linux. I'm using function calls FT_CreateDeviceInfoList(), FT_GetDeviceInfoList(), and FT_OpenEx() in the driver.
Here is the code which is based on an example:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "../ftd2xx.h"
static void showVersion (DWORD locationID)
{
FT_STATUS ftStatus;
FT_HANDLE ftHandle = (FT_HANDLE) NULL;
ftStatus = FT_OpenEx((PVOID)(uintptr_t)locationID, FT_OPEN_BY_LOCATION, &ftHandle);
if (!FT_SUCCESS(ftStatus))
{
printf("FT_OpenEx failed (error %d)\n",
(int)ftStatus);
return;
}
(void)FT_Close(ftHandle);
}
int main (void)
{
FT_STATUS ftStatus;
FT_DEVICE_LIST_INFO_NODE *devInfo = NULL;
DWORD numDevs = 0;
int retCode = 0;
ftStatus = FT_CreateDeviceInfoList(&numDevs);
if (!FT_SUCCESS(ftStatus))
{
printf("FT_CreateDeviceInfoList failed (error %d)\n",
(int)ftStatus);
retCode = EXIT_FAILURE;
goto exit;
}
if (numDevs == 0)
{
printf("No devices connected\n");
retCode = EXIT_FAILURE+1;
goto exit;
}
else
{
printf("Number of devices is %d\n", numDevs);
}
/* Allocate Storage */
devInfo = calloc((size_t)numDevs, sizeof(FT_DEVICE_LIST_INFO_NODE));
if (devInfo == NULL)
{
printf("Allocation failure.\n");
retCode = EXIT_FAILURE+2;
goto exit;
}
ftStatus = FT_GetDeviceInfoList(devInfo, &numDevs);
if (!FT_SUCCESS(ftStatus))
{
printf("FT_GetDeviceInfoList failed (error %d)\n",
(int)ftStatus);
retCode = EXIT_FAILURE+3;
goto exit;
}
for (int i=0; i<(int)numDevs; i++)
{
printf("Device[%d] Type is 0x%x\n", i, devInfo[i].Type);
printf("Device[%d] LocId is 0x%x\n", i, devInfo[i].LocId);
printf("Device[%d] Flags is 0x%x\n", i, devInfo[i].Flags);
showVersion(devInfo[i].LocId);
}
exit:
free(devInfo);
return retCode;
}
Here is the output (x4):
Number of devices is 4
Device[0] Type is 0x3
Device[0] LocId is 0x0
Device[0] Flags is 0x1
FT_OpenEx() fails with error 2 (FT_DEVICE_NOT_FOUND).
A device info flags value of 1 seems to indicate that the device is already open. Is that correct?
The error code from open function seems to indicate that the device was not found, which is a little confusing.
I unloaded the VCP driver as explained in
https://www.ftdichip.com/Support/Documents/AppNotes/AN_220_FTDI_Drivers_Installation_Guide_for_Linux.pdflinux@linux-desktop:~$ sudo rmmod ftdi_sio
linux@linux-desktop:~$ sudo rmmod usbserial
linux@linux-desktop:~$ dmesg | grep ftdi
[13124.959002] usbcore: registered new interface driver ftdi_sio
[13124.959155] ftdi_sio 1-1.2:1.0: FTDI USB Serial Device converter detected
[13124.962715] ftdi_sio 1-1.2:1.1: FTDI USB Serial Device converter detected
[13124.963148] ftdi_sio 1-1.2:1.2: FTDI USB Serial Device converter detected
[13124.965881] ftdi_sio 1-1.2:1.3: FTDI USB Serial Device converter detected
[13171.085880] ftdi_sio ttyUSB3: FTDI USB Serial Device converter now disconnected from ttyUSB3
[13171.086023] ftdi_sio ttyUSB2: FTDI USB Serial Device converter now disconnected from ttyUSB2
[13171.086336] ftdi_sio ttyUSB1: FTDI USB Serial Device converter now disconnected from ttyUSB1
[13171.087592] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
[13171.087638] usbcore: deregistering interface driver ftdi_sio
[13171.087688] ftdi_sio 1-1.2:1.3: device disconnected
[13171.087751] ftdi_sio 1-1.2:1.2: device disconnected
[13171.087810] ftdi_sio 1-1.2:1.1: device disconnected
[13171.087868] ftdi_sio 1-1.2:1.0: device disconnected
Anyone see why the device isn't opening?