Skip to content

Commit

Permalink
serial: Simplify the echo process
Browse files Browse the repository at this point in the history
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
  • Loading branch information
xiaoxiang781216 authored and acassis committed Aug 1, 2023
1 parent 888b8e5 commit 82e7696
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions drivers/serial/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -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')
{
Expand All @@ -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--;
}
}
}

Expand Down

0 comments on commit 82e7696

Please sign in to comment.