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_mbed.py 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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_Mbed(HostTestPluginBase):
  16. def safe_sendBreak(self, serial):
  17. """ Wraps serial.sendBreak() to avoid serial::serialposix.py exception on Linux
  18. Traceback (most recent call last):
  19. File "make.py", line 189, in <module>
  20. serial.sendBreak()
  21. File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 511, in sendBreak
  22. termios.tcsendbreak(self.fd, int(duration/0.25))
  23. error: (32, 'Broken pipe')
  24. """
  25. result = True
  26. try:
  27. serial.sendBreak()
  28. except:
  29. # In linux a termios.error is raised in sendBreak and in setBreak.
  30. # The following setBreak() is needed to release the reset signal on the target mcu.
  31. try:
  32. serial.setBreak(False)
  33. except:
  34. result = False
  35. return result
  36. # Plugin interface
  37. name = 'HostTestPluginResetMethod_Mbed'
  38. type = 'ResetMethod'
  39. stable = True
  40. capabilities = ['default']
  41. required_parameters = ['serial']
  42. def setup(self, *args, **kwargs):
  43. """ Configure plugin, this function should be called before plugin execute() method is used.
  44. """
  45. return True
  46. def execute(self, capabilitity, *args, **kwargs):
  47. """ Executes capability by name.
  48. Each capability may directly just call some command line
  49. program or execute building pythonic function
  50. """
  51. result = False
  52. if self.check_parameters(capabilitity, *args, **kwargs) is True:
  53. if capabilitity == 'default':
  54. serial = kwargs['serial']
  55. result = self.safe_sendBreak(serial)
  56. return result
  57. def load_plugin():
  58. """ Returns plugin available in this module
  59. """
  60. return HostTestPluginResetMethod_Mbed()