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