summaryrefslogtreecommitdiffstats
path: root/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins')
-rw-r--r--tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/__init__.py68
-rw-r--r--tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/host_test_plugins.py118
-rw-r--r--tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/host_test_registry.py89
-rw-r--r--tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_firefox.py76
-rw-r--r--tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_mbed.py71
-rw-r--r--tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_mps2.py107
-rw-r--r--tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_shell.py64
-rw-r--r--tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_silabs.py61
-rw-r--r--tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_reset_mbed.py72
-rw-r--r--tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_reset_mps2.py74
-rw-r--r--tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_reset_silabs.py66
11 files changed, 866 insertions, 0 deletions
diff --git a/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/__init__.py b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/__init__.py
new file mode 100644
index 000000000..913da0264
--- /dev/null
+++ b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/__init__.py
@@ -0,0 +1,68 @@
+"""
+mbed SDK
+Copyright (c) 2011-2013 ARM Limited
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+import host_test_registry
+
+# This plugins provide 'flashing' methods to host test scripts
+import module_copy_mbed
+import module_copy_shell
+import module_copy_silabs
+#import module_copy_firefox
+#import module_copy_mps2
+
+# Plugins used to reset certain platform
+import module_reset_mbed
+import module_reset_silabs
+#import module_reset_mps2
+
+
+# Plugin registry instance
+HOST_TEST_PLUGIN_REGISTRY = host_test_registry.HostTestRegistry()
+
+# Static plugin registration
+# Some plugins are commented out if they are not stable or not commonly used
+HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_copy_mbed.load_plugin())
+HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_copy_shell.load_plugin())
+HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_reset_mbed.load_plugin())
+#HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_copy_firefox.load_plugin())
+
+# Extra platforms support
+#HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_copy_mps2.load_plugin())
+#HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_reset_mps2.load_plugin())
+HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_copy_silabs.load_plugin())
+HOST_TEST_PLUGIN_REGISTRY.register_plugin(module_reset_silabs.load_plugin())
+
+# TODO: extend plugin loading to files with name module_*.py loaded ad-hoc
+
+###############################################################################
+# Functional interface for host test plugin registry
+###############################################################################
+def call_plugin(type, capability, *args, **kwargs):
+ """ Interface to call plugin registry functional way
+ """
+ return HOST_TEST_PLUGIN_REGISTRY.call_plugin(type, capability, *args, **kwargs)
+
+def get_plugin_caps(type):
+ """ Returns list of all capabilities for plugin family with the same type.
+ If there are no capabilities empty list is returned
+ """
+ return HOST_TEST_PLUGIN_REGISTRY.get_plugin_caps(type)
+
+def print_plugin_info():
+ """ Prints plugins' information in user friendly way
+ """
+ print HOST_TEST_PLUGIN_REGISTRY
diff --git a/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/host_test_plugins.py b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/host_test_plugins.py
new file mode 100644
index 000000000..8bc1da35d
--- /dev/null
+++ b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/host_test_plugins.py
@@ -0,0 +1,118 @@
+"""
+mbed SDK
+Copyright (c) 2011-2013 ARM Limited
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+from os import access, F_OK
+from sys import stdout
+from time import sleep
+from subprocess import call
+
+
+class HostTestPluginBase:
+ """ Base class for all plug-ins used with host tests.
+ """
+ ###########################################################################
+ # Interface:
+ ###########################################################################
+
+ ###########################################################################
+ # Interface attributes defining plugin name, type etc.
+ ###########################################################################
+ name = "HostTestPluginBase" # Plugin name, can be plugin class name
+ type = "BasePlugin" # Plugin type: ResetMethod, Copymethod etc.
+ capabilities = [] # Capabilities names: what plugin can achieve
+ # (e.g. reset using some external command line tool)
+ stable = False # Determine if plugin is stable and can be used
+
+ ###########################################################################
+ # Interface methods
+ ###########################################################################
+ def setup(self, *args, **kwargs):
+ """ Configure plugin, this function should be called before plugin execute() method is used.
+ """
+ return False
+
+ def execute(self, capabilitity, *args, **kwargs):
+ """ Executes capability by name.
+ Each capability e.g. may directly just call some command line
+ program or execute building pythonic function
+ """
+ return False
+
+ ###########################################################################
+ # Interface helper methods - overload only if you need to have custom behaviour
+ ###########################################################################
+ def print_plugin_error(self, text):
+ """ Function prints error in console and exits always with False
+ """
+ print "Plugin error: %s::%s: %s"% (self.name, self.type, text)
+ return False
+
+ def print_plugin_info(self, text, NL=True):
+ """ Function prints notification in console and exits always with True
+ """
+ if NL:
+ print "Plugin info: %s::%s: %s"% (self.name, self.type, text)
+ else:
+ print "Plugin info: %s::%s: %s"% (self.name, self.type, text),
+ return True
+
+ def print_plugin_char(self, char):
+ """ Function prints char on stdout
+ """
+ stdout.write(char)
+ stdout.flush()
+ return True
+
+ def check_mount_point_ready(self, destination_disk, init_delay=0.2, loop_delay=0.25):
+ """ Checks if destination_disk is ready and can be accessed by e.g. copy commands
+ @init_delay - Initial delay time before first access check
+ @loop_delay - pooling delay for access check
+ """
+ if not access(destination_disk, F_OK):
+ self.print_plugin_info("Waiting for mount point '%s' to be ready..."% destination_disk, NL=False)
+ sleep(init_delay)
+ while not access(destination_disk, F_OK):
+ sleep(loop_delay)
+ self.print_plugin_char('.')
+
+ def check_parameters(self, capabilitity, *args, **kwargs):
+ """ This function should be ran each time we call execute()
+ to check if none of the required parameters is missing.
+ """
+ missing_parameters = []
+ for parameter in self.required_parameters:
+ if parameter not in kwargs:
+ missing_parameters.append(parameter)
+ if len(missing_parameters) > 0:
+ self.print_plugin_error("execute parameter(s) '%s' missing!"% (', '.join(parameter)))
+ return False
+ return True
+
+ def run_command(self, cmd, shell=True):
+ """ Runs command from command line.
+ """
+ result = True
+ try:
+ ret = call(cmd, shell=shell)
+ if ret:
+ self.print_plugin_error("[ret=%d] Command: %s"% (int(ret), cmd))
+ return False
+ except Exception as e:
+ result = False
+ self.print_plugin_error("[ret=%d] Command: %s"% (int(ret), cmd))
+ self.print_plugin_error(str(e))
+ return result
diff --git a/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/host_test_registry.py b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/host_test_registry.py
new file mode 100644
index 000000000..5237b9a25
--- /dev/null
+++ b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/host_test_registry.py
@@ -0,0 +1,89 @@
+"""
+mbed SDK
+Copyright (c) 2011-2013 ARM Limited
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+class HostTestRegistry:
+ """ Simple class used to register and store
+ host test plugins for further usage
+ """
+ # Here we actually store all the plugins
+ PLUGINS = {} # 'Plugin Name' : Plugin Object
+
+ def print_error(self, text):
+ print "Plugin load failed. Reason: %s"% text
+
+ def register_plugin(self, plugin):
+ """ Registers and stores plugin inside registry for further use.
+ Method also calls plugin's setup() function to configure plugin if needed.
+
+ Note: Different groups of plugins may demand different extra parameter. Plugins
+ should be at least for one type of plugin configured with the same parameters
+ because we do not know which of them will actually use particular parameter.
+ """
+ # TODO:
+ # - check for unique caps for specified type
+ if plugin.name not in self.PLUGINS:
+ if plugin.setup(): # Setup plugin can be completed without errors
+ self.PLUGINS[plugin.name] = plugin
+ return True
+ else:
+ self.print_error("%s setup failed"% plugin.name)
+ else:
+ self.print_error("%s already loaded"% plugin.name)
+ return False
+
+ def call_plugin(self, type, capability, *args, **kwargs):
+ """ Execute plugin functionality respectively to its purpose
+ """
+ for plugin_name in self.PLUGINS:
+ plugin = self.PLUGINS[plugin_name]
+ if plugin.type == type and capability in plugin.capabilities:
+ return plugin.execute(capability, *args, **kwargs)
+ return False
+
+ def get_plugin_caps(self, type):
+ """ Returns list of all capabilities for plugin family with the same type.
+ If there are no capabilities empty list is returned
+ """
+ result = []
+ for plugin_name in self.PLUGINS:
+ plugin = self.PLUGINS[plugin_name]
+ if plugin.type == type:
+ result.extend(plugin.capabilities)
+ return sorted(result)
+
+ def load_plugin(self, name):
+ """ Used to load module from
+ """
+ mod = __import__("module_%s"% name)
+ return mod
+
+ def __str__(self):
+ """ User friendly printing method to show hooked plugins
+ """
+ from prettytable import PrettyTable
+ column_names = ['name', 'type', 'capabilities', 'stable']
+ pt = PrettyTable(column_names)
+ for column in column_names:
+ pt.align[column] = 'l'
+ for plugin_name in sorted(self.PLUGINS.keys()):
+ name = self.PLUGINS[plugin_name].name
+ type = self.PLUGINS[plugin_name].type
+ stable = self.PLUGINS[plugin_name].stable
+ capabilities = ', '.join(self.PLUGINS[plugin_name].capabilities)
+ row = [name, type, capabilities, stable]
+ pt.add_row(row)
+ return pt.get_string()
diff --git a/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_firefox.py b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_firefox.py
new file mode 100644
index 000000000..360835e49
--- /dev/null
+++ b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_firefox.py
@@ -0,0 +1,76 @@
+"""
+mbed SDK
+Copyright (c) 2011-2013 ARM Limited
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+from os.path import join, basename
+from host_test_plugins import HostTestPluginBase
+
+
+class HostTestPluginCopyMethod_Firefox(HostTestPluginBase):
+
+ def file_store_firefox(self, file_path, dest_disk):
+ try:
+ from selenium import webdriver
+ profile = webdriver.FirefoxProfile()
+ profile.set_preference('browser.download.folderList', 2) # custom location
+ profile.set_preference('browser.download.manager.showWhenStarting', False)
+ profile.set_preference('browser.download.dir', dest_disk)
+ profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'application/octet-stream')
+ # Launch browser with profile and get file
+ browser = webdriver.Firefox(profile)
+ browser.get(file_path)
+ browser.close()
+ except:
+ return False
+ return True
+
+ # Plugin interface
+ name = 'HostTestPluginCopyMethod_Firefox'
+ type = 'CopyMethod'
+ capabilities = ['firefox']
+ required_parameters = ['image_path', 'destination_disk']
+
+ def setup(self, *args, **kwargs):
+ """ Configure plugin, this function should be called before plugin execute() method is used.
+ """
+ try:
+ from selenium import webdriver
+ except ImportError, e:
+ self.print_plugin_error("Error: firefox copy method requires selenium library. %s"% e)
+ return False
+ return True
+
+ def execute(self, capabilitity, *args, **kwargs):
+ """ Executes capability by name.
+ Each capability may directly just call some command line
+ program or execute building pythonic function
+ """
+ result = False
+ if self.check_parameters(capabilitity, *args, **kwargs) is True:
+ image_path = kwargs['image_path']
+ destination_disk = kwargs['destination_disk']
+ # Prepare correct command line parameter values
+ image_base_name = basename(image_path)
+ destination_path = join(destination_disk, image_base_name)
+ if capabilitity == 'firefox':
+ self.file_store_firefox(image_path, destination_path)
+ return result
+
+
+def load_plugin():
+ """ Returns plugin available in this module
+ """
+ return HostTestPluginCopyMethod_Firefox()
diff --git a/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_mbed.py b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_mbed.py
new file mode 100644
index 000000000..18fe0c42a
--- /dev/null
+++ b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_mbed.py
@@ -0,0 +1,71 @@
+"""
+mbed SDK
+Copyright (c) 2011-2013 ARM Limited
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+from shutil import copy
+from host_test_plugins import HostTestPluginBase
+
+
+class HostTestPluginCopyMethod_Mbed(HostTestPluginBase):
+
+ def generic_mbed_copy(self, image_path, destination_disk):
+ """ Generic mbed copy method for "mbed enabled" devices.
+ It uses standard python shuitl function to copy
+ image_file (target specific binary) to device's disk.
+ """
+ result = True
+ if not destination_disk.endswith('/') and not destination_disk.endswith('\\'):
+ destination_disk += '/'
+ try:
+ copy(image_path, destination_disk)
+ except Exception, e:
+ self.print_plugin_error("shutil.copy('%s', '%s')"% (image_path, destination_disk))
+ self.print_plugin_error("Error: %s"% str(e))
+ result = False
+ return result
+
+ # Plugin interface
+ name = 'HostTestPluginCopyMethod_Mbed'
+ type = 'CopyMethod'
+ stable = True
+ capabilities = ['default']
+ required_parameters = ['image_path', 'destination_disk']
+
+ def setup(self, *args, **kwargs):
+ """ Configure plugin, this function should be called before plugin execute() method is used.
+ """
+ return True
+
+ def execute(self, capabilitity, *args, **kwargs):
+ """ Executes capability by name.
+ Each capability may directly just call some command line
+ program or execute building pythonic function
+ """
+ result = False
+ if self.check_parameters(capabilitity, *args, **kwargs) is True:
+ if capabilitity == 'default':
+ image_path = kwargs['image_path']
+ destination_disk = kwargs['destination_disk']
+ # Wait for mount point to be ready
+ self.check_mount_point_ready(destination_disk) # Blocking
+ result = self.generic_mbed_copy(image_path, destination_disk)
+ return result
+
+
+def load_plugin():
+ """ Returns plugin available in this module
+ """
+ return HostTestPluginCopyMethod_Mbed()
diff --git a/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_mps2.py b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_mps2.py
new file mode 100644
index 000000000..f7768873f
--- /dev/null
+++ b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_mps2.py
@@ -0,0 +1,107 @@
+"""
+mbed SDK
+Copyright (c) 2011-2013 ARM Limited
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+import re
+from os.path import join
+from host_test_plugins import HostTestPluginBase
+
+
+class HostTestPluginCopyMethod_MPS2(HostTestPluginBase):
+
+ # MPS2 specific flashing / binary setup funcitons
+ def mps2_set_board_image_file(self, disk, images_cfg_path, image0file_path, image_name='images.txt'):
+ """ This function will alter image cfg file.
+ Main goal of this function is to change number of images to 1, comment all
+ existing image entries and append at the end of file new entry with test path.
+ @return True when all steps succeed.
+ """
+ MBED_SDK_TEST_STAMP = 'test suite entry'
+ image_path = join(disk, images_cfg_path, image_name)
+ new_file_lines = [] # New configuration file lines (entries)
+
+ # Check each line of the image configuration file
+ try:
+ with open(image_path, 'r') as file:
+ for line in file:
+ if re.search('^TOTALIMAGES', line):
+ # Check number of total images, should be 1
+ new_file_lines.append(re.sub('^TOTALIMAGES:[\t ]*[\d]+', 'TOTALIMAGES: 1', line))
+ elif re.search('; - %s[\n\r]*$'% MBED_SDK_TEST_STAMP, line):
+ # Look for test suite entries and remove them
+ pass # Omit all test suite entries
+ elif re.search('^IMAGE[\d]+FILE', line):
+ # Check all image entries and mark the ';'
+ new_file_lines.append(';' + line) # Comment non test suite lines
+ else:
+ # Append line to new file
+ new_file_lines.append(line)
+ except IOError as e:
+ return False
+
+ # Add new image entry with proper commented stamp
+ new_file_lines.append('IMAGE0FILE: %s ; - %s\r\n'% (image0file_path, MBED_SDK_TEST_STAMP))
+
+ # Write all lines to file
+ try:
+ with open(image_path, 'w') as file:
+ for line in new_file_lines:
+ file.write(line),
+ except IOError:
+ return False
+
+ return True
+
+ def mps2_select_core(self, disk, mobo_config_name=""):
+ """ Function selects actual core
+ """
+ # TODO: implement core selection
+ pass
+
+ def mps2_switch_usb_auto_mounting_after_restart(self, disk, usb_config_name=""):
+ """ Function alters configuration to allow USB MSD to be mounted after restarts
+ """
+ # TODO: implement USB MSD restart detection
+ pass
+
+ # Plugin interface
+ name = 'HostTestPluginCopyMethod_MPS2'
+ type = 'CopyMethod'
+ capabilities = ['mps2']
+ required_parameters = ['image_path', 'destination_disk']
+
+ def setup(self, *args, **kwargs):
+ """ Configure plugin, this function should be called before plugin execute() method is used.
+ """
+ return True
+
+ def execute(self, capabilitity, *args, **kwargs):
+ """ Executes capability by name.
+ Each capability may directly just call some command line
+ program or execute building pythonic function
+ """
+ result = False
+ if self.check_parameters(capabilitity, *args, **kwargs) is True:
+ if capabilitity == 'mps2':
+ # TODO: Implement MPS2 firmware setup here
+ pass
+ return result
+
+
+def load_plugin():
+ """ Returns plugin available in this module
+ """
+ return HostTestPluginCopyMethod_MPS2()
diff --git a/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_shell.py b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_shell.py
new file mode 100644
index 000000000..f7fb23b0a
--- /dev/null
+++ b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_shell.py
@@ -0,0 +1,64 @@
+"""
+mbed SDK
+Copyright (c) 2011-2013 ARM Limited
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+import os
+from os.path import join, basename
+from host_test_plugins import HostTestPluginBase
+
+
+class HostTestPluginCopyMethod_Shell(HostTestPluginBase):
+
+ # Plugin interface
+ name = 'HostTestPluginCopyMethod_Shell'
+ type = 'CopyMethod'
+ stable = True
+ capabilities = ['shell', 'cp', 'copy', 'xcopy']
+ required_parameters = ['image_path', 'destination_disk']
+
+ def setup(self, *args, **kwargs):
+ """ Configure plugin, this function should be called before plugin execute() method is used.
+ """
+ return True
+
+ def execute(self, capabilitity, *args, **kwargs):
+ """ Executes capability by name.
+ Each capability may directly just call some command line
+ program or execute building pythonic function
+ """
+ result = False
+ if self.check_parameters(capabilitity, *args, **kwargs) is True:
+ image_path = kwargs['image_path']
+ destination_disk = kwargs['destination_disk']
+ # Wait for mount point to be ready
+ self.check_mount_point_ready(destination_disk) # Blocking
+ # Prepare correct command line parameter values
+ image_base_name = basename(image_path)
+ destination_path = join(destination_disk, image_base_name)
+ if capabilitity == 'shell':
+ if os.name == 'nt': capabilitity = 'copy'
+ elif os.name == 'posix': capabilitity = 'cp'
+ if capabilitity == 'cp' or capabilitity == 'copy' or capabilitity == 'copy':
+ copy_method = capabilitity
+ cmd = [copy_method, image_path, destination_path]
+ result = self.run_command(cmd)
+ return result
+
+
+def load_plugin():
+ """ Returns plugin available in this module
+ """
+ return HostTestPluginCopyMethod_Shell()
diff --git a/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_silabs.py b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_silabs.py
new file mode 100644
index 000000000..1572bbc6e
--- /dev/null
+++ b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_silabs.py
@@ -0,0 +1,61 @@
+"""
+mbed SDK
+Copyright (c) 2011-2013 ARM Limited
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+from host_test_plugins import HostTestPluginBase
+
+
+class HostTestPluginCopyMethod_Silabs(HostTestPluginBase):
+
+ # Plugin interface
+ name = 'HostTestPluginCopyMethod_Silabs'
+ type = 'CopyMethod'
+ capabilities = ['eACommander', 'eACommander-usb']
+ required_parameters = ['image_path', 'destination_disk']
+
+ def setup(self, *args, **kwargs):
+ """ Configure plugin, this function should be called before plugin execute() method is used.
+ """
+ self.EACOMMANDER_CMD = 'eACommander.exe'
+ return True
+
+ def execute(self, capabilitity, *args, **kwargs):
+ """ Executes capability by name.
+ Each capability may directly just call some command line
+ program or execute building pythonic function
+ """
+ result = False
+ if self.check_parameters(capabilitity, *args, **kwargs) is True:
+ image_path = kwargs['image_path']
+ destination_disk = kwargs['destination_disk']
+ if capabilitity == 'eACommander':
+ cmd = [self.EACOMMANDER_CMD,
+ '--serialno', destination_disk,
+ '--flash', image_path,
+ '--resettype', '2', '--reset']
+ result = self.run_command(cmd)
+ elif capabilitity == 'eACommander-usb':
+ cmd = [self.EACOMMANDER_CMD,
+ '--usb', destination_disk,
+ '--flash', image_path]
+ result = self.run_command(cmd)
+ return result
+
+
+def load_plugin():
+ """ Returns plugin available in this module
+ """
+ return HostTestPluginCopyMethod_Silabs()
diff --git a/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_reset_mbed.py b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_reset_mbed.py
new file mode 100644
index 000000000..0390d84ba
--- /dev/null
+++ b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_reset_mbed.py
@@ -0,0 +1,72 @@
+"""
+mbed SDK
+Copyright (c) 2011-2013 ARM Limited
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+from host_test_plugins import HostTestPluginBase
+
+
+class HostTestPluginResetMethod_Mbed(HostTestPluginBase):
+
+ def safe_sendBreak(self, serial):
+ """ Wraps serial.sendBreak() to avoid serial::serialposix.py exception on Linux
+ Traceback (most recent call last):
+ File "make.py", line 189, in <module>
+ serial.sendBreak()
+ File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 511, in sendBreak
+ termios.tcsendbreak(self.fd, int(duration/0.25))
+ error: (32, 'Broken pipe')
+ """
+ result = True
+ try:
+ serial.sendBreak()
+ except:
+ # In linux a termios.error is raised in sendBreak and in setBreak.
+ # The following setBreak() is needed to release the reset signal on the target mcu.
+ try:
+ serial.setBreak(False)
+ except:
+ result = False
+ return result
+
+ # Plugin interface
+ name = 'HostTestPluginResetMethod_Mbed'
+ type = 'ResetMethod'
+ stable = True
+ capabilities = ['default']
+ required_parameters = ['serial']
+
+ def setup(self, *args, **kwargs):
+ """ Configure plugin, this function should be called before plugin execute() method is used.
+ """
+ return True
+
+ def execute(self, capabilitity, *args, **kwargs):
+ """ Executes capability by name.
+ Each capability may directly just call some command line
+ program or execute building pythonic function
+ """
+ result = False
+ if self.check_parameters(capabilitity, *args, **kwargs) is True:
+ if capabilitity == 'default':
+ serial = kwargs['serial']
+ result = self.safe_sendBreak(serial)
+ return result
+
+
+def load_plugin():
+ """ Returns plugin available in this module
+ """
+ return HostTestPluginResetMethod_Mbed()
diff --git a/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_reset_mps2.py b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_reset_mps2.py
new file mode 100644
index 000000000..22938090b
--- /dev/null
+++ b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_reset_mps2.py
@@ -0,0 +1,74 @@
+"""
+mbed SDK
+Copyright (c) 2011-2013 ARM Limited
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+import os
+from host_test_plugins import HostTestPluginBase
+
+# Note: This plugin is not fully functional, needs improvements
+
+class HostTestPluginResetMethod_MPS2(HostTestPluginBase):
+ """ Plugin used to reset ARM_MPS2 platform
+ Supports:
+ reboot.txt - startup from standby state, reboots when in run mode.
+ shutdown.txt - shutdown from run mode.
+ reset.txt - reset FPGA during run mode.
+ """
+ def touch_file(self, path):
+ """ Touch file and set timestamp to items
+ """
+ with open(path, 'a'):
+ os.utime(path, None)
+
+ # Plugin interface
+ name = 'HostTestPluginResetMethod_MPS2'
+ type = 'ResetMethod'
+ capabilities = ['reboot.txt', 'shutdown.txt', 'reset.txt']
+ required_parameters = ['disk']
+
+ def setup(self, *args, **kwargs):
+ """ Prepare / configure plugin to work.
+ This method can receive plugin specific parameters by kwargs and
+ ignore other parameters which may affect other plugins.
+ """
+ return True
+
+ def execute(self, capabilitity, *args, **kwargs):
+ """ Executes capability by name.
+ Each capability may directly just call some command line
+ program or execute building pythonic function
+ """
+ result = False
+ if self.check_parameters(capabilitity, *args, **kwargs) is True:
+
+ if capabilitity == 'reboot.txt':
+ # TODO: Implement touch file for reboot
+ pass
+
+ elif capabilitity == 'shutdown.txt':
+ # TODO: Implement touch file for shutdown
+ pass
+
+ elif capabilitity == 'reset.txt':
+ # TODO: Implement touch file for reset
+ pass
+
+ return result
+
+def load_plugin():
+ """ Returns plugin available in this module
+ """
+ return HostTestPluginResetMethod_MPS2()
diff --git a/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_reset_silabs.py b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_reset_silabs.py
new file mode 100644
index 000000000..2c05cb21c
--- /dev/null
+++ b/tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_reset_silabs.py
@@ -0,0 +1,66 @@
+"""
+mbed SDK
+Copyright (c) 2011-2013 ARM Limited
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+from host_test_plugins import HostTestPluginBase
+
+
+class HostTestPluginResetMethod_SiLabs(HostTestPluginBase):
+
+ # Plugin interface
+ name = 'HostTestPluginResetMethod_SiLabs'
+ type = 'ResetMethod'
+ stable = True
+ capabilities = ['eACommander', 'eACommander-usb']
+ required_parameters = ['disk']
+
+ def setup(self, *args, **kwargs):
+ """ Configure plugin, this function should be called before plugin execute() method is used.
+ """
+ # Note you need to have eACommander.exe on your system path!
+ self.EACOMMANDER_CMD = 'eACommander.exe'
+ return True
+
+ def execute(self, capabilitity, *args, **kwargs):
+ """ Executes capability by name.
+ Each capability may directly just call some command line
+ program or execute building pythonic function
+ """
+ result = False
+ if self.check_parameters(capabilitity, *args, **kwargs) is True:
+ disk = kwargs['disk'].rstrip('/\\')
+
+ if capabilitity == 'eACommander':
+ # For this copy method 'disk' will be 'serialno' for eACommander command line parameters
+ # Note: Commands are executed in the order they are specified on the command line
+ cmd = [self.EACOMMANDER_CMD,
+ '--serialno', disk,
+ '--resettype', '2', '--reset',]
+ result = self.run_command(cmd)
+ elif capabilitity == 'eACommander-usb':
+ # For this copy method 'disk' will be 'usb address' for eACommander command line parameters
+ # Note: Commands are executed in the order they are specified on the command line
+ cmd = [self.EACOMMANDER_CMD,
+ '--usb', disk,
+ '--resettype', '2', '--reset',]
+ result = self.run_command(cmd)
+ return result
+
+
+def load_plugin():
+ """ Returns plugin available in this module
+ """
+ return HostTestPluginResetMethod_SiLabs()