@@ -110,9 +110,8 @@ static esp_err_t _ringbuf_pop(RingbufHandle_t ringbuf_hdl, uint8_t *buf, size_t
110110static esp_err_t _ringbuf_push (RingbufHandle_t ringbuf_hdl , const uint8_t * buf , size_t write_bytes , TickType_t ticks_to_wait )
111111{
112112 int res = xRingbufferSend (ringbuf_hdl , buf , write_bytes , ticks_to_wait );
113-
114113 if (res != pdTRUE ) {
115- ESP_LOGW (TAG , "The in buffer is too small , the data has been lost" );
114+ ESP_LOGW (TAG , "The ringbuffer is full , the data has been lost" );
116115 return ESP_FAIL ;
117116 }
118117 return ESP_OK ;
@@ -392,8 +391,9 @@ static void in_xfer_cb(usb_transfer_t *in_xfer)
392391 if (data_len + in_xfer -> actual_num_bytes >= cdc -> in_ringbuf_size ) {
393392 // TODO: add notify cb for user
394393 // if ringbuffer overflow, drop the data
395- ESP_LOGD (TAG , "in ringbuf full" );
394+ ESP_LOGW (TAG , "CDC in ringbuf is full! " );
396395 } else {
396+ ESP_LOG_BUFFER_HEXDUMP (TAG , in_xfer -> data_buffer , in_xfer -> actual_num_bytes , ESP_LOG_DEBUG );
397397 if (_ringbuf_push (cdc -> in_ringbuf_handle , in_xfer -> data_buffer , in_xfer -> actual_num_bytes , pdMS_TO_TICKS (TIMEOUT_USB_RINGBUF_MS )) != ESP_OK ) {
398398 ESP_LOGE (TAG , "in ringbuf push failed" );
399399 }
@@ -619,7 +619,7 @@ static esp_err_t _cdc_open(usbh_cdc_t *cdc)
619619 ESP_ERROR_CHECK (usb_host_get_active_config_descriptor (cdc -> dev_hdl , & config_desc ));
620620 ESP_ERROR_CHECK (usb_host_get_device_descriptor (cdc -> dev_hdl , & device_desc ));
621621
622- cdc_parsed_info_t cdc_info ;
622+ cdc_parsed_info_t cdc_info = { 0 } ;
623623 ret = cdc_parse_interface_descriptor (device_desc , config_desc , cdc -> intf_idx , & cdc -> data .intf_desc , & cdc_info );
624624 if (ret != ESP_OK ) {
625625 goto err ;
@@ -795,12 +795,12 @@ esp_err_t usbh_cdc_read_bytes(usbh_cdc_handle_t cdc_handle, const uint8_t *buf,
795795 usbh_cdc_t * cdc = (usbh_cdc_t * ) cdc_handle ;
796796 ESP_GOTO_ON_FALSE (cdc -> state == USBH_CDC_OPEN , ESP_ERR_INVALID_STATE , fail , TAG , "Device is not connected" );
797797
798- size_t data_len = _get_ringbuf_len ( cdc -> in_ringbuf_handle ) ;
799- if (data_len > * length ) {
800- data_len = * length ;
798+ size_t data_len = * length ;
799+ if (data_len > CONFIG_IN_RINGBUFFER_SIZE ) {
800+ data_len = CONFIG_IN_RINGBUFFER_SIZE ;
801801 }
802802
803- ret = _ringbuf_pop (cdc -> in_ringbuf_handle , (uint8_t * )buf , data_len , length , pdMS_TO_TICKS ( TIMEOUT_USB_RINGBUF_MS ) );
803+ ret = _ringbuf_pop (cdc -> in_ringbuf_handle , (uint8_t * )buf , data_len , length , ticks_to_wait );
804804 if (ret != ESP_OK ) {
805805 ESP_LOGD (TAG , "cdc read failed" );
806806 * length = 0 ;
0 commit comments