Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
Это архивный репозиторий. Вы можете его клонировать или просматривать файлы, но не вносить изменения или открывать задачи/запросы на слияние.

detect_auto.py 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. import re
  15. class DetectPlatformTest():
  16. PATTERN_MICRO_NAME = "Target '(\w+)'"
  17. re_detect_micro_name = re.compile(PATTERN_MICRO_NAME)
  18. def test(self, selftest):
  19. result = True
  20. c = selftest.mbed.serial_readline() # {{start}} preamble
  21. if c is None:
  22. return selftest.RESULT_IO_SERIAL
  23. selftest.notify(c.strip())
  24. selftest.notify("HOST: Detecting target name...")
  25. c = selftest.mbed.serial_readline()
  26. if c is None:
  27. return selftest.RESULT_IO_SERIAL
  28. selftest.notify(c.strip())
  29. # Check for target name
  30. m = self.re_detect_micro_name.search(c)
  31. if m and len(m.groups()):
  32. micro_name = m.groups()[0]
  33. micro_cmp = selftest.mbed.options.micro == micro_name
  34. result = result and micro_cmp
  35. selftest.notify("HOST: MUT Target name '%s', expected '%s'... [%s]"% (micro_name,
  36. selftest.mbed.options.micro,
  37. "OK" if micro_cmp else "FAIL"))
  38. for i in range(0, 2):
  39. c = selftest.mbed.serial_readline()
  40. if c is None:
  41. return selftest.RESULT_IO_SERIAL
  42. selftest.notify(c.strip())
  43. return selftest.RESULT_SUCCESS if result else selftest.RESULT_FAILURE