Skip to content

Commit 16e8efa

Browse files
committed
Merge branch 'feat/diag_port' into 'master'
feat(diag): pass serial port to esp-idf-diag See merge request espressif/esp-idf!39813
2 parents 5d8e56b + ef9e762 commit 16e8efa

File tree

1 file changed

+50
-29
lines changed

1 file changed

+50
-29
lines changed

tools/idf_py_actions/diag_ext.py

Lines changed: 50 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,29 @@
88
from typing import Tuple
99

1010
import click
11+
1112
from idf_py_actions.tools import PropertyDict
1213
from idf_py_actions.tools import RunTool
1314
from idf_py_actions.tools import yellow_print
1415

1516

16-
def diag(action: str,
17-
ctx: click.core.Context,
18-
args: PropertyDict,
19-
debug: bool,
20-
log_prefix: bool,
21-
force: bool,
22-
no_color: bool,
23-
zip_directory: Optional[str],
24-
list_recipes: bool,
25-
check_recipes: bool,
26-
cmdl_recipes: Tuple,
27-
cmdl_tags: Tuple,
28-
purge_file: Optional[str],
29-
append: bool,
30-
output: Optional[str]) -> None:
31-
17+
def diag(
18+
action: str,
19+
ctx: click.core.Context,
20+
args: PropertyDict,
21+
debug: bool,
22+
log_prefix: bool,
23+
force: bool,
24+
no_color: bool,
25+
zip_directory: Optional[str],
26+
list_recipes: bool,
27+
check_recipes: bool,
28+
cmdl_recipes: Tuple,
29+
cmdl_tags: Tuple,
30+
purge_file: Optional[str],
31+
append: bool,
32+
output: Optional[str],
33+
) -> None:
3234
diag_args: list = [sys.executable, '-m', 'esp_idf_diag']
3335

3436
def add_common_arguments(diag_args: list) -> None:
@@ -100,6 +102,17 @@ def add_recipe_arguments(diag_args: list) -> None:
100102
diag_args += ['--force']
101103
if purge_file:
102104
diag_args += ['--purge', purge_file]
105+
if args.port:
106+
diag_args += ['--port', args.port]
107+
else:
108+
yellow_print(
109+
(
110+
'The target serial port is not specified, so '
111+
'autodetection will be used. To set it manually, use '
112+
'the "--port" option. Example: "idf.py --port '
113+
'/dev/ttyUSB0 diag".'
114+
)
115+
)
103116

104117
try:
105118
RunTool('idf_diag', diag_args, args.project_dir, hints=not args.no_hints)()
@@ -161,24 +174,30 @@ def action_extensions(base_actions: Dict, project_path: str) -> Any:
161174
'multiple': True,
162175
'metavar': 'RECIPE',
163176
'type': str,
164-
'help': ('Recipe to use. This option can be specified multiple times. '
165-
'By default, all built-in recipes are used. RECIPE refers to '
166-
'the recipe file path or the file name stem for built-in recipes.'),
177+
'help': (
178+
'Recipe to use. This option can be specified multiple times. '
179+
'By default, all built-in recipes are used. RECIPE refers to '
180+
'the recipe file path or the file name stem for built-in recipes.'
181+
),
167182
},
168183
{
169184
'names': ['-t', '--tag', 'cmdl_tags'],
170185
'multiple': True,
171186
'metavar': 'TAG',
172187
'type': str,
173-
'help': ('Consider only recipes containing TAG. This option can be specified '
174-
'multiple times. By default, all recipes are used. Use -l/--list-recipes '
175-
'option to see recipe TAG information.'),
188+
'help': (
189+
'Consider only recipes containing TAG. This option can be specified '
190+
'multiple times. By default, all recipes are used. Use -l/--list-recipes '
191+
'option to see recipe TAG information.'
192+
),
176193
},
177194
{
178195
'names': ['-a', '--append'],
179196
'is_flag': True,
180-
'help': ('Use recipes specified with the -r/--recipe option in '
181-
'combination with the built-in recipes.'),
197+
'help': (
198+
'Use recipes specified with the -r/--recipe option in '
199+
'combination with the built-in recipes.'
200+
),
182201
},
183202
{
184203
'names': ['-f', '--force'],
@@ -189,16 +208,18 @@ def action_extensions(base_actions: Dict, project_path: str) -> Any:
189208
'names': ['-o', '--output'],
190209
'metavar': 'PATH',
191210
'type': str,
192-
'help': ('Diagnostic report directory PATH or zip file archive PATH. '
193-
'If not specified, the report-UUID is used as the report directory, '
194-
'and the report directory specified with the --zip option with a zip '
195-
'extension is used for the zip file archive.')
211+
'help': (
212+
'Diagnostic report directory PATH or zip file archive PATH. '
213+
'If not specified, the report-UUID is used as the report directory, '
214+
'and the report directory specified with the --zip option with a zip '
215+
'extension is used for the zip file archive.'
216+
),
196217
},
197218
{
198219
'names': ['-p', '--purge', 'purge_file'],
199220
'metavar': 'PATH',
200221
'type': str,
201-
'help': ('Use a custom purge file to remove sensitive information from the report.')
222+
'help': ('Use a custom purge file to remove sensitive information from the report.'),
202223
},
203224
],
204225
},

0 commit comments

Comments
 (0)