microsoft / vscode-arduino

Visual Studio Code extension for Arduino
Other
1.17k stars 226 forks source link

Serial Monitor displaying null characters for seconds before actual data #1730

Open joseportillodev opened 7 months ago

joseportillodev commented 7 months ago

OS: MacOS Sonoma 14.4.1 VSCode: 1.88.0 (Universal) Arduino IDE: 2.3.3-nightly-20240305 Arduino VSCode Extension: v0.6.0 Serial Monitor VSCode Extension: v0.11.0

Bug: Using the serial monitor with an ESP8266 board (Wemos D1 Mini clone) and a simple test application, it displays a huge amount of null/garbled chars, during several seconds, before displaying the actual data sent by the ESP8266 to the computer. On many occasions, after the aforementioned huge amount of null/garbled chars, the pane displays some chunk of data (one line or a part of it) repeatedly before actual data.

Notes:

When uploading the sketch to the ESP8266, the Arduino extension disconnects the Serial Monitor, performs the sketch upload, and connects the Serial Monitor back. On connection, the pane displays a few more seconds of junk characters and I can finally see the sketch output.

Steps:

Sample sketch:

void setup() {
    // LED ON
    pinMode(LED_BUILTIN, OUTPUT);
    digitalWrite(LED_BUILTIN, LOW);
    delay(1000);

    // Setup serial port
    Serial.begin(115200);
    Serial.println(F("\r\nESP8266 TEST APPLICATION v1.0 | Build " __DATE__ " " __TIME__));
    Serial.println(ESP.getFullVersion());
}

void loop() {
    static int i;

    Serial.printf("Loop: %u\r\n", i++);
    digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
    delay(1000);
}

Expected output (sketch banner and loop traces):

Captura de pantalla 2024-04-09 a las 15 07 53

What actually happens:

Captura de pantalla 2024-04-09 a las 15 08 35

...a few seconds later...

Captura de pantalla 2024-04-09 a las 15 08 07

According to the timestamps, only one second has elapsed and only one huge line of <null?> chars has been "inserted" into the pane view. After a few seconds of wait time, you'll see the application banner and at least 15~20 loop traces appear instantly.

Quick demo video (start Monitoring after connecting board to computer) https://github.com/microsoft/vscode-arduino/assets/166513883/e988952a-326d-47ea-b21f-103d1b6c00c9

Quick demo video (upload sketch) https://github.com/microsoft/vscode-arduino/assets/166513883/d5fcb701-e565-4776-8261-8cfa9a9f1a67

Thank you! Jose

joseportillodev commented 7 months ago

Just one more screenshot, showing the "repeating piece of data" issue. (just clicked Start Monitoring while the board was connected and the sketch running)

Captura de pantalla 2024-04-09 a las 16 44 03