Skip to content

Commit 68cc708

Browse files
authored
Merge pull request #2438 from IngHK/cdch_mounted_fix
fix of #2437 CDCh tuh_cdc_mounted() returns true before process config is completed
2 parents 7a92038 + 00ba4e9 commit 68cc708

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/class/cdc/cdc_host.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@ typedef struct {
5353
uint8_t bInterfaceSubClass;
5454
uint8_t bInterfaceProtocol;
5555

56+
uint8_t ep_notif;
5657
uint8_t serial_drid; // Serial Driver ID
58+
bool mounted; // Enumeration is complete
5759
cdc_acm_capability_t acm_capability;
58-
uint8_t ep_notif;
5960

60-
uint8_t line_state; // DTR (bit0), RTS (bit1)
6161
TU_ATTR_ALIGNED(4) cdc_line_coding_t line_coding; // Baudrate, stop bits, parity, data width
62+
uint8_t line_state; // DTR (bit0), RTS (bit1)
6263

6364
#if CFG_TUH_CDC_FTDI || CFG_TUH_CDC_CP210X || CFG_TUH_CDC_CH34X
6465
cdc_line_coding_t requested_line_coding;
@@ -305,7 +306,8 @@ bool tuh_cdc_itf_get_info(uint8_t idx, tuh_itf_info_t* info) {
305306

306307
bool tuh_cdc_mounted(uint8_t idx) {
307308
cdch_interface_t* p_cdc = get_itf(idx);
308-
return p_cdc != NULL;
309+
TU_VERIFY(p_cdc);
310+
return p_cdc->mounted;
309311
}
310312

311313
bool tuh_cdc_get_dtr(uint8_t idx) {
@@ -644,9 +646,9 @@ void cdch_close(uint8_t daddr) {
644646
// Invoke application callback
645647
if (tuh_cdc_umount_cb) tuh_cdc_umount_cb(idx);
646648

647-
//tu_memclr(p_cdc, sizeof(cdch_interface_t));
648649
p_cdc->daddr = 0;
649650
p_cdc->bInterfaceNumber = 0;
651+
p_cdc->mounted = false;
650652
tu_edpt_stream_close(&p_cdc->stream.tx);
651653
tu_edpt_stream_close(&p_cdc->stream.rx);
652654
}
@@ -747,6 +749,7 @@ bool cdch_open(uint8_t rhport, uint8_t daddr, tusb_desc_interface_t const *itf_d
747749

748750
static void set_config_complete(cdch_interface_t * p_cdc, uint8_t idx, uint8_t itf_num) {
749751
TU_LOG_DRV("CDCh Set Configure complete\r\n");
752+
p_cdc->mounted = true;
750753
if (tuh_cdc_mount_cb) tuh_cdc_mount_cb(idx);
751754

752755
// Prepare for incoming data

0 commit comments

Comments
 (0)