mirror of https://github.com/ARMmbed/mbed-os.git
Add detect_targets.py script to list the connected target boards
parent
0379af11aa
commit
fc04cfbb9d
|
@ -0,0 +1,84 @@
|
|||
#! /usr/bin/env python2
|
||||
"""
|
||||
mbed SDK
|
||||
Copyright (c) 2011-2013 ARM Limited
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
TEST BUILD & RUN
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
|
||||
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
||||
sys.path.insert(0, ROOT)
|
||||
|
||||
|
||||
from tools.options import get_default_options_parser
|
||||
|
||||
# Check: Extra modules which are required by core test suite
|
||||
from tools.utils import check_required_modules
|
||||
check_required_modules(['prettytable'])
|
||||
|
||||
# Imports related to mbed build api
|
||||
from tools.build_api import mcu_toolchain_matrix
|
||||
from tools.test_api import get_autodetected_MUTS_list
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
# Parse Options
|
||||
parser = get_default_options_parser()
|
||||
|
||||
parser.add_option("-S", "--supported-toolchains",
|
||||
action="store_true",
|
||||
dest="supported_toolchains",
|
||||
default=False,
|
||||
help="Displays supported matrix of MCUs and toolchains")
|
||||
|
||||
parser.add_option('-f', '--filter',
|
||||
dest='general_filter_regex',
|
||||
default=None,
|
||||
help='For some commands you can use filter to filter out results')
|
||||
|
||||
parser.add_option("-v", "--verbose",
|
||||
action="store_true",
|
||||
dest="verbose",
|
||||
default=False,
|
||||
help="Verbose diagnostic output")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
# Only prints matrix of supported toolchains
|
||||
if options.supported_toolchains:
|
||||
print mcu_toolchain_matrix(platform_filter=options.general_filter_regex)
|
||||
exit(0)
|
||||
|
||||
# If auto_detect attribute is present, we assume other auto-detection
|
||||
# parameters like 'toolchains_filter' are also set.
|
||||
print "[mbed] Detecting connected mbed-enabled devices... "
|
||||
|
||||
MUTs = get_autodetected_MUTS_list()
|
||||
|
||||
for mut in MUTs.values():
|
||||
print "[mbed] Detected %s, port: %s, mounted: %s"% (mut['mcu'], mut['port'], mut['disk'])
|
||||
|
||||
except KeyboardInterrupt, e:
|
||||
print "\n[CTRL+c] exit"
|
||||
except Exception,e:
|
||||
import traceback
|
||||
traceback.print_exc(file=sys.stdout)
|
||||
print "[ERROR] %s" % str(e)
|
||||
sys.exit(1)
|
Loading…
Reference in New Issue