]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_reset_mbed.py
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / workspace_tools / host_tests / host_tests_plugins / module_reset_mbed.py
1 """
2 mbed SDK
3 Copyright (c) 2011-2013 ARM Limited
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 """
17
18 from host_test_plugins import HostTestPluginBase
19
20
21 class HostTestPluginResetMethod_Mbed(HostTestPluginBase):
22
23 def safe_sendBreak(self, serial):
24 """ Wraps serial.sendBreak() to avoid serial::serialposix.py exception on Linux
25 Traceback (most recent call last):
26 File "make.py", line 189, in <module>
27 serial.sendBreak()
28 File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 511, in sendBreak
29 termios.tcsendbreak(self.fd, int(duration/0.25))
30 error: (32, 'Broken pipe')
31 """
32 result = True
33 try:
34 serial.sendBreak()
35 except:
36 # In linux a termios.error is raised in sendBreak and in setBreak.
37 # The following setBreak() is needed to release the reset signal on the target mcu.
38 try:
39 serial.setBreak(False)
40 except:
41 result = False
42 return result
43
44 # Plugin interface
45 name = 'HostTestPluginResetMethod_Mbed'
46 type = 'ResetMethod'
47 stable = True
48 capabilities = ['default']
49 required_parameters = ['serial']
50
51 def setup(self, *args, **kwargs):
52 """ Configure plugin, this function should be called before plugin execute() method is used.
53 """
54 return True
55
56 def execute(self, capabilitity, *args, **kwargs):
57 """ Executes capability by name.
58 Each capability may directly just call some command line
59 program or execute building pythonic function
60 """
61 result = False
62 if self.check_parameters(capabilitity, *args, **kwargs) is True:
63 if capabilitity == 'default':
64 serial = kwargs['serial']
65 result = self.safe_sendBreak(serial)
66 return result
67
68
69 def load_plugin():
70 """ Returns plugin available in this module
71 """
72 return HostTestPluginResetMethod_Mbed()
Imprint / Impressum