Skip to content

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

Open
@KurtE

Description

@KurtE

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions