Redirecting console output from a Qt application to a telnet session
if been struggling with this problem for a while now.
I've got an embedded Linux running on an ARM platform (Freescale iMX257).
The bootloader (RedBoot) starts Linux with the option
When I'm connected via the UART, my terminal program will let me type commands and get output from my running Qt application.
But when the module is in the field, I want to access it via Telnet, as there won't be a UART connection, only LAN.
I can open a telnet session, which will let me type commands and get output from those commands. But I can't see the output of my Qt application as this is still emitted on the UART.
How can I redirect the output of that application to the telnet session?
I thought this would do:
(via telnet on ttyp0)
I tried to modify the command running my application in the /etc/inittab:
I started playing around with /dev/ttymxc0 as well, but without result...
What am I doing wrong here?
Thanks in advance!
Can you redirect the output of Qt in a file (e.g. in the ramdisk or storage), then telnet and read the file ?
./myQtApp > /tmp/qt_debug.log 2>&1
tail -f /tmp/qt_debug.log
If you need to limit the size of the log, use logrotate
I have solved a similar problem by launching applications in a Gnu screen session that is running in multi-user mode. Then, I can attach and detach from the session at arbitrary times or from various connection methods (serial console, telnet, ssh, etc.).
Thanks for the hint.
Although I'd rather avoid using a file (as there isn't much spare space on the device), you gave me a valuable hint:
I added the " 2>&1" to my start-myQtApp script that's called by inittab:
So now I can:
-open a telnet session
-vi start-myQtApp and add the redirection
-myQtApp will respawn and be redirected to the telnet session.
It's a start but it includes killing myQtApp, which can cause loss of valuable information about the state the application was in before I killed it.
I also can't add the redirection to start-myQtApp as a default, because then I get the following error when the app starts when the telnet session is not active (=99% of the time):
My question boils down to this:
Is there a way to redirect the stdout/stderr stream of a *running* application?
I already found some solutions involving the use of external programs
(using gdb, using screen), but again these take a lot of space in my file system.
I like the way they do it with gdb. But can't this be done without that workaround?
I found it.
The solution is to add this to the program code: (c++)
I haven't found a solution that does this without editing the source code. (except using screen or gdb, which wasn't an option for me)
|All times are GMT -5. The time now is 05:33 PM.|