Skip to content

UART locks and stops receiving data #6326

Closed
@gonzabrusco

Description

@gonzabrusco

Board

ESP32 Dev Module

Device Description

ESP32 Dev Module connected with USB directly to the PC.

Hardware Configuration

Standard Serial(0) configuration.

Version

latest master

IDE Name

Platformio IO

Operating System

Windows 10

Flash frequency

40 MHz

PSRAM enabled

no

Upload speed

115200

Description

Hello. I think I found a bug in HardwareSerial.

When you fill the receive buffer very fast when the code is locked in some other process, the serial stops receiving. It just stops working for RX (TX keeps working). It looks like UART RX is getting locked.

I must say that I'm using Platformio IO with Tasmota dev fork @Jason2866 (https://github.com/Jason2866/platform-espressif32) because Platformio still does not support Arduino 2.0/ IDF 4.4. But the platform-packages are being used directly from master like this:

platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2.2/platform-tasmota-espressif32-2.0.2.zip
platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git

Another thing that called my attention, if the default rx buffer is 256 bytes, why does the serial loopbacks MORE than 256 bytes? Where is it storing the extra characters? Are we looking at a buffer overflow problem?

If you send this (255 chars):
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has sur
It responds ok everythime.

If you send this (366 chars!!!)
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
It still responds ok everythime when It should truncate to 256 because the default RX buffer is 256.... (or I'm getting something wrong here?)

But if you send this (574 chars!!)
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
The Serial RX just locks forever.

I saw this because in my application I'm using the UART for communication with another microcontroller. And I noticed that after a long blocking part of the code, the Serial stopped working.

Sketch

#include <Arduino.h>

uint32_t startTime;

void setup() {
    Serial.begin(115200);

    startTime = millis();
}

void loop() {
    while(millis() - startTime < 5000) {
        // blocking loop
    }
    Serial.println();
    Serial.println("Finished blocking loop. Now printing everything received");

    while(Serial.available()) Serial.print((char)Serial.read());
    Serial.println();
    startTime = millis();
}

Debug Message

Run sketch and send the texts described before.

Other Steps to Reproduce

No.

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions