CTRL_H = '\x08'
CTRL_R = '\x12'
CTRL_T = '\x14'
+CTRL_Y = '\x19'
CTRL_RBRACKET = '\x1d' # Ctrl+]
# ANSI terminal codes
self._pressed_menu_key = False
self._read_line = b""
self._gdb_buffer = b""
+ self._output_enabled = True
def main_loop(self):
self.console_reader.start()
# this may need to be made more efficient, as it pushes out a byte
# at a time to the console
for b in data:
- self.console.write_bytes(b)
+ if self._output_enabled:
+ self.console.write_bytes(b)
if b == b'\n': # end of line
self.handle_serial_input_line(self._read_line.strip())
self._read_line = b""
self.serial.setRTS(True)
time.sleep(0.2)
self.serial.setRTS(False)
+ self.output_enable(True)
elif c == CTRL_F: # Recompile & upload
self.run_make("flash")
elif c == CTRL_A: # Recompile & upload app only
self.run_make("app-flash")
+ elif c == CTRL_Y: # Toggle output display
+ self.output_toggle()
else:
red_print('--- unknown menu character {} --'.format(key_description(c)))
--- {reset:7} Reset target board via RTS line
--- {make:7} Run 'make flash' to build & flash
--- {appmake:7} Run 'make app-flash to build & flash app
+--- {output:7} Toggle output display
""".format(version=__version__,
exit=key_description(self.exit_key),
menu=key_description(self.menu_key),
reset=key_description(CTRL_R),
make=key_description(CTRL_F),
appmake=key_description(CTRL_A),
-
+ output=key_description(CTRL_Y),
)
def __enter__(self):
p.wait()
if p.returncode != 0:
self.prompt_next_action("Build failed")
+ else:
+ self.output_enable(True)
def lookup_pc_address(self, pc_addr):
translation = subprocess.check_output(
pass # happens on Windows, maybe other OSes
self.prompt_next_action("gdb exited")
+ def output_enable(self, enable):
+ self._output_enabled = enable
+
+ def output_toggle(self):
+ self._output_enabled = not self._output_enabled
+ yellow_print("\nToggle output display: {}, Type Ctrl-T Ctrl-Y to show/disable output again.".format(self._output_enabled))
+
def main():
parser = argparse.ArgumentParser("idf_monitor - a serial output monitor for esp-idf")