LibFTDI kills ttyUSB

  c++, ftdi, libftdi

I have two FTDI devices connected to a machine running Ubuntu 20.04. One is a FT232H the other one a FT4232H. lsusb gives me this output:

Bus 001 Device 003: ID 0403:6014 Future Technology Devices International, Ltd FT232H 
Single HS USB-UART/FIFO IC
Bus 001 Device 007: ID 0d8c:000c C-Media Electronics, Inc. Audio Adapter
Bus 001 Device 008: ID 0403:6011 Future Technology Devices International, Ltd FT4232H 
Quad HS USB-UART/FIFO IC
Bus 001 Device 005: ID 04b4:6572 Cypress Semiconductor Corp. Unprogrammed CY7C65642 hub
Bus 001 Device 006: ID 0eef:7200 D-WAV Scientific Co., Ltd Touchscreen Controller
Bus 001 Device 004: ID 0424:2514 Microchip Technology, Inc. (formerly SMSC) USB 2.0 Hub
Bus 001 Device 002: ID 1a40:0201 Terminus Technology Inc. FE 2.1 7-port Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

The FTDI devices show up as ttyUSB in /dev as one would expect:

[email protected]:~$ ls /dev | grep ttyUSB
ttyUSB0
ttyUSB1
ttyUSB2
ttyUSB3
ttyUSB4

ttyUSB0 - ttyUSB3 are the individual ports of the FT4232H, ttyUSB4 is the FT232H. This I know for sure, since I can control the hardware connected through these ports.

When I connect to the FT232H through libftdipp everything works as expected, I can communicate and control the GPIOs on the chip. But once my program to connect to the FT232H starts the first tty ttyUSB0 disappears.

The program I use libftdi with looks like this (minimal example):

#include <iostream>
#include <thread>
#include <libftdi1/ftdi.hpp>
#include <usb.h>
#include <stdio.h>
#include <iostream>
#include <string.h>

When I run it it looks like this:

[email protected]:~$ ls /dev | grep ttyUSB
ttyUSB0
ttyUSB1
ttyUSB2
ttyUSB3
ttyUSB4


#define VENDOR 0x0403
#define PRODUCT 0x6014

int main(void)
{
   struct ftdi_context ftdi;
   int ftdi_status = 0;
   ftdi_status = ftdi_init(&ftdi);
   if ( ftdi_status != 0 ) {
      std::cout << "Failed to initialize devicen";
      return 1;
   }
   ftdi_status = ftdi_usb_open(&ftdi, VENDOR, PRODUCT);

   // close ftdi
   ftdi_usb_reset(&ftdi);
   ftdi_usb_close(&ftdi);
   return 0;
}

When I run it it looks like this:

[email protected]:/opt/apps$ ls /dev | grep ttyUSB
ttyUSB0
ttyUSB1
ttyUSB2
ttyUSB3
ttyUSB4
[email protected]:/opt/apps$ ./iocontrollertest
[email protected]:/opt/apps$ ls /dev | grep ttyUSB
ttyUSB1
ttyUSB2
ttyUSB3
ttyUSB4

What could be the reason for this unrelated device to disappear?

Source: Windows Questions C++

LEAVE A COMMENT