From 6a6e23abf5e28471f368b225c96c1b0cb8797191 Mon Sep 17 00:00:00 2001 From: Bert Vermeulen Date: Sun, 2 Sep 2012 15:00:02 +0200 Subject: [PATCH] serial: set speed in both directions --- hardware/common/serial.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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;