Backup 1

Committer:
borlanic
Date:
Tue Apr 24 11:45:18 2018 +0000
Revision:
0:02dd72d1d465
BaBoRo_test2 - backup 1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
borlanic 0:02dd72d1d465 1 #! /usr/bin/env python2
borlanic 0:02dd72d1d465 2 """
borlanic 0:02dd72d1d465 3 mbed SDK
borlanic 0:02dd72d1d465 4 Copyright (c) 2011-2013 ARM Limited
borlanic 0:02dd72d1d465 5
borlanic 0:02dd72d1d465 6 Licensed under the Apache License, Version 2.0 (the "License");
borlanic 0:02dd72d1d465 7 you may not use this file except in compliance with the License.
borlanic 0:02dd72d1d465 8 You may obtain a copy of the License at
borlanic 0:02dd72d1d465 9
borlanic 0:02dd72d1d465 10 http://www.apache.org/licenses/LICENSE-2.0
borlanic 0:02dd72d1d465 11
borlanic 0:02dd72d1d465 12 Unless required by applicable law or agreed to in writing, software
borlanic 0:02dd72d1d465 13 distributed under the License is distributed on an "AS IS" BASIS,
borlanic 0:02dd72d1d465 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
borlanic 0:02dd72d1d465 15 See the License for the specific language governing permissions and
borlanic 0:02dd72d1d465 16 limitations under the License.
borlanic 0:02dd72d1d465 17 """
borlanic 0:02dd72d1d465 18 from __future__ import print_function
borlanic 0:02dd72d1d465 19 import sys
borlanic 0:02dd72d1d465 20 import os
borlanic 0:02dd72d1d465 21 import re
borlanic 0:02dd72d1d465 22
borlanic 0:02dd72d1d465 23 ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
borlanic 0:02dd72d1d465 24 sys.path.insert(0, ROOT)
borlanic 0:02dd72d1d465 25
borlanic 0:02dd72d1d465 26 from tools.options import get_default_options_parser
borlanic 0:02dd72d1d465 27
borlanic 0:02dd72d1d465 28 # Check: Extra modules which are required by core test suite
borlanic 0:02dd72d1d465 29 from tools.utils import check_required_modules
borlanic 0:02dd72d1d465 30 check_required_modules(['prettytable'])
borlanic 0:02dd72d1d465 31
borlanic 0:02dd72d1d465 32 # Imports related to mbed build api
borlanic 0:02dd72d1d465 33 from tools.build_api import mcu_toolchain_matrix
borlanic 0:02dd72d1d465 34 from tools.test_api import get_autodetected_MUTS_list
borlanic 0:02dd72d1d465 35 from tools.test_api import get_module_avail
borlanic 0:02dd72d1d465 36 from argparse import ArgumentParser
borlanic 0:02dd72d1d465 37
borlanic 0:02dd72d1d465 38 try:
borlanic 0:02dd72d1d465 39 import mbed_lstools
borlanic 0:02dd72d1d465 40 except:
borlanic 0:02dd72d1d465 41 pass
borlanic 0:02dd72d1d465 42
borlanic 0:02dd72d1d465 43 def main():
borlanic 0:02dd72d1d465 44 """Entry Point"""
borlanic 0:02dd72d1d465 45 try:
borlanic 0:02dd72d1d465 46 # Parse Options
borlanic 0:02dd72d1d465 47 parser = ArgumentParser()
borlanic 0:02dd72d1d465 48
borlanic 0:02dd72d1d465 49 parser.add_argument("-S", "--supported-toolchains",
borlanic 0:02dd72d1d465 50 action="store_true",
borlanic 0:02dd72d1d465 51 dest="supported_toolchains",
borlanic 0:02dd72d1d465 52 default=False,
borlanic 0:02dd72d1d465 53 help="Displays supported matrix of"
borlanic 0:02dd72d1d465 54 " targets and toolchains")
borlanic 0:02dd72d1d465 55
borlanic 0:02dd72d1d465 56 parser.add_argument('-f', '--filter',
borlanic 0:02dd72d1d465 57 dest='general_filter_regex',
borlanic 0:02dd72d1d465 58 default=None,
borlanic 0:02dd72d1d465 59 help='Filter targets')
borlanic 0:02dd72d1d465 60
borlanic 0:02dd72d1d465 61 parser.add_argument("-v", "--verbose",
borlanic 0:02dd72d1d465 62 action="store_true",
borlanic 0:02dd72d1d465 63 dest="verbose",
borlanic 0:02dd72d1d465 64 default=False,
borlanic 0:02dd72d1d465 65 help="Verbose diagnostic output")
borlanic 0:02dd72d1d465 66
borlanic 0:02dd72d1d465 67 options = parser.parse_args()
borlanic 0:02dd72d1d465 68
borlanic 0:02dd72d1d465 69 # Only prints matrix of supported toolchains
borlanic 0:02dd72d1d465 70 if options.supported_toolchains:
borlanic 0:02dd72d1d465 71 print(mcu_toolchain_matrix(
borlanic 0:02dd72d1d465 72 platform_filter=options.general_filter_regex))
borlanic 0:02dd72d1d465 73 exit(0)
borlanic 0:02dd72d1d465 74
borlanic 0:02dd72d1d465 75 # If auto_detect attribute is present, we assume other auto-detection
borlanic 0:02dd72d1d465 76 # parameters like 'toolchains_filter' are also set.
borlanic 0:02dd72d1d465 77 muts = get_autodetected_MUTS_list()
borlanic 0:02dd72d1d465 78
borlanic 0:02dd72d1d465 79 mcu_filter = options.general_filter_regex or ".*"
borlanic 0:02dd72d1d465 80
borlanic 0:02dd72d1d465 81 count = 0
borlanic 0:02dd72d1d465 82 for mut in muts.values():
borlanic 0:02dd72d1d465 83 if re.match(mcu_filter, mut['mcu'] or "Unknown"):
borlanic 0:02dd72d1d465 84 interface_version = get_interface_version(mut['disk'])
borlanic 0:02dd72d1d465 85 print("")
borlanic 0:02dd72d1d465 86 print("[mbed] Detected %s, port %s, mounted %s, interface "
borlanic 0:02dd72d1d465 87 "version %s:" %
borlanic 0:02dd72d1d465 88 (mut['mcu'], mut['port'], mut['disk'], interface_version))
borlanic 0:02dd72d1d465 89 print("[mbed] Supported toolchains for %s" % mut['mcu'])
borlanic 0:02dd72d1d465 90 print(mcu_toolchain_matrix(platform_filter=mut['mcu']))
borlanic 0:02dd72d1d465 91 count += 1
borlanic 0:02dd72d1d465 92
borlanic 0:02dd72d1d465 93 if count == 0:
borlanic 0:02dd72d1d465 94 print("[mbed] No mbed targets were detected on your system.")
borlanic 0:02dd72d1d465 95
borlanic 0:02dd72d1d465 96 except KeyboardInterrupt:
borlanic 0:02dd72d1d465 97 print("\n[CTRL+c] exit")
borlanic 0:02dd72d1d465 98 except Exception as exc:
borlanic 0:02dd72d1d465 99 import traceback
borlanic 0:02dd72d1d465 100 traceback.print_exc(file=sys.stdout)
borlanic 0:02dd72d1d465 101 print("[ERROR] %s" % str(exc))
borlanic 0:02dd72d1d465 102 sys.exit(1)
borlanic 0:02dd72d1d465 103
borlanic 0:02dd72d1d465 104 def get_interface_version(mount_point):
borlanic 0:02dd72d1d465 105 """ Function returns interface version from the target mounted on the specified mount point
borlanic 0:02dd72d1d465 106
borlanic 0:02dd72d1d465 107 mount_point can be acquired via the following:
borlanic 0:02dd72d1d465 108 muts = get_autodetected_MUTS_list()
borlanic 0:02dd72d1d465 109 for mut in muts.values():
borlanic 0:02dd72d1d465 110 mount_point = mut['disk']
borlanic 0:02dd72d1d465 111
borlanic 0:02dd72d1d465 112 @param mount_point Name of disk where platform is connected to host machine.
borlanic 0:02dd72d1d465 113 """
borlanic 0:02dd72d1d465 114 if get_module_avail('mbed_lstools'):
borlanic 0:02dd72d1d465 115 try :
borlanic 0:02dd72d1d465 116 mbedls = mbed_lstools.create()
borlanic 0:02dd72d1d465 117 mbeds = mbedls.list_mbeds(unique_names=True, read_details_txt=True)
borlanic 0:02dd72d1d465 118
borlanic 0:02dd72d1d465 119 for mbed in mbeds:
borlanic 0:02dd72d1d465 120 if mbed['mount_point'] == mount_point:
borlanic 0:02dd72d1d465 121
borlanic 0:02dd72d1d465 122 if 'daplink_version' in mbed:
borlanic 0:02dd72d1d465 123 return mbed['daplink_version']
borlanic 0:02dd72d1d465 124 except :
borlanic 0:02dd72d1d465 125 return 'unknown'
borlanic 0:02dd72d1d465 126
borlanic 0:02dd72d1d465 127 return 'unknown'
borlanic 0:02dd72d1d465 128
borlanic 0:02dd72d1d465 129 if __name__ == '__main__':
borlanic 0:02dd72d1d465 130 main()