View Full Version : Module development - how to start ?
vaclavpe@gmail
21-02-2009, 05:50 AM
Hello all and sorry for (probably stupid) question.
I need to capture data from UART, analyze them and then one of
reactions is to read some internal registers in ARM and send them back
to UART.
The problem is that the process must be really fast, allowed delay is
around 1ms. So I was thinking to do it in kernel space (speed, direct
reading of memory registers). But I can not find the way how to use
actual serial driver in my code. I feel that I can't use /dev/ttySx
directly, can I ?
Probably the first step will be to try everything in user space.
Or does anybody have better idea ? Can you point me there ?
Thank you in advance,
V.
david
21-02-2009, 05:58 AM
On Fri, 20 Feb 2009 07:50:58 -0800, vaclavpe@gmail rearranged some
electrons to say:
> Hello all and sorry for (probably stupid) question.
>
> I need to capture data from UART, analyze them and then one of reactions
> is to read some internal registers in ARM and send them back to UART.
>
> The problem is that the process must be really fast, allowed delay is
> around 1ms. So I was thinking to do it in kernel space (speed, direct
> reading of memory registers). But I can not find the way how to use
> actual serial driver in my code. I feel that I can't use /dev/ttySx
> directly, can I ?
>
> Probably the first step will be to try everything in user space.
>
> Or does anybody have better idea ? Can you point me there ?
>
> Thank you in advance,
> V.
Not sure what speed you're running your serial port, but, for example,
at 9600 bps, it will take 1 ms to just to receive or transmit one
character.
Janaka
23-02-2009, 01:19 PM
On Feb 21, 2:50*am, "vaclavpe@gmail" <vacla...@gmail.com> wrote:
> Hello all and sorry for (probably stupid) question.
>
> I need to capture data from UART, analyze them and then one of
> reactions is to read some internal registers in ARM and send them back
> to UART.
>
> The problem is that the process must be really fast, allowed delay is
> around 1ms. So I was thinking to do it in kernel space (speed, direct
> reading of memory registers). But I can not find the way how to use
> actual serial driver in my code. I feel that I can't use /dev/ttySx
> directly, can I ?
>
> Probably the first step will be to try everything in user space.
>
> Or does anybody have better idea ? Can you point me there ?
>
> Thank you in advance,
> V.
In kernel space you'll have to deal directly with the UART register
set or the raw API provided by the UART driver.
Janaka
25-02-2009, 02:50 PM
> Hello,
>
> yes, I would like to reuse UART driver already available. But I don't know how to use it. Do you have some example ?
> Some kernel module which uses UART for its work ?
>
> Thank you in advance,
> Vaclav
Its hard to comment without knowing the exact UART and surrounding
HW. However, in general, most UART drivers in the kernel will provide
a CHAR device that then can be mounted on a file system via "mknod /
dev/ttySx c <MAJ> <MIN>" (NOTE that the file system contex is only in
usermode. NOT KERNEL MODE). These drivers fills out a structure
"struct file_operations", which has pointers to functions it supports
(ie: read, write, ioctl ...). In your custom device driver, you cant
get a pointer to this structure and call the functions directly to do
whatever you have to do. You will have to do some digging yourself to
find out a clean way to do this (or a member of the group can help
you) .
Vitus Jensen
26-02-2009, 11:08 AM
Am Fri, 20 Feb 2009 07:50:58 -0800 schrieb vaclavpe@gmail:
> Hello all and sorry for (probably stupid) question.
It's not stupid, I once asked the same thing :-D
> I need to capture data from UART, analyze them and then one of reactions
> is to read some internal registers in ARM and send them back to UART.
>
> The problem is that the process must be really fast, allowed delay is
> around 1ms. So I was thinking to do it in kernel space (speed, direct
> reading of memory registers). But I can not find the way how to use
> actual serial driver in my code. I feel that I can't use /dev/ttySx
> directly, can I ?
....
You can't.
But you could implement a line discipline and access the serial driver
this way. PPP and SLIP are implemented as line disciplines, http://
en.wikipedia.org/wiki/Line_discipline
Bye,
Vitus
--
'Trust me, I haven't done this before and it didn't work then either'
Vitus Jensen, Hannover, Germany, Earth, Milky Way, Universe (current)
vBulletin® v3.8.3, Copyright ©2000-2010, Jelsoft Enterprises Ltd.