Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Redirecting console output to target system screen: (4 Items)
   
Redirecting console output to target system screen  
I am debugging a project using qconn on the target system and using a Windows XP system and Momentics as the host for 
development. The target and development computers are linked by an Ethernet connection. Debugging works just fine. When 
debugging, all the output to stdout from the target system being debugged goes to the Console tab on the development 
machine. My question is - How do I redirect this output so that it goes to the target system's screen? I have tried 
changing some of the "Target options" settings and "Standard Input and Output" settings but no luck.

The reason I need to do this is that simple text based displays are being generated on the target system and I am also 
reading the keyboard to select which display is generated. The displays don't work in the Console tab because I use 
control codes to locate the cursor and so on, and the Console tab doesn't respond to those. Because I never write a CR+
LF to stdout I just end up with a very long string in the Console tab and everything slows down. It also doesn't respond
 to keypresses.

I just want to make the target system behave exactly like it does when you run the program on the target without 
debugging, when you are debugging. Any thoughts?
Re: Redirecting console output to target system screen  
> I am debugging a project using qconn on the target system and using a Windows 
> XP system and Momentics as the host for development. The target and 
> development computers are linked by an Ethernet connection. Debugging works 
> just fine. When debugging, all the output to stdout from the target system 
> being debugged goes to the Console tab on the development machine. My question
>  is - How do I redirect this output so that it goes to the target system's 
> screen? I have tried changing some of the "Target options" settings and "
> Standard Input and Output" settings but no luck.
> 
> The reason I need to do this is that simple text based displays are being 
> generated on the target system and I am also reading the keyboard to select 
> which display is generated. The displays don't work in the Console tab because
>  I use control codes to locate the cursor and so on, and the Console tab 
> doesn't respond to those. Because I never write a CR+LF to stdout I just end 
> up with a very long string in the Console tab and everything slows down. It 
> also doesn't respond to keypresses.
> 
> I just want to make the target system behave exactly like it does when you run
>  the program on the target without debugging, when you are debugging. Any 
> thoughts?

Hmm,

Try to debug this :

#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(int argc, char *argv[]) {
	
	close(1);
	//open("/dev/con1", O_RDWR); incase You are running 
                //no photon
	open("/dev/ttyp0", O_RDWR);
	printf("Welcome to the Momentics IDE\n");
	return EXIT_SUCCESS;
}

Have a pterm open what displays You ttyp0: sh in the titel bar thing.
You could use fopen with "a" in conjunction with fprintf().
But perhaps someone has a better way for You.

Jeevan


Re: Redirecting console output to target system screen  
> > I am debugging a project using qconn on the target system and using a 
> Windows 
> > XP system and Momentics as the host for development. The target and 
> > development computers are linked by an Ethernet connection. Debugging works 
> 
> > just fine. When debugging, all the output to stdout from the target system 
> > being debugged goes to the Console tab on the development machine. My 
> question
> >  is - How do I redirect this output so that it goes to the target system's 
> > screen? I have tried changing some of the "Target options" settings and "
> > Standard Input and Output" settings but no luck.
> > 
> > The reason I need to do this is that simple text based displays are being 
> > generated on the target system and I am also reading the keyboard to select 
> 
> > which display is generated. The displays don't work in the Console tab 
> because
> >  I use control codes to locate the cursor and so on, and the Console tab 
> > doesn't respond to those. Because I never write a CR+LF to stdout I just end
>  
> > up with a very long string in the Console tab and everything slows down. It 
> 
> > also doesn't respond to keypresses.
> > 
> > I just want to make the target system behave exactly like it does when you 
> run
> >  the program on the target without debugging, when you are debugging. Any 
> > thoughts?
> 
> Hmm,
> 
> Try to debug this :
> 
> #include <stdlib.h>
> #include <stdio.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> 
> int main(int argc, char *argv[]) {
> 	
> 	close(1);
> 	//open("/dev/con1", O_RDWR); incase You are running 
>                 //no photon
> 	open("/dev/ttyp0", O_RDWR);
> 	printf("Welcome to the Momentics IDE\n");
> 	return EXIT_SUCCESS;
> }
> 
> Have a pterm open what displays You ttyp0: sh in the titel bar thing.
> You could use fopen with "a" in conjunction with fprintf().
> But perhaps someone has a better way for You.
> 
> Jeevan
> 
> 


Yes. That works! If you only use the first open command then in only works outside of Photon. If you only use the second
 open command then it only works from the command line.

Can I just check I have understood how this works? The close command closes down standard output and the following open 
command will always grab the next free file descriptor which will be stdout. Is that right?

Thanks very much.
Re: Redirecting console output to target system screen  
Yup.