"Read"ing an InputStream floods System.out

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

Moderators: roger, gloomyandy, skoehler

"Read"ing an InputStream floods System.out

Postby AlanG » Sat Jun 14, 2014 7:43 pm

Revised:

With leJOS 0.8.1 beta and Java SE 7u55, I find that the System.out file on my EV3 is flooded with the message "Reading with wait = false", every time my program executes the "while" loop:

while(((charsAvailable = NMEAstream.available()) > 0) && ((charsAvailable + charIndex) < inBuffer.length)) {
//System.err.println("Index: " + charIndex + " Len: " + charsAvailable);
totalChars = NMEAstream.read(inBuffer, charIndex, charsAvailable);
charIndex = charIndex + charsAvailable;
}

The following program excerpts show how NMEAstream is set up as a (presumably standard) Java SE 7 java.io.InputStream that reads in data from a Bluetooth-connected GPS device:

localBTconn = new BTConnector();//Now, start the Bluetooth Connector, Connection, and InputStream which
//the overriding "run" method will actually use.
System.out.println("Connecting to BT GPS...");
if ((GPSconnected = (connectionToGPS = localBTconn.connect(gpsDeviceName, NXTConnection.RAW)) != null)) {
System.out.println(gpsDeviceName + "!");
pausingAtStart = false;
} else {
System.out.println("No BT GPS connection!");
System.err.println("No BT GPS connection!");
pausingAtStart = false;
Thread.sleep(500);//Give the "run" method time to end;
System.exit(1);
}
NMEAstream = connectionToGPS.openInputStream(); //This should succeed as soon as there is a connection

This seems to me to be a perfectly proper way to open an InputStream to a GPS device. But the overriding of java.io.InputStream methods in lejos.remote.nxt.NXTInputStream and lejos.remote.nxt.BTConnection appear to be the cause of this problem. Does anyone know a quick way to stop this flood of useless messages going to the System.out file? Not only does the flood show up on my EV3's LCD display, it also floods the "<program name>.out" file on my EV3's SD card.
Last edited by AlanG on Sat Jun 14, 2014 9:14 pm, edited 1 time in total.
AlanG
New User
 
Posts: 17
Joined: Wed May 21, 2014 10:02 pm

Re: "Read"ing an InputStream floods System.out

Postby gloomyandy » Sat Jun 14, 2014 8:20 pm

Looks like there is a fair bit of debug code still in the Bluetooth comms (which you may consider a "flood of useless messages", but which you and the developer that has probably put a fair amount of time and effort into getting this code working may find of use when you run into a problem!), so if you don't want it then edit the code to comment it out and rebuild ev3classes.jar and replace the ev3classes.jar on your sd card.
https://sourceforge.net/p/lejos/ev3/ci/ ... ction.java
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4240
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: "Read"ing an InputStream floods System.out

Postby AlanG » Wed Jun 18, 2014 7:20 pm

Thank you for your suggestion about ev3classes.jar. I built an ev3classes project in my Eclipse workspace and loaded into it the files in ev3classes-src.zip . Once I changed the compiler compliance level from 1.4 to 1.7 and added jna.jar to the build path, I was able to build the whole project with no compiler errors.

>>>Does 156 compiler warnings ("is not used", "deprecated", and others) sound about right for the 0.8.1 beta??

I commented out some code in the "read" routines in BTConnection, and it is now doing what I want.

>>>But is there a published list of the error codes issued by LastErrorException?? I keep getting an occasional code 38 when some glitch breaks the connection between my EV3 and my Dual XGPS150A GPS device.

In general, I intend to disturb the leJOS release code as little as possible, to minimize confusion for myself and for the high school robotics students that I mentor. I need to revise the lejos.hardware.gps classes to improve some non-optimal features of their design. So I intend, whenever possible, to create distinctively named subclasses of your GPS classes and use them in my code. (BTconnector.connect creates a BTConnection that cannot be type-cast to a "BTConnection2". So, I was forced to modify the code for BTConnection.)
AlanG
New User
 
Posts: 17
Joined: Wed May 21, 2014 10:02 pm

Re: "Read"ing an InputStream floods System.out

Postby gloomyandy » Wed Jun 18, 2014 7:56 pm

If you are going to make changes to the leJOS source you will be better of using git to pull a copy into eclipse. This will allow you to re-merge your changes when/if we change things.

LastErrorException is not really leJOS code it is part of JNA
https://jna.java.net/javadoc/com/sun/jn ... ption.html
The error code in this case is likely to be a Linux error code:
http://www.virtsync.com/c-error-codes-include-errno

38 is a rather strange error, when do you get it exactly? Posting a stack trace would probably help.
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4240
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK


Return to EV3 Software

Who is online

Users browsing this forum: No registered users and 2 guests

more stuff