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.
|
||||
TERM_REOPEN_DELAY = 0.1
|
||||
|
||||
# 6 (baud) + 2 (bits) + 1 (parity) + 1 (stop) + 3 * comma
|
||||
LINE_CODING_STRLEN = 13
|
||||
LINE_CODING_SEP = ','
|
||||
LINE_CODING_DELIM = ';'
|
||||
|
||||
|
||||
def usb_serial_name(serial_number):
|
||||
|
@ -269,16 +269,17 @@ class USBSerialTest(mbed_host_tests.BaseHostTest):
|
|||
mbed_serial.reset_output_buffer()
|
||||
mbed_serial.dtr = True
|
||||
try:
|
||||
payload = six.ensure_str(mbed_serial.read(LINE_CODING_STRLEN))
|
||||
while len(payload) == LINE_CODING_STRLEN:
|
||||
baud, bits, parity, stop = (int(i) for i in payload.split(','))
|
||||
payload = six.ensure_str(mbed_serial.read_until(LINE_CODING_DELIM))
|
||||
while len(payload) > 0:
|
||||
baud, bits, parity, stop = (
|
||||
int(i) for i in payload.strip(LINE_CODING_DELIM).split(LINE_CODING_SEP))
|
||||
new_line_coding = {
|
||||
'baudrate': baud,
|
||||
'bytesize': self._BYTESIZES[bits],
|
||||
'parity': self._PARITIES[parity],
|
||||
'stopbits': self._STOPBITS[stop]}
|
||||
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:
|
||||
self.log('TEST ERROR: {}'.format(exc))
|
||||
self.notify_complete(False)
|
||||
|
|
|
@ -84,7 +84,8 @@
|
|||
#define SERIAL_LOOPBACK_REPS 100
|
||||
#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 NONASCII_CHAR ('?')
|
||||
|
@ -776,9 +777,9 @@ void test_serial_line_coding_change()
|
|||
for (size_t i = 0; i < num_line_codings; i++) {
|
||||
lc_expected = &(test_codings[i]);
|
||||
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,
|
||||
lc_expected->stop);
|
||||
TEST_ASSERT_EQUAL_INT(LINE_CODING_STRLEN, rc);
|
||||
rc = usb_serial.printf("%06i,%02i,%01i,%01i%c", lc_expected->baud, lc_expected->bits, lc_expected->parity,
|
||||
lc_expected->stop, LINE_CODING_DELIM);
|
||||
TEST_ASSERT(rc > 0);
|
||||
// The pyserial Python module does not update all line coding params
|
||||
// at once. It updates params one by one instead, and since every
|
||||
// update is followed by port reconfiguration we get multiple
|
||||
|
|
Loading…
Reference in New Issue