Minor improvements for pio device monitor command

This commit is contained in:
Ivan Kravets
2022-06-12 12:14:28 +03:00
parent 7aaa9c028b
commit 375c396b7b
4 changed files with 23 additions and 23 deletions

View File

@ -19,7 +19,7 @@ PlatformIO Core 6
* **Device Monitor** * **Device Monitor**
- Automatically reconnect if a connection fails - Automatically reconnect if a connection fails
- Added new `pio device monitor --no-reconnect <https://docs.platformio.org/en/latest/core/userguide/device/cmd_monitor.html#cmdoption-pio-device-monitor-reconnect-no-reconnect>`__ option to disable automatic reconnection - Added new `pio device monitor --no-reconnect <https://docs.platformio.org/en/latest/core/userguide/device/cmd_monitor.html#cmdoption-pio-device-monitor-no-reconnect>`__ option to disable automatic reconnection
- Handle disconnects more gracefully (`issue #3939 <https://github.com/platformio/platformio-core/issues/3939>`_) - Handle disconnects more gracefully (`issue #3939 <https://github.com/platformio/platformio-core/issues/3939>`_)
* Fixed an issue when a custom `pio test --project-config <https://docs.platformio.org/en/latest/core/userguide/cmd_test.html#cmdoption-pio-test-c>`__ was not handled properly (`issue #4299 <https://github.com/platformio/platformio-core/issues/4299>`_) * Fixed an issue when a custom `pio test --project-config <https://docs.platformio.org/en/latest/core/userguide/cmd_test.html#cmdoption-pio-test-c>`__ was not handled properly (`issue #4299 <https://github.com/platformio/platformio-core/issues/4299>`_)

2
docs

Submodule docs updated: c86b25dd81...f0acc3040f

View File

@ -33,30 +33,30 @@ from platformio.project.options import ProjectOptions
"--baud", "--baud",
type=int, type=int,
default=ProjectOptions["env.monitor_speed"].default, default=ProjectOptions["env.monitor_speed"].default,
help="Set baud/speed, default=%d" % ProjectOptions["env.monitor_speed"].default, show_default=True,
help="Set baud/speed",
) )
@click.option( @click.option(
"--parity", "--parity",
default="N", default="N",
show_default=True,
type=click.Choice(["N", "E", "O", "S", "M"]), type=click.Choice(["N", "E", "O", "S", "M"]),
help="Set parity, default=N", help="Set parity",
)
@click.option("--rtscts", is_flag=True, help="Enable RTS/CTS flow control, default=Off")
@click.option(
"--xonxoff", is_flag=True, help="Enable software flow control, default=Off"
) )
@click.option("--rtscts", is_flag=True, help="Enable RTS/CTS flow control")
@click.option("--xonxoff", is_flag=True, help="Enable software flow control")
@click.option( @click.option(
"--rts", default=None, type=click.IntRange(0, 1), help="Set initial RTS line state" "--rts", default=None, type=click.IntRange(0, 1), help="Set initial RTS line state"
) )
@click.option( @click.option(
"--dtr", default=None, type=click.IntRange(0, 1), help="Set initial DTR line state" "--dtr", default=None, type=click.IntRange(0, 1), help="Set initial DTR line state"
) )
@click.option("--echo", is_flag=True, help="Enable local echo, default=Off") @click.option("--echo", is_flag=True, help="Enable local echo")
@click.option( @click.option(
"--encoding", "--encoding",
default="UTF-8", default="UTF-8",
help="Set the encoding for the serial port (e.g. hexlify, " show_default=True,
"Latin1, UTF-8), default: UTF-8", help="Set the encoding for the serial port (e.g. hexlify, Latin1, UTF-8)",
) )
@click.option( @click.option(
"-f", "--filter", "filters", multiple=True, help="Add filters/text transformations" "-f", "--filter", "filters", multiple=True, help="Add filters/text transformations"
@ -64,36 +64,35 @@ from platformio.project.options import ProjectOptions
@click.option( @click.option(
"--eol", "--eol",
default="CRLF", default="CRLF",
show_default=True,
type=click.Choice(["CR", "LF", "CRLF"]), type=click.Choice(["CR", "LF", "CRLF"]),
help="End of line mode, default=CRLF", help="End of line mode",
) )
@click.option("--raw", is_flag=True, help="Do not apply any encodings/transformations") @click.option("--raw", is_flag=True, help="Do not apply any encodings/transformations")
@click.option( @click.option(
"--exit-char", "--exit-char",
type=int, type=int,
default=3, default=3,
show_default=True,
help="ASCII code of special character that is used to exit " help="ASCII code of special character that is used to exit "
"the application, default=3 (Ctrl+C)", "the application [default=3 (Ctrl+C)]",
) )
@click.option( @click.option(
"--menu-char", "--menu-char",
type=int, type=int,
default=20, default=20,
help="ASCII code of special character that is used to " help="ASCII code of special character that is used to "
"control terminal (menu), default=20 (DEC)", "control terminal (menu) [default=20 (DEC)]",
) )
@click.option( @click.option(
"--quiet", "--quiet",
is_flag=True, is_flag=True,
help="Diagnostics: suppress non-error messages, default=Off", help="Diagnostics: suppress non-error messages",
) )
@click.option( @click.option(
"--reconnect/--no-reconnect", "--no-reconnect",
default=True, is_flag=True,
help=( help="Disable automatic reconnection if the established connection fails",
"If established connection fails, "
"silently retry on the same port, default=True"
),
) )
@click.option( @click.option(
"-d", "-d",
@ -104,7 +103,7 @@ from platformio.project.options import ProjectOptions
@click.option( @click.option(
"-e", "-e",
"--environment", "--environment",
help="Load configuration from `platformio.ini` and specified environment", help="Load configuration from `platformio.ini` and the specified environment",
) )
def device_monitor_cmd(**options): def device_monitor_cmd(**options):
platform = None platform = None
@ -131,6 +130,7 @@ def device_monitor_cmd(**options):
"--exit-char can not be the same as --menu-char" "--exit-char can not be the same as --menu-char"
) )
print(options)
start_terminal(options) start_terminal(options)

View File

@ -68,7 +68,7 @@ def start_terminal(options):
fg="red", fg="red",
err=True, err=True,
) )
if options["reconnect"]: if not options["no_reconnect"]:
raise UserSideException(term.pio_unexpected_exception) raise UserSideException(term.pio_unexpected_exception)
return return
except UserSideException as exc: except UserSideException as exc: