comment out and add note for tud_cdc_connected() in cdc_msc examples

This commit is contained in:
hathach 2020-11-24 00:06:59 +07:00
parent 4b4f880785
commit 7860469661
3 changed files with 12 additions and 5 deletions

View File

@ -83,6 +83,8 @@ static void cdc_task(void)
for (itf = 0; itf < CFG_TUD_CDC; itf++) for (itf = 0; itf < CFG_TUD_CDC; itf++)
{ {
// connected() check for DTR bit
// Most but not all terminal client set this when making connection
if ( tud_cdc_n_connected(itf) ) if ( tud_cdc_n_connected(itf) )
{ {
if ( tud_cdc_n_available(itf) ) if ( tud_cdc_n_available(itf) )

View File

@ -105,7 +105,9 @@ void tud_resume_cb(void)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void cdc_task(void) void cdc_task(void)
{ {
if ( tud_cdc_connected() ) // connected() check for DTR bit
// Most but not all terminal client set this when making connection
// if ( tud_cdc_connected() )
{ {
// connected and there are data available // connected and there are data available
if ( tud_cdc_available() ) if ( tud_cdc_available() )
@ -133,7 +135,7 @@ void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts)
(void) itf; (void) itf;
// connected // connected
if ( dtr && rts ) if ( dtr )
{ {
// print initial message when connected // print initial message when connected
tud_cdc_write_str("\r\nTinyUSB CDC MSC device example\r\n"); tud_cdc_write_str("\r\nTinyUSB CDC MSC device example\r\n");

View File

@ -168,9 +168,11 @@ void cdc_task(void* params)
// RTOS forever loop // RTOS forever loop
while ( 1 ) while ( 1 )
{ {
if ( tud_cdc_connected() ) // connected() check for DTR bit
// Most but not all terminal client set this when making connection
// if ( tud_cdc_connected() )
{ {
// connected and there are data available // There are data available
if ( tud_cdc_available() ) if ( tud_cdc_available() )
{ {
uint8_t buf[64]; uint8_t buf[64];
@ -200,10 +202,11 @@ void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts)
(void) itf; (void) itf;
// connected // connected
if ( dtr && rts ) if ( dtr )
{ {
// print initial message when connected // print initial message when connected
tud_cdc_write_str("\r\nTinyUSB CDC MSC device with FreeRTOS example\r\n"); tud_cdc_write_str("\r\nTinyUSB CDC MSC device with FreeRTOS example\r\n");
tud_cdc_write_flush();
} }
} }