From 278acbec5d5c375ca50e1c38d8c9550820d0e0ae Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Thu, 14 Aug 2014 11:29:56 +0100 Subject: [PATCH] Host test: wrapped mbed.serial.timeout into separate function to avoid traceback and send proper IO_SERIAL error from host test(s) --- workspace_tools/host_tests/echo.py | 2 +- workspace_tools/host_tests/host_test.py | 4 ++-- workspace_tools/host_tests/stdio_auto.py | 2 +- workspace_tools/host_tests/tcpecho_client_auto.py | 2 +- workspace_tools/host_tests/udpecho_client_auto.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/workspace_tools/host_tests/echo.py b/workspace_tools/host_tests/echo.py index f5f8300ba6..ad0f7303a8 100644 --- a/workspace_tools/host_tests/echo.py +++ b/workspace_tools/host_tests/echo.py @@ -29,7 +29,7 @@ class EchoTest(Test): TEST="longer serial test" check = True for i in range(1, 100): - self.mbed.serial.write(TEST + "\n") + self.mbed.serial_write(TEST + "\n") l = self.mbed.serial.readline().strip() if not l: continue diff --git a/workspace_tools/host_tests/host_test.py b/workspace_tools/host_tests/host_test.py index 3045928fc8..d6aa1bd8a5 100644 --- a/workspace_tools/host_tests/host_test.py +++ b/workspace_tools/host_tests/host_test.py @@ -124,12 +124,12 @@ class Mbed: def serial_write(self, write_buffer): """ Wraps self.mbed.serial object write method """ - result = -1 + result = None if self.serial: try: result = self.serial.write(write_buffer) except: - result = -1 + result = None return result def safe_sendBreak(self, serial): diff --git a/workspace_tools/host_tests/stdio_auto.py b/workspace_tools/host_tests/stdio_auto.py index 65fd272b9f..b262e065ba 100644 --- a/workspace_tools/host_tests/stdio_auto.py +++ b/workspace_tools/host_tests/stdio_auto.py @@ -31,7 +31,7 @@ class StdioTest(DefaultTest): for i in range(1, 5): random_integer = random.randint(-10000, 10000) print "Generated number: " + str(random_integer) - self.mbed.serial.write(str(random_integer) + "\n") + self.mbed.serial_write(str(random_integer) + "\n") serial_stdio_msg = "" ip_msg_timeout = self.mbed.options.timeout diff --git a/workspace_tools/host_tests/tcpecho_client_auto.py b/workspace_tools/host_tests/tcpecho_client_auto.py index 9f2f26bb8c..1d8b6b0f82 100644 --- a/workspace_tools/host_tests/tcpecho_client_auto.py +++ b/workspace_tools/host_tests/tcpecho_client_auto.py @@ -33,7 +33,7 @@ class TCPEchoClientTest(Test): self.mbed.reset() print "Sending server IP Address to target..." connection_str = ip_address + ":" + str(port_no) + "\n" - self.mbed.serial.write(connection_str) + self.mbed.serial_write(connection_str) class TCPEchoClient_Handler(BaseRequestHandler): diff --git a/workspace_tools/host_tests/udpecho_client_auto.py b/workspace_tools/host_tests/udpecho_client_auto.py index e03d2c59ff..9d65bac3a8 100644 --- a/workspace_tools/host_tests/udpecho_client_auto.py +++ b/workspace_tools/host_tests/udpecho_client_auto.py @@ -32,7 +32,7 @@ class UDPEchoClientTest(Test): self.mbed.reset() print "Sending server IP Address to target..." connection_str = ip_address + ":" + str(port_no) + "\n" - self.mbed.serial.write(connection_str) + self.mbed.serial_write(connection_str) class UDPEchoClient_Handler(BaseRequestHandler):