|
USBIP C library 0.7.0
Virtual USB devices & host drivers over USB/IP
|
One program can serve several independent USB devices at once.
Plug each onto the same transport and they share one listener: the host enumerates them all, attaches them separately, and detaching one leaves the others alone.
This is not the same as a composite device. A composite is ONE device with several functions, seen under one VID/PID and attached once; several devices are separate products that happen to be emulated by one program, each with its own descriptors, its own busid, its own endpoint space (both can use 0x81) and its own attach.
Nothing else changes: each device is built exactly as it would be on its own.
Devices are named on the wire by busid, assigned 1-1, 1-2, ... in plug order - what an importer selects:
Each import is independent: the host binds a separate driver to each device, exactly as if you had plugged in two.
usbip_device_set_busid() pins a name when plug order is not stable enough (call it before usbip_device_plug()), and usbip_device_get_busid() reads back the one in effect - handy for the "attach with this" line an example prints. Importing a busid nobody exports is refused, rather than served some other device.
usbip_host_get_device_list() returns every exported device and usbip_host_open_vid_pid() picks one by identity, so a host program needs no changes. The libusb-1.0 drop-in (Wrappers) reports them as separate devices with distinct bus/device addresses, so a stock libusb program sees both.
The listener is shared by address, so the second usbip_device_plug() on 0.0.0.0:3240 joins the first one's socket instead of failing to bind.