Stop System.out appearing on LCD screen 0.8.1-beta

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

Stop System.out appearing on LCD screen 0.8.1-beta

Postby mcrosbie » Mon May 05, 2014 1:39 pm

Hi everyone,

System.out and System.err appear on the LCD overlaid over other graphics I have displayed. Previously (in 0.7.0) these would appear in the Eclipse Console when I ran EV3Tools->EV3Console. How do I stop System.out and System.err appearing on the LCD and instead get redirected to ProgramName.out and ProgramName.err? I've dug through the code in ev3classes but can't see where it's defined.

Just upgraded from 0.7.0 to 0.8.1-beta on Mac OS 10.9.2 and it's working great so far - nice job on the install and Eclipse plugin.

Thanks!
Mark
mcrosbie
Novice
 
Posts: 25
Joined: Wed Mar 24, 2010 12:27 pm
Location: Dublin, Ireland

Re: Stop System.out appearing on LCD screen 0.8.1-beta

Postby lawrie » Mon May 05, 2014 5:36 pm

The code is in lejos.internal.EV3Wrapper. It is only used when a program is run by the menu. So if you run a jar file from ssh or use the scp/ssh option in the Eclipse plugin, it is not used.

You can cycle through the LCD overlays by using a Left+Right key chord, so you can see either scrolling (sdout/stderr) output or the normal LCD screen output, or both. This does not work well for all applications.

The output should also go to <program>.out, <program>.err and to EV3Control/EV3Console. If this is not happening, let me know. However, EV3Wrapper traps exception, so no exception report goes to stderr. Perhaps its exception handler should call printStackFrame() so you get the report in EV3Console/EV3Control as well.

If you think we need another option for this, let me know. We were trying to fix the case where the system output was just thrown away if EV3Control/EV3Console was not used.
lawrie
leJOS Team Member
 
Posts: 922
Joined: Mon Feb 05, 2007 1:27 pm

Re: Stop System.out appearing on LCD screen 0.8.1-beta

Postby skoehler » Mon May 05, 2014 7:48 pm

Take a look at System.setOut and System.setErr:
http://docs.oracle.com/javase/7/docs/ap ... ystem.html
skoehler
leJOS Team Member
 
Posts: 1430
Joined: Thu Oct 30, 2008 4:54 pm

Re: Stop System.out appearing on LCD screen 0.8.1-beta

Postby mcrosbie » Mon May 05, 2014 9:57 pm

Hi Lawrie,

It seems that the EV3Wrapper uncaughtException() method already tries to print the stack frame for the exception but the code is commented out in the version I have. It would make sense to redirect that to System.err output so it can be analysed.

I see the code for intercepting the left/right keys in the LCDLayerSwitcher thread - but this conflicts with the code I'm writing that also wants to use the Left/Right buttons for a function in the game. I like the idea of scrolling through output overlays, so perhaps require pressing ENTER plus Left/Right to enable the scroll feature as that is an unusual key combination to conflict with. An application should be able to call something like System.enableOverlays(boolean enable) which sets a boolean checked in the LCDLayerSwitcher thread if the application wants full control of the screen and keys.

Does the RedirectStream class in EV3Wrapper write the System.out and System.err to files? If so perhaps a orig.flush() would make sense in each method. All I see in <program>.out is:
Code: Select all
classpath: /home/lejos/programs/SpaceInvaders.jar:/home/root/lejos/lib/ev3classes.jar:/home/root/lejos/lib/dbusjava.jar:/home/root/lejos/libjna/usr/share/java/jna.jar:.


With no actual printed output. But I think Andy mentioned that this was a bug in another thread recently.

Mark
mcrosbie
Novice
 
Posts: 25
Joined: Wed Mar 24, 2010 12:27 pm
Location: Dublin, Ireland

Re: Stop System.out appearing on LCD screen 0.8.1-beta

Postby gloomyandy » Mon May 05, 2014 11:02 pm

Mark just to be clear to switch the display you need to press both left and right at the same time. You can use them individually for whatever you want. Also I'm not a fan of allowing a program to disable this. If you don't want it then there should probably be a run option in the menu that runs the program without the wrapper. Lawrie do we have one of those?
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4118
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Stop System.out appearing on LCD screen 0.8.1-beta

Postby lawrie » Thu May 08, 2014 1:36 pm

Mark,

I have made the changes to EV3Wrapper in the latest Git source. It now sends the stack trace to the original stderr, and I added some extra flushes. I also fixed a bug in the View function in the menu and in downloading files in EV3Control, that I spotted when testing this.

Lawrie
lawrie
leJOS Team Member
 
Posts: 922
Joined: Mon Feb 05, 2007 1:27 pm

Re: Stop System.out appearing on LCD screen 0.8.1-beta

Postby lawrie » Thu May 08, 2014 1:43 pm

Andy, no there is currently an option to not use the wrapper. I am not quite sure how you would describe such an option in user terms. It sounds a bit like the Zaphod Beeblebrox's glasses option: don't tell me about errors or exceptions - http://www.mostly-harmless.de/joo.html. Lawrie
lawrie
leJOS Team Member
 
Posts: 922
Joined: Mon Feb 05, 2007 1:27 pm

Re: Stop System.out appearing on LCD screen 0.8.1-beta

Postby AlanG » Wed May 21, 2014 10:56 pm

lawrie wrote:The code is in lejos.internal.EV3Wrapper. It is only used when a program is run by the menu. So if you run a jar file from ssh or use the scp/ssh option in the Eclipse plugin, it is not used.

You can cycle through the LCD overlays by using a Left+Right key chord, so you can see either scrolling (sdout/stderr) output or the normal LCD screen output, or both. This does not work well for all applications.

The output should also go to <program>.out, <program>.err and to EV3Control/EV3Console. If this is not happening, let me know. However, EV3Wrapper traps exception, so no exception report goes to stderr. Perhaps its exception handler should call printStackFrame() so you get the report in EV3Console/EV3Control as well.

If you think we need another option for this, let me know. We were trying to fix the case where the system output was just thrown away if EV3Control/EV3Console was not used.


Could control of the displayed LCD overlays also be accomplished by the setting of a LINUX environment variable that defines the user's choice of default overlay? I would like, by default, to start everything I run via EV3 keystrokes with only the LCD displays that I have programmed. I would be willing to either Telnet to the EV3's LINUX shell and do a "setenv", or use Eclipse to set a variable in a "LeJos EV3 launch configuration".

Regards,
AlanG
AlanG
New User
 
Posts: 15
Joined: Wed May 21, 2014 10:02 pm


Return to EV3 Software

Who is online

Users browsing this forum: No registered users and 4 guests

more stuff