Skip to content

Commit 260a076

Browse files
committed
fix serial
1 parent 78bdf67 commit 260a076

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

components/drivers/serial/serial.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,29 +1110,27 @@ static rt_err_t rt_serial_control(struct rt_device *dev,
11101110
}
11111111
else
11121112
{
1113+
_termio_to_termios(args, &tmp);
11131114
tio = &tmp;
11141115
}
11151116

11161117
if (tio == RT_NULL) return -RT_EINVAL;
11171118

1118-
tio->c_iflag = 0;
1119-
tio->c_oflag = 0;
1120-
tio->c_lflag = 0;
1121-
11221119
/* update oflag for console device */
11231120
if (rt_console_get_device() == dev)
1124-
tio->c_oflag = OPOST | ONLCR;
1121+
tio->c_oflag |= (OPOST | ONLCR);
1122+
1123+
tio->c_cflag &= ~(CSIZE | CSTOPB | PARODD | PARENB);
11251124

11261125
/* set cflag */
1127-
tio->c_cflag = 0;
11281126
if (serial->config.data_bits == DATA_BITS_5)
1129-
tio->c_cflag = CS5;
1127+
tio->c_cflag |= CS5;
11301128
else if (serial->config.data_bits == DATA_BITS_6)
1131-
tio->c_cflag = CS6;
1129+
tio->c_cflag |= CS6;
11321130
else if (serial->config.data_bits == DATA_BITS_7)
1133-
tio->c_cflag = CS7;
1131+
tio->c_cflag |= CS7;
11341132
else if (serial->config.data_bits == DATA_BITS_8)
1135-
tio->c_cflag = CS8;
1133+
tio->c_cflag |= CS8;
11361134

11371135
if (serial->config.stop_bits == STOP_BITS_2)
11381136
tio->c_cflag |= CSTOPB;

0 commit comments

Comments
 (0)