port und so

This commit is contained in:
chk
2026-03-10 15:49:53 +01:00
parent 20e2790552
commit ab9b0919fb
7 changed files with 19 additions and 51 deletions

View File

@@ -1,11 +1,11 @@
module.exports = {
fluidnc: {
host: process.env.FluidNcHost || "fluidncred.local",
host: process.env.FluidNcHost || "fluidncRed.local",
port: Number(process.env.FluidNcPort) || 80,
reconnectDelay: 30000
},
server: {
port: Number(process.env.PORT) || 10000
port: Number(process.env.PORT) || 3000
}
};

View File

@@ -38,7 +38,6 @@ class FluidNCClient extends EventEmitter {
});
}
// --- BASIC COMMANDS ---
sendLine(cmd) {
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
this.ws.send(cmd + "\n");
@@ -58,10 +57,6 @@ class FluidNCClient extends EventEmitter {
this.sendLine(cmd);
}
setZero() {
this.sendLine("G92 X0 Y0 Z0");
}
onMessage(fn) {
this.on("message", fn);
}

View File

@@ -1,26 +0,0 @@
class StatusParser {
static parse(line){
if(!line.startsWith("<")) return null;
const stateMatch = line.match(/^<([^|]+)/);
const posMatch = line.match(/MPos:([^|]+)/);
if(!posMatch) return null;
const parts = posMatch[1].split(",");
return {
type: "status",
state: stateMatch ? stateMatch[1] : "unknown",
x: parseFloat(parts[0]),
y: parseFloat(parts[1]),
z: parseFloat(parts[2])
};
}
}
module.exports = StatusParser;

View File

@@ -46,10 +46,6 @@ wss.on("connection", (ws) => {
fluid.sendGcode(data.cmd);
}
if (data.type === "zero") {
fluid.setZero();
}
} catch (e) {
console.log("[WS] Error parsing:", e);
}
@@ -70,7 +66,7 @@ fluid.onMessage((msg) => {
});
});
// Status polling ("?" every 200ms)
// Status polling ("?" every 50ms)
setInterval(() => {
fluid.requestStatus();
}, 50);