From dbfd43a098b14e3c84764b0203748bc97238abc8 Mon Sep 17 00:00:00 2001 From: Filip Jagodzinski Date: Thu, 20 Sep 2018 11:37:54 +0200 Subject: [PATCH] Tests: USB: Wait before closing host's port This delay eliminates the possibility of the device detecting the port being closed when still waiting for data. --- TESTS/host_tests/usb_device_serial.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TESTS/host_tests/usb_device_serial.py b/TESTS/host_tests/usb_device_serial.py index 9394811bf9..7574ee92cb 100644 --- a/TESTS/host_tests/usb_device_serial.py +++ b/TESTS/host_tests/usb_device_serial.py @@ -32,6 +32,7 @@ MSG_KEY_LOOPBACK = 'loopback' MSG_KEY_CHANGE_LINE_CODING = 'change_lc' RX_BUFF_SIZE = 32 +TERM_CLOSE_DELAY = 0.01 TERM_REOPEN_DELAY = 0.1 LINE_CODING_STRLEN = 13 @@ -181,6 +182,7 @@ class USBSerialTest(mbed_host_tests.BaseHostTest): return while mbed_serial.out_waiting > 0: time.sleep(0.001) + time.sleep(TERM_CLOSE_DELAY) mbed_serial.close() def loopback(self, usb_id_str): @@ -212,6 +214,7 @@ class USBSerialTest(mbed_host_tests.BaseHostTest): return while mbed_serial.out_waiting > 0: time.sleep(0.001) + time.sleep(TERM_CLOSE_DELAY) mbed_serial.close() def change_line_coding(self, usb_id_str): @@ -249,6 +252,7 @@ class USBSerialTest(mbed_host_tests.BaseHostTest): self.log('TEST ERROR: {}'.format(exc)) self.notify_complete(False) return + time.sleep(TERM_CLOSE_DELAY) mbed_serial.close() def setup(self):