Howto use iCommand to do...

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

Moderators: roger, imaqine, 99jonathan

New User
Posts: 1
Joined: Thu Feb 28, 2008 8:40 pm

Howto use iCommand to do...

Postby Hadi.Skalli » Thu Feb 28, 2008 8:43 pm

Hi everyone, just installed and got working iCommand. It is a great tool.
Does anyone know how to (or is it possible to):

(1) Connect to many bricks using bluetooth and iCommand.

(2) Send and receive messages to the brick.(I tryed messageWrite and messageRead from the Inbox class but for some reason it doesn`t seem to be working.)



User avatar
Site Admin
Posts: 392
Joined: Fri Aug 04, 2006 4:03 pm

Re: Howto use iCommand to do...

Postby bbagnall » Thu Feb 28, 2008 9:23 pm

Hi Hadi,

Currently iCommand only supports one NXT brick. If some changes were made to iCommand it's probably possible to connect with more than one but I haven't looked into it deeply. There have been a few people from time to time who looked into it but I haven't heard anything back really.

Regarding inboxes, I haven't played with these much. It probably sent the message but it doesn't do anything once it receives it? You probably need a program on your other NXT brick ready to do something when it gets a message. I assume this would be programmed using NXT-G.

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

Postby PatrickLismore » Thu Feb 28, 2008 11:39 pm

there is this class that takes the name of the NXT and the Bluetooth Address as parameters to connect to, im sure it would be possible with a we bit of work to modify so that you can connect to multiple bricks by specifing the multiple NXT names and Bluetooth addresses.

A PC Bluetooth dongle can have multiple bricks connected I dont know what the limit is but to get around any limitations you could probably use two bluetooth dongles

heres the class its contained in the samples folder with in the Lejos_nxj folder i know its not ICOMMAND but im sure you could write a program that sends over integers which your NXT could interpret for commands

for example

1 could mean turn right
2 could mean turn left

Code: Select all

import lejos.pc.comm.*;

 * This is a PC sample. It connects to the NXT, and then
 * sends an integer and waits for a reply, 100 times.
 * Compile this program with javac (not nxjc), and run it
 * with java.
 * You need pccomm.jar on the CLASSPATH. On Windows you
 * will also need bluecove.jar on the CLASSPATH. On Linux,
 * you will need on the Java library path.
 * Run the program by:
 *   java BTSend <name> <address>
 * where <name> is the name of your NXT, and <address> is
 * its Bluetooth address.
 * For example:
 *   java BTSend NXT 00:16:53:00:78:48
 * You can find the address for your NXT by running nxjbrowse
 *  - this lists the name and address of each NXT it finds.
 * See the comment in the code on how to do a Bluetooth
 * inquiry to find your NXT, instead of using the address
 * parameter.
 * Your NXT should be running a sample such as BTReceive or
 * SignalTest. Run the NXT program first until it is
 * waiting for a connection, and then run the PC program.
 * @author Lawrie Griffiths
public class BTSend {
   public static void main(String[] args) {
      NXTComm nxtComm = NXTCommFactory.createNXTComm(NXTCommFactory.BLUETOOTH);
      /* Another way to connect, by discovery:

      NXTInfo[] nxtInfo =[0], NXTCommFactory.BLUETOOTH);
      if (nxtInfo.length == 0) {
         System.out.println("No NXT Found");
      // arg[0] = name, e.g NXT
      // arg[1] = address, with optional colons, e.g. 00:16:53:00:78:48
      if (args.length != 2) {
         System.out.println("Usage: BTSend name address");
      NXTInfo[] nxtInfo = new NXTInfo[1];
      nxtInfo[0] = new NXTInfo(args[0],args[1]);
      System.out.println("Connecting to " + nxtInfo[0].btResourceString);

      boolean opened = false;
      try {
         opened =[0]);
      } catch (NXTCommException e) {
         System.out.println("Exception from open");
      if (!opened) {
         System.out.println("Failed to open " + nxtInfo[0].name);
      System.out.println("Connected to " + nxtInfo[0].btResourceString);
      InputStream is = nxtComm.getInputStream();
      OutputStream os = nxtComm.getOutputStream();
      DataOutputStream dos = new DataOutputStream(os);
      DataInputStream dis = new DataInputStream(is);
      for(int i=0;i<100;i++) {
         try {
            System.out.println("Sending " + (i*30000));
         } catch (IOException ioe) {
            System.out.println("IO Exception writing bytes:");
         try {
            System.out.println("Received " + dis.readInt());
         } catch (IOException ioe) {
            System.out.println("IO Exception reading bytes:");
      try {
      } catch (IOException ioe) {
         System.out.println("IOException closing connection:");

Return to “NXJ Software”

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest