]> sigrok.org Git - libsigrok.git/commitdiff
serial: set speed in both directions
authorBert Vermeulen <redacted>
Sun, 2 Sep 2012 13:00:02 +0000 (15:00 +0200)
committerBert Vermeulen <redacted>
Sun, 2 Sep 2012 13:42:56 +0000 (15:42 +0200)
hardware/common/serial.c

index 002b23c32ef6fd8f73dbe49433eb5d6af15ec419..3838030a277d0271777476aafa303f9b57e40836 100644 (file)
@@ -234,6 +234,9 @@ SR_PRIV int serial_set_params(int fd, int baudrate, int bits, int parity,
        struct termios term;
        speed_t baud;
 
+       if (tcgetattr(fd, &term) < 0)
+               return SR_ERR;
+
        switch (baudrate) {
        case 9600:
                baud = B9600;
@@ -255,8 +258,7 @@ SR_PRIV int serial_set_params(int fd, int baudrate, int bits, int parity,
        default:
                return SR_ERR;
        }
-
-       if (tcgetattr(fd, &term) < 0)
+       if (cfsetospeed(&term, baud) < 0)
                return SR_ERR;
        if (cfsetispeed(&term, baud) < 0)
                return SR_ERR;