Skip to content

serial_write_substring hangs when writing to disconnected USB #1681

@dhalbert

Description

@dhalbert

If CDC USB is connected and then becomes disconnected, serial_write_substring() in supervisor/shared/serial.c will loop forever trying to write a string. The call to tud_cdc_connected() returns true even though USB has been disconnected. See code in https://github.com/adafruit/circuitpython/blob/master/supervisor/shared/serial.c#L54.

Opening an issue in tinyusb about this.

#1680 discusses a case where PyPortal hangs (no display update, but no crash) after running the OpenWeather demo for a long time. In discussing this with @jerryneedell, the host computer went to sleep during that period, with the REPL connected. I replicated the problem this way:

  1. Start PyPortal running OpenWeather. Use a USB cable with a data/power-only switch
  2. Connect to REPL.
  3. After a minute or less, disconnect the data by flipping the switch on the USB cable. The PyPortal will remain powered but will lose its USB connection.
  4. The PyPortal will eventually try to print() a string, and will call serial_write_substring(). As described above, it will loop forever there, because tud_cdc_connected() but no bytes are able to be written to CDC.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy