Skip to content

Commit

Permalink
Add user-definable monitor options to platformio.ini // Resolve #2165
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed May 25, 2019
1 parent 70a0bd7 commit a84195b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
7 changes: 4 additions & 3 deletions HISTORY.rst
Expand Up @@ -10,19 +10,20 @@ PlatformIO 4.0
* **Project Management**

- Unified workspace storage (`workspace_dir <http://docs.platformio.org/page/projectconf/section_platformio.html#workspace-dir>`__ -> ``.pio``) for PlatformIO Build System, Library Manager, and other internal services (`issue #1778 <https://github.com/platformio/platformio-core/issues/1778>`_)
- Switched to workspace ``.pio/build`` folder for build artifacts instead of ``.pioenvs``
- Share common (global) options between build environments using ``[env]`` section in `"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__ (`issue #1643 <https://github.com/platformio/platformio-core/issues/1643>`_)
- Include external configuration files in `"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__ with `extra_configs <http://docs.platformio.org/page/projectconf/section_platformio.html#extra-configs>`__ option (`issue #1590 <https://github.com/platformio/platformio-core/issues/1590>`_)
- Override default `"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__ with a custom using ``-c, --project-conf`` option for `platformio run <http://docs.platformio.org/page/userguide/cmd_run.html>`__, `platformio debug <http://docs.platformio.org/page/userguide/cmd_debug.html>`__, or `platformio test <http://docs.platformio.org/page/userguide/cmd_test.html>`__ commands (`issue #1913 <https://github.com/platformio/platformio-core/issues/1913>`_)
- Custom project ``***_dir`` options declared in "platformio" section of `"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__ have higher priority than `Environment variables <http://docs.platformio.org/page/envvars.html>`__
- Use workspace ``.pio/build`` folder for build artifacts instead of ``.pioenvs``
- Added new `monitor_flags <http://docs.platformio.org/page/projectconf/section_env_monitor.html#monitor-flags>`__ option to `"platformio.ini" (Project Configuration File) <https://docs.platformio.org/page/projectconf.html>`__ which allows passing extra flags and options to `platformio device monitor <http://docs.platformio.org/page/userguide/cmd_device.html#cmd-device-monitor>`__ command (`issue #2165 <https://github.com/platformio/platformio-core/issues/2165>`_)

* **Library Management**

- Save libraries passed to `platformio lib install <http://docs.platformio.org/page/userguide/lib/cmd_install.html>`__ command into the project dependency list (`lib_deps <http://docs.platformio.org/page/projectconf/section_env_library.html#lib-deps>`__) with a new ``--save`` flag (`issue #1028 <https://github.com/platformio/platformio-core/issues/1028>`_)
- Install all project dependencies declared via `lib_deps <http://docs.platformio.org/page/projectconf/section_env_library.html#lib-deps>`__ option using a simple `platformio lib install <http://docs.platformio.org/page/userguide/lib/cmd_install.html>`__ command (`issue #2147 <https://github.com/platformio/platformio-core/issues/2147>`_)
- Use isolated library dependency storage per project build environment (`issue #1696 <https://github.com/platformio/platformio-core/issues/1696>`_)
- Override default source and include directories for a library via `library.json <http://docs.platformio.org/page/librarymanager/config.html>`__ manifest using ``includeDir`` and ``srcDir`` fields
- Use workspace ``.pio/libdeps`` folder for project dependencies instead of ``.piolibdeps``
- Switched to workspace ``.pio/libdeps`` folder for project dependencies instead of ``.piolibdeps``

* **Infrastructure**

Expand All @@ -43,7 +44,7 @@ PlatformIO 3.0

* Support custom CMake configuration for CLion IDE using ``CMakeListsUser.txt`` file
* Fixed an issue with hardcoded C stadard version when generating project for CLion IDE (`issue #2527 <https://github.com/platformio/platformio-core/issues/2527>`_)
* Fixed "systemd-udevd" warnings in `99-platformio-udev.rules <http://docs.platformio.org/en/latest/faq.html#platformio-udev-rules>`__ (`issue #2442 <https://github.com/platformio/platformio-core/issues/2442>`_)
* Fixed "systemd-udevd" warnings in `99-platformio-udev.rules <http://docs.platformio.org/page/faq.html#platformio-udev-rules>`__ (`issue #2442 <https://github.com/platformio/platformio-core/issues/2442>`_)
* Fixed an issue when ``-U`` in ``build_flags`` does not remove macro previously defined via ``-D`` flag (`issue #2508 <https://github.com/platformio/platformio-core/issues/2508>`_)
* Fixed an issue for Project Generator when include path search order is inconsistent to what passed to the compiler (`issue #2509 <https://github.com/platformio/platformio-core/issues/2509>`_)

Expand Down
2 changes: 1 addition & 1 deletion docs
20 changes: 14 additions & 6 deletions platformio/commands/device.py
Expand Up @@ -162,16 +162,20 @@ def device_list( # pylint: disable=too-many-branches
"--environment",
help="Load configuration from `platformio.ini` and specified environment")
def device_monitor(**kwargs): # pylint: disable=too-many-branches
custom_monitor_flags = []
try:
monitor_options = get_project_options(kwargs['project_dir'],
kwargs['environment'])
if monitor_options:
env_options = get_project_options(kwargs['project_dir'],
kwargs['environment'])
if "monitor_flags" in env_options:
custom_monitor_flags = ProjectConfig.parse_multi_values(
env_options['monitor_flags'])
if env_options:
for k in ("port", "speed", "rts", "dtr"):
k2 = "monitor_%s" % k
if k == "speed":
k = "baud"
if kwargs[k] is None and k2 in monitor_options:
kwargs[k] = monitor_options[k2]
if kwargs[k] is None and k2 in env_options:
kwargs[k] = env_options[k2]
if k != "port":
kwargs[k] = int(kwargs[k])
except exception.NotPlatformIOProject:
Expand All @@ -182,11 +186,13 @@ def device_monitor(**kwargs): # pylint: disable=too-many-branches
if len(ports) == 1:
kwargs['port'] = ports[0]['port']

sys.argv = ["monitor"]
sys.argv = ["monitor"] + custom_monitor_flags
for k, v in kwargs.items():
if k in ("port", "baud", "rts", "dtr", "environment", "project_dir"):
continue
k = "--" + k.replace("_", "-")
if k in custom_monitor_flags:
continue
if isinstance(v, bool):
if v:
sys.argv.append(k)
Expand All @@ -196,6 +202,8 @@ def device_monitor(**kwargs): # pylint: disable=too-many-branches
else:
sys.argv.extend([k, str(v)])

print(sys.argv)

try:
miniterm.main(
default_port=kwargs['port'],
Expand Down
1 change: 1 addition & 0 deletions platformio/project/config.py
Expand Up @@ -86,6 +86,7 @@
"monitor_speed",
"monitor_rts",
"monitor_dtr",
"monitor_flags",

# Library
"lib_deps",
Expand Down

0 comments on commit a84195b

Please sign in to comment.