File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
examples/dual/host_info_to_device_cdc/src Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ static void usb_device_init(void) {
108108 tusb_init (BOARD_TUD_RHPORT , & dev_init );
109109 tud_cdc_configure_t cdc_cfg = TUD_CDC_CONFIGURE_DEFAULT ();
110110 cdc_cfg .tx_persistent = true;
111+ cdc_cfg .tx_overwritabe_if_not_connected = false;
111112 tud_cdc_configure (& cdc_cfg );
112113 board_init_after_tusb ();
113114}
@@ -209,6 +210,13 @@ void tud_resume_cb(void) {
209210}
210211
211212void cdc_task (void ) {
213+ if (!tud_cdc_connected ()) {
214+ // delay a bit otherwise we can outpace host's terminal. Linux will set LineState (DTR) then Line Coding.
215+ // If we send data before Linux's terminal set Line Coding, it can be ignored --> missing data with hardware test loop
216+ tusb_time_delay_ms_api (50 );
217+ return ;
218+ }
219+
212220 for (uint8_t daddr = 1 ; daddr <= CFG_TUH_DEVICE_MAX ; daddr ++ ) {
213221 if (tuh_mounted (daddr )) {
214222 if (is_print [daddr ]) {
Original file line number Diff line number Diff line change 112112
113113// CDC FIFO size of TX and RX
114114#define CFG_TUD_CDC_RX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
115- #define CFG_TUD_CDC_TX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64 )
115+ #define CFG_TUD_CDC_TX_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 256 )
116116
117117// CDC Endpoint transfer buffer size, more is faster
118118#define CFG_TUD_CDC_EP_BUFSIZE (TUD_OPT_HIGH_SPEED ? 512 : 64)
You can’t perform that action at this time.
0 commit comments