rendered paste body #include <stdio.h> /* Standard input/output definitions */ #include <string.h> /* String function definitions */ #include <unistd.h> /* UNIX standard function definitions */ #include <fcntl.h> /* File control definitions */ #include <errno.h> /* Error number definitions */ #include <termios.h> /* POSIX terminal control definitions */int main(int argc, char **argv){ int fd; struct termios options; char buffer[128]; /* Input buffer */ int nbytes; /* Number of bytes read */ int tries; /* Number of tries so far */ fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY); fcntl(fd, F_SETFL, 0); if (fd == -1)perror("open_port: Unable to open /dev/ttyUSB0 - "); fcntl(fd, F_SETFL, 0); /* get the current options */ tcgetattr(fd, &options); options.c_cflag &= ~PARENB; options.c_cflag &= ~CSTOPB; options.c_cflag &= ~CSIZE; options.c_cflag |= CS8; options.c_iflag &= ~(IXON | IXOFF | IXANY); options.c_oflag &= ~OPOST; /* * Set the baud rates to 19200... */ cfsetispeed(&options, B19200); cfsetospeed(&options, B19200); /* set the options */ tcsetattr(fd, TCSANOW, &options); for(;;){ nbytes = read(fd,&buffer,sizeof(buffer)); printf("nbytes = %i; buffer = %32.32x\n",nbytes,buffer); } close(fd); return 0;}--------------------------gcc cod.c && sudo ./a.out nbytes = 1; buffer = 000000000000000000000000be2d3860nbytes = 1; buffer = 000000000000000000000000be2d3860nbytes = 1; buffer = 000000000000000000000000be2d3860nbytes = 1; buffer = 000000000000000000000000be2d3860nbytes = 1; buffer = 000000000000000000000000be2d3860nbytes = 1; buffer = 000000000000000000000000be2d3860nbytes = 1; buffer = 000000000000000000000000be2d3860nbytes = 1; buffer = 000000000000000000000000be2d3860nbytes = 1; buffer = 000000000000000000000000be2d3860