Skip to content

fix(serial): let users pick the laser's port instead of silently using ttyS0 - #3

Merged
SJLS27 merged 1 commit into
SJLS27:mainfrom
pkkid:fix/serial-port-selection
Nov 17, 2026
Merged

SJLS27 merged 1 commit into
SJLS27:mainfrom
pkkid:fix/serial-port-selection

Conversation

@pkkid

@pkkid pkkid commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

First of all, thank you so much for starting a project like this. I am very excited to have a new app to control my laser. ❤️

On Linux, clicking Connect reported success but the laser never responded for the non-pro "xTool D1". The desktop app picked a port silently, taking the first one whose name contained tty, which on most PCs is the motherboard UART /dev/ttyS0 rather than the USB laser at /dev/ttyUSB0. Nothing in the UI showed which port was in use, so there was no way to tell or fix it.

Connect now opens a small port chooser instead. It lists USB serial ports with a description of the chip (e.g. /dev/ttyUSB0 · CH340 USB serial (QinHeng) · 1a86:7523), preselects the likely laser, and tucks the 32 built-in ttyS* ports behind a "Show N built-in ports" button. The chosen port name is then shown in the Laser panel and the port dropdown.

Two related bugs surfaced while debugging and are fixed here too:

  • Disconnect never released the port. It waited for a reader.read() that only returns when data arrives, so other apps (e.g. LightBurn) stayed locked out until OpenBurn quit. It now cancels the reader first.
  • Overlapping writes could drop the connection. A status poll landing during a command threw on the locked writer, which was treated as a closed port. Writes are now queued.

Testing

  • New unit tests for port ranking and descriptions, the IPC request broker, the chooser dialog, and both transport regressions (verified to fail on main).
  • npm run typecheck, npm run build and the touched test files pass locally. src/gcode/job.test.ts and src/workspace/textStyle.test.ts fail in my environment on main too (no 2D canvas), so they're unrelated.
  • e2e was not run locally (no xvfb); CI covers it.
  • Manually on Fedora with an xTool D1: the chooser lists only /dev/ttyUSB0, connecting works, and LightBurn can take the port after Disconnect.

Independent of #4 (xTool firmware support); whichever merges second has a one-line conflict in Machine.connectSerial.

image

Created with Claude Opus 5.5 in Claude Code.
🤖 Generated with Claude Code

The desktop build answered Electron's select-serial-port event itself,
taking the first port whose name contained "tty". On Linux that is often
the motherboard UART (/dev/ttyS0), so the app reported "connected" while
GCode went nowhere, and the user never saw which port was used.

- Forward the port list to a renderer dialog that shows OS port names,
  preselects the USB adapter and flags built-in UARTs.
- Show the chosen port name in the Laser panel and the port dropdown.
- Disconnect now cancels the pending read so the port actually closes.
- Serialize writes so a status poll overlapping a command no longer
  fails on the locked writer and drops the connection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SJLS27 added a commit that referenced this pull request Nov 17, 2026
feat(serial): desktop port chooser and xTool firmware support (PRs #3 and #4)
@SJLS27
SJLS27 merged commit ee7bd65 into SJLS27:main Nov 17, 2026
@SJLS27

SJLS27 commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thanks @pkkid, merged! 🎉 The default was a real trap: the app said "connected" while nothing reached the laser, and the locked-writer race on a status poll could drop the connection mid-job. Both are fixed now.

I reviewed the change locally (typecheck, the full suite and the desktop e2e smoke) and brought it in together with #4. now has it via #7 (merge commit ee7bd65, your commit keeps its authorship).

One conflict on the way: new WebSerialTransport(port, baudRate) in machine.ts needed the port name from this PR plus the firmware assignment from #4 — resolved as WebSerialTransport(port, baudRate, this.portNames.get(port)) + this.firmware = firmware.

I also credited you in CHANGELOG.md under Unreleased.

@SJLS27

SJLS27 commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Thanks @pkkid, merged! 🎉 The ttyS0 default was a real trap: the app said "connected" while nothing reached the laser, and the locked-writer race on a status poll could drop the connection mid-job. Both are fixed now.

I reviewed the change locally (typecheck, the full suite and the desktop e2e smoke) and brought it in together with #4. main now has it via #7 (merge commit ee7bd65, your commit keeps its authorship).

One conflict on the way: new WebSerialTransport(port, baudRate) in machine.ts needed the port name from this PR plus the firmware assignment from #4 — resolved as WebSerialTransport(port, baudRate, this.portNames.get(port)) + this.firmware = firmware.

I also credited you in CHANGELOG.md under Unreleased.

rvalotta pushed a commit to rvalotta/openburn that referenced this pull request Nov 22, 2026
Brings pkkid's feat/xtool-firmware (d0af971) on top of PR SJLS27#3. xTool's
controllers answer GRBL commands but differ in ways that left the D1
connected yet unable to move: '?' corrupts the next line, '$J=' jogs are
ignored until M2, status reports carry no state word and 'ok:IDLE'
chatter is not an acknowledgement.

- New src/serial/dialect.ts (poll, jog, chatter, identification).
- On connect the machine sends $I and switches to the xTool command set
  only when the controller answers '[XTool ...]'; 1.5 s fallback.
- New Firmware device setting (Auto-detect / GRBL / xTool).

Conflict resolution: src/serial/machine.ts keeps the port-name argument
from PR SJLS27#3 and adds the firmware assignment from PR SJLS27#4; TODO.md keeps the
xTool limitation note and drops the 'auto-selects the first port' note
that PR SJLS27#3 already fixes.

Verified: typecheck clean, 289/289 tests in 41 files.
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