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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers serial_complete_auto.py Source File

serial_complete_auto.py

00001 """
00002 mbed SDK
00003 Copyright (c) 2011-2013 ARM Limited
00004 
00005 Licensed under the Apache License, Version 2.0 (the "License");
00006 you may not use this file except in compliance with the License.
00007 You may obtain a copy of the License at
00008 
00009     http://www.apache.org/licenses/LICENSE-2.0
00010 
00011 Unless required by applicable law or agreed to in writing, software
00012 distributed under the License is distributed on an "AS IS" BASIS,
00013 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014 See the License for the specific language governing permissions and
00015 limitations under the License.
00016 """
00017 
00018 import sys
00019 import uuid
00020 import time
00021 import string
00022 from sys import stdout
00023 
00024 class SerialCompleteTest():
00025 
00026     def test(self, selftest):
00027         strip_chars = string.whitespace + "\0"
00028         out_str = selftest.mbed.serial_readline()
00029         selftest.notify("HOST: " + out_str)
00030 
00031         if not out_str:
00032             selftest.notify("HOST: No output detected")
00033             return selftest.RESULT_IO_SERIAL
00034 
00035         out_str_stripped = out_str.strip(strip_chars)
00036 
00037         if out_str_stripped != "123456789":
00038             selftest.notify("HOST: Unexpected output. '123456789' Expected. but received '%s'" % out_str_stripped)
00039             return selftest.RESULT_FAILURE
00040 
00041         else:
00042             return selftest.RESULT_SUCCESS
00043