From ab9b0919fb31bd6c6a096f8cbb763ff92101bb3b Mon Sep 17 00:00:00 2001 From: chk <79915315+ChKendel@users.noreply.github.com> Date: Tue, 10 Mar 2026 15:49:53 +0100 Subject: [PATCH] port und so --- pythonExample/example.py | 11 ----------- scripts/accessWss.py | 14 ++++++++++++++ server/config/config.js | 4 ++-- server/fluidnc/FluidNCClient.js | 5 ----- server/fluidnc/StatusParser.js | 26 -------------------------- server/server.js | 6 +----- web/index.html | 4 ++-- 7 files changed, 19 insertions(+), 51 deletions(-) delete mode 100644 pythonExample/example.py create mode 100644 scripts/accessWss.py delete mode 100644 server/fluidnc/StatusParser.js diff --git a/pythonExample/example.py b/pythonExample/example.py deleted file mode 100644 index 76162e3..0000000 --- a/pythonExample/example.py +++ /dev/null @@ -1,11 +0,0 @@ -import websocket -import json - -ws = websocket.WebSocket() -ws.connect("wss://localhost:3000") - -ws.send(json.dumps({ -"type":"jog", -"axis":"x", -"value":10 -})) \ No newline at end of file diff --git a/scripts/accessWss.py b/scripts/accessWss.py new file mode 100644 index 0000000..9a108a4 --- /dev/null +++ b/scripts/accessWss.py @@ -0,0 +1,14 @@ +import websocket +import json +import ssl + +websocket.enableTrace(True) + +ws = websocket.create_connection( + "wss://localhost:3000", + sslopt={"cert_reqs": ssl.CERT_NONE} +) + +ws.send(json.dumps({"type": "gcode", "cmd": "G0 x104"})) + +ws.close() \ No newline at end of file diff --git a/server/config/config.js b/server/config/config.js index 58fd1cb..9c42963 100644 --- a/server/config/config.js +++ b/server/config/config.js @@ -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 } }; \ No newline at end of file diff --git a/server/fluidnc/FluidNCClient.js b/server/fluidnc/FluidNCClient.js index b81f3ff..8a84cc6 100644 --- a/server/fluidnc/FluidNCClient.js +++ b/server/fluidnc/FluidNCClient.js @@ -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); } diff --git a/server/fluidnc/StatusParser.js b/server/fluidnc/StatusParser.js deleted file mode 100644 index 4c3cd85..0000000 --- a/server/fluidnc/StatusParser.js +++ /dev/null @@ -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; \ No newline at end of file diff --git a/server/server.js b/server/server.js index 9c0e7a6..fc9e2e9 100644 --- a/server/server.js +++ b/server/server.js @@ -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); diff --git a/web/index.html b/web/index.html index 5de682e..29067bd 100644 --- a/web/index.html +++ b/web/index.html @@ -2,7 +2,7 @@
-