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