diff --git a/HISTORY.rst b/HISTORY.rst index fb34f947..cfcaedee 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -23,6 +23,10 @@ PlatformIO 3.0 * Custom ``test_transport`` for `PIO Unit Testing `__ Engine * Configure Serial Port Monitor in `Project Configuration File "platformio.ini" `__ (`issue #787 `_) +* New `monitor `__ + target which allows to launch Serial Monitor automatically after successful + "build" or "upload" operations + (`issue #788 `_) * Project generator for `VIM `__ * Multi-line support for the different options in `Project Configuration File "platformio.ini" `__, such as: ``build_flags``, ``build_unflags``, etc. diff --git a/docs b/docs index 90756ec9..dd628f3e 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 90756ec9f7138b0d147b70f28bdd3d85dd5da17a +Subproject commit dd628f3e8e500d27e3b12b1f80269327b11e5ab0 diff --git a/platformio/commands/run.py b/platformio/commands/run.py index 403a0a15..fdd9cefe 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -21,6 +21,7 @@ from time import time import click from platformio import __version__, exception, telemetry, util +from platformio.commands.device import device_monitor as cmd_device_monitor from platformio.commands.lib import lib_install as cmd_lib_install from platformio.commands.lib import get_builtin_libs from platformio.commands.platform import \ @@ -107,7 +108,11 @@ def cli(ctx, environment, target, upload_port, project_dir, silent, verbose, ep = EnvironmentProcessor(ctx, envname, options, target, upload_port, silent, verbose) - results.append((envname, ep.process())) + result = (envname, ep.process()) + results.append(result) + if result[1] and "monitor" in ep.get_build_targets() and \ + "nobuild" not in ep.get_build_targets(): + ctx.invoke(cmd_device_monitor) found_error = any([status is False for (_, status) in results]) @@ -226,7 +231,7 @@ class EnvironmentProcessor(object): result[k] = v return result - def _get_build_variables(self): + def get_build_variables(self): variables = {"pioenv": self.name} if self.upload_port: variables['upload_port'] = self.upload_port @@ -240,7 +245,7 @@ class EnvironmentProcessor(object): variables[k] = v return variables - def _get_build_targets(self): + def get_build_targets(self): targets = [] if self.targets: targets = [t for t in self.targets] @@ -252,11 +257,14 @@ class EnvironmentProcessor(object): if "platform" not in self.options: raise exception.UndefinedEnvPlatform(self.name) - build_vars = self._get_build_variables() - build_targets = self._get_build_targets() + build_vars = self.get_build_variables() + build_targets = self.get_build_targets() telemetry.on_run_environment(self.options, build_targets) + # skip monitor target, we call it above + if "monitor" in build_targets: + build_targets.remove("monitor") if "nobuild" not in build_targets: # install dependent libraries if "lib_install" in self.options: