Open Lighting Architecture  0.10.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 #include <string>
26 #include <vector>
27 
28 #ifdef _WIN32
29 // Define types and constants to mimic termios.h
30 #define B9600 9600
31 #define B19200 19200
32 #define B38400 38400
33 #define B57600 57600
34 #define B115200 115200
35 #define B230400 230400
36 typedef unsigned speed_t;
37 #else
38 #include <termios.h>
39 #endif // _WIN32
40 
41 namespace ola {
42 namespace io {
43 
44 typedef enum {
45  BAUD_RATE_9600 = 9600,
46  BAUD_RATE_19200 = 19200,
47  BAUD_RATE_38400 = 38400,
48  BAUD_RATE_57600 = 57600,
49  BAUD_RATE_115200 = 115200,
50  BAUD_RATE_230400 = 230400,
51 } baud_rate;
52 
60 bool UIntToSpeedT(uint32_t value, speed_t *output);
61 
71 bool AcquireUUCPLockAndOpen(const std::string &path, int oflag, int *fd);
72 
79 void ReleaseUUCPLock(const std::string &path);
80 } // namespace io
81 } // namespace ola
82 #endif // INCLUDE_OLA_IO_SERIAL_H_
bool UIntToSpeedT(uint32_t value, speed_t *output)
Convert an integer baud rate to the termios struct speed_t.
Definition: Serial.cpp:117
void ReleaseUUCPLock(const std::string &path)
Remove a UUCP lock file for the device.
Definition: Serial.cpp:234
bool AcquireUUCPLockAndOpen(const std::string &path, int oflag, int *fd)
Try to open the path, respecting UUCP locking.
Definition: Serial.cpp:142
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44