You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

module_reset_silabs.py 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. """
  2. mbed SDK
  3. Copyright (c) 2011-2013 ARM Limited
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. """
  14. from host_test_plugins import HostTestPluginBase
  15. class HostTestPluginResetMethod_SiLabs(HostTestPluginBase):
  16. # Plugin interface
  17. name = 'HostTestPluginResetMethod_SiLabs'
  18. type = 'ResetMethod'
  19. stable = True
  20. capabilities = ['eACommander', 'eACommander-usb']
  21. required_parameters = ['disk']
  22. def setup(self, *args, **kwargs):
  23. """ Configure plugin, this function should be called before plugin execute() method is used.
  24. """
  25. # Note you need to have eACommander.exe on your system path!
  26. self.EACOMMANDER_CMD = 'eACommander.exe'
  27. return True
  28. def execute(self, capabilitity, *args, **kwargs):
  29. """ Executes capability by name.
  30. Each capability may directly just call some command line
  31. program or execute building pythonic function
  32. """
  33. result = False
  34. if self.check_parameters(capabilitity, *args, **kwargs) is True:
  35. disk = kwargs['disk'].rstrip('/\\')
  36. if capabilitity == 'eACommander':
  37. # For this copy method 'disk' will be 'serialno' for eACommander command line parameters
  38. # Note: Commands are executed in the order they are specified on the command line
  39. cmd = [self.EACOMMANDER_CMD,
  40. '--serialno', disk,
  41. '--resettype', '2', '--reset',]
  42. result = self.run_command(cmd)
  43. elif capabilitity == 'eACommander-usb':
  44. # For this copy method 'disk' will be 'usb address' for eACommander command line parameters
  45. # Note: Commands are executed in the order they are specified on the command line
  46. cmd = [self.EACOMMANDER_CMD,
  47. '--usb', disk,
  48. '--resettype', '2', '--reset',]
  49. result = self.run_command(cmd)
  50. return result
  51. def load_plugin():
  52. """ Returns plugin available in this module
  53. """
  54. return HostTestPluginResetMethod_SiLabs()