Repository navigation
feat(serial): make xTool lasers (D1) move by speaking their GRBL dialect - #4
Conversation
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>
|
Thanks @pkkid, merged! 🎉 The xTool dialect detection ( Everything is on I documented the limitation you noted in the PR body in Thanks again, this is great work. |
|
I am able to connect fine now and move the laser. I have not tried burning anything yet and I don't think I'll be able to get to that until sometime next week. Thanks so much for getting the fix in! |
An xTool D1 connected fine but ignored every jog button, and typing
$Iin the console got no answer. LightBurn drives the same machine without trouble.xTool's firmware answers to GRBL commands but differs in a few ways:
?real-time poll gets buffered and corrupts the next command, so the D1 needs?\n, which it answers with an extraok.$J=jogs are acknowledged but ignored, and motion only runs afterM2.<MPos:x,y,z,a>.ok:IDLE/ok:512chatter that isn't a line acknowledgement.This adds
src/serial/dialect.ts, which documents those differences and keeps them out of the GRBL path. On connect the machine sends$Iand switches to the xTool command set only if the controller answers[XTool …]. If it answers[VER:…], or nothing arrives within 1.5 s (e.g. an Arduino resetting on open), it behaves exactly as before. A new Firmware device setting (Auto-detect / GRBL / xTool) lets users force either dialect; forced GRBL doesn't send$Iat all.xTool polling pauses while a job streams, because the extra
okper poll would be miscounted as a line acknowledgement. Jobs and frames already end withM2.Testing
npm run typecheckandnpm run buildpass. Same two pre-existing canvas test failures asmainin my environment; e2e not run locally.Not yet verified on hardware
Pause/Stop (
!,~, Ctrl+X) on the D1, job progress (the firmware may run a job only onceM2arrives, so progress could run ahead), and long jobs. Noted inTODO.md.Independent of #3 (serial port chooser); whichever merges second has a one-line conflict in
Machine.connectSerial.1. The new Firmware setting: the default is Auto-detect; the other options are GRBL and xTool (D1 and similar).
2. Jogging a D1, before and after:
ok:512/ok:IDLE, the$Jjog is acknowledged and ignored, and MPos stays at 0.00.G91/G1/G90/M2. The D1 replies[MSG:Pgm End]and MPos moves to 10.00.Created with Claude Opus 5.5 in Claude Code.
🤖 Generated with Claude Code