Skip to content

feat(serial): desktop port chooser and xTool firmware support (PRs #3 and #4) - #7

Merged
SJLS27 merged 5 commits into
mainfrom
integrate/serial-pkkid
Nov 17, 2026
Merged

SJLS27 merged 5 commits into
mainfrom
integrate/serial-pkkid

Conversation

@SJLS27

@SJLS27 SJLS27 commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Integrates the two open pull requests from @pkkid's fork, reviewed and combined locally.

What this brings

Serial port chooser (PR #3, 2e95336)

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

  • electron/serialPort.ts: USB chip catalogue (CH340, FTDI, CP210x, PL2303, Arduino…), a pickSerialPort that never recommends ttyS*/Bluetooth, and a SerialPortBroker routing the choice to the renderer over IPC.
  • src/ui/SerialPortDialog.tsx: lists the real OS ports with the chip name, preselects the USB adapter and hides built-in UARTs behind Show N built-in ports.
  • Disconnect now cancels the pending read so the port actually closes.
  • Writes are serialised: a status poll overlapping a command no longer fails on the locked writer and drops the connection.

xTool firmware (PR #4, d0af971)

xTool controllers answer GRBL commands but differ: a bare ? 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 …], with a 1.5 s fallback to stock GRBL.
  • New Firmware device setting (Auto-detect / GRBL / xTool).

Docs

CHANGELOG [Unreleased], README.md/README.es.md, docs/USAGE.md, docs/ARCHITECTURE.md and a Serial / firmware block in TODO.md.

Conflict resolution

Verification

  • npm run typecheck
  • npm run test — 289/289 tests in 41 files
  • npm run build
  • npx playwright test e2e/app.spec.ts — 4/4 (headless Electron)
  • sh scripts/flatpak-local.sh + flatpak info io.github.SJLS27.OpenBurn
  • No dependency changes, so package-lock.json and flatpak/node-sources.json are untouched

Known limitation

xTool was only verified on connect and jog (D1, fw 40.30.002.01). The firmware commits motion on M2, so job progress can run ahead of the head, and Pause/Stop (!, ~, Ctrl+X) is unverified. Tracked in TODO.md.

Follow-ups (not in this PR)

  • e2e for the port dialog (simulate select-serial-port in the main process).
  • Explicit migration test for openburn.device without firmware.

Closes #3
Closes #4

pkkid and others added 5 commits November 14, 2026 21:32
xTool's controllers answer GRBL commands but differ in ways that left
the D1 connected yet unable to move:

- input is line based, so the bare '?' poll corrupted the next command;
- '$J=' jogs are acknowledged but ignored, and motion only runs after an
  M2 program end (which is how LightBurn jogs it);
- status reports carry no state word and come with an extra 'ok';
- 'ok:IDLE' / 'ok:512' chatter is not an acknowledgement.

The dialect lives in serial/dialect.ts. On connect the machine sends $I
and switches to the xTool command set only when the controller answers
'[XTool ...]'; otherwise, or if nothing answers within 1.5 s, it behaves
as before. A new Firmware device setting (Auto-detect / GRBL / xTool)
lets users force either dialect; GRBL skips the $I entirely.

Verified on an xTool D1 (fw 40.30.002.01): connect, status and jog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
Brings pkkid's fix/serial-port-selection (2e95336) into main. The desktop
build used to answer Electron's select-serial-port event by picking the
first port whose name matched /usb|tty|acm|serial/, which on Linux is
usually the motherboard UART (/dev/ttyS0): the app reported 'connected'
while GCode went nowhere.

- A renderer dialog lists the real ports with their USB chip and hides
  built-in UARTs behind 'Show N built-in ports'.
- Disconnect cancels the pending read so the port actually closes.
- Writes are serialised so a status poll overlapping a command no longer
  fails on the locked writer and drops the connection.

Verified locally: typecheck clean, 256/256 unit tests (22 new in
src/serial, SerialPortDialog.test.tsx and electron/serialPort.test.ts).
Brings pkkid's feat/xtool-firmware (d0af971) on top of PR #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 #3 and adds the firmware assignment from PR #4; TODO.md keeps the
xTool limitation note and drops the 'auto-selects the first port' note
that PR #3 already fixes.

Verified: typecheck clean, 289/289 tests in 41 files.
…ration

Tie the two merged PRs together in user-facing docs:

- CHANGELOG [Unreleased]: xTool firmware and the desktop port chooser under
  Added, the ttyS0 / disconnect / locked-writer bugs under Fixed, the xTool
  M2 limitation, and credit to @pkkid.
- README and README.es: the port chooser and xTool detection in the GRBL
  control section.
- ARCHITECTURE: xTool status polling and the M2 caveat next to the pause and
  stop commands.
- TODO: a Serial/firmware block with the remaining follow-ups (port chooser
  e2e, hardware verification on xTool, migration test for openburn.device).

Verified: npm run typecheck, npm run test (289/289) and npm run build.
@SJLS27
SJLS27 merged commit 03e22bc into main Nov 17, 2026
2 checks passed
@SJLS27
SJLS27 deleted the integrate/serial-pkkid branch November 17, 2026 22:17
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