2ec1e693 |
1 | /* -*-c-*- |
2 | * |
665fffde |
3 | * $Id: serial.h,v 1.2 2002/01/30 09:23:58 mdw Exp $ |
2ec1e693 |
4 | * |
5 | * Common serial functionality |
6 | * |
7 | * (c) 2001 Mark Wooding |
8 | */ |
9 | |
10 | /*----- Licensing notice --------------------------------------------------* |
11 | * |
12 | * This file is part of Jog: Programming for a jogging machine. |
13 | * |
14 | * Jog is free software; you can redistribute it and/or modify |
15 | * it under the terms of the GNU General Public License as published by |
16 | * the Free Software Foundation; either version 2 of the License, or |
17 | * (at your option) any later version. |
18 | * |
19 | * Jog is distributed in the hope that it will be useful, |
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 | * GNU General Public License for more details. |
23 | * |
24 | * You should have received a copy of the GNU General Public License |
25 | * along with Jog; if not, write to the Free Software Foundation, |
26 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
27 | */ |
28 | |
29 | /*----- Revision history --------------------------------------------------* |
30 | * |
31 | * $Log: serial.h,v $ |
665fffde |
32 | * Revision 1.2 2002/01/30 09:23:58 mdw |
33 | * Follow new transport configuration interface. Add parameters for flow |
34 | * control. Break the format into separate parameters for independent |
35 | * configuration. |
36 | * |
2ec1e693 |
37 | * Revision 1.1 2002/01/25 19:34:45 mdw |
38 | * Initial revision |
39 | * |
40 | */ |
41 | |
42 | #ifndef SERIAL_H |
43 | #define SERIAL_H |
44 | |
45 | #ifdef __cplusplus |
46 | extern "C" { |
47 | #endif |
48 | |
49 | /*----- Header files ------------------------------------------------------*/ |
50 | |
51 | #ifdef HAVE_CONFIG_H |
52 | # include "config.h" |
53 | #endif |
54 | |
55 | /*----- Data structures ---------------------------------------------------*/ |
56 | |
57 | typedef struct serial_config { |
58 | unsigned long baud; /* Baud rate */ |
665fffde |
59 | unsigned char wordlen; /* Word length */ |
60 | unsigned char parity; /* Parity type (magic constant) */ |
61 | unsigned char stopbits; /* Number of stop bits */ |
62 | unsigned char flow; /* Flow control */ |
2ec1e693 |
63 | } serial_config; |
64 | |
65 | enum { PARITY_NONE, PARITY_ODD, PARITY_EVEN }; |
665fffde |
66 | enum { FLOW_NONE, FLOW_XONXOFF, FLOW_RTSCTS }; |
2ec1e693 |
67 | |
665fffde |
68 | #define SERIAL_INIT { 9600, 8, PARITY_NONE, 1, FLOW_NONE } |
2ec1e693 |
69 | |
70 | /*----- Functions provided ------------------------------------------------*/ |
71 | |
72 | /* --- @serial_parse@ --- * |
73 | * |
665fffde |
74 | * Arguments: @serial_config *sc@ = pointer to serial config structure |
75 | * @const char *k, *v@ = keyword and value pair |
2ec1e693 |
76 | * |
77 | * Returns: Zero if OK, or @-1@ on error. |
78 | * |
79 | * Use: Parses a serial config string into something more |
80 | * reasonable. The config structure should have been |
81 | * initialized to something sensible (e.g., @SERIAL_INIT@) |
82 | * already. |
83 | */ |
84 | |
665fffde |
85 | extern int serial_parse(serial_config */*sc*/, |
86 | const char */*k*/, const char */*v*/); |
2ec1e693 |
87 | |
88 | /*----- That's all, folks -------------------------------------------------*/ |
89 | |
90 | #ifdef __cplusplus |
91 | } |
92 | #endif |
93 | |
94 | #endif |