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.
29 /*----- Revision history --------------------------------------------------*
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
37 * Revision 1.1 2002/01/25 19:34:45 mdw
49 /*----- Header files ------------------------------------------------------*/
55 /*----- Data structures ---------------------------------------------------*/
57 typedef struct serial_config
{
58 unsigned long baud
; /* Baud rate */
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 */
65 enum { PARITY_NONE
, PARITY_ODD
, PARITY_EVEN
};
66 enum { FLOW_NONE
, FLOW_XONXOFF
, FLOW_RTSCTS
};
68 #define SERIAL_INIT { 9600, 8, PARITY_NONE, 1, FLOW_NONE }
70 /*----- Functions provided ------------------------------------------------*/
72 /* --- @serial_parse@ --- *
74 * Arguments: @serial_config *sc@ = pointer to serial config structure
75 * @const char *k, *v@ = keyword and value pair
77 * Returns: Zero if OK, or @-1@ on error.
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@)
85 extern int serial_parse(serial_config */
*sc*/
,
86 const char */
*k*/
, const char */
*v*/
);
88 /*----- That's all, folks -------------------------------------------------*/