diff options
| author | hathach <[email protected]> | 2026-04-02 23:56:47 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2026-04-03 10:45:16 +0700 |
| commit | 9368e5d40f3d8e5ac323d288f969782a962d593e (patch) | |
| tree | ee398f81d49d3e3c0637650a8aa1f3c8993d4a5e | |
| parent | 134e14849b1864ce3454950a50d2c79d93a96cd8 (diff) | |
fix issue with exmaple
| -rw-r--r-- | examples/host/cdc_msc_hid/src/cdc_app.c | 14 | ||||
| -rwxr-xr-x | test/hil/hil_test.py | 9 |
2 files changed, 9 insertions, 14 deletions
diff --git a/examples/host/cdc_msc_hid/src/cdc_app.c b/examples/host/cdc_msc_hid/src/cdc_app.c index c897bdd06..20033981e 100644 --- a/examples/host/cdc_msc_hid/src/cdc_app.c +++ b/examples/host/cdc_msc_hid/src/cdc_app.c @@ -43,14 +43,10 @@ static size_t console_read(uint8_t *buf, size_t bufsize) { } static size_t console_write(const uint8_t *buf, size_t bufsize) { - size_t count = 0; - while (count < bufsize) { - if (board_putchar((int)buf[count]) < 0) { - break; - } - count++; - } - return count; + // Use board_uart_write directly for non-blocking behavior. + // board_putchar -> sys_write has a blocking retry loop that causes UART RX overrun. + int wr = board_uart_write(buf, (int) bufsize); + return (wr > 0) ? (size_t) wr : 0; } // forward from console to usbh @@ -78,7 +74,7 @@ void cdc_app_task(void) { do { // uart write is slow, while waiting forward uart -> usbh else uart rx can be overflow if (count) { - wr += console_write(buf + wr, count); + wr += console_write(buf + wr, count - wr); } console_to_usbh(idx); } while (wr < count); diff --git a/test/hil/hil_test.py b/test/hil/hil_test.py index 40779d1a4..f23e2fc22 100755 --- a/test/hil/hil_test.py +++ b/test/hil/hil_test.py @@ -1189,9 +1189,8 @@ def test_example(board, f1, example): print(f'Flashing {fw_name}.elf') # flash firmware. It may fail randomly, retry a few times - max_rety = max_retry start_s = time.time() - for i in range(max_rety): + for i in range(max_retry): ret = globals()[f'flash_{board["flasher"]["name"].lower()}'](board, fw_name) if ret.returncode == 0: try: @@ -1202,14 +1201,14 @@ def test_example(board, f1, example): print(' OK', end='') break except Exception as e: - if i == max_rety - 1: + if i == max_retry - 1: err_count += 1 print(f'{STATUS_FAILED}: {e}') else: - print(f'\n Test failed: {e}, retry {i+2}/{max_rety}', end='') + print(f'\n Test failed: {e}, retry {i+2}/{max_retry}', end='') time.sleep(0.5) else: - print(f'\n Flash failed, retry {i+2}/{max_rety}', end='') + print(f'\n Flash failed, retry {i+2}/{max_retry}', end='') time.sleep(0.5) if ret.returncode != 0: |
