xiaoxiang781216 commented on code in PR #8691:
URL: https://github.com/apache/nuttx/pull/8691#discussion_r1123136673


##########
drivers/serial/serial.c:
##########
@@ -886,6 +888,53 @@ static ssize_t uart_read(FAR struct file *filep,
 
           *buffer++ = ch;
           recvd++;
+
+          if (dev->isconsole
+#ifdef CONFIG_SERIAL_TERMIOS
+              && (dev->tc_iflag & ECHO)
+#endif
+             )
+            {
+              /* Check for the beginning of a VT100 escape sequence, 3 byte */
+
+              if (ch == ASCII_ESC)
+                {
+                  /* Mark that we should skip 2 more bytes */
+
+                  dev->escape = 2;
+                  continue;
+                }
+              else if (dev->escape == 2 && ch != ASCII_LBRACKET)
+                {
+                  /* It's not an <esc>[x 3 byte sequence, show it */
+
+                  dev->escape = 0;
+                }
+
+              /* Echo if the character is not a control byte */
+
+              if ((!iscntrl(ch & 0xff) || (ch == '\n')) && dev->escape == 0)
+                {
+                    {
+                      uart_putxmitchar(dev, ch, true);
+                    }
+                }
+
+              /* Skipping character count down */
+
+              if (dev->escape > 0)
+                {
+                  dev->escape--;
+                }
+            }
+#ifdef CONFIG_SERIAL_TERMIOS
+          else if (dev->isconsole == false && (dev->tc_iflag & ECHO))

Review Comment:
   ```suggestion
             else
   #endif
   ```
   and remove line 937



##########
drivers/serial/serial.c:
##########
@@ -886,6 +888,53 @@ static ssize_t uart_read(FAR struct file *filep,
 
           *buffer++ = ch;
           recvd++;
+
+          if (dev->isconsole
+#ifdef CONFIG_SERIAL_TERMIOS
+              && (dev->tc_iflag & ECHO)

Review Comment:
   ```suggestion
                 || (dev->tc_iflag & ECHO)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to