For the benefit of anyone running Hardy Heron who wants to use leJOS, I've summarized the steps (minus my errors and back-tracking!) to install and configure leJOS to work on my Ubuntu laptop with Bluetooth.
I run Ubuntu 8.04 fully updated on a new HP Pavilion DV9744CA latop with a D-Link DBT-120 Bluetooth Dongle.
- 1. Install these development packages:
- sudo apt-get install libusb-dev
sudo apt-get install libbluetooth-dev
sudo apt-get install gcj
2. Use Synaptic Package Manager to install NetBeans if you want to use NetBeans--I happen to prefer it but it's a personal choice
3. NetBeans is installed with the openjdk Java Development Kit. The leJOS development team forum recommends using the Sun Java 1.6 SDK which can also be downloaded with Synaptic
4. If you download the Sun Java 1.6 SDK, edit the NetBeans launcher to include --jdkhome /usr/lib/jvm/java-6-sun-1.6.0.06 so that it uses the Java Sun version and not the openjdk
5. You will also have to choose which version you will use: sudo update-alternatives - - config java (I found that here http://forum.java.sun.com/thread.jsp...sageID=9756412 and here http://ubuntuforums.org/showthread.php?t=543965
6. Visit http://lejos.sourceforge.net and download the lejos_NXT_0_6_0beta.tar.gz tarball (I saved it in /usr/bin/lejos)
7. Unpack it: tar xfvz lejos_NXT_0_6_0beta.tar.gz.
8. Move it to the spot you want it: sudo mv /usr/bin/lejos /user/share/lejos.
9. Give everyone read and write privileges: chmod 777 /usr/share/lejos/bin --recursive.
10. Edit your .profile file by adding these lines to the very end so that you can build the leJOS installation, and then reboot: sudo gedit ~.profile
- export PATH=/usr/share/lejos/bin:$PATH
export PATH=/usr.share/ant/bin:$PATH
export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.06
export NXT_HOME=/usr/share/lejos
11. Move to the /usr/share/lejos/build folder and run ant to build your installation: ant
12. At this point it works with USB but not Bluetooth. If you don't have root privileges, you can run run sudo -s to open a root window before using any of the nxt commands like nxjbrowse, nxjc or nxj.
13. This is where you install the leJOS firmware. Connect it to your computer using the USB cable and make sure it's on. You will have to use a bent paperclip to depress the reset button in one of the grooves. When the device starts audibly clicking. Run nxjflash from a root window. There might be a data aborts—if it doesn't work, pop out a battery, put it back in and try again.
14. Edit your .profile file to include the following and then reboot:
sudo gedit ~/.profile
- export PATH=/usr/share/lejos/lib:$PATH
export PATH=/usr/share/lejos/3rdparty/lib:$PATH
export CLASSPATH=/usr/share/lejos/lib/classes.jar:$CLASSPATH
export CLASSPATH=/usr/share/lejos/lib/jtools.jar:$CLASSPATH
export CLASSPATH=/usr/share/lejos/lib/pccomm.jar:$CLASSPATH
export CLASSPATH=/usr/share/lejos/lib/pctools.jar:$CLASSPATH
export CLASSPATH=/usr/share/lejos/3rdparty/lib/bcel-5.1.jar:$CLASSPATH
export CLASSPATH=/usr/share/lejos/3rdparty/lib/bluecove.jar:$CLASSPATH
export CLASSPATH=/usr/share/lejos/3rdparty/lib/bluecove203.jar:$CLASSPATH
export CLASSPATH=/usr/share/lejos/3rdparty/lib/bluecove-gpl.jar:$CLASSPATH
export CLASSPATH=/usr/share/lejos/3rdparty/lib/commons-cli-1.0.jar:$CLASSPATH
export CLASSPATH=/usr/share/lejos/3rdparty/lib/cpptasks.jar:$CLASSPATH
15. Copy libjlibnxt.so from the /usr/share/lejos/bin folder to the /usr/lib/jvm/java-6-openjdk/jre/lib/i386 folder
16. Add Bluetooth Analyzer to the Applications/Accessories menu
17. Create a file called /etc/udev/rules/70-lego.rules with this content (you can find the idVendor for the dongle by running lsusb):
- BUS=="usb", SYSFS{idVendor}=="03eb", GROUP="lego", MODE="0660" /* Atmel */
BUS=="usb", SYSFS{idVendor}=="0694", GROUP="lego", MODE="0660" /* Lego */
BUS=="usb", SYSFS{idVendor}=="0a12", GROUP="lego", MODE="0660" /* Dongle */
18. Create a group called lego and add yourself to it in System/Administration/Users and Groups/Manage Groups
19. Create file NXT.properties in /usr/share/lejos/bin, with NXTCommBluetooth=lejos.pc.comm.NXTCommBluecove as the only text
20. Plug in the dongle. Ubuntu's Bluetooth Analyzer will open and an icon will appear in your panel
21. Get the NXT's Bluetooth address with the hcitool scan command (it will look like this 00:16:53:05:CA:2C)
22. You may need to delete the /var/lib/bluetooth/00:13:46:11:CD:01 directory (I found this in a forum posting and I tried doing this when I couldn't connect and it seemed to work): rm -rf 00:13:46:11:CD:01
23. On the NXT brick turn on Bluetooth and enable visibility. Search for your computer and add the device
24. Run nxjbrowse from a terminal and, when prompted by Bluetooth Analyzer, provide the default NXT password 1234 (this is called pairing and should only have to be done once). You should get a Java window popup prompting you to connect to your NXT brick. Make a note of the name and MAC address
25. You may need to go into Bluetooth Manager/Preferences and change the Mode of Operation to “Visible and Connectable for other devices”. Also enable Receive Files from Remote Devices under File Transfer
26. Reboot. Make sure the NXT brick is on and Bluetooth is enabled and the device is visible. Run nxjbrowse. You should successfully connect.
27. Move to the samples folder and compile BTReceive (nxjc BTReceive.java). Compile BTSend (this one is compiled with javac as specified in the file comments). Ensure that the NXT brick is on and Bluetooth is on and the device is visible. Upload the BTReceive file to the NXT (nxj BTReceive). If there is a data abort (which seems to occur from time to occasional time with this beta) you will have to remove a battery and restart the NXT and try to upload it again.
28.From your root window, run java BTSend [NXT_NAME] [NXT-Address]. You should see a stream of integers being exchanged between your computer and the brick. Tada!
Bookmarks