From 00a2db8951c325d54465ca4eedb60903d9e73d87 Mon Sep 17 00:00:00 2001 From: Joacim Breiler Date: Fri, 25 Oct 2024 07:42:16 +0200 Subject: [PATCH 1/2] Filter messages from command response --- .../fluidnc/commands/FluidNCCommand.java | 5 ++++ .../commands/GetFirmwareSettingsCommand.java | 5 ++++ .../GetFirmwareSettingsCommandTest.java | 26 ++++++++++++++++--- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/commands/FluidNCCommand.java b/ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/commands/FluidNCCommand.java index c86d27fa90..10f2208191 100644 --- a/ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/commands/FluidNCCommand.java +++ b/ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/commands/FluidNCCommand.java @@ -53,6 +53,11 @@ public void appendResponse(String response) { return; } + // Do not append messages + if (response.startsWith("[MSG:")) { + return; + } + super.appendResponse(response); if (response.startsWith("ok")) { diff --git a/ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/commands/GetFirmwareSettingsCommand.java b/ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/commands/GetFirmwareSettingsCommand.java index fda9378011..e84b778c12 100644 --- a/ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/commands/GetFirmwareSettingsCommand.java +++ b/ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/commands/GetFirmwareSettingsCommand.java @@ -36,6 +36,11 @@ public GetFirmwareSettingsCommand() { super("$Config/Dump"); } + @Override + public void appendResponse(String response) { + super.appendResponse(response); + } + public Map getSettings() { if (!isOk()) { return new HashMap<>(); diff --git a/ugs-core/test/com/willwinder/universalgcodesender/firmware/fluidnc/commands/GetFirmwareSettingsCommandTest.java b/ugs-core/test/com/willwinder/universalgcodesender/firmware/fluidnc/commands/GetFirmwareSettingsCommandTest.java index e820207641..6db79f9008 100644 --- a/ugs-core/test/com/willwinder/universalgcodesender/firmware/fluidnc/commands/GetFirmwareSettingsCommandTest.java +++ b/ugs-core/test/com/willwinder/universalgcodesender/firmware/fluidnc/commands/GetFirmwareSettingsCommandTest.java @@ -1,13 +1,12 @@ package com.willwinder.universalgcodesender.firmware.fluidnc.commands; import com.willwinder.universalgcodesender.types.CommandException; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; -import static org.junit.Assert.assertTrue; import org.junit.Test; import java.util.Map; +import static org.junit.Assert.*; + public class GetFirmwareSettingsCommandTest { @Test public void appendResponseWithYamlConfigShouldParseSettingsAsYaml() { @@ -29,6 +28,27 @@ public void appendResponseWithYamlConfigShouldParseSettingsAsYaml() { assertEquals("800", settings.get("axis/y/steps_per_mm")); } + @Test + public void appendResponseShouldIgnoreMessages() { + GetFirmwareSettingsCommand command = new GetFirmwareSettingsCommand(); + command.appendResponse("axis:"); + command.appendResponse(" shared_stepper_disable_pin: gpio.13:low"); + command.appendResponse(" shared_stepper_reset_pin: NO_PIN"); + command.appendResponse(" x:"); + command.appendResponse("[MSG:INFO: Huanyang PD014 Accel:6.000]"); + command.appendResponse(" steps_per_mm: 800"); + command.appendResponse(" y:"); + command.appendResponse(" steps_per_mm: 800"); + command.appendResponse("ok"); + + Map settings = command.getSettings(); + assertEquals(4, settings.keySet().size()); + assertEquals("gpio.13:low", settings.get("axis/shared_stepper_disable_pin")); + assertEquals("NO_PIN", settings.get("axis/shared_stepper_reset_pin")); + assertEquals("800", settings.get("axis/x/steps_per_mm")); + assertEquals("800", settings.get("axis/y/steps_per_mm")); + } + @Test public void getSettingsShouldThrowExceptionOnFaultyYaml() { GetFirmwareSettingsCommand command = new GetFirmwareSettingsCommand(); From cf8588c812e11d7045cd3ab4b196a1b0e77cf3c4 Mon Sep 17 00:00:00 2001 From: Joacim Breiler Date: Fri, 25 Oct 2024 07:42:39 +0200 Subject: [PATCH 2/2] Filter messages from command response --- .../fluidnc/commands/GetFirmwareSettingsCommand.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/commands/GetFirmwareSettingsCommand.java b/ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/commands/GetFirmwareSettingsCommand.java index e84b778c12..fda9378011 100644 --- a/ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/commands/GetFirmwareSettingsCommand.java +++ b/ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/commands/GetFirmwareSettingsCommand.java @@ -36,11 +36,6 @@ public GetFirmwareSettingsCommand() { super("$Config/Dump"); } - @Override - public void appendResponse(String response) { - super.appendResponse(response); - } - public Map getSettings() { if (!isOk()) { return new HashMap<>();