First of all, I have tried reading the documentation:
"To change the default stdin, stdout, stderr streams for new tasks, modify _GLOBAL_REENT->_stdin
(_stdout, _stderr) before creating the task."
but I think the information there is slightly different from what I am trying to achieve.
I have two separate tasks, telnet (running in one task) and a "console" (running in a second task) piping things to a UART port.
The console task is running fine, piping things out to its "_GLOBAL_REENT->stdin" instance.
The telnet task is also running fine taking input from the telnet peer and piping output using "telnet_send" (from libtelnet.c, https://github.com/seanmiddleditch/libtelnet).
Now I want to somehow redirect the console's stdin/stdout to the telnet session, when I receive a certain keypress combination.
I have done so far:
- 1. handle the keypress combination I want
2. Add in the corresponding function handlers for when an input stream is coming from the telnet session
3. Add in a function (that runs in the main task of the telnet task) to read from a buffer and pipe the output using "telnet_send"
- 1. Get the "instance" of the stdout of the console, and somehow get it's output and pipe it to a buffer (see #3 above).
2. Get the "instance" of the stdin of the console, and somehow get the telnet input to pipe it to that stdin.
And is there a way to restore it?
Marjon