From 0654186ca1114af2082252d21c1e3d6ee11d972c Mon Sep 17 00:00:00 2001 From: David van Rijn Date: Thu, 5 Mar 2026 10:58:09 +0100 Subject: [PATCH] rtt_cmd: add option to disable local echo When using a remote shell (like from zephyr), the character are echoed already, and sometimes even control characters are used to keep the typed command while also logging. So the shell experience is improved when the remote host does the echoing. --- pyocd/subcommands/rtt_cmd.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyocd/subcommands/rtt_cmd.py b/pyocd/subcommands/rtt_cmd.py index 075c96455..d866b3591 100644 --- a/pyocd/subcommands/rtt_cmd.py +++ b/pyocd/subcommands/rtt_cmd.py @@ -61,6 +61,8 @@ def get_args(cls) -> List[argparse.ArgumentParser]: help="Down channel ID.") rtt_options.add_argument("-d", "--log-file", type=str, default=None, help="Log file name. When specified, logging mode is enabled.") + rtt_options.add_argument("--echo", action=argparse.BooleanOptionalAction, default=True, + help="Echo locally typed characters. By default echo is on.") return [cls.CommonOptions.COMMON, cls.CommonOptions.CONNECT, rtt_parser] @@ -191,8 +193,9 @@ def viewer_loop(self, up_chan, down_chan, kb): if ord(c) == 27: # process ESC break - elif c.isprintable() or c == '\n': - print(c, end="", flush=True) + if self._args.echo: + if c.isprintable() or c == '\n': + print(c, end="", flush=True) # add char to buffer cmd += c.encode("utf-8")