lkml.org 
[lkml]   [1999]   [Sep]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 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/

\
 
 \ /
  Last update: 2005-03-22 13:53    [W:0.079 / U:0.260 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site