LeJOS fails on raw usb receive

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

Moderators: 99jonathan, roger, imaqine

LeJOS fails on raw usb receive

Postby Sergii » Wed May 07, 2014 1:51 am

Hi!

I'm trying to make segway using gyrosensor of my mobile phone over usb. It actually works now, but not so long as I want. Due to some reason transmission of bytes over usb leads LeJOS to fail after about 10 seconds of data transfer with such message:
Exception: 16
at: 120: 81

nxjdebugtool -di Segway.nxd -c -m 16 120 81

The class number 16 refers to:
java.lang.NullPointerException (NullPointerException.java)

The method number 120 refers to:
java.util.AbstractList.<init>()V (AbstractList.java)

PC 81 is invalid.

As you can see the stack trace is quite strange and it is out of my code. It appears even if app isn't running and phone just connected to the nxt block powered on. Phone sends just float zeros every 10ms over usb.

Can somebody please help me to find the reason?
Sergii
New User
 
Posts: 3
Joined: Wed May 07, 2014 1:41 am

Re: LeJOS fails on raw usb receive

Postby skoehler » Wed May 07, 2014 7:56 am

is there only one "at ...." line?
16 is indeed a nullpointer. But it seems that strange that it work for a while and then fails. Do you have a memory leak in your code maybe?
skoehler
leJOS Team Member
 
Posts: 1422
Joined: Thu Oct 30, 2008 4:54 pm

Re: LeJOS fails on raw usb receive

Postby Sergii » Sat May 10, 2014 3:21 pm

Yes, there is only one "at" line.

I have found the problem. It is not actually in my code on NXT brick.

You can easily reproduce this exception by running USB send(maybe few times) example and the NXT brick which is turned on and displays the main menu(no app is running).
It seems like lejos is waiting for connection and when some strange data comes it fails with this exception
Exception: 16
at: 120: 81
Sergii
New User
 
Posts: 3
Joined: Wed May 07, 2014 1:41 am

Re: LeJOS fails on raw usb receive

Postby skoehler » Sat May 10, 2014 3:39 pm

Sergii wrote:Yes, there is only one "at" line.

I have found the problem. It is not actually in my code on NXT brick.

You can easily reproduce this exception by running USB send(maybe few times) example and the NXT brick which is turned on and displays the main menu(no app is running).
It seems like lejos is waiting for connection and when some strange data comes it fails with this exception
Exception: 16
at: 120: 81

Oh! Are you saying the menu is running when this exception occurs? That changes everything. In particular, instead of Segway.nxd use StartUpText.nxd. Then it should tell you where in the menu the exception occurs.
$ nxjdebugtool -di StartUpText.nxd -c -m 16 120 81

The class number 16 refers to:
java.lang.NullPointerException (NullPointerException.java)

The method number 120 refers to:
lejos.nxt.comm.LCPResponder.run()V (LCPResponder.java)

PC 81 refers to:
line 99 in LCPResponder.java


The error is caused by the fact that the menu expect all USB communication to follow the LCP protocol. Since the menu is now fed non-LCP-conforming data (I assume), it crashes after a while.
The best you can do here is to send an LCP command packet unknown to leJOS. The leJOS menu should then at least ignore the LCP packet. If you're lucky, it even sends back some error packet saying that the LCP command is unknown. Then, the phone could stop sending data.
skoehler
leJOS Team Member
 
Posts: 1422
Joined: Thu Oct 30, 2008 4:54 pm

Re: LeJOS fails on raw usb receive

Postby Sergii » Sat May 10, 2014 5:09 pm

Thank you!

I have solved my problem by sending data after my program on NXT has started listening.
Sergii
New User
 
Posts: 3
Joined: Wed May 07, 2014 1:41 am


Return to NXJ Software

Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests

cron
more stuff