From dc6e8060a63a8b5615c6ff413ab54544649095b7 Mon Sep 17 00:00:00 2001 From: Joacim Breiler Date: Thu, 14 Dec 2023 19:45:31 +0100 Subject: [PATCH] Added a detection if echo mode is active and will only try to disable if it is. (#2392) This will prevent the echo disable command to be sent on channels that doesn't support them on FluidNC. --- .../firmware/fluidnc/FluidNCController.java | 7 +++- .../fluidnc/commands/DetectEchoCommand.java | 36 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/commands/DetectEchoCommand.java diff --git a/ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/FluidNCController.java b/ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/FluidNCController.java index 66a1c2290..2409b79c0 100644 --- a/ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/FluidNCController.java +++ b/ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/FluidNCController.java @@ -36,6 +36,7 @@ This file is part of Universal Gcode Sender (UGS). import com.willwinder.universalgcodesender.firmware.IFirmwareSettings; import static com.willwinder.universalgcodesender.firmware.fluidnc.FluidNCUtils.DISABLE_ECHO_COMMAND; import static com.willwinder.universalgcodesender.firmware.fluidnc.FluidNCUtils.GRBL_COMPABILITY_VERSION; +import com.willwinder.universalgcodesender.firmware.fluidnc.commands.DetectEchoCommand; import com.willwinder.universalgcodesender.firmware.fluidnc.commands.FluidNCCommand; import com.willwinder.universalgcodesender.firmware.fluidnc.commands.GetAlarmCodesCommand; import com.willwinder.universalgcodesender.firmware.fluidnc.commands.GetErrorCodesCommand; @@ -568,7 +569,11 @@ private void initializeController() { } private void disableEcho() throws Exception { - communicator.sendByteImmediately(DISABLE_ECHO_COMMAND); + DetectEchoCommand detectEchoCommand = sendAndWaitForCompletion(this, new DetectEchoCommand()); + if (detectEchoCommand.isEchoActivated()) { + LOGGER.log(Level.INFO, "Controller has echo activated, turning it off"); + communicator.sendByteImmediately(DISABLE_ECHO_COMMAND); + } } /** diff --git a/ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/commands/DetectEchoCommand.java b/ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/commands/DetectEchoCommand.java new file mode 100644 index 000000000..4373d3988 --- /dev/null +++ b/ugs-core/src/com/willwinder/universalgcodesender/firmware/fluidnc/commands/DetectEchoCommand.java @@ -0,0 +1,36 @@ +/* + Copyright 2023 Will Winder + + This file is part of Universal Gcode Sender (UGS). + + UGS is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + UGS is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with UGS. If not, see . + */ +package com.willwinder.universalgcodesender.firmware.fluidnc.commands; + +import com.willwinder.universalgcodesender.types.GcodeCommand; + +/** + * A command for detecting if echo mode is activated on the controller + * + * @author Joacim Breiler + */ +public class DetectEchoCommand extends GcodeCommand { + public DetectEchoCommand() { + super(""); + } + + public boolean isEchoActivated() { + return getResponse().equals("\nok"); + } +}