ESP32-S3 - Two way USB comunication
Posted: Fri Jan 13, 2023 9:58 am
Hi,
I want to communicate with EPOS printer using ESP32-S3 as a host. Everything is working fine as long I'm sending data to the printer. But this printer have two endpoints IN and OUT. To get information about the status of the printer etc. I need to read data coming from the printer. So my question is: What is the correct way to read IN endpoint?
What I'm doing now is sending starting communication like here every time I send something to the printer to get a possible answer:
But after this, I got a rapid callback with USB_TRANSFER_STATUS_COMPLETED and transfer->actual_num_bytes == 0 or 64, but sometimes with some data. Maybe I don't understand something but I thought I should get USB_TRANSFER_STATUS_TIMED_OUT when nothing is received in 5 seconds and USB_TRANSFER_STATUS_COMPLETED only when something is received.
I tried to find any examples with both-way communication but anything I can find is CDC component, but this is slightly different because there is another notify endpoint.
What is the best way to poll IN endpoint?
I want to communicate with EPOS printer using ESP32-S3 as a host. Everything is working fine as long I'm sending data to the printer. But this printer have two endpoints IN and OUT. To get information about the status of the printer etc. I need to read data coming from the printer. So my question is: What is the correct way to read IN endpoint?
What I'm doing now is sending starting communication like here every time I send something to the printer to get a possible answer:
Code: Select all
esp_err_t read_request(void)
{
esp_err_t err;
xfer_in->num_bytes = 64;
xfer_in->device_handle = last_driver->dev_hdl;
xfer_in->bEndpointAddress = endpoint_in_address;
xfer_in->callback = receive_cb;
xfer_in->timeout_ms = 5000;
xfer_in->context = last_driver;
err = usb_host_transfer_submit(xfer_in);
ESP_LOGI(TAG, "read_request - start - 0x%04X", err);
return ESP_OK;
}
I tried to find any examples with both-way communication but anything I can find is CDC component, but this is slightly different because there is another notify endpoint.
What is the best way to poll IN endpoint?