#include #include #include #include #include int main() { struct termios tio; const char *device = "/dev/ttyS0"; char d[50]; int i=0; char c[50]; int h = 0; int g=0; long b,m = 0; long k = 1000000000; long j = 1000000000; int tty_fd; //printf("enter the number of characters:"); //scanf("%d",&n); //printf("\n"); tty_fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY); if(tty_fd == -1) { printf("failed to open port\n"); return EXIT_FAILURE; } memset(&tio,0,sizeof(tio)); tio.c_iflag=0; tio.c_oflag=0; tio.c_cflag=CS8|CREAD|CLOCAL; // 8n1, see termios.h for more information tio.c_lflag=0; tio.c_cc[VMIN]=1; tio.c_cc[VTIME]=0; cfsetospeed(&tio,B115200); // 115200 baud cfsetispeed(&tio,B115200); // 115200 baud tcflush(tty_fd, TCIFLUSH); tcsetattr(tty_fd,TCSANOW,&tio); d[50]= '\0'; c[50]='\0'; while( i< 50 ) { scanf("%c",&c[i]); //write(tty_fd,&c[i],1); //read(tty_fd,d,i); //printf("%s",d); i = i+1 ; } if (write(tty_fd,c,50)>0) { printf("sucess.. written!\n\n"); for ( i; i