Open zjwhitehead opened 4 years ago
Looks like this is still happening. Im also experiencing the issue on the RP2040.
The following code hangs when connected to the webserial example.
The main fix is just sending less than 64 bytes but obviously sometimes you need to send more than that...
Changing 200
to 64
below changes how many bytes are sent.
#include "Adafruit_TinyUSB.h"
// USB WebUSB object
Adafruit_USBD_WebUSB usb_web;
// Landing Page: scheme (0: http, 1: https), url
WEBUSB_URL_DEF(landingPage, 1 /*https*/, "adafruit.github.io/Adafruit_TinyUSB_Arduino/examples/webusb-serial/index.html");
int led_pin = LED_BUILTIN;
// the setup function runs once when you press reset or power the board
void setup()
{
#if defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARCH_RP2040)
// Manual begin() is required on core without built-in support for TinyUSB such as mbed rp2040
TinyUSB_Device_Init(0);
#endif
usb_web.setLandingPage(&landingPage);
usb_web.setLineStateCallback(line_state_callback);
//usb_web.setStringDescriptor("TinyUSB WebUSB");
usb_web.begin();
Serial.begin(115200);
// wait until device mounted
while( !TinyUSBDevice.mounted() ) delay(1);
Serial.println("TinyUSB WebUSB Serial example");
}
void loop(){}
void line_state_callback(bool connected){
if ( connected ) {
for (int i = 0; i < 200; i++) {
int digit = i % 10;
Serial.print(digit);
usb_web.print(digit);
usb_web.flush();
}
}
}
Any thoughts on how to overcome this?
This is still happening on 1.18.3 😢 Any updated on how to fix this?
Describe the bug Passing in strings over a certain length freezes the device. May be related to buffer overflow? looks like it crashes after 64 characters.
Set up (please complete the following information)
To Reproduce Steps to reproduce the behavior:
webusb_serial
example hereif ( connected ) usb_web.println("TinyUSB WebUSB Serial example");
toif ( connected ) usb_web.println("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
Expected behavior Full string is printed out via web_usb without crashing
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Seems to work as expected on SAMD21 boards
Tested in Chrome 83.0.4103.14 and Brave browser (Chromium)