Re: SV: Accessing serial ports from a loadable module (from kernel space)

From: Greg KH (greg@kroah.com)
Date: Tue Feb 22 2000 - 00:21:14 EST


Hi Jörgen,

On Mon, Feb 21, 2000 at 11:35:53PM +0100, Jörgen Overgaard wrote:
> Hi Greg,
>
> and thanks for your answer.
>
> I'll try to answer your question as good as I can. Hihi.
> I'm running a program called SatTrack that can write some information (like position, frequency, etc)
> to any TTY or even a file.
> Maybe you have run into this program or even using it.
> Anyway... I needed some way of controlling my radios frequency aswell as my antennas automagicly from
> the Linux box. The radios can be controlled via a serial port. The protocol they use is CI-V.
>
> I've come so far that my "program / driver" gets the data (SatTrack writes to /dev/ci-v) and does some
> formatting / protocol,etc.
>
> I bet you and all you others out there know some other way to to this, but since I got interested in kernel programming /
> device drivers I decided to try and solve my problem, and at the same time broaden my knowlage in Linux. :-)
>

Ok, let me see if I understand what you are trying to do:

+----------+ +-------------+ +------------+ +-------------+ +-------+
| SatTrack | <--> | your driver | <--> | tty driver | <--> | serial port | <--> | radio |
+----------+ +-------------+ +------------+ +-------------+ +-------+

Is this correct?

If so, and you REALLY want to write a driver, you might want to try:

+----------+ +-------------+ +-------------+ +-------+
| SatTrack | <--> | your driver | <--> | serial port | <--> | radio |
+----------+ +-------------+ +-------------+ +-------+

and have your driver take over the serial port logic.

Now that would involve a lot of duplication of the serial tty driver in
your driver, but would allow you to write a driver that should do what
you need.

But you could just do the following, if you want to stay out of kernel
space:

+----------+ +--------------+ +------------+ +-------------+ +-------+
| SatTrack | <--> | your program | <--> | tty driver | <--> | serial port | <--> | radio |
+----------+ +--------------+ +------------+ +-------------+ +-------+

And have all of your formatting logic live in a user program which just
reads the data from the file that the SatTrack program is outputting and
spits out the correct serial commands to the serial driver.

Does this sound like what you want to do?

> I'm still open for all suggestions though! Hihi :-)
>
> You also wrote:
> "That being said, you could have your driver implement the tty interface,
> thereby looking like a serial port to any user applications."
>
> I'm not sure I'm following you quite there. (Could be my understanding of english language), but please take your time
> to explain. I'm here to learn! :-)

Your driver can implement the tty interface, looking like a tty device
to userspace. For instance, the usb-serial driver looks like a tty
device to all user programs that interface to it, but it spits out and
talks USB out through kernel space. The usb-serial driver implements a
tty driver interface.

Take a look at include/linux/tty_driver.h for more description of what a
tty driver needs in order to hook up to the tty system.

Hope this helps, and if you have anymore questions, please feel free to
ask.

greg k-h
greg@kroah.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Feb 23 2000 - 21:00:29 EST