Node.js bindings for the LinuxCNC NML interface. Control and monitor CNC machines running LinuxCNC directly from JavaScript/TypeScript.
npm install @linuxcnc-node/core
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();
Full API documentation: https://b0czek.github.io/linuxcnc-node/
GPL-2.0-only