You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2023/03/20 22:23:25 UTC
[nuttx] branch master updated: drivers/pty: Echo input by default
This is an automated email from the ASF dual-hosted git repository.
masayuki 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 fab77cd322 drivers/pty: Echo input by default
fab77cd322 is described below
commit fab77cd322b70aeac9b2aef25681c02e3192b1df
Author: Huang Qi <hu...@xiaomi.com>
AuthorDate: Mon Mar 20 10:54:12 2023 +0800
drivers/pty: Echo input by default
Align the pty behavior to linux/bsd,
Also fix the ECHO issue with microadb after https://github.com/apache/nuttx/pull/8691.
adb shell will echo normally with this patch.
Signed-off-by: Huang Qi <hu...@xiaomi.com>
---
drivers/serial/pty.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c
index bd869e4415..e975eddf57 100644
--- a/drivers/serial/pty.c
+++ b/drivers/serial/pty.c
@@ -74,6 +74,7 @@ struct pty_dev_s
struct file pd_sink; /* Accepts data from write() method (pipe input) */
bool pd_master; /* True: this is the master */
tcflag_t pd_iflag; /* Terminal input modes */
+ tcflag_t pd_lflag; /* Terminal local modes */
tcflag_t pd_oflag; /* Terminal output modes */
struct pty_poll_s pd_poll[CONFIG_DEV_PTY_NPOLLWAITERS];
};
@@ -470,6 +471,11 @@ static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, size_t len)
ntotal = file_read(&dev->pd_src, buffer, len);
}
+ if (dev->pd_lflag & ECHO)
+ {
+ pty_write(filep, buffer, ntotal);
+ }
+
return ntotal;
}
@@ -949,7 +955,7 @@ int pty_register2(int minor, bool susv1)
/* Map CR -> NL from terminal input (master)
* For some usage like adb shell:
- * adb shell write \r -> nsh read \n
+ * adb shell write \r -> nsh read \n and echo input
* nsh write \n -> adb shell read \r\n
*/
@@ -961,6 +967,7 @@ int pty_register2(int minor, bool susv1)
devpair->pp_master.pd_oflag = OPOST | OCRNL;
devpair->pp_slave.pd_devpair = devpair;
devpair->pp_slave.pd_oflag = OPOST | ONLCR;
+ devpair->pp_slave.pd_lflag = ECHO;
/* Register the master device
*