Keyboard firmwares for Atmel AVR and Cortex-M
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.

dev_null_auto.py 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. class DevNullTest():
  15. def check_readline(self, selftest, text):
  16. """ Reads line from serial port and checks if text was part of read string
  17. """
  18. result = False
  19. c = selftest.mbed.serial_readline()
  20. if c and text in c:
  21. result = True
  22. return result
  23. def test(self, selftest):
  24. result = True
  25. # Test should print some text and later stop printing
  26. # 'MBED: re-routing stdout to /null'
  27. res = self.check_readline(selftest, "re-routing stdout to /null")
  28. if not res:
  29. # We haven't read preamble line
  30. result = False
  31. else:
  32. # Check if there are printed characters
  33. str = ''
  34. for i in range(3):
  35. c = selftest.mbed.serial_read(32)
  36. if c is None:
  37. return selftest.RESULT_IO_SERIAL
  38. else:
  39. str += c
  40. if len(str) > 0:
  41. result = False
  42. break
  43. selftest.notify("Received %d bytes: %s"% (len(str), str))
  44. return selftest.RESULT_SUCCESS if result else selftest.RESULT_FAILURE