Show "TimeoutError" only in the verbose mode when can not find a serial port

This commit is contained in:
Ivan Kravets
2022-07-08 15:18:52 +03:00
parent dd14b5e2ed
commit 4c2aca4956
4 changed files with 27 additions and 17 deletions

View File

@@ -13,6 +13,11 @@ PlatformIO Core 6
**A professional collaborative platform for declarative, safety-critical, and test-driven embedded development.** **A professional collaborative platform for declarative, safety-critical, and test-driven embedded development.**
6.1.1 (2022-??-??)
~~~~~~~~~~~~~~~~~~
* Show "TimeoutError" only in the verbose mode when finding a serial port
6.1.0 (2022-07-06) 6.1.0 (2022-07-06)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~

View File

@@ -117,6 +117,7 @@ def AutodetectUploadPort(*args, **kwargs):
board_config=env.BoardConfig() if "BOARD" in env else None, board_config=env.BoardConfig() if "BOARD" in env else None,
upload_protocol=upload_protocol, upload_protocol=upload_protocol,
prefer_gdb_port="blackmagic" in upload_protocol, prefer_gdb_port="blackmagic" in upload_protocol,
verbose=int(ARGUMENTS.get("PIOVERBOSE", 0)),
) )
) )

View File

@@ -88,6 +88,7 @@ def find_serial_port( # pylint: disable=too-many-arguments
ensure_ready=False, ensure_ready=False,
prefer_gdb_port=False, prefer_gdb_port=False,
timeout=2, timeout=2,
verbose=False,
): ):
if initial_port: if initial_port:
if not is_pattern_port(initial_port): if not is_pattern_port(initial_port):
@@ -97,8 +98,8 @@ def find_serial_port( # pylint: disable=too-many-arguments
if upload_protocol and upload_protocol.startswith("blackmagic"): if upload_protocol and upload_protocol.startswith("blackmagic"):
return find_blackmagic_serial_port(prefer_gdb_port, timeout) return find_blackmagic_serial_port(prefer_gdb_port, timeout)
if board_config and board_config.get("build.hwids", []): if board_config and board_config.get("build.hwids", []):
return find_board_serial_port(board_config, timeout) return find_board_serial_port(board_config, timeout, verbose)
port = find_known_uart_port(ensure_ready, timeout) port = find_known_uart_port(ensure_ready, timeout, verbose)
if port: if port:
return port return port
@@ -158,7 +159,7 @@ def find_blackmagic_serial_port(prefer_gdb_port=False, timeout=0):
return None return None
def find_board_serial_port(board_config, timeout=0): def find_board_serial_port(board_config, timeout=0, verbose=False):
hwids = board_config.get("build.hwids", []) hwids = board_config.get("build.hwids", [])
try: try:
@@ -175,18 +176,19 @@ def find_board_serial_port(board_config, timeout=0):
except retry.RetryStopException: except retry.RetryStopException:
pass pass
click.secho( if verbose:
"TimeoutError: Could not automatically find serial port " click.secho(
"for the `%s` board based on the declared HWIDs=%s" "TimeoutError: Could not automatically find serial port "
% (board_config.get("name", "unknown"), hwids), "for the `%s` board based on the declared HWIDs=%s"
fg="yellow", % (board_config.get("name", "unknown"), hwids),
err=True, fg="yellow",
) err=True,
)
return None return None
def find_known_uart_port(ensure_ready=False, timeout=0): def find_known_uart_port(ensure_ready=False, timeout=0, verbose=False):
known_hwids = list(BLACK_MAGIC_HWIDS) known_hwids = list(BLACK_MAGIC_HWIDS)
# load from UDEV rules # load from UDEV rules
@@ -222,12 +224,13 @@ def find_known_uart_port(ensure_ready=False, timeout=0):
except retry.RetryStopException: except retry.RetryStopException:
pass pass
click.secho( if verbose:
"TimeoutError: Could not automatically find serial port " click.secho(
"based on the known UART bridges", "TimeoutError: Could not automatically find serial port "
fg="yellow", "based on the known UART bridges",
err=True, fg="yellow",
) err=True,
)
return None return None

View File

@@ -73,6 +73,7 @@ class SerialTestOutputReader:
), ),
upload_protocol=project_options.get("upload_protocol"), upload_protocol=project_options.get("upload_protocol"),
ensure_ready=True, ensure_ready=True,
verbose=self.test_runner.verbose,
) )
if port: if port:
return port return port