LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How hard is it to write a USB device driver? (https://www.linuxquestions.org/questions/programming-9/how-hard-is-it-to-write-a-usb-device-driver-837446/)

Daravon 10-11-2010 12:51 PM

How hard is it to write a USB device driver?
 
I know, I know..."How long is a piece of string"?

I have one of these devices:

http://www.cyberopticssemi.com/PDFs/...ta%20Sheet.pdf

Of course, it's Windows only, and XP only at that. However, the data that needs transferred between the device and the computer should be fairly basic, unless it offloads a lot of processing to the computer. I'm not a programmer, nor do I play one on TV, but I have written some fairly complicated microcontroller programs and some basic Java GUIs. Besides writing the actual code, how hard is it to do whatever needs done to make a Linux device driver, apart from the code to make the device work?

GrapefruiTgirl 10-11-2010 01:01 PM

How to write a Linux USB device driver.

That article should be a good place to start. It appears to walk you through the entire process. :)

Since you have some programming experience, you are ahead of the game already. I'm not a kernel module programmer either, but if I were looking for what you're asking for, I'd do what I just did and use Google, with a query of "writing Linux kernel driver".

Also, don't quote me but there may be a downloadable version of "Linux Kernel in a Nutshell" or at least a similar publication, I believe another one is "Linux Kernel Module Programming" - if you can find either of these, you would do well to grab them. But, that article really is thorough, so have a look at that, and if you get a more specific question(s), by all means ask away!

EDIT: P.S. I neglected to mention, a great place also to have a look, is in the source code of an existing kernel driver module, for a similar USB device, if there is a similar one already in the kernel. Perhaps one can be modified to work with your device or at least provide a template from which to work on your own.

neonsignal 10-12-2010 04:38 AM

Quote:

Originally Posted by Daravon (Post 4124134)

Many measurement devices run a virtual serial link over the USB or bluetooth connection (for example, an SPP profile over bluetooth). The manufacturer might be willing to at least acknowledge this if you were to ask. Try plugging it into the Linux box and see what dmesg reports about the USB.

So you might not even need to write a driver per se; you might just have to write some code to interpret the data stream from the bluetooth link (which is self pairing, so probably transparent).

However, it is quite likely that the basic sensor data has to be processed at the computer end in order to provide useful results. To do this, you will either need a good understanding of how the leveling sensor works, or will need to get more details from the manufacturer. My guess is that it is a 2D accelerometer, so there may be calibration values involved (offset and range), filtering, and conversion to angles.

Some manufacturers of niche products like this may be willing to provide more information, especially if you were to offer to contribute your code back to them; they probably don't have the resources to write drivers for multiple platforms, and they are in the business of selling hardware, not software.


All times are GMT -5. The time now is 05:47 AM.