arduino-esp32 icon indicating copy to clipboard operation
arduino-esp32 copied to clipboard

String data = USBCOM.readString();

Open Red-Owl opened this issue 1 year ago • 4 comments

Board

ESP32 wt32-s3-wrover (wt32sc01 plus)

Device Description

ESP32 wt32-s3-wrover (wt32sc01 plus)

Hardware Configuration

ESP32 wt32-s3-wrover (wt32sc01 plus)

Version

v2.0.16

IDE Name

Platformio

Operating System

win11

Flash frequency

40mhz

PSRAM enabled

yes

Upload speed

115200

Description

ERROR A stack overflow in task usbd has been detected.

Sketch

void usb_as_serial_read(){
    String data = USBCOM.readString();
}

Debug Message

***ERROR*** A stack overflow in task usbd has been detected.


Backtrace: 0x40378296:0x3fcb8c90 0x4037d7e9:0x3fcb8cb0 0x40380c9a:0x3fcb8cd0 0x4037f49c:0x3fcb8d50 0x4037d8a0:0x3fcb8d80 0x4037d896:0x00000000 |<-CORRUPTED

Other Steps to Reproduce

send via serial monitor a INFO string in repeat mode repeat 10 arrow up, INFO enter arrow up,INFO enter arrow up,INFO enter .... panic !! or send \r\n panic !!

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

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

Red-Owl avatar Jun 30 '24 15:06 Red-Owl

Once again, programming error. Don't pass Strings (or any large object) around, use pointers. USBCOM is not part of the code here. For help with 3rd party libraries, you need to contact the author.

lbernstone avatar Jun 30 '24 19:06 lbernstone

@Red-Owl - please provide more details about how to reproduce this issue. What is USBCOM obejct? Is it an external library as commented by @lbernstone?

SuGlider avatar Aug 02 '24 21:08 SuGlider

ESP32-S3 has two possible USB CDC objects: from HW Serial JTAG and from USB OTG. Both implement Stream which allows to execute Serial.readString() whenever Serial is configured as the USB port.

Is that the issue?

SuGlider avatar Aug 02 '24 21:08 SuGlider

Arduino Core 3.0.3 works fine, using S3 with HWSerial_JTAG and with USB_OTG.


void setup() {
  Serial.begin();
  Serial.setDebugOutput(true);
  while (!Serial) delay(100);
  Serial.println("Starting...");
  log_i("Starting from LOG_I");  // testing DBG ouput
}

void loop() {
  String data = "";
  data = Serial.readString(); // timeout is 1 second by default. This function will take 1 sec to return.
  if (data.length() > 0) { 
    Serial.println(data);
  } else {
    Serial.println("Loop: No data read.");
  }
}

SuGlider avatar Aug 02 '24 22:08 SuGlider

Hello,

Due to the overwhelming volume of issues currently being addressed, we have decided to close the previously received tickets. If you still require assistance or if the issue persists, please don't hesitate to reopen the ticket.

Thanks.

Parsaabasi avatar Jan 15 '25 13:01 Parsaabasi