Connection failed with communication PC - NXT

Post your NXJ projects, project ideas, etc here!

Moderators: roger, 99jonathan, imaqine

Re: Connection failed with communication PC - NXT

Postby Marco9x » Wed Jun 20, 2012 7:53 pm

Code: Select all
import lejos.pc.comm.NXTConnector;
import lejos.nxt.*;
import lejos.nxt.remote.NXTCommand;
import lejos.pc.comm.*;

public class bluetooth {

   /**
    * @param args
    */
   public static void main(String[] args) throws Exception{
      // TODO Auto-generated method stub
      
      NXTConnector conn = new NXTConnector();
      
      if(!conn.connectTo("NXT","00:16:53:09:1a:74",NXTCommFactory.BLUETOOTH,NXTComm.LCP)){
      System.err.println("Connessione fallita");
      System.exit(1);
      }
      System.out.println("Connesso");
      
       NXTCommandConnector.setNXTCommand(new NXTCommand(conn.getNXTComm()));
      Motor.A.resetTachoCount();
      Motor.B.resetTachoCount();
      System.out.println("Tacómetro A: " + Motor.A.getTachoCount());
      System.out.println("Tacómetro B: " + Motor.B.getTachoCount());
      Motor.A.rotate(3600, true);
      Motor.B.rotate(-3600);
      Thread.sleep(1000);
      System.out.println("Tacómetro A: " + Motor.A.getTachoCount());
      System.out.println("Tacómetro B: " + Motor.B.getTachoCount());
      conn.close();

   }

}


new output from nxjbrowse:
leJOS NXJ> Searching for any NXT using Bluetooth inquiry
BlueCove version 2.1.0 on bluez
Found: NXT
leJOS NXJ> Name 0 = NXT
leJOS NXJ> Address 0 = 001653091A74
BlueCove stack shutdown completed
Marco9x
New User
 
Posts: 9
Joined: Sat Jun 16, 2012 1:32 pm

Re: Connection failed with communication PC - NXT

Postby gloomyandy » Wed Jun 20, 2012 8:00 pm

Please try the following....
Code: Select all
      if(!conn.connectTo("NXT","00:16:53:09:1a:74",NXTCommFactory.BLUETOOTH)){
      System.err.println("Connessione fallita");
      System.exit(1);
      }


If that does not work try...
Code: Select all
      if(!conn.connectTo(null,null,NXTCommFactory.BLUETOOTH)){
      System.err.println("Connessione fallita");
      System.exit(1);
      }


if that does not work try...
Code: Select all
      if(!conn.connectTo("*",null,NXTCommFactory.BLUETOOTH)){
      System.err.println("Connessione fallita");
      System.exit(1);
      }


Andy
PS Remember to check that your NXT is turned on and sat at the standard menu. Check each time because it will turn off if you have not used it for a while.
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3003
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Connection failed with communication PC - NXT

Postby Marco9x » Wed Jun 20, 2012 8:08 pm

NXT is turned on.
All tests have failed
Marco9x
New User
 
Posts: 9
Joined: Sat Jun 16, 2012 1:32 pm

Re: Connection failed with communication PC - NXT

Postby gloomyandy » Wed Jun 20, 2012 8:21 pm

In which case it must be something to do with how you are running your code. The last two tests basically do the same thing that nxjbrowse does and that seems to work. So how exactly are you running your test program? Also did you see any extra output from any of the above tests?
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3003
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Previous

Return to NXJ Projects

Who is online

Users browsing this forum: No registered users and 1 guest

more stuff