FreeCalypso > hg > fc-pcm-if
annotate sw/libserial/setbaud.c @ 13:315428573a25
fc-mcsi-rxtx: implement record function
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 28 Oct 2024 07:24:53 +0000 |
parents | a4918a161d2e |
children |
rev | line source |
---|---|
2
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module implements the termios/ioctl setting of the baud rate. |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/ioctl.h> |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <asm/ioctls.h> |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <asm/termbits.h> |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdio.h> |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdlib.h> |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <unistd.h> |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 extern int target_fd; |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 set_serial_baudrate(br) |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 unsigned br; |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 { |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 struct termios2 target_termios; |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 target_termios.c_iflag = IGNBRK; |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 target_termios.c_oflag = 0; |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 target_termios.c_cflag = BOTHER|CLOCAL|HUPCL|CREAD|CS8; |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 target_termios.c_lflag = 0; |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 target_termios.c_cc[VMIN] = 1; |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 target_termios.c_cc[VTIME] = 0; |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 target_termios.c_ispeed = br; |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 target_termios.c_ospeed = br; |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 if (ioctl(target_fd, TCSETSF2, &target_termios) < 0) { |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 perror("TCSETSF2"); |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 exit(1); |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 } |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 return 0; |
a4918a161d2e
sw: starting with libserial, copied from fc-sim-sniff
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 } |