:TEP: 113
:Group: Core Working Group
:Type: Documentary
-:Status: Draft
+:Status: Final
:TinyOS-Version: 2.x
:Author: Ben Greenstein and Philip Levis
-:Draft-Created: 11-Jul-2005
-:Draft-Version: $Revision$
-:Draft-Modified: $Date$
-:Draft-Discuss: TinyOS Developer List <tinyos-devel at mail.millennium.berkeley.edu>
-
.. Note::
This memo documents a part of TinyOS for the TinyOS Community, and
====================================================================
Users need to read data out of a TinyOS network. The most common
-approach is to attach a mote to a PC or latop with a wired
+approach is to attach a mote to a PC or laptop with a wired
connection. While the interface on the PC side can vary from a serial
cable to a USB device to IP, the mote generally talks to a serial port
(UART). In TinyOS 1.x, the UART packet format is platform-specific,
2.0 introduces the notion of packet format dispatch, so a mote can
support multiple UART packet formats simultaneously. This allows
transparent bridging (e.g., an 802.15.4 base station) to exist in
-parallel with platform-independent communication, which allows
-simplifies the PC toolchain. This memo documents the protocols and
-structure of the TinyOS 2.x serial communication stack.
+parallel with platform-independent communication, which simplifies the
+PC toolchain. This memo documents the protocols and structure of the
+TinyOS 2.x serial communication stack.
2. Serial Stack Structure
====================================================================
The lowest level of the stack is the raw UART. This HIL component
provides functionality for configuring the UART (speed, stop bytes,
-etc.) as well as sending/receiving bytes.
+etc.), sending/receiving bytes, and flushing the UART.
The Encoder/Framer sits above the raw UART. This component translates
raw data bytes into packet bytes using a serial protocol's
====================================================================
Section 2 describes the basic structure of the TinyOS 2.x serial
-stack structure. This section describes its actual implementation,
+stack. This section describes its actual implementation,
including SerialActiveMessageC, which sits on top of the Dispatcher.
All of the components except for UartC are part of the serial
library that lives in ``tos/lib/serial``.
async event void putDone();
}
-It also provides interfaces for configuring the serial port. *NOTE:
-These are not codified yet, and so working out the UART HIL seems like
-a good idea.*
+Alternatively, ``UartC`` may provide the UartStream multi-byte level
+interface. See the Low-Level I/O TEP [TEP117_] for details.
+
+Additionally, UartC provides a split-phase interface to signal when
+the UART is idle. There are situations (such as when powering down the
+usart, when switching from TX to RX on a radio with a UART data line,
+etc.) when we need explicit information that the data sent over the
+UART has actually been transmitted in full. The problem is that on
+MCUs that double-buffer UART communication (such as the msp430), a
+putDone event signifies that the UART is ready to accept another byte,
+but NOT that the UART is idle.
+
+::
+
+ interface SerialFlush {
+ command void flush();
+ event void flushDone();
+ }
+
+It may provide additional interfaces for configuring the serial
+port. This TEP does not consider this topic.
3.2 Encoder/Framer: HdlcTranslateC
like framing (See RFC 1662[RFC1662_]). Type dispatch and buffer
management are left to higher layers in the serial stack. The protocol
is currently stop-and-wait in the host-to-mote direction and best
-effort in the mote-to-host direction. The first performance upgrade of
-this module will be to implement sliding window reliability in both
-directions.
+effort in the mote-to-host direction.
SerialP provides two byte-level interfaces to the upper layer for
sending and receiving packets, respectively called SendBytePacket and
On the sending side, SerialP is responsible for encapsulation of upper
layer packets. An upper layer component such as SerialDispatcherC
-initiates the sending of a packet by calling startSend, passing the
+initiates the sending of a packet by calling startSend(), passing the
first byte to send. SerialP collects subsequent bytes by signalling
-nextByte. Within the nextByte handler or between calls to nextByte,
+nextByte(). Within the nextByte handler or between calls to nextByte(),
the upper layer should indicate the end-of-packet by calling
-completeSend. If completeSend is called from within a nextByte
-handler, SerialP will ignore the return of the call to nextByte.
+completeSend(). If completeSend is called from within a nextByte()
+handler, SerialP will ignore the return of the call to nextByte().
::
SerialP maintains a small window of bytes that have been received by
the upper layer and not yet sent to the UART. Depending on the timing
requirements of the underlying UART, the size of this window can be
-changed. SerialP uses repeated calls to nextByte to keep this window
+changed. SerialP uses repeated calls to nextByte() to keep this window
filled.
-SerialP uses SerialFrameComm to send a delimiter between frames,
-a serial-level type field, the bytes of the packet, and a two-byte
-frame CRC. For mote-to-host gap detection and link reliability, a
-sequence number may also be sent (not currently activated).
+SerialP uses SerialFrameComm to send a delimiter between frames, a
+serial-level type field, the bytes of the packet, and a two-byte frame
+CRC. For mote-to-host gap detection and link reliability, a sequence
+number may also be sent (not activated in the default implementation).
-After sending an entire frame and receiving the last putDone event
-from below, SerialP signals sendCompleted to indicate the success or
+After sending an entire frame and receiving the last putDone() event
+from below, SerialP signals sendCompleted() to indicate the success or
failure of a requested transmission.
Packet reception is also managed by SerialP and the interface
Upon receiving an interframe delimiter and a new frame's header,
SerialP signals the upper layer indicating that a packet is
-arriving. For each byte received, SerialP signals byteReceived. (Note:
-SerialP signals on byte k-2 when byte k arrives, because the
-implementation precludes it from knowing when it has encountered the
-2-byte CRC in the frame footer until after it has received it. Lagging
-behind by two bytes makes it possible to hide all frame details from
-the upper layer.) Once SerialP receives the complete frame it signals
-endPacket with a value of SUCCESS. If instead it loses sync during
-reception it signals endPacket with FAIL.
+arriving. For each byte received, SerialP signals byteReceived().
+Once SerialP receives the complete frame it signals endPacket with a
+value of SUCCESS. If instead it loses sync during reception it signals
+endPacket with FAIL.
SerialP acknowledges frames it receives. Acknowledgements have a
higher priority than data transmissions and consequently, data frames
be transmitted may begin spooling into SerialP while SerialP is
actively sending an acknowledgement.
+Only the PC-to-mote communication path supports acknowledgements.
+SerialP does not request acknowledgements from the PC for two reasons.
+First, acks are not perfect reliable: they are used on the
+PC-to-mote path to raise reliability to a usable level. In the case of
+the PC-to-mote path, the UART receive buffer is typically a single
+byte, so a high interrupt load can easily lose (and sometimes does) a
+byte. This is in contrast to the PC receive buffer, which is much
+larger and does not have to deal with overflow. Second, adding support
+for acks would increase the code size and complexity of the serial
+stack. As code space is often at a premium, this would add little
+needed functionality at significant cost. Of course, any application
+that requires perfect reliability may layer its own scheme on top of
+the serial protocol.
+
+The acknowledgement protocol is stop-and-wait to minimize buffering on
+the mote side. This is considered more important on memory constrained
+devices than increased throughput in the PC-to-mote direction, which
+most applications only use for occasional control transmissions.
+
3.4 Dispatcher: SerialDispatcherC
--------------------------------------------------------------------
When SerialDispatcherC receives the first data byte of a packet from
SerialP, it stores it as the packet type and calls
-SerialPacketInfo.offset() to determine where in a message_t that
+offset() to determine where in a message_t that
packet format begins. It then spools data bytes in, filling them into
its message_t buffer. Similarly, on the send side, it first sends the
type byte and spools out data bytes starting from the index denoted by
the call to offset(). SerialDispatcherC uses the two length commands,
-dataLinkLength and upperLength, to translate between the two notions
+dataLinkLength() and upperLength(), to translate between the two notions
of packet length: above, length refers to the payload excluding
header, while below it refers to the payload plus header.
SerialAMSender instantiations for queue space. The underlying
implementation schedulers the packets in these queues using some form
of fair-share queueing. SerialAMReceiverC provides the virtualized
-abstraction for reception. These abstraction are very similar to
+abstraction for reception. These abstractions are very similar to
TinyOS's radio abstractions, namely, AMSenderC and AMReceiverC. See
Section 4 of TEP 116[TEP116_] for more information. Unlike the
services in the TEP 116, the serial component virtualizations provide
|
|
| Ben Greenstein
-| Center for Embedded Networked Sensing
-| UCLA 3563 Boelter Hall
-| Los Angeles, CA 90095-1596
+| Intel Research Seattle
+| 1100 NE 45th Street, 6th Floor
+| Seattle, WA 98105
|
-| phone - +1 310 206 3925
-| email - ben@cs.ucla.edu
+| phone - +1 206 206 545 2501
+| email - benjamin.m.greenstein@intel.com
6. Citations
====================================================================
.. [TEP116] TEP 116: Packet Protocols. tinyos-2.x/doc/txt/tep116.txt
+.. [TEP117] TEP 117: Low-Level I/O. tinyos-2.x/doc/txt/tep117.txt
+
.. [HDLC] International Organization For Standardization, ISO Standard 3309-1979, "Data communication - High-level data link control procedures - Frame structure", 1979.
.. [RFC1662] PPP in HDLC-like Framing, Internet Engineering Task Force (IETF), 1994