Skip to content

Commit 72ac08d

Browse files
committed
Introduce new command 'detect' which is used to detect connected targets/platforms to the system
1 parent ed236f5 commit 72ac08d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

mbed/mbed.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,6 +1829,26 @@ def export(ide=None, mcu=None):
18291829
env=env)
18301830

18311831

1832+
# Test command
1833+
@subcommand('detect',
1834+
help='Detect mbed targets/boards connected to this system.')
1835+
def test(tlist=False):
1836+
# Gather remaining arguments
1837+
args = remainder
1838+
# Find the root of the program
1839+
program = Program(os.getcwd(), True)
1840+
# Change directories to the program root to use mbed OS tools
1841+
with cd(program.path):
1842+
tools_dir = program.get_tools()
1843+
1844+
# Prepare environment variables
1845+
env = os.environ.copy()
1846+
env['PYTHONPATH'] = '.'
1847+
popen(['python', '-u', os.path.join(tools_dir, 'detect_targets.py')]
1848+
+ args,
1849+
env=env)
1850+
1851+
18321852
# Build system and exporters
18331853
@subcommand('target',
18341854
dict(name='name', nargs='?', help='Default target name. Example: K64F, NUCLEO_F401RE, NRF51822...'),

0 commit comments

Comments
 (0)