diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index 1e8763368d..f2e19aa760 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -1148,8 +1148,6 @@ static rt_err_t rt_serial_control(struct rt_device *dev, { _termios_to_termio(tio, args); } - - tio->__c_ispeed = tio->__c_ospeed = cfgetospeed(tio); } break; case TCSETAW: @@ -1176,8 +1174,7 @@ static rt_err_t rt_serial_control(struct rt_device *dev, if (tio == RT_NULL) return -RT_EINVAL; config = serial->config; - tio->__c_ispeed = tio->__c_ospeed = cfgetospeed(tio); - baudrate = _get_baudrate(tio->__c_ispeed); + baudrate = _get_baudrate(cfgetospeed(tio)); config.baud_rate = baudrate; switch (tio->c_cflag & CSIZE) diff --git a/components/drivers/serial/serial_tty.c b/components/drivers/serial/serial_tty.c index d8479aad22..98e7ee652d 100644 --- a/components/drivers/serial/serial_tty.c +++ b/components/drivers/serial/serial_tty.c @@ -296,6 +296,7 @@ static int serial_tty_param(struct lwp_tty *tp, struct termios *t) RT_ASSERT(softc); serial = softc->parent; + cfsetispeed(t, t->__c_ispeed); return rt_device_control(&(serial->parent), TCSETS, t); }