annotate libserial-orig/setbaud.c @ 619:f82551c77e58

libserial-newlnx: ASYNC_LOW_LATENCY patch reverted Reports from Das Signal indicate that loadtools performance on Debian is about the same as on Slackware, and that including or omitting the ASYNC_LOW_LATENCY patch from Serg makes no difference. Because the patch in question does not appear to be necessary, it is being reverted until and unless someone other than Serg reports an actual real-world system on which loadtools operation times are slowed compared to the Mother's Slackware reference and on which Slackware-like performance can be restored by setting the ASYNC_LOW_LATENCY flag.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 27 Feb 2020 01:09:48 +0000
parents cb1ba53a1106
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
248
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module implements the termios/ioctl setting of the baud rate.
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/ioctl.h>
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <termios.h>
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdio.h>
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <unistd.h>
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "baudrate.h"
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 extern int target_fd;
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 struct baudrate *current_baud_rate;
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 set_serial_baudrate(br)
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 struct baudrate *br;
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 {
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 struct termios target_termios;
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 target_termios.c_iflag = IGNBRK;
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 target_termios.c_oflag = 0;
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 target_termios.c_cflag = CLOCAL|HUPCL|CREAD|CS8;
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 target_termios.c_lflag = 0;
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 target_termios.c_cc[VMIN] = 1;
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 target_termios.c_cc[VTIME] = 0;
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 cfsetispeed(&target_termios, br->termios_code);
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 cfsetospeed(&target_termios, br->termios_code);
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 if (tcsetattr(target_fd, TCSAFLUSH, &target_termios) < 0) {
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 perror("tcsetattr");
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 exit(1);
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 }
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 current_baud_rate = br;
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 return 0;
cb1ba53a1106 beginning of factored-out libserial
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 }