Skip to content

Commit 005c3a7

Browse files
committed
Host test: wrapped timeout for MUTs serial port access to handle IO_SERIAL error while accessing serial port
1 parent d076c51 commit 005c3a7

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

workspace_tools/host_tests/host_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def __init__(self):
8686
print 'Mbed: "%s" "%s"' % (self.port, self.disk)
8787

8888
def init_serial(self, baud=9600, extra_baud=9600):
89+
""" Initialize serial port. Function will return error is port can't be opened or initialized """
8990
result = True
9091
try:
9192
self.serial = Serial(self.port, timeout=1)
@@ -100,6 +101,14 @@ def init_serial(self, baud=9600, extra_baud=9600):
100101
self.flush()
101102
return result
102103

104+
def serial_timeout(self, timeout):
105+
""" Wraps self.mbed.serial object timeout property """
106+
result = None
107+
if self.serial:
108+
self.serial.timeout = timeout
109+
result = True
110+
return result
111+
103112
def serial_read(self, count=1):
104113
""" Wraps self.mbed.serial object read method """
105114
result = None

workspace_tools/host_tests/rtc_auto.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ class RTCTest(DefaultTest):
2626

2727
def run(self):
2828
test_result = True
29-
c = self.mbed.serial.timeout = None
29+
if self.mbed.serial_timeout(None) is None:
30+
self.print_result("ioerr_serial")
31+
return
3032
for i in range(0, 5):
3133
c = self.mbed.serial_read(38) # 38 len("[1256729742] [2009-10-28 11:35:42 AM]\n"
3234
if c is None:

workspace_tools/host_tests/wait_us_auto.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ class WaitusTest(DefaultTest):
2323
def run(self):
2424
test_result = True
2525
# First character to start test (to know after reset when test starts)
26-
self.mbed.serial.timeout = None
26+
if self.mbed.serial_timeout(None) is None:
27+
self.print_result("ioerr_serial")
28+
return
2729
c = self.mbed.serial_read(1)
2830
if c is None:
2931
self.print_result("ioerr_serial")

0 commit comments

Comments
 (0)