comparison libserial-linux/setbaud.c @ 661:fd7b447b99e3

libserial rename The version that was previously named libserial-newlnx is now libserial-linux, and the version that was previosly named libserial-orig is now libserial-posix. This new naming is more in line with the objective reality of the difference, moving away from naming based on our project history.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 05 Mar 2020 19:54:31 +0000
parents libserial-newlnx/setbaud.c@ab8410d06ca7
children
comparison
equal deleted inserted replaced
660:b34384991094 661:fd7b447b99e3
1 /*
2 * This module implements the termios/ioctl setting of the baud rate.
3 */
4
5 #include <sys/types.h>
6 #include <sys/ioctl.h>
7 #include <asm/ioctls.h>
8 #include <asm/termbits.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <unistd.h>
12 #include "baudrate.h"
13
14 extern int target_fd;
15
16 struct baudrate *current_baud_rate;
17
18 set_serial_baudrate(br)
19 struct baudrate *br;
20 {
21 struct termios2 target_termios;
22
23 target_termios.c_iflag = IGNBRK;
24 target_termios.c_oflag = 0;
25 target_termios.c_cflag = br->termios_code | CLOCAL|HUPCL|CREAD|CS8;
26 target_termios.c_lflag = 0;
27 target_termios.c_cc[VMIN] = 1;
28 target_termios.c_cc[VTIME] = 0;
29 target_termios.c_ispeed = br->nonstd_speed;
30 target_termios.c_ospeed = br->nonstd_speed;
31 if (ioctl(target_fd, TCSETSF2, &target_termios) < 0) {
32 perror("TCSETSF2");
33 exit(1);
34 }
35 current_baud_rate = br;
36 return 0;
37 }