Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466

Dependencies:   ssd1331

Committer:
kadonotakashi
Date:
Wed Oct 10 00:33:53 2018 +0000
Revision:
0:8fdf9a60065b
how to make mbed librry

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kadonotakashi 0:8fdf9a60065b 1 #!/usr/bin/env python2
kadonotakashi 0:8fdf9a60065b 2 """
kadonotakashi 0:8fdf9a60065b 3 mbed SDK
kadonotakashi 0:8fdf9a60065b 4 Copyright (c) 2011-2015 ARM Limited
kadonotakashi 0:8fdf9a60065b 5
kadonotakashi 0:8fdf9a60065b 6 Licensed under the Apache License, Version 2.0 (the "License");
kadonotakashi 0:8fdf9a60065b 7 you may not use this file except in compliance with the License.
kadonotakashi 0:8fdf9a60065b 8 You may obtain a copy of the License at
kadonotakashi 0:8fdf9a60065b 9
kadonotakashi 0:8fdf9a60065b 10 http://www.apache.org/licenses/LICENSE-2.0
kadonotakashi 0:8fdf9a60065b 11
kadonotakashi 0:8fdf9a60065b 12 Unless required by applicable law or agreed to in writing, software
kadonotakashi 0:8fdf9a60065b 13 distributed under the License is distributed on an "AS IS" BASIS,
kadonotakashi 0:8fdf9a60065b 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kadonotakashi 0:8fdf9a60065b 15 See the License for the specific language governing permissions and
kadonotakashi 0:8fdf9a60065b 16 limitations under the License.
kadonotakashi 0:8fdf9a60065b 17
kadonotakashi 0:8fdf9a60065b 18 Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
kadonotakashi 0:8fdf9a60065b 19
kadonotakashi 0:8fdf9a60065b 20 """
kadonotakashi 0:8fdf9a60065b 21
kadonotakashi 0:8fdf9a60065b 22 import sys
kadonotakashi 0:8fdf9a60065b 23 import mbed_lstools
kadonotakashi 0:8fdf9a60065b 24 from prettytable import PrettyTable
kadonotakashi 0:8fdf9a60065b 25
kadonotakashi 0:8fdf9a60065b 26 try:
kadonotakashi 0:8fdf9a60065b 27 from colorama import init
kadonotakashi 0:8fdf9a60065b 28 except:
kadonotakashi 0:8fdf9a60065b 29 pass
kadonotakashi 0:8fdf9a60065b 30
kadonotakashi 0:8fdf9a60065b 31 COLORAMA = 'colorama' in sys.modules
kadonotakashi 0:8fdf9a60065b 32
kadonotakashi 0:8fdf9a60065b 33 from ioper_base import IOperTestCaseBase
kadonotakashi 0:8fdf9a60065b 34 from ioper_test_fs import IOperTest_FileStructure_Basic
kadonotakashi 0:8fdf9a60065b 35 from ioper_test_fs import IOperTest_FileStructure_MbedEnabled
kadonotakashi 0:8fdf9a60065b 36 from ioper_test_target_id import IOperTest_TargetID_Basic
kadonotakashi 0:8fdf9a60065b 37 from ioper_test_target_id import IOperTest_TargetID_MbedEnabled
kadonotakashi 0:8fdf9a60065b 38
kadonotakashi 0:8fdf9a60065b 39
kadonotakashi 0:8fdf9a60065b 40 TEST_LIST = [IOperTest_TargetID_Basic('basic'),
kadonotakashi 0:8fdf9a60065b 41 IOperTest_TargetID_MbedEnabled('mbed-enabled'),
kadonotakashi 0:8fdf9a60065b 42 IOperTest_FileStructure_Basic('basic'),
kadonotakashi 0:8fdf9a60065b 43 IOperTest_FileStructure_MbedEnabled('mbed-enabled'),
kadonotakashi 0:8fdf9a60065b 44 IOperTestCaseBase('all'), # Dummy used to add 'all' option
kadonotakashi 0:8fdf9a60065b 45 ]
kadonotakashi 0:8fdf9a60065b 46
kadonotakashi 0:8fdf9a60065b 47
kadonotakashi 0:8fdf9a60065b 48 class IOperTestRunner():
kadonotakashi 0:8fdf9a60065b 49 """ Calls all i/face interoperability tests
kadonotakashi 0:8fdf9a60065b 50 """
kadonotakashi 0:8fdf9a60065b 51
kadonotakashi 0:8fdf9a60065b 52 def __init__(self, scope=None):
kadonotakashi 0:8fdf9a60065b 53 """ Test scope:
kadonotakashi 0:8fdf9a60065b 54 'pedantic' - all
kadonotakashi 0:8fdf9a60065b 55 'mbed-enabled' - let's try to check if this device is mbed-enabled
kadonotakashi 0:8fdf9a60065b 56 'basic' - just simple, passive tests (no device flashing)
kadonotakashi 0:8fdf9a60065b 57 """
kadonotakashi 0:8fdf9a60065b 58 self.requested_scope = scope # Test scope given by user
kadonotakashi 0:8fdf9a60065b 59 self.raw_test_results = {} # Raw test results, can be used by exporters: { Platform: [test results]}
kadonotakashi 0:8fdf9a60065b 60
kadonotakashi 0:8fdf9a60065b 61 # Test scope definitions
kadonotakashi 0:8fdf9a60065b 62 self.SCOPE_BASIC = 'basic' # Basic tests, sanity checks
kadonotakashi 0:8fdf9a60065b 63 self.SCOPE_MBED_ENABLED = 'mbed-enabled' # Let's try to check if this device is mbed-enabled
kadonotakashi 0:8fdf9a60065b 64 self.SCOPE_PEDANTIC = 'pedantic' # Extensive tests
kadonotakashi 0:8fdf9a60065b 65 self.SCOPE_ALL = 'all' # All tests, equal to highest scope level
kadonotakashi 0:8fdf9a60065b 66
kadonotakashi 0:8fdf9a60065b 67 # This structure will help us sort test scopes so we can include them
kadonotakashi 0:8fdf9a60065b 68 # e.g. pedantic also includes basic and mbed-enabled tests
kadonotakashi 0:8fdf9a60065b 69 self.scopes = {self.SCOPE_BASIC : 0,
kadonotakashi 0:8fdf9a60065b 70 self.SCOPE_MBED_ENABLED : 1,
kadonotakashi 0:8fdf9a60065b 71 self.SCOPE_PEDANTIC : 2,
kadonotakashi 0:8fdf9a60065b 72 self.SCOPE_ALL : 99,
kadonotakashi 0:8fdf9a60065b 73 }
kadonotakashi 0:8fdf9a60065b 74
kadonotakashi 0:8fdf9a60065b 75 if COLORAMA:
kadonotakashi 0:8fdf9a60065b 76 init() # colorama.init()
kadonotakashi 0:8fdf9a60065b 77
kadonotakashi 0:8fdf9a60065b 78 def run(self):
kadonotakashi 0:8fdf9a60065b 79 """ Run tests, calculate overall score and print test results
kadonotakashi 0:8fdf9a60065b 80 """
kadonotakashi 0:8fdf9a60065b 81 mbeds = mbed_lstools.create()
kadonotakashi 0:8fdf9a60065b 82 muts_list = mbeds.list_mbeds()
kadonotakashi 0:8fdf9a60065b 83 test_base = IOperTestCaseBase()
kadonotakashi 0:8fdf9a60065b 84
kadonotakashi 0:8fdf9a60065b 85 self.raw_test_results = {}
kadonotakashi 0:8fdf9a60065b 86 for i, mut in enumerate(muts_list):
kadonotakashi 0:8fdf9a60065b 87 result = []
kadonotakashi 0:8fdf9a60065b 88 self.raw_test_results[mut['platform_name']] = []
kadonotakashi 0:8fdf9a60065b 89
kadonotakashi 0:8fdf9a60065b 90 print "MBEDLS: Detected %s, port: %s, mounted: %s"% (mut['platform_name'],
kadonotakashi 0:8fdf9a60065b 91 mut['serial_port'],
kadonotakashi 0:8fdf9a60065b 92 mut['mount_point'])
kadonotakashi 0:8fdf9a60065b 93 print "Running interoperability test suite, scope '%s'" % (self.requested_scope)
kadonotakashi 0:8fdf9a60065b 94 for test_case in TEST_LIST:
kadonotakashi 0:8fdf9a60065b 95 if self.scopes[self.requested_scope] >= self.scopes[test_case.scope]:
kadonotakashi 0:8fdf9a60065b 96 res = test_case.test(param=mut)
kadonotakashi 0:8fdf9a60065b 97 result.extend(res)
kadonotakashi 0:8fdf9a60065b 98 self.raw_test_results[mut['platform_name']].extend(res)
kadonotakashi 0:8fdf9a60065b 99
kadonotakashi 0:8fdf9a60065b 100 columns = ['Platform', 'Test Case', 'Result', 'Scope', 'Description']
kadonotakashi 0:8fdf9a60065b 101 pt = PrettyTable(columns)
kadonotakashi 0:8fdf9a60065b 102 for col in columns:
kadonotakashi 0:8fdf9a60065b 103 pt.align[col] = 'l'
kadonotakashi 0:8fdf9a60065b 104
kadonotakashi 0:8fdf9a60065b 105 for tr in result:
kadonotakashi 0:8fdf9a60065b 106 severity, tr_name, tr_scope, text = tr
kadonotakashi 0:8fdf9a60065b 107 tr = (test_base.COLOR(severity, mut['platform_name']),
kadonotakashi 0:8fdf9a60065b 108 test_base.COLOR(severity, tr_name),
kadonotakashi 0:8fdf9a60065b 109 test_base.COLOR(severity, severity),
kadonotakashi 0:8fdf9a60065b 110 test_base.COLOR(severity, tr_scope),
kadonotakashi 0:8fdf9a60065b 111 test_base.COLOR(severity, text))
kadonotakashi 0:8fdf9a60065b 112 pt.add_row(list(tr))
kadonotakashi 0:8fdf9a60065b 113 print pt.get_string(border=True, sortby='Result')
kadonotakashi 0:8fdf9a60065b 114 if i + 1 < len(muts_list):
kadonotakashi 0:8fdf9a60065b 115 print
kadonotakashi 0:8fdf9a60065b 116 return self.raw_test_results
kadonotakashi 0:8fdf9a60065b 117
kadonotakashi 0:8fdf9a60065b 118 def get_available_oper_test_scopes():
kadonotakashi 0:8fdf9a60065b 119 """ Get list of available test scopes
kadonotakashi 0:8fdf9a60065b 120 """
kadonotakashi 0:8fdf9a60065b 121 scopes = set()
kadonotakashi 0:8fdf9a60065b 122 for oper_test in TEST_LIST:
kadonotakashi 0:8fdf9a60065b 123 if oper_test.scope is not None:
kadonotakashi 0:8fdf9a60065b 124 scopes.add(oper_test.scope)
kadonotakashi 0:8fdf9a60065b 125 return list(scopes)