mbed-os for GR-LYCHEE
Dependents: mbed-os-example-blinky-gr-lychee GR-Boads_Camera_sample GR-Boards_Audio_Recoder GR-Boads_Camera_DisplayApp ... more
tools/host_tests/serial_nc_tx_auto.py@0:f782d9c66c49, 2018-02-02 (annotated)
- Committer:
- dkato
- Date:
- Fri Feb 02 05:42:23 2018 +0000
- Revision:
- 0:f782d9c66c49
mbed-os for GR-LYCHEE
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dkato | 0:f782d9c66c49 | 1 | """ |
dkato | 0:f782d9c66c49 | 2 | mbed SDK |
dkato | 0:f782d9c66c49 | 3 | Copyright (c) 2011-2013 ARM Limited |
dkato | 0:f782d9c66c49 | 4 | |
dkato | 0:f782d9c66c49 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
dkato | 0:f782d9c66c49 | 6 | you may not use this file except in compliance with the License. |
dkato | 0:f782d9c66c49 | 7 | You may obtain a copy of the License at |
dkato | 0:f782d9c66c49 | 8 | |
dkato | 0:f782d9c66c49 | 9 | http://www.apache.org/licenses/LICENSE-2.0 |
dkato | 0:f782d9c66c49 | 10 | |
dkato | 0:f782d9c66c49 | 11 | Unless required by applicable law or agreed to in writing, software |
dkato | 0:f782d9c66c49 | 12 | distributed under the License is distributed on an "AS IS" BASIS, |
dkato | 0:f782d9c66c49 | 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
dkato | 0:f782d9c66c49 | 14 | See the License for the specific language governing permissions and |
dkato | 0:f782d9c66c49 | 15 | limitations under the License. |
dkato | 0:f782d9c66c49 | 16 | """ |
dkato | 0:f782d9c66c49 | 17 | |
dkato | 0:f782d9c66c49 | 18 | import sys |
dkato | 0:f782d9c66c49 | 19 | import uuid |
dkato | 0:f782d9c66c49 | 20 | import time |
dkato | 0:f782d9c66c49 | 21 | import string |
dkato | 0:f782d9c66c49 | 22 | from sys import stdout |
dkato | 0:f782d9c66c49 | 23 | |
dkato | 0:f782d9c66c49 | 24 | class SerialNCTXTest(): |
dkato | 0:f782d9c66c49 | 25 | |
dkato | 0:f782d9c66c49 | 26 | def test(self, selftest): |
dkato | 0:f782d9c66c49 | 27 | selftest.mbed.flush(); |
dkato | 0:f782d9c66c49 | 28 | # Wait 0.5 seconds to ensure mbed is listening |
dkato | 0:f782d9c66c49 | 29 | time.sleep(0.5) |
dkato | 0:f782d9c66c49 | 30 | |
dkato | 0:f782d9c66c49 | 31 | selftest.mbed.serial_write("S"); |
dkato | 0:f782d9c66c49 | 32 | |
dkato | 0:f782d9c66c49 | 33 | strip_chars = string.whitespace + "\0" |
dkato | 0:f782d9c66c49 | 34 | |
dkato | 0:f782d9c66c49 | 35 | out_str = selftest.mbed.serial_readline() |
dkato | 0:f782d9c66c49 | 36 | selftest.notify("HOST: " + out_str) |
dkato | 0:f782d9c66c49 | 37 | |
dkato | 0:f782d9c66c49 | 38 | if not out_str: |
dkato | 0:f782d9c66c49 | 39 | selftest.notify("HOST: No output detected") |
dkato | 0:f782d9c66c49 | 40 | return selftest.RESULT_IO_SERIAL |
dkato | 0:f782d9c66c49 | 41 | |
dkato | 0:f782d9c66c49 | 42 | out_str_stripped = out_str.strip(strip_chars) |
dkato | 0:f782d9c66c49 | 43 | |
dkato | 0:f782d9c66c49 | 44 | if out_str_stripped != "TX OK - Expected": |
dkato | 0:f782d9c66c49 | 45 | selftest.notify("HOST: Unexpected output. Expected 'TX OK - Expected' but received '%s'" % out_str_stripped) |
dkato | 0:f782d9c66c49 | 46 | return selftest.RESULT_FAILURE |
dkato | 0:f782d9c66c49 | 47 | |
dkato | 0:f782d9c66c49 | 48 | out_str = selftest.mbed.serial_readline() |
dkato | 0:f782d9c66c49 | 49 | |
dkato | 0:f782d9c66c49 | 50 | # If no characters received, pass the test |
dkato | 0:f782d9c66c49 | 51 | if not out_str: |
dkato | 0:f782d9c66c49 | 52 | selftest.notify("HOST: No further output detected") |
dkato | 0:f782d9c66c49 | 53 | return selftest.RESULT_SUCCESS |
dkato | 0:f782d9c66c49 | 54 | else: |
dkato | 0:f782d9c66c49 | 55 | out_str_stripped = out_str.strip(strip_chars) |
dkato | 0:f782d9c66c49 | 56 | |
dkato | 0:f782d9c66c49 | 57 | if out_str_stripped == "TX OK - Unexpected": |
dkato | 0:f782d9c66c49 | 58 | selftest.notify("HOST: Unexpected output returned indicating TX still functioning") |
dkato | 0:f782d9c66c49 | 59 | else: |
dkato | 0:f782d9c66c49 | 60 | selftest.notify("HOST: Extraneous output '%s' detected indicating unknown error" % out_str_stripped) |
dkato | 0:f782d9c66c49 | 61 | |
dkato | 0:f782d9c66c49 | 62 | return selftest.RESULT_FAILURE |