Skip to content

Commit

Permalink
Fixed connection problem with GRBL_ESP32 in wifi mode (#2583)
Browse files Browse the repository at this point in the history
It requires a small pause between querying the status and fetching the build information.
  • Loading branch information
breiler authored Aug 1, 2024
1 parent b93cf32 commit a9fb590
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
import com.willwinder.universalgcodesender.firmware.grbl.commands.GetSettingsCommand;
import com.willwinder.universalgcodesender.listeners.ControllerState;
import com.willwinder.universalgcodesender.listeners.MessageType;
import static com.willwinder.universalgcodesender.utils.ControllerUtils.sendAndWaitForCompletion;

import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.logging.Logger;

import static com.willwinder.universalgcodesender.utils.ControllerUtils.sendAndWaitForCompletion;

/**
* A class that implements an initialization protocol for GRBL and keeps an internal state of the
* connection process. The query process will not require the controller to be reset which is needed
Expand Down Expand Up @@ -50,6 +49,7 @@ public boolean initialize() throws ControllerException{
controller.setControllerState(ControllerState.CONNECTING);
isInitializing.set(true);
try {
// Some controllers need this wait before we can query its status
Thread.sleep(2000);
if (!GrblUtils.isControllerResponsive(controller)) {
isInitializing.set(false);
Expand All @@ -58,6 +58,8 @@ public boolean initialize() throws ControllerException{
return false;
}

// Some controllers need this wait before we can query the rest of its information
Thread.sleep(2000);
fetchControllerVersion();
fetchControllerState();

Expand Down Expand Up @@ -110,6 +112,10 @@ public boolean isInitialized() {
return isInitialized.get();
}

public boolean isInitializing() {
return isInitializing.get();
}

public GrblVersion getVersion() {
return version;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,6 @@ private GrblController initializeAndConnectController(String grblVersionString)
instance.openCommPort(getSettings().getConnectionDriver(), "/dev/port", 1234);
Thread.sleep(50);

instance.rawResponseHandler(grblVersionString);
return instance;
}
}

0 comments on commit a9fb590

Please sign in to comment.