Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void loop(){
- readCommand(computerSerial);
- if (commandSent){
- if(!driverSerial.isListening()){
- driverSerial.listen();
- }
- command = "";
- }
- }
- void readCommand(Stream &source) {
- commandSent = false;
- while (source.available() > 0) {
- char c = source.read();
- if ( (c != '\0') && (c != 10) && (c != 13)){ // if char is not a null or a LF or a CR
- command += c;
- }
- if (c == 13) { //if there is a \n then command is sent
- //command += "\r";
- commandSent = true;
- source.print("command:"); //debug
- source.print(command); //debug
- source.println("END"); //debug
- source.flush();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement