port konfigurierbar
This commit is contained in:
16
.vscode/launch.json
vendored
Normal file
16
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Attach appRobotDriver (Docker)",
|
||||
"type": "node",
|
||||
"request": "attach",
|
||||
"address": "localhost",
|
||||
"port": 2081,
|
||||
"localRoot": "${workspaceFolder}",
|
||||
"remoteRoot": "/usr/src/app",
|
||||
"restart": true,
|
||||
"timeout": 10000
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -212,3 +212,13 @@
|
||||
2026-04-01T16:09:27.471Z ::ffff:172.21.0.6: Ping
|
||||
2026-04-01T16:09:32.477Z ::ffff:172.21.0.6: Ping
|
||||
2026-04-01T16:09:37.480Z ::ffff:172.21.0.6: Ping
|
||||
2026-04-03T16:38:27.971Z ::ffff:172.21.0.9: Ping
|
||||
2026-04-03T16:38:32.978Z ::ffff:172.21.0.9: Ping
|
||||
2026-04-03T16:38:37.980Z ::ffff:172.21.0.9: Ping
|
||||
2026-04-03T16:38:42.965Z ::ffff:172.21.0.9: Ping
|
||||
2026-04-03T16:38:47.973Z ::ffff:172.21.0.9: Ping
|
||||
2026-04-03T16:38:52.968Z ::ffff:172.21.0.9: Ping
|
||||
2026-04-03T16:39:19.994Z ::ffff:172.21.0.9: Ping
|
||||
2026-04-03T16:39:19.995Z ::ffff:172.21.0.9: Ping
|
||||
2026-04-03T16:40:19.977Z ::ffff:172.21.0.9: Ping
|
||||
2026-04-03T16:40:19.980Z ::ffff:172.21.0.9: Ping
|
||||
|
||||
@@ -144,8 +144,11 @@ setTimeout(function(){
|
||||
console.log("Works with FluidNc Base");
|
||||
|
||||
|
||||
port = 2095
|
||||
server.listen(port);
|
||||
|
||||
const port = Number(process.env.PORT);
|
||||
const listenPort = Number.isInteger(port) ? port : 2095;
|
||||
|
||||
server.listen(listenPort);
|
||||
console.log("Listen on Port: https://localhost:" + port.toString()+ "/")
|
||||
|
||||
|
||||
@@ -192,5 +195,9 @@ const infoServer = https.createServer(httpsOptions, (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
infoServer.listen(2098);
|
||||
console.log("Info server listening on https://localhost:2098/");
|
||||
|
||||
const InfPort = Number(process.env.PORT);
|
||||
const listenInfoPort = Number.isInteger(InfPort) ? InfPort : 2095;
|
||||
|
||||
infoServer.listen(listenInfoPort);
|
||||
console.log("Info server listening on https://localhost:"+ listenInfoPort.toString() + "/");
|
||||
|
||||
60
test/WSDriver_ReceiveMsg.test.js
Normal file
60
test/WSDriver_ReceiveMsg.test.js
Normal file
@@ -0,0 +1,60 @@
|
||||
const WebSocket = require('ws');
|
||||
|
||||
const TEST_URL = "wss://localhost:2095";
|
||||
|
||||
describe("WebSocket Verbindung (appRobot_Driver)", () => {
|
||||
|
||||
let ws;
|
||||
|
||||
beforeAll((done) => {
|
||||
// self-signed cert ignorieren (wichtig!)
|
||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
||||
|
||||
ws = new WebSocket(TEST_URL);
|
||||
|
||||
ws.on('open', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
ws.on('error', (err) => {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
if (ws) ws.close();
|
||||
});
|
||||
|
||||
test("Ping → sollte Antwort bekommen", (done) => {
|
||||
|
||||
ws.on('message', (data) => {
|
||||
const msg = data.toString();
|
||||
|
||||
try {
|
||||
expect(msg).toBe("Ping");
|
||||
done();
|
||||
} catch (err) {
|
||||
done(err);
|
||||
}
|
||||
});
|
||||
|
||||
ws.send("Ping");
|
||||
});
|
||||
|
||||
test("GCode senden → sollte Antwort liefern", (done) => {
|
||||
|
||||
ws.on('message', (data) => {
|
||||
const msg = data.toString();
|
||||
|
||||
try {
|
||||
expect(msg).toContain("X"); // M114 response enthält Positionsdaten
|
||||
done();
|
||||
} catch (err) {
|
||||
done(err);
|
||||
}
|
||||
});
|
||||
|
||||
ws.send("G1 X10 F100");
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user