| Linux - Kernel This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
08-30-2007, 12:48 AM
|
#1
|
|
LQ Newbie
Registered: Aug 2007
Location: India
Posts: 8
Rep:
|
Writing Simple Device Driver In Linux
Hi,
I want to ask is suppose I have one device which operates on serial port. I want to read/ write into this device using linux. How should I start with it? And where can I see the data coming from this device? Like in windows you have hyperterminal to view data transaction from and in serial port of PC. As I am new to write device driver I have asked such a basic question. I think this would be a smiplest device driver to start with. Can anyone help me out with this please? 
|
|
|
|
08-30-2007, 03:13 PM
|
#2
|
|
Moderator
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,476
Rep: 
|
If you plan to write your own serial port driver, you will need to actually write the driver for your special needs. If you just need to use the port, you can stay in the user space. Of course, you can write it as driver, too. Your program will look differently as module an as user-space program.
To access serial port you can use a tool like minicom. The port is just a file, so you can read/write to it. Serial ports are /dev/ttyS0, /dev/ttyS1 and so on.
|
|
|
|
08-31-2007, 04:37 AM
|
#3
|
|
LQ Newbie
Registered: Aug 2007
Location: India
Posts: 8
Original Poster
Rep:
|
Inserting Device Driver In Linux
Thanks Mara. One more thing that I want to ask is if I write a code for device driver and later on insert its module then do I need to recompile the kernel to use this device driver?
|
|
|
|
08-31-2007, 11:23 AM
|
#4
|
|
LQ Newbie
Registered: Jul 2007
Posts: 24
Rep:
|
Quote:
Originally Posted by i_love_linux
Thanks Mara. One more thing that I want to ask is if I write a code for device driver and later on insert its module then do I need to recompile the kernel to use this device driver?
|
NO. Just insert and you can use that driver
|
|
|
|
09-04-2007, 12:23 AM
|
#5
|
|
LQ Newbie
Registered: Aug 2007
Location: India
Posts: 8
Original Poster
Rep:
|
Quote:
Originally Posted by ravime
NO. Just insert and you can use that driver
|
Ok.. Thanks.  .. I am gonna try it today.
|
|
|
|
09-04-2007, 09:25 AM
|
#6
|
|
Member
Registered: Aug 2007
Posts: 92
Rep:
|
Quote:
Originally Posted by i_love_linux
Hi,
I want to ask is suppose I have one device which operates on serial port. I want to read/ write into this device using linux. How should I start with it? And where can I see the data coming from this device? Like in windows you have hyperterminal to view data transaction from and in serial port of PC. As I am new to write device driver I have asked such a basic question. I think this would be a smiplest device driver to start with. Can anyone help me out with this please? 
|
I think that Greg Kroah-Hartman deals with this in his book
"Linux Device Drivers 3."
You can download it (as a single web-page) from
http://m.domaindlx.com/LinuxHelp/ldd3/about-ldd3.htm or
Last edited by jtshaw; 04-06-2008 at 11:37 AM.
|
|
|
|
09-04-2007, 07:16 PM
|
#7
|
|
Senior Member
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 4,573
|
When a device attaches to a serial port, you should consider carefully how the intended clients will view the device ... and whether the purpose of the device is truly "generic" or "application specific."
If this device provides a generic service to the system, then you can build a kernel-level driver for it.
If, on the other hand, the device is application specific, maybe what you want is a simple library... a set of functions and procedures that can be called by the program, all in user-land.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:46 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|