2ec1e693 |
1 | /* -*-c-*- |
2 | * |
3 | * $Id: serial.h,v 1.1 2002/01/25 19:34:45 mdw Exp $ |
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 $ |
32 | * Revision 1.1 2002/01/25 19:34:45 mdw |
33 | * Initial revision |
34 | * |
35 | */ |
36 | |
37 | #ifndef SERIAL_H |
38 | #define SERIAL_H |
39 | |
40 | #ifdef __cplusplus |
41 | extern "C" { |
42 | #endif |
43 | |
44 | /*----- Header files ------------------------------------------------------*/ |
45 | |
46 | #ifdef HAVE_CONFIG_H |
47 | # include "config.h" |
48 | #endif |
49 | |
50 | /*----- Data structures ---------------------------------------------------*/ |
51 | |
52 | typedef struct serial_config { |
53 | unsigned long baud; /* Baud rate */ |
54 | unsigned wordlen; /* Word length */ |
55 | unsigned parity; /* Parity type (magic constant) */ |
56 | unsigned stopbits; /* Number of stop bits */ |
57 | } serial_config; |
58 | |
59 | enum { PARITY_NONE, PARITY_ODD, PARITY_EVEN }; |
60 | |
61 | #define SERIAL_INIT { 9600, 8, PARITY_NONE, 1 } |
62 | |
63 | /*----- Functions provided ------------------------------------------------*/ |
64 | |
65 | /* --- @serial_parse@ --- * |
66 | * |
67 | * Arguments: @const char *p@ = configuration string to parse |
68 | * @serial_config *sc@ = pointer to serial config structure |
69 | * |
70 | * Returns: Zero if OK, or @-1@ on error. |
71 | * |
72 | * Use: Parses a serial config string into something more |
73 | * reasonable. The config structure should have been |
74 | * initialized to something sensible (e.g., @SERIAL_INIT@) |
75 | * already. |
76 | */ |
77 | |
78 | extern int serial_parse(const char */*p*/, serial_config */*sc*/); |
79 | |
80 | /*----- That's all, folks -------------------------------------------------*/ |
81 | |
82 | #ifdef __cplusplus |
83 | } |
84 | #endif |
85 | |
86 | #endif |