开发者

Linux USB programming

开发者 https://www.devze.com 2023-03-15 10:23 出处:网络
I am new to Linux kernel programming. I wish to develop a program to read USB drive information like its manufacturer name, capacity, etc. I know about descriptors and their attributes. But I don\'t u

I am new to Linux kernel programming. I wish to develop a program to read USB drive information like its manufacturer name, capacity, etc. I know about descriptors and their attributes. But I don't understand how to enumerate USB drives connected to the system. I am looking for the function which initiates connection between kernel and USB port. How is it possible开发者_高级运维?


You don't need to program the kernel as such - in fact to read the device info you don't even need a device driver.

The USB system is different in the newer 2.6 kernels so a lot of the online tutorials may be out of date - but start here http://www.linux-usb.org/

If you do want to write a USB device driver see this Linux journal tutorial


Do you really want to do a kernel programming? There is an lsusb utility, capable of reading "USB drive information like its manufacturer name", descriptors... It also can enumerate all usb devices.

Sources of lsusb are e.g. here http://www.google.com/codesearch#VKTEFMx6wp0/lsusb.c

If you are doing a writing an USB driver, which works in kernel mode, I suggest you read some existing usb driver and USB driver programming FAQ.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号