PDA

View Full Version : Writing raw USB data



Poincare
05-22-2010, 07:17 PM
Hi. I have a few question about USB on linux. Firstly, how do I know which file descriptor in the /dev/ section is USB? Secondly, how can I write raw code to it? Would I have to write a kernel level driver?

MK27
05-22-2010, 07:41 PM
Hi. I have a few question about USB on linux. Firstly, how do I know which file descriptor in the /dev/ section is USB?

USB devices begin with "s", eg storage devices are sd. Stuff like this is listed here:

http://www.kernel.org/pub/linux/docs/device-list/devices-2.6+.txt

Pretty sure there is a copy in with the kernel source.



Secondly, how can I write raw code to it? Would I have to write a kernel level driver?

Yep.

Poincare
05-22-2010, 07:56 PM
examples of writing a USB driver?

MK27
05-22-2010, 08:07 PM
Heh-heh.

Linux Device Drivers, Third Edition [LWN.net] (http://lwn.net/Kernel/LDD3/)

Major issue will be the nature of the device itself. You communicate via "endpoints" that functional aspects of the hardware, so you almost certainly need the specifications for it. You can get the standards for such here:

USB.org - Documents (http://www.usb.org/developers/docs/)

but the actual specific ones you need to get from the manufacturer. The above link will help you to understand them, once you have read up enough about (usb) drivers. So this is a fairly serious undertaking.

Subsonics
05-22-2010, 08:54 PM
Actually there is something known as "scsi pass through", that uses ioctl calls to send scsi control messages to usb devices available on Linux. It gives you kernel space control over a usb device from user space.