FreeCalypso > hg > freecalypso-tools
comparison libserial-newlnx/setbaud.c @ 255:ab8410d06ca7
libserial-newlnx: new way implemented, compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 22 Sep 2017 00:19:41 +0000 |
parents | 6984b76f3def |
children |
comparison
equal
deleted
inserted
replaced
254:6984b76f3def | 255:ab8410d06ca7 |
---|---|
2 * This module implements the termios/ioctl setting of the baud rate. | 2 * This module implements the termios/ioctl setting of the baud rate. |
3 */ | 3 */ |
4 | 4 |
5 #include <sys/types.h> | 5 #include <sys/types.h> |
6 #include <sys/ioctl.h> | 6 #include <sys/ioctl.h> |
7 #include <termios.h> | 7 #include <asm/ioctls.h> |
8 #include <asm/termbits.h> | |
8 #include <stdio.h> | 9 #include <stdio.h> |
9 #include <stdlib.h> | 10 #include <stdlib.h> |
10 #include <unistd.h> | 11 #include <unistd.h> |
11 #include "baudrate.h" | 12 #include "baudrate.h" |
12 | 13 |
15 struct baudrate *current_baud_rate; | 16 struct baudrate *current_baud_rate; |
16 | 17 |
17 set_serial_baudrate(br) | 18 set_serial_baudrate(br) |
18 struct baudrate *br; | 19 struct baudrate *br; |
19 { | 20 { |
20 struct termios target_termios; | 21 struct termios2 target_termios; |
21 | 22 |
22 target_termios.c_iflag = IGNBRK; | 23 target_termios.c_iflag = IGNBRK; |
23 target_termios.c_oflag = 0; | 24 target_termios.c_oflag = 0; |
24 target_termios.c_cflag = CLOCAL|HUPCL|CREAD|CS8; | 25 target_termios.c_cflag = br->termios_code | CLOCAL|HUPCL|CREAD|CS8; |
25 target_termios.c_lflag = 0; | 26 target_termios.c_lflag = 0; |
26 target_termios.c_cc[VMIN] = 1; | 27 target_termios.c_cc[VMIN] = 1; |
27 target_termios.c_cc[VTIME] = 0; | 28 target_termios.c_cc[VTIME] = 0; |
28 cfsetispeed(&target_termios, br->termios_code); | 29 target_termios.c_ispeed = br->nonstd_speed; |
29 cfsetospeed(&target_termios, br->termios_code); | 30 target_termios.c_ospeed = br->nonstd_speed; |
30 if (tcsetattr(target_fd, TCSAFLUSH, &target_termios) < 0) { | 31 if (ioctl(target_fd, TCSETSF2, &target_termios) < 0) { |
31 perror("tcsetattr"); | 32 perror("TCSETSF2"); |
32 exit(1); | 33 exit(1); |
33 } | 34 } |
34 current_baud_rate = br; | 35 current_baud_rate = br; |
35 return 0; | 36 return 0; |
36 } | 37 } |