Marco Zecchini
/
Example_RTOS
Rtos API example
Embed:
(wiki syntax)
Show/hide line numbers
module_reset_mbed.py
00001 """ 00002 mbed SDK 00003 Copyright (c) 2011-2013 ARM Limited 00004 00005 Licensed under the Apache License, Version 2.0 (the "License"); 00006 you may not use this file except in compliance with the License. 00007 You may obtain a copy of the License at 00008 00009 http://www.apache.org/licenses/LICENSE-2.0 00010 00011 Unless required by applicable law or agreed to in writing, software 00012 distributed under the License is distributed on an "AS IS" BASIS, 00013 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 See the License for the specific language governing permissions and 00015 limitations under the License. 00016 """ 00017 00018 from host_test_plugins import HostTestPluginBase 00019 00020 00021 class HostTestPluginResetMethod_Mbed(HostTestPluginBase): 00022 00023 def safe_sendBreak(self, serial): 00024 """ Wraps serial.sendBreak() to avoid serial::serialposix.py exception on Linux 00025 Traceback (most recent call last): 00026 File "make.py", line 189, in <module> 00027 serial.sendBreak() 00028 File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 511, in sendBreak 00029 termios.tcsendbreak(self.fd, int(duration/0.25)) 00030 error: (32, 'Broken pipe') 00031 """ 00032 result = True 00033 try: 00034 serial.sendBreak() 00035 except: 00036 # In linux a termios.error is raised in sendBreak and in setBreak. 00037 # The following setBreak() is needed to release the reset signal on the target mcu. 00038 try: 00039 serial.setBreak(False) 00040 except: 00041 result = False 00042 return result 00043 00044 # Plugin interface 00045 name = 'HostTestPluginResetMethod_Mbed' 00046 type = 'ResetMethod' 00047 stable = True 00048 capabilities = ['default'] 00049 required_parameters = ['serial'] 00050 00051 def setup(self, *args, **kwargs): 00052 """ Configure plugin, this function should be called before plugin execute() method is used. 00053 """ 00054 return True 00055 00056 def execute(self, capabilitity, *args, **kwargs): 00057 """ Executes capability by name. 00058 Each capability may directly just call some command line 00059 program or execute building pythonic function 00060 """ 00061 result = False 00062 if self.check_parameters(capabilitity, *args, **kwargs) is True: 00063 if capabilitity == 'default': 00064 serial = kwargs['serial'] 00065 result = self.safe_sendBreak(serial) 00066 return result 00067 00068 00069 def load_plugin (): 00070 """ Returns plugin available in this module 00071 """ 00072 return HostTestPluginResetMethod_Mbed()
Generated on Sun Jul 17 2022 08:25:28 by 1.7.2