Skip to contentSkip to conversation

Line disciplines.

DISCUSSION ian 2 participants 4 messages Jul 15, 2008 – Jul 16, 2008 TTY layer and serial drivers

lore
Share & tools
lore

ian

author
#0 lore raw

Hi!

Im trying to use a line discipline as a way to hook my kernel module up to a serial port.

I've implemented methods for open, close, and receive_buf, and registered the line discipline (Im using N_MOUSE as my number for now)

I've tried using stty line 2 < /dev/ttyS1 to attach my line discipline to a serial port (and tried this on an already open port too (using cat to open the port) and my methods never get called.

I've even written a little userspace program that opens ttyS1 and uses tcsetattr() to select c_line=N_MOUSE.

It looks like the ldisc is being set because after this stty reports ttyS1 to be using '2' which is correct, however my methods are still never called.

What am I missing?

TIA,

-Ian

#1 lore raw
Quoted 10 lines · ian

Im trying to use a line discipline as a way to hook my kernel module up to a serial port.

I've implemented methods for open, close, and receive_buf, and registered the line discipline (Im using N_MOUSE as my number for now)

I've tried using stty line 2 < /dev/ttyS1 to attach my line discipline to a serial port (and tried this on an already open port too (using cat to open the port) and my methods never get called.

Quoted 8 lines

I've even written a little userspace program that opens ttyS1 and uses tcsetattr() to select c_line=N_MOUSE.

It looks like the ldisc is being set because after this stty reports ttyS1 to be using '2' which is correct, however my methods are still never called.

What am I missing?

I suspect that since you are using an existing ldisc number that the existing ldisc module is being loaded instead of your module.

Do you see the init routine of your module called? If so, what is the return value from tty_register_ldisc()?

Signature · 2 lines
Paul Fulghum
MicroGate Systems, Ltd.
author
#2 lore raw
Quoted 3 lines · Paul Fulghum

I suspect that since you are using an existing ldisc number that the existing ldisc module is being loaded instead of your module.

I dont think this is the case, and looking in /proc my line disc was listed with the number 2. there were no others other than n_tty

Quoted 1 line

Do you see the init routine of your module called?

Yes.

Quoted 1 line

If so, what is the return value from tty_register_ldisc()?

Offhand I cant recall (several days ago) but since the ldisc appeared in /proc/tty/ldiscs I would have thought this succeded?

-Ian

#3 lore raw
Quoted 2 lines · ian
Quoted 1 line · Paul Fulghum

If so, what is the return value from tty_register_ldisc()?

Never mind, that function always returns 0 unless an invalid ldisc number is specified.

Quoted 2 lines

Offhand I cant recall (several days ago) but since the ldisc appeared in /proc/tty/ldiscs I would have thought this succeded?

OK, since your open method is not being called I would try placing some strategic printks in drivers/char/tty_io.c:tty_set_ldisc()
to trace the path taken when the line discipline is selected. That is where the open() method should be called.

--
Paul