Serial-line communication in TinyOS-1.1

Last updated 03 Sep 2003


Overview

Serial-line communication forms the primary channel for wired communication between a TinyOS device and a backend device, such as a PC. TinyOS-1.0 provided only primitive serial communication over a UART serial link that was abstracted in the UARTNoCRCPacket component. This component was used in conjunction with the GenericBase application to provide a simple pipe between the serial and wireless channels. On the PC, a simple java application (SerialForward) provided a relay between the serial data over a TCP/IP socket connection. None of these mechanisms provided for any level of synchronization or reliability.

The TinyOS-1.1 incorporates a new suite of components, applications and PC tools to provide more robust and flexible serial communication. They incorporate a framing protocol that provides for synchronization and flow control and the ability to select from multiple different types of data sources including legacy and simulator based. This document provides a usage instructions for the serial communication suite.

Developer details for using TinyOS-1.1 serial communications components.

Usage

UARTFramedPacket

The configuration component UARTFramedPacket provides the same interface and semantics as UARTNoCRCPacket. The configuration wires FramerM and FramerAckM together for generic, synchronized serial communication service. For existing applications that use UARTNoCRCPacket, simply replace the component name in the configuration or use an 'as' alias.

TOSBase/TransparentBase

To build: change to the apps/TOSBase or apps/TransparentBase directories and type 'make <platform>'  (for the mica2/mica2dot series, remember to also specify the desired frequency). For TOSBase, be sure to define the variable DEF_TOS_AM_GROUP according to the configuration of your network.

Install this application onto the device as you normally would.

Java Tools

The java tools receive/send information from/to packet sources.  A packet source is specified by the syntax

<source>[@parameters]

Table 2 lists all the sources understood by the java tools

Specification Description
sf@HOSTNAME:PORTNUMBER a serial forwarder at HOSTNAME and TCP PORTNUMBER
serial@SERIALPORT:BAUDRATE a TinyOS device directly connect via a local serial port that uses the framed communication protocol. SERIALPORT is the name of the serial port using DOS semantics (e.g. COM1, COM2, etc...) and BAUDRATE is the speed in baud (e.g. 19200, 57600). BAUDRATE can also be a mote name (mica, mica2, mica2dot) to pick the standard baudrate for that mote.
network@HOSTNAME:PORTNUMBER a TinyOS device connected via a network at HOSTNAME and TCP PORTNUMBER. This option is typically used with remote programmers such as the EPRB.
old-serial@SERIALPORT[:BAUDRATE][,PACKET_SIZE] a TinyOS device directly connected via a local serial port, but does NOT use any framing or ACK protocols. This is the legacy implementation. Since there is no framing, an optional PACKET_SIZE may be specified (default is 36)
old-network@HOSTNAME:PORTNUMBER a TinyOS device connected via a network without framing or ACK protocols. The HOSTNAME and PORTNUMBER parameters are as in the 'network' source
dummy a dummy packet sink and source
tossim-serial[@HOSTNAME] a virtual serial port for node 0 in TOSSIM. HOSTNAME is the name of the node running the TOSSIM instance
tossim-radio[@HOSTNAME] the radios of TOSSIM nodes. HOSTNAME is the name of the node running the TOSSIM instance

Table 2: Known Packet Sources

For the net.tinyos.PacketSource and net.tinyos.PhoenixSource, the packet source can be specified either

  1. When creating the object using the appropriate constructor/method call.
  2. Defining the environment variable MOTECOM to be the desired source.   Example:
            bash% export MOTECOM=serial@COM1:19200
    For this to work with the newer versions of the JVM, you must install a JNI shim that gives java access to platform environment variables. Change to 'tools/java/jni' and execute 'make install' to install the shim

Most applications, except SerialForwarder, use the MOTECOM environment variables. For the SerialForwarder tool, you may specify the packet source

  1. via the '-comm' option when starting the program. Invoke the program with the '-help' option for a list of other options.
  2. by changing the source in the dialog box in the GUI.  Click the 'Stop Server' button, change the source specifier and click 'Start Server'.