Serial port to serial port copying software
Quote:
>Hello:
> I'm trying to find out whether anyone has idea for a serial-port
>sharing program. Basically, I have a Linux box connected to a modem
>and a PC acting as a terminal. I would like to be able to access the
>modem directly from the terminal, probably by setting up an account
>with the shell set as the serial-copying program. This would allow me
>to access the modem from the terminal without having to go through the
>intermediate step of starting up a terminal program on the Linux
>machine.
> Does anyone have something like this already written?
I wrote something like this for SCO a while back. It was truely
trivial, about 30 lines of C.
Basically you open the modem port, set the line to raw mode, set stdin,
and stdout to raw mode, fork, with one process echoing stdin to the
modem, and the other echoing modem input to stdout.
Just set it as your login shell:
main() {
int fdin,fdout
int cc;
struct termio ios, ios2;
ioctl(0, TCGETA, ios)
...
ios.c_cc[VMIN]=1;
ios.c_cc[VTIME]=0;
...
ioctl(0, TCSETAF, ios);
fdin = open("/dev/modem",O_RDONLY);
ioctl(fdin, TCGETA, ios2)
...
ios2.c_cc[VMIN]=1;
ios2.c_cc[VTIME]=0;
...
ioctl(fdin, TCSETAF, ios2);
fdout = open("/dev/modem",O_WRONLY);
if(fork()) {
for(;;){
read(fdin, &cc, 1);
write(1, &cc, 1);
}
} else {
for(;;) {
read(0, &cc, 1);
write(fdout, &cc, 1);
}
}
Quote:
}
Rough but you get the idea
Note Follow-ups to comp.lang.c
--
Digital Designs BBS 1-919-423-4216 Hope Mills, NC 28348-2201
Somewhere in the Styx of North Carolina ...