forked from mavlink/c_uart_interface_example
-
Notifications
You must be signed in to change notification settings - Fork 7
/
serial_port.h
57 lines (41 loc) · 1.59 KB
/
serial_port.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/** This example is public domain. */
/**
* @file serial_port.h
*
* @brief Serial interface definition
*
* Functions for opening, closing, reading and writing via serial ports
*
* @author Trent Lukaczyk, <[email protected]>
* @author Jaycee Lock, <[email protected]>
*
*/
// ------------------------------------------------------------------------------
// Includes
// ------------------------------------------------------------------------------
#include <cstdlib>
#include <stdio.h> /* Standard input/output definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <termios.h> /* POSIX terminal control definitions */
#include <common/mavlink.h>
// ------------------------------------------------------------------------------
// Defines
// ------------------------------------------------------------------------------
// The following two non-standard baudrates should have been defined by the system
// If not, just fallback to number
#ifndef B460800
#define B460800 460800
#endif
#ifndef B921600
#define B921600 921600
#endif
// ------------------------------------------------------------------------------
// Prototypes
// ------------------------------------------------------------------------------
int read_serial(mavlink_message_t &message);
int write_serial(mavlink_message_t &message);
void open_serial(char *&uart_name, int &baudrate);
void close_serial();
int _open_port(const char* port);
bool _setup_port(int baud, int data_bits, int stop_bits, bool parity, bool hardware_control);