Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
serial_port.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2010 Antoine Drouin <poinix@gmail.com>
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
23 #ifndef SERIAL_PORT_H
24 #define SERIAL_PORT_H
25 
26 #if !USE_ARBITRARY_BAUDRATE
27 #include <termios.h>
28 
29 struct SerialPort {
30  int fd; /* serial device fd */
31  struct termios orig_termios; /* saved tty state structure */
32  struct termios cur_termios; /* tty state structure */
33 };
34 
35 #else
36 #include <linux/termios.h>
37 
38 struct SerialPort {
39  int fd; /* serial device fd */
40  struct termios2 orig_termios; /* saved tty state structure */
41  struct termios2 cur_termios; /* tty state structure */
42 };
43 
44 #endif
45 
46 extern struct SerialPort *serial_port_new(void);
47 extern void serial_port_free(struct SerialPort *me);
48 extern void serial_port_flush(struct SerialPort *me);
49 extern void serial_port_flush_output(struct SerialPort *me);
50 extern int serial_port_open_raw(struct SerialPort *me, const char *device, speed_t speed);
51 extern int serial_port_open(struct SerialPort *me, const char *device,
52  void(*term_conf_callback)(struct termios *, speed_t *));
53 extern void serial_port_close(struct SerialPort *me);
54 extern int serial_port_set_baudrate(struct SerialPort *me, speed_t speed);
55 extern int serial_port_set_bits_stop_parity(struct SerialPort *me, const int bits, const int stop, const int parity);
56 
57 #endif /* SERIAL_PORT_H */
struct termios cur_termios
Definition: serial_port.h:32
void serial_port_free(struct SerialPort *me)
Definition: serial_port.c:80
void serial_port_close(struct SerialPort *me)
Definition: serial_port.c:184
int serial_port_open_raw(struct SerialPort *me, const char *device, speed_t speed)
Definition: serial_port.c:111
struct termios orig_termios
Definition: serial_port.h:31
void serial_port_flush_output(struct SerialPort *me)
Definition: serial_port.c:100
int serial_port_set_bits_stop_parity(struct SerialPort *me, const int bits, const int stop, const int parity)
Definition: serial_port.c:224
int serial_port_open(struct SerialPort *me, const char *device, void(*term_conf_callback)(struct termios *, speed_t *))
Definition: serial_port.c:153
struct SerialPort * serial_port_new(void)
Definition: serial_port.c:74
int serial_port_set_baudrate(struct SerialPort *me, speed_t speed)
Definition: serial_port.c:210
void serial_port_flush(struct SerialPort *me)
Definition: serial_port.c:89