Closed andrewleech closed 1 month ago
Thanks for your PR, please add define and description in cdc_device.h
like how #ifndef CFG_TUD_CDC_EP_BUFSIZE
does.
Thanks, I did think the setting should be detailed somewhere, in hindsight cdc_device.h
should have been the obvious location!
Describe the PR This MR provides a build configuration define that allows an application to prevent clearing of the CDC TX fifo buffer on port setup / reset.
The default if it's not set or set to 0 is the same as current production code.
This means that an application can write data to the CDC port before the USB is connected and available, eg logging data right from application startup. This buffered data will then be flushed down the CDC port on the next write or
tud_cdc_write_flush();
after the CDC is connected.Additional context Related information: https://github.com/hathach/tinyusb/discussions/2595
I'm hoping to add this to support a feature used in micropython. There, the stm port is using the STM usb stack, not TinyUSB. It has a feature where data "sent" to usb CDC at startup is buffered (in the usb stack), before USB is init / connected. Then when USB is connected, data previously buffered is flushed down the line to the client.
In practice, this buffered content consists of a "startup banner" like:
This feature has been there for years and is quite popular, I really want to replicate this feature on TinyUSB to use across all ports, eventually replacing the STM usb stack with TinyUSB for consistency with all other micropython ports.