annotate libserial-posix/setbaud.c @ 1014:961efadd530a default tip

fc-shell TCH DL handler: add support for CSD modes TCH DL capture mechanism in FC Tourmaline firmware has been extended to support CSD modes in addition to speech - add the necessary support on the host tools side. It needs to be noted that this mechanism in its present state does NOT provide the debug utility value that was sought: as we learned only after the code was implemented, TI's DSP has a misfeature in that the buffer we are reading (a_dd_0[]) is zeroed out when the IDS block is enabled, i.e., we are reading all zeros and not the real DL bits we were after. But since the code has already been written, we are keeping it - perhaps we can do some tests with IDS disabled.
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 26 Nov 2024 06:27:43 +0000
parents fd7b447b99e3
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 }