This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 82e76961cd serial: Simplify the echo process
82e76961cd is described below

commit 82e76961cdc02c2cf5fcdfb2a1eb3889a7a87879
Author: Xiang Xiao <[email protected]>
AuthorDate: Tue Aug 1 03:00:29 2023 +0800

    serial: Simplify the echo process
    
    Signed-off-by: Xiang Xiao <[email protected]>
---
 drivers/serial/serial.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
index e880f27c44..2c70f35210 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--;
-                }
             }
         }
 

Reply via email to