Problem with class RemoteRequestEV3

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

Moderators: roger, gloomyandy, skoehler

Problem with class RemoteRequestEV3

Postby jenbau » Fri May 09, 2014 4:41 pm

Hi,

I'm trying to use the new RemoteRequestEV3 connector class for Android. It seems to connect to the ev3 controller but I can't create a regulated motor object by that. What do I have to do? I am using the ev3classes.jar from the snapshot and the sd500 and the lejosimage.gz from the snapshot as well. I always get:

connected to ev3 EV3
connected to ev3 Not knon
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1864)
at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(ObjectOutputStream.java:1773)
at java.io.ObjectOutputStream.writeNonProxyDesc(ObjectOutputStream.java:1267)
at java.io.ObjectOutputStream.writeClassDesc(ObjectOutputStream.java:1212)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1408)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1159)
at java.io.ObjectOutputStream.writeFatalException(ObjectOutputStream.java:1564)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:332)
at lejos.remote.ev3.RemoteRequestRegulatedMotor.<init>(Unknown Source)
at lejos.remote.ev3.RemoteRequestEV3.createRegulatedMotor(Unknown Source)
at com.carmeq.mindstorm.MindstormTest.connect(MindstormTest.java:24)
at com.carmeq.mindstorm.MindstormTest.main(MindstormTest.java:59)
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1864)
at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(ObjectOutputStream.java:1773)
at java.io.ObjectOutputStream.writeNonProxyDesc(ObjectOutputStream.java:1267)
at java.io.ObjectOutputStream.writeClassDesc(ObjectOutputStream.java:1212)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1408)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1159)
at java.io.ObjectOutputStream.writeFatalException(ObjectOutputStream.java:1564)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:332)
at lejos.remote.ev3.RemoteRequestRegulatedMotor.waitComplete(Unknown Source)
at com.carmeq.mindstorm.MindstormTest.connect(MindstormTest.java:28)
at com.carmeq.mindstorm.MindstormTest.main(MindstormTest.java:59)
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1864)
at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(ObjectOutputStream.java:1773)
at java.io.ObjectOutputStream.writeNonProxyDesc(ObjectOutputStream.java:1267)
at java.io.ObjectOutputStream.writeClassDesc(ObjectOutputStream.java:1212)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1408)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1159)
at java.io.ObjectOutputStream.writeFatalException(ObjectOutputStream.java:1564)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:332)
at lejos.remote.ev3.RemoteRequestRegulatedMotor.close(Unknown Source)
at com.carmeq.mindstorm.MindstormTest.connect(MindstormTest.java:29)
at com.carmeq.mindstorm.MindstormTest.main(MindstormTest.java:59)
java.net.SocketException: Socket closed
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:99)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1864)
at java.io.ObjectOutputStream$BlockDataOutputStream.flush(ObjectOutputStream.java:1809)
at java.io.ObjectOutputStream.flush(ObjectOutputStream.java:700)
at java.io.ObjectOutputStream.close(ObjectOutputStream.java:721)
at lejos.remote.ev3.RemoteRequestEV3.disConnect(Unknown Source)
at com.carmeq.mindstorm.MindstormTest.connect(MindstormTest.java:30)
at com.carmeq.mindstorm.MindstormTest.main(MindstormTest.java:59)
ende

Here is my code:

try {
RemoteRequestEV3 ev3 = new RemoteRequestEV3("192.168.2.112");
Audio audio = ev3.getAudio();
audio.systemSound(3);
// RemoteRequestMenu menu = new RemoteRequestMenu("192.168.2.112");
System.out.println("connected to ev3 " + ev3.getType());
System.out.println("connected to ev3 " + ev3.getName());
RegulatedMotor motor = ev3.createRegulatedMotor("A", 'L');
/*System.out.println(motor.getMaxSpeed());
motor.setSpeed(Math.round(motor.getMaxSpeed()));
motor.rotate(1000);*/
motor.waitComplete();
motor.close();
ev3.disConnect();
System.out.println("ende");
} catch (IOException e) {
System.err.println("An exception occurred: " + e);
}

can anyone help?

Regards
Jens
jenbau
New User
 
Posts: 3
Joined: Fri May 09, 2014 4:36 pm

Re: Problem with class RemoteRequestEV3

Postby lawrie » Fri May 09, 2014 6:49 pm

You need the latest version of EV3Menu as well as ev3classes for it for work. If you get them both from Git, build them both with their ant build files, so that the versions on the EV3 get updated, and then restart the EV3, it should work.
lawrie
leJOS Team Member
 
Posts: 922
Joined: Mon Feb 05, 2007 1:27 pm

Re: Problem with class RemoteRequestEV3

Postby jenbau » Sun May 11, 2014 1:40 pm

Hi lawrie,

thanks for your answer. I did what you told me. I uploaded the DBus, ev3classes and ev3menu to the device via ant. Now I don't get an exception anymore but the motor still does not move. I can play a sound whatsoever. So the connection seems to work. Here is my current code:

try {
RemoteRequestEV3 ev3 = new RemoteRequestEV3("192.168.2.112");
Audio audio = ev3.getAudio();
audio.systemSound(2);
System.out.println("connected to ev3 " + ev3.getType());
System.out.println("connected to ev3 " + ev3.getName());
ev3.setDefault();
RegulatedMotor motor = ev3.createRegulatedMotor("A", 'L');
System.out.println(motor.getMaxSpeed());
motor.setSpeed(Math.round(motor.getMaxSpeed()));
motor.rotate(1000);
motor.waitComplete();
motor.close();
audio.systemSound(3);
ev3.disConnect();
System.out.println("ende");
} catch (IOException e) {
System.err.println("An exception occurred: " + e);
}

Thanks for your help. Regards
Jens
jenbau
New User
 
Posts: 3
Joined: Fri May 09, 2014 4:36 pm

Re: Problem with class RemoteRequestEV3

Postby lawrie » Sun May 11, 2014 7:28 pm

There was a problem in getMaxSpeed that caused it to return 0. Also, I made a lot of changes to remote request today.

I tried your test on the latest version, and it worked. You need to pull the latest versions of ev3classes and EV3Menu again, build them, and restart the EV3.

You do not need the call to ev3.setDefault() unless you use any of the static methods in LCD, Button, Sound, Motor etc.

You do not need the call to waitComplete as the version of rotate you are using does not return until the rotation is complete.

There are still probably a few things that don't work with remote request, such as motor listeners and the LCD methods that use fonts.
lawrie
leJOS Team Member
 
Posts: 922
Joined: Mon Feb 05, 2007 1:27 pm

Re: Problem with class RemoteRequestEV3

Postby jenbau » Thu May 15, 2014 5:06 pm

Hey Lawrie,

thank you so much. With your changes it worked perfectly and I could manage to establish a connection to my android phone and control the motors. We had a team workshop where we used this and you made 30 people very happy, so I cannot thank you enough!

Regards
Jens
jenbau
New User
 
Posts: 3
Joined: Fri May 09, 2014 4:36 pm


Return to EV3 Software

Who is online

Users browsing this forum: No registered users and 2 guests

more stuff