Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers module_reset_silabs.py Source File

module_reset_silabs.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 from __future__ import print_function
00018 
00019 from .host_test_plugins import HostTestPluginBase
00020 
00021 
00022 class HostTestPluginResetMethod_SiLabs(HostTestPluginBase):
00023 
00024     # Plugin interface
00025     name = 'HostTestPluginResetMethod_SiLabs'
00026     type = 'ResetMethod'
00027     stable = True
00028     capabilities = ['eACommander', 'eACommander-usb']
00029     required_parameters = ['disk']
00030 
00031     def setup(self, *args, **kwargs):
00032         """ Configure plugin, this function should be called before plugin execute() method is used.
00033         """
00034         # Note you need to have eACommander.exe on your system path!
00035         self.EACOMMANDER_CMD = 'eACommander.exe'
00036         return True
00037 
00038     def execute(self, capabilitity, *args, **kwargs):
00039         """ Executes capability by name.
00040             Each capability may directly just call some command line
00041             program or execute building pythonic function
00042         """
00043         result = False
00044         if self.check_parameters(capabilitity, *args, **kwargs) is True:
00045             disk = kwargs['disk'].rstrip('/\\')
00046 
00047             if capabilitity == 'eACommander':
00048                 # For this copy method 'disk' will be 'serialno' for eACommander command line parameters
00049                 # Note: Commands are executed in the order they are specified on the command line
00050                 cmd = [self.EACOMMANDER_CMD,
00051                        '--serialno', disk,
00052                        '--resettype', '2', '--reset',]
00053                 result = self.run_command(cmd)
00054             elif capabilitity == 'eACommander-usb':
00055                 # For this copy method 'disk' will be 'usb address' for eACommander command line parameters
00056                 # Note: Commands are executed in the order they are specified on the command line
00057                 cmd = [self.EACOMMANDER_CMD,
00058                        '--usb', disk,
00059                        '--resettype', '2', '--reset',]
00060                 result = self.run_command(cmd)
00061         return result
00062 
00063 
00064 def load_plugin ():
00065     """ Returns plugin available in this module
00066     """
00067     return HostTestPluginResetMethod_SiLabs()