private static void resetAll() { core.discharge(); core = new ComCoreDummy(); for (Communication c : Communication.values()) { c.internal_reset(); } initThread.interrupt(); Communication.class.notifyAll(); }
@Override protected void internal_connect() throws MyException, InterruptedException { internal_reset(); // Wait for GRBL to reset (1 secound) Communication.doChangedEvent("Wait for GRBL Reset ..."); Communication.class.wait(3000); // SET absolute internal_send("$X"); doSendEvent("$X"); // 2 secound Timout for answer synchronized (Communication.class) { for (int i = 0; i < 20; i++) { Communication.class.wait(100); // give data the possibility to enter internal_receive! if (!core.isConnected()) { throw new MyException("Lost connection!"); } if (!internal_isbusy()) { break; } } } if (internal_isbusy()) { throw new MyException("Printer did not answer to $I!"); } }
@Override protected void internal_connect() throws MyException, InterruptedException { // try 3 times to get answare: for (int t = 0; t < 3; t++) { internal_reset(); // Send M110 to reset checksum internal_send("M110"); doSendEvent("M110"); // 5 secound Timout for answer for (int i = 0; i < 50; i++) { Communication.class.wait(100); // give data the possibility to enter internal_receive! if (!core.isConnected()) { throw new MyException("Lost connection! (" + status + ")"); } if (receiveCount > 0) { break; } } if (receiveCount > 0) { break; } Communication.doChangedEvent("Printer not answering to M110! Retrying ..."); } // Printer not answered! if (receiveCount == 0) { throw new MyException("Printer did not respond! Try to replug USB cable."); } // SET absolute internal_send("G90"); doSendEvent("G90"); // 2 secound Timout for answer synchronized (Communication.class) { for (int i = 0; i < 20; i++) { Communication.class.wait(100); // give data the possibility to enter internal_receive! if (!core.isConnected()) { throw new MyException("Lost connection!"); } if (!internal_isbusy()) { break; } } } if (internal_isbusy()) { throw new MyException("Printer did not answer to G90!"); } }