comparison libserial-orig/baudtab.c @ 248:cb1ba53a1106

beginning of factored-out libserial
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 21 Sep 2017 21:43:34 +0000
parents
children 39b39b546824
comparison
equal deleted inserted replaced
247:b5b148ef63da 248:cb1ba53a1106
1 /*
2 * This module contains the table of baud rates supported
3 * by this implementation of FreeCalypso libserial.
4 */
5
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <strings.h>
10 #include <termios.h>
11 #include "baudrate.h"
12
13 struct baudrate baud_rate_table[] = {
14 /* the first listed rate will be our default */
15 {"115200", B115200, 0},
16 {"57600", B57600, 1},
17 {"38400", B38400, 2},
18 {"19200", B19200, 4},
19 /*
20 * Non-standard high baud rates remapped by CP2102 EEPROM programming
21 * or by a hacky patch to the ftdi_sio Linux kernel driver to work
22 * with FTDI adapters.
23 */
24 {"812500", B921600, -1},
25 {"406250", B460800, -1},
26 {"203125", B230400, -1},
27 /* table search terminator */
28 {NULL, B0, -1},
29 };
30
31 struct baudrate *
32 find_baudrate_by_name(srch_name)
33 char *srch_name;
34 {
35 struct baudrate *br;
36
37 for (br = baud_rate_table; br->name; br++)
38 if (!strcmp(br->name, srch_name))
39 break;
40 if (br->name)
41 return(br);
42 else {
43 fprintf(stderr, "error: baud rate \"%s\" not known\n",
44 srch_name);
45 return(NULL);
46 }
47 }