diff --git a/.gitignore b/.gitignore index b25c15b..d0713c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,7 @@ *~ +lasercut_v0.5.zip +lasercut_v0.5.zip +NatBrailleTools/BrailleLogger/bin/Braille2GcodeEncoder.class +NatBrailleTools/BrailleLogger/bin/Braille6GcodeEncoding.class +NatBrailleTools/BrailleLogger/bin/BrailleLogger.class +NatBrailleTools/BrailleLogger/bin/GCodeGenerator.class diff --git a/NatBrailleTools/BrailleLogger/ant/braillelogger_ant_build.xml b/NatBrailleTools/BrailleLogger/ant/braillelogger_ant_build.xml new file mode 100644 index 0000000..63b6d2c --- /dev/null +++ b/NatBrailleTools/BrailleLogger/ant/braillelogger_ant_build.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/NatBrailleTools/BrailleLogger/ant/jar-in-jar-loader.zip b/NatBrailleTools/BrailleLogger/ant/jar-in-jar-loader.zip new file mode 100644 index 0000000..4ee2ee6 Binary files /dev/null and b/NatBrailleTools/BrailleLogger/ant/jar-in-jar-loader.zip differ diff --git a/NatBrailleTools/BrailleLogger/bin/Braille2GcodeEncoder.class b/NatBrailleTools/BrailleLogger/bin/Braille2GcodeEncoder.class index cd03adb..bc855d9 100644 Binary files a/NatBrailleTools/BrailleLogger/bin/Braille2GcodeEncoder.class and b/NatBrailleTools/BrailleLogger/bin/Braille2GcodeEncoder.class differ diff --git a/NatBrailleTools/BrailleLogger/bin/Braille6GcodeEncoding.class b/NatBrailleTools/BrailleLogger/bin/Braille6GcodeEncoding.class index 5c97c4e..edbd0ba 100644 Binary files a/NatBrailleTools/BrailleLogger/bin/Braille6GcodeEncoding.class and b/NatBrailleTools/BrailleLogger/bin/Braille6GcodeEncoding.class differ diff --git a/NatBrailleTools/BrailleLogger/bin/BrailleLogger.class b/NatBrailleTools/BrailleLogger/bin/BrailleLogger.class index 22f819b..68c2044 100644 Binary files a/NatBrailleTools/BrailleLogger/bin/BrailleLogger.class and b/NatBrailleTools/BrailleLogger/bin/BrailleLogger.class differ diff --git a/NatBrailleTools/BrailleLogger/bin/GCodeGenerator.class b/NatBrailleTools/BrailleLogger/bin/GCodeGenerator.class index 6731139..5025765 100644 Binary files a/NatBrailleTools/BrailleLogger/bin/GCodeGenerator.class and b/NatBrailleTools/BrailleLogger/bin/GCodeGenerator.class differ diff --git a/NatBrailleTools/BrailleLogger/bin/braillelogger_ant_build.xml b/NatBrailleTools/BrailleLogger/bin/braillelogger_ant_build.xml new file mode 100644 index 0000000..ce8f352 --- /dev/null +++ b/NatBrailleTools/BrailleLogger/bin/braillelogger_ant_build.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/NatBrailleTools/BrailleLogger/src/BrailleLogger.java b/NatBrailleTools/BrailleLogger/src/BrailleLogger.java index 6de2fb3..a3d6b0f 100644 --- a/NatBrailleTools/BrailleLogger/src/BrailleLogger.java +++ b/NatBrailleTools/BrailleLogger/src/BrailleLogger.java @@ -29,7 +29,7 @@ public class BrailleLogger { System.out.println(";" + s); } - if (args[0] != null) + if (args.length > 0) { FileReader fr; Braille2GcodeEncoder encoder = new Braille2GcodeEncoder(new Braille6GcodeEncoding()); diff --git a/NatBrailleTools/bin/braillelogger.jar b/NatBrailleTools/bin/braillelogger.jar new file mode 100644 index 0000000..344c0ba Binary files /dev/null and b/NatBrailleTools/bin/braillelogger.jar differ diff --git a/NatBrailleTools/bin/gcodestreamer.jar b/NatBrailleTools/bin/gcodestreamer.jar new file mode 100644 index 0000000..4ce227c Binary files /dev/null and b/NatBrailleTools/bin/gcodestreamer.jar differ diff --git a/NatBrailleTools/gcodestreamer/.classpath b/NatBrailleTools/gcodestreamer/.classpath new file mode 100644 index 0000000..c66687b --- /dev/null +++ b/NatBrailleTools/gcodestreamer/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/NatBrailleTools/simpleJavaGrblStreamer/.project b/NatBrailleTools/gcodestreamer/.project similarity index 62% rename from NatBrailleTools/simpleJavaGrblStreamer/.project rename to NatBrailleTools/gcodestreamer/.project index 1ff8812..b4650e9 100644 --- a/NatBrailleTools/simpleJavaGrblStreamer/.project +++ b/NatBrailleTools/gcodestreamer/.project @@ -1,6 +1,6 @@ - simpleJavaGrblStreamer + gcodestreamer @@ -10,14 +10,8 @@ - - org.eclipse.m2e.core.maven2Builder - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature diff --git a/NatBrailleTools/gcodestreamer/.settings/org.eclipse.jdt.core.prefs b/NatBrailleTools/gcodestreamer/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..3a21537 --- /dev/null +++ b/NatBrailleTools/gcodestreamer/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/NatBrailleTools/gcodestreamer/ant/gcodestreamer_ant_build.xml b/NatBrailleTools/gcodestreamer/ant/gcodestreamer_ant_build.xml new file mode 100644 index 0000000..7719f64 --- /dev/null +++ b/NatBrailleTools/gcodestreamer/ant/gcodestreamer_ant_build.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/NatBrailleTools/gcodestreamer/ant/jar-in-jar-loader.zip b/NatBrailleTools/gcodestreamer/ant/jar-in-jar-loader.zip new file mode 100644 index 0000000..4ee2ee6 Binary files /dev/null and b/NatBrailleTools/gcodestreamer/ant/jar-in-jar-loader.zip differ diff --git a/NatBrailleTools/gcodestreamer/bin/.gitignore b/NatBrailleTools/gcodestreamer/bin/.gitignore new file mode 100644 index 0000000..c2d9872 --- /dev/null +++ b/NatBrailleTools/gcodestreamer/bin/.gitignore @@ -0,0 +1 @@ +/com/ diff --git a/NatBrailleTools/gcodestreamer/src/com/willwinder/sjgs/simplejavagrblstreamer/SimpleJavaGrblStreamer.java b/NatBrailleTools/gcodestreamer/src/com/willwinder/sjgs/simplejavagrblstreamer/SimpleJavaGrblStreamer.java new file mode 100644 index 0000000..ba97fc3 --- /dev/null +++ b/NatBrailleTools/gcodestreamer/src/com/willwinder/sjgs/simplejavagrblstreamer/SimpleJavaGrblStreamer.java @@ -0,0 +1,176 @@ +package com.willwinder.sjgs.simplejavagrblstreamer; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.LinkedList; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.logging.Level; +import java.util.logging.Logger; +import jssc.SerialPort; +import jssc.SerialPortEvent; +import jssc.SerialPortEventListener; +import jssc.SerialPortException; + +/** + * + * @author wwinder + */ +public class SimpleJavaGrblStreamer { + static int GRBL_BUFFER_SIZE = 125; + + public static void main(String argv[]) throws SerialPortException, IOException, InterruptedException { + if (argv.length == 0) + { + System.out.println("Arguments: "); + return; + } + if (argv.length != 3 && argv.length != 2) { + System.out.println("Arguments: "); + return; + } + + String commPort = argv[0]; + Integer baud = Integer.parseInt(argv[1]); + InputStream file = null; + if (argv.length == 2) + file = System.in; + else { + file = new FileInputStream(argv[2]); + System.out.println("Streaming file " + argv[2]); + } + + System.out.println("Streaming to port <" + commPort + " : " + baud + ">"); + SimpleJavaGrblStreamer s = new SimpleJavaGrblStreamer(commPort, baud); + s.send(file); + + System.out.println("Done senting file."); + } + + String commPort = null; + Integer baud = null; + + private SimpleJavaGrblStreamer(String commPort, Integer baud) { + this.commPort = commPort; + this.baud = baud; + } + + private void send(InputStream f) throws SerialPortException, IOException, InterruptedException { + BlockingQueue commandComplete = new LinkedBlockingQueue(); + + SerialPort serialPort = new SerialPort(commPort); + serialPort.openPort(); + serialPort.setParams(baud, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE, true, true); + + Thread.sleep(5000); + + serialPort.addEventListener(new GrblSerialListener(serialPort, commandComplete)); + GrblSerialSender sender = new GrblSerialSender(f, serialPort, commandComplete, GRBL_BUFFER_SIZE); + sender.send(); + serialPort.closePort(); + } + + private static class GrblSerialListener implements SerialPortEventListener { + SerialPort serialPort = null; + BlockingQueue completedCommands; + StringBuilder inputBuffer; + private GrblSerialListener(SerialPort port, BlockingQueue completedCommands) { + this.serialPort = port; + this.completedCommands = completedCommands; + inputBuffer = new StringBuilder(); + } + + @Override + public void serialEvent(SerialPortEvent event) { + if(event.isRXCHAR() && event.getEventValue() > 0){ + try { + byte buffer[] = serialPort.readBytes(); + for (byte b: buffer) { + if (b == '\n') { + //System.out.println("Received command: " + inputBuffer.toString()); + if (inputBuffer.toString().startsWith("ok") || inputBuffer.toString().startsWith("error")) + completedCommands.add(1); + inputBuffer.setLength(0); + } else { + inputBuffer.append((char)b); + } + } + } + catch (SerialPortException ex) { + System.out.println(ex); + System.out.println("serialEvent"); + } + } + } + } + + private static class GrblSerialSender { + InputStream file = null; + SerialPort port = null; + Integer currentBufferSize = null; + Integer maxBufferSize = null; + + BlockingQueue completedCommands = null; + LinkedList activeCommandSizes; + + private GrblSerialSender(InputStream f, SerialPort sp, BlockingQueue completedCommands, Integer activeBufferSize) { + file = f; + port = sp; + maxBufferSize = activeBufferSize; + currentBufferSize = 0; + this.completedCommands = completedCommands; + activeCommandSizes = new LinkedList(); + } + + private void send() throws IOException { + // Java 8 + //try(Stream lines = Files.lines(Paths.get(file.getAbsolutePath()))){ + // lines.forEach(s -> sendLine(s)); + //} + + BufferedReader br = null; + try { + String sCurrentLine; + br = new BufferedReader(new InputStreamReader(file)); + while ((sCurrentLine = br.readLine()) != null) { + sendLine(sCurrentLine); + } + } finally { + if (br != null)br.close(); + } + } + + private void sendLine(String s) { + // Wait until there is room, if necessary. + while (maxBufferSize < (currentBufferSize + s.length() + 1)) { + try { + //System.out.println("waiting for room.... active command count: " + this.activeCommandSizes.size()); + + // Wait for a command to complete + completedCommands.take(); + currentBufferSize -= this.activeCommandSizes.removeFirst(); + } catch (InterruptedException ex) { + Logger.getLogger(SimpleJavaGrblStreamer.class.getName()).log(Level.SEVERE, null, ex); + return; + } + } + + try { + System.out.println("Sending command: " + s.trim()); + //System.out.printf("."); + this.port.writeString(s.trim() + "\n"); + int commandSize = s.length() + 1; + activeCommandSizes.add(commandSize); + currentBufferSize += commandSize; + } catch (SerialPortException ex) { + Logger.getLogger(SimpleJavaGrblStreamer.class.getName()).log(Level.SEVERE, null, ex); + return; + } + } + } +} diff --git a/NatBrailleTools/simpleJavaGrblStreamer/.classpath b/NatBrailleTools/simpleJavaGrblStreamer/.classpath deleted file mode 100644 index fd7ad7f..0000000 --- a/NatBrailleTools/simpleJavaGrblStreamer/.classpath +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/NatBrailleTools/simpleJavaGrblStreamer/.gitignore b/NatBrailleTools/simpleJavaGrblStreamer/.gitignore deleted file mode 100644 index b83d222..0000000 --- a/NatBrailleTools/simpleJavaGrblStreamer/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target/ diff --git a/NatBrailleTools/simpleJavaGrblStreamer/.settings/org.eclipse.core.resources.prefs b/NatBrailleTools/simpleJavaGrblStreamer/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index e9441bb..0000000 --- a/NatBrailleTools/simpleJavaGrblStreamer/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding/=UTF-8 diff --git a/NatBrailleTools/simpleJavaGrblStreamer/.settings/org.eclipse.jdt.core.prefs b/NatBrailleTools/simpleJavaGrblStreamer/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 60105c1..0000000 --- a/NatBrailleTools/simpleJavaGrblStreamer/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/NatBrailleTools/simpleJavaGrblStreamer/.settings/org.eclipse.m2e.core.prefs b/NatBrailleTools/simpleJavaGrblStreamer/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f..0000000 --- a/NatBrailleTools/simpleJavaGrblStreamer/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/NatBrailleTools/simpleJavaGrblStreamer/LICENSE b/NatBrailleTools/simpleJavaGrblStreamer/LICENSE deleted file mode 100644 index 3ffdaba..0000000 --- a/NatBrailleTools/simpleJavaGrblStreamer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Will Winder - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/NatBrailleTools/simpleJavaGrblStreamer/README.md b/NatBrailleTools/simpleJavaGrblStreamer/README.md deleted file mode 100644 index a26b741..0000000 --- a/NatBrailleTools/simpleJavaGrblStreamer/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# simpleJavaGrblStreamer - -A minimal Java application to stream a file to GRBL as quickly as possible. - -Uses a blocking queue to send events from the serial event thread to the main thread which is sending the file. - -Build with "mvn compile assembly:single" - -Run with "java -jar " diff --git a/NatBrailleTools/simpleJavaGrblStreamer/ant/gcodestreamer_ant_build.xml b/NatBrailleTools/simpleJavaGrblStreamer/ant/gcodestreamer_ant_build.xml new file mode 100644 index 0000000..7719f64 --- /dev/null +++ b/NatBrailleTools/simpleJavaGrblStreamer/ant/gcodestreamer_ant_build.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/NatBrailleTools/simpleJavaGrblStreamer/ant/jar-in-jar-loader.zip b/NatBrailleTools/simpleJavaGrblStreamer/ant/jar-in-jar-loader.zip new file mode 100644 index 0000000..4ee2ee6 Binary files /dev/null and b/NatBrailleTools/simpleJavaGrblStreamer/ant/jar-in-jar-loader.zip differ diff --git a/NatBrailleTools/simpleJavaGrblStreamer/pom.xml b/NatBrailleTools/simpleJavaGrblStreamer/pom.xml deleted file mode 100644 index 9da9675..0000000 --- a/NatBrailleTools/simpleJavaGrblStreamer/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - 4.0.0 - com.willwinder.sjgs - simpleJavaGrblStreamer - 1.0-SNAPSHOT - jar - - - org.scream3r - jssc - 2.8.0 - - - - UTF-8 - 1.6 - 1.6 - - - - - maven-assembly-plugin - - - - com.willwinder.sjgs.simplejavagrblstreamer.SimpleJavaGrblStreamer - - - - jar-with-dependencies - - - - - - diff --git a/NatBrailleTools/simpleJavaGrblStreamer/src/main/java/com/willwinder/sjgs/simplejavagrblstreamer/SimpleJavaGrblStreamer.java b/NatBrailleTools/simpleJavaGrblStreamer/src/main/java/com/willwinder/sjgs/simplejavagrblstreamer/SimpleJavaGrblStreamer.java index 87bc5c8..ba97fc3 100644 --- a/NatBrailleTools/simpleJavaGrblStreamer/src/main/java/com/willwinder/sjgs/simplejavagrblstreamer/SimpleJavaGrblStreamer.java +++ b/NatBrailleTools/simpleJavaGrblStreamer/src/main/java/com/willwinder/sjgs/simplejavagrblstreamer/SimpleJavaGrblStreamer.java @@ -25,7 +25,12 @@ public class SimpleJavaGrblStreamer { static int GRBL_BUFFER_SIZE = 125; public static void main(String argv[]) throws SerialPortException, IOException, InterruptedException { - if (argv.length != 3 && argv.length != 2) { + if (argv.length == 0) + { + System.out.println("Arguments: "); + return; + } + if (argv.length != 3 && argv.length != 2) { System.out.println("Arguments: "); return; } diff --git a/NatBrailleTools/simpleJavaGrblStreamer/target/classes/com/willwinder/sjgs/simplejavagrblstreamer/SimpleJavaGrblStreamer$GrblSerialListener.class b/NatBrailleTools/simpleJavaGrblStreamer/target/classes/com/willwinder/sjgs/simplejavagrblstreamer/SimpleJavaGrblStreamer$GrblSerialListener.class deleted file mode 100644 index 184e392..0000000 Binary files a/NatBrailleTools/simpleJavaGrblStreamer/target/classes/com/willwinder/sjgs/simplejavagrblstreamer/SimpleJavaGrblStreamer$GrblSerialListener.class and /dev/null differ diff --git a/NatBrailleTools/simpleJavaGrblStreamer/target/classes/com/willwinder/sjgs/simplejavagrblstreamer/SimpleJavaGrblStreamer$GrblSerialSender.class b/NatBrailleTools/simpleJavaGrblStreamer/target/classes/com/willwinder/sjgs/simplejavagrblstreamer/SimpleJavaGrblStreamer$GrblSerialSender.class deleted file mode 100644 index e3a7e06..0000000 Binary files a/NatBrailleTools/simpleJavaGrblStreamer/target/classes/com/willwinder/sjgs/simplejavagrblstreamer/SimpleJavaGrblStreamer$GrblSerialSender.class and /dev/null differ diff --git a/NatBrailleTools/simpleJavaGrblStreamer/target/classes/com/willwinder/sjgs/simplejavagrblstreamer/SimpleJavaGrblStreamer.class b/NatBrailleTools/simpleJavaGrblStreamer/target/classes/com/willwinder/sjgs/simplejavagrblstreamer/SimpleJavaGrblStreamer.class deleted file mode 100644 index 627119b..0000000 Binary files a/NatBrailleTools/simpleJavaGrblStreamer/target/classes/com/willwinder/sjgs/simplejavagrblstreamer/SimpleJavaGrblStreamer.class and /dev/null differ diff --git a/printed_parts_v0.5.zip b/printed_parts_v0.5.zip new file mode 100644 index 0000000..e343ac0 Binary files /dev/null and b/printed_parts_v0.5.zip differ