3 * $Id: serial.h,v 1.2 2002/01/30 09:23:58 mdw Exp $
5 * Common serial functionality
7 * (c) 2001 Mark Wooding
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Jog: Programming for a jogging machine.
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.
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.
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.
36 /*----- Header files ------------------------------------------------------*/
42 /*----- Data structures ---------------------------------------------------*/
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 */
52 enum { PARITY_NONE, PARITY_ODD, PARITY_EVEN };
53 enum { FLOW_NONE, FLOW_XONXOFF, FLOW_RTSCTS };
55 #define SERIAL_INIT { 9600, 8, PARITY_NONE, 1, FLOW_NONE }
57 /*----- Functions provided ------------------------------------------------*/
59 /* --- @serial_parse@ --- *
61 * Arguments: @serial_config *sc@ = pointer to serial config structure
62 * @const char *k, *v@ = keyword and value pair
64 * Returns: Zero if OK, or @-1@ on error.
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@)
72 extern int serial_parse(serial_config */*sc*/,
73 const char */*k*/, const char */*v*/);
75 /*----- That's all, folks -------------------------------------------------*/