eclipse-threadx / usbx

Eclipse ThreadX - USBX is a high-performance USB host, device, and on-the-go (OTG) embedded stack, that is fully integrated with Eclipse ThreadX RTOS
https://github.com/eclipse-threadx/rtos-docs/blob/main/rtos-docs/usbx/index.md
MIT License
148 stars 88 forks source link

Automatically activate/deactivate CDC ECM #114

Open ZerAtaii opened 11 months ago

ZerAtaii commented 11 months ago

Hi, I use Azure RTOS with the netxduo layer to manage TCP/IP sockets. The application exchanges a set of commands through netcat via "Windows sub Linux" on different ports (32071 to 32076) with an ethernet over USB protocol (CDC ECM). In my application, there are different communication buses, wifi / BLE / cellular network / IOT (through cellular or WIFI). When there is an error in one, the whole system is "blocked" (no more inputs from USB but the system is still running). After a delay of 29mins, 2 functions are triggered (ux_slave_class_cdc_ecm_instance_activate and ux_slave_class_cdc_ecm_instance_deactivate) and everything works fine after this. Do you know how to automatically trigger these functions after a few minutes without communication?

usb_IF

Best regards, Antoine

xiaocq2001 commented 11 months ago

I guess ux_slave_class_cdc_ecm_instance_activate and ux_slave_class_cdc_ecm_instance_deactivate is triggered by a USB bus reset from host side, maybe you can consider adjust some timeout setting on your host side?

On device side, there is usually some way in device controller hardware that can "detach" from host, there is no API for detaching, but you can try to operate the hardware to "detach" and "attach" again to let host re-enumerate your device.

ZerAtaii commented 11 months ago

For this project, the USB host is a Windows PC running WSL. I send a curl command and after a while the download speed drops to 0. From then on, I'm no longer able to communicate via the USB connection. The 2 CDC functions allow me to reinstantiate the whole chain and solve the problem. I don't think we can blame the USB host when it's just a simple PC? I could manually trigger the functions, but how do i know when i'm actually dealing with the bug?