The TINI API3
We briefly discussed the TINI API in Chapter 5, and here we will be digging in a little deeper. The TINI API is the set of packages (classes and methods) for interfacing the TINI hardware to the Java Virtual Machine. In other words, these are the set of Java classes you will use to program TINI specific features like the 1-Wire network that are not part of the Java Virtual Machine. Here we will provide a quick overview of the various packages in the current TINI API and include some package diagrams that help map out how the classes fit and interrelate. Some of the packages will be discussed in more detail in other parts of this book (like 1-Wire, CAN, Network, I2C, ports). You will find the TINI API documentation in the javadocs\firmware folder of your TINI install folder (%TINI_HOME%\docs\javadocs\firmware if you followed the installation method described in the book). Some of the package descriptions have been grouped together because they either work together or the classes in one package directly extend the classes of another package. Figure 7-10 shows the key to the diagrams we will be using.
com.dalsemi.comm – This package provides the basic communication classes and methods for accessing some of the TINI-specific hardware devices. This includes: Serial ports, CAN (Controller Area Network) bus, and the LCD (liquid crystal display). com.dalsemi.fs – This package is an extension to the standard java.io.File class. It provides methods for accessing the file permissions and the owner ID of TINI files.
Figure 7-12: Diagram of the com.dalsemi.fs and com.dalsemi.io packages
com.dalsemi.io – This package provides interfaces and implementations for the conversion of bytes to characters and characters to bytes for a particular encoding scheme, like ISO 8859-1 (see “The ISO 8859 Alphabet Soup”4 and “The ISO8859-1 table”5 ) and UTF8 (see “RFC2253 – UTF-8 String Representation of Distinguished Names”6). com.dalsemi.onewire – Contains the single class OneWireAccessProvider which manages the Dallas Semiconductor 1-Wire adapter class. This enables an application to be adapter independent. com.dalsemi.onewire.adapter – This package contains the base classes for all 1-Wire port adapter objects. com.dalsemi.onewire.container – This package includes the classes and methods to manipulate specific 1-Wire devices. com.dalsemi.onewire.utils – This package contains the utilities necessary to translate and verify 1-Wire Network addresses and perform 8- and 16-bit cyclic redundancy checks.
Figure 7-13: Diagram of the com.dalsemi.onewire.* packages
com.dalsemi.shell – This package contains the abstract class and implementation of a system shell for TINI. This shell interacts between a program and the TINI operating system, and provides the current environment and the user ID of the current process. Methods are provided for converting to and from the numerical user ID and its text representation and for determining whether a particular user is an administrator. com.dalsemi.shell.server – This package provides an abstract class for a generic server and a server session.
Servers will listen on some system resource for connection requests. When a connection request arrives, the server starts up a session to handle that request. Servers are designed to be multi-threaded, allowing multiple simultaneous connections. com.dalsemi.shell.server.ftp – This package extends com.dalsemi.shell.server to implement a simple FTP server as described in RFC 959 (see “File Transfer Protocol”7). This server uses a ServerSocket to listen on the specified port (defaults to port 21) for FTP connection requests.
For each connection made, an FTP session is created. All command processing is handled by the FTP session, not the server. com.dalsemi.shell.server.serial – This package extends com.dalsemi.shell.server to implement a serial port server.
This server listens for user connections on TINI port serial0. For each connection made, a Serial session is created. All command processing is handled by the session. com.dalsemi.shell.server.telnet – This package extends com.dalsemi.shell.server to implement a Telnet server as described in RFC 854 (see “Telnet Protocol Specification”8).
This server uses a ServerSocket to listen on the specified port (defaults to port 23) for Telnet connection requests. For each connection made, a Telnet session is created. All command processing is handled by the Telnet session. com.dalsemi.system – This package provides a number of classes for managing TINI memory, accessing the state of the TINI operating system, and classes for accessing TINI hardware such as: the watchdog timer, the clock, the bitport, the byteport, and the dataport, interrupts, I2C interface and “a collection of hopefully useful debug utilities.” com.dalsemi.tininet – This package provides classes for managing the parameters of the TINI network . com.dalsemi.tininet.dhcp – This package provides a class that implements a DHCPClient for dynamically obtaining new IP Addresses.
Figure 7-15: Diagram of the com.dalsemi.system package
com.dalsemi.tininet.dns – This package provides a class that implements a DNS (Domain Name System) lookup service according to RFC 1035. com.dalsemi.tininet.http – This package provides a class that implements a simple HTTP server (see “Hypertext Transfer Protocol”9).
com.dalsemi.tininet.icmp – This package provides a class that implements an ICMP (ping) echo request server (see “Internet Control Message Protocol”10). com.dalsemi.tininet.ppp – This package provides a class that implements Point- to-Point Protocol (PPP) for providing IP packet transport over a serial link (see “The Point-to-Point Protocol”11). com.dalsemi.protocol – This package provides classes for working with server protocols, headers and URLs.
Figure 7-16: Diagram of the com.dalsemi.tininet.* and com.dalsemi.protocol packages
The next thing to do after loading the TINI firmware is to load the TINI shell (slush) into TINI so you can actually log in and configure your network settings. Before we do that, however, we will take a little time to discuss the TINI API.