el_supremo
Well-known member
This sketch behaves rather oddly using beta12 on Teensy3.
It should just repeatedly write the first string 5 times, then the second string 5 times etc.
The first string is 61 chars long and each one is printed as soon as it is generated. The other string is 62 chars long and five of them are written but none of them will appear on the Serial Monitor until the next 61 char string is printed which flushes the buffer.
Adding Serial.flush() doesn't help.
I don't think this is in the Serial Monitor itself because this doesn't happen when run on a Nano (also using 1.0.3).
When the 62 char string is written, println() adds CR/LF on the end which makes it 64 chars long.
If you change the second string from 62 chars to 126 chars, the same thing happens so it appears that writing a string that is an exact multiple of 64 chars is the problem.
Also, if you write the 62 char line 64 times, that will cause a flush of the whole lot, presumably because it has filled an internal 4096 char buffer.
Pete
Code:
void setup(void)
{
Serial.begin(9600);
while(!Serial);
}
int count = 0;
void loop(void)
{
if((count/5) == 0) {
Serial.println("RMC A 2013/01/25 18:43:18.000 52 05.5686N - 106 35.7915W 9 A");
} else {
Serial.println("RMC A 2013/01/25 18:43:18.000 52 05.5686N - 106 35.7915W 10 A");
}
count++;
if(count > 9)count = 0;
delay(1000);
}
The first string is 61 chars long and each one is printed as soon as it is generated. The other string is 62 chars long and five of them are written but none of them will appear on the Serial Monitor until the next 61 char string is printed which flushes the buffer.
Adding Serial.flush() doesn't help.
I don't think this is in the Serial Monitor itself because this doesn't happen when run on a Nano (also using 1.0.3).
When the 62 char string is written, println() adds CR/LF on the end which makes it 64 chars long.
If you change the second string from 62 chars to 126 chars, the same thing happens so it appears that writing a string that is an exact multiple of 64 chars is the problem.
Also, if you write the 62 char line 64 times, that will cause a flush of the whole lot, presumably because it has filled an internal 4096 char buffer.
Pete
Last edited: