|
60 | 60 | // to handle the reconnect operation correctly.
|
61 | 61 | #define USB_DISCONNECT_DELAY_MS 1
|
62 | 62 |
|
63 |
| -// Despite having ECHO and ECHOCTL POSIX lflags disabled by default by |
64 |
| -// pyserial, a delay is needed for host to properly handle data received |
65 |
| -// from USB serial/CDC device. |
66 |
| -// With no delay host would echo 0x00-0x31 characters prefixed with '^'. |
67 |
| -#define TX_DELAY_MS 10 |
68 |
| - |
69 | 63 | #define LINE_CODING_STRLEN 13 // 6 + 2 + 1 + 1 + 3 * comma
|
70 | 64 |
|
71 | 65 | #define USB_DEV_SN_LEN (32) // 32 hex digit UUID
|
@@ -373,7 +367,6 @@ void test_cdc_rx_single_bytes_concurrent()
|
373 | 367 | usb_cdc.connect();
|
374 | 368 | greentea_send_kv(MSG_KEY_SEND_BYTES_SINGLE, MSG_VALUE_DUMMY);
|
375 | 369 | usb_cdc.wait_ready();
|
376 |
| - wait_ms(TX_DELAY_MS); |
377 | 370 | Thread tx_thread;
|
378 | 371 | event_flags.set(EF_SEND);
|
379 | 372 | tx_thread.start(mbed::callback(tx_thread_fun, &usb_cdc));
|
@@ -443,7 +436,6 @@ void test_cdc_rx_multiple_bytes_concurrent()
|
443 | 436 | usb_cdc.connect();
|
444 | 437 | greentea_send_kv(MSG_KEY_SEND_BYTES_MULTIPLE, HOST_RX_BUFF_SIZE_RATIO);
|
445 | 438 | usb_cdc.wait_ready();
|
446 |
| - wait_ms(TX_DELAY_MS); |
447 | 439 | Thread tx_thread;
|
448 | 440 | event_flags.set(EF_SEND);
|
449 | 441 | tx_thread.start(mbed::callback(tx_thread_fun, &usb_cdc));
|
@@ -485,7 +477,6 @@ void test_cdc_loopback()
|
485 | 477 | usb_cdc.connect();
|
486 | 478 | greentea_send_kv(MSG_KEY_LOOPBACK, MSG_VALUE_DUMMY);
|
487 | 479 | usb_cdc.wait_ready();
|
488 |
| - wait_ms(TX_DELAY_MS); |
489 | 480 | uint8_t rx_buff, tx_buff;
|
490 | 481 | for (int i = 0; i < CDC_LOOPBACK_REPS; i++) {
|
491 | 482 | tx_buff = (uint8_t)(rand() % 0x100);
|
@@ -660,10 +651,7 @@ void test_serial_printf_scanf()
|
660 | 651 | TestUSBSerial usb_serial(USB_SERIAL_VID, USB_SERIAL_PID, 1, usb_dev_sn);
|
661 | 652 | usb_serial.connect();
|
662 | 653 | greentea_send_kv(MSG_KEY_LOOPBACK, MSG_VALUE_DUMMY);
|
663 |
| - while (!usb_serial.connected()) { |
664 |
| - wait_ms(1); |
665 |
| - } |
666 |
| - wait_ms(TX_DELAY_MS); |
| 654 | + usb_serial.wait_ready(); |
667 | 655 | static const char fmt[] = "Formatted\nstring %i.";
|
668 | 656 | int tx_val, rx_val, rc;
|
669 | 657 | for (int i = 0; i < SERIAL_LOOPBACK_REPS; i++) {
|
@@ -704,10 +692,7 @@ void test_serial_line_coding_change()
|
704 | 692 | TestUSBSerial usb_serial(USB_SERIAL_VID, USB_SERIAL_PID, 1, usb_dev_sn);
|
705 | 693 | usb_serial.connect();
|
706 | 694 | greentea_send_kv(MSG_KEY_CHANGE_LINE_CODING, MSG_VALUE_DUMMY);
|
707 |
| - while (!usb_serial.connected()) { |
708 |
| - wait_ms(1); |
709 |
| - } |
710 |
| - wait_ms(TX_DELAY_MS); |
| 695 | + usb_serial.wait_ready(); |
711 | 696 | usb_serial.attach(line_coding_changed_cb);
|
712 | 697 | size_t num_line_codings = sizeof test_codings / sizeof test_codings[0];
|
713 | 698 | line_coding_t *lc_prev = &default_lc;
|
|
0 commit comments