serial: Simplify the echo process

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2023-08-01 03:00:29 +08:00 committed by Alan Carvalho de Assis
parent 888b8e59dd
commit 82e76961cd

View File

@ -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--;
}
}
}