diff options
| author | Zixun LI <[email protected]> | 2026-06-16 21:18:46 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-06-16 21:18:46 +0200 |
| commit | e61c6765fa6ce556f2abaef0dcb5bed3b1486ee0 (patch) | |
| tree | 28c1b3653a4789b738a1414bdc2e8d8ecaab5495 /test | |
| parent | 3d745ee9d62414e7bd0c255b833715c5261edeee (diff) | |
| parent | ba3b2453e7cbf3572663dd1b7eadafdcc6b0a912 (diff) | |
Merge pull request #3699 from hathach/claude/musb-ep0-review-fixes
dcd/musb: harden & refactor the EP0 control state machine (review follow-up for #3643)
Diffstat (limited to 'test')
| -rwxr-xr-x | test/hil/hil_test.py | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/test/hil/hil_test.py b/test/hil/hil_test.py index c2ba34f02..aee59e05a 100755 --- a/test/hil/hil_test.py +++ b/test/hil/hil_test.py @@ -145,8 +145,7 @@ class HilConfig(TypedDict): CMD_TIMEOUT = int(os.getenv('HIL_CMD_TIMEOUT', '180')) POOL_TIMEOUT = int(os.getenv('HIL_POOL_TIMEOUT', '3000')) SERIAL_READ_TIMEOUT = float(os.getenv('HIL_SERIAL_READ_TIMEOUT', '5')) -SERIAL_WRITE_TIMEOUT = float(os.getenv('HIL_SERIAL_WRITE_TIMEOUT', '2')) -SERIAL_WRITE_DEADLINE = float(os.getenv('HIL_SERIAL_WRITE_DEADLINE', '10')) +SERIAL_WRITE_TIMEOUT = float(os.getenv('HIL_SERIAL_WRITE_TIMEOUT', '10')) def cmd_stdout_text(out: Any) -> str: @@ -247,24 +246,14 @@ def open_serial_dev(port: str): return ser -def serial_write_all(ser: serial.Serial, data: bytes, deadline: float = SERIAL_WRITE_DEADLINE): - total = 0 - end = time.monotonic() + deadline - - while total < len(data): - try: - written = ser.write(data[total:]) - except serial.SerialTimeoutException: - written = 0 - - if written: - total += written - continue - - if time.monotonic() >= end: - raise AssertionError(f'Serial write timeout after {deadline:.1f}s') - - time.sleep(0.01) +def serial_write_all(ser: serial.Serial, data: bytes): + # write_timeout is a total deadline for the whole call (pyserial keeps partial progress + # internally). A timeout means the device stopped draining — treat it as fatal: pyserial + # loses the partial-write count on raise, so retrying would duplicate bytes on the wire. + try: + ser.write(data) + except serial.SerialTimeoutException: + raise AssertionError(f'Serial write timeout after {SERIAL_WRITE_TIMEOUT:.1f}s') def read_disk_file(uid: str, lun: int, fname: str) -> bytes: |
