This commit is contained in:
chk
2026-06-14 06:35:18 +02:00
parent b19489d836
commit 87cbd51bd2
6 changed files with 112 additions and 2 deletions

View File

@@ -10434,3 +10434,48 @@
2026-06-12T21:21:46.525Z ::ffff:127.0.0.1: M114 2026-06-12T21:21:46.525Z ::ffff:127.0.0.1: M114
2026-06-12T21:21:46.740Z ::ffff:127.0.0.1: G1 X1 Y2 Z3 2026-06-12T21:21:46.740Z ::ffff:127.0.0.1: G1 X1 Y2 Z3
2026-06-12T21:21:46.964Z ::ffff:127.0.0.1: G1 X1 2026-06-12T21:21:46.964Z ::ffff:127.0.0.1: G1 X1
2026-06-14T04:23:39.913Z ::ffff:127.0.0.1: M114
2026-06-14T04:23:39.926Z ::ffff:127.0.0.1: G1 X1 Y2 Z3
2026-06-14T04:23:40.100Z ::ffff:127.0.0.1: M114
2026-06-14T04:23:40.318Z ::ffff:127.0.0.1: G1 X1 Y2 Z3
2026-06-14T04:23:40.538Z ::ffff:127.0.0.1: G1 X1
2026-06-14T04:23:46.503Z ::ffff:127.0.0.1: M114
2026-06-14T04:23:46.523Z ::ffff:127.0.0.1: G1 X1 Y2 Z3
2026-06-14T04:23:46.722Z ::ffff:127.0.0.1: M114
2026-06-14T04:23:46.942Z ::ffff:127.0.0.1: G1 X1 Y2 Z3
2026-06-14T04:23:47.170Z ::ffff:127.0.0.1: G1 X1
2026-06-14T04:23:47.897Z ::ffff:127.0.0.1: M114
2026-06-14T04:23:48.113Z ::ffff:127.0.0.1: G1 X1 Y2 Z3
2026-06-14T04:23:48.343Z ::ffff:127.0.0.1: G1 X1
2026-06-14T04:23:49.312Z ::ffff:127.0.0.1: M114
2026-06-14T04:23:49.323Z ::ffff:127.0.0.1: G1 X1 Y2 Z3
2026-06-14T04:23:51.159Z ::ffff:127.0.0.1: M114
2026-06-14T04:23:51.176Z ::ffff:127.0.0.1: G1 X1 Y2 Z3
2026-06-14T04:23:51.457Z ::ffff:127.0.0.1: M114
2026-06-14T04:23:51.671Z ::ffff:127.0.0.1: G1 X1 Y2 Z3
2026-06-14T04:23:51.903Z ::ffff:127.0.0.1: G1 X1
2026-06-14T04:25:08.160Z ::ffff:127.0.0.1: M114
2026-06-14T04:25:08.217Z ::ffff:127.0.0.1: M114
2026-06-14T04:25:08.237Z ::ffff:127.0.0.1: G1 X1 Y2 Z3
2026-06-14T04:25:08.387Z ::ffff:127.0.0.1: G1 X1 Y2 Z3
2026-06-14T04:25:08.630Z ::ffff:127.0.0.1: G1 X1
2026-06-14T04:25:30.816Z ::ffff:127.0.0.1: M114
2026-06-14T04:25:30.961Z ::ffff:127.0.0.1: M114
2026-06-14T04:25:30.973Z ::ffff:127.0.0.1: G1 X1 Y2 Z3
2026-06-14T04:25:31.040Z ::ffff:127.0.0.1: G1 X1 Y2 Z3
2026-06-14T04:25:31.264Z ::ffff:127.0.0.1: G1 X1
2026-06-14T04:26:12.885Z ::ffff:127.0.0.1: M114
2026-06-14T04:26:12.958Z ::ffff:127.0.0.1: M114
2026-06-14T04:26:12.975Z ::ffff:127.0.0.1: G1 X1 Y2 Z3
2026-06-14T04:26:13.108Z ::ffff:127.0.0.1: G1 X1 Y2 Z3
2026-06-14T04:26:13.339Z ::ffff:127.0.0.1: G1 X1
2026-06-14T04:33:34.837Z ::ffff:127.0.0.1: M114
2026-06-14T04:33:34.919Z ::ffff:127.0.0.1: M114
2026-06-14T04:33:34.936Z ::ffff:127.0.0.1: G1 X1 Y2 Z3
2026-06-14T04:33:35.058Z ::ffff:127.0.0.1: G1 X1 Y2 Z3
2026-06-14T04:33:35.280Z ::ffff:127.0.0.1: G1 X1
2026-06-14T04:33:51.635Z ::ffff:127.0.0.1: M114
2026-06-14T04:33:51.788Z ::ffff:127.0.0.1: M114
2026-06-14T04:33:51.805Z ::ffff:127.0.0.1: G1 X1 Y2 Z3
2026-06-14T04:33:51.860Z ::ffff:127.0.0.1: G1 X1 Y2 Z3
2026-06-14T04:33:52.102Z ::ffff:127.0.0.1: G1 X1

View File

@@ -14648,3 +14648,21 @@
2026-06-12T21:15:19.098Z ::ffff:127.0.0.1 : Ping 2026-06-12T21:15:19.098Z ::ffff:127.0.0.1 : Ping
2026-06-12T21:21:46.291Z ::ffff:127.0.0.1 : Ping 2026-06-12T21:21:46.291Z ::ffff:127.0.0.1 : Ping
2026-06-12T21:21:46.316Z ::ffff:127.0.0.1 : Ping 2026-06-12T21:21:46.316Z ::ffff:127.0.0.1 : Ping
2026-06-14T04:23:39.866Z ::ffff:127.0.0.1 : Ping
2026-06-14T04:23:39.872Z ::ffff:127.0.0.1 : Ping
2026-06-14T04:23:46.466Z ::ffff:127.0.0.1 : Ping
2026-06-14T04:23:46.468Z ::ffff:127.0.0.1 : Ping
2026-06-14T04:23:47.681Z ::ffff:127.0.0.1 : Ping
2026-06-14T04:23:49.303Z ::ffff:127.0.0.1 : Ping
2026-06-14T04:23:51.124Z ::ffff:127.0.0.1 : Ping
2026-06-14T04:23:51.201Z ::ffff:127.0.0.1 : Ping
2026-06-14T04:25:07.898Z ::ffff:127.0.0.1 : Ping
2026-06-14T04:25:08.193Z ::ffff:127.0.0.1 : Ping
2026-06-14T04:25:30.562Z ::ffff:127.0.0.1 : Ping
2026-06-14T04:25:30.931Z ::ffff:127.0.0.1 : Ping
2026-06-14T04:26:12.639Z ::ffff:127.0.0.1 : Ping
2026-06-14T04:26:12.931Z ::ffff:127.0.0.1 : Ping
2026-06-14T04:33:34.572Z ::ffff:127.0.0.1 : Ping
2026-06-14T04:33:34.893Z ::ffff:127.0.0.1 : Ping
2026-06-14T04:33:51.379Z ::ffff:127.0.0.1 : Ping
2026-06-14T04:33:51.767Z ::ffff:127.0.0.1 : Ping

View File

@@ -106,7 +106,7 @@ class RobotController {
return; return;
} }
if (cmd === 'M92') { if (cmd === 'M92' || cmd === 'G92') {
robot.createMotorPosition(); robot.createMotorPosition();
if (Number.isFinite(params.X)) { robot.xMotor = params.X; robot.xMotorChanged = true; } if (Number.isFinite(params.X)) { robot.xMotor = params.X; robot.xMotorChanged = true; }
if (Number.isFinite(params.Y)) { robot.alpha = params.Y; robot.yMotorChanged = true; } if (Number.isFinite(params.Y)) { robot.alpha = params.Y; robot.yMotorChanged = true; }

View File

@@ -544,7 +544,7 @@ module.exports = class TelnetSenderGRBL extends SenderInterface {
if(this.aAxisGrbl == "x" && mNew.xMotorChanged && Number.isFinite(mNew.y)){ if(this.aAxisGrbl == "x" && mNew.xMotorChanged && Number.isFinite(mNew.x)){
data += " a" + (mNew.y * 180 / Math.PI).toFixed(2).toString(); data += " a" + (mNew.y * 180 / Math.PI).toFixed(2).toString();
} }
if(this.aAxisGrbl == "y" && mNew.yMotorChanged && Number.isFinite(mNew.y)){ if(this.aAxisGrbl == "y" && mNew.yMotorChanged && Number.isFinite(mNew.y)){

View File

@@ -51,6 +51,34 @@ describe('RobotController (ToDo_6)', () => {
expect(robot.sendCommand).toHaveBeenCalled(); expect(robot.sendCommand).toHaveBeenCalled();
}); });
test('applyCommand: M92 setzt Motorwerte absolut und sendet G92', () => {
const robot = createDummyRobot();
robot.createMotorPosition = jest.fn();
RobotController.applyCommand(robot, { command: 'M92', params: { X: 5, Y: 0.5, A: 0.3 } });
expect(robot.createMotorPosition).toHaveBeenCalledTimes(1);
expect(robot.xMotor).toBe(5);
expect(robot.alpha).toBe(0.5);
expect(robot.a).toBe(0.3);
expect(robot.calculatePositionFromMotorAngles).toHaveBeenCalled();
expect(robot.sendCommand).toHaveBeenCalledWith('G92');
});
test('applyCommand: G92 verhält sich identisch zu M92 (Bug 3)', () => {
const robot = createDummyRobot();
robot.createMotorPosition = jest.fn();
RobotController.applyCommand(robot, { command: 'G92', params: { X: 5, Y: 0.5, A: 0.3 } });
expect(robot.createMotorPosition).toHaveBeenCalledTimes(1);
expect(robot.xMotor).toBe(5);
expect(robot.alpha).toBe(0.5);
expect(robot.a).toBe(0.3);
expect(robot.calculatePositionFromMotorAngles).toHaveBeenCalled();
expect(robot.sendCommand).toHaveBeenCalledWith('G92');
});
test('applyCommand: ungültiger Befehl wird ignoriert', () => { test('applyCommand: ungültiger Befehl wird ignoriert', () => {
const robot = createDummyRobot(); const robot = createDummyRobot();
RobotController.applyCommand(robot, null); RobotController.applyCommand(robot, null);

View File

@@ -84,4 +84,23 @@ describe("TelnetSenderGRBL.execCommand", () => {
expect(sender.tSocket.written).toBe("G92 x12.34 y57.30 z57.30\r\n"); expect(sender.tSocket.written).toBe("G92 x12.34 y57.30 z57.30\r\n");
}); });
test("aAxisGrbl guard prüft mNew.x, nicht mNew.y (Bug 5)", () => {
// Sender mit aAxisGrbl = "x": GRBL-a-Achse bekommt xMotor
const sender = new TenetSender("test.test", 2300, null, null, null, "x");
sender.tSocket = {
written: "",
write: function(txt) { this.written = txt; }
};
const mOld = { x: 0, y: 0, z: 0, a: 0, b: 0, c: 0, e: 0 };
// mNew.x ist NaN (ungültig), mNew.y ist finite — alter Bug würde Guard passieren lassen
const mNew = { x: NaN, y: 1.0, z: 0, a: 0, b: 0, c: 0, e: 0 };
mNew.xMotorChanged = true;
sender.execCommand("G1", mOld, mNew);
// Guard muss auf mNew.x prüfen — da NaN, darf kein "a"-Wert gesendet werden
expect(sender.tSocket.written).not.toContain(" a");
});
}); });