Skip to content

Instantly share code, notes, and snippets.

@ril3y
Created April 28, 2012 14:13
Show Gist options
  • Save ril3y/2519367 to your computer and use it in GitHub Desktop.
Save ril3y/2519367 to your computer and use it in GitHub Desktop.
Filesender logic for tgFX
while (!tg.getClearToSend()) {
//Not ready yet
Thread.sleep(1);
//We have to check again while in the sleeping thread that sometime
//during waiting for the clearbuffer the serialport has not been disconnected.
//And cancel has not been called
if (!tg.isConnected()) {
console.appendText("[!]Serial Port Disconnected.... Stopping file sending task...");
return false;
} else if (tg.isCANCELLED()) {
console.appendText("[!]Canceling the file sending task...");
return false;
}
}
//This looks like its not needed since the same check above in the while block.
//However I am pretty confident that this is.
if (!tg.isConnected()) {
console.appendText("[!]Serial Port Disconnected.... Stopping file sending task...");
return false;
}
//Finally write the line everything is Good to go.
tg.write(line);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment