May
2004, Issue 166
Embedded
Java Controllers
PROGRAMMING
TOOLS
AJile
provides a few applications to program and debug your
JStamp/JStik. These come with the development versions
of the hardware.
Jembuilder
takes Java class files and converts them to a form that
can be loaded into the controller. This is a type of
linker. Charade loads this file and acts as an interactive
terminal/debugger.
JSwat
is a debugger. I haven’t used it, so I can’t comment
on it. Although I admit to occasionally writing buggy
code, I’ve learned other methods of debugging Java.
In
addition, you need a Java compiler. Sun’s Java works
fine. A text editor to create the source files is useful,
although some people prefer an IDE. All of the applications
run in Windows.
EMBEDDED
JAVA
If
you’re used to running Java on a larger machine, the
connected limited device configuration (CLDC) version
of Java is limited. Some things are left out because
they aren’t needed (e.g., the entire java.awt.* hierarchy
is gone). However, most of the core libraries remain,
although in a somewhat smaller form. Many of the methods
and classes not needed in an embedded environment have
been removed. For instance, the main hierarchy is reduced
to java.io, java.lang, java.util, and javax.microedition.io.
Each of these packages is pruned to have only the classes
needed for embedded systems. You can download the latest
version of the CLDC standard from Sun.
The
main thing you need to know is that the JStamp and JStik
do not support normal preemptive threading. For all
normal threads, you must use Thread.yield(), Thread.sleep(),
or some sort of blocking I/O in order to switch threads.
This makes for a much more defined real-time behavior
when threading is used.
The
other main difference is that the I/O packages are much
more limited. There are no java.net.* packages. Replacing
this is the javax.microedition.io package, which deals
with I/O at a somewhat lower level than standard Java.
However, the javax.comm package works fine when dealing
with the serial ports.
Note
that the CLDC is one of the configurations of Java 2
Micro Edition. AJile has pledged to eventually provide
the other configuration, but it isn’t available at this
time.