Serial monitor output unexpectedly stops

Status
Not open for further replies.

chrisspurgeon

New member
When outputting a substantial amount of text to the Serial Monitor I've been experiencing an issue where the output will just truncate and stop appearing. Here's a super simple sketch that generates the problem (I'm running this on a new Teensy 4.1, with the CPU speed set to 396MHz, and Optimize set to "Fast")...

Code:
void setup() {

  Serial.begin(9600);
  for (int i = 0; i < 500; i++) {
    Serial.print("Another number: ");
    Serial.println(i);
  }

}

void loop() {

}

After the expected output appears in the Serial Monitor for a few hundred lines, it just dies. Here's the end of the output...

Code:
Another number: 386
Another number: 387
Another number: 388
Another number: 389
Another number: 390
Another number: 391
Another number: 392
Another number: 393
Another number: 394
Another

There are no errors during compilation (not surprising, considering how simple the sketch is). Anyone have any idea what's going on? THANKS!
 
Putting that on a currently active Teensy LC works fine. The T_4.1 at 480 Mbps is way faster than that at 12 Mbps.

The change below - waits for Serial before printing. Without that the T_4.1 here showed nothing of the prints 0-499.

Code:
void setup() {
  Serial.begin(9600);
  [B]while (!Serial && millis() < 2000) ; // wait[/B]
  for (int i = 0; i < 500; i++) {
    Serial.print("Another number: ");
    Serial.println(i);
  }

}

void loop() {

}
 
Are you using Mac, Linux or Windows. Which version? If Linux, double check you have the latest udev rules (they were updated months ago for a new ModemManger bug).
 
Putting that on a currently active Teensy LC works fine. The T_4.1 at 480 Mbps is way faster than that at 12 Mbps.

The change below - waits for Serial before printing. Without that the T_4.1 here showed nothing of the prints 0-499.

Code:
void setup() {
  Serial.begin(9600);
  [B]while (!Serial && millis() < 2000) ; // wait[/B]
  for (int i = 0; i < 500; i++) {
    Serial.print("Another number: ");
    Serial.println(i);
  }

}

void loop() {

}

Thanks, I'll try that!
 
Status
Not open for further replies.
Back
Top