Keyboard firmwares for Atmel AVR and Cortex-M
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

echo_flow_control.py 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 import Test
  15. class EchoTest(Test):
  16. def __init__(self):
  17. Test.__init__(self)
  18. self.mbed.init_serial()
  19. self.mbed.extra_serial.rtscts = True
  20. self.mbed.reset()
  21. def test(self):
  22. self.mbed.flush()
  23. self.notify("Starting the ECHO test")
  24. TEST="longer serial test"
  25. check = True
  26. for i in range(1, 100):
  27. self.mbed.extra_serial.write(TEST + "\n")
  28. l = self.mbed.extra_serial.readline().strip()
  29. if not l: continue
  30. if l != TEST:
  31. check = False
  32. self.notify('"%s" != "%s"' % (l, TEST))
  33. else:
  34. if (i % 10) == 0:
  35. self.notify('.')
  36. return check
  37. if __name__ == '__main__':
  38. EchoTest().run()