From 10d306b7d4a18c01f0a1ddb6d53d92d2a22705ac Mon Sep 17 00:00:00 2001 From: chk <79915315+ChKendel@users.noreply.github.com> Date: Mon, 8 Jun 2026 18:17:53 +0200 Subject: [PATCH] Claude Ultracode Fixes --- logs/gcode_commands.log | 14 ++++++++++++++ logs/pings.log | 7 +++++++ public/app.js | 6 ++++-- public/style.css | 6 ++++++ robot/TelnetSenderGRBL.js | 2 +- robot/WSSenderGrbl.js | 4 ++-- server/InputWS.js | 1 + startRobot.js | 12 +++++++----- test/Sender.Telnet.test.js | 8 ++++---- 9 files changed, 46 insertions(+), 14 deletions(-) diff --git a/logs/gcode_commands.log b/logs/gcode_commands.log index d74b3c0..5fc8472 100644 --- a/logs/gcode_commands.log +++ b/logs/gcode_commands.log @@ -10219,3 +10219,17 @@ 2026-06-08T15:25:42.319Z ::ffff:127.0.0.1: M114 2026-06-08T15:25:53.707Z ::ffff:127.0.0.1: M114 2026-06-08T15:25:59.281Z ::ffff:127.0.0.1: M114 +2026-06-08T16:15:02.308Z ::ffff:127.0.0.1: M114 +2026-06-08T16:15:02.316Z ::ffff:127.0.0.1: G1 X1 Y2 Z3 +2026-06-08T16:15:09.917Z ::ffff:127.0.0.1: M114 +2026-06-08T16:15:09.925Z ::ffff:127.0.0.1: G1 X1 Y2 Z3 +2026-06-08T16:15:18.670Z ::ffff:127.0.0.1: M114 +2026-06-08T16:15:18.679Z ::ffff:127.0.0.1: G1 X1 Y2 Z3 +2026-06-08T16:15:23.488Z ::ffff:127.0.0.1: M114 +2026-06-08T16:15:23.495Z ::ffff:127.0.0.1: G1 X1 Y2 Z3 +2026-06-08T16:15:31.077Z ::ffff:127.0.0.1: M114 +2026-06-08T16:15:31.094Z ::ffff:127.0.0.1: G1 X1 Y2 Z3 +2026-06-08T16:16:38.041Z ::ffff:127.0.0.1: M114 +2026-06-08T16:16:38.051Z ::ffff:127.0.0.1: G1 X1 Y2 Z3 +2026-06-08T16:17:00.361Z ::ffff:127.0.0.1: M114 +2026-06-08T16:17:00.370Z ::ffff:127.0.0.1: G1 X1 Y2 Z3 diff --git a/logs/pings.log b/logs/pings.log index 59c78a8..68a16ef 100644 --- a/logs/pings.log +++ b/logs/pings.log @@ -14559,3 +14559,10 @@ 2026-06-08T15:25:42.307Z ::ffff:127.0.0.1 : Ping 2026-06-08T15:25:53.690Z ::ffff:127.0.0.1 : Ping 2026-06-08T15:25:59.273Z ::ffff:127.0.0.1 : Ping +2026-06-08T16:15:02.289Z ::ffff:127.0.0.1 : Ping +2026-06-08T16:15:09.896Z ::ffff:127.0.0.1 : Ping +2026-06-08T16:15:18.652Z ::ffff:127.0.0.1 : Ping +2026-06-08T16:15:23.464Z ::ffff:127.0.0.1 : Ping +2026-06-08T16:15:31.061Z ::ffff:127.0.0.1 : Ping +2026-06-08T16:16:38.024Z ::ffff:127.0.0.1 : Ping +2026-06-08T16:17:00.351Z ::ffff:127.0.0.1 : Ping diff --git a/public/app.js b/public/app.js index a8388d8..5e63a6a 100644 --- a/public/app.js +++ b/public/app.js @@ -57,8 +57,10 @@ document.addEventListener('DOMContentLoaded', function() { sendersUl.innerHTML = ''; data.senders.forEach(sender => { const li = document.createElement('li'); - li.textContent = `${sender.name}: ${sender.state}`; - li.classList.add((sender.health || 'disconnected').toLowerCase()); + const state = sender.state || 'disconnected'; + const label = sender.url ? `${sender.name} (${sender.url}): ${state}` : `${sender.name}: ${state}`; + li.textContent = label; + li.classList.add(state.toLowerCase()); sendersUl.appendChild(li); }); diff --git a/public/style.css b/public/style.css index 9a5d1ed..4547fb3 100644 --- a/public/style.css +++ b/public/style.css @@ -121,6 +121,12 @@ h1 { content: "⛔"; } +/* 🟡 CONNECTING / RECONNECTING */ +.section#senders li.connecting::before, +.section#senders li.reconnecting::before { + content: "🟡"; +} + .state-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(25px, 1fr)); diff --git a/robot/TelnetSenderGRBL.js b/robot/TelnetSenderGRBL.js index af9ce75..20cf26e 100755 --- a/robot/TelnetSenderGRBL.js +++ b/robot/TelnetSenderGRBL.js @@ -387,7 +387,7 @@ module.exports = class TelnetSenderGRBL extends SenderInterface { // abhngig vom FluidNC und dessen speed interpretation ist. } - if(data.indexOf("G90") == -1 && data.indexOf("G1 ") > 0){ + if(data.indexOf("G90") == -1 && data.indexOf("G1 ") !== -1){ data = "G90 " + data; } diff --git a/robot/WSSenderGrbl.js b/robot/WSSenderGrbl.js index a16840a..fdb8137 100755 --- a/robot/WSSenderGrbl.js +++ b/robot/WSSenderGrbl.js @@ -387,8 +387,8 @@ module.exports = class WSSenderGrbl extends SenderInterface { data += " f" + (this.maxSpeedF.toFixed(2).toString()); - if (data.length > 3) { - if (data.indexOf("G90") == -1) { + if (this.ws && data.length > 3) { + if (data.indexOf("G90") == -1 && data.indexOf("G1 ") !== -1) { data = "G90 " + data; } console.log("Driver send to 🤖 " + this.urlGRBLstr + " the message: " + data); diff --git a/server/InputWS.js b/server/InputWS.js index c8da893..4ffd4d6 100644 --- a/server/InputWS.js +++ b/server/InputWS.js @@ -29,6 +29,7 @@ function initInputWS(server, robot, GCode, sharedState) { /* ---------- GCode ---------- */ if (GCode.containsCommand(message)) { console.log("🔵 GCode.receiveGCode: Incoming command: " + message); + logCommand(sharedState, clientIP, message); GCode.receiveGCode(robot, message); broadcast(wss, GCode.getM114(robot)); return; diff --git a/startRobot.js b/startRobot.js index e05b2ef..c3303fa 100755 --- a/startRobot.js +++ b/startRobot.js @@ -99,11 +99,13 @@ function createApp(options = {}) { consoleObj.warn(`Startup warning: ${disconnectedSenders.length} sender(s) disconnected at startup.`); } - setTimeoutFn(() => { - senders.forEach(s => { - if (s.instance?.tSocket) robot.cmdReceivers.push(s.instance); - }); - }, 5000); + // Register all senders as command receivers immediately and permanently. + // Each sender's execCommand() guards internally against sending while it is + // disconnected, and resumes automatically once it (re)connects — so there is + // no need to wait for a socket or to re-register after a reconnect. The old + // 5s one-shot registration silently dropped senders that connected later + // (e.g. after EHOSTUNREACH backoff) and never registered WebSocket senders. + senders.forEach(s => robot.cmdReceivers.push(s.instance)); const port = Number(processEnv.PORT) || 2095; httpsServer.listen(port); diff --git a/test/Sender.Telnet.test.js b/test/Sender.Telnet.test.js index 3d8ad1c..efb466d 100755 --- a/test/Sender.Telnet.test.js +++ b/test/Sender.Telnet.test.js @@ -25,8 +25,8 @@ describe("TelnetSenderGRBL.execCommand", () => { sender.execCommand("G1", mOld, mNew); - // ✅ verify output - expect(sender.tSocket.written).toBe("G1 x12.34 y90.00 z-90.00 f2300.00\r\n"); + // ✅ verify output — G1 moves must be sent in absolute mode (G90 prefix) + expect(sender.tSocket.written).toBe("G90 G1 x12.34 y90.00 z-90.00 f2300.00\r\n"); }); @@ -54,8 +54,8 @@ describe("TelnetSenderGRBL.execCommand", () => { sender.execCommand("G1", mOld, mNew); - // ✅ verify output - expect(sender.tSocket.written).toBe("G1 x22.50 f2300.00\r\n"); + // ✅ verify output — G1 moves must be sent in absolute mode (G90 prefix) + expect(sender.tSocket.written).toBe("G90 G1 x22.50 f2300.00\r\n"); }); test("writes correct G-code G92 to mocked tSocket", () => {