diff --git a/platformio/device/monitor/command.py b/platformio/device/monitor/command.py index 0a9a518a..24216b6c 100644 --- a/platformio/device/monitor/command.py +++ b/platformio/device/monitor/command.py @@ -130,7 +130,6 @@ def device_monitor_cmd(**options): "--exit-char can not be the same as --menu-char" ) - print(options) start_terminal(options) diff --git a/platformio/device/monitor/terminal.py b/platformio/device/monitor/terminal.py index 6cb78e20..9a043b6e 100644 --- a/platformio/device/monitor/terminal.py +++ b/platformio/device/monitor/terminal.py @@ -13,6 +13,7 @@ # limitations under the License. import signal +import sys import threading import click @@ -60,8 +61,17 @@ def start_terminal(options): except KeyboardInterrupt: pass term.join() + + # cleanup term.console.cleanup() + + # restore original standard streams + sys.stdin = sys.__stdin__ + sys.stdout = sys.__stdout__ + sys.stderr = sys.__stderr__ + term.close() + if term.pio_unexpected_exception: click.secho( "Disconnected (%s)" % term.pio_unexpected_exception, @@ -70,6 +80,7 @@ def start_terminal(options): ) if not options["no_reconnect"]: raise UserSideException(term.pio_unexpected_exception) + return except UserSideException as exc: if not is_port_valid: