Last active
November 25, 2015 02:12
-
-
Save chrwei/563b315ec96dbb1a6fc6 to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
* Serial echo for verifying communication with a PC based program | |
* On Galileo or Edison this can talk to a process on the host | |
* if you setup socat to create some devices. | |
*/ | |
//Galileo or Edison, setup ring buffer and TTYUARTClass | |
RingBuffer rx_buffer_S1; | |
TTYUARTClass mySerial(&rx_buffer_S1, 3, false); | |
void setup() { | |
//for Galileo or Edison specify the host TTY to connect to | |
mySerial.init_tty("/root/tty0"); | |
//now the mySerial instance can be treated just like any Serial instance | |
mySerial.begin(115200); | |
} | |
void loop() | |
{ | |
mySerial.write("A"); | |
if(mySerial.available()) { | |
char in = mySerial.read(); | |
if(in == 'A') { | |
mySerial.write("$"); | |
} else { | |
mySerial.write("!"); | |
} | |
} | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment