serial: set speed in both directions

This commit is contained in:
Bert Vermeulen 2012-09-02 15:00:02 +02:00
parent 6ac0db19f3
commit 6a6e23abf5
1 changed files with 4 additions and 2 deletions

View 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;