Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I am new to Linux. I have been programming for over 15 years, mostly C/C++ and assembly.
I have been assigned the task of writing a User Space Device Driver for a USB device. The device is a barcode scanner which the system sees as a Keyboard.
I am trying to figure out how to know when a new device is plugged into the computer so that the device driver can be started and receive information from the scanner.
I am trying to use usbfs and libusb in writing this driver.
If I am wrong or you can point me in the correct path I would be very appreciative.
An interesting question. It doesn't seem to me that a "device driver" in the usual (kernel) sense will be needed. This will be an interface library to be used by the application-program ... it seems of little use to me to try to treat this device as "a separate device-type" nor to mount it globally to the system. For that reason, it seems irrelevant to "detect when the device is plugged-in."
The interface-library might poll the various USB devices and see which one identifies itself as a scanner... "/proc" or "/sys" or "/dev" and so-forth can tell you that (see lsusb and its man-page). Then open that device and make it very easy for the application to do what it needs to do with the device.
But it's just a user library, and I'll daresay that a suitable one probably already exists. . .
You opinions is right. The usb driver libraries have been wrote, you can download them, in china I have tried to do this, and we have a relerant paper for this problem now, but it is in Chinese, sorry,
Then maybe you can find another documentation about your opinions now,
I think it is very useful, but it is not efficent, ........of cource you can port your usb drivers to other OS, provided you have completed your projetcts,,,,,
The barcode scanner software that I am working on is for an embedded system and there may be more than one connected to the system at any one time. I thought of polling and placed that before the management but they said that it was unexceptable. The barcode scanner currently shows up as a keyboard usb device.
Once again, I thank you for your help and suggestions.
As you'll see, an application-library can scan the USB devices to find out just what kind of device they are, e.g. as lsusb does. So, when asked to open a scanner, it can look to find one that isn't already in-use. And so on.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.