port und so
This commit is contained in:
@@ -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
|
|
||||||
}))
|
|
||||||
14
scripts/accessWss.py
Normal file
14
scripts/accessWss.py
Normal file
@@ -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()
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
fluidnc: {
|
fluidnc: {
|
||||||
host: process.env.FluidNcHost || "fluidncred.local",
|
host: process.env.FluidNcHost || "fluidncRed.local",
|
||||||
port: Number(process.env.FluidNcPort) || 80,
|
port: Number(process.env.FluidNcPort) || 80,
|
||||||
reconnectDelay: 30000
|
reconnectDelay: 30000
|
||||||
},
|
},
|
||||||
|
|
||||||
server: {
|
server: {
|
||||||
port: Number(process.env.PORT) || 10000
|
port: Number(process.env.PORT) || 3000
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -38,7 +38,6 @@ class FluidNCClient extends EventEmitter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- BASIC COMMANDS ---
|
|
||||||
sendLine(cmd) {
|
sendLine(cmd) {
|
||||||
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
||||||
this.ws.send(cmd + "\n");
|
this.ws.send(cmd + "\n");
|
||||||
@@ -58,10 +57,6 @@ class FluidNCClient extends EventEmitter {
|
|||||||
this.sendLine(cmd);
|
this.sendLine(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
setZero() {
|
|
||||||
this.sendLine("G92 X0 Y0 Z0");
|
|
||||||
}
|
|
||||||
|
|
||||||
onMessage(fn) {
|
onMessage(fn) {
|
||||||
this.on("message", fn);
|
this.on("message", fn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
|
||||||
@@ -46,10 +46,6 @@ wss.on("connection", (ws) => {
|
|||||||
fluid.sendGcode(data.cmd);
|
fluid.sendGcode(data.cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.type === "zero") {
|
|
||||||
fluid.setZero();
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("[WS] Error parsing:", e);
|
console.log("[WS] Error parsing:", e);
|
||||||
}
|
}
|
||||||
@@ -70,7 +66,7 @@ fluid.onMessage((msg) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Status polling ("?" every 200ms)
|
// Status polling ("?" every 50ms)
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
fluid.requestStatus();
|
fluid.requestStatus();
|
||||||
}, 50);
|
}, 50);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<html lang="de">
|
<html lang="de">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>SCARA Robot Control</title>
|
<title>2D Robot Control</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
background: #234;
|
background: #234;
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<h1>SCARA Robot Control</h1>
|
<h1>2D Robot Control</h1>
|
||||||
|
|
||||||
<div id="posBox">
|
<div id="posBox">
|
||||||
<div>X: <span id="posX">0.000</span></div>
|
<div>X: <span id="posX">0.000</span></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user