@bko,
Thanks for the suggestions… edited to remove previous post.
I think there is still an issue. If I insert a delay after the first Serial
print on the photon, the photon appears to stream the output correctly. Else it fails…see output below
Here is the updated code:
T3:
#define POUART Serial2
unsigned long baud = 115200;
String inputString = ""; // a string to hold incoming data
boolean stringComplete = false; // whether the string is complete
void setup() {
Serial.begin(baud); // for T3 to PO connection
POUART.begin(baud); // use this for T3 PO interaction
}
void POUART_read() {
while (POUART.available()) {
// get the new byte:
char inChar = (char)POUART.read();
if (inChar == 13) {
stringComplete = true;
} else {
inputString += inChar;
}
}
}
void loop()
{
POUART_read();
if(stringComplete) {
Serial.print("Got input: ");
Serial.println(inputString);
if (inputString == "abc"){
Serial.println("Got String: ABC");
}
stringComplete = false;
inputString = "";
}
}
Photon:
#define UART Serial2
void setup()
{
UART.begin(115200);
UART.println("With Delay inserted after first print");
}
void loop()
{
UART.println("012345678");
delay(10); // This delay after first print appears to help..
UART.println("abc");
delay(5000); // delay 5 secs
}
Output: (Note the first Odd char ÿ <— Unprintable Photon buffer data?)
ÿNo Delay inserted after first print
01
Got input: 2345678
Got input:
abc
Got input: 012345678
a
Got input: bc
Got input: 012345678
a
Got input: bc
Got input: 012345678
a
Got input: bc
Got input: 012345678
a
Got input: bc
Got input:
ÿWith Delay inserted after first print
Got input: 012345678
Got input: abc
Got String: ABC
Got input:
012345678
Got input: abc
Got String: ABC
Got input:
012345678
Got input: abc
Got String: ABC
Got input:
012345678
Got input: abc
Got String: ABC
Got input:
012345678