-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
295 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
21 changes: 21 additions & 0 deletions
21
NatBrailleTools/BrailleLogger/ant/braillelogger_ant_build.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<project default="create_run_jar" name="Create Runnable Jar for Project BrailleLogger with Jar-in-Jar Loader"> | ||
<!--this file was created by Eclipse Runnable JAR file Export Wizard--> | ||
<!--ANT 1.7 is required--> | ||
<!--define folder properties--> | ||
<property name="dir.buildfile" value="."/> | ||
<property name="dir.workspace" value="D:/Users/Stephane/eclipse-workspace"/> | ||
<property name="dir.jarfile" value="I:/home/3d/braillerapsp.github/BrailleRapSP/NatBrailleTools/bin"/> | ||
<target name="create_run_jar"> | ||
<jar destfile="${dir.jarfile}/braillelogger.jar"> | ||
<manifest> | ||
<attribute name="Main-Class" value="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader"/> | ||
<attribute name="Rsrc-Main-Class" value="BrailleLogger"/> | ||
<attribute name="Class-Path" value="."/> | ||
<attribute name="Rsrc-Class-Path" value="./"/> | ||
</manifest> | ||
<zipfileset src="jar-in-jar-loader.zip"/> | ||
<fileset dir="I:/home/3d/braillerapsp.github/BrailleRapSP/NatBrailleTools/BrailleLogger/bin"/> | ||
</jar> | ||
</target> | ||
</project> |
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
NatBrailleTools/BrailleLogger/bin/Braille2GcodeEncoder.class
Binary file not shown.
Binary file modified
BIN
+1.97 KB
(220%)
NatBrailleTools/BrailleLogger/bin/Braille6GcodeEncoding.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
21 changes: 21 additions & 0 deletions
21
NatBrailleTools/BrailleLogger/bin/braillelogger_ant_build.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<project default="create_run_jar" name="Create Runnable Jar for Project BrailleLogger with Jar-in-Jar Loader"> | ||
<!--this file was created by Eclipse Runnable JAR file Export Wizard--> | ||
<!--ANT 1.7 is required--> | ||
<!--define folder properties--> | ||
<property name="dir.buildfile" value="."/> | ||
<property name="dir.workspace" value="D:/Users/Stephane/eclipse-workspace"/> | ||
<property name="dir.jarfile" value="I:/home/3d/braillerapsp.github/BrailleRapSP/NatBrailleTools/bin"/> | ||
<target name="create_run_jar"> | ||
<jar destfile="${dir.jarfile}/braillelogger.jar"> | ||
<manifest> | ||
<attribute name="Main-Class" value="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader"/> | ||
<attribute name="Rsrc-Main-Class" value="BrailleLogger"/> | ||
<attribute name="Class-Path" value="."/> | ||
<attribute name="Rsrc-Class-Path" value="./"/> | ||
</manifest> | ||
<zipfileset src="jar-in-jar-loader.zip"/> | ||
<fileset dir="${dir.buildfile}"/> | ||
</jar> | ||
</target> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="lib" path="I:/local/java/jSSC-2.8.0-Release/jssc.jar"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
NatBrailleTools/gcodestreamer/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
22 changes: 22 additions & 0 deletions
22
NatBrailleTools/gcodestreamer/ant/gcodestreamer_ant_build.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<project default="create_run_jar" name="Create Runnable Jar for Project gcodestreamer with Jar-in-Jar Loader"> | ||
<!--this file was created by Eclipse Runnable JAR file Export Wizard--> | ||
<!--ANT 1.7 is required--> | ||
<!--define folder properties--> | ||
<property name="dir.buildfile" value="."/> | ||
<property name="dir.workspace" value="D:/Users/Stephane/eclipse-workspace"/> | ||
<property name="dir.jarfile" value="I:/home/3d/braillerapsp.github/BrailleRapSP/NatBrailleTools/bin"/> | ||
<target name="create_run_jar"> | ||
<jar destfile="${dir.jarfile}/gcodestreamer.jar"> | ||
<manifest> | ||
<attribute name="Main-Class" value="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader"/> | ||
<attribute name="Rsrc-Main-Class" value="com.willwinder.sjgs.simplejavagrblstreamer.SimpleJavaGrblStreamer"/> | ||
<attribute name="Class-Path" value="."/> | ||
<attribute name="Rsrc-Class-Path" value="./ jssc.jar"/> | ||
</manifest> | ||
<zipfileset src="jar-in-jar-loader.zip"/> | ||
<fileset dir="I:/home/3d/braillerapsp.github/BrailleRapSP/NatBrailleTools/gcodestreamer/bin"/> | ||
<zipfileset dir="I:/local/java/jSSC-2.8.0-Release" includes="jssc.jar"/> | ||
</jar> | ||
</target> | ||
</project> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/com/ |
176 changes: 176 additions & 0 deletions
176
.../gcodestreamer/src/com/willwinder/sjgs/simplejavagrblstreamer/SimpleJavaGrblStreamer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: <comm port> <baud> <file>"); | ||
return; | ||
} | ||
if (argv.length != 3 && argv.length != 2) { | ||
System.out.println("Arguments: <comm port> <baud> <file>"); | ||
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<Integer> 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<Integer> completedCommands; | ||
StringBuilder inputBuffer; | ||
private GrblSerialListener(SerialPort port, BlockingQueue<Integer> 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<Integer> completedCommands = null; | ||
LinkedList<Integer> activeCommandSizes; | ||
|
||
private GrblSerialSender(InputStream f, SerialPort sp, BlockingQueue<Integer> completedCommands, Integer activeBufferSize) { | ||
file = f; | ||
port = sp; | ||
maxBufferSize = activeBufferSize; | ||
currentBufferSize = 0; | ||
this.completedCommands = completedCommands; | ||
activeCommandSizes = new LinkedList<Integer>(); | ||
} | ||
|
||
private void send() throws IOException { | ||
// Java 8 | ||
//try(Stream<String> 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; | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
NatBrailleTools/simpleJavaGrblStreamer/.settings/org.eclipse.core.resources.prefs
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
NatBrailleTools/simpleJavaGrblStreamer/.settings/org.eclipse.jdt.core.prefs
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
NatBrailleTools/simpleJavaGrblStreamer/.settings/org.eclipse.m2e.core.prefs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.