CNC Router Controller
Serial communication, job queuing, and pause/resume control.
This case study is a placeholder. Full content coming soon.
Overview
A CNC router controlled via serial (G-code over USB). The machine manages a job queue — accepting G-code programs as actions, tracking execution progress as state, and exposing pause, resume, and emergency stop controls.
What this covers:
- Serial port management in
init()/kill() - Modelling a job queue as serializable state
- Validated actions with Zod input schemas
- Using
emitInfo()to stream progress messages to the UI - Handling asynchronous hardware feedback
Machine design
Full walkthrough coming soon.
Key patterns
| Pattern | Where it applies |
|---|---|
_serialPort private state key | Open serial connection, not broadcast |
createAction with Zod schema | Validating incoming G-code job payload |
updateState({ jobProgress }) | Incremental progress updates |
emitInfo() | Streaming machine feedback line-by-line |
emitError() | Surfacing controller faults |