From 837d81d73c053401a6fe6802d6efe6ac49aa99aa Mon Sep 17 00:00:00 2001 From: Joacim Breiler Date: Wed, 9 Aug 2023 18:17:49 +0200 Subject: [PATCH] Fixed a problem with grblHAL where certain responses were treated as parser state commands. (#2275) --- .../com/willwinder/universalgcodesender/GrblController.java | 6 +++++- .../universalgcodesender/GrblControllerInitializer.java | 5 ----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ugs-core/src/com/willwinder/universalgcodesender/GrblController.java b/ugs-core/src/com/willwinder/universalgcodesender/GrblController.java index 4256b3541..81e1bfa8b 100644 --- a/ugs-core/src/com/willwinder/universalgcodesender/GrblController.java +++ b/ugs-core/src/com/willwinder/universalgcodesender/GrblController.java @@ -164,6 +164,9 @@ private void initialize() { positionPollTimer.stop(); initializer.initialize(); capabilities = GrblUtils.getGrblStatusCapabilities(initializer.getVersion().getVersionNumber(), initializer.getVersion().getVersionLetter()); + + // Toggle the state to force UI update + setControllerState(ControllerState.CONNECTING); positionPollTimer.start(); }); } @@ -232,7 +235,8 @@ else if (GrblUtils.isGrblStatusString(response)) { this.checkStreamFinished(); } - else if (GrblUtils.isGrblFeedbackMessage(response, capabilities)) { + // We can only parse feedback messages when we know what capabilities the controller have + else if (initializer.isInitialized() && GrblUtils.isGrblFeedbackMessage(response, capabilities)) { GrblFeedbackMessage grblFeedbackMessage = new GrblFeedbackMessage(response); // Convert feedback message to raw commands to update modal state. updateParserModalState(getCommandCreator().createCommand(GrblUtils.parseFeedbackMessage(response, capabilities))); diff --git a/ugs-core/src/com/willwinder/universalgcodesender/GrblControllerInitializer.java b/ugs-core/src/com/willwinder/universalgcodesender/GrblControllerInitializer.java index 04c21945f..5ca3d465f 100644 --- a/ugs-core/src/com/willwinder/universalgcodesender/GrblControllerInitializer.java +++ b/ugs-core/src/com/willwinder/universalgcodesender/GrblControllerInitializer.java @@ -57,14 +57,9 @@ public boolean initialize() { return false; } - // Toggle the state to force UI update - controller.setControllerState(ControllerState.CONNECTING); - controller.setControllerState(ControllerState.IDLE); - fetchControllerState(); messageService.dispatchMessage(MessageType.INFO, String.format("*** Connected to %s\n", version.toString())); - controller.requestStatusReport(); isInitialized.set(true); isInitializing.set(false); return true;