Take the 2-minute tour ×  I want to read the content of a pen-
drive data connected to a FTDI board through a c program. I have
the following code using which I can read partial data but that
also happens sometimes not every time I connect the board to PC.
Can you please tell me what changes should be made to the code
#include <termios.h> #include <unistd.h> int n = 0; struct
termios tty; struct termios tty_old;      unsigned char
buf[100];     int fd;     fd= open("/dev/ttyUSB0", O_RDWR|
O_NOCTTY);           printf("Port opened\n");     memset (&tty,
0, sizeof tty);     printf("set attributes\n");     /* Error
Handling */     if ( tcgetattr ( fd, &tty ) != 0 )
printf("Error from tcgetattr:%d \n",strerror(errno));      /*
Save old tty parameters */     tty_old = tty;      /* Set Baud
Rate */     cfsetospeed (&tty, (speed_t)B9600);     cfsetispeed
(&tty, (speed_t)B9600);      /* Setting other Port Stuff */
tty.c_cflag     &=  ~PARENB;        // Make 8n1     tty.c_cflag
&=  ~CSTOPB;     tty.c_cf