ESP32S3 USB CDC设备通信缓冲区问题

xinhaojie
Posts: 57
Joined: Wed Feb 23, 2022 10:56 am

ESP32S3 USB CDC设备通信缓冲区问题

Postby xinhaojie » Mon Jun 13, 2022 1:46 am

环境 win11 ESP IDF4.4.1 ESP32S3

测试用例代码如下:
void tinyusb_cdc_rx_callback(int itf, cdcacm_event_t *event)
{
/* initialization */
size_t rx_size = 0;
static uint32_t recv_total_len = 0;
static uint32_t count = 0;

/* read */
esp_err_t ret = tinyusb_cdcacm_read(itf, buf, CONFIG_TINYUSB_CDC_RX_BUFSIZE, &rx_size);
if (ret == ESP_OK) {
buf[rx_size] = '\0';
ESP_LOGI(TAG, "Got data (%d bytes): %s", rx_size, buf);
} else {
ESP_LOGE(TAG, "Read error");
}
}

在官方的CDC测试用例代码中,我尝试修改了RX TX FIFO大小,但是这个回调函数每次读取到的数据最大也就是64字节。修改了很多地方对这个值都没有影像。数据无论发送多快都是每次只接收到64字节。并且在一次回调中多次调用tinyusb_cdcacm_read接口,但是从第二次调用开始都会返回失败。
我想达到的目的是:加大缓冲区大小,尽量减少调用这个回调函数,减少cpu负载。

I (497) TinyUSB: TinyUSB Driver installed
I (497) example: USB initialization DONE
I (797) example: Line state changed! dtr:0, rst:0
I (857) example: Line state changed! dtr:0, rst:0
I (5697) example: Line state changed! dtr:0, rst:0
I (5707) example: Line state changed! dtr:0, rst:0
I (6597) example: Got data (64 bytes): test575275727527522752775242752427575375752752275242737527527521
I (6607) example: Got data (64 bytes): 2753753546546456456456456456456789789789643786789789789789789789
I (6617) example: Got data (50 bytes): 789546456456213123123123123123123123123123123123c7
I (8797) example: Got data (64 bytes): test575275727527522752775242752427575375752752275242737527527521
I (8807) example: Got data (64 bytes): 2753753546546456456456456456456789789789643786789789789789789789
I (8817) example: Got data (50 bytes): 789546456456213123123123123123123123123123123123c7

xinhaojie
Posts: 57
Joined: Wed Feb 23, 2022 10:56 am

Re: ESP32S3 USB CDC设备通信缓冲区问题

Postby xinhaojie » Tue Jun 21, 2022 2:17 am

这个问题官方能关注下不。我想修改cdc的buffer大小,减少我回调函数调用次数。但是修改了配置之后还是每64字节回调一次。我知道usb短点数据大小是64.修改了源代码中各个我认为有效果的位置都没有改变。

xinhaojie
Posts: 57
Joined: Wed Feb 23, 2022 10:56 am

Re: ESP32S3 USB CDC设备通信缓冲区问题

Postby xinhaojie » Sun Jul 10, 2022 1:27 am

手工置顶

llzzdd
Posts: 26
Joined: Thu Apr 18, 2024 3:14 am

Re: ESP32S3 USB CDC设备通信缓冲区问题

Postby llzzdd » Mon May 20, 2024 5:35 am

您好,我现在也是有问题,一直发送数据,发送一段时间后,就会发送错误,固定发送数据量,有时候就会突然卡1s多不发送

Who is online

Users browsing this forum: Baidu [Spider] and 36 guests