Open Lighting Architecture  0.9.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Serial.h
1 /*
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * This library is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15  *
16  * Serial.h
17  * Serial IO functions.
18  * Copyright (C) 2014 Peter Newman
19  */
20 
21 #ifndef INCLUDE_OLA_IO_SERIAL_H_
22 #define INCLUDE_OLA_IO_SERIAL_H_
23 
24 #include <stdint.h>
25 #ifdef _WIN32
26 // Define types and constants to mimic termios.h
27 #define B9600 9600
28 #define B19200 19200
29 #define B38400 38400
30 #define B57600 57600
31 #define B115200 115200
32 #define B230400 230400
33 typedef unsigned speed_t;
34 #else
35 #include <termios.h>
36 #endif
37 
38 namespace ola {
39 namespace io {
40 
41 typedef enum {
42  BAUD_RATE_9600 = 9600,
43  BAUD_RATE_19200 = 19200,
44  BAUD_RATE_38400 = 38400,
45  BAUD_RATE_57600 = 57600,
46  BAUD_RATE_115200 = 115200,
47  BAUD_RATE_230400 = 230400,
48 } baud_rate;
49 
57 bool UIntToSpeedT(uint32_t value, speed_t *output);
58 } // namespace io
59 } // namespace ola
60 #endif // INCLUDE_OLA_IO_SERIAL_H_