NXT to NXT

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

Moderators: 99jonathan, roger, imaqine

NXT to NXT

Postby mdsmitty » Wed Sep 12, 2007 2:16 am

I saw that beta 4 support brick to brick comms so figured i would mess around with it. below is a short version of the code. they seam to connect but i think im missing something when sending. I should get a 1 to appear on the recever brick but i don't what am i missing?

Also i noticed a beeping from the bricks when they are on now. the same sound you get when they are in upload mode. it seams to get louder when using bluetooth comms. is this normal?

Brick one (sender)
BTRemoteDevice btrd = Bluetooth.getKnownDevice("NXT");
BTConnection btc = Bluetooth.connect(btrd);
InputStream is = btc.openInputStream();
OutputStream os = btc.openOutputStream();
DataInputStream dis = new DataInputStream(is);
DataOutputStream dos = new DataOutputStream(os);
dos.write(15);
dos.flush();

Brick two(receiver)
BTConnection btc = Bluetooth.waitForConnection();
InputStream is = btc.openInputStream();
OutputStream os = btc.openOutputStream();
DataInputStream dis = new DataInputStream(is);
DataOutputStream dos = new DataOutputStream(os);
while(true){
LCD.clear();
LCD.drawInt(dis.available(), 4, 0, 0);
LCD.refresh();
Thread.sleep(100);
}
mdsmitty
Novice
 
Posts: 78
Joined: Tue Feb 27, 2007 3:07 am

Postby lawrie » Wed Sep 12, 2007 5:15 pm

Do you have a NXT named "NXT" in the known devices for you client machine? Look at Devices on the Bluetooth menu. If it is not there, do a Search and add it.

There is currently no error handling on the Bluetooth.connect() method, and it can appear to have connected when the connect has failed.

I think the sound is normal, but I am not sure what causes it. It is different and not as loud as firmware update mode.
lawrie
leJOS Team Member
 
Posts: 922
Joined: Mon Feb 05, 2007 1:27 pm

Postby mdsmitty » Wed Sep 12, 2007 11:45 pm

Lawrie,
Everything was working fine based on the DataInputStream and the InputStream class. DataInputStream gets the available method from extending inputstream which is mostly an abstract class. in inputStream the available method is not abstract and only returns 0. So I found my problem.

As far as the sound goes i turned on one of the bricks at work which has the Lego firmware on them and they click to so i imagine it is normal.

Thanks for your help.
Mike
mdsmitty
Novice
 
Posts: 78
Joined: Tue Feb 27, 2007 3:07 am


Return to NXJ Software

Who is online

Users browsing this forum: Google [Bot] and 5 guests

more stuff