Created
April 28, 2012 14:13
-
-
Save ril3y/2519367 to your computer and use it in GitHub Desktop.
Filesender logic for tgFX
This file contains hidden or 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
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