From 34a327791cfcd21d94d9b38f52b2aa5bba28f10f Mon Sep 17 00:00:00 2001 From: Per-Olov Jernberg Date: Sun, 6 Oct 2019 15:03:23 +0200 Subject: [PATCH] idf_monitor: Exit with CTRL+X in menu Currently, the only way of exiting the idf_monitor program is to hit the CTRL+] button, if your keyboard doesn't have that key unless you hit another modifier key, it's not super trivial to exit. This change adds the option to exit with CTRL+T (for menu) then hitting X (or CTRL+X) for exiting. Closes https://github.com/espressif/esp-idf/pull/4167 Closes https://github.com/espressif/esp-idf/issues/4129 --- docs/en/api-guides/tools/idf-monitor.rst | 2 ++ tools/idf_monitor.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/en/api-guides/tools/idf-monitor.rst b/docs/en/api-guides/tools/idf-monitor.rst index c7da5f1e08..c93b31f2f2 100644 --- a/docs/en/api-guides/tools/idf-monitor.rst +++ b/docs/en/api-guides/tools/idf-monitor.rst @@ -40,6 +40,8 @@ For easy interaction with IDF Monitor, use the keyboard shortcuts given in the t +-------------------+--------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | - Ctrl+H (or H) | Display all keyboard shortcuts | | +-------------------+--------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| - Ctrl+X (or X) | Exit the program | | ++-------------------+--------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Any keys pressed, other than ``Ctrl-]`` and ``Ctrl-T``, will be sent through the serial port. diff --git a/tools/idf_monitor.py b/tools/idf_monitor.py index f68020613f..c0f6d3b81f 100755 --- a/tools/idf_monitor.py +++ b/tools/idf_monitor.py @@ -64,6 +64,7 @@ CTRL_R = '\x12' CTRL_T = '\x14' CTRL_Y = '\x19' CTRL_P = '\x10' +CTRL_X = '\x18' CTRL_L = '\x0c' CTRL_RBRACKET = '\x1d' # Ctrl+] @@ -495,6 +496,9 @@ class Monitor(object): self.serial.setRTS(False) # EN=HIGH, chip out of reset time.sleep(0.45) # timeouts taken from esptool.py, includes esp32r0 workaround. defaults: 0.05 self.serial.setDTR(False) # IO0=HIGH, done + elif c in [CTRL_X, 'x', 'X']: # Exiting from within the menu + self.console_reader.stop() + self.serial_reader.stop() else: red_print('--- unknown menu character {} --'.format(key_description(c))) @@ -514,6 +518,7 @@ class Monitor(object): --- {output:14} Toggle output display --- {log:14} Toggle saving output into file --- {pause:14} Reset target into bootloader to pause app via RTS line +--- {menuexit:14} Exit program """.format(version=__version__, exit=key_description(self.exit_key), menu=key_description(self.menu_key), @@ -522,7 +527,8 @@ class Monitor(object): appmake=key_description(CTRL_A) + ' (or A)', output=key_description(CTRL_Y), log=key_description(CTRL_L), - pause=key_description(CTRL_P)) + pause=key_description(CTRL_P), + menuexit=key_description(CTRL_X) + ' (or X)') def __enter__(self): """ Use 'with self' to temporarily disable monitoring behaviour """