OSDN Git Service

Update lejos_osek to nxtOSEK_v205b0.zip
[nxt-jsp/etrobo-atk.git] / nxtOSEK / lejos_nxj / README.html
index fc5cb2d..5a98454 100644 (file)
@@ -1,35 +1,36 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\r
 <html>\r
 <head>\r
-  <title>leJOS NXT, a Java system for the Lego Mindstorms NXT</title>\r
+  <title>leJOS NXJ, a Java system for the Lego Mindstorms NXT</title>\r
 </head>\r
 <body style="background-color: rgb(255, 255, 255);">\r
 <ul>\r
-  <li><a href="#what_is_lejos">What is leJOS?</a></li>\r
+  <li><a href="#what_is_lejos">What is leJOS NXJ?</a></li>\r
   <li><a href="#preliminiaries">Preliminiaries</a></li>\r
   <li><a href="#installation_and_set_up">Installation and Set Up</a></li>
-  <li><a href="#using-lejos">Using lejos on the NXT</a></li>\r
-  <li><a href="#limitations">Known limitations</a></li>\r
-  <li><a href="#bugs">Known bugs</a></li>\r
+  <li><a href="#using-lejos">Using leJOS NXJ</a></li>
+  <li><a href="#compiling">Compiling and running your first code</a></li>\r
+  <li><a href="#tools">LeJOS NXJ Tools</a></li>\r
+  <li><a href="#limitations">Known limitations in leJOS</a></li>\r
+  <li><a href="#bugs">Known bugs in leJOS</a></li>\r
+  <li><a href="#nxjbugs">Known bugs and limitations in leJOS NXJ</a></li>\r
   <li><a href="#documentation">Documentation</a></li>\r
   <li><a href="#license">License</a></li>\r
   <li><a href="#questions">Questions and Problems</a></li>\r
 </ul>\r
-<a href="#questions"> </a>\r
-<h1><a name="what_is_lejos">What is leJOS?</a></h1>\r
-leJOS (pronounced like the Spanish word "lejos" for "far") is a 
-tiny Java-based operating system that\r
-has been ported to the following platforms: </a>\r
+<h1><a name="what_is_lejos">What is leJOS NXJ?</a></h1>\r
+<p>leJOS (pronounced like the Spanish word "lejos" for "far") is a 
+tiny Java-based operating system that has been ported to the following platforms:</p>\r
 <ul>\r
-  <li>Lego Mindstorms NXT</li>
-  <li>Lego Mindstorms RCX</li>\r
-  <li>Unix (for emulation of lejos programs only)</li>\r
+  <li>LEGO Mindstorms NXT</li>
+  <li>LEGO Mindstorms RCX</li>\r
+  <li>Unix (for emulation of leJOS programs only)</li>\r
   </a>\r
 </ul>\r
-leJOS was originally forked out of the </a><a\r
+<p>leJOS was originally forked out of the </a><a\r
  href="http://tinyvm.sourceforge.net">TinyVM project</a>. <br>\r
 It contains a VM for Java bytecodes and additional software to load and\r
-run Java programs. <br/><br/>
+run Java programs.</p>
 
 These are some of the features offered:\r
 <ul>\r
@@ -43,59 +44,174 @@ These are some of the features offered:
   <li>Math class</li>
   <li>Well-documented Robotics API</li>\r
 </ul>\r
+\r
+<p>leJOS NXJ is the version of leJOS for the LEGO Mindstorms NXT. \r
+It uses the same Java VM as the RCX version, but has new drivers for the NXT hardware.\r
+</p>\r
+<p>leJOS NXJ adds lots of new capability to leJOS including a file system, a menu system,\r
+and support for I2C sensors, including those from third parties. The built-in tachometers in\r
+the NXT motors have enabled much improved control over speed, steering and navigation.\r
+</p>\r
+<p>Bluetooth and USB communications are a great improvement over the infra-red link used by the RCX.</p>\r
+\r
 <h1><a name="preliminiaries">Preliminaries</a></h1>\r
 <ul>\r
-  <li>You need a Java Development Kit (JDK), preferably 1.5</li>\r
-  <li>Your PATH must contain the JDK's bin directory</li>\r
+  <li>You need a Java Development Kit (JDK), preferably 1.5 or later.</li>\r
+  <li>Your PATH must contain the JDK's bin directory.</li>\r
   <li>Make sure you have set JAVA_HOME properly to the root directory\r
-of the JDK</li>\r
-  <li>In case you want to build the distribution, your PATH must\r
-contain the ant binary (ant 1.6 or above)</li>
-  <li>You need libusb installed. On Windows you should use the libusb-Win32 filter driver</li>
-  <li>On Windows you will need the Lego Mindstorms NXT software installed, as its USB drivers are used</li>\r
-</ul>\r
-<h1><a name="installation_and_set_up">Installation and Set Up</a></h1>\r
-Please download the leJOS\r
-documentation from the same location you downloaded this distribution.\r
+of the JDK.</li>\r
+  <li>On systems other than Microsoft Windows, you will need to build the distribution, so your PATH must\r
+contain the ant binary (ant 1.7 or above).</li>
+  <li>You need libusb installed. On Microsoft Windows you should use the libusb-Win32 filter driver.</li>
+  <li>On Microsoft Windows and MAC OS X you will need the LEGO Mindstorms NXT software installed, as its USB drivers are used.</li>
+  <li>On MAC OS X systems, you will need the OS X developer tools installed.</li>
+  \r
+</ul>
+
+The libusb filter driver for Microsoft Windows can be obtained from <a href="http://libusb-win32.sourceforge.net/#downloads">http://libusb-win32.sourceforge.net/#downloads</a>. \r
+This does not currently work under Windows Vista - see "Known Bugs and Limitations in leJOS NXJ" below.\r
+However, it works if you install on Vista under Windows XP compatibility mode:<br/>\r
 <ol>\r
-  <li>Set your environment variable <em>LEJOS_HOME</em> to the\r
-directory you installed this distribution into</li>
-  <li>Add leJOS's bin directory to your PATH</li>\r
-  <li>On Linux, depending on the privilege settings you might need to\r
-adjust the execution permissions in the <em>bin</em> folder</li>\r
+<li>Download libusb-win32-filter-bin-0.1.12.1.exe (the version current @ 27/09/07)\r
+<li>Right click on this file. Select Properties | Compatibility Click the "Run this program in compatibility mode" box and select "Windows XP (Service Pack2)" from the drop down list.\r
+<li>Right click again and select "Run as Administrator". Follow the installation instructions. Run the test program will list the usb devices plugged into your computer, but not new devices.\r
 </ol>\r
-On Linux, you will have to build the distribution first. To do so,\r
-switch to the <em>build</em> folder and run <code>ant</code>.\r
-Note that depending on the privilege settings you might need to adjust\r
-the the execution permissions in the <em>release</em> folder.
-<h1><a name="using-lejos">Using lejos on the NXT</a></h1>
-<ul>
-  <li>Compile using <em>lejosjc</em> instead of <em>javac</em></li>
-  <li>Link programs using <em>lejoslink</em></li>
-  <li>Download and run programs using <em>lejosdl</em>
-  <li>Emulate leJOS programs on the host using <em>emu-lejosrun</em> (currently Linux only)</li>
-  <li>Exceptions: Use <em>lejoslink --verbose</em>. Exceptions are shown in the NXT as Method:XXXX, CLASS:YY, where XXXX = method_signature and YY = exception_class_index</li>
-</ul>
+<br/>
+
+libusb for other systems can be obtained from <a href="http://libusb.sourceforge.net">http://libusb.sourceforge.net</a>.<br/><br/>
+
+On Linux systems, if you are running leJOS NXJ from a non-root user, you will need to ensure that you have read and write access the NXT USB device in /dev/bus/usb.
+If you can identify the device in /dev/bus/usb, you can do this by:<br/><br/>
+
+<em>sudo chmod a+w /dev/bus/usb/xxx/yyy</em><br/><br/>
+
+However, the yyy number will count up each time the NXT is disconnected and reconnected.<br/><br/>
+
+A better solution is to use udev rules or pamcomsole. How to do this varies with different Linux systems. A pamconsole solution that works on Fedora Core 5, is to create a file /etc/security/console.perms.d/60-libusb.perms with the two lines:<br/><br/>
 
-Your NXT must be plugged into the USB, switched on, and in firmware update mode to run lejosdl. 
+<code>\r
+&lt;usbdevices&gt;=/dev/bus/usb/*/*<br/>
+&lt;console&gt; 0600 &lt;usbdevices&gt; 0644 root
+</code>\r
 <br/><br/>
+\r
+To use udev rules, set up a file such as  /etc/udev/rules.d/70-lego.rules and populate it with the following lines: <br/><br/>\r
+\r
+<code>\r
+# Lego NXT<br/>\r
+BUS=="usb", SYSFS{idVendor}=="03eb", GROUP="lego", MODE="0660" <br/>\r
+BUS=="usb", SYSFS{idVendor}=="0694", GROUP="lego", MODE="0660" <br/>\r
+</code>\r
+</br>\r
+\r
+This relies on the username you are using being in the <em>lego</em> group. You can modify the file to your\r
+requirements. The two vendors are LEGO and Atmel (for the samba driver used in firmware update mode).\r
+You may need to restart udev.\r
+\r
+<h1><a name="installation_and_set_up">Installation and Set Up</a></h1>\r
+\r
+<ol>
+  <li>Extract the files from the distribution. A lejos_nxj subdirectory will be created.</li>\r
+  <li>Set the environment variable <em>NXJ_HOME</em> to the full path of the lejos_nxj\r
+directory.</li>
+  <li>Add the lejos_nxj/bin directory to your PATH.</li>\r
+  <li>On Linux and Unix systems, depending on your privilege settings you might need to\r
+adjust the execution permissions in the <em>bin</em> directory.</li>\r
+</ol>\r
+On Linux and Unix systems, you will have to build the distribution first. To do so,\r
+switch to the <em>build</em> folder and run <code>ant</code>. You  will need to ensure that the\r
+packages that leJOS NXJ is dependent on are on your system. These include libusb-dev,\r
+gcj and libbluetooth-dev.\r
+
+<h1><a name="using-lejos">Using leJOS NXJ</a></h1>
+<ul>\r
+  <li>Flash the leJOS NXJ firmware using <em>nxjflash</em>.</li>
+  <li>Compile using <em>nxjc</em> instead of <em>javac</em>.</li>
+  <li>Link, upload and run programs using <em>nxj</em>.</li>
+  <li>Exceptions: Use <em>nxj --verbose</em> to get information on methods and special classes used by your program. Exceptions are shown on the NXT as Method:XXXX, CLASS:YY, where XXXX = method_signature and YY = exception_class_index</li>
+</ul>
+
+<p>Your NXT must be plugged into the USB, switched on, and in firmware update mode to run nxjflash. Note that the standard LEGO firmware will be overwritten and all existing data lost. You can reinstall the LEGO firmware using the LEGO Mindstorms software.
+</p>
 To go into firmware update mode press the reset button (at the back of the NXT , upper left corner) for more than 4 seconds. 
-Your NXT will audibly tick when it is firmware update mode, but is not running a lejos program.
-<br/><br/>
-To switch your NXT on, just press the orange button. It will start to audibly tick.
-<br/><br/>
-When you use <em>lejosdl</em> your program will download and run. You can stop a program by pressing the ENTER and ESCAPE (orange and grey square) buttons together. 
-This powers down the NXT immediately. Press the ENTER (orange) button to wake it up again.
-<br/><br/>
-You can also power down the NXT with ENTER + ESCAPE, after an Exception occurs.
+Your NXT will audibly tick when it is firmware update mode.
+<br/><br/>\r
+\r
+<p>To run nxjflash, open a command window, and type <em>nxjflash</em></p>\r
 \r
+<p><em>nxjflash</em> will write the Java VM and the leJOS NXJ start-up menu to the flash memory of your NXT. It will create an empty user flash area. When the flash procedure has finished, leJOS NXJ will start up and an empty menu will be displayed.\r
+</p>
+<p>You can switch the NXT off at any time, including when a program is running, by pressing the orange and dark gray buttons (ENTER + ESCAPE) together.To switch it back on just press the orange button. The leJOS NXJ start-up menu will be displayed.
+</p>\r
+\r
+If your NXT freezes at any time, remove and re-insert a battery.
+
+<h1><a name="compiling">Compiling and running your first code</a></h1>
+
+To compile, link and download the Tune sample:
+
+<ul>
+  <li>Open a command window</li>
+  <li>Check that java and lejos_nxj are on your PATH</li>\r
+  <li>Check that the NXJ_HOME environment variable is defined</li>
+  <li>Change to the lejos_nxj\samples\Tune directory</li>
+  <li>Type <em>nxjc Tune.java</em></li>
+  <li>Check that your USB cable is connected</li>\r
+  <li>Check that the NXT is turned on</li>\r
+  <li>Type <em>nxj -r Tune</em></li>
+ </ul>
+<p>After a few seconds, you should hear an ascending tone sequence indicating that the program uploaded OK. You will then hear a tune play. When it has finished the leJOS NXJ menu will be displayed.</p>
+\r
+<p>When you switch your NXT back on, select "Files" and press ENTER and you will see "Tune.nxj" in the files menu</p>\r
+\r
+<p>You can navigate through the leJOS NXJ menus using the left and right buttons. You select a menu item by pressing ENTER, and exit from a menu by pressing ESCAPE. There are 3 menus: Files, Bluetooth ands System. To select a program, go to the Files menu, scroll down to your program and press the ENTER button. You will then see a sub-menu that lets you execute or delete the program.</p>\r
+\r
+<h1><a name="tools">LeJOS NXJ Tools</a></h1>\r
+<p>The following tools are available with leJOS NXJ:</p>\r
+\r
+<ul>\r
+<li><em>nxjflash</em> - flashes the firmware</li>\r
+<li><em>nxjc</em> - compiles a Java program for leJOS NXJ</li>\r
+<li><em>nxj</em> - links, uploads and optionally runs a leJOS NXJ program</li>\r
+<li><em>nxjlink</em> - links a program</li>\r
+<li><em>nxjupload</em> - uploads and optionally runs a program</li>\r
+<li><em>nxjbrowse</em> - explorer for NXJ files</li>\r
+<li><em>emu-lejosrun</em> - emulate a leJOS NXJ program on Unix</li>\r
+</ul>\r
+\r
+<p><em>nxj</em>, <em>nxjupload</em> and <em>nxjbrowse</em> can be used over Bluetooth or USB.\r
+By default they try to use USB first, and if this fails, they try Bluetooth</P>\r
+\r
+<p>Use the <em>--usb</em> flag to select usb only, or <em>--bluetooth</em> for Bluetooth only.</p>\r
+\r
+<p><em>nxjbrowse</em> displays a list of all the NXTs that it finds, and allows you to select one to connect to. \r
+<em>nxj</em> and <em>nxjupload</em>, try each NXT they find in turn until they successfully connect to one. \r
+To pick a specific NXT to connect to by name, use the <em>--name</em> flag.</p>\r
+\r
+<p>You can connect to a specific NXT by address, using the <em>--address</em> flag. If you specify the address, a Bluetooth inquiry will not be done,\r
+and the connection will be much faster. Use <em>nxjbrowse</em> to list the addresses of your NXT devices. An address is 12 hex digits with optional colons\r
+between the hex pairs.</p>\r
+\r
+<p>The leJOS NXJ tools can use different comms driver to connect to the NXT. The only driver available for USB is NXTCommLibnxt, \r
+which uses David Anderson's libnxt library and the libusb open source library. This works on all operating systems. \r
+For Bluetooth on Windows, NXTCommBluecove, which uses the Bluecove open source library, is used. \r
+On Linux and MAC OS X, NXTCommBluez, which uses the open source Bluez project, is used for Bluetooth.</p>\r
+\r
+<p>A future version of leJOS NXJ is expected to support the LEGO Fantom API, which should work for both USB abd Bluetooth.</p>\r
+\r
+<p>The properties file,lejos_nxt/bin/nxj.properties, can be modified to select different comms drivers,\r
+but for this release the defaults are the only available drivers.</p>\r
+\r
+<p><em>nxjbrowse</em> lists the files on the NXT and includes their size, and start and end pages. \r
+It can be used to delete, upload and download programs and other files. \r
+It can also run programs, change the name of the NXT and defrag the files,\r
+moving them all to the start of user flash memory. Changing the name of the NXT only works over USB.</p> \r
 <h1><a name="limitations">Known limitations</a></h1>\r
 Due to size constraints, some Java language\r
 features have been omitted. Others just haven't been implemented yet.\r
-Known limitations are: </a>\r
+Known limitations with all versions of leJOS are: </a>\r
 <ul>\r
-  <li>Garbage collection is not performed yet.\r
-Hence, the number of objects in your program should be limited</li>\r
   <li>Switch statements are not supported</li>\r
   <li>Arithmetic operations on variables of type long are not\r
 supported, although you can cast ints to longs and vice versa</li>\r
@@ -114,6 +230,7 @@ not supported by leJOS</li>
   </a>\r
 </ul>\r
 <h1><a name="bugs">Known Bugs</a></h1>\r
+<p>The following bugs apply to all versions of leJOS:</p>\r
 <ul>\r
  <li>MONITOREXIT ignores null objects (it assumes\r
 MONITORENTER has handled them). Furthermore, it doesn't check monitor\r
@@ -124,21 +241,68 @@ synchronized. This could lead to access of statics before they are
 initialized, when multiple threads use a class</li>\r
   </a>\r
 </ul>\r
+<h1><a name="nxjbugs">Known Bugs and Limitations in leJOS NXJ</a></h1>\r
+<p>The following bugs and limitations apply to the current version of leJOS NXJ:</p>\r
+\r
+<ul>\r
+<li>Occasionally, after flashing the firmware with with nxjflash, the battery level reads as 0.0 and buttons do not respond. If this happens, a battery must be removed and re-inserted. It is not necessary to repeat the nxjflash.\r
+</li>\r
+<li>leJOS NXJ does not work out of the box on Windows Vista systems. This is due to limitations in libusb-win32 that the leJOS  NXJ Windows USB tools, including nxjflash, rely on. Installing libusb in windows XP compatibility mode should cure the problem.\r
+</li>\r
+<li>Bluetooth does not work on MAC OS X systems, and the ant build files for MAC OS X are largely untested.  See the forums on the leJOS web site for the latest state of leJOS on MAC OS X.\r
+</li>\r
+<li>Occasionally, after pressing the orange (ENTER) button to start leJOS NXJ, the LCD remains blank. If this occurs, and is not due to low batteries, it is necessary to shut down leJOS, by pressing the orange and dark gray buttons (ENTER + ESCAPE), and try again.\r
+</li>\r
+<li>Only one file can be open at a time.\r
+</li>\r
+<li>leJOS NXJ only supports program upload and download, tools such as nxjbrowse, and LEGO communications Protocol commands when the start-up menu is running, not when a user program is running, unless a user program explicitly starts the LCPBTResponder thread.\r
+</li>\r
+<li>The number of files that can be uploaded to lejos NXJ is limited by the fact that the whole file table must fit into two 256-byte pages. If the average filename length is 15 characters, approximately 20 files are supported.\r
+</li>\r
+<li>The maximum filename length is 20 characters.\r
+</li>\r
+<li>Not all LEGO Communications Protocol command are supported, and the semantics of some of them are different from that of the standard LEGO firmware. In particular only one file can be open at a time and the file handle is always 0.\r
+</li>\r
+<li>The leJOS NXJ USB driver does not return a unique serial number for each NXT, in the way that the standard LEGO software does. The effects of this are not known, but it may be the cause of lejos NXJ not working with the LEGO fantom API over USB.\r
+</li>\r
+<li>Java streams over USB are never closed down, and are always open.\r
+</li>\r
+<li>Reading buttons is not very reliable unless your code takes steps to wait for button readings to stabilize. See the TextMenu code for how to do this.\r
+</li>\r
+<li>The RCX limitations of the Java VM also apply to NXJ.\r
+</li> \r
+<li>Sound volume cannot be controlled when playing tones.\r
+</li>\r
+<li>Support for sound sample files is limited to 8-bit WAV files with a sample rate of 11k.\r
+</li>\r
+<li>Data aborts occur if there is a failure in the NXJ VM. If a data abort occurs, it is necessary to remove and re-insert a battery.\r
+</li>\r
+<li>leJOS NXJ does not work with the LEGO Mindstorms PC software, or the LEGO Mindstorms Fantom API.\r
+</li>\r
+<li>On Windows, using the Bluecove library, NXTs that have been paired with the PC are in the list of available NXTs, even when they are not switched on. This does not happen with Bluez on Linux.\r
+</li>\r
+<li>Is usually necessary to pair your NXT using the Operating System before it can be connected to by the lejOS NXJ PC tools and libraries.\r
+</li>\r
+<li>Discovery of Bluetooth devices is slow, taking at least 10 seconds. It is slower still with Bluez on Linux. For Java streams connections from user programs, you can connect directly by Bluetooth address, which is much faster.\r
+</li>\r
+<li>To get permissions to the lejos NXJ usb devices from non-root users on Linux, you typically need to user pamconsole or udev rules. The instructions for doing this are not very explicit.\r
+</li>\r
+</ul>\r
 <h1><a name="documentation">Documentation</a></h1>\r
-Please download the leJOS documentation from\r
-the same location you downloaded this distribution from. The\r
-documentation contains the API docs. \r
+The API docs for leJOS NXJ is included in the download. You can also access them on the leJOS web site.\r
 <h1><a name="license">License</a></h1>\r
 We are continuing to release under the Mozilla Public License\r
-(see the LICENSE file). The runjava utility using David Anderson's libnxt
+(see the LICENSE file). The nxjflash utility using David Anderson's libnxt
 which is release under a GPL v2 license (see COPYING in the libnxt directory).\r
 <h1><a name="questions">Questions and Problems</a></h1>\r
 Please direct feedback to the lejos-discussion\r
 mailing list mailto:lejos-discussion@lists.sourceforge.net. <br>\r
 To subscribe, see </a><a\r
  href="http://lists.sourceforge.net/lists/listinfo/lejos-discussion">http://lists.sourceforge.net/lists/listinfo/lejos-discussion</a>.\r
-<p> Feel free to take a look at the <a href="http://www.lejos.org">Lejos\r
+<p> Feel free to take a look at the <a href="http://www.lejos.org">LeJOS\r
 website</a> or its <a href="http://sourceforge.net/projects/lejos">project\r
 page</a>. </p>\r
+\r
+<p>There are forums on the web site that can be used to ask questions, share information on projects, etc.</p>\r
 </body>\r
 </html>\r