|
|
|
|
|
by GoldenStake
4102 days ago
|
|
As someone who has never needed to write device drivers, this is pretty interesting toy example. I was a bit confused when it got to the part about
> detach (unbind) the kernel driver
Does this mean there is a default kernel driver on the interface and we must detach it first to make it available? |
|
Yes. Sometimes, and most prominently: A lot of cheap gizmos register themselves as "HID" (human interface devices) which is a class normally reserved for keyboards and mice. Windows, Linux, OSX, ... have default drivers, and the HID protocols implements a channel for arbitrary data to be passed to/from the device (/dev/hidraw* in Linux). In turn it allows people to talk to the "USB rocket launcher" providing a simple executable application, without needing to register a driver.
If you want to talk to the usb device using libusb (or the python bindings) you have to unbind this generic driver. You can either do it from within libusb, or for example, in the sys filesystem.
For a USB ethernet adapter (which I happen to have laying around):
...so it's bound to device 2-1.1:1.0 ... ...ethernet interface is now gone, I can, theoretically, now talk to the device using libusb.Another example: Some programming cables for microcontroller development (similar to, e.g. the Arduino stuff) might have use a standard USB-to-Serial bridge chip. But as you have to talk to it in a non-standard way you'd have to unbind the default usb-to-serial kernel module and talk directly to the usb device.