UPDATE! Now I *am* embarassed! I myself had posted a solution / workaround to this problem 3 Years ago! LOL!! See the post, "Serial.read baud-rate issues..." in this forum. In a nutshell, as Ben Rose pointed out, the processor just can't accurately do high baud rates (at least on Input).
So, the workaround is: USE 9600 Baud! I just tested it, and it's working!
-------------
Hi y'all! This question is embarassingly simple, but I'm stumped! I'm talking to TinyDuino via USB Serial connection 115200 baud. I send single-character "commands" from a Windows program to the tiny, pull them off the wire in the main loop() with:
if (Serial.available() > 0)
processIncomingByte(Serial.read());
and all is well. Works great, no issues. I've decided to expand my "protocol" a bit, to consist of multi-character "strings", e.g. - "DELAY 500", etc. So I have tried this:
String str; // module declaration
in loop():
if (Serial.available() > 0)
{
str = Serial.readStringUntil('\n');
Serial.print("str = "); Serial.println(str);
// also tried: Serial.print("str = "); Serial.println(str.c_str());
}
An example of the result (from the input, "M1234") is:
str = L⸮⸮
I've also tried using char buffer[32], and appending single chars to that buffer, with a check for the '\n'. Similar result.
What the heck am I missing here? This ought to be falling-off-a-rock simple!
This doesn't work even with the Arduino serial monitor either; tho single-char inputs are fine, and all println outputs from the tiny.
Any thoughts?