Skip to content

[merge] v0.4.1 from win-serial-patch - #6

Merged
gavinhsmith merged 1 commit into
mainfrom
win-serial-patch
Sep 24, 2026
Merged

gavinhsmith merged 1 commit into
mainfrom
win-serial-patch

Conversation

@gavinhsmith

Copy link
Copy Markdown
Owner

Fixes TINCLIBC not connecting to tinclib-firmware's PC target (calculator plugged straight into the PC, PC app on the COM port). Every retry played the Windows disconnect/connect sound and no frame arrived. The ESP board path was not affected.

  • tinc_init() gave up on HELLO after 600 ms (TINC_RETRY_MAX x TINC_REPLY_TIMEOUT_MS). That's before Windows has loaded usbser and the PC app has the port open. It now retries on NO_REPLY until TINC_DEVICE_WAIT_MS, timed from the same start as the device wait, so the call stays bounded (~2.6 s at worst). Other errors still return at once, and the protocol timing constants are unchanged.
  • A repeat tinc_init() keeps USB up instead of cleaning up and re-initialising. Re-enumerating is what made COM9 vanish on every retry. Only tinc_shutdown() tears USB down now.
  • Side effect: an ESP that never answers now fails after ~2 s instead of 600 ms.
  • Test test_hello_late_reply: HELLO answered after 2 x TINC_RETRY_MAX lost replies gives TINC_OK; never answered gives TINC_ERR_NO_REPLY after roughly the window.
  • Version 0.4.1 (no API or wire change, same protocol pin).

Known limit, not fixed: while the calculator is idle nothing answers USB, so the PC's port open blocks until the next tinclib call. Pressing [enter] in TINCLIBC unblocks it.

Not yet tested on hardware. To check: pio run -e pc in tinclib-firmware, run .pio/build/pc/program.exe COM9, start TINCLIBC. Expect COM9: open, then the HELLO exchange, within about a second of [enter]. Whether 2 s is enough on a first plug-in (usbser load) is unmeasured.

After merge: tag v0.4.1 and move tinclib-config's lib/tinclib submodule to it.

- Retry HELLO on NO_REPLY until TINC_DEVICE_WAIT_MS (same start as the
  device wait), so a PC host has time to load usbser and open the port
- A repeat tinc_init() keeps USB up instead of re-enumerating, so the
  PC's COM port survives a retry
- Test: HELLO answered after several lost replies, and never answered
- Version 0.4.1
@gavinhsmith
gavinhsmith merged commit e9f57e4 into main Sep 24, 2026
4 checks passed
@gavinhsmith
gavinhsmith deleted the win-serial-patch branch September 24, 2026 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant