3 Copyright (c) 2011-2015 ARM Limited 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 9 http://www.apache.org/licenses/LICENSE-2.0 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. 17 Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com> 22 from .host_test_plugins
import HostTestPluginBase
28 name =
'HostTestPluginResetMethod_Mbed' 31 capabilities = [
'default']
32 required_parameters = [
'serial']
36 @details We can check module version by referring to version attribute 38 print pkg_resources.require("mbed-host-tests")[0].version 41 HostTestPluginBase.__init__(self)
43 pyserial_version = pkg_resources.require(
"pyserial")[0].version
48 """! Retrieve pyserial module version 49 @return Returns float with pyserial module number 52 m = self.
re_float.search(pyserial_version)
55 version = float(m.group(0))
61 """! Closure for pyserial version dependant API calls 67 def _safe_sendBreak_v2_7(self, serial):
68 """! pyserial 2.7 API implementation of sendBreak/setBreak 70 Below API is deprecated for pyserial 3.x versions! 71 http://pyserial.readthedocs.org/en/latest/pyserial_api.html#serial.Serial.sendBreak 72 http://pyserial.readthedocs.org/en/latest/pyserial_api.html#serial.Serial.setBreak 81 serial.setBreak(
False)
86 def _safe_sendBreak_v3_0(self, serial):
87 """! pyserial 3.x API implementation of send_brea / break_condition 89 http://pyserial.readthedocs.org/en/latest/pyserial_api.html#serial.Serial.send_break 90 http://pyserial.readthedocs.org/en/latest/pyserial_api.html#serial.Serial.break_condition 99 serial.break_condition =
False 100 except Exception
as e:
101 self.
print_plugin_error(
"Error while doing 'serial.break_condition = False' : %s"% str(e))
106 """! Configure plugin, this function should be called before plugin execute() method is used. 110 def execute(self, capability, *args, **kwargs):
111 """! Executes capability by name 113 @param capability Capability name 114 @param args Additional arguments 115 @param kwargs Additional arguments 116 @details Each capability e.g. may directly just call some command line program or execute building pythonic function 117 @return Capability call return value 119 if not kwargs[
'serial']:
126 if capability ==
'default':
127 serial = kwargs[
'serial']
133 """! Returns plugin available in this module Base class for all plugins used with host tests.
def execute(self, capability, args, kwargs)
Executes capability by name.
def setup(self, args, kwargs)
Configure plugin, this function should be called before plugin execute() method is used...
def _safe_sendBreak_v3_0(self, serial)
pyserial 3.x API implementation of send_brea / break_condition
def check_parameters(self, capability, args, kwargs)
This function should be ran each time we call execute() to check if none of the required parameters i...
def load_plugin()
Returns plugin available in this module.
def get_pyserial_version(self, pyserial_version)
Retrieve pyserial module version.
def _safe_sendBreak_v2_7(self, serial)
pyserial 2.7 API implementation of sendBreak/setBreak
def safe_sendBreak(self, serial)
Closure for pyserial version dependant API calls.
def print_plugin_error(self, text)
Interface helper methods - overload only if you need to have custom behaviour.