mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 02:27:13 +02:00
Show "TimeoutError" only in the verbose mode when can not find a serial port
This commit is contained in:
@ -13,6 +13,11 @@ PlatformIO Core 6
|
||||
|
||||
**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)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
@ -117,6 +117,7 @@ def AutodetectUploadPort(*args, **kwargs):
|
||||
board_config=env.BoardConfig() if "BOARD" in env else None,
|
||||
upload_protocol=upload_protocol,
|
||||
prefer_gdb_port="blackmagic" in upload_protocol,
|
||||
verbose=int(ARGUMENTS.get("PIOVERBOSE", 0)),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -88,6 +88,7 @@ def find_serial_port( # pylint: disable=too-many-arguments
|
||||
ensure_ready=False,
|
||||
prefer_gdb_port=False,
|
||||
timeout=2,
|
||||
verbose=False,
|
||||
):
|
||||
if 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"):
|
||||
return find_blackmagic_serial_port(prefer_gdb_port, timeout)
|
||||
if board_config and board_config.get("build.hwids", []):
|
||||
return find_board_serial_port(board_config, timeout)
|
||||
port = find_known_uart_port(ensure_ready, timeout)
|
||||
return find_board_serial_port(board_config, timeout, verbose)
|
||||
port = find_known_uart_port(ensure_ready, timeout, verbose)
|
||||
if port:
|
||||
return port
|
||||
|
||||
@ -158,7 +159,7 @@ def find_blackmagic_serial_port(prefer_gdb_port=False, timeout=0):
|
||||
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", [])
|
||||
try:
|
||||
|
||||
@ -175,18 +176,19 @@ def find_board_serial_port(board_config, timeout=0):
|
||||
except retry.RetryStopException:
|
||||
pass
|
||||
|
||||
click.secho(
|
||||
"TimeoutError: Could not automatically find serial port "
|
||||
"for the `%s` board based on the declared HWIDs=%s"
|
||||
% (board_config.get("name", "unknown"), hwids),
|
||||
fg="yellow",
|
||||
err=True,
|
||||
)
|
||||
if verbose:
|
||||
click.secho(
|
||||
"TimeoutError: Could not automatically find serial port "
|
||||
"for the `%s` board based on the declared HWIDs=%s"
|
||||
% (board_config.get("name", "unknown"), hwids),
|
||||
fg="yellow",
|
||||
err=True,
|
||||
)
|
||||
|
||||
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)
|
||||
|
||||
# load from UDEV rules
|
||||
@ -222,12 +224,13 @@ def find_known_uart_port(ensure_ready=False, timeout=0):
|
||||
except retry.RetryStopException:
|
||||
pass
|
||||
|
||||
click.secho(
|
||||
"TimeoutError: Could not automatically find serial port "
|
||||
"based on the known UART bridges",
|
||||
fg="yellow",
|
||||
err=True,
|
||||
)
|
||||
if verbose:
|
||||
click.secho(
|
||||
"TimeoutError: Could not automatically find serial port "
|
||||
"based on the known UART bridges",
|
||||
fg="yellow",
|
||||
err=True,
|
||||
)
|
||||
|
||||
return None
|
||||
|
||||
|
@ -73,6 +73,7 @@ class SerialTestOutputReader:
|
||||
),
|
||||
upload_protocol=project_options.get("upload_protocol"),
|
||||
ensure_ready=True,
|
||||
verbose=self.test_runner.verbose,
|
||||
)
|
||||
if port:
|
||||
return port
|
||||
|
Reference in New Issue
Block a user