Using TinyVM - Vorlesungen

estrapadesherbetSoftware and s/w Development

Nov 18, 2013 (3 years and 6 months ago)

94 views

TinyVM

Version 0.1.3 Cross Platform Edition


Introduction

Jose Solorzano describes TinyVM as a small (~ 10 Kb) Virtual Machine that can run linked Java
TM

code in
the Lego® RCX. It supports several of the most useful features of the Java language, such as m
ulti
-
threading, synchronization and exceptions. It also has a wide range of APIs for controlling the RCX.


TinyVM was originially written to be run on Unix/Linux systems. The tools for downloading TinyVM
firmware and Java sources to the RCX, originally wr
itten in C, have been re
-
coded here in Java to allow
TinyVM to be used on other platforms.

Steps for installing TinyVM


It is assumed you already have the Java 2 JDK installed.


Install Java Communications API

Download and install the java communications A
PI. This can be obtained from the sun’s site at


http://java.sun.com/products/javacomm/

( Don’t forget to add comm.jar to your classpath ).


Note:

It has been observed on some systems that the java
programs relying on the Communications
API only run if launched from the same drive on which Comm.jar is located.


Add jtools.jar to your CLASSPATH

The jtools.jar contains all the tools needed to download the firmware and the program files to your
RCX.


U
sing TinyVM


Instructions for using TinyVM can be found on Jose Solorzano’s
site
. A brief summary follows.


Compiling the TinyVM Java programs

To compile a java program written for TinyVM you will ne
ed the classes.jar containing all
the TinyVM classes. The path to the classes.jar is to be passed as an argument while
compiling your program as shown below.


Format:

javac

classpath <path to classes.jar> <program.java>



Note:

It is recommended not to s
et your classpath environment variable, as this will screw up other


java compilations not meant for TinyVM.

Downloading firmware to RCX

To Download Firmware to RCX run the FirmwareDownload class. The default serial port
used for c
ommunication is COM1. If some other port is to be used it can be sent as an
argument.


The FirmwareDownload class by default loads the TinyVM software provided by Jose
Solorzano, which is encoded in the “tinyvm.srec” file. Passing the filename containing

the
firmware as an argument can download any other firmware. The usage is shown in the
example below:


Format:

Java idea.rcx.FirmwareDownload <optional: filename>

(or)


java
-
Dport.name=<port name> idea.rcx.FirmwareDownload <optional: filename>



Loading
a TinyVM class file to the RCX

There are two options to load a class file to the RCX.


Option 1: Create an output file for the class file and load it to the RCX by running the class


ProgramDownload

Option 2: Create a temporary output file and run

it automatically.


The steps for using the options are given below:


Option 1:

Run the ConvertClass class by passing three arguments. The first argument is the path to the
classes.jar . The second argument is the name of the class file to convert and the

third is the
name of the file to store the converted file.


Format:


Java ConvertClass <path to classes.jar> <class file name> <output file name>


Load the output file into RCX

To load the obtained file to RCX pass it as an argument and run the ProgramDo
wnload class.

The default serial port used for communication is COM1. If some other port is to be used it
can be sent as an argument.





Format:

java ProgramDownload <filename>

(or)

java

Dport.name=<port name> ProgramDownload <filename>


Option 2:

Run t
he ConvertClass class by passing two arguments. The first argument is the path to the
classes.jar and the second argument is the name of the class file to convert. This converts the
class file to a format suitable to RCX, stores in a temporary file and run
s it. The default serial
port used for communication is COM1. If some other port is to be used it can be sent as an
argument.



Format:


java ConvertClass <path to classes.jar> <class file name>


(or)


java

Dport.name=<port name> ConvertClass <path to cl
asses.jar> <class file name>



Using the included batch files on Windows 9x or NT systems.

All of the above functionality can be achieved by running some simple batch files provided. These files are
in the bin directory. To use this batch files the bin dir
ectory is to be added to the PATH environmental
variable.


The batch files to be run are as follows:


FirmwareDownload

ProgramCompile <program.java>

ConvertClass <class file name>

ProgramDownload <generated file>


--
> Be sure to update the options in bin
\
TinyvmOptions.bat prior to using these files.



Trouble Shooting using Batch Files

There is a possibility of getting an out of environment space error while running the batch files. It can be
fixed by just adding the following command line into the configu
ration file.

For Windows NT you should include the following line in your config.nt file

shell=%systemroot%
\
system32
\
COMMAND.COM /p /e:<size>

For Windows 95 you should add the following line to your config.sys file:

shell=C:
\
COMMAND.COM /p /e:<size>

In

both examples "<size>" is the maximum length in bytes you want COMMAND.COM to allocate for each
program. The default is 256 bytes and the maximum is 32K.



Links


For more information about TinyVM and RCX Programming, please consult the following links.


TinyVM Cross Platform Edition page

Jose Solorzano's TinyVM page

Keko
a Proudfoot's Comprehensive RCX Page

Lego MindStorms Internals Page

Home page for Lego Mindstorms

Write Tcl fo
r the RCX

A new book by O'Reilly on RCX Robots



Feedback


The Cross Platform tools are currently under development. Please send any suggestions or comments on
classes about the idea.rcx package to
brainstage@compuserve.com
.