Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GIGA: Serial.flush() will hang if the Serial monitor is not connected. #35

Open
KurtE opened this issue Jan 18, 2025 · 1 comment
Open

Comments

@KurtE
Copy link

KurtE commented Jan 18, 2025

Describe the bug
Title pretty well describes it.
Optional: attach the sketch

Additional context
Running current stuff in the arduino branch, after the recent merge.

void setup() {
  Serial.begin(115200);
  while(!Serial && (millis() < 4000)) {}
  Serial.println("Quick and dirty test");
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(LED_BUILTIN+1, OUTPUT);
  pinMode(LED_BUILTIN+2, OUTPUT);
}

int loop_count = 0;
void loop() {
  Serial.print("Loop count: ");
  Serial.println(++loop_count);
  Serial.flush();
  digitalWrite(LED_BUILTIN, (loop_count & 1)? HIGH : LOW);
  digitalWrite(LED_BUILTIN+1, (loop_count & 2)? HIGH : LOW);
  digitalWrite(LED_BUILTIN+2, (loop_count & 4)? HIGH : LOW);
  delay(250);
}

If you run the sketch above, without the Serial monitor connected, it will hang at the flush. It will startup when
you connect and it will stop again if you should close it.

If you comment out the Serial.flush(), it runs without this issue.

@mjs513
Copy link

mjs513 commented Jan 18, 2025

@KurtE
Gave your sketch a try and am seeing the same as think as you are with Serial.flush().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants