Includes library modifications to allow access to AIN_4 (AIN_0 / 5)
mbd_os/tools/detect_targets.py@0:eafc3fd41f75, 2016-09-20 (annotated)
- Committer:
- bryantaylor
- Date:
- Tue Sep 20 21:26:12 2016 +0000
- Revision:
- 0:eafc3fd41f75
hackathon
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bryantaylor | 0:eafc3fd41f75 | 1 | #! /usr/bin/env python2 |
bryantaylor | 0:eafc3fd41f75 | 2 | """ |
bryantaylor | 0:eafc3fd41f75 | 3 | mbed SDK |
bryantaylor | 0:eafc3fd41f75 | 4 | Copyright (c) 2011-2013 ARM Limited |
bryantaylor | 0:eafc3fd41f75 | 5 | |
bryantaylor | 0:eafc3fd41f75 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); |
bryantaylor | 0:eafc3fd41f75 | 7 | you may not use this file except in compliance with the License. |
bryantaylor | 0:eafc3fd41f75 | 8 | You may obtain a copy of the License at |
bryantaylor | 0:eafc3fd41f75 | 9 | |
bryantaylor | 0:eafc3fd41f75 | 10 | http://www.apache.org/licenses/LICENSE-2.0 |
bryantaylor | 0:eafc3fd41f75 | 11 | |
bryantaylor | 0:eafc3fd41f75 | 12 | Unless required by applicable law or agreed to in writing, software |
bryantaylor | 0:eafc3fd41f75 | 13 | distributed under the License is distributed on an "AS IS" BASIS, |
bryantaylor | 0:eafc3fd41f75 | 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
bryantaylor | 0:eafc3fd41f75 | 15 | See the License for the specific language governing permissions and |
bryantaylor | 0:eafc3fd41f75 | 16 | limitations under the License. |
bryantaylor | 0:eafc3fd41f75 | 17 | """ |
bryantaylor | 0:eafc3fd41f75 | 18 | import sys |
bryantaylor | 0:eafc3fd41f75 | 19 | import os |
bryantaylor | 0:eafc3fd41f75 | 20 | |
bryantaylor | 0:eafc3fd41f75 | 21 | ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) |
bryantaylor | 0:eafc3fd41f75 | 22 | sys.path.insert(0, ROOT) |
bryantaylor | 0:eafc3fd41f75 | 23 | |
bryantaylor | 0:eafc3fd41f75 | 24 | from tools.options import get_default_options_parser |
bryantaylor | 0:eafc3fd41f75 | 25 | |
bryantaylor | 0:eafc3fd41f75 | 26 | # Check: Extra modules which are required by core test suite |
bryantaylor | 0:eafc3fd41f75 | 27 | from tools.utils import check_required_modules |
bryantaylor | 0:eafc3fd41f75 | 28 | check_required_modules(['prettytable']) |
bryantaylor | 0:eafc3fd41f75 | 29 | |
bryantaylor | 0:eafc3fd41f75 | 30 | # Imports related to mbed build api |
bryantaylor | 0:eafc3fd41f75 | 31 | from tools.build_api import mcu_toolchain_matrix |
bryantaylor | 0:eafc3fd41f75 | 32 | from tools.test_api import get_autodetected_MUTS_list |
bryantaylor | 0:eafc3fd41f75 | 33 | |
bryantaylor | 0:eafc3fd41f75 | 34 | |
bryantaylor | 0:eafc3fd41f75 | 35 | def main(): |
bryantaylor | 0:eafc3fd41f75 | 36 | """Entry Point""" |
bryantaylor | 0:eafc3fd41f75 | 37 | try: |
bryantaylor | 0:eafc3fd41f75 | 38 | # Parse Options |
bryantaylor | 0:eafc3fd41f75 | 39 | parser = get_default_options_parser() |
bryantaylor | 0:eafc3fd41f75 | 40 | |
bryantaylor | 0:eafc3fd41f75 | 41 | parser.add_argument("-S", "--supported-toolchains", |
bryantaylor | 0:eafc3fd41f75 | 42 | action="store_true", |
bryantaylor | 0:eafc3fd41f75 | 43 | dest="supported_toolchains", |
bryantaylor | 0:eafc3fd41f75 | 44 | default=False, |
bryantaylor | 0:eafc3fd41f75 | 45 | help="Displays supported matrix of" |
bryantaylor | 0:eafc3fd41f75 | 46 | " targets and toolchains") |
bryantaylor | 0:eafc3fd41f75 | 47 | |
bryantaylor | 0:eafc3fd41f75 | 48 | parser.add_argument('-f', '--filter', |
bryantaylor | 0:eafc3fd41f75 | 49 | dest='general_filter_regex', |
bryantaylor | 0:eafc3fd41f75 | 50 | default=None, |
bryantaylor | 0:eafc3fd41f75 | 51 | help='Filter targets') |
bryantaylor | 0:eafc3fd41f75 | 52 | |
bryantaylor | 0:eafc3fd41f75 | 53 | parser.add_argument("-v", "--verbose", |
bryantaylor | 0:eafc3fd41f75 | 54 | action="store_true", |
bryantaylor | 0:eafc3fd41f75 | 55 | dest="verbose", |
bryantaylor | 0:eafc3fd41f75 | 56 | default=False, |
bryantaylor | 0:eafc3fd41f75 | 57 | help="Verbose diagnostic output") |
bryantaylor | 0:eafc3fd41f75 | 58 | |
bryantaylor | 0:eafc3fd41f75 | 59 | options = parser.parse_args() |
bryantaylor | 0:eafc3fd41f75 | 60 | |
bryantaylor | 0:eafc3fd41f75 | 61 | # Only prints matrix of supported toolchains |
bryantaylor | 0:eafc3fd41f75 | 62 | if options.supported_toolchains: |
bryantaylor | 0:eafc3fd41f75 | 63 | print mcu_toolchain_matrix( |
bryantaylor | 0:eafc3fd41f75 | 64 | platform_filter=options.general_filter_regex) |
bryantaylor | 0:eafc3fd41f75 | 65 | exit(0) |
bryantaylor | 0:eafc3fd41f75 | 66 | |
bryantaylor | 0:eafc3fd41f75 | 67 | # If auto_detect attribute is present, we assume other auto-detection |
bryantaylor | 0:eafc3fd41f75 | 68 | # parameters like 'toolchains_filter' are also set. |
bryantaylor | 0:eafc3fd41f75 | 69 | muts = get_autodetected_MUTS_list() |
bryantaylor | 0:eafc3fd41f75 | 70 | |
bryantaylor | 0:eafc3fd41f75 | 71 | count = 0 |
bryantaylor | 0:eafc3fd41f75 | 72 | for mut in muts.values(): |
bryantaylor | 0:eafc3fd41f75 | 73 | print "" |
bryantaylor | 0:eafc3fd41f75 | 74 | print "[mbed] Detected %s, port %s, mounted %s" % \ |
bryantaylor | 0:eafc3fd41f75 | 75 | (mut['mcu'], mut['port'], mut['disk']) |
bryantaylor | 0:eafc3fd41f75 | 76 | print "[mbed] Supported toolchains for %s" % mut['mcu'] |
bryantaylor | 0:eafc3fd41f75 | 77 | print mcu_toolchain_matrix(platform_filter=r'^'+mut['mcu']+'$') |
bryantaylor | 0:eafc3fd41f75 | 78 | count += 1 |
bryantaylor | 0:eafc3fd41f75 | 79 | |
bryantaylor | 0:eafc3fd41f75 | 80 | if count == 0: |
bryantaylor | 0:eafc3fd41f75 | 81 | print "[mbed] No mbed targets where detected on your system." |
bryantaylor | 0:eafc3fd41f75 | 82 | |
bryantaylor | 0:eafc3fd41f75 | 83 | except KeyboardInterrupt: |
bryantaylor | 0:eafc3fd41f75 | 84 | print "\n[CTRL+c] exit" |
bryantaylor | 0:eafc3fd41f75 | 85 | except Exception as exc: |
bryantaylor | 0:eafc3fd41f75 | 86 | import traceback |
bryantaylor | 0:eafc3fd41f75 | 87 | traceback.print_exc(file=sys.stdout) |
bryantaylor | 0:eafc3fd41f75 | 88 | print "[ERROR] %s" % str(exc) |
bryantaylor | 0:eafc3fd41f75 | 89 | sys.exit(1) |
bryantaylor | 0:eafc3fd41f75 | 90 | |
bryantaylor | 0:eafc3fd41f75 | 91 | if __name__ == '__main__': |
bryantaylor | 0:eafc3fd41f75 | 92 | main() |