Linux USB programming

2019-06-18 15:54发布

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?

标签: c linux usb kernel
2条回答
兄弟一词,经得起流年.
2楼-- · 2019-06-18 16:44

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

查看更多
啃猪蹄的小仙女
3楼-- · 2019-06-18 16:46

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.

查看更多
登录 后发表回答