@linuxcnc-node/core
v2.1.3
Published
Node.js bindings for core LinuxCNC NML interface
Maintainers
Readme
@linuxcnc-node/core
Node.js bindings for the LinuxCNC NML interface. Control and monitor CNC machines running LinuxCNC directly from JavaScript/TypeScript.
Features
- StatChannel - Real-time machine status monitoring with typed property change events
- CommandChannel - Send commands to LinuxCNC (MDI, program control, jogging, tool changes, etc.)
- ErrorChannel - Receive error and operator messages from LinuxCNC
- PositionLogger - High-frequency position logging for toolpath visualization
Installation
npm install @linuxcnc-node/coreQuick Start
import {
StatChannel,
CommandChannel,
TaskMode,
TaskState,
PositionIndex,
} from "@linuxcnc-node/core";
const stat = new StatChannel();
const cmd = new CommandChannel();
// Watch for position changes
stat.on("motion.traj.actualPosition", (pos) => {
// pos is now a Float64Array(9) - destructure index for readable access
const { X, Y, Z } = PositionIndex;
console.log(`X=${pos[X]} Y=${pos[Y]} Z=${pos[Z]}`);
});
// Send commands
await cmd.setState(TaskState.ON);
await cmd.setTaskMode(TaskMode.MDI);
await cmd.executeMdi("G0 X10 Y10");
// Cleanup
stat.destroy();Documentation
Full API documentation: https://b0czek.github.io/linuxcnc-node/
Requirements
- Linux
- LinuxCNC installed and running
- Node.js 18+
License
GPL-2.0-only
