@@ -1323,20 +1323,21 @@ def get_env(self):
1323
1323
return env
1324
1324
1325
1325
def get_target (self , target = None ):
1326
- if target :
1327
- if target .lower () == 'detect' or target .lower () == 'auto' :
1328
- targets = self .get_detected_targets ()
1329
- if targets == False :
1330
- error ("The target detection requires that the 'mbed-ls' python module is installed." )
1331
- elif len (targets ) > 1 :
1332
- error ("Multiple targets were detected.\n Only 1 target board should be connected to your system when you use the '-m auto' switch." )
1333
- elif len (targets ) == 0 :
1334
- error ("No targets were detected.\n Please make sure a target board to this system." )
1335
- else :
1336
- action ("Detected \" %s\" connected to \" %s\" and using com port \" %s\" " % (targets [0 ]['name' ], targets [0 ]['mount' ], targets [0 ]['serial' ]))
1337
- target = targets [0 ]['name' ]
1338
- else :
1339
- target = self .get_cfg ('TARGET' )
1326
+ target_cfg = self .get_cfg ('TARGET' )
1327
+ target = target if target else target_cfg
1328
+
1329
+ if target and (target .lower () == 'detect' or target .lower () == 'auto' ):
1330
+ targets = self .get_detected_targets ()
1331
+ if targets == False :
1332
+ error ("The target detection requires that the 'mbed-ls' python module is installed." )
1333
+ elif len (targets ) > 1 :
1334
+ error ("Multiple targets were detected.\n Only 1 target board should be connected to your system when you use the '-m auto' switch." )
1335
+ elif len (targets ) == 0 :
1336
+ error ("No targets were detected.\n Please make sure a target board to this system." )
1337
+ else :
1338
+ action ("Detected \" %s\" connected to \" %s\" and using com port \" %s\" " % (targets [0 ]['name' ], targets [0 ]['mount' ], targets [0 ]['serial' ]))
1339
+ target = targets [0 ]['name' ]
1340
+
1340
1341
if target is None :
1341
1342
error ("Please specify target using the -m switch or set default target using command 'mbed target'" , 1 )
1342
1343
return target
0 commit comments