comparison sw/libserial/setbaud.c @ 2:a4918a161d2e

sw: starting with libserial, copied from fc-sim-sniff
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 11 Oct 2024 22:37:11 +0000
parents
children
comparison
equal deleted inserted replaced
1:b3190839cce3 2:a4918a161d2e
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
13 extern int target_fd;
14
15 set_serial_baudrate(br)
16 unsigned br;
17 {
18 struct termios2 target_termios;
19
20 target_termios.c_iflag = IGNBRK;
21 target_termios.c_oflag = 0;
22 target_termios.c_cflag = BOTHER|CLOCAL|HUPCL|CREAD|CS8;
23 target_termios.c_lflag = 0;
24 target_termios.c_cc[VMIN] = 1;
25 target_termios.c_cc[VTIME] = 0;
26 target_termios.c_ispeed = br;
27 target_termios.c_ospeed = br;
28 if (ioctl(target_fd, TCSETSF2, &target_termios) < 0) {
29 perror("TCSETSF2");
30 exit(1);
31 }
32 return 0;
33 }