MicroPython provides 'network.LAN' and 'network.WLAN' but is there anything which provides 'network.USB' which supports networking over USB, any resources which would help someone create such a thing ?
There have been some successful efforts to provide USB networking on a Pico but they have bridged TinyUSB directly to LwIP. Something more MicroPythonic would be better.
I have enabled TinyUSB networking, have added enough to get that built and 'nic = network.USB()' working, so am now trying to figure out how to move on from there.
network.USB ?
Re: network.USB ?
Just to clarify what you mean... my interpretation is "the Pico uses an external usb ethernet adaptor connected via usb-otg". i.e. the Pico is a USB _host_.
There's three main parts:
- implementation of a USB host stack (tiny usb supports this, although generally we haven't yet figured out a good plan for "host mode" usb in MicroPython)
- implementation of the net class driver (tiny usb supports this as a device, but not as a host afaict)
- bridging that to lwip and providing a LAN adaptor (not too complicated, see how this is done for wiznet, etc)
But having said that now I'm wondering if possibly you mean that Pico is a usb _device_, and it presents as a network device to the PC, allowing the PC to talk to the Pico via a network interface (over the USB cable). Similar to what you do with something like a Raspberry Pi using libcomposite/gadget mode. This is likely a lot simpler to implement, and much like how we already use TinyUSB's MSC support.
Re: network.USB ?
Yes, exactly that - Apologies for not being clearer.jimmo wrote: ↑Fri Jul 15, 2022 2:49 pmBut having said that now I'm wondering if possibly you mean that Pico is a usb _device_, and it presents as a network device to the PC, allowing the PC to talk to the Pico via a network interface (over the USB cable). Similar to what you do with something like a Raspberry Pi using libcomposite/gadget mode. This is likely a lot simpler to implement, and much like how we already use TinyUSB's MSC support.
Similar to MSC when you plug a Pico into a Pi/PC then access its disk from the Pi/PC. Plug this in and then one can ping it from the Pi/PC, fetch web pages from it, assuming there's a MicroPython coded web server running.
And, like a Pico-W using 'network.WLAN', one can run MicroPython code to request web pages, except the request will go via the USB to the Pi/PC which will have to be running whatever routing stuff it needs to bridge it to the local network or outside world.
The 'extmod/network_wiznet5k.c' module is indeed what I have based what I have done so far on, most of its guts ripped out so just a skeleton, no actual functionality.
I did see some references to a 'network.SLIP' which looked like it would be useful, but the github's gone and it seems the author pivoted to doing it a direct via UART way anyway.