diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index e880f27c447..2c70f352102 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -885,10 +885,19 @@ static ssize_t uart_read(FAR struct file *filep, dev->escape = 0; } + else if (dev->escape > 0) + { + /* Skipping character count down */ + + if (--dev->escape > 0) + { + continue; + } + } /* Echo if the character is not a control byte */ - if ((!iscntrl(ch & 0xff) || (ch == '\n')) && dev->escape == 0) + if (!iscntrl(ch & 0xff) || ch == '\n') { if (ch == '\n') { @@ -904,13 +913,6 @@ static ssize_t uart_read(FAR struct file *filep, echoed = true; } - - /* Skipping character count down */ - - if (dev->escape > 0) - { - dev->escape--; - } } }