I've only just downloaded the code and started playing with....
But looking at the code this isn't a problem with the gcode file.
The method waitForResponse is actually processing a response from the printer.
It basically reads character data coming back from the printer until it sees an end of line character.
It then pulls the response line apart.
In particualer the line in question is where the printer has issued an 'rs' which is a resend request.
Not having looked at the firmware I don't know why it would do this.
Anyway the host application is is looking for a number after the 'rs' command.
I'm guessing that the rs command looks like:
rs N79
However the code passes the full N79 to the parseLong call which causes the Exception.
The following 'UNTESTED" patched version of waitForResponse should fix the problem.
Brett
/**
* Parse the string sent back from the RepRap machine.
*
*/
private long waitForResponse()
{
int i;
String resp = "";
long result = allSentOK;
String lns;
resetReceived();
boolean goAgain;
Date timer = new Date();
long startWait = timer.getTime();
long timeNow;
long increment = 2000;
long longWait = 10*60*1000; // 10 mins...
for(;
{
timeNow = timer.getTime() - startWait;
if(timeNow > increment)
{
Debug.d("GCodeReaderAndWriter().waitForResponse(): waited for " + timeNow/1000 + " seconds.");
increment = 2*increment;
}
if(timeNow > longWait)
{
Debug.e("GCodeReaderAndWriter().waitForResponse(): waited for " + timeNow/1000 + " seconds.");
try {
queue("M0 ;shut RepRap down");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try
{
i = serialInStream.read();
} catch (Exception e)
{
i = -1;
}
//anything found?
if (i >= 0)
{
char c = (char)i;
//is it at the end of the line?
if (c == '\n' || c == '\r')
{
goAgain = false;
Debug.d("GCodeWriter.waitForResponse() - received response from RepRap "+ resp);
if (resp.startsWith("start") || resp.contentEquals("")) // Startup or null string...
{
resp = "";
goAgain = true;
} else if (resp.startsWith("!!")) // Horrible hard fault?
{
result = shutDown;
Debug.e("GCodeWriter.waitForResponse(): RepRap hard fault!");
} else if (resp.startsWith("//")) // immediate DEBUG "comment" from the firmware ( like C++ )
{
resp = "";
goAgain = true;
} else if (resp.endsWith("\\")) // lines ending in a single backslash are considered "continued" to the next line, like "C"
{
// Debug.d("GCodeWriter.waitForResponse(): " + resp);
// resp = ""; don't clear the previuos response...
goAgain = true; // but do "go again"
} else if (resp.startsWith("rs")) // Re-send request?
{
lns = resp.substring(3);
int sp = lns.indexOf(" ");
if(sp > 0)
lns = lns.substring(0, sp);
// Some firmware (may be all) returns the line with a leading 'N'.
if (lns.startsWith("N"))
lns = lns.substring(1);
result = Long.parseLong(lns);
} else if (!resp.startsWith("ok")) // Must be "ok" if not those - check
{
Debug.e("GCodeWriter.waitForResponse() - dud response from RepRap:" + resp);
result = lineNumber; // Try to send the last line again
}
// Have we got temperatures and/or coordinates?
eTemp = parseReturnedValue(resp, " T:");
bTemp = parseReturnedValue(resp, " B:");
if(resp.indexOf(" C:") >= 0)
{
x = parseReturnedValue(resp, " X:");
y = parseReturnedValue(resp, " Y:");
z = parseReturnedValue(resp, " Z:");
e = parseReturnedValue(resp, " E:");
}
if(!goAgain)
{
Debug.c("Response: " + resp);
lastResp = resp.substring(2);
return result;
}
} else
resp += c;
}
}
}