Skip to content

Commit bf6b04f

Browse files
committed
Adding suggestions when mbed detect fails. Suppress traceback from mbed tools by default
1 parent 10a6c10 commit bf6b04f

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

mbed/mbed.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,15 +2459,29 @@ def detect():
24592459
# Prepare environment variables
24602460
env = program.get_env()
24612461

2462-
popen([python_cmd, '-u', os.path.join(tools_dir, 'detect_targets.py')]
2463-
+ args,
2464-
env=env)
2462+
try:
2463+
pquery([python_cmd, '-u', os.path.join(tools_dir, 'detect_targets.py')]
2464+
+ args,
2465+
env=env)
2466+
except ProcessException as e:
2467+
error("Failed to correctly detect all targets (run with '-vv' for more information)")
2468+
if very_verbose:
2469+
error(str(e))
24652470
else:
24662471
warning("The mbed tools were not found in \"%s\". \nLimited information will be shown about connected mbed targets/boards" % program.path)
24672472
targets = program.get_detected_targets()
24682473
if targets:
2474+
unknown_found = False
24692475
for target in targets:
2470-
action("Detected \"%s\" connected to \"%s\" and using com port \"%s\"" % (target['name'], target['mount'], target['serial']))
2476+
if target['name'] is None:
2477+
unknown_found = True
2478+
action("Detected unknown target connected to \"%s\" and using com port \"%s\"" % (target['mount'], target['serial']))
2479+
else:
2480+
action("Detected \"%s\" connected to \"%s\" and using com port \"%s\"" % (target['name'], target['mount'], target['serial']))
2481+
2482+
if unknown_found:
2483+
warning("If you're developing a new target, you can mock the device to continue your development. "
2484+
"Use 'mbedls --mock ID:NAME' to do so (see 'mbedls --help' for more information)")
24712485

24722486

24732487
# Generic config command

0 commit comments

Comments
 (0)