Re: Serial proxy driver help...

Rogier Wolff (R.E.Wolff@BitWizard.nl)
Tue, 7 Sep 1999 11:39:25 +0200 (MEST)


Mike A. Harris wrote:

[connecting serial ports together]

> Some people responded that such would be easy to do, but that it
> could be done in userland. Well I have researched it and am

I use this to test my multiport serial boards.

I do an stty command and then use two cat commands to forward the data
in each direction.

I have measured the delays (by running ppp over such a routed link)
and concluded that the userland doesn't give any significant delays.
There may be scheduling delays, e.g. that 10ms worth of serial data is
grouped and returned in one read call, but that's about it.

The serial cards that I work with are by the way also doing this
grouping, so this doesn't really matter.

You should set the "low_latency" flag. This should remove the 10ms
delays. I"m not sure how to set that flag from userspace. I've just
experimented with it by doing "tty->low_latency = 1" from my driver.

Machine with the script is up now... Here's the (internal use only!)
script. (the script is called string as I connect port 2 to 3 using
a null modem, port 3 to 4 using software here, then 4 to 5 using
another null modem etc etc.)

------------------------------------------------------------------
#!/bin/sh
#ports="5 6 7 13 14 15 31"
ports="1 2 3 4 5 6 7 8 9"
for i in $ports
do
stty 115200 -ixon -ixoff clocal ignbrk ignpar crtscts -opost -isig -icanon -iexten -echo -icrnl -inlcr < /dev/ttysr$i
done

cat /dev/ttysr1 > /dev/ttysr2 & cat /dev/ttysr2 > /dev/ttysr1 &
cat /dev/ttysr3 > /dev/ttysr4 & cat /dev/ttysr4 > /dev/ttysr3 &
cat /dev/ttysr5 > /dev/ttysr6 & cat /dev/ttysr6 > /dev/ttysr5 &
cat /dev/ttysr7 > /dev/ttysr8 & cat /dev/ttysr8 > /dev/ttysr7 &

---------------------------------------------------------------------

Cleaning it up a bit for "publication"

#!/bin/sh
# connect_serial_ports
# Usage : connect_serial_ports port1 port2
#
stty 115200 -ixon -ixoff clocal ignbrk ignpar crtscts -opost -isig -icanon -iexten -echo -icrnl -inlcr < $1
stty 115200 -ixon -ixoff clocal ignbrk ignpar crtscts -opost -isig -icanon -iexten -echo -icrnl -inlcr < $2

cat $1 > $2 & cat $2 > $1 &

and my string script would become:

#!/bin/sh
connect_serial_ports /dev/ttysr1 /dev/ttysr2
connect_serial_ports /dev/ttysr3 /dev/ttysr4
connect_serial_ports /dev/ttysr5 /dev/ttysr6
connect_serial_ports /dev/ttysr6 /dev/ttysr8

which looks a bit nicer.

Roger.

-- 
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
------ Microsoft SELLS you Windows, Linux GIVES you the whole house ------

- 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/