uart.c: Fixed UART initialization, now we set and apply defaults
authorAlex Tereschenko <alext.mkrs@gmail.com>
Sun, 19 Jul 2015 19:50:52 +0000 (21:50 +0200)
committerBrendan Le Foll <brendan.le.foll@intel.com>
Wed, 22 Jul 2015 10:07:04 +0000 (11:07 +0100)
Closes #221.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
src/uart/uart.c

index 22868a5..82e1252 100644 (file)
@@ -211,6 +211,12 @@ mraa_uart_init_raw(const char* path)
     // handling, such as flow control or line editing semantics.
     // cfmakeraw is not POSIX!
     cfmakeraw(&termio);
+    if (tcsetattr(dev->fd, TCSAFLUSH, &termio) < 0) {
+        syslog(LOG_ERR, "uart: tcsetattr() failed after cfmakeraw()");
+        close(dev->fd);
+        free(dev);
+        return NULL;
+    }
 
     if (mraa_uart_set_baudrate(dev, 9600) != MRAA_SUCCESS) {
         close(dev->fd);