44 #include <sys/ioctl.h> 52 static const speed_t speed = B19200;
55 const int uart = open(device, O_RDWR | O_NOCTTY);
58 PX4_ERR(
"opening %s", device);
64 struct termios uart_config_original;
66 if ((termios_state = tcgetattr(uart, &uart_config_original)) < 0) {
68 PX4_ERR(
"%s: %d", device, termios_state);
73 struct termios uart_config;
74 tcgetattr(uart, &uart_config);
77 uart_config.c_oflag &= ~ONLCR;
80 if (cfsetispeed(&uart_config, speed) < 0 || cfsetospeed(&uart_config, speed) < 0) {
82 PX4_ERR(
"%s: %d (cfsetispeed, cfsetospeed)", device, termios_state);
86 if ((termios_state = tcsetattr(uart, TCSANOW, &uart_config)) < 0) {
88 PX4_ERR(
"%s (tcsetattr)", device);
93 ioctl(uart, TIOCSSINGLEWIRE, SER_SINGLEWIRE_ENABLED);
Namespace encapsulating all device framework classes, functions and data.
Simple error/warning functions, heavily inspired by the BSD functions of the same names...
int open_uart(const char *device)