From: Bert Vermeulen Date: Sun, 2 Sep 2012 13:00:02 +0000 (+0200) Subject: serial: set speed in both directions X-Git-Tag: dsupstream~716 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6a6e23abf5e28471f368b225c96c1b0cb8797191;p=libsigrok.git serial: set speed in both directions --- diff --git a/hardware/common/serial.c b/hardware/common/serial.c index 002b23c3..3838030a 100644 --- a/hardware/common/serial.c +++ b/hardware/common/serial.c @@ -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;