Linux-kernel mailing list archive 1999-36,: Re: Serial proxy driver help...

# Re: Serial proxy driver help...

Richard B. Johnson (root@chaos.analogic.com)
Tue, 7 Sep 1999 08:37:31 -0400 (EDT)

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: BOSZORMENYI Zoltan: "Re: cdrom problem(s)"
- Previous message: Richard B. Johnson: "Re: long username"
- Next in thread: Junio Hamano: "Re: Serial proxy driver help..."
- Reply: Junio Hamano: "Re: Serial proxy driver help..."

On Tue, 7 Sep 1999, Mike A. Harris wrote:

> I wrote a while back about creating a driver for the kernel which
> would take the incoming data from one serial port (a null modem)
> and output it to another serial port (a modem), and vice versa.
>
> 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
> still not sure how to proceed. I would like to try both a kernel
> level approach, and a userland approach as well. It is important
> that the transfers have low latency between the two serial ports.
>
> Can someone help me out with this?

This is a template.

i = open("/dev/ttyS0", O_RDWR|O_NDELAY); /* Open non-delay */
j = open("/dev/ttyS1, O_RDWR|O_NDELAY");
fcntl(i, ... ~O_NDELAY); /* Restore delay */
fcntl(j, ... ~O_NDELAY);
ioctl(i, TCSETS, &termios); /* Set to binary mode */
ioctl(j, TCSETS, &termios);

for(;;)
{
select(i+1....) /* Timeout on select about 2 character times */
{
len = read(i, buf, LEN);
if(len)write(j, buf, len);
}
select(j+1....)
{
len = read(j, buf, LEN);
if(len) write(i, buf, len);
}
}

Cheers,
Dick Johnson
**** FILE SYSTEM WAS MODIFIED ****
Penguin : Linux version 2.3.13 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.

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

- Next message: BOSZORMENYI Zoltan: "Re: cdrom problem(s)"
- Previous message: Richard B. Johnson: "Re: long username"
- Next in thread: Junio Hamano: "Re: Serial proxy driver help..."
- Reply: Junio Hamano: "Re: Serial proxy driver help..."