LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 08-30-2007, 12:48 AM   #1
i_love_linux
LQ Newbie
 
Registered: Aug 2007
Location: India
Posts: 8

Rep: Reputation: 0
Smile 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?
 
Old 08-30-2007, 03:13 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
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.
 
Old 08-31-2007, 04:37 AM   #3
i_love_linux
LQ Newbie
 
Registered: Aug 2007
Location: India
Posts: 8

Original Poster
Rep: Reputation: 0
Question 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?
 
Old 08-31-2007, 11:23 AM   #4
ravime
LQ Newbie
 
Registered: Jul 2007
Posts: 24

Rep: Reputation: 15
Quote:
Originally Posted by i_love_linux View Post
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
 
Old 09-04-2007, 12:23 AM   #5
i_love_linux
LQ Newbie
 
Registered: Aug 2007
Location: India
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by ravime View Post
NO. Just insert and you can use that driver
Ok.. Thanks. .. I am gonna try it today.
 
Old 09-04-2007, 09:25 AM   #6
johnhamiltion
Member
 
Registered: Aug 2007
Posts: 92

Rep: Reputation: 15
Quote:
Originally Posted by i_love_linux View Post
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.
 
Old 09-04-2007, 07:16 PM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Device Driver Writing Guide SJD Linux - Hardware 1 04-11-2007 12:01 PM
Writing Device Driver... okeyla Programming 3 05-18-2005 07:41 AM
writing printer device driver in linux sidbash Programming 3 07-04-2004 11:16 PM
Need help in writing device driver eshwar_ind Programming 1 02-07-2004 03:46 PM
Quick and easy solution for writing a linux device driver? mr_segfault Programming 5 01-08-2004 10:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 07:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration