From 9838c8136f01dd125eccdd73a3124bf12e1df933 Mon Sep 17 00:00:00 2001 From: Jim Paris Date: Fri, 25 Sep 2020 14:35:18 -0400 Subject: [PATCH] Add option to force DTS and RTS pins high This is for development boards like those for the ESP32, where it's common to use RTS and DTR to control chip resets. --- terminal.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/terminal.py b/terminal.py index 5462c83..602a291 100755 --- a/terminal.py +++ b/terminal.py @@ -362,6 +362,9 @@ if __name__ == "__main__": help="Don't use colors in output") parser.add_argument("--flow", "-f", action="store_true", help="Enable RTS/CTS flow control") + parser.add_argument("--esp", "-e", action="store_true", + help="Force RTS and DTR high, for ESP boards. Note that" + " the lines may still glitch low at startup.") parser.add_argument("--bufsize", "-z", metavar="SIZE", type=int, help="Buffer size for reads and writes", default=65536) @@ -395,7 +398,13 @@ if __name__ == "__main__": sys.stderr.write("error: %s specified more than once\n" % node) raise SystemExit(1) try: - dev = MySerial(node, baud, rtscts = args.flow) + dev = MySerial(None, baud, rtscts = args.flow) + dev.port = node + if args.esp: + # Force DTR and RTS high by setting to false + dev.dtr = False + dev.rts = False + dev.open() except serial.serialutil.SerialException: sys.stderr.write("error opening %s\n" % node) raise SystemExit(1)