Skip to content

Commit 4d2bd4f

Browse files
committed
Fallback to detect connected target board when doing compile or test with no target specified
1 parent 485a450 commit 4d2bd4f

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

mbed/mbed.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,13 +1714,11 @@ def get_target(self, target=None):
17141714
target_cfg = self.get_cfg('TARGET')
17151715
target = target if target else target_cfg
17161716

1717-
if target and (target.lower() == 'detect' or target.lower() == 'auto'):
1717+
if not target or (target.lower() == 'detect' or target.lower() == 'auto'):
17181718
detected = self.detect_single_target()
17191719
if detected:
17201720
target = detected['name']
17211721

1722-
if target is None:
1723-
error("Please specify target using the -m switch or set default target using command \"mbed target\"", 1)
17241722
return target
17251723

17261724
def get_toolchain(self, toolchain=None):
@@ -1762,7 +1760,7 @@ def detect_single_target(self, info=None):
17621760
elif len(targets) > 1:
17631761
error("Multiple targets were detected.\nOnly 1 target board should be connected to your system.", 1)
17641762
elif len(targets) == 0:
1765-
error("No targets were detected.\nPlease make sure a target board is connected to this system.", 1)
1763+
error("No targets were detected.\nPlease make sure a target board is connected to this system.\nAlternatively, you can specify target using the -m switch or set default target using command \"mbed target\"", 1)
17661764
else:
17671765
action("Detected \"%s\" connected to \"%s\" and using com port \"%s\"" % (targets[0]['name'], targets[0]['mount'], targets[0]['serial']))
17681766
info = targets[0]

0 commit comments

Comments
 (0)