Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. int
  2. set_line(int speed)
  3. {
  4.     struct termios   tio;
  5.     memcpy(&tio, &line_tio, sizeof(tio));
  6.     tcgetattr(line_fd, &tio);     /* Get the current attributes of the Serial port */
  7.     cfsetispeed(&tio,B9600); /* Set Read  Speed as 9600                       */
  8.     cfsetospeed(&tio,B9600); /* Set Write Speed as 9600                       */
  9.     cfmakeraw(&tio);
  10.     //tio.c_cflag |= CREAD | CLOCAL;
  11.     tio.c_cc[VTIME] = 0; /* Wait indefinetly   */
  12.    // tio.c_cc[VMIN]  = 1;
  13.  
  14.     if (tcsetattr(line_fd, TCSAFLUSH, &tio) != 0)
  15.         return (-1);
  16.     sleep(1);
  17.     tcflush(line_fd, TCIOFLUSH);
  18.     return (0);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement