Closed zhuyeaini9 closed 1 year ago
Sorry, but i dont understand the problem you have. You cant create IN or OUT response on esp32, it is controlled by host driver:
I have one usb device which can return magnet info when send cmd like "rm" or "rc" to it. now I can attach this device under ubuntu succesfully,the now port /dev/ttyUSB1 appeared. then I open it with the tool CuteCom successfully and send the cmd "rm" to the port: it should return some magnet info from the device as usual,but no info returned. I can see the send cmd "rm" from the esp32's log of USBIP_CMD_SUBMIT with OUT direction. but I can not see the IN direction of USBIP_CMD_SUBMIT which I can send the data back to ubuntu. the tool CuteCom can work well when plug the usb device directly to ubuntu. from your advice: IN - its data transfer from device to host, but its still initialized by host. the IN should come from the host,but now it seems not come,any advice is welcome!!! thanks!!!
Sorry, i dont know why you dont get IN answer. This is PoC code, its not finished and wont work with some devices.
You should study how USB works, also here is some info about USB/IP: https://docs.kernel.org/usb/usbip_protocol.html
thanks your reply. it seems that the usbip not send the IN direction of USBIP_CMD_SUBMIT.
now I can see the reply from esp32 when send some cmd after add follow code in init code: it call the usb_host_transfer_submit on the IN direction of endpointaddress. ` //--------------------------------------------------------------------------------------------- if (ep->bEndpointAddress & 0x80) { esp_err_t err = usb_host_interface_claim(_host->clientHandle(), _host->deviceHandle(), n, 0); ESP_LOGI("usb_host_interface_claim", "interface number: %d", n);
` and the message can be get from the data_read callback when send some cmd to esp32. now the problem is send these data back to client(pc).
I can see the cmd send from client and the reply(the direction is 0 OUT):
the reply is just the send cmd's reply,not contain the message from the cmd. so where is the chance to send the message back to client? the direction is 0 (OUT) when send cmd to esp32. I cann't see the direction 1(IN) of USBIP_CMD_SUBMIT. it has some error (socket close)when I send the message back directly to client. from the usbip protocol,it seems should have USBIP_CMD_SUBMIT and reply USBIP_RET_SUBMIT. any advice is welcome.