In concept, writing a Linux system driver shouldn’t be that onerous, however it’s tougher than it appears. Nonetheless, utilizing libusb, you’ll be able to simply take care of USB gadgets from consumer area, which, for a lot of functions, is ok. [Crescentrose] didn’t know something about writing user-space USB drivers till they wrote one and documented it for us. Oh, the code is in Rust, for which there aren’t as many examples.
The system in query was a USB hub with some further lights and devices. So the actual concern, it appears to us, wasn’t the code, however determining the protocol and the USB stack. The put up covers that, too, explaining configurations, interfaces, and endpoints.
There are different ancillary subjects, too, like establishing udev. This allows you to load issues when a USB system (or one thing else) plugs in.
After all, you got here for the principle code. The Rust program is pretty simple after you have the preliminaries out of the way in which. The libusb library helps quite a bit. By the top, the code kicks off some threads, handles interrupts, and does different device-driver-like issues.
So when you like Rust and also you ever considered a consumer area system driver for a USB system, that is your probability to see it finished. It didn’t take years. Nonetheless, you are able to do quite a bit in consumer area.