mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #12805 from fkjagodzinski/test_update-usb_serial-minimal_printf
Tests: USBSerial: Handle minimal printf limitationspull/12917/head
commit
5f76dfe896
|
@ -47,8 +47,8 @@ TERM_CLOSE_DELAY = 0.01
|
||||||
# during terminal reopen test.
|
# during terminal reopen test.
|
||||||
TERM_REOPEN_DELAY = 0.1
|
TERM_REOPEN_DELAY = 0.1
|
||||||
|
|
||||||
# 6 (baud) + 2 (bits) + 1 (parity) + 1 (stop) + 3 * comma
|
LINE_CODING_SEP = ','
|
||||||
LINE_CODING_STRLEN = 13
|
LINE_CODING_DELIM = ';'
|
||||||
|
|
||||||
|
|
||||||
def usb_serial_name(serial_number):
|
def usb_serial_name(serial_number):
|
||||||
|
@ -269,16 +269,17 @@ class USBSerialTest(mbed_host_tests.BaseHostTest):
|
||||||
mbed_serial.reset_output_buffer()
|
mbed_serial.reset_output_buffer()
|
||||||
mbed_serial.dtr = True
|
mbed_serial.dtr = True
|
||||||
try:
|
try:
|
||||||
payload = six.ensure_str(mbed_serial.read(LINE_CODING_STRLEN))
|
payload = six.ensure_str(mbed_serial.read_until(LINE_CODING_DELIM))
|
||||||
while len(payload) == LINE_CODING_STRLEN:
|
while len(payload) > 0:
|
||||||
baud, bits, parity, stop = (int(i) for i in payload.split(','))
|
baud, bits, parity, stop = (
|
||||||
|
int(i) for i in payload.strip(LINE_CODING_DELIM).split(LINE_CODING_SEP))
|
||||||
new_line_coding = {
|
new_line_coding = {
|
||||||
'baudrate': baud,
|
'baudrate': baud,
|
||||||
'bytesize': self._BYTESIZES[bits],
|
'bytesize': self._BYTESIZES[bits],
|
||||||
'parity': self._PARITIES[parity],
|
'parity': self._PARITIES[parity],
|
||||||
'stopbits': self._STOPBITS[stop]}
|
'stopbits': self._STOPBITS[stop]}
|
||||||
mbed_serial.apply_settings(new_line_coding)
|
mbed_serial.apply_settings(new_line_coding)
|
||||||
payload = six.ensure_str(mbed_serial.read(LINE_CODING_STRLEN))
|
payload = six.ensure_str(mbed_serial.read_until(LINE_CODING_DELIM))
|
||||||
except serial.SerialException as exc:
|
except serial.SerialException as exc:
|
||||||
self.log('TEST ERROR: {}'.format(exc))
|
self.log('TEST ERROR: {}'.format(exc))
|
||||||
self.notify_complete(False)
|
self.notify_complete(False)
|
||||||
|
|
|
@ -84,7 +84,8 @@
|
||||||
#define SERIAL_LOOPBACK_REPS 100
|
#define SERIAL_LOOPBACK_REPS 100
|
||||||
#define USB_RECONNECT_DELAY_MS 1
|
#define USB_RECONNECT_DELAY_MS 1
|
||||||
|
|
||||||
#define LINE_CODING_STRLEN 13 // 6 + 2 + 1 + 1 + 3 * comma
|
#define LINE_CODING_SEP (',')
|
||||||
|
#define LINE_CODING_DELIM (';')
|
||||||
|
|
||||||
#define USB_DEV_SN_LEN (32) // 32 hex digit UUID
|
#define USB_DEV_SN_LEN (32) // 32 hex digit UUID
|
||||||
#define NONASCII_CHAR ('?')
|
#define NONASCII_CHAR ('?')
|
||||||
|
@ -776,9 +777,9 @@ void test_serial_line_coding_change()
|
||||||
for (size_t i = 0; i < num_line_codings; i++) {
|
for (size_t i = 0; i < num_line_codings; i++) {
|
||||||
lc_expected = &(test_codings[i]);
|
lc_expected = &(test_codings[i]);
|
||||||
num_expected_callbacks = lc_prev->get_num_diffs(*lc_expected);
|
num_expected_callbacks = lc_prev->get_num_diffs(*lc_expected);
|
||||||
rc = usb_serial.printf("%06i,%02i,%01i,%01i", lc_expected->baud, lc_expected->bits, lc_expected->parity,
|
rc = usb_serial.printf("%06i,%02i,%01i,%01i%c", lc_expected->baud, lc_expected->bits, lc_expected->parity,
|
||||||
lc_expected->stop);
|
lc_expected->stop, LINE_CODING_DELIM);
|
||||||
TEST_ASSERT_EQUAL_INT(LINE_CODING_STRLEN, rc);
|
TEST_ASSERT(rc > 0);
|
||||||
// The pyserial Python module does not update all line coding params
|
// The pyserial Python module does not update all line coding params
|
||||||
// at once. It updates params one by one instead, and since every
|
// at once. It updates params one by one instead, and since every
|
||||||
// update is followed by port reconfiguration we get multiple
|
// update is followed by port reconfiguration we get multiple
|
||||||
|
|
Loading…
Reference in New Issue