Skip to content

feat: add SerialOpener hook to FlasherOptions#44

Merged
deadprogram merged 1 commit into
tinygo-org:mainfrom
jgangemi:jae/serial-opener
Jul 5, 2026
Merged

feat: add SerialOpener hook to FlasherOptions#44
deadprogram merged 1 commit into
tinygo-org:mainfrom
jgangemi:jae/serial-opener

Conversation

@jgangemi

Copy link
Copy Markdown
Contributor

Summary

Adds an optional SerialOpener hook to FlasherOptions so callers can intercept how serial ports are opened, enabling coordinated multi-consumer access to a single physical port.

Motivation

When a tool multiplexes one serial port between a live monitor and the flasher, having the flasher call serial.Open directly conflicts with the externally-managed port handle. This hook lets the caller supply its own opener — e.g. one that coordinates with a running monitor — used for both the initial open and the reopen-after-USB-reenumeration path.

Details

  • New field SerialOpener func(name string, mode *serial.Mode) (serial.Port, error) on FlasherOptions.
  • New() and reopenPort() route opens through a small opts.openPort() helper that uses SerialOpener when set and falls back to serial.Open otherwise.
  • Fully backward compatible: a nil hook preserves current behavior exactly.
  • Includes a unit test verifying the hook is invoked.

Enables callers to intercept port opens for coordinated multi-consumer access (e.g. a serial monitor running alongside the flasher).
@deadprogram

Copy link
Copy Markdown
Member

cc @georgik

@deadprogram

Copy link
Copy Markdown
Member

Thank you for the addition here @jgangemi now merging.

@deadprogram deadprogram merged commit 9cc955a into tinygo-org:main Jul 5, 2026
3 checks passed
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.

2 participants