diff options
author | wizard23 <wizard23@cb376a5e-1013-0410-a455-b6b1f9ac8223> | 2008-07-08 02:53:24 +0000 |
---|---|---|
committer | wizard23 <wizard23@cb376a5e-1013-0410-a455-b6b1f9ac8223> | 2008-07-08 02:53:24 +0000 |
commit | be73214a033bd68adc54a26349a69a5cdb59ab98 (patch) | |
tree | 38931c790c3ac68cf16f798b81dd07c7d27d7f63 | |
parent | 60b671960d8080da5e92857cd54bb5dd8ba5ab35 (diff) | |
download | reprap-backup-be73214a033bd68adc54a26349a69a5cdb59ab98.tar.gz reprap-backup-be73214a033bd68adc54a26349a69a5cdb59ab98.zip |
added queueing of commands, and fixed missing newline after each command (which turned out to be the real problem)
git-svn-id: https://reprap.svn.sourceforge.net/svnroot/reprap@1723 cb376a5e-1013-0410-a455-b6b1f9ac8223
-rw-r--r-- | trunk/users/hoeken/arduino/GCode_Host/GCode_Host.pde | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/trunk/users/hoeken/arduino/GCode_Host/GCode_Host.pde b/trunk/users/hoeken/arduino/GCode_Host/GCode_Host.pde index 5464b0e1..6d8f4360 100644 --- a/trunk/users/hoeken/arduino/GCode_Host/GCode_Host.pde +++ b/trunk/users/hoeken/arduino/GCode_Host/GCode_Host.pde @@ -23,26 +23,35 @@ void setup() //init stuff size(1024, 600); //smooth(); - + // List all the available serial ports println(Serial.list()); //open the first port... myPort = new Serial(this, Serial.list()[0], 19200); + //load our gcode lines + gcode = loadStrings("job.gcode"); - //println(gcode); font = loadFont("ArialMT-48.vlw"); } +int queueLength = 2; +int commandsInQueue = 0; + + + void draw() { background(20, 20, 20); + while (myPort.available() > 0) { - int inByte = myPort.read(); + int inByte; + + inByte = myPort.read(); if (inByte == '\n') { @@ -54,11 +63,12 @@ void draw() temperature = m[0]; if (match(serialLine, "^start") != null) + { started = true; - + } if (match(serialLine, "^ok") != null) { - commandComplete = true; + commandsInQueue--; if (gcodeIndex == gcode.length) println("Job's done!"); @@ -74,10 +84,14 @@ void draw() if (started) { - if (commandComplete) + if (commandsInQueue < queueLength) { String cmd = getNextCommand(); - commandComplete = false; + print("next command: "); + println(cmd); + + print("queue length: "); + println(commandsInQueue); if (gcodeIndex == gcode.length) { @@ -86,8 +100,10 @@ void draw() if (cmd != null) { + commandsInQueue++; println("Sent: " +cmd); myPort.write(cmd); + myPort.write("\n"); } } } |