Arduino gets stuck with G-codes October 08, 2009 04:15PM |
Registered: 14 years ago Posts: 17 |
Re: Arduino gets stuck with G-codes October 08, 2009 05:18PM |
Registered: 16 years ago Posts: 169 |
Re: Arduino gets stuck with G-codes October 09, 2009 02:09AM |
Registered: 14 years ago Posts: 17 |
Re: Arduino gets stuck with G-codes October 09, 2009 03:37AM |
Registered: 15 years ago Posts: 62 |
Re: Arduino gets stuck with G-codes October 09, 2009 04:07AM |
Registered: 16 years ago Posts: 467 |
Re: Arduino gets stuck with G-codes October 09, 2009 08:01AM |
Registered: 16 years ago Posts: 169 |
Re: Arduino gets stuck with G-codes October 09, 2009 08:17AM |
Registered: 14 years ago Posts: 17 |
Re: Arduino gets stuck with G-codes October 09, 2009 03:23PM |
Registered: 16 years ago Posts: 169 |
Re: Arduino gets stuck with G-codes October 10, 2009 03:11AM |
Registered: 14 years ago Posts: 17 |
Re: Arduino gets stuck with G-codes October 10, 2009 05:22AM |
Registered: 15 years ago Posts: 62 |
Re: Arduino gets stuck with G-codes October 10, 2009 07:55AM |
Registered: 14 years ago Posts: 17 |
Re: Arduino gets stuck with G-codes October 11, 2009 08:40AM |
Registered: 14 years ago Posts: 17 |
/** * Send the g-codes to the machine * @param gcodes */ public void sendToMachine(List gcodes)throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("COM4"); if ( portIdentifier.isCurrentlyOwned() ) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = portIdentifier.open(this.getClass().getName(),2000); if ( commPort instanceof SerialPort ) { SerialPort serialPort = (SerialPort) commPort; serialPort.setSerialPortParams(4800,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE); InputStream in = serialPort.getInputStream(); OutputStream out = serialPort.getOutputStream(); byte[] buffer = new byte[1024]; int len = -1; String matchString = "started"; int count = 0; try { String val = ""; while ( (len = in.read(buffer)) > -1 ) { if(len > 0) val += new String(buffer,0,len); if(val.endsWith("\n")){ if(val.startsWith(matchString)) { if(matchString.equals("started")) // initing matchString = "Done"; // after that it is all 'Done' only out.write(gcodes.get(count).toString().getBytes()); count++; } val = ""; } if(count == gcodes.size()) break; } serialPort.close(); } catch ( IOException e ) { e.printStackTrace(); } } } }