你好,
在运行示例程序 esp32-s2-usb-host-cdc 时,当与设备通讯有段时间之后,串口打印错误信息:
[0;33mW (1922332) : BULK IN, dir: 1, err: 0x103[0m
之后发现无法收到USB的数据了,请问这是什么原因导致出现这个错误的?
下面是原来的代码
void xfer_in_data()
{
ESP_LOGD("", "EP: 0x%02x", USB_DESC_EP_GET_ADDRESS(&endpoints[EP2]));
cdc_ep_irps[EP2]->num_bytes = bMaxPacketSize0; //1 worst case MPS
cdc_ep_irps[EP2]->num_iso_packets = 0;
cdc_ep_irps[EP2]->num_bytes = 64;
esp_err_t err;
if(ESP_OK != (err = hcd_irp_enqueue(cdc_ep_pipe_hdl[EP2], cdc_ep_irps[EP2]))) {
ESP_LOGW("", "BULK %s, dir: %d, err: 0x%x", "IN", USB_DESC_EP_GET_EP_DIR(&endpoints[EP2]), err);
}
}
这是我修改后的代码
void xfer_in_data()
{
ESP_LOGD("", "EP: 0x%02x", USB_DESC_EP_GET_ADDRESS(&endpoints[EP2]));
cdc_ep_irps[EP2]->actual_num_bytes = bMaxPacketSize0; //1 worst case MPS
cdc_ep_irps[EP2]->num_iso_packets = 0;
cdc_ep_irps[EP2]->num_bytes = 1024;
esp_err_t err;
if(ESP_OK != (err = hcd_irp_enqueue(cdc_ep_pipe_hdl[EP2], cdc_ep_irps[EP2]))) {
ESP_LOGW("", "BULK %s, dir: %d, err: 0x%x", "IN", USB_DESC_EP_GET_EP_DIR(&endpoints[EP2]), err);
}
}
可是还是出现同样的错误。查询发现是cdc_ep_irps[EP2]->reserved_flags为0x02(IRP_STATE_INFLIGHT),请问是数据还没接收完吗?应该如何解决?
esp32-s2-usb-host-cdc 示例程序接收错误问题
Moderator: ESP_Bob
Re: esp32-s2-usb-host-cdc 示例程序接收错误问题
Are you using example from my repository by any chance? That repository is mark as archived, because USB host API in esp-idf evaluated and here you can find new library with examples which works with esp-idf master:
https://github.com/chegewara/esp32-usb-host
and here is docs if you would like to write own code from scratch:
https://docs.espressif.com/projects/esp ... _host.html
https://github.com/chegewara/esp32-usb-host
and here is docs if you would like to write own code from scratch:
https://docs.espressif.com/projects/esp ... _host.html
Who is online
Users browsing this forum: No registered users and 35 guests