It is possible to redirect some input to TTY device by standard IO redirection.
echo ahoj > /dev/tty1
Such redirection will however end in the output buffer of the TTY device
so the characters will be ghosts - visible on the terminal, but not effective.
It is, in fact, not possible by standard tools to redirect input to
terminal as if it is a real input from keyboard.
It is possible to do it by using Linux specific ioctl()
,
but I haven't found any user space tool that would allow me to simply redirect
keyboard input from one terminal to another.
The only tool I've found is openvt, part of console-tools package, but it reads the input from the command line parameter so it's not suitable for permanent IO redirection which is what I needed.
make termpipe
With this tool it's possible to do this:
sudo kill -stop <pid> # Stop agetty or whatewer process may be reading the source terminal to prevent race condition
sudo stty -F /dev/tty1 raw # set the source terminal to raw mode so that it's not line buffered among other things
sudo cat /dev/tty1 | sudo termpipe /dev/ttyUSB0 & # this effectively redirects local keyboard input as if it is an input from the serial interface