Skip to content

Rewrite of the web_serial example website. #3091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

raldone01
Copy link

@raldone01 raldone01 commented Apr 20, 2025

Fixes: #2632

This makes the web serial website code available and it adds lots of new features that make serial debugging fun!

If you find any bugs or want some changes just tell me.
I tried to keep it as simple as possible while still providing useful features.

image

@raldone01 raldone01 marked this pull request as draft April 21, 2025 12:46
Adds support for web serial as well.
@raldone01 raldone01 marked this pull request as ready for review April 21, 2025 15:12
@raldone01 raldone01 force-pushed the fix/web_serial branch 2 times, most recently from 2bf87b8 to 95f1166 Compare May 18, 2025 16:00
@HiFiPhile
Copy link
Collaborator

Thank for your PR, it does indeed resolve the ZLP issue in #2632.

However I've some issues on Chrome 136 Windows 10:

  • Disconnect button has no UI update, although sending and receiving is stopped
  • Sometimes ASCII get translated to hex, entering aaaaa returns 6/9/2025, 4:07:29 PM 97,97,97,97,97 on serial console
  • Serial console get stuck on 1st connection, 2nd connection returns Failed to execute 'open' on 'SerialPort': The port is already open., needs to refresh the page on 3rd attempt to make it work
    image

@raldone01
Copy link
Author

raldone01 commented Jun 9, 2025

Sometimes ASCII get translated to hex

That's an odd one.
I will try to reproduce that on the weekend.
Did this happen with the stock webusb_serial example?
Are you sure this is not a firmware problem?
I can't find any obvious place in the js that could cause this (don't have access to a mcu currently).

Serial console get stuck on 1st connection, 2nd connection returns...

Ugh. Fair enough.

@HiFiPhile
Copy link
Collaborator

HiFiPhile commented Jun 9, 2025

That's an odd one.
I will try to reproduce that on the weekend.
Did this happen with the stock webusb_serial example?

Yeah I'm not tricking you :) Tested on STM32L053 and STM32F723.

I just recorded a video demonstration on my home PC with Chrome 137 Windows 10, the symptome is a little different

  • At 00:10 when I connect to serial, the input box is grayed out until something is received 1
  • For the hex coding issue, at 00:40 you can see the serial data out captured by USB analyzer is indeed something like 1051,1052,1053,1054,1055,1056,1057
  • (2nd video) Click on disconnect button doesn't release the device even with a55e234, following connection got error Unable to claim interface
Chrome.Paq5suxchp-1.mp4
chrome_8ppkgJviKD.mp4
diff --git a/examples/device/webusb_serial/src/main.c b/examples/device/webusb_serial/src/main.c
index d189af91f..f0796e0e8 100644
--- a/examples/device/webusb_serial/src/main.c
+++ b/examples/device/webusb_serial/src/main.c
@@ -253,6 +253,7 @@ void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) {
   if (dtr && rts) {
     // print initial message when connected
     tud_cdc_write_str("\r\nTinyUSB WebUSB device example\r\n");
+    tud_cdc_write_flush();
   }
 }

Footnotes

  1. Can be mitigated by

@raldone01
Copy link
Author

raldone01 commented Jun 9, 2025

Thanks for the video that makes it very easy to reproduce. 🤣

Having the dev tools open would have been even better (for the next time).

I will fix these four issues. Might take me a while though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebUSB example crash when a max size packet and a ZLP received
2 participants