Some Questions about NXT and Bluetooth

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

Moderators: 99jonathan, roger, imaqine

Some Questions about NXT and Bluetooth

Postby PatrickLismore » Mon Feb 11, 2008 7:16 am

I have a few questions that I need answers to to help me move on.

I know I can connect two NXT bricks to a PC with one bluetooth dongle,

Can i have my application read from one NXT Brick and Send commands to move another?

How do i go about being specific and making sure i read from the right NXT Brick and Write to the other one.

When i use "NXTCommand.open" its gonna open only one connection.

Is there away to open bluetooth connections based on specific ports and is this affected with the icommand.properties file.

Another thing thats coming up in my work and i need clarification on is,

I am able to run pc based programs using Icommand I can move the robot as well as read data from the sensors what I was planning to do was going to try and read the data from one nxt's light sensors and based on the values being sent to the PC, the PC program would then send the relevant navigation commands to the other NXT Brick.

When i execute a program on the NXT Brick , say for example my line following program i am unable to use the PC based program because it will not connect to the Brick. If i connect the PC based program to the NXT Brick first which is able to control the robot and send values from the sensors back to the pc, if i then execute my line following program on the Brick thats connected to the PC and the NXT Brick program is running it then makes the PC program not work at all the PC program does not get back any values from the sensors and also the control of the robot does not work anymore.

It seems that you can use the PC & icommand or NXT programs (bluetooth class on the brick to send data back to the PC)

can someone confirm if this is the case or is there away that i can exectue a program on the NXT Brick and use a PC based application that is connected to the brick via bluetooth?

thanks
Patrick
User avatar
PatrickLismore
Active User
 
Posts: 81
Joined: Tue Oct 16, 2007 7:28 pm
Location: Prague

Postby gloomyandy » Mon Feb 11, 2008 10:45 am

Hi Patrick....
First a bit of background that I think will help you understand what is going on...

Programs like ICommand and other remote control applications that can drive the nxt using the standard Lego firmware make use of a protocol called LCP (Lego command protocol), which in this case has been implemented over the top of Bluetooth. To enable this to work the nxt needs to accept Bluetooth connections and hook this connection up to a command interpretor that can process LCP. One of the differences between the Lego firmware and the leJOS firmware is the location of this interpretor. In the Lego world it is built into the actual firmware, in leJOS it is implemented in Java and normally runs as part of the menu system that you see when you start the brick. However when you run a user program the menu system is replaced by the user application. So there is no LCP available to process the commands....

Luckily the LCP command interpretor is in the standard leJOS class lib just waiting to be used... Take a look at the LCP class. Even better there is a LCPBTResponder that will hook the Bluetooth connection up to LCP for you. So basically if you want to have an application that runs on the NXT but at the same time be able to issue commands via Bluetooth/LCP then you need to include the responder in your application...

As to connecting to more than one NXT using ICommand, sorry I'm not really an ICommand user. However you can certainly connect to more than one NXT using the pcomms classes, so you could write your own PC side app to do this...

Hope this helps....

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3881
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Postby PatrickLismore » Mon Feb 11, 2008 11:35 am

Thanks for the response it certinly helped clarify what exactly was going on,

Ill take your sound advice , study the classes and see what I can do

much appreicated , thanks again Patrick
User avatar
PatrickLismore
Active User
 
Posts: 81
Joined: Tue Oct 16, 2007 7:28 pm
Location: Prague

Postby PatrickLismore » Thu Feb 21, 2008 9:37 pm

I have abandoned the LCPBTResponder idea

it kept throwing an exception and when it did not throw an exception it would not respond to commands from the PC while the NXT program was running.

I have since made progress tho, I have managed to connect the two Bricks together and have the first brick send data across to the other and have a message display on the second based on the integer passed over.

i just need to add some motor processes on the second brick and i will be almost finished.
User avatar
PatrickLismore
Active User
 
Posts: 81
Joined: Tue Oct 16, 2007 7:28 pm
Location: Prague


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 3 guests

cron
more stuff