From c1b1468a755404fdb07d944cf649a0f98de04981 Mon Sep 17 00:00:00 2001 From: Joacim Breiler Date: Thu, 14 Dec 2023 19:37:59 +0100 Subject: [PATCH] Added a detection if echo mode is active and will only try to disable if it is. 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 66a1c22907..2409b79c05 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 0000000000..4373d39883 --- /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"); + } +}