Skip to content

while (!Serial); hangs on Swan R5 with CDC (generic 'Serial' supercede U(S)ART) #1672

Closed
@zfields

Description

@zfields

Describe the bug
Firmware hangs at while (!Serial);.

Here is the implementation:

USBSerial::operator bool()
{
  delay(10);
  return dtrState;
}

I took a cursory look, and I don't see anywhere dtrState is getting set.

Here is the Arduino Board Configuration
image

The bug only appears with CDC (generic 'Serial' supercede U(S)ART).

The bug does not reproduce with:

  • CDC (no generic 'Serial')
  • HID (keyboard and mouse)

To Reproduce
Complete source code which can be used to reproduce the issue. Please try to be as generic as possible (no extra code, extra hardware,...)

Steps to reproduce the behavior:

  1. Flash this program to the device

    void setup()
    {
        Serial.begin(115200);
        while (!Serial);
        pinMode(LED_BUILTIN, OUTPUT);
    }
    
    void loop()
    {
        Serial.println("Looping!");
        static uint32_t state = LOW;
        state = !state;
        digitalWrite(LED_BUILTIN, state);
        delay(750);
    }
  2. The device will not blink or print "Looping!".

  3. Comment out

       while (!Serial);
  4. Reflash device

  5. The device will work as expected.

Expected behavior
I would expect Serial == true (a.k.a. to be "ready"), if it can send bytes over USB.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Linux
  • Arduino IDE version: 1.8.19
  • STM32 core version: latest

Board (please complete the following information):

  • Name: Swan R5
  • Hardware Revision:

Additional context

VSCode Version: 1.65.1
Commit: 8908a9ca0f221f36507231afb39d2d8d1e182702
Date: 2022-03-08T02:09:03.269Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Linux x64 5.16.11-76051611-generic

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions