#include #include #include #include #include #include #include #include #include int main( void ) { struct termios te,old; int fd,i=0,n; unsigned long readed = 0; char buff[128]; fd = open( "COM1", O_RDWR|O_NDELAY|O_BINARY|O_NONBLOCK); tcgetattr( fd, &old); bzero( &te, sizeof( te )); te.c_iflag |= IGNBRK; te.c_oflag = 0; te.c_cflag |= CLOCAL; te.c_cflag |= CREAD; te.c_cflag |= HUPCL; te.c_cflag &= ~CSIZE; te.c_lflag = 0; te.c_cc[VTIME] = 0; te.c_cc[VMIN] = 1; tcflush( fd, TCIFLUSH ); te.c_cflag |= B9600; te.c_cflag |= PARENB; te.c_cflag |= PARODD; te.c_cflag |= CSTOPB; te.c_cflag |= CS7; tcsetattr( fd, TCSANOW, &te ); usleep(300); for( i=0; i<=34; i++ ) { read( fd, &n ,1); usleep( 500 ); printf("%c", n); } printf("\n"); close (fd ); return 0; }