Building TINI Binaries
Once you have compiled Java classes from their source, they need to be converted to TINI's binary format before they can be
used. Dallas provide two utilities for creating binaries - TINIConvertor and BuildDependancy.
These are well documented in the files Building_Applications.txt and BuildDependency_README.txt included in the TINI distribution.
Basically TINIConvertor is used to build the TINI binary and can be used directly if your program does not depend on any classes that are not included in the standard TINI API.
Make sure that tini.jar from the TINI SDK is in your class path and then the syntax is:
java TINIConvertor -f <class file> -o <output file> -d <TINI install dir>/path/to/tini.db
If your program depends on classes that do not make up part of the TINI API, such as OneWire containers then BuildDependency must be used.
This builds in extra dependencies before calling TINIConvertor to build the binary.
Again with tini.jar in the classpath, the syntax is:
java BuildDependency -f <class file> -o <output file> -d /path/to/tini.db -add <dependency list> [-x <dependency file>] [-p <dependency location(s)>]
Where dependency list is a colon seperated list of dependencies to include, e.g. OneWireContainer04;OneWireContainer21
Here are a few shell scripts to keep the typing to a minimum...
- tiniconvertor invokes TINIConvertor to convert class file(s) to a tini binary.
- builddependency invokes BuildDependency to convert class file(s) to a tini binary.
- deploytini does just that...
However, a far better way of automating the build process of TINI applications is to use TiniAnt,
which is an extention to Apache Ant *the* cross platform build tool.
TiniAnt adds a new task type, <tini> to ant that really takes the pain out of building large TINI projects with complex dependencies.
1-Wire Example Code
The source for some sample servlets using the 1-Wire API to control and monitor several devices can be downloaded below.
These work fine on TINI in conjunction with
TINIHttpServer, but note that the code has not been optimised for TINI's JVM.
They will also work on other platforms that support Java and 1-Wire such as a PC equipped with a DS9097U serial to 1-wire adapter and running a suitable servlet container such as Jakarta Tomcat.
- DS2406Servlet - The DS2406 (Family code 0x12) is a dual addressable switch with 1K-Bit of onboard EPROM.
This servlet locates any DS2406s on the default adapter and reads the state of the port
pins and output latches for both channels.
It also allows the state of the output latches to be changed at the push of a button.
- DS18B20Servlet - The DS18B20 (Family Code 0x28) is a programmable resolution digital thermometer.
This servlet locates any family code 0x28 devices on the default adapter and displays the current temperature reading.
It also allows the resolution to be set, shows the alarm status and allows the high and low alarms to be set if present.
- DS2450Servlet - The DS2450 (Family Code 0x20) is a quad A/D convertor. Pins not used as inputs can be controlled as outputs.
The device features programmable range, resolution and alarms. This servlet locates each family code 0x20 device connected to the default adapter and deisplays the raw voltage level at each of the input pins. It also allows setting of the range, resolution, alarms and output latch state of each pin.
- DS2890Servlet - The DS2890 (Family Code 0x2C) is a linear taper digitally controlled potentiometer. This servlet locates each family code 0x2C device on the default adapter and allows the wiper position to be set.
- DS2404Servlet - The DS2404 (Family Code 0x04) is a real time clock/calendar with 4096 bits of non-volatile memory. This servlet simply locates each family code 0x04 device on the default adapter, checks that the clock is running and displays the current time and date.
Some quick and dirty code to set the DS2404's time to the current system time can be found here.
To build the servlets into TINIHttpServer, the build.properties file in the source distribution must be modified.
Specifically, alter the servlet.src property to reflct the locations of the servlet source and the onewire.deps
property to include any dependencies. I found it easier to alter onewire.deps to a colon
separated list of dependencies rather than using THS_ALL ro THS_MIN as this gives more control as to what is compiled in.