From: scipio Date: Tue, 7 Nov 2006 00:43:43 +0000 (+0000) Subject: Full update. X-Git-Tag: tinyos/2.0.1~267 X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=commitdiff_plain;h=e375f4f25e4f47409d09d6a13f57aff159c20886;p=tinyos-2.x.git Full update. --- diff --git a/doc/html/install-tinyos.html b/doc/html/install-tinyos.html index 312a1982..f75cded6 100644 --- a/doc/html/install-tinyos.html +++ b/doc/html/install-tinyos.html @@ -1,377 +1,382 @@ - - - - - Installing TinyOS 2.0 - - - - -
Installing TinyOS 2.0
-
Last updated 12 June 2006
- -

If you already have a 1.x tree, you are better off following the upgrade -instructions at upgrade-tinyos.html. - -

Currently, the TinyOS Core Working Group supports TinyOS on two platforms: Cygwin (Windows) -and Linux. There have been some successful efforts to getting TinyOS environments working -on Mac OSX, but OSX is not supported by the Core WG.

- -

Installing a TinyOS enviromnent has four basic steps; Windows requires an extra step, -installing Cygwin, which is a UNIX-like environment. The steps are:

- -
    -
  1. Installing a Java 1.5 (Java 5) JDK. Java is the most common way of interacting - with mote base stations or gateways that are plugged into a PC or laptop.
  2. -
  3. Windows only. Install Cygwin. This gives you a shell - and many UNIX tools which the TinyOS environment uses, such as perl and shell - scripts.
  4. -
  5. Installing native compilers. As you're compiling code for low-power - microcontrollers, you need compilers that can generate the proper assembly code. - If you using mica-family motes, you need the AVR toolchain; if you're using - telos-family motes, you need the MSP430 toolchain.
  6. -
  7. Installing the nesC compiler. TinyOS is written in nesC, a dialect - of C with support for the TinyOS concurrency model and component-based - programming. The nesC compiler is platform-independent: it passes its output - to the native compilers, so that it can take advantage of all of the effort - put into their optimizations.
  8. -
  9. Installing the TinyOS source tree. If you want to compile and - install TinyOS programs, you need the code.
  10. -
  11. Installing the Graphviz visualization tool. The TinyOS - environment includes nesdoc, a tool that automatically - generates HTML documentation from source code. Part of this process - involves drawing diagrams that show the relationships between - different TinyOS components. Graphviz - is an open source tool - that nesdoc uses to draw the diagrams.
  12. -
- -

Step 1: Install Java 1.5 JDK

- -Windows
-Download and install Sun's 1.5 JDK from http://java.sun.com. - -

-Linux
-Download and install IBM's 1.5 JDK from http://www-128.ibm.com/developerworks/java/jdk/. - -

Step 2: Install Cygwin

- - This step is required for Windows installations only. If you are installing -on Linux, skip to step 3. - -

We have put online the cygwin packages that we've confirmed to be -compatible with TinyOS. The instructions below use those packages. You -can also upgrade your cygwin environment according to the instructions -at www.cygwin.com and your environment will most likely work. A large -number of TinyOS users, upgrade their cygwin packages at least monthly -from cygnus. However, since we can't test what packages are compatible -as they become available daily, we can't confirm that today's set will -work. - -

-

    -
  1. Download the confirmed-compatible cygwin packages from the tinyos web site here. -

    -

  2. In a cygwin shell, unzip the above package into some directory. In these instructions the directory is /cygdrive/c/newcygpkgs. -
    -     $ cd /cygdrive/c/newcygpkgs
    -     $ tar zxvf cygwin-1.2a.tgz 
    -
    -This unzips the packages. -

    -

  3. In Windows Explorer, navigate to /cygdrive/c/newcygpkgs and click on the file setup.exe. Setup.exe is the setup program distributed by Cygnus Solutions. -

    -

  4. Follow these steps when the Cygwin Setup windows appears: -
      -
    -
  5. Opt to disable the virus scanner (it will be enabled when you're finished). -

    -

  6. Opt to Install from Local Directory. -

    -

  7. Specify the Root directory to be where your current cygwin installation is. This would be the directory that directories like 'opt' and 'usr' are in. For example, mine is rooted at c:\tinyos\cygwin, so I enter that. -

    -

  8. Select to Install for All Users -

    -

  9. Select the Unix file type (very important!) -

    -

  10. For the Local Packages Directory, specify where you unzipped the cygwin packages tarfile. For example, I would specify c:\newcygpkgs. (The setup.exe program will probably select the right default directory.) -

    -

  11. The next window will allow you to select packages to install. You should see that most of the packages have an X-ed box next to them; these are the packages that are to be installed. -

    -

  12. Click install. Some notes: -
      -
    • You might see a message explaining that you need to reboot because some files are in use. This most likely means that your cygwin DLL is loaded and in-use and, therefore, cannot be replaced. When you reboot, the new DLL will be loaded. -
    • Related to the above warnings, if you see warnings about the cygwin1.dll not being found, don't worry. All will be well once you reboot and the right DLL is loaded. -
    -
- - -

Step 3: Install native compilers

- -Install the appropriate version of the following (Windows or Linux, -avr or msp430 or both) with the rpm command 'rpm -ivh '. -On -windows, if you get an error claiming that the rpm was build for an NT -computer and you're on a windows NT computer, bypass the erroneous -error by using 'rpm -ivh --ignoreos rpmname'. -(We have xscale -compiler tools online at -http://www.tinyos.net/dist-1.2.0/tools/ -but they have not yet been extensively tested by a large community.) - - -

Atmel AVR Tools - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ToolWindows/CygwinLinux
avr-binutilsavr-binutils-2.15tinyos-3.cygwin.i386.rpmavr-binutils-2.15tinyos-3.i386.rpm
avr-gccavr-gcc-3.4.3-1.cygwin.i386.rpm avr-gcc-3.4.3-1.i386.rpm
avr-libcavr-libc-1.2.3-1.cygwin.i386.rpmavr-libc-1.2.3-1.i386.rpm
avariceavarice-2.4-1.cygwin.i386.rpmavarice-2.4-1.i386.rpm
insight (avr-gdb)avr-insight-6.3-1.cygwin.i386.rpmavr-insight-6.3-1.i386.rpm
-If you receive an rpm error that indicates that you have a newer version already installed, try rpm -Uvh --force - - -

TI MSP430 Tools - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ToolWindows/CygwinLinux
basemsp430tools-base-0.1-20050607.cygwin.i386.rpmmsp430tools-base-0.1-20050607.i386.rpm
python toolsmsp430tools-python-tools-1.0-1.cygwin.noarch.rpmmsp430tools-python-tools-1.0-1.noarch.rpm
binutils msp430tools-binutils-2.16-20050607.cygwin.i386.rpmmsp430tools-binutils-2.16-20050607.i386.rpm
gccmsp430tools-gcc-3.2.3-20050607.cygwin.i386.rpmmsp430tools-gcc-3.2.3-20050607.i386.rpm
libcmsp430tools-libc-20050308cvs-20050608.cygwin.i386.rpmmsp430tools-libc-20050308cvs-20050608.i386.rpm
jtagNot yet availablemsp430tools-jtag-lib-20031101cvs-20050610.i386.rpm
gdbNot yet availablemsp430tools-gdb-6.0-20050609.i386.rpm
- -

Step 4: Install TinyOS toolchain

- -The TinyOS-specific tools are the NesC compiler and a set of tools -developed in the tinyos-2.x/tools source code repository. They are -also installed using rpms. If you using the Cygwin version recommended -in these install -instructions, you should install the "Recommended" Windows/Cygwin -nesC RPM (1.2.7b). If you install it and it does not work (e.g., you -get strange errors when you try to execute it), this may be due -to a Cygwin version incompatibility: try the "Other" Windows/Cygwin -RPM (1.2.7a). - - -

TinyOS-specific Tools - - - - - - - - - - - - - - - - - - - - - - - - - -
ToolRecommended Windows/CygwinOther Windows/CygwinLinuxCommand
NesCnesc-1.2.7b-1.cygwin.i386.rpmnesc-1.2.7a-1.cygwin.i386.rpmnesc-1.2.7a-1.i386.rpm rpm -Uvh
tinyos-toolstinyos-tools-1.2.2-1.cygwin.i386.rpmtinyos-tools-1.2.2-1.cygwin.i386.rpmtinyos-tools-1.2.2-1.i386.rpmrpm -ivh --force (1.x tree)
rpm -Uvh (no 1.x tree)
- -

Step 5: Install the TinyOS 2.x source tree

- -Now that the tools are installed, you need only install the tinyos 2.x -source tree and then set your environment variables. -Install the appropriate version of the following (Window or Linux) -with the rpm command 'rpm -ivh '. -As with the previous rpms, if you get an error claiming that the rpm -was build for an NT computer and you're on a windows NT computer, -bypass the erroneous error by using 'rpm -ivh --ignoreos -rpmname'. - -
    -
  • Install tinyos-2.x -

    - - - -

    TinyOS 2.x - - - - - - - - - - - - - -
    Windows/CygwinLinux
    TinyOStinyos-2.0.0beta2-3.cygwin.noarch.rpmtinyos-2.0.0beta2-3.noarch.rpm
    -

  • Configure your environment -

    -Ideally, you'll put these environment variables in a shell script that will run when your shell starts, but you needn't -put such a script under /etc/profile.d. -

    -The example -settings below assume that the tinyos-2.x installation is in /opt/tinyos-2.x. -Change the settings to be correct for where you've put your tinyos-2.x tree. Note -that the windows CLASSPATH must be a windows-style path, not a cygwin path. You can -generate a windows style path from a cygwin-style path using 'cygpath -w'. For example: -

    export CLASSPATH=`cygpath -w $TOSROOT/support/sdk/java/tinyos.jar`
    -export CLASSPATH="$CLASSPATH;."
    -
    - -

    TinyOS 2.x - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Environment VariableWindowsLinux
    TOSROOT/opt/tinyos-2.xsame as in Cygwin - -
    TOSDIR$TOSROOT/tossame as in Cygwin - -
    CLASSPATHC:\tinyos\cygwin\opt\tinyos-2.x\support\sdk\java\tinyos.jar;.$TOSROOT/support/sdk/java/tinyos.jar:. - -
    MAKERULES$TOSROOT/support/make/Makerulessame as in Cygwin - -
    PATH/opt/msp430/bin:$PATHsame as in Cygwin - -
    - -Only necessary if you're using the MSP430 platform/tools. - -

    -In addition to the above environment variables, do the following on Linux machines: -

      -
    1. Change the ownership on your /opt/tinyos-2.x files: chown -R <your uid> /opt/tinyos-2.x -
    2. Change the permissions on any serial (/dev/ttyS<N>), usb -(/dev/tts/usb<N>, /dev/ttyUSB<N>), or parallel (/dev/parport) devices you -are going to use: chmod 666 /dev/<devicename> - -
    - -
- -

Step 6: Installing Graphviz

- -

Go to download page of the Graphviz project -and download the appropriate RPM. You only need the basic graphviz RPM (graphviz-); -you don't need all of the add-ons, such as -devel, -doc, -perl, etc. -If you're not sure what version of Linux you're running,

- -
uname -a
- -

might give you some useful information. Install the rpm with rpm -i rpm-name. -In the case of Windows, there is a simple install program, so you don't need to deal with RPMs.

- - - + + + + + Installing TinyOS 2.0 + + + + +
Installing TinyOS 2.0
+
Last updated 5 November 2006
+ +

If you already have a 1.x tree or an existing 2.x tree, you are better off +following the upgrade instructions at +upgrade-tinyos.html.

+ +

Currently, the TinyOS Core Working Group supports TinyOS on two platforms: Cygwin (Windows) +and Linux. There have been some successful efforts to getting TinyOS environments working +on Mac OSX, but OSX is not supported by the Core WG.

+ +

Installing a TinyOS enviromnent has five basic steps; Windows requires an extra step, +installing Cygwin, which is a UNIX-like environment. The steps are:

+ +
    +
  1. Installing a Java 1.5 (Java 5) JDK. Java is the most common way of interacting + with mote base stations or gateways that are plugged into a PC or laptop.
  2. +
  3. Windows only. Install Cygwin. This gives you a shell + and many UNIX tools which the TinyOS environment uses, such as perl and shell + scripts.
  4. +
  5. Installing native compilers. As you're compiling code for low-power + microcontrollers, you need compilers that can generate the proper assembly code. + If you using mica-family motes, you need the AVR toolchain; if you're using + telos-family motes, you need the MSP430 toolchain.
  6. +
  7. Installing the nesC compiler. TinyOS is written in nesC, a dialect + of C with support for the TinyOS concurrency model and component-based + programming. The nesC compiler is platform-independent: it passes its output + to the native compilers, so that it can take advantage of all of the effort + put into their optimizations.
  8. +
  9. Installing the TinyOS source tree. If you want to compile and + install TinyOS programs, you need the code.
  10. +
  11. Installing the Graphviz visualization tool. The TinyOS + environment includes nesdoc, a tool that automatically + generates HTML documentation from source code. Part of this process + involves drawing diagrams that show the relationships between + different TinyOS components. Graphviz + is an open source tool + that nesdoc uses to draw the diagrams.
  12. +
+ +

Step 1: Install Java 1.5 JDK

+ +Windows
+Download and install Sun's 1.5 JDK from http://java.sun.com. + +

+Linux
+Download and install IBM's 1.5 JDK from http://www-128.ibm.com/developerworks/java/jdk/. + +

Step 2: Install Cygwin

+ + This step is required for Windows installations only. If you are installing +on Linux, skip to step 3. + +

We have put online the cygwin packages that we've confirmed to be +compatible with TinyOS. The instructions below use those packages. You +can also upgrade your cygwin environment according to the instructions +at www.cygwin.com and your environment will most likely work. A large +number of TinyOS users, upgrade their cygwin packages at least monthly +from cygnus. However, since we can't test what packages are compatible +as they become available daily, we can't confirm that today's set will +work. + +

+

    +
  1. Download the confirmed-compatible cygwin packages from the tinyos web site here. +

    +

  2. In a cygwin shell, unzip the above package into some directory. In these instructions the directory is /cygdrive/c/newcygpkgs. +
    +     $ cd /cygdrive/c/newcygpkgs
    +     $ tar zxvf cygwin-1.2a.tgz 
    +
    +This unzips the packages. +

    +

  3. In Windows Explorer, navigate to /cygdrive/c/newcygpkgs and click on the file setup.exe. Setup.exe is the setup program distributed by Cygnus Solutions. +

    +

  4. Follow these steps when the Cygwin Setup windows appears: +
      +
    +
  5. Opt to disable the virus scanner (it will be enabled when you're finished). +

    +

  6. Opt to Install from Local Directory. +

    +

  7. Specify the Root directory to be where your current cygwin installation is. This would be the directory that directories like 'opt' and 'usr' are in. For example, mine is rooted at c:\tinyos\cygwin, so I enter that. +

    +

  8. Select to Install for All Users +

    +

  9. Select the Unix file type (very important!) +

    +

  10. For the Local Packages Directory, specify where you unzipped the cygwin packages tarfile. For example, I would specify c:\newcygpkgs. (The setup.exe program will probably select the right default directory.) +

    +

  11. The next window will allow you to select packages to install. You should see that most of the packages have an X-ed box next to them; these are the packages that are to be installed. +

    +

  12. Click install. Some notes: +
      +
    • You might see a message explaining that you need to reboot because some files are in use. This most likely means that your cygwin DLL is loaded and in-use and, therefore, cannot be replaced. When you reboot, the new DLL will be loaded. +
    • Related to the above warnings, if you see warnings about the cygwin1.dll not being found, don't worry. All will be well once you reboot and the right DLL is loaded. +
    +
+ + +

Step 3: Install native compilers

+ +Install the appropriate version of the following (Windows or Linux, +avr or msp430 or both) with the rpm command 'rpm -ivh '. +On +windows, if you get an error claiming that the rpm was build for an NT +computer and you're on a windows NT computer, bypass the erroneous +error by using 'rpm -ivh --ignoreos rpmname'. +(We have xscale +compiler tools online at +http://www.tinyos.net/dist-1.2.0/tools/ +but they have not yet been extensively tested by a large community.) + + +

Atmel AVR Tools + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ToolWindows/CygwinLinux
avr-binutilsavr-binutils-2.15tinyos-3.cygwin.i386.rpmavr-binutils-2.15tinyos-3.i386.rpm
avr-gccavr-gcc-3.4.3-1.cygwin.i386.rpm avr-gcc-3.4.3-1.i386.rpm
avr-libcavr-libc-1.2.3-1.cygwin.i386.rpmavr-libc-1.2.3-1.i386.rpm
avariceavarice-2.4-1.cygwin.i386.rpmavarice-2.4-1.i386.rpm
insight (avr-gdb)avr-insight-6.3-1.cygwin.i386.rpmavr-insight-6.3-1.i386.rpm
+If you receive an rpm error that indicates that you have a newer version already installed, try rpm -Uvh --force + + +

TI MSP430 Tools + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ToolWindows/CygwinLinux
basemsp430tools-base-0.1-20050607.cygwin.i386.rpmmsp430tools-base-0.1-20050607.i386.rpm
python toolsmsp430tools-python-tools-1.0-1.cygwin.noarch.rpmmsp430tools-python-tools-1.0-1.noarch.rpm
binutils msp430tools-binutils-2.16-20050607.cygwin.i386.rpmmsp430tools-binutils-2.16-20050607.i386.rpm
gccmsp430tools-gcc-3.2.3-20050607.cygwin.i386.rpmmsp430tools-gcc-3.2.3-20050607.i386.rpm
libcmsp430tools-libc-20050308cvs-20050608.cygwin.i386.rpmmsp430tools-libc-20050308cvs-20050608.i386.rpm
jtagNot yet availablemsp430tools-jtag-lib-20031101cvs-20050610.i386.rpm
gdbNot yet availablemsp430tools-gdb-6.0-20050609.i386.rpm
+ +

Step 4: Install TinyOS toolchain

+ +The TinyOS-specific tools are the NesC compiler and a set of tools +developed in the tinyos-2.x/tools source code repository. They are +also installed using rpms. If you using the Cygwin version recommended +in these install +instructions, you should install the "Recommended" Windows/Cygwin +nesC RPM. +Try installing it and if it does not work (e.g., you +get strange errors when you try to execute it), this may be due +to a Cygwin version incompatibility: try the "Other" Windows/Cygwin +RPM (1.2.7a). If you are using Cygwin and installing the nesC RPM +causes an error that the RPM was built for Cygwin, +add the --ignoreos option. + + +

TinyOS-specific Tools + + + + + + + + + + + + + + + + + + + + + + + + + +
ToolRecommended Windows/CygwinOther Windows/CygwinLinuxCommand
NesCnesc-1.2.7b-1.cygwin.i386.rpmnesc-1.2.7a-1.cygwin.i386.rpmnesc-1.2.7a-1.i386.rpm rpm -Uvh
+ rpm -Uvh --ignoreos (if Cygwin complains)
tinyos-toolstinyos-tools-1.2.3-1.cygwin.i386.rpmtinyos-tools-1.2.3-1.cygwin.i386.rpmtinyos-tools-1.2.3-1.i386.rpmrpm -ivh --force (1.x tree)
rpm -Uvh (no 1.x tree)
+ +

Step 5: Install the TinyOS 2.x source tree

+ +Now that the tools are installed, you need only install the tinyos 2.x +source tree and then set your environment variables. +Install the appropriate version of the following (Window or Linux) +with the rpm command 'rpm -ivh '. +As with the previous rpms, if you get an error claiming that the rpm +was build for an NT computer and you're on a windows NT computer, +bypass the erroneous error by using 'rpm -ivh --ignoreos +rpmname'. + +
    +
  • Install tinyos-2.x +

    + + + +

    TinyOS 2.x + + + + + + + + + + + + + +
    Windows/CygwinLinux
    TinyOStinyos-2.0.0-1.cygwin.noarch.rpmtinyos-2.0.0-1.noarch.rpm
    +

  • Configure your environment +

    +Ideally, you'll put these environment variables in a shell script that will run when your shell starts, but you needn't +put such a script under /etc/profile.d. +

    +The example +settings below assume that the tinyos-2.x installation is in /opt/tinyos-2.x. +Change the settings to be correct for where you've put your tinyos-2.x tree. Note +that the windows CLASSPATH must be a windows-style path, not a cygwin path. You can +generate a windows style path from a cygwin-style path using 'cygpath -w'. For example: +

    export CLASSPATH=`cygpath -w $TOSROOT/support/sdk/java/tinyos.jar`
    +export CLASSPATH="$CLASSPATH;."
    +
    + +

    TinyOS 2.x + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Environment VariableWindowsLinux
    TOSROOT/opt/tinyos-2.xsame as in Cygwin + +
    TOSDIR$TOSROOT/tossame as in Cygwin + +
    CLASSPATHC:\tinyos\cygwin\opt\tinyos-2.x\support\sdk\java\tinyos.jar;.$TOSROOT/support/sdk/java/tinyos.jar:. + +
    MAKERULES$TOSROOT/support/make/Makerulessame as in Cygwin + +
    PATH/opt/msp430/bin:$PATHsame as in Cygwin + +
    + +Only necessary if you're using the MSP430 platform/tools. + +

    +In addition to the above environment variables, do the following on Linux machines: +

      +
    1. Change the ownership on your /opt/tinyos-2.x files: chown -R <your uid> /opt/tinyos-2.x +
    2. Change the permissions on any serial (/dev/ttyS<N>), usb +(/dev/tts/usb<N>, /dev/ttyUSB<N>), or parallel (/dev/parport) devices you +are going to use: chmod 666 /dev/<devicename> + +
    + +
+ +

Step 6: Installing Graphviz

+ +

Go to download page of the Graphviz project +and download the appropriate RPM. You only need the basic graphviz RPM (graphviz-); +you don't need all of the add-ons, such as -devel, -doc, -perl, etc. +If you're not sure what version of Linux you're running,

+ +
uname -a
+ +

might give you some useful information. Install the rpm with rpm -i rpm-name. +In the case of Windows, there is a simple install program, so you don't need to deal with RPMs.

+ + + diff --git a/doc/html/overview.html b/doc/html/overview.html index a929d36e..5f542805 100644 --- a/doc/html/overview.html +++ b/doc/html/overview.html @@ -6,7 +6,7 @@ TinyOS 2.0 Overview - + -
-

Pins and Buses

+
+

Low-Level I/O

@@ -300,12 +300,12 @@ ul.auto-toc { - + - + - + @@ -321,35 +321,34 @@ TEP 1.

Abstract

The memo documents the TinyOS 2.x interfaces used for controlling -digital IO functionality and digital interfaces other than serial -communication covered in [tep113].

+digital IO functionality and digital interfaces.

1. Introduction

The canonical TinyOS device is likely to have a variety of digital interfaces. These interfaces may be divided into two broad -categories. The first are general purpose digital I/O lines (pins) -for individual digital signals at physical pins on a chip or -platform. The second are digital I/O interfaces that have predefined -communication protocol formats. The two buses covered in this -document are the Serial Peripheral Interface (SPI) and the -Inter-Integrated Circuit (I2c) or Two-Wire interface. While there are -likely other bus formats, we presume SPI and I2C to have the largest -coverage. While the UART interface is also in this category, it is -covered separately in [tep113].

-

This memo documents the interfaces used for pins and the two buses.

+categories. The first are general purpose digital I/O lines (pins) for +individual digital signals at physical pins on a chip or platform. The +second are digital I/O interfaces that have predefined communication +protocol formats. The three buses covered in this document are the +Serial Peripheral Interface (SPI), the Inter-Integrated Circuit (I2C) +or Two-Wire interface, and the Universal Asynchronous +Receiver/Transmitter (UART) interface. While there are likely other +bus formats, we presume SPI, I2C, and UART to have the largest +coverage.

+

This memo documents the interfaces used for pins and the three buses.

2. Pins

-

General Purpose I/O (GPIO) pins are single, versatile digital I/O signals -individually controllable on a particular chip or platform. Each GPIO -can be placed into either an input mode or an output mode. On -some platforms a third 'tri-state' mode may exist, but this -functionality is platform specific and will not be covered in this -document.

-

On many platforms, a physical pin may function as either a digital GPIO -or another special function I/O such. Examples include ADC I/O or a bus -I/O. Interfaces to configure the specific function of a pin are +

General Purpose I/O (GPIO) pins are single, versatile digital I/O +signals individually controllable on a particular chip or +platform. Each GPIO can be placed into either an input mode or an +output mode. On some platforms a third 'tri-state' mode may exist, but +this functionality is platform specific and will not be covered in +this document.

+

On many platforms, a physical pin may function as either a digital +GPIO or another special function I/O such. Examples include ADC I/O or +a bus I/O. Interfaces to configure the specific function of a pin are platform specific.

The objective of the interfaces described here is not to attempt to cover all possibilities of GPIO functionality and features, but to @@ -398,7 +397,9 @@ interface GeneralIO async command void toggle(); async command bool get(); async command void makeInput(); + async command bool isInput(); async command void makeOutput(); + async command bool isOutput(); }

@@ -414,7 +415,9 @@ through a platform specific HAL interface.

interface GpioInterrupt { async command error_t enableRisingEdge(); + async command bool isRisingEdgeEnabled(); async command error_t enableFallingEdge(); + async command bool isFallingEdgeEnabled(); async command error_t disable(); async event void fired(); @@ -428,12 +431,15 @@ with a GPIO event. Platforms MAY provide this interface.

Some platforms may have hardware support for such a feature. Other platforms may emulate this capability using the SoftCaptureC component. The interface makes not declaration of the precision or -accuracy of the timestamp with respect to the associated GPIO event.

+accuracy of the timestamp with respect to the associated GPIO +event.

 interface GpioCapture {
 
   async command error_t captureRisingEdge();
+  async command bool isRisingEdgeEnabled();
   async command error_t captureFallingEdge();
+  async command bool isFallingEdgeEnabled();
   async event void captured(uint16_t time);
   async command void disable();
 
@@ -463,18 +469,18 @@ interfaces and implementations.

asynchronous packet level interface. The byte level interface is intended for short transactions (3-4 bytes) on the SPI bus.

-interface SPIByte {
-  async command error_t write( uint8_t tx, uint8_t* rx );
+interface SpiByte {
+  async command uint8_t write( uint8_t tx );
 }
 

The packet level interface is for larger bus transactions. The -pointer/length interface permits use of hardware assist such as DMA.

+pointer/length interface permits use of hardware assist such as +DMA.

-interface SPIPacket {
-
+interface SpiPacket {
   async command error_t send( uint8_t* txBuf, uint8_t* rxBuf, uint16_t len );
   async event void sendDone( uint8_t* txBuf, uint8_t* rxBuf, uint16_t len,
-                            error_t error );
+                             error_t error );
 }
 
@@ -483,33 +489,112 @@ interface SPIPacket {

The Inter-Integrated Circuit (I2C) interface is another type of digital bus that is often used for chip-to-chip communication. It is also known as a two-wire interface.

-

The I2CPacket interface provides for asynchronous Master mode communication on an -I2C with application framed packets. It supports only single -transfers with a start-stop condition around each transfer.

+

The I2CPacket interface provides for asynchronous Master mode +communication on an I2C with application framed packets. Individual +I2C START-STOP events are controllable which allows the using +component to do multiple calls within a single I2C transaction and +permits multiple START sequences

Platforms providing I2C capability MUST provide this interface.

-interface I2CPacket {
-  async command result_t readPacket(uint16_t _addr, uint8_t _length, uint8_t* _data);
-  async command result_t writePacket(uint16_t _addr, uint8_t _length, uint8_t* _data);
-  async event void readPacketDone(uint16_t addr, uint8_t length, uint8_t* data, result_t success);
-  async event void writePacketDone(uint16_t addr, uint8_t length, uint8_t* data, result_t success);
+interface I2CPacket<addr_size> {
+  async command error_t read(i2c_flags_t flags, uint16_t addr, uint8_t length, u int8_t* data);
+  async event void readDone(error_t error, uint16_t addr, uint8_t length, uint8_t* data);
+  async command error_t write(i2c_flags_t flags, uint16_t addr, uint8_t length, uint8_t* data);
+  async event void writeDone(error_t error, uint16_t addr, uint8_t length, uint8_t* data)
+}
+
+

The interface is typed according to the addressing space the +underlying implementation supports. Valid type values are below.

+
+TI2CExtdAddr - Interfaces uses the extended (10-bit) addressing mode.
+TI2CBasicAddr - Interfaces uses the basic (7-bit) addressing mode.
+
+

The i2c_flags_t values are defined below. The flags define the +behavior of the operation for the call being made. These values may be +ORed together.

+
+I2C_START    - Transmit an I2C STOP at the beginning of the operation.
+I2C_STOP     - Transmit an I2C STOP at the end of the operation. Cannot be used
+               with the I2C_ACK_END flag.
+I2C_ACK_END  - ACK the last byte sent from the buffer. This flags is only valid
+               a write operation. Cannot be used with the I2C_STOP flag.
+
+ +
+

3.3 UART

+

The Universal Asynchronous Receiver/Transmitter (UART) interface is a +type of serial interconnect. The interface is "asynchronous" since it +recovers timing from the data stream itself, rather than a separate +control stream. The interface is split into an asynchronous multi-byte +level interface and a synchronous single-byte level interface.

+

The multi-byte level interface, UartStream, provides a split-phase +interface for sending and receiving one or more bytes at a time. When +receiving bytes, a byte-level interrupt can be enabled or an interrupt +can be generated after receiving one or more bytes. The latter is +intended to support use cases where the number of bytes to receive is +already known. If the byte-level receive interrupt is enabled, the +receive command MUST return FAIL. If a multi-byte receive interrupt is +enabled, the enableReceiveInterrupt command MUST return FAIL.

+
+interface UartStream {
+  async command error_t send( uint8_t* buf, uint16_t len );
+  async event void sendDone( uint8_t* buf, uint16_t len, error_t error );
+
+  async command error_t enableReceiveInterrupt();
+  async command error_t disableReceiveInterrupt();
+  async event void receivedByte( uint8_t byte );
+
+  async command error_t receive( uint8_t* buf, uint8_t len );
+  async event void receiveDone( uint8_t* buf, uint16_t len, error_t error );
+}
+
+

The single-byte level interface, UartByte, provides a synchronous +interface for sending and receiving a single byte. This interface is +intended to support use cases with short transactions. Because UART is +asynchronous, the receive command takes a timeout which represents +units in byte-times, after which the command returns with an +error. Note that use of this interface is discouraged if the UART baud +rate is low.

+
+interface UartByte {
+  async command error_t send( uint8_t byte );
+  async command error_t receive( uint8_t* byte, uint8_t timeout );
 }
 
-

4. Author's Address

+

4. Implementation

+

Example implementations of the pin interfaces can be found in tos/chips/msp430/pins, +tos/chips/atm128/pins, and tos/chips/pxa27x/gpio.

+

Example implementations of the SPI interfaces can be found in tos/chips/msp430/usart, +tos/chips/atm128/spi, and tos/chips/pxa27x/ssp.

+

Example implementations of the I2C interfaces can be found in tos/chips/msp430/usart, +tos/chips/atm128/i2c, and tos/chips/pxa27x/i2c.

+

Example implementations of the UART interfaces can be found in tos/chips/msp430/usart, +tos/chips/atm128/uart/ and tos/chips/pxa27x/uart.

+
+
+

5. Author's Address

Phil Buonadonna
-
Arched Rock Corporation
+
Arch Rock Corporation
657 Mission St. Ste 600
San Francisco, CA 94105-4120

phone - +1 415 692-0828 x2833
+

+

+
Jonathan Hui
+
Arched Rock Corporation
+
657 Mission St. Ste 600
+
San Francisco, CA 94105-4120
+

+
phone - +1 415 692-0828 x2835
TinyOS-Version:2.x
Author:Phil Buonadonna
Phil Buonadonna, Jonathan Hui
Draft-Created:23-Jan-2006
Draft-Version:1.2
Draft-Version:1.1.2.9
Draft-Modified:2006-07-12
Draft-Modified:2006-09-30
Draft-Discuss:TinyOS Developer List <tinyos-devel at mail.millennium.berkeley.edu>
diff --git a/doc/html/tep118.html b/doc/html/tep118.html index 47d1b974..dfede355 100644 --- a/doc/html/tep118.html +++ b/doc/html/tep118.html @@ -303,9 +303,9 @@ ul.auto-toc { - + - + @@ -401,7 +401,7 @@ generic configuration DisseminatorC(typedef t, uint16_t key) { provides interface DisseminationUpdate <t>; } -

The t argument MUST be able to fit in a single message_t[tep111_] after +

The t argument MUST be able to fit in a single message_t[1] after considering the headers that the dissemination protocol introduces. A dissemination implementation SHOULD have a compile error if a larger type than this is used.

@@ -516,12 +516,6 @@ trickle.

Philip Levis and Gilman Tolle
Draft-Created:10-Dec-2004
Draft-Version:1.2
Draft-Version:1.1.2.3
Draft-Modified:2006-07-12
Draft-Modified:2006-06-20
Draft-Discuss:TinyOS Developer List <tinyos-devel at mail.millennium.berkeley.edu>
-
-

Docutils System Messages

-
-

System Message: ERROR/3 (txt/tep118.txt, line 116); backlink

-Unknown target name: "tep111".
-
diff --git a/doc/html/tep119.html b/doc/html/tep119.html index 3719f95e..32516a77 100644 --- a/doc/html/tep119.html +++ b/doc/html/tep119.html @@ -497,36 +497,54 @@ such as queueing and timing.

LinkEstimatorP estimates the quality of link to or from each neighbor. Link estimation can be done in a variety of ways, and we do not impose one here. It is decoupled from the establishment of -routes. There is a narrow interface (LinkEstimator) between the link -estimator and the routing engine. The one requirement is that the -quality returned is standardized. A larger return value from -LinkEstimator.getQuality(), LinkEstimator.getforwardQuality(), -LinkEstimator.getreserveQuality() MUST imply that the link to the -neighbor is estimated to be of a higher quality than the one that -results in a smaller return value. The range of value SHOULD be -[0,255] and the variation in link quality in that range SHOULD be -linear. Radio provided values such as LQI or RSI, beacon based link -estimation to compute ETX, or their combination are some possible -approaches to estimating link qualities. LinkEstimatorP MAY have its -own control messages to compute bi-directional link qualities:

+routes. There is a narrow interface (LinkEstimator and +NeighborTableEviction) between the link estimator and the routing +engine. The one requirement is that the quality returned is +standardized. A smaller return value from LinkEstimator.getQuality(), +LinkEstimator.getforwardQuality(), LinkEstimator.getreserveQuality() +MUST imply that the link to the neighbor is estimated to be of a +higher quality than the one that results in a smaller return +value. The range of value SHOULD be [0,255] and the variation in link +quality in that range SHOULD be linear. Radio provided values such as +LQI or RSI, beacon based link estimation to compute ETX, or their +combination are some possible approaches to estimating link +qualities. LinkEstimatorP MAY have its own control messages to compute +bi-directional link qualities. LinkEstimatorP provides calls (txAck(), +txNoAck(), and clearDLQ()) to update the link estimates based on +successful or unsuccessful data transmission to the neighbors. The +user of LinkEstimatorP can call insertNeighbor() to manually insert a +node in the neighbor table, pinNeighbor() to prevent a neighbor from +being evicted, and unpinNeighbor() to restore eviction policy:

-typedef uint16_t neighbor_t
+typedef uint16_t neighbor_table_entry_t
 
 LinkEstimatorP {
   provides {
+    interface StdControl;
+    interface AMSend as Send;
+    interface Receive;
     interface LinkEstimator;
-    interface NeighborTable;
+    interface Init;
+    interface Packet;
+    interface LinkSrcPacket;
   }
 }
 
 interface LinkEstimator {
-  command uint8_t getLinkQuality(neighbot_t neighbor);
-  command uint8_t getReverseQuality(neighbot_t neighbor);
-  command uint8_t getForwardQuality(neighbot_t neighbor);
+  command uint8_t getLinkQuality(uint16_t neighbor);
+  command uint8_t getReverseQuality(uint16_t neighbor);
+  command uint8_t getForwardQuality(uint16_t neighbor);
+  command error_t insertNeighbor(am_addr_t neighbor);
+  command error_t pinNeighbor(am_addr_t neighbor);
+  command error_t unpinNeighbor(am_addr_t neighbor);
+  command error_t txAck(am_addr_t neighbor);
+  command error_t txNoAck(am_addr_t neighbor);
+  command error_t clearDLQ(am_addr_t neighbor);
+  event void evicted(am_addr_t neighbor);
 }
 
-interface NeighborTable {
-  event void evicted(neighbot_t neighbor)
+interface NeighborTableEviction {
+  event void evicted(uint16_t neighbor)
 }
 
diff --git a/doc/html/tep120.html b/doc/html/tep120.html index 02affb5a..e50e9f14 100644 --- a/doc/html/tep120.html +++ b/doc/html/tep120.html @@ -314,9 +314,9 @@ ul.auto-toc {
Adam Wolisz Draft-Created:17-April-2006 -Draft-Version:1.2 +Draft-Version:1.1.2.5 -Draft-Modified:2006-07-12 +Draft-Modified:2006-10-25 Draft-Discuss:TinyOS Alliance <tinyos-alliance at mail.millennium.berkeley.edu> @@ -758,29 +758,32 @@ standardized interfaces that allows such technology to interoperate.

9. Funding

-

As with the IETF, individuals are responsible for their own costs, -which primarily involve meetings, travel, and generation of work -products. Membership participation will involve attendance at -Alliance meetings. Registration fees will be charged to cover costs -associated with adminstration of the meetings.

-

Companies and institutions are encouraged to contribute financial and -in-kind support. It will be essential that companies provide initial -funding to create the legal structure and to establish basic IT -capabilities to host the web site and working groups.

Initially, we expect that there are no full time employees in the Alliance and that funding needs are limited to such items as lawyer's fees, web site costs, and insurance. If the Alliance eventually requires full time support personnel, the funding structure will have to be re-visited.

+

As with the IETF, individuals are responsible for their own costs, +which primarily involve meetings, travel, and generation of work +products. The Alliance is predominantly a volunteer organization. +Membership participation will involve attendance at +Alliance meetings. Registration fees will be charged to cover costs +associated with adminstration of the meetings.

To maintain the focus on technical excellence and meritocracy, we want to avoid the heavy-handed quid-pro-quo seen in many industrial consortiums where funding determines influence. The best use of funds and the best form of influence is direct contribution to the work -products of the Alliance. We will permit targeted contributions -toward specific working groups or technical capabilities.

-

We seek to keep overall structure lean, mostly volunteer. -Focus on desired impact and recognition, rather than control.

-

Institutional members +products of the Alliance. +To keep the structure of the Alliance and its operations minimalist +and lean, membership focuses on desired impact and recognition, rather +than control. We want the best way to influence the direction of the Alliance +to be to contribute technical work and demonstrate leadership, rather than +try to control what individuals can or cannot contribute.

+

Companies and institutions are encouraged to contribute financial and +in-kind support. It will be essential that companies provide initial +funding to create the legal structure and to establish basic IT +capabilities to host the web site and working groups. +Institutional members will pay an annual membership fee. In some cases, a contributing corporate member may provide in-kind services such as lawyers' time used to @@ -790,52 +793,80 @@ solicited and encouraged. In this case the donator need not become a contributing corporate member, e.g., in those cases where such a membership may be prohibited or unwanted. The costs of meetings, such as the TinyOS -technology exchange, will be covered through registration fees.

-

Individuals are responsible -for their own costs such as -for travel, meeting costs, or costs for contributing -software or documentation to the Alliance. The Alliance -is primarily a volunteer organization.

+technology exchange, will be covered through registration fees and +not by institutional membership fees.

10. Work Products

-

Code base -Stable, robust core release -Rapidly evolving, innovative extensions -Reference Implementations -Tools -Data -Documentation -Standard proposals -Marketing and Promotion -Testing and Compliance -Assessments -Applications and uses of technology -Educational Materials

+

The broad mission of the Alliance calls for a broad range of +work products.

+

Foremost among these are a set of TEPs documenting +systems and protocols as well as TEPs that provide guidance +and knowledge to the community. Technical documentation will have +robust and open reference implementations for the community to +use, refine, improve, and discuss. These reference implementations +will not preclude alternative, compatibile implementations which may +have additional features or optimizations. The Alliance Working Groups +will periodically produce periodic releases of these reference +implementations for the community to use and improve.

+

The Alliance will support community contributions +of innovative extensions and systems by providing a CVS repository +to store them. +In order to keep these contributions organized for users, the +Steering Committee may nominate one or more people to caretake +the repository by setting minimal guidelines for the use of +the directory structure and migrating code as it joins the core +or falls into disuse.

+

To make these technological resources more accessible and useful +to a broad embedded networks community, the Alliance will be +dedicated to providing a set of educational materials. This +includes introductory tutorials, documentation of core systems, +simple and complex example applications, and user guides.

+

In addition to educational sample applications, whose purpose +is to teach new developers about the internals and workings of +the technology, the Alliance will develop and make available +several end-user applications and tools. The goal is to improve +the accessibility of the technology to end-users while +demonstrating its effectiveness. Historical examples of such applications +include Surge and TinyDB. An important part of this effort is +good documentation for users who are not expert programmers, as well +as tools and graphical environments.

11. Conclusions

-

The time has come to create an organizational structure to allow the effort to grow -Beyond the Berkeley + Others -It is a balancing act -Stability vs Innovation -Broad Participation vs Strong Requirements -Uniform Licensing vs Institutional Differences -Goal is to help to community to work together -Not a forum for maneuvering and intrigue -Focus on consensus building and technical soundness -Minimal mechanism to resolve rare differences -Focus on working groups and individual contributions -with architectural and organization oversight -Be pragmatic on participation -Don’t have to make deep commitments to participate -Can’t expect broad guarantees in return

+

By focusing on consensus building and technical excellence, the +Alliance seeks to avoid being a forum for political and economic +positioning. It will achieve this by focusing on working groups +and the contributions of individuals, while not taking strong +positions on the benefits or drawbacks of different approaches. +The variety of application domains sensornets are used in and +the huge differences in requirements mean that having a suite +of solutions, rather than a single one, is often not only +desirable but essential.

+

Over the past five years, low-power embedded sensor networks have +grown from research prototypes to working systems that are being +actively deployed. Furthermore, there is a vibrant research community +that actively works to deploy these systems and collaborate with +industry, making advances quickly accessible and usable. A great +catalyst to this growth has been the presence of a large community +around a shared, free code base.

+

The time has come to create an organizational structure to +allow the effort to grow further. As sensornets become more widespread, +contributions and advancements will be from an increasingly broad +demographic of users, and bringing them all together will speed +progress and improve the potential benefit these systems can bring +to society. This focus on bringing disparate groups together lies +at the heart of the Alliance. Rather than depend on strong requirements, +it depends on broad collaboration and participation, placing a minimalist +set of expectations that will encourage the exchange of ideas and +technology.

12. Author's Address

Philippe Bonnet <bonnet.p@gmail.com>
David Culler <culler@cs.berkeley.edu>
+
David Culler <dculler at archrock.com>,
Deborah Estrin <destrin@cs.ucla.edu>
Ramesh Govindan <ramesh@usc.edu>
Mike Horton <mhorton@xbow.com>
@@ -847,9 +878,6 @@ Can’t expect broad guarantees in return

Matt Welsh <mdw@cs.harvard.edu>
Adam Wolisz <awo@ieee.org>
-
-
David Culler <dculler at archrock.com>,
-
diff --git a/doc/html/tep123.html b/doc/html/tep123.html index 4ff751b4..997d719f 100644 --- a/doc/html/tep123.html +++ b/doc/html/tep123.html @@ -303,9 +303,9 @@ ul.auto-toc { Rodrigo Fonseca, Omprakash Gnawali, Kyle Jamieson, Sukun Kim, Philip Levis, and Alec Woo Draft-Created:3-Aug-2006 -Draft-Version:1.2 +Draft-Version:1.1.2.3 -Draft-Modified:2006-09-08 +Draft-Modified:2006-10-25 Draft-Discuss:TinyOS Developer List <tinyos-devel at mail.millennium.berkeley.edu> @@ -418,14 +418,14 @@ to do so.

Field definitions are as follows:

    -
  • C: Congestion notification. If a node is receiving packets faster than it can forward them, it MAY set the C field to notify other nodes. If a node hears a packet from node N with the C bit set, it MUST NOT transmit CTP data frames to N until it hears a packet from N with the C bit cleared.
  • -
  • P: Routing pull. The P bit allows nodes to request routing information from other nodes. If a node hears a packet with the P bit set, it SHOULD transmit a routing frame in the near future if it has a valid route.
  • +
  • C: Congestion notification. If a node is receiving packets faster than it can forward them, it MAY set the C field to notify other nodes. If a node hears a packet from node N with the C bit set, it MUST NOT transmit CTP data frames to N until it hears a packet from N with the C bit cleared.
  • +
  • P: Routing pull. The P bit allows nodes to request routing information from other nodes. If a node with a valid route hears a packet with the P bit set, it SHOULD transmit a routing frame in the near future.
  • THL: Time Has Lived. When a node generates a CTP data frame, it MUST set THL to 0. When a node receives a CTP data frame, it MUST increment the THL. If a node receives a THL of 255, it increments it to 0.
  • ETX: The ETX routing metric of the single-hop sender. When a node transmits a CTP data frame, it MUST put the ETX value of its route through the single-hop destination in the ETX field. If a node receives a packet with a lower gradient than its own, then it MUST schedule a routing frame in the near future.
  • origin: The originating address of the packet. A node forwarding a data frame MUST NOT modify the origin field.
  • seqno: Origin sequence number. The originating node sets this field, and a node forwarding a data frame MUST NOT modify it.
  • collect_id: Higher-level protocol identifier. The origin sets this field, and a node forwarding a data frame MUST NOT modify it.
  • -
  • data: the data payload, of zero or more bytes.
  • +
  • data: the data payload, of zero or more bytes. A node forwarding a data frame MUST NOT modify the data payload.

Together, the origin, seqno and collect_id fields denote a unique @@ -434,9 +434,9 @@ THL denote a unique *packet instance* within the network. The distinction is important for duplicate suppression in the presence of routing loops. If a node suppresses origin packets, then if asked to forward the same packet twice due to a routing loop, it will -drop the packet. However, if it suppresses packet instances, then -unless the THL has wrapped around to the identical value it had -on previous times around.

+drop the packet. However, if it suppresses packet instances, then it +will route succesfully in the presence of transient loops unless the +THL happens to wrap around to a forwarded packet instance.

A node MUST send CTP data frames as unicast messages with link-layer acknowledgments enabled.

@@ -473,6 +473,79 @@ below its own. When a parent hears a child advertise an ETX below its own, it MUST schedule a routing frame for transmission in the near future.

+
+

6. Implementation

+

An implementation of CTP can be found in the tos/lib/net/ctp directory +of TinyOS 2.0. This section describes the structure of that implementation +and is not in any way part of the specification of CTP.

+

This implementation has three major subcomponents:

+

1) A link estimator, which is responsible for estimating the +single-hop ETX of communication with single-hop neighbors.

+

2) A routing engine, which uses link estimates as well as +network-level information to decide which neighbor is the next +routing hop.

+

3) A forwarding engine, which maintains a queue of packets +to send. It decides when and if to send them. The name is a little +misleading: the forwarding engine is responsible for forwarded traffic +as well as traffic generated on the node.

+
+

6.1 Link Estimation

+

The link estimator estimates the ETX to single-hop neighbors. +The implementation uses two mechanisms to estimate the quality of a link: +periodic broadcast packets and data packets. The estimator itself +only generates broadcast packets. For data traffic, it depends on +other components telling it about acknowledged and unacknowledged +transmissions.

+

The periodic broadcast packets have sequence numbers, which the +estimator uses to estimate the sender-to-receiver packet reception +rate (PRR). The data payload of periodic broadcast packets contain +these estimates. Therefore, when node A receives a link estimation +broadcast message from node B, it can use the packet header to +estimate the B-to-A PRR and the packet payload to update B's +estimate of the A-to-B PRR.

+

Multiplying these two values gives a bidirectional PRR, or +an estimate of the probability that if A transmits a packet to B, +B will successfully hear and acknowledge the packet and A will +hear the acknowledgment. The inverse of the bidirecitonal PRR +is the ETX.

+

CTP link estimation adapts its beaconing rate to be slow when +its routing table is stable and faster when changes occur. +It adjusts the beaconing interval using an algorithm similar +to the trickle dissemination protocol[2_]. CTP sends beacons +more often when one of three conditions occurs:

+
+
    +
  1. The routing table is empty (this also sets the P bit)
  2. +
  3. The node's routing ETX increases by >= 1 trasmission
  4. +
  5. The node hears a packet with the P bit set
  6. +
+
+

CTP also estimates link quality using data transmissions. This +is a direct measure of ETX. Whenever the data path transmits a +packet, it tells the link estimator the destimation and whether +it was successfully acknowledged. The estimator produces an ETX +estimate every 5 such transmissions, where 0 successes has an +ETX of 6.

+

The estimator combines the beacon and data estimates by incorporating +them into an exponentially weighted moving average. Beacon-based +estimates seed the neighbor table. The expectation is that the low +beacon rate in a stable network means that for a selected route, +data estimates will outweigh beacon estimates. Additionally, as +the rate at which CTP collects data estimates is proportional to +the transmission rate, then it can quickly detect a broken link and +switch to another candidate neighbor.

+
+ +
+
+

Docutils System Messages

+
+

System Message: ERROR/3 (txt/tep123.txt, line 232); backlink

+Unknown target name: "2".
+
diff --git a/doc/html/tep3.html b/doc/html/tep3.html index 7153aad8..a5f6123a 100644 --- a/doc/html/tep3.html +++ b/doc/html/tep3.html @@ -303,9 +303,9 @@ ul.auto-toc { Ion Yannopoulos, David Gay Draft-Created:31-Dec-2004 -Draft-Version:1.2 +Draft-Version:1.1.2.3 -Draft-Modified:2006-07-12 +Draft-Modified:2006-01-16 Draft-Discuss:TinyOS Developer List <tinyos-devel at mail.millennium.berkeley.edu> diff --git a/doc/html/upgrade-tinyos.html b/doc/html/upgrade-tinyos.html index 0ef16dff..50fbfaa9 100644 --- a/doc/html/upgrade-tinyos.html +++ b/doc/html/upgrade-tinyos.html @@ -1,20 +1,15 @@ - +
Upgrading from TinyOS 1.x to TinyOS 2.x
+
Last updated 5 November 2006

- - -
Upgrading from TinyOS 1.x to TinyOS 2.x
-

This document describes how to upgrade your TinyOS 1.x environment to a TinyOS 2.x environment. This requires that you not only install the TinyOS 2.x rpm, but also that you upgrade your tools from the toolset @@ -37,9 +32,7 @@ There are 3 steps to upgrading from 1.x to 2.x:

  • Install the Tinyos 2.x source tree.
  • -
    - -

    1. Upgrade your external tools.

    +

    Step 1: Upgrade your external tools.

    The 1.2 toolset uses the same Java JDK and ATT Graphviz versions, so those do not need to be upgraded. What does need to be upgraded are your compiler tools. Install the appropriate version of the following @@ -149,8 +142,8 @@ distribution trees, but are linked below for convenience. -


    -

    2. Upgrade your TInyOS-specific tools.

    +

    +

    Step 2: Upgrade your TinyOS-specific tools.

    The TinyOS-specific tools are the NesC compiler and a set of tools developed in the tinyos-2.x/tools source code repository. They are @@ -161,14 +154,15 @@ Also, if you plan on maintaining a tinyos-1.x tree simultaneously with a tinyos-2.x tree, the tinyos-tools installed for the 1.x versions must remain installed so use rpm -ivh. If you are only installing a 2.x tree, you can use rpm -Uvh. -If you using the Cygwin version recommendedin these install +If you using the Cygwin version recommended +in these install instructions, you should install the "Recommended" Windows/Cygwin -nesC RPM (1.2.7b). If you install it and it does not work (e.g., you +nesC RPM. +Try installing it and if it does not work (e.g., you get strange errors when you try to execute it), this may be due -to a Cygwin version incompatibility: try the "Other" Windows/Cygwin +to a Cygwin version incompatibility: try the "Other" Windows/Cygwin RPM (1.2.7a). -

    @@ -184,24 +178,24 @@ RPM (1.2.7a). NesC - nesc-1.2.7b-1.cygwin.i386.rpm + nesc-1.2.7b-1.cygwin.i386.rpm nesc-1.2.7a-1.cygwin.i386.rpm nesc-1.2.7a-1.i386.rpm - rpm -Uvh + rpm -Uvh
    rpm -Uvh --ignoreos (if Cygwin complains) tinyos-tools - tinyos-tools-1.2.2-1.cygwin.i386.rpm - tinyos-tools-1.2.2-1.cygwin.i386.rpm - tinyos-tools-1.2.2-1.i386.rpm + tinyos-tools-1.2.2-1.cygwin.i386.rpm + tinyos-tools-1.2.2-1.cygwin.i386.rpm + tinyos-tools-1.2.2-1.i386.rpm rpm -ivh --force (1.x tree)
    rpm -Uvh (no 1.x tree)
    -


    -

    3. Install the TinyOS 2.x source tree.

    +

    +

    Step 3: Install the TinyOS 2.x source tree.

    Now that the tools are installed, you need only install the tinyos 2.x source tree and then set your environment variables. @@ -210,11 +204,21 @@ source tree and then set your environment variables.
  • Install tinyos-2.x

    -To preserve your old tinyos-1.x tree, we strongly recommend that you use + +

    If you have an existing 1.x tree, we strongly recommend that you use the install (-i) rpm argument when installing the tinyos-2.x rpm rather than the upgrade (-U) argument. The difference is that the -U will first remove the tinyos-1.x tree while -i will not remove previously installed -files. Said another way, we recommend using rpm -ivh. +files. Said another way, we recommend using rpm -ivh.

    + +

    If you have an existing 2.x tree which you want to keep unchanged, then +you will need to move it to make space for the new one. For example, if you +have an existing tree in /opt/tinyos-2.x/, then you can move it +to /opt/tinyos-2.x-old. Once you have moved it, we recommend +performing a forced installation of the 2.0 tree.

    + +

    If you have an existing 2.x tree which you do not care about, then we +recommend removing it before installing the new one with a forced install.

    TinyOS 2.x @@ -222,12 +226,17 @@ files. Said another way, we recommend using rpm -ivh. + - - + + +
    Windows/Cygwin LinuxCommand
    TinyOStinyos-2.0.0beta2-3.cygwin.noarch.rpmtinyos-2.0.0beta2-3.noarch.rpmtinyos-2.0.0-1.cygwin.noarch.rpmtinyos-2.0.0-1.noarch.rpmrpm -Uvh (to upgrade)
    + rpm -ivh (to install)
    + rpm -ivh --force (to force install)
    +
    @@ -308,8 +317,7 @@ groups:

  • -
    -

    Switching back to a TinyOS 1.x tree

    +

    Switching back to a TinyOS 1.x tree

    Since the tools are backwardly compatible, you need only change your environment variables to point to the 1.x settings. Assuming that your old tree was in /opt/tinyos-1.x, you would use the following @@ -347,4 +355,8 @@ values: -

    +

    + +

    Switching between the two should require switching only these environment +variables.

    + diff --git a/doc/index.html b/doc/index.html index dca149c7..e482e6cb 100644 --- a/doc/index.html +++ b/doc/index.html @@ -11,7 +11,7 @@ TinyOS 2.0 Documentation
    -
    Last Modified: Oct 31 2005
    +
    Last Modified: October 27 2006
    @@ -36,25 +36,30 @@
  • TinyOS 2.0 overview
  • TinyOS 2.0 install instructions
  • TinyOS 2.0 upgrade instructions (includes instructions for how to upgrade your tools for 2.0)
  • +
  • A brief set of notes on porting code from TinyOS 1.x to 2.0.
  • - Tutorials + Tutorials -

    TinyOS 2.0 has a few tutorials to get a new user started with programming +

    TinyOS 2.0 has a few tutorials to get a new user started with programming the system. These tutorials introduce nesC programming and some major TinyOS abstractions, such as timers and communication.

    -

    +

    Additionally, for more advanced programming, there is a + TinyOS Programming Manual. + The book describes nesC's features in greater detail, + including generic components, concurrency, and common + component design patterns.

    - TEPs and Source Code Documentation + TEPs @@ -64,7 +69,7 @@ different kinds of TEPs and their roles. TEPs 1-100 are BCP (Best Current Practice) TEPs, while TEPS 101+ are Informational, Documentary, or Experimental. Currently, - all TEPs are still Drafts: comments and feedback to the + many TEPs are Drafts: comments and feedback to the authors or the associated working group is welcome.

    @@ -80,31 +85,41 @@
  • TEP 107: Boot Sequence [HTML] [TXT]
  • TEP 108: Resource Arbitration [HTML] [TXT]
  • TEP 109: Sensorboards [HTML] [TXT]
  • -
  • TEP 110: Service Distributions [HTML] [TXT]
  • TEP 111: message_t [HTML] [TXT]
  • TEP 112: Microcontroller Power Management [HTML] [TXT]
  • TEP 113: Serial Communication [HTML] [TXT]
  • TEP 114: SIDs: Source and Sink Independent Drivers [HTML] [TXT]
  • TEP 115: Power Management of Non-Virtualized Devices [HTML] [TXT]
  • TEP 116: Packet Protocols [HTML] [TXT]
  • +
  • TEP 117: Low-Level I/O [HTML] [TXT]
  • +
  • TEP 118: Dissemination [HTML] [TXT]
  • +
  • TEP 119: Collection [HTML] [TXT]
  • +

    + + + + TinyOS Source Code Documentation + + +

    In addition to TEPs, which document the organization and design - behind important parts of TinyOS, there is also source code - documentation. TinyOS (nesC) code has nesdoc annotations, - which can be found here (note that this link is external):

    - - -

    - -

    + behind important parts of TinyOS, there is also source code + documentation.

    + + + + TinyOS Java toolchain Code Documentation + + + -

    There is similar javadoc documentation for the Java toolchain, - which can be found here:

    - - -

    +

    There is similar + javadoc documentation for the Java toolchain, + which describes the Java classes and their functionality. This documentation + is incomplete.

    diff --git a/doc/stylesheets/tinyos.css b/doc/stylesheets/tinyos.css index 0937e6b8..bb305d20 100644 --- a/doc/stylesheets/tinyos.css +++ b/doc/stylesheets/tinyos.css @@ -14,12 +14,12 @@ table { font-size: 14px; } a:link { - color: #d3595e; + color: #c3494e; text-decoration: none; font-weight: bold; } a:visited { - color: #404040; + color: #c3494e; text-decoration: none; font-weight: bold; } @@ -73,7 +73,7 @@ ul.links { .menu { width: 100%; - background-color: #c00000; + background-color: #d0d0d0; padding: .2em 1em .2em 1em; border: 0; margin: 0; @@ -101,7 +101,7 @@ ul.links { width: 100%; margin: 0 0 0 0; border: 0 0 0 0; - background-color: #a0a0a0; + background-color: #d0d0d0; color: #000000; } @@ -111,17 +111,17 @@ ul.links { border: 0 0 0 0; padding: .2em .2em .2em .2em; text-align: left; - background-color: #e0e0c0; + background-color: #d0d0d0; } .title { - background-color: grey; + background-color: #d0d0d0; font-family: Helvetica, sans-serif; font-size: x-large; font-weight: bold; } .subtitle { - background-color: grey; + background-color: #d0d0d0; font-family: Helvetica, sans-serif; font-weight: normal; font-size: medium; diff --git a/doc/txt/overview.txt b/doc/txt/overview.txt index 73e5dcc7..c8616f4e 100644 --- a/doc/txt/overview.txt +++ b/doc/txt/overview.txt @@ -3,7 +3,7 @@ TinyOS 2.0 Overview ============================ :Author: Philip Levis -:Date: Feb 8 2006 +:Date: Oct 30 2006 .. Note:: @@ -81,7 +81,7 @@ a full active message communication layer. The HAA is described in TEP 2: Hardware Abstraction Architecture[TEP2_]. -Currently (as of the 2.0 beta2 release in July 2006), TinyOS 2.0 supports +Currently (as of the 2.0 release in November 2006), TinyOS 2.0 supports the following platforms: * eyesIFXv2 @@ -94,7 +94,7 @@ the following platforms: * btnode3 -The btnode3 platform is not included in the beta2 RPM. +The btnode3 platform is not included in the RPM. 3. Scheduler ==================================================================== @@ -241,7 +241,12 @@ each one will receive its fair share of transmission opportunities. Further information on message_t can be found in TEP 111: message_t[TEP111_], while further information on AM can be -found in TEP 116: Packet Protocoks[TEP116_]. +found in TEP 116: Packet Protocols[TEP116_]. + +The current TinyOS release has a low-power stack for the CC1000 +radio (mica2 platform) and an experimental low-power stack for +the CC2420 radio (micaz, telosb, and intelmote2 platforms). + 8. Sensors ==================================================================== @@ -326,6 +331,17 @@ TEP 115: Power Management of Non-Virtualised Devices{TEP115_], is handled through resource abiters. Fully virtualized services have their own, individual power management policies. +TinyOS 2.0 provides low-power stacks for the CC1000 (mica2) +and CC2420 (micaz, telosb, imote2) radios. Both use a low-power +listening apporach, where transmitters send long preambles or +repeatedly send packets and receivers wake up periodically to +sense the channel to hear if there is a packet being +transmitted. The low-power stack CC1000 is standard, while +the CC2420 stack is experimental. That is, the default CC1000 +stack (chips/cc1000) has low-power-listening, while the default +CC2420 stack (chips/cc2420) does not. To use the low-power CC2420 +stack, you must include chips/cc2420_lpl in your application Makefile. + 12. Network Protocols ==================================================================== @@ -335,9 +351,12 @@ and collection. Dissemination reliably delivers small (fewer than 20 byte) data items to every node in a network, while collection builds a routing tree rooted at a sink node. Together, these two protocols enable a wide range of data collection -applications. +applications. Collection has advanced significantly since the +most recent beta release; experimental tests in multiple +network conditions have seen very high (>98%) deliver rates +as long as the network is not saturated. -12. Conclusion +13. Conclusion ==================================================================== TinyOS 2.0 represents the next step of TinyOS development. Building on @@ -348,7 +367,7 @@ still under active development: future prereleases will include non-volatile storage, basic multihop protocols (collection routing, dissemination), and further power management abstractions. -13. Acknowledgments +14. Acknowledgments ==================================================================== TinyOS 2.0 is the result of a lot of hard work from a lot of people, @@ -358,10 +377,10 @@ Prabal Dutta, Gilman Tolle, Martin Turon, Phil Buonodonna, Ben Greenstein, David Culler, Kristin Wright, Ion Yannopoulos, Henri Dubois-Ferriere, Jan Beutel, Robert Szewczyk, Rodrigo Fonseca, Kyle Jamieson, Omprakash Gnawali, -and Kristin Wright. +David Moss, and Kristin Wright. -14. Author's Address +15. Author's Address ==================================================================== | Philip Levis @@ -374,7 +393,7 @@ and Kristin Wright. | | email - pal@cs.stanford.edu -15. Citations +16. Citations ==================================================================== .. [TEP1] TEP 1: TEP Structure and Keywords. http://tinyos.cvs.sourceforge.net/*checkout*/tinyos/tinyos-2.x/doc/html/tep1.html?pathrev=tinyos-2_0_devel-BRANCH diff --git a/doc/txt/tep1.txt b/doc/txt/tep1.txt index ea35a2b0..a2fee1bc 100644 --- a/doc/txt/tep1.txt +++ b/doc/txt/tep1.txt @@ -160,10 +160,28 @@ describe systems that do not have a reference implementation. The fourth field is "Status," which specifies the status of the TEP. A TEP status can either be "Draft," which means it is a work in -progress, "Final," which means it is complete and will not change, or -"Obsolete," which means it should no longer be considered. If a TEP is -"Obsolete" because it has been replaced by another TEP, then the new -TEP number should follow "Obsolete," such as "Obsolete by TEP 1231." +progress, "Final," which means it is complete and will not change. +Once a TEP has the status "Final," its body MUST NOT change. +The values of its header fields MUST NOT change. The header of a +Final TEP MAY have an "Obsoleted By" field added. + +The "Obsoletes" field is a backward pointer to an earlier TEP which +the current TEP renders obsolete. An Obsoletes field MAY have multiple +TEPs listed. For example, if TEP 191 were to replace TEPs 111 and 116, it +would have the field "Obsoletes: 111, 116". + +The "Obsoleted By" field is added to a Final TEP when another TEP has +rendered it obsolete. The field contains the number of the obsoleting +TEP. For example, if TEP 111 were obsoleted by TEP 191, it would have +the field "Obsoleted By: 191". + +"Obsoletes" and "Obsoleted By" fields MUST agree. For a TEP to list another +TEP in its Obsoletes field, then that TEP MUST list it in the Obsoleted By +field. + +The obsoletion fields are used to keep track of evolutions and modifications +of a single abstraction. They are not intended to force a single approach or +mechanism over alternative possibilities. If a TEP is Best Current Practices or Documentary, then it MUST include an additional field, "TinyOS-Version:," which states what @@ -171,10 +189,16 @@ version(s) of TinyOS the document pertains to. This document pertains to all versions of TinyOS, until made obsolete by a future TEP. This field MUST appear after the Status field and before the Author field. -The final required field is Author, which states the names of the +The final required field is "Author," which states the names of the authors of the document. Full contact information should not be listed here (see Section 3.2). +There is an optional field, "Extends." The "Extends" field refers to +another TEP. The purpose of this field is to denote when a TEP represents +an addition to an existing TEP. Meeting the requirements of a TEP with an +Extends field requires also meeting the requirements of all TEPs listed +in the Extends field. + If a TEP is a Draft, then four additional fields MUST be included: Draft-Created, Draft-Modified, Draft-Version, and Draft-Discuss. Draft-Created states the date the document was created, Draft-Modified diff --git a/doc/txt/tep101.txt b/doc/txt/tep101.txt index 2c0d1c7a..8ef78389 100644 --- a/doc/txt/tep101.txt +++ b/doc/txt/tep101.txt @@ -25,11 +25,10 @@ Analog-to-Digital Converters (ADCs) Abstract ==================================================================== -This TEP proposes a hardware abstraction for TinyOS 2.x analog-to-digital -converters (ADCs). It focuses on aligning the ADC abstraction with the -three-layer Hardware Abstraction Architecture (HAA) described in [TEP2]_, but -addresses only the HPL and HAL, because the highest level abstraction of an -ADC is platform-dependent. +This TEP proposes a hardware abstraction for analog-to-digital converters (ADCs) +in TinyOS 2.x, which is aligned to the three-layer Hardware Abstraction +Architecture (HAA) specified in [TEP2]. It describes some design principles and +documents the set of hardware-independent interfaces to an ADC. 1. Introduction ==================================================================== @@ -42,14 +41,14 @@ TinyOS, the distinction between a sensor and an ADC were blurred: this led components that had nothing to do with an ADC to still resemble one programatically, even though the semantics and forms of operation were completely different. To compensate for the difference non-ADC sensors -introduced additional interfaces, such as ADCError, that were tightly bound to -sensor acquisition but separate in wiring. The separation between the ADC and -ADCError interface is bug prone and problematic, as is the equation of a +introduced additional interfaces, such as ``ADCError``, that were tightly bound +to sensor acquisition but separate in wiring. The separation between the ADC and +``ADCError`` interface is bug prone and problematic, as is the equation of a sensor and an ADC. TinyOS 2.x separates the structure and interfaces of an ADC from those of sensors (which may be on top of an ADC, but this fact is hidden -from higher level components). This TEP presents how TinyOS 2.x decomposes and -structures ADC software. TEP 109 (Sensor Boards) shows how a platform can -present actual named sensors [TEP109]_. +from higher level components). This TEP presents how TinyOS 2.x structures ADC +software. TEP 109 (Sensor Boards) shows how a platform can present actual named +sensors [TEP109]_. As can be seen in Appendix A the ADC hardware used on TinyOS platforms differ in many respects, which makes it difficult to find a chip independent @@ -58,286 +57,366 @@ configuration details of an ADC would still depend on the actual device producing the input signal (sensor). Neither a platform independent application nor the ADC hardware stack itself has access to this information, as it can only be determined on a platform or sensorboard level. For example, -determining which ADC port a sensor is attached to and how a conversion result -is to be interpreted is a platform-specific determination. +determining which ADC port a sensor is attached to and how conversion results +need to be interpreted is a platform specific determination. Although the +actual configuration details may be different the procedure of configuring an +ADC can be unified on all ADCs with the help of **hardware independent +interfaces**: in a similar way as the ``Read`` interface definition does not +predefine the type or semantics of the exchanged data (see [TEP114]_), a +configuration interface definition can abstract from the data type and +semantics of the involved configuration settings. For example, like a +component can provide a ``Read`` or ``Read`` interface +depending on the data it can offer, a component can also use a +``AdcConfigure`` or +``AdcConfigure`` interface depending on what ADC +it represents. This TEP proposes the (typed) ``AdcConfigure`` interface as the +standard interface for configuring an ADC in TinyOS 2.x. In spite of their hardware differences, one aspect represents a common -denominator of all ADCs: they produce conversion results. In order to -facilitate sensor software development this capability can be made available -via chip-independent interfaces for every ADC. However, conversion results -depend on and have to be interpreted with respect to the platform-specific -configuration settings (the ADC channel, the applied reference voltage, etc.). -Therefore the highest level of ADC abstraction consists of -platform-independent interfaces for ADC data collection and chip-specific -interfaces for ADC hardware configuration. The top layer of the ADC stack -thus remains platform-dependent and consequently the ADC abstraction does not -include an HIL, but ends with the HAL. Following the principles of the -HAA [TEP2]_ the HAL of an ADC should also expose the chip-specific capabilities -for ADC data collection. For example, the ADC12 on the MSP430 MCU supports a -complex repeat conversion mode for a set of different input channels, which is -too specific to be represented by a platform-independent data collection -interface. Therefore the HAL of an ADC abstraction is broken into two -sublayers: The bottom HAL layer, called HAL1, exposes the full capabilities of -the respective ADC in a chip-specific way. It realizes the standard HAL in the -HAA [TEP2]_ and the HPL lies below it. On top of the HAL1 sits the HAL2 which -maps the interfaces it uses from HAL1 to a set of platform-independent -interfaces for data collection and chip-specific configuration interfaces. +denominator of all ADCs: they produce conversion results. To facilitate sensor +software development conversion results are returned by the ADC hardware stack +using the standard TinyOS interfaces ``Read``, ``ReadNow`` and ``ReadStream`` +(see `2. Interfaces`_ and [TEP114]_). Conversion results are returned as +uninterpreted values and translating them to engineering units can only be done +with the configuration knowledge of the respective platform, for example, the +reference voltage or the resistance of a reference resistor in ratiometric +measurements. Translating uninterpreted values to engineering units is +performed by components located on top of the ADC hardware stack and out of the +scope of this TEP. + +The top layer of abstraction of an ADC - the Hardware Interface Layer (HIL) - +thus provides the standard TinyOS interfaces ``Read``, ``ReadNow`` and +``ReadStream`` and uses the ``AdcConfigure`` interface for hardware +configuration (why it **uses** and does not **provide** ``AdcConfigure`` is +explained below). Since the type and semantics of the parameters passed +through these interfaces is dependent on the actual ADC implementation, it is +only a "weak" HIL (see [TEP2]_). + +Following the principles of the HAA [TEP2]_ the Hardware Adaptation Layer (HAL, +which resides below the HIL) of an ADC should expose all the chip-specific +capabilities of the chip. For example, the ADC12 on the MSP430 MCU supports a +"Repeat-Sequence-of-Channels Mode" and therefore this function should be +accessible on the HAL of the **MSP430 ADC12** hardware abstraction. Other ADCs +might not exhibit such functionality and might therefore - on the level of HAL +- provide only an interface to perform single conversions. Since all ADCs have +the same HIL representation it may thus be necessary to perform some degree of +software emulation in the HIL implementation. For example, a ``ReadStream`` +command can be emulated by multiple single conversion commands. Below the HAL +resides the Hardware Presentation Layer (HPL), a stateless component that +provides access to the hardware registers (see [TEP2]_). The general structure +(without virtualization) of the ADC hardware stack is as follows :: + + + ^ | + | | + | Read, + AdcConfigure ReadNow (+ Resource), + | ReadStream + | | + | V + +----------------------------------+ + | Hardware Interface Layer (HIL) | + | (chip-specific implementation) | + +----------------------------------+ + | + | + chip-specific interface(s) + Resource + (e.g. Msp430Adc12SingleChannel + Resource) + | + V + +----------------------------------+ + | Hardware Adaptation Layer (HAL) | + | (chip-specific implementation) | + +----------------------------------+ + | + | + chip-specific interface(s) + (e.g. HplAdc12) + | + V + +----------------------------------+ + | Hardware Presentation Layer (HPL)| + | (chip-specific implementation) | + +----------------------------------+ -The rest of this TEP specifies: -* the set of platform-independent interfaces for the collection of ADC - conversion results (`2. Interfaces`_) -* guidelines on how an ADC's HAL should be split into HAL1 and HAL2 and - how the HAL1 should expose chip-specific interfaces (`3. HAL1 guidelines`_) -* what components an ADC's HAL2 MUST implement (`4. HAL2 requirements`_) -* guidelines on how the HAL2 may be structured (`5. HAL2 implementation guidelines`_) -* a section pointing to the current implementation (`6. Implementation`_) +The rest of this TEP specifies: +* the set of standard TinyOS interfaces for collecting ADC conversion + results and for configuring an ADC (`2. Interfaces`_) +* guidelines on how an ADC's HAL should expose chip-specific + interfaces (`3. HAL guidelines`_) +* what components an ADC's HIL MUST implement (`4. HIL requirements`_) +* guidelines on how the HIL should be implemented + (`5. HIL guidelines`_) +* a section pointing to current implementations (`6. Implementation`_) -This TEP ends with appendices documenting, as an example, the ADC -implementation for the TI MSP430 MCU. +This TEP ends with appendices documenting, as an example, the ADC implementation +for the TI MSP430 MCU. 2. Interfaces ==================================================================== -This TEP proposes to adopt the following three generic, source-independent -data collection interfaces from [TEP114]_ for the collection of ADC conversion -results:: +This TEP proposes the ``AdcConfigure`` interface for ADC hardware configuration +and the ``Read``, ``ReadNow`` and ``ReadStream`` interfaces to acquire +conversion results. A ``Read[Now|Stream]`` interface is always provided in +conjunction with a ``AdcConfigure`` interface. + +Interface for configuring the ADC hardware +-------------------------------------------------------------------- + +The ``AdcConfigure`` interface is defined as follows:: + + interface AdcConfigure< config_type > + { + async command config_type getConfiguration(); + } + +This interface is used by the ADC implementation to retrieve the hardware +configuration of an ADC client. ``config_type`` is a chip-specific data type +(simple or structured) that contains all information necessary to configure the +respective ADC hardware. For example, on the ADC12 of the MSP430 the +``AdcConfigure`` interface will be instantiated with the ``const +msp430adc12_channel_config_t*`` data type. A client MUST always return the same +configuration through a ``AdcConfigure`` interface and, if configuration data +is passed as a pointer, the HIL component (see `4. HIL requirements`_) MUST NOT +reference it after the return of the ``getConfiguration()`` command. If a +client wants to use the ADC with different configurations it must provide +multiple instances of the ``AdcConfigure`` interface. + + +Interfaces for acquiring conversion results +-------------------------------------------------------------------- + +This TEP proposes to adopt the following three generic, source-independent data +collection interfaces from [TEP114]_ for the collection of ADC conversion +results on the level of HIL:: interface Read< size_type > interface ReadNow< size_type > interface ReadStream< size_type > -Every data collection interface is associated with certain chip-specific -configuration data (e.g. input channel, sample-hold-time, etc.). How this -association can be realized is explained in Section `4. HAL2 requirements`_. -As the resolution of conversion results is chip-specific, the 'size_type' -parameter reflects an upper bound for the chip-specific resolution of the -conversion results - the actual resolution may be smaller, depending on the -ADC and/or data source (e.g. uint16_t for a 12-bit ADC). The above interfaces -are specified in [TEP114]_, in the following their usage is explained with -respect to ADCs. +Every data collection interface is associated with an ``AdcConfigure`` +interface (how this association is realized is explained in Section `4. HIL +requirements`_). As the resolution of conversion results is chip-specific, the +``size_type`` parameter reflects an upper bound for the chip-specific +resolution of the conversion results - the actual resolution may be smaller +(e.g. uint16_t for a 12-bit ADC). The above interfaces are specified in +[TEP114]_, in the following their usage is explained with respect to ADCs. Read --------------------------------------------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The Read interface can be used to sample an ADC channel and return a single -conversion result. It provides no guarantees about when exactly the sampling -occurs (the request may be buffered). +The ``Read`` interface can be used to sample an ADC channel and return a single +conversion result as an uninterpreted value. The meaning of the ``Read`` +interface is explained in [TEP114]_. ReadNow --------------------------------------------------------------------- - -The ReadNow interface provides more precise control over the time of the -sampling: If a call to ReadNow.read() succeeds, the ADC starts to sample the -channel immediately (the request is not buffered). Due to its timing -constraints the ReadNow interface is always provided in conjunction with an -instance of the Resource interface. Refer to [TEP108]_ on how the 'Resource' +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The ``ReadNow`` interface is similar to the ``Read`` interface. The difference +is that if a call to ``ReadNow.read()`` succeeds, the ADC starts to sample the +channel immediately (precisely: when ``SUCCESS`` is returned the hardware has +started the sampling process). Due to its timing constraints the ``ReadNow`` +interface is always provided in conjunction with an instance of the +``Resource`` interface (a client must reserve the ADC before the client may +call ``ReadNow.read()``). Please refer to [TEP108]_ on how the ``Resource`` interface should be used by a client component. - ReadStream --------------------------------------------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The ReadStream interface can be used to sample an ADC channel multiple times -with a specified sampling period. It provides no guarantees about when exactly -the first sampling occurs, but all subsequent samplings occur with the -specified sampling period. +The ``ReadStream`` interface can be used to sample an ADC channel multiple times +with a specified sampling period. The meaning of the ``ReadStream`` interface +is explained in [TEP114]_ . -3. HAL1 guidelines +3. HAL guidelines ==================================================================== -As explained in `1. Introduction`_ the HAL of an ADC abstraction consists of -two sublayers, HAL1 and HAL2. In the ADC component stack the HAL1 resides -below HAL2 and above the HPL. It exposes the full capabilities of the ADC in a -chip-specific way and has the same function as the 'traditional' HAL in the -HAA [TEP2]_. Therefore only chip- and platform-dependent clients MAY wire to -the HAL1. Although the HAL1 is chip-specific, both, in terms of implementation +As explained in `1. Introduction`_ the HAL exposes the full capabilities of the +ADC hardware. Therefore only chip- and platform-dependent clients can wire to +the HAL. Although the HAL is chip-specific, both, in terms of implementation and representation, its design should follow the guidelines described below to -facilitate the mapping to platform-independent interfaces on the level of -HAL2. Appendix B shows the HAL1 specification for the TI MSP430 MCU. +facilitate the mapping to the HIL representation. Appendix B shows the +signature of the HAL for the MSP430. Resource reservation -------------------------------------------------------------------- -As the ADC hardware is a shared resource that is multiplexed between several -clients, it requires access arbitration. Therefore the HAL1 configuration -component should provide a parameterized 'Resource' interface, instantiate a -generic arbiter component and connect the 'Resource' interface to the arbiter -as described in [TEP108]_. To ensure fair and uniform arbitration on all -platforms the standard round robin arbiter is recommended. Refer to [TEP108]_ -on how the 'Resource' interface is to be used by a client wiring to HAL1. +As the ADC hardware is a shared resource that is usually multiplexed between +several clients some form of access arbitration is necessary. The HAL should +therefore provide a parameterized ``Resource`` interface, instantiate a +standard arbiter component and connect the ``Resource`` interface to the +arbiter as described in [TEP108]_. To ensure fair and uniform arbitration on +all platforms the standard round robin arbiter is recommended. Resource +arbiters and the ``Resource`` interface are the topic of [TEP108]_. Configuration and sampling -------------------------------------------------------------------- -As the ADC hardware is a shared resource the HAL1 should support hardware -configuration and sampling on a per-client basis (although per-port -configuration is possible, it is not recommended, because it forces all -clients to use the same settings for a given port). Therefore an HAL1 should -provide sampling interfaces parameterized by a client identifier. An HAL1 -client can use its instance of the sampling interface to configure the ADC -hardware, start the sampling process and get conversion results. It wires to a -sampling interface using a unique client identifier. All commands and events -in the sampling interface should be 'async' to reflect the potential timing -requirements of clients. An HAL1 may provide multiple different parameterized -sampling interfaces, depending on the hardware capabilities. This allows to +As the ADC hardware is a shared resource the HAL should support hardware +configuration and sampling per client (although per-port configuration is +possible, it is not recommended, because it forces all clients to use the same +configuration for a given port). Therefore the HAL should provide sampling +interfaces parameterized by a client identifier. A HAL client can use its +instance of the sampling interface to configure the ADC hardware, start the +sampling process and acquire conversion results. It wires to a sampling +interface using a unique client identifier (this may be hidden by a +virtualization component). All commands and events in the sampling interface +should be 'async' to reflect the potential timing requirements of clients on +the level of HAL. A HAL may provide multiple different parameterized sampling +interfaces, depending on the hardware capabilities. This allows to differentiate/group ADC functionality, for example single vs. repeated -sampling, single channel vs. multiple channels or low-frequency vs. +sampling, single channel vs. multiple channels or low-frequency vs. high-frequency sampling. Every sampling interface should allow the client to individually configure the ADC hardware, for example by including the configuration data as parameters in the sampling commands. However, if -configuration data is passed as a pointer, the HAL1 component MUST NOT -reference it after the return of the respective command. Appendix B shows the -HAL1 interfaces for the TI MSP430 MCU. +configuration data is passed as a pointer, the HAL component MUST NOT reference +it after the return of the respective command. Appendix B shows the HAL +interfaces for the MSP430. -HAL1 virtualization +HAL virtualization -------------------------------------------------------------------- In order to hide wiring complexities and/or export only a subset of all ADC -functions generic ADC wrapper components may be provided on the level of HAL1 -to be instantiated by chip- and platform-dependent clients. +functions generic ADC wrapper components may be provided on the level of HAL. +Such components can also be used to ensure that a sampling interface is always +provided with a ``Resource`` interface and both are instantiated with the same +client ID if this is required by the HAL implementation. -4. HAL2 requirements +4. HIL requirements ==================================================================== -The following components MUST be provided on all platforms that have an ADC:: +The following generic components MUST be provided on all platforms that have an +ADC:: - AdcReadClient - AdcReadNowClient - AdcReadStreamClient + AdcReadClientC + AdcReadNowClientC + AdcReadStreamClientC -These generic components are instantiated and provide access to the ADC on a -per-client basis via a platform-independent interface for data collection and -a chip-specific ADC configuration interface. This section describes the -representation of the HAL2. Guidelines on how the HAL2 can be implemented are -discussed in Section `5. HAL2 implementation guidelines`_. Appendix C shows -the AdcReadClient for the TI MSP430 MCU. +These components provide virtualized access to the HIL of an ADC. They are +instantiated by an ADC client and provide/use the four interfaces described in +Section `2. Interfaces`_. An ADC client may instantiate multiple such +components. The following paragraphs describe their signatures. Note that this +TEP does not address the issue of how to deal with multiple ADCs on the same +platform (the question of how to deal with multiple devices of the same class +is a general one in TinyOS 2.x). Appendix C shows the ``AdcReadClientC`` for +the MSP430. -The fact that the components use chip-specific ADC configuration interfaces -(see below) and the fact that the provided interfaces for data-collection must -be interpreted with respect to the configuration data - for example the -reference voltage - makes the HAL2 representation chip dependent. Therefore -the ADC abstraction does not include an HIL. -AdcReadClient +AdcReadClientC -------------------------------------------------------------------- :: - generic configuration AdcReadClient() { + generic configuration AdcReadClientC() { provides { interface Read< size_type >; } uses { - // chip-dependent configuration interface + interface AdcConfigure< config_type >; } } -The AdcReadClient provides platform-independent access for data collection via -the 'Read' interface. The actual ADC channel (port) and further configuration -details are determined by a chip-dependent configuration interface. It is the -task of the client to wire this interface to a component that provides its ADC -configuration. The HAL2 implementation will use this interface to "pull" the -client's ADC settings when it translates the 'Read.read()' command to a -chip-specific sampling command. The resolution of the conversion result is -chip-specific, the 'size_type' parameter represents an upper bound for the -resolution of the conversion results. - -AdcReadNowClient +The ``AdcReadClientC`` component provides a ``Read`` interface for acquiring +single conversion results. The associated ADC channel (port) and further +configuration details are returned by the ``AdcConfigure.getConfiguration()`` +command. It is the task of the client to wire this interface to a component +that provides the client's ADC configuration. The HIL implementation will use +the ``AdcConfigure`` interface to dynamically "pull" the client's ADC settings +when it translates the ``Read.read()`` command to a chip-specific sampling +command. Note that both, ``size_type`` and ``config_type``, are only +placeholders and will be instantiated by the respective HIL implementation (for +an example, see the AdcReadClientC for the MSP430 in Appendix C). + +AdcReadNowClientC -------------------------------------------------------------------- :: - generic configuration AdcReadNowClient() { + generic configuration AdcReadNowClientC() { provides { interface Resource; interface ReadNow< size_type >; } uses { - // chip-dependent configuration interface + interface AdcConfigure< config_type >; } } -The AdcReadNowClient provides platform-independent access for data collection -via the 'ReadNow' and 'Resource' interface. The actual ADC channel (port) and -further configuration details are determined by a chip-dependent configuration -interface. It is the task of the client to wire this interface to a component -that provides its ADC configuration. The HAL2 implementation will use this -interface to "pull" the client's ADC settings when it translates the -'ReadNow.read()' command to a chip-specific sampling command. A client MUST -use the 'Resource' interface to request access to the ADC as described in -[TEP108]_ (the HAL2 implementation SHOULD return the error code 'ERESERVE' if -the client has not reserved access). The resolution of the conversion result -is chip-specific, the 'size_type' parameter represents an upper bound for the -resolution of the conversion result. - -AdcReadStreamClient +The ``AdcReadNowClientC`` component provides a ``ReadNow`` interface for +acquiring single conversion results. In contrast to ``Read.read()`` when a call +to ``ReadNow.read()`` succeeds, the ADC starts to sample the channel +immediately (a successful ``Read.read()`` command may not have this +implication, see [TEP114]_ and `2. Interfaces`_). A client MUST reserve the ADC +through the ``Resource`` interface before the client may call +``ReadNow.read()`` and it must release the ADC through the ``Resource`` +interface when it no longer needs to access it (for more details on the +``Resource`` interface please refer to [TEP108]_). The associated ADC channel +(port) and further configuration details are returned by the +``AdcConfigure.getConfiguration()`` command. It is the task of the client to +wire this interface to a component that provides the client's ADC +configuration. The HIL implementation will use the ``AdcConfigure`` interface +to dynamically "pull" the client's ADC settings when it translates the +``ReadNow.read()`` command to a chip-specific sampling command. Note that both, +``size_type`` and ``config_type``, are only placeholders and will be +instantiated by the respective HIL implementation (for an example how this is +done for the AdcReadClientC see Appendix C). + +AdcReadStreamClientC -------------------------------------------------------------------- :: - generic configuration AdcReadStreamClient() { + generic configuration AdcReadStreamClientC() { provides { interface ReadStream< size_type >; } uses { - // chip-dependent configuration interface + interface AdcConfigure< config_type>; } } -The AdcReadStreamClient provides platform-independent access for data -collection via the 'ReadStream' interface. The actual ADC channel (port) and -further configuration details are determined by a chip-dependent configuration -interface. It is the task of the client to wire this interface to a component -that provides its ADC configuration. The HAL2 implementation will use this -interface to "pull" the client's ADC settings when it translates the -'ReadStream.read()' command to a chip-specific sampling command. The -resolution of the conversion results is chip-specific, the 'size_type' -parameter represents an upper bound for the resolution of the conversion -results. - -5. HAL2 implementation guidelines +The ``AdcReadStreamClientC`` component provides a ``ReadStream`` interface for +acquiring multiple conversion results at once. The ``ReadStream`` interface is +explained in [TEP114]_ and `2. Interfaces`_. The ``AdcConfigure`` interface is +used in the same way as described in the section on the ``AdcReadClientC``. +Note that both, ``size_type`` and ``config_type``, are only placeholders and +will be instantiated by the respective HIL implementation (for an example how +this is done for the AdcReadClientC see Appendix C). + +5. HIL guidelines ==================================================================== -The HAL2 implementation of an ADC stack has two main tasks: It translates a -platform-independent HAL2 request (from the 'Read', 'ReadNow' or 'ReadStream' -interface) to a chip-specific HAL1 sampling command and it abstracts from the -'Resource' interface. The first task cannot be solved in a chip-independent -way, because it involves chip-specific configuration data. The second task MAY -be performed by the following library components: ArbitratedReadC, and -ArbitratedReadStreamC (in tinyos-2.x/tos/system) - refer to the Atmel Atmega -128 HAL2 implementation (in tinyos-2.x/tos/chips/atm128/adc), for an example. -Note that since the 'ReadNow' interface is always provided in conjunction with -a 'Resource' interface the HAL2 implementation does not have to perform the -ADC resource reservation in this case, but can simply forward an instance of -the 'Resource' interface from the HAL1 (to AdcReadNowClient). - -To support multiple ADC clients the HAL2 implementation should provide -parameterized 'Read', 'ReadNow' and 'ReadStream' interfaces as well as a -parameterized chip-specific configuration interface. It should also use an -instance of the 'Resource' interface (provided by the HAL1) per provided -'Read' and 'ReadStream' interface to perform automatic resource reservation. -The HAL2 representation ('AdcReadClient', 'AdcReadNowClient' and -'AdcReadStreamClient') should ensure the correct wiring between the HAL1 and -HAL2. - -From the perspective of the HAL2 the typical sequence of events is as follows: -After a client has requested data via the 'Read' or 'ReadStream' interface the -HAL2 will request access to the HAL1 via the 'Resource' interface, e.g. using -the library components mentioned above. When it is signalled the 'granted' -event, the HAL2 will 'pull' the client's ADC settings and translate the -client's command to a chip-specific HAL1 sampling command. Once it is -signalled the conversion result(s) it releases the ADC via the 'Resource' -interface and forwards the conversion result(s) to the client. When a client -has requested data via the 'ReadNow' interface the HAL2 translates the -client's command to the chip-specific HAL1 sampling command without using the -'Resource' interface (it may check ownership of the client via the -'ArbiterInfo' interface). In order to reduce state in the HAL2 and facilitate -the mapping between used and provided interfaces the 'AdcReadClient', -'AdcReadNowClient' and 'AdcReadStreamClient' should use the same interface -identifier when it connects the HAL2 to HAL1 (see, for example, the MSP430 -ADC12 implementation in Appendix C). +The HIL implementation of an ADC stack has two main tasks: it translates a +``Read``, ``ReadNow`` or ``ReadStream`` request to a chip-specific HAL sampling +command and it abstracts from the ``Resource`` interface (the latter only for +the ``AdcReadClientC`` and ``AdcReadStreamClientC``). The first task is solved +with the help of the ``AdcConfigure`` interface which is used by the HIL +implementation to retrieve a client's ADC configuration. The second task MAY +be performed by the following library components: ``ArbitratedReadC``, and +``ArbitratedReadStreamC`` (in tinyos-2.x/tos/system) - please refer to the +Atmel Atmega 128 HAL implementation (in tinyos-2.x/tos/chips/atm128/adc) for an +example. Note that since the ``ReadNow`` interface is always provided in +conjunction with a ``Resource`` interface the HIL implementation does not have +to perform the ADC resource reservation for an ``AdcReadNowClientC``, but may +simply forward an instance of the ``Resource`` interface from the HAL to the +``AdcReadNowClientC``. + +The typical sequence of events is as follows: when a client requests data +through the ``Read`` or ``ReadStream`` interface the HIL will request access to +the HAL using the ``Resource`` interface. After the HIL has been granted +access, it will "pull" the client's ADC configuration using the +``AdcConfigure`` interface and translate the client's ``Read`` or +``ReadStream`` command to a chip-specific HAL command. Once the HIL is +signalled the conversion result(s) from the HAL it releases the ADC through the +``Resource`` interface and signals the conversion result(s) to the client +though the ``Read`` or ``ReadStream`` interface. When a client requests data +through the ``ReadNow`` interface the HIL translates the client's command to +the chip-specific HAL command without using the ``Resource`` interface (it may +check ownership of the client through the ``ArbiterInfo`` interface - this +check can also be done in the HAL implementation). Once the HIL is signalled +the conversion result(s) it forwards it to the respective ``ReadNow`` client. 6. Implementation ==================================================================== @@ -346,28 +425,24 @@ The implementation of the ADC12 stack on the MSP430 can be found in ``tinyos-2.x/tos/chips/msp430/adc12``: * ``HplAdc12P.nc`` is the HPL implementation - * ``Msp430Adc12P.nc`` is the HAL1 implementation - * ``AdcC.nc`` is the HAL2 implementation + * ``Msp430Adc12P.nc`` is the HAL implementation + * ``AdcP.nc`` is the HIL implementation * ``AdcReadClientC.nc``, ``AdcReadNowClientC.nc`` and - ``AdcReadStreamClientC.nc`` provide access to the ADC on a per-client - basis via the interfaces 'Read', 'ReadNow' and 'ReadStream', - respectively, and the msp430-specific ADC configuration - interface ``Msp430Adc12Config.nc`` + ``AdcReadStreamClientC.nc`` provide virtualized access to the HIL + * the use of DMA or the reference voltage generator and the + HAL virtualization components are explained in ``README.txt`` The Atmel Atmega 128 ADC implementation can be found in ``tinyos-2.x/tos/chips/atm128/adc``: * ``HplAtm128AdcC.nc`` is the HPL implementation - * ``Atm128AdcP.nc`` is the HAL1 implementation + * ``Atm128AdcP.nc`` is the HAL implementation * ``WireAdcP.nc`` and the library components for arbitrating 'Read', 'ReadNow' and 'ReadStream', ``ArbitratedReadC`` and ``ArbitratedReadStreamC`` (in ``tinyos-2.x/tos/system``), realize - the HAL2 + the HAL * ``AdcReadClientC.nc``, ``AdcReadNowClientC.nc`` and - ``AdcReadStreamClientC.nc`` provide access to the ADC on a per-client - basis via the platform-independent interfaces 'Read', 'ReadNow' and - 'ReadStream', respectively, and the atmega-specific ADC configuration - interface ``Atm128AdcConfig.nc`` + ``AdcReadStreamClientC.nc`` provide virtualized access to the HIL Appendix A: Hardware differences between platforms @@ -436,78 +511,62 @@ commonly used in TinyOS platforms: +----------------------+----------------------+---------------------+ -Appendix B: an HAL1 representation: MSP430 ADC12 +Appendix B: a HAL representation: MSP430 ADC12 ==================================================================== -The following shows the HAL1 representation for the ADC12 of the TI MSP430 -MCU. It reflects the four MSP430 ADC12 conversion modes as it lets a client -sample an ADC channel once ("Single-channel-single-conversion") or repeatedly +This section shows the HAL signature for the ADC12 of the TI MSP430 MCU. It +reflects the four MSP430 ADC12 conversion modes as it lets a client sample an +ADC channel once ("Single-channel-single-conversion") or repeatedly ("Repeat-single-channel"), multiple times ("Sequence-of-channels") or multiple times repeatedly ("Repeat-sequence-of-channels"). In contrast to the single channel conversion modes the sequence conversion modes trigger a single -interrupt after multiple samples and thus enable high-frequency sampling (a -sequence conversion mode for multiple different channels is not (yet) -implemented).:: +interrupt after multiple samples and thus enable high-frequency sampling. The +``DMAExtension`` interface is used to reset the state machine when the DMA is +responsible for data transfer (managed in an exterior component):: - configuration Msp430Adc12C + configuration Msp430Adc12P { - provides interface Resource[uint8_t id]; - provides interface Msp430Adc12SingleChannel as SingleChannel[uint8_t id]; - } + provides { + interface Resource[uint8_t id]; + interface Msp430Adc12SingleChannel as SingleChannel[uint8_t id]; + interface AsyncStdControl as DMAExtension[uint8_t id]; + } + } interface Msp430Adc12SingleChannel { - async command error_t getSingleData(const msp430adc12_channel_config_t *config); - async command error_t getSingleDataRepeat(const msp430adc12_channel_config_t *config, - uint16_t jiffies); - async command error_t getMultipleData( const msp430adc12_channel_config_t *config, - uint16_t *buffer, uint16_t numSamples, uint16_t jiffies); - async command error_t getMultipleDataRepeat(const msp430adc12_channel_config_t *config, - uint16_t *buffer, uint8_t numSamples, uint16_t jiffies); + async command error_t configureSingle(const msp430adc12_channel_config_t *config); + async command error_t configureSingleRepeat(const msp430adc12_channel_config_t *config, uint16_t jiffies); + async command error_t configureMultiple( const msp430adc12_channel_config_t *config, uint16_t buffer[], uint16_t numSamples, uint16_t jiffies); + async command error_t configureMultipleRepeat(const msp430adc12_channel_config_t *config, uint16_t buffer[], uint8_t numSamples, uint16_t jiffies); + async command error_t getData(); async event error_t singleDataReady(uint16_t data); - async event uint16_t* multipleDataReady(uint16_t *buffer, uint16_t - numSamples); + async event uint16_t* multipleDataReady(uint16_t buffer[], uint16_t numSamples); } -There exist two wrapper components, Msp430Adc12ClientC and -Msp430Adc12RefVoltAutoClientC, which SHOULD be used to eliminate wiring -errors. + typedef struct { + unsigned int inch: 4; // input channel + unsigned int sref: 3; // reference voltage + unsigned int ref2_5v: 1; // reference voltage level + unsigned int adc12ssel: 2; // clock source sample-hold-time + unsigned int adc12div: 3; // clock divider sample-hold-time + unsigned int sht: 4; // sample-hold-time + unsigned int sampcon_ssel: 2; // clock source sampcon signal + unsigned int sampcon_id: 2; // clock divider sampcon signal + } msp430adc12_channel_config_t; -Appendix C: an HAL2 representation: MSP430 ADC12 + +Appendix C: a HIL representation: MSP430 ADC12 ==================================================================== -The AdcReadClientC component for the MSP430 ADC12 is implemented as follows: -:: +The signature of the AdcReadClientC component for the MSP430 ADC12 is as +follows:: generic configuration AdcReadClientC() { provides interface Read; - uses interface Msp430Adc12Config; - } implementation { - components AdcC; - #ifdef REF_VOLT_AUTO_CONFIGURE - components new Msp430Adc12RefVoltAutoClientC() as Msp430AdcClient; - #else - components new Msp430Adc12ClientC() as Msp430AdcClient; - #endif - - enum { - CLIENT = unique(ADCC_SERVICE), - }; - - Read = AdcC.Read[CLIENT]; - Msp430Adc12Config = AdcC.Config[CLIENT]; - AdcC.SingleChannel[CLIENT] -> Msp430AdcClient.Msp430Adc12SingleChannel; - AdcC.Resource[CLIENT] -> Msp430AdcClient.Resource; - #ifdef REF_VOLT_AUTO_CONFIGURE - Msp430Adc12Config = Msp430AdcClient.Msp430Adc12Config; - #endif + uses interface AdcConfigure; } -Note that the same CLIENT identifier is used for all involved interfaces to -facilitate the mapping between the HAL2 and HAL1 interfaces. The conditional -compile directive REF_VOLT_AUTO_CONFIGURE can be used to automatically enable -the internal reference voltage generator during the sampling process. - .. [TEP1] TEP 1: TEP Structure and Keywords. .. [TEP2] TEP 2: Hardware Abstraction Architecture. .. [TEP108] TEP 108: Resource Arbitration. diff --git a/doc/txt/tep102.txt b/doc/txt/tep102.txt index 8c1c1dcc..1a2c6e41 100644 --- a/doc/txt/tep102.txt +++ b/doc/txt/tep102.txt @@ -78,11 +78,11 @@ Three fundamental properties of timers are *precision*, *width* and *accuracy*. Examples of precision are millisecond, a cycle of a 32kHz clock, and -microseconds. All precisions are in "binary" units with respect to -one second. That is, one second contains 1024 binary milliseconds, -32768 32kHz ticks, or 1048576 microseconds. This TEP emphasizes -millisecond and 32kHz tick precisions while reasonably accommodating -other precisions. +microseconds. All precisions presented in this TEP are in "binary" +units with respect to one second. That is, one second contains 1024 +binary milliseconds, 32768 32kHz ticks, or 1048576 microseconds. +This TEP emphasizes millisecond and 32kHz tick precisions while +reasonably accommodating other precisions. Examples of widths are 8-bit, 16-bit, 32-bit, and 64-bit. The width for timer interfaces and components SHOULD be 32-bits. That is, for @@ -112,9 +112,9 @@ reflected in the interface type. Precision is expressed as an empty type -- TMilli, T32khz, and TMicro -- written in the standard Timer.h header like this:: - typedef struct { } TMilli; - typedef struct { } T32khz; - typedef struct { } TMicro; + typedef struct { } TMilli; // 1024 ticks per second + typedef struct { } T32khz; // 32768 ticks per second + typedef struct { } TMicro; // 1048576 ticks per second Note that the precision names are expressed as either frequency or period, whichever is convenient. @@ -159,11 +159,15 @@ get() return the current time. isOverflowPending() - return TRUE if an overflow interrupt will occur after the outermost - atomic block is exits. FALSE otherwise. + return TRUE if the overflow flag is set for this counter, i.e., if and + only if an overflow interrupt will occur after the outermost atomic + block exits. Return FALSE otherwise. This command only returns the + state of the overflow flag and causes no side effect. It is expected + that the underlying hardware platform sets the overflow flag when + appropriate. clearOverflow() - cancel the pending overflow interrupt. + cancel the pending overflow interrupt clearing the overflow flag. overflow() signals that an overflow in the current time. That is, the current @@ -174,7 +178,7 @@ Alarm -------------------------------------------------------------------- Alarm components are extensions of Counters that signal an event -when their Compare register detects the alarm time has been hit. +when their compare register detects the alarm time has been hit. All commands and events of the Alarm interface are asynchronous (or in "interrupt context"). The Alarm interface provides a set of "basic" commands for common usage and provides a set of "extended" @@ -210,26 +214,37 @@ isRunning() or has not yet fired. FALSE is returned otherwise. startAt(t0,dt) + cancel any previously running alarm and set to fire at time t1 = - t0+dt. This form allows a delay to be anchored to some time t0 - taken before the invocation of start. This is also the form used - internally in the timer subsystem to allow the use of the full width - of an alarm while being able to detect if the alarm time for a short - alarm prematurely elapsed. + t0+dt. This form allows a delay to be anchored to some time t0 taken + before the invocation of startAt. The timer subsystem uses this form + internally, to be able to use of the full width of an alarm while also + detecting when a short alarm elapses prematurely. getNow() return the current time in the precision and width of the alarm. getAlarm() return the time the currently running alarm will fire or the time - that the previously running alarm was set to fire. + that the previously running alarm was set to fire. getAlarm can + be used with startAt to set an alarm from the previous alarm time, + as in startAt(getAlarm(),dt). This pattern is used within the + fired() event to construct periodic alarms. BusyWait -------------------------------------------------------------------- -The BusyWait interface replaces the TOSH_uwait macro from TinyOS -1.x. :: +The BusyWait interface allows for very short synchronous delays. +BusyWait should be used sparingly and when an Alarm would not be +reasonably efficient or accurate. The BusyWait interface replaces +the TOSH_uwait macro from TinyOS 1.x. + +BusyWait blocks for no less than the specified amount of time. No +explicit upper bound is imposed on the enacted delay, though it is +expected the underlying implementation spins in a busy loop until +the specified amount of time has elapsed. +:: interface BusyWait { @@ -237,7 +252,7 @@ The BusyWait interface replaces the TOSH_uwait macro from TinyOS } wait(dt) - block for no less than the specified amount of time. + block until at least dt time units have elapsed LocalTime -------------------------------------------------------------------- @@ -330,71 +345,76 @@ getdt() 3. HAL guidelines ==================================================================== -Platforms typically select a clocking option for each of their -hardware counters, based on their hardware design (e.g., the mica -family of motes all run their hardware timer 0 at 32kHz, and the micaz -mote runs its timer 1 at cpu frequency/256). Platforms SHOULD expose -the timing functionality of these timers using the Alarm and Counter -interfaces, in the fashion described below. Platforms MAY expose the -same hardware timer with different frequencies - use of conflicting -frequences in the same program SHOULD produce compile-time -errors. - - -A hardware timer with precision *P* and width *W* SHOULD be exposed as -several components:: - - configuration CounterPWC { - provides interface Counter; - } ... - generic configuration AlarmPWC { - provides interface Alarm; - } ... +Platforms SHOULD expose their relevant timing capabilities using +standard Alarm and Counter interfaces. The design pattern presented +here defines a component naming convention to allow platform +independent access to particular Alarms and Counters if they exist +and to cause compile errors if they do not. -and, except if *W* is 32:: +A platform specific hardware timer with precision ${P} and width +${W} SHOULD be exposed as these two conventional Counter and Alarm +components:: - configuration CounterP32C { - provides interface Counter; - } ... - generic configuration AlarmP32C { - provides interface Alarm; - } ... + configuration Counter${P}${W}C + { + provides interface Counter< T${P}, uint${W}_t >; + } -Instantiating the Alarm... components provides a new Alarm independent -of all prior instantiations. Instantiating such a component "consumes" -a compare register from the corresponding hardware timer; when no more -compare registers are available, instantiation SHOULD produce a -compile-time error (see Appendix B for an example of how to achieve -this). + generic configuration Alarm${P}${W}C() + { + provides interface Alarm< T${P}, uint${W}_t >; + } + +Instantiating an Alarm${P}${W}C component provides a new and +independent Alarm. If the platform presents a limited number of +Alarm resources, then allocating more Alarms in an application than +are available for the platform SHOULD produce a compile-time error. +See Appendix B for an example of how to make allocatable Alarms that +are each implemented on independent hardware timers. + +For example, if a platform has an 8-bit 32kHz counter and three +8-bit 32kHz alarms, then the Counter and Alarm interfaces for +${P}=32khz and ${W}=16 are:: + + configuration Counter32khz8C + { + provides interface Counter< T32khz, uint8_t >; + } + + generic configuration Alarm32khz8C() + { + provides interface Alarm< T32khz, uint8_t >; + } + +This pattern MAY be used to defined components for the platform that +are mutually incompatible in single application. Incompatible +components SHOULD produce compile-time errors when compiled +together. -For example, the micaz platform includes an AlarmMilli8C and -AlarmMilli32C components for timer 0 (one instantiation allowed), and -Alarm32kHz16C and Alarm32kHz32C for timer 1 (three instantiations -allowed). 4. HIL requirements ==================================================================== The following component MUST be provided on all platforms:: - TimerMilliC + HilTimerMilliC BusyWaitMicroC -TimerMilliC +HilTimerMilliC -------------------------------------------------------------------- :: - #define TIMERMILLIC_SERVICE ... - configuration TimerMilliC + configuration HilTimerMilliC { provides interface Init; - provides interface Timer[uint8_t num]; - provides interface LocalTime; + provides interface Timer as TimerMilli[ uint8_t num ]; } -A timer is allocated using unique(TIMERMILLIC_SERVICE) to obtain a new -unique timer number. This timer number is used to index the TimerMilli -parameterised interface. +A new timer is allocated using unique(UQ_TIMER_MILLI) to obtain a +new unique timer number. This timer number is used to index the +TimerMilli parameterised interface. UQ_TIMER_MILLI is defined in +Timer.h. HilTimerMilliC is used by the generic component +TimerMilliC found in ``tos/system/``. BusyWaitMicroC -------------------------------------------------------------------- @@ -495,6 +515,11 @@ created:: new TransformAlarmC( TMilli, uint32_t, T32khz, uint16_t, 5 ) +It is the exclusive responsibility of the developer using +TransformAlarmC to ensure that all five of its arguments are self +consistent. No compile errors are generated if the parameters +passed to TransformAlarmC are inconsistent. + TransformCounterC -------------------------------------------------------------------- @@ -543,13 +568,79 @@ timers. :: uses interface Timer as TimerFrom; } -6. Author's Address +6. Implementation +==================================================================== + +The definition of the HIL interfaces are found in ``tinyos-2.x/tos/lib/timer``: + + * ``Alarm.nc`` + * ``BusyWait.nc`` + * ``Counter.nc`` + * ``LocalTime.nc`` + * ``Timer.h`` defines precision tags and strings for unique() + * ``Timer.nc`` + +The implementation of the utility components are also found in +``tinyos-2.x/tos/lib/timer``: + + * ``AlarmToTimerC.nc`` + * ``BusyWaitCounterC.nc`` + * ``CounterToLocalTimeC.nc`` + * ``TransformAlarmC.nc`` + * ``TransformAlarmCounterC.nc`` + * ``TransformCounterC.nc`` + * ``VirtualizeAlarmC.nc`` + * ``VirtualizeTimerC.nc`` + +The implementation of Timers for the MSP430 is in +``tinyos-2.x/tos/chips/msp430/timer``: + + * ``Alarm32khz16C.nc`` is generic and provides a new ``Alarm`` + * ``Alarm32khz32C.nc`` is generic and provides a new ``Alarm`` + * ``AlarmMilli16C.nc`` is generic and provides a new ``Alarm`` + * ``AlarmMilli32C.nc`` is generic and provides a new ``Alarm`` + * ``BusyWait32khzC.nc`` provides ``BusyWait`` + * ``BusyWaitMicroC.nc`` provides ``BusyWait`` + * ``Counter32khz16C.nc`` provides ``Counter`` + * ``Counter32khz32C.nc`` provides ``Counter`` + * ``CounterMilli16C.nc`` provides ``Counter`` + * ``CounterMilli32C.nc`` provides ``Counter`` + * ``GpioCaptureC.nc`` + * ``HilTimerMilliC.nc`` provides ``Timer as TimerMilli[uint8_t num]`` + * ``Msp430AlarmC.nc`` is generic and converts an MSP430 timer to a 16-bit Alarm + * ``Msp430Capture.nc`` HPL interface definition for MSP430 timer captures + * ``Msp430ClockC.nc`` exposes MSP430 hardware clock initialization + * ``Msp430ClockInit.nc`` HPL interface definition for hardware clock initialization + * ``Msp430ClockP.nc`` implements MSP430 hardware clock initialization and + calibration and startup + * ``Msp430Compare.nc`` HPL interface definition for MSP430 timer compares + * ``Msp430Counter32khzC.nc`` provides ``Counter`` based on + MSP430 TimerB + * ``Msp430CounterC.nc`` is generic and converts an Msp430Timer to a Counter + * ``Msp430CounterMicroC.nc`` provides ``Counter`` based on + MSP430 TimerA + * ``Msp430Timer.h`` defines additional MSP430 timer bitmasks and structs + * ``Msp430Timer.nc`` HPL interface definition + * ``Msp430Timer32khzC.nc`` is generic and allocates a new 32khz hardware timer + * ``Msp430Timer32khzMapC.nc`` exposes the MSP430 hardware timers as a + parameterized interface allocatable using Msp430Timer32khzC + * ``Msp430TimerC.nc`` exposes the MSP430 hardware timers + * ``Msp430TimerCapComP.nc`` is generic and implements the HPL for MSP430 + capture/compare special function registers + * ``Msp430TimerCommonP.nc`` maps the MSP430 timer interrupts to Msp430TimerEvents + * ``Msp430TimerControl.nc`` HPL interface definition + * ``Msp430TimerEvent.nc`` HPL interface definition + * ``Msp430TimerP.nc`` is generic and implements the HPL for MSP430 timer + special function registers + +7. Author's Address ==================================================================== | Cory Sharp | Moteiv Corporation | 55 Hawthorne St, Suite 550 | San Francisco, CA 94105 | +| phone - +1 415 692 0963 | email - cory@moteiv.com | | diff --git a/doc/txt/tep103.txt b/doc/txt/tep103.txt index d5aaee13..d90ad7fe 100644 --- a/doc/txt/tep103.txt +++ b/doc/txt/tep103.txt @@ -3,18 +3,12 @@ Permanent Data Storage (Flash) ============================================== :TEP: 103 -:Group: Core Working Group +:Group: Core Working Group :Type: Documentary -:Status: Draft +:Status: Final :TinyOS-Version: 2.x :Author: David Gay, Jonathan Hui -:Draft-Created: 27-Sep-2004 -:Draft-Version: $Revision$ -:Draft-Modified: $Date$ -:Draft-Discuss: TinyOS Developer List - - .. Note:: This memo documents a part of TinyOS for the TinyOS Community, and @@ -32,39 +26,41 @@ HAL layers of various flash chips. 1. Introduction ==================================================================== -Flash chips are a form of EEPROM (electrically-eraseable, programmable +Flash chips are a form of EEPROM (electrically-erasable, programmable read-only memory), distinguished by a fast erase capability. However, erases can only be done in large units (from 256B to 128kB depending on the flash chip). Erases are the only way to switch bits from 0 to 1, and programming operations can only switch 1's to 0's. Additionally, some chips require that programming only happen once between each erase, -or that it be in relatively large units (e.g., 256B). +or that it be in relatively large units (e.g., 256B). In the table below, we summarise these differences by categorising flash chips by their underlying technology (NOR vs NAND). We also include a column for Atmel's AT45DB flash chip family, as it has -significantly different tradeoffs than other flash chips: :: - - - NOR AT45DB NAND - (ex: ST M25P40, (ex: Samsung - Intel PXA27x) K9K1G08R0B) - - Erase : Slow (seconds) Fast (ms) Fast (ms) - Erase unit : Large (64KB-128KB) Small (256B) Medium (8KB-32KB) - Writes : Slow (100s kB/s) Slow (60kB/s) Fast (MBs/s) - Write unit : 1 bit 256B 100's of bytes - Bit-errors : Low Low High (requires ECC, - bad-block mapping) - Read : Bus limited* Slow+Bus limited Bus limited - Erase cycles : 10^4 - 10^5 10^4 ** 10^5 - 10^7 - Intended use : Code storage Data storage Data storage - Energy/byte : 1uJ 1uJ .01uJ - - * M25P40 reads are limited by the use of a 25MHz SPI bus. The PXA27x flash is - memory mapped (reads are very fast and can directly execute code). - ** Or infinite? Data sheet just says that every page within a sector - must be written every 10^4 writes within that sector +significantly different tradeoffs than other flash chips: + + + ============= ================== ================= =================== + X NOR AT45DB NAND + (ex: ST M25P40, (ex: Samsung + Intel PXA27x) K9K1G08R0B) + ============= ================== ================= =================== + Erase Slow (seconds) Fast (ms) Fast (ms) + Erase unit Large (64KB-128KB) Small (256B) Medium (8KB-32KB) + Writes Slow (100s kB/s) Slow (60kB/s) Fast (MBs/s) + Write unit 1 bit 256B 100's of bytes + Bit-errors Low Low High (requires ECC, + bad-block mapping) + Read Bus limited [*]_ Slow+Bus limited Bus limited + Erase cycles 10^4 - 10^5 10^4 [*]_ 10^5 - 10^7 + Intended use Code storage Data storage Data storage + Energy/byte 1uJ 1uJ .01uJ + ============= ================== ================= =================== + +.. [*] M25P40 reads are limited by the use of a 25MHz SPI bus. The PXA27x flash + is memory mapped (reads are very fast and can directly execute code). +.. [*] Or infinite? Data sheet just says that every page within a sector + must be written every 10^4 writes within that sector The energy/byte is the per-byte cost of erasing plus programming. It is derived from the timing and power consumption of erase and write operations @@ -92,7 +88,7 @@ three components listed above are supported on these chips: - ``ByteEEPROMC`` allows arbitrary rewrites of sections of the flash. This is not readily implementable on a flash chip with large erase units. - The ``Matchbox`` implementation was AT45DB-specific. It was not - reimplemented for these other chips, in part because it does not + reimplemented for these other chips, in part because it does not support some applications (e.g., network reprogramming) very well. 2. Storage in TinyOS 2.x @@ -107,7 +103,7 @@ this approach has several drawbacks: in a free, open-source operating system. - To support arbitrary block writes where blocks are smaller than the erase unit, and to deal with the limited number of erase cycles/block - requires remapping blocks. We believe that maintaining this remapping + requires remapping blocks. We believe that maintaining this remapping table is too expensive on many mote-class devices. A second approach is to provide a generic low-level interface providing @@ -117,7 +113,7 @@ operations, along with information describing the flash chip's layout we believe that the large differences between NAND and NOR flash (see the table above), in particular the differences in reliability, write and erase units, make the design of a useful generic low-level interface -tricky at best. +tricky at best. We thus believe it is best, for now at least, to define high-level storage abstractions that are useful for sensor network applications, @@ -137,7 +133,7 @@ storage abstraction (the abstraction defines the format). We prefer the use of single abstractions over fixed-size volumes over the use of a more general filing system (like Matchbox) for several reasons: - + - TinyOS is currently targeted at running a single application, and many applications know their storage needs in advance: for instance, a little space for configuration data, and everything else for a log of @@ -152,7 +148,7 @@ reasons: "wear levelling" (ensuring that each block of the flash is erased the same number of time, to maximise flash chip lifetime). -New abstractions (including a filing system...) can easily be added to +New abstractions (including a filing system) can easily be added to this framework. The rest of this TEP covers some principles for the organisation of @@ -166,7 +162,7 @@ storage abstractions in detail (Section 4). The flash chip architecture follows the three-layer Hardware Abstraction Architecture (HAA), with each chip providing a presentation layer (HPL, Section 3.1), adaptation layer (HAL, Section 3.2) and -platform-independent interface layer (HIL, Section 3.3) [2_]. +platform-independent interface layer (HIL, Section 3.3) [2_]. The implementation of these layers SHOULD be found in the ``tos/chips/CHIPNAME`` directory. If a flash chip is part of a larger family with a similar interface, the HAA SHOULD support all family members @@ -181,13 +177,13 @@ and ST M25P chip families. The flash HPL has a chip-dependent, platform-independent interface. The implementation of this HPL is platform-dependent. The flash HPL SHOULD be -stateless. +stateless. To remain platform independent, a flash chip's HPL SHOULD connect to platform-specific components providing access to the flash chip; these components SHOULD be placed in the ``tos/platforms/PLATFORM/chips/CHIPNAME`` -directory. If the flash chip implementation supports a family of +directory. If the flash chip implementation supports a family of flash chips, this directory MAY also contain a file describing the particular flash chip found on the platform. @@ -205,16 +201,18 @@ abstractions that interact cleanly with the rest of the flash system. 3.3 Hardware Interface Layer (HIL) -------------------------------------------------------------------- -Each flash chip MUST provide implementations of the storage abstractions -described in Section 4. These abstractions MUST be presented in +Each flash chip MUST support at least one of the storage abstractions +described in Section 4. These abstractions SHOULD be presented in components named ``ChipAbstractionC``, e.g., ``At45dbLogStorageC``. +Additionally, a flash chip implementation MAY support platforms +with multiple instances of the same storage chip. The way in which +this is achieved is not specified further in this TEP. -Each platform MUST have ``AbstractionC`` components (e.g., ``LogStorageC``) -implementing the storage abstractions of Section 4. Platforms with a single -storage chip SHOULD simply make ``AbstractionC`` be a simple configuration -wrapping the appropriate ``ChipAbstractionC`` component. Platforms with -multiple storage chips SHOULD redirect uses of ``AbstractionC`` to the -appropriate storage chip, based on the requested volume. +Each platform MUST have ``AbstractionC`` components (e.g., +``LogStorageC``) implementing the storage abstractions of Section 4 +supported by its flash chip(s). On platforms with multiple storage chips +SHOULD redirect uses of ``AbstractionC`` to the appropriate storage +chip, based on the requested volume. 4. Non-Volatile Storage Abstractions =================================================================== @@ -249,11 +247,12 @@ directory. When not specified, the tool picks a suitable physical location for a volume. If there is any reason that the physical allocation cannot be satisfied, an error should be given at compile time. The tool SHOULD be named ``tos-storage-CHIPNAME`` and be distributed with the other -tools supporting a platform. +tools supporting a platform. The XML file SHOULD be named +``volumes-CHIPNAME.xml``. The compile-time tool MUST prepend 'VOLUME\_' to each volume name in the XML file and '#define' each resulting name to map to a unique -integer. +integer. The storage abstractions are accessed by instantiating generic components that take the volume macro as argument: :: @@ -269,22 +268,20 @@ A volume MUST NOT be used with more than one storage abstraction instance. 4.2 Large objects ------------------------------------------------------------------ -The motivating example for large objects is the transmission or long-term -storage of large pieces of data. For instance, programs in a network-reprogramming -system, or large data-packets in a reliable data-transmission system. Such -objects have two interesting characteristics: each byte in the object is -written at most once, and a full object is written in a single "session" -(i.e., without the mote rebooting). +The motivating example for large objects is the transmission or +long-term storage of large pieces of data. For instance, programs in a +network-reprogramming system, or large data-packets in a reliable +data-transmission system. Such objects have an interesting +characteristic: each byte in the object is written at most once. This leads to the definition of the ``BlockStorageC`` abstraction for storing -large objects: +large objects or other "write-once" objects: - A large object ranges from a few kilobytes upwards. - A large object is erased before the first write. -- A commit ensures that a large object survives a reboot or crash +- A sync ensures that a large object survives a reboot or crash - Reads are unrestricted -- Writes can only be performed between an erase and a commit -- Each byte can only be written once between an erase and a commit +- Each byte can only be written once between two erases Large objects are accessed by instantiating a BlockStorageC component which takes a volume id argument: :: @@ -296,23 +293,20 @@ which takes a volume id argument: :: } } ... -The ``BlockRead`` and ``BlockWrite`` interfaces contain the following -operations (all split-phase, except ``BlockRead.getSize``): +The ``BlockRead`` and ``BlockWrite`` interfaces (briefly presented in +Appendix B) contain the following operations (all split-phase, except +``BlockRead.getSize``): - ``BlockWrite.erase``: erase the volume. After a reboot or a commit, a volume MUST be erased before it can be written to. - ``BlockWrite.write``: write some bytes starting at a given - offset. Each byte MUST NOT be written more than once between an erase - and the subsequent commit. Writes MUST NOT be performed between a - commit and the subsequent erase. + offset. Each byte MUST NOT be written more than once between two erases. -- ``BlockWrite.commit``: commit all writes to a given volume. Writes - MUST NOT be performed after a commit until a subsequent erase. Commit - MUST be called to ensure written data survives a reboot or crash. -- ``BlockRead.verify``: verify that the volume contains the results of a - successful commit. +- ``BlockWrite.sync``: ensure all previous writes are present on a given + volume. Sync MUST be called to ensure written data survives a reboot + or crash. - ``BlockRead.read``: read some bytes starting at a given offset. @@ -325,6 +319,11 @@ operations (all split-phase, except ``BlockRead.getSize``): For full details on arguments and other considerations, see the comments in the interface definitions. +Note that these interfaces contain no direct support for verifying the +integrity of the BlockStorage data, but such support can easily be built +by using the ``computeCrc`` command and storing the result in a +well-defined location, and checking this CRC when desired. + 4.3 Logging ------------------------------------------------------------------ @@ -341,7 +340,7 @@ record based: each call to ``LogWrite.append`` (see below) creates a new record. On failure (crash or reboot), the log MUST only lose whole records from the end of the log. Additionally, once a circular log wraps around, calls to ``LogWrite.append`` MUST only lose whole records from -the beginning of the log. +the beginning of the log. Logs are accessed by instantiating a LogStorageC component which takes a volume id and a boolean argument: :: @@ -356,19 +355,20 @@ volume id and a boolean argument: :: If the ``circular`` argument is TRUE, the log is circular; otherwise it is linear. -The ``LogRead`` and ``LogWrite`` interfaces contain the following -operations (all split-phase except ``LogWrite.currentOffset``, -``LogRead.currentOffset`` and ``LogRead.getSize``): +The ``LogRead`` and ``LogWrite`` interfaces (briefly presented in +Appendix B) contain the following operations (all split-phase except +``LogWrite.currentOffset``, ``LogRead.currentOffset`` and +``LogRead.getSize``): - ``LogWrite.erase``: erase the log. A log MUST be erased (possibly in some previous session) before any other operation can be used. - ``LogWrite.append``: append some bytes to the log. In a circular log, - this may overwrite the current read position. In this case, the + this may overwrite the current read position. In this case, the read position MUST be advanced to the log's current beginning (i.e., as if ``LogRead.seek`` had been called with ``SEEK_BEGINNING``). Additionally, the ``LogWrite.appendDone`` event reports whenever, in a - circular log, an append erases old records. + circular log, an append MAY have erased old records. Each append creates a separate record. Log implementations may have a maximum record size; all implementations MUST support records of up @@ -397,7 +397,7 @@ operations (all split-phase except ``LogWrite.currentOffset``, - ``LogRead.seek``: set the read position to a value returned by a prior call to ``LogWrite.currentOffset`` or ``LogRead.currentOffset``, or to the special ``SEEK_BEGINNING`` value. In a circular log, if - the specified position has been overwritten, behave as if + the specified position has been overwritten, behave as if ``SEEK_BEGINNING`` was requested. ``SEEK_BEGINNING`` positions the read position at the beginning of @@ -450,12 +450,12 @@ which takes a volume id argument: :: } } ... -A small object MUST be mounted (via the ``Mount`` interface) before +A small object MUST be mounted (via the ``Mount`` interface) before the first use. -The ``Mount`` and ``ConfigStorage`` interfaces contain the following -operations (all split-phase except ``ConfigStorage.getSize`` and -``ConfigStorage.valid``): +The ``Mount`` and ``ConfigStorage`` interfaces (briefly presented in +Appendix B) contain the following operations (all split-phase except +``ConfigStorage.getSize`` and ``ConfigStorage.valid``): - ``Mount.mount``: mount the volume. @@ -519,7 +519,7 @@ Appendix A. HAA for some existing flash chips A.1 AT45DB ------------------------------------------------------------------ - + The Atmel AT45DB family HPL is: :: configuration HplAt45dbC { @@ -529,7 +529,7 @@ The Atmel AT45DB family HPL is: :: The ``HplAt45db`` interface has flash->buffer, buffer->flash, compare buffer to flash, erase page, read, compute CRC, and write operations. Most of these operations are asynchronous, i.e., their completion is signaled -before the flash chip has completed the operation. The HPL also includes +before the flash chip has completed the operation. The HPL also includes operations to wait for asynchronous operations to complete. A generic, system-independent implementation of the HPL @@ -560,7 +560,7 @@ providing volume information: :: Note that the AT45DB HAL resource management is independent of the underlying HPL's power management. The motivation for this is that individual flash operations may take a long time, so it may be desirable to -release the flash's bus during long-running operations. +release the flash's bus during long-running operations. The ``At45db`` interface abstracts from the low-level HPL operations by: @@ -577,7 +577,7 @@ map volume-relative pages to absolute pages. A.2 ST M25P ------------------------------------------------------------------ - + The ST M25P family HPL is: :: configuration Stm25pSpiC { @@ -610,3 +610,97 @@ erase. Additionally, it has operations to report volume size and remap volume-relative addresses. Clients of the ST M25P HAL must implement the ``getVolumeId`` event of the ``Stm25pVolume`` interface so that the HAL can obtain the volume id of each of its clients. + +Appendix B. Storage interfaces +==================================================================== + +These interfaces are presented briefly here for reference; please refer +to the TinyOS documentation for a full description of the commands, +events and their parameters. + +B.1 BlockStorage interfaces +------------------------------------------------------------------ + +The BlockStorage interfaces are: :: + + interface BlockRead { + command error_t read(storage_addr_t addr, void* buf, storage_len_t len); + event void readDone(storage_addr_t addr, void* buf, storage_len_t len, + error_t error); + + command error_t computeCrc(storage_addr_t addr, storage_len_t len, + uint16_t crc); + event void computeCrcDone(storage_addr_t addr, storage_len_t len, + uint16_t crc, error_t error); + + command storage_len_t getSize(); + } + + interface BlockWrite { + command error_t write(storage_addr_t addr, void* buf, storage_len_t len); + event void writeDone(storage_addr_t addr, void* buf, storage_len_t len, + error_t error); + + command error_t erase(); + event void eraseDone(error_t error); + + command error_t sync(); + event void syncDone(error_t error); + } + +B.2 ConfigStorage interfaces +------------------------------------------------------------------ + +The ConfigStorage interfaces are: :: + + interface Mount { + command error_t mount(); + event void mountDone(error_t error); + } + + interface ConfigStorage { + command error_t read(storage_addr_t addr, void* buf, storage_len_t len); + event void readDone(storage_addr_t addr, void* buf, storage_len_t len, + error_t error); + + command error_t write(storage_addr_t addr, void* buf, storage_len_t len); + event void writeDone(storage_addr_t addr, void* buf, storage_len_t len, + error_t error); + + command error_t commit(); + event void commitDone(error_t error); + + command storage_len_t getSize(); + command bool valid(); + } + +B.3 LogStorage interfaces +------------------------------------------------------------------ + +The LogStorage interfaces are: :: + + interface LogRead { + command error_t read(void* buf, storage_len_t len); + event void readDone(void* buf, storage_len_t len, error_t error); + + command storage_cookie_t currentOffset(); + + command error_t seek(storage_cookie_t offset); + event void seekDone(error_t error); + + command storage_len_t getSize(); + } + + interface LogWrite { + command error_t append(void* buf, storage_len_t len); + event void appendDone(void* buf, storage_len_t len, bool recordsLost, + error_t error); + + command storage_cookie_t currentOffset(); + + command error_t erase(); + event void eraseDone(error_t error); + + command error_t sync(); + event void syncDone(error_t error); + } diff --git a/doc/txt/tep109.txt b/doc/txt/tep109.txt index ba8809fc..12894aab 100644 --- a/doc/txt/tep109.txt +++ b/doc/txt/tep109.txt @@ -80,9 +80,11 @@ reflect the specifc name of the sensor, and optionally provide a component with a generic name for application authors who only care about the general class of the sensor. -This document assumes that sensors return uninterpreted values of -arbitrary size or datatype. Conversion of sensor values to something -with actual physical meaning is beyond the scope of this document. +This document takes no position on the meaning of the values returned +by sensor drivers. They may be raw uninterpreted values or they may +have some physical meaning. If a driver returns uninterpreted values, +the driver may provide additional interfaces that would allow +higher-level clients to interpret the value properly. 2. Sensor HIL Components ==================================================================== @@ -217,32 +219,7 @@ For example:: // connect to the sensor's platform-dependent HPL here } -4. Sensor HPL Components -==================================================================== - -A sensor HPL is necessarily platform-dependent or -sensorboard-dependent. These components should provide access to the -physical resources needed by the sensor, in a platform-independent -manner that can be used by the shared logic of the sensor HAL -components. In the case of bus-based sensors, this HPL may be nothing -more than wiring to the appropriate bus interface for use by the HAL -component. - -For example:: - - configuration HplSensirionSht11C { - provides interface Init; - provides interface Resource[ uint8_t id ]; - provides interface GeneralIO as DATA; - provides interface GeneralIO as SCK; - provides interface GpioInterrupt as InterruptDATA; - } - implementation { - // connect to platform or sensorboard-dependent resources - // power-manage the sensor through platform-specific means - } - -5. Directory Organization Guidelines +4. Directory Organization Guidelines ==================================================================== Because the same physical sensor may be attached to TinyOS platforms @@ -324,7 +301,7 @@ code that will enter the core source tree. In general, sensor components may be placed anywhere as long as the nesC compiler receives enough `-I` directives to locate all of the necessary pieces. -6. Authors' Addresses +5. Authors' Addresses ==================================================================== | David Gay @@ -367,10 +344,438 @@ receives enough `-I` directives to locate all of the necessary pieces. | | email - gtolle@archrock.com -7. Citations +6. Citations ==================================================================== .. [TEP2] TEP 2: Hardware Abstraction Architecture .. [TEP114] TEP 114: SIDs: Source and Sink Indepedent Drivers .. [TEP115] TEP 115: Power Management of Non-Virtualized Devices +Appendix A: Sensor Driver Examples +==================================================================== + +1. Analog ADC-Connected Sensor +------------------------------ + +The Analog sensor requires two components + +* a component to present the sensor itself (HamamatsuS1087ParC) + +* a component to select the appropriate hardware resources, such as + ADC port 4, reference voltage 1.5V, and a slow sample and hold time + (HamamatsuS1087ParP). + +The AdcReadClientC component and underlying machinery handles all of +the arbitration and access to the ADC. + +:: + + tos/platforms/telosa/chips/s1087/HamamatsuS1087ParC.nc + + generic configuration HamamatsuS1087ParC() { + provides interface Read; + provides interface ReadStream; + } + implementation { + components new AdcReadClientC(); + Read = AdcReadClientC; + + components new AdcReadStreamClientC(); + ReadStream = AdcReadStreamClientC; + + components HamamatsuS1087ParP; + AdcReadClientC.Msp430Adc12Config -> HamamatsuS1087ParP; + AdcReadStreamClientC.Msp430Adc12Config -> HamamatsuS1087ParP; + } + +:: + + tos/platforms/telosa/chips/s1087/HamamatsuS1087ParP.nc + + module HamamatsuS1087ParP { + provides interface Msp430Adc12Config; + } + implementation { + + async command msp430adc12_channel_config_t + Msp430Adc12Config.getChannelSettings() { + + msp430adc12_channel_config_t config = { + inch: INPUT_CHANNEL_A4, + sref: REFERENCE_VREFplus_AVss, + ref2_5v: REFVOLT_LEVEL_1_5, + adc12ssel: SHT_SOURCE_ACLK, + adc12div: SHT_CLOCK_DIV_1, + sht: SAMPLE_HOLD_4_CYCLES, + sampcon_ssel: SAMPCON_SOURCE_SMCLK, + sampcon_id: SAMPCON_CLOCK_DIV_1 + }; + + return config; + } + } + +2. Binary Pin-Connected Sensor +------------------------------ + +The Binary sensor gets a bit more complex, because it has three +components: + +* one to present the sensor (UserButtonC) + +* one to execute the driver logic (UserButtonLogicP) + +* one to select the appropriate hardware resources, such as MSP430 + Port 27 (HplUserButtonC). + +Note that the presentation of this sensor is not arbitrated because +none of the operations are split-phase. + +:: + + tos/platforms/telosa/UserButtonC.nc + + configuration UserButtonC { + provides interface Get; + provides interface Notify; + } + implementation { + + components UserButtonLogicP; + + components HplUserButtonC; + UserButtonLogicP.GpioInterrupt -> HplUserButtonC.GpioInterrupt; + UserButtonLogicP.GeneralIO -> HplUserButtonC.GeneralIO; + + Get = UserButtonLogicP; + Notify = UserButtonLogicP; + } + +:: + + tos/platforms/telosa/UserButtonLogicP.nc + + module UserButtonLogicP { + provides interface Get; + provides interface Notify; + + uses interface GeneralIO; + uses interface GpioInterrupt; + } + implementation { + norace bool m_pinHigh; + + task void sendEvent(); + + command bool Get.get() { return call GeneralIO.get(); } + + command error_t Notify.enable() { + call GeneralIO.makeInput(); + + if ( call GeneralIO.get() ) { + m_pinHigh = TRUE; + return call GpioInterrupt.enableFallingEdge(); + } else { + m_pinHigh = FALSE; + return call GpioInterrupt.enableRisingEdge(); + } + } + + command error_t Notify.disable() { + return call GpioInterrupt.disable(); + } + + async event void GpioInterrupt.fired() { + call GpioInterrupt.disable(); + + m_pinHigh = !m_pinHigh; + + post sendEvent(); + } + + task void sendEvent() { + bool pinHigh; + pinHigh = m_pinHigh; + + signal Notify.notify( pinHigh ); + + if ( pinHigh ) { + call GpioInterrupt.enableFallingEdge(); + } else { + call GpioInterrupt.enableRisingEdge(); + } + } + } + +:: + + tos/platforms/telosa/HplUserButtonC.nc + + configuration HplUserButtonC { + provides interface GeneralIO; + provides interface GpioInterrupt; + } + implementation { + + components HplMsp430GeneralIOC as GeneralIOC; + + components new Msp430GpioC() as UserButtonC; + UserButtonC -> GeneralIOC.Port27; + GeneralIO = UserButtonC; + + components HplMsp430InterruptC as InterruptC; + + components new Msp430InterruptC() as InterruptUserButtonC; + InterruptUserButtonC.HplInterrupt -> InterruptC.Port27; + GpioInterrupt = InterruptUserButtonC.Interrupt; + } + +3. Digital Bus-Connected Sensor +------------------------------- + +The Digital sensor is the most complex out of the set, and includes +six components: + +* one to present the sensor (SensirionSht11C) + +* one to request arbitrated access and to transform the sensor HAL + into the sensor HIL (SensirionSht11P) + +* one to present the sensor HAL (HalSensirionSht11C) + +* one to perform the driver logic needed to support the HAL, which + twiddles pins according to a sensor-specific protocol + (SensirionSht11LogicP). + +* one to select the appropriate hardware resources, such as the clock, + data, and power pins, and to provide an arbiter for the sensor + (HplSensirionSht11C). + +* one to perform the power control logic needed to support the power + manager associated with the arbiter (HplSensirionSht11P). + +This bus-connected sensor is overly complex because it does not rely +on a shared framework of bus manipulation components. A sensor built +on top of the I2C or SPI bus would likely require fewer components. + +:: + + tos/platforms/telosa/chips/sht11/SensirionSht11C.nc + + generic configuration SensirionSht11C() { + provides interface Read as Temperature; + provides interface Read as Humidity; + } + implementation { + components new SensirionSht11ReaderP(); + + Temperature = SensirionSht11ReaderP.Temperature; + Humidity = SensirionSht11ReaderP.Humidity; + + components HalSensirionSht11C; + + enum { TEMP_KEY = unique("Sht11.Resource") }; + enum { HUM_KEY = unique("Sht11.Resource") }; + + SensirionSht11ReaderP.TempResource -> HalSensirionSht11C.Resource[ TEMP_KEY ]; + SensirionSht11ReaderP.Sht11Temp -> HalSensirionSht11C.SensirionSht11[ TEMP_KEY ]; + SensirionSht11ReaderP.HumResource -> HalSensirionSht11C.Resource[ HUM_KEY ]; + SensirionSht11ReaderP.Sht11Hum -> HalSensirionSht11C.SensirionSht11[ HUM_KEY ]; + } + +:: + + tos/chips/sht11/SensirionSht11ReaderP.nc + + generic module SensirionSht11ReaderP() { + provides interface Read as Temperature; + provides interface Read as Humidity; + + uses interface Resource as TempResource; + uses interface Resource as HumResource; + uses interface SensirionSht11 as Sht11Temp; + uses interface SensirionSht11 as Sht11Hum; + } + implementation { + command error_t Temperature.read() { + call TempResource.request(); + return SUCCESS; + } + + event void TempResource.granted() { + error_t result; + if ((result = call Sht11Temp.measureTemperature()) != SUCCESS) { + call TempResource.release(); + signal Temperature.readDone( result, 0 ); + } + } + + event void Sht11Temp.measureTemperatureDone( error_t result, uint16_t val ) { + call TempResource.release(); + signal Temperature.readDone( result, val ); + } + + command error_t Humidity.read() { + call HumResource.request(); + return SUCCESS; + } + + event void HumResource.granted() { + error_t result; + if ((result = call Sht11Hum.measureHumidity()) != SUCCESS) { + call HumResource.release(); + signal Humidity.readDone( result, 0 ); + } + } + + event void Sht11Hum.measureHumidityDone( error_t result, uint16_t val ) { + call HumResource.release(); + signal Humidity.readDone( result, val ); + } + + event void Sht11Temp.resetDone( error_t result ) { } + event void Sht11Temp.measureHumidityDone( error_t result, uint16_t val ) { } + event void Sht11Temp.readStatusRegDone( error_t result, uint8_t val ) { } + event void Sht11Temp.writeStatusRegDone( error_t result ) { } + + event void Sht11Hum.resetDone( error_t result ) { } + event void Sht11Hum.measureTemperatureDone( error_t result, uint16_t val ) { } + event void Sht11Hum.readStatusRegDone( error_t result, uint8_t val ) { } + event void Sht11Hum.writeStatusRegDone( error_t result ) { } + + default event void Temperature.readDone( error_t result, uint16_t val ) { } + default event void Humidity.readDone( error_t result, uint16_t val ) { } + } + +:: + + tos/platforms/telosa/chips/sht11/HalSensirionSht11C.nc + + configuration HalSensirionSht11C { + provides interface Resource[ uint8_t client ]; + provides interface SensirionSht11[ uint8_t client ]; + } + implementation { + components new SensirionSht11LogicP(); + SensirionSht11 = SensirionSht11LogicP; + + components HplSensirionSht11C; + Resource = HplSensirionSht11C.Resource; + SensirionSht11LogicP.DATA -> HplSensirionSht11C.DATA; + SensirionSht11LogicP.CLOCK -> HplSensirionSht11C.SCK; + SensirionSht11LogicP.InterruptDATA -> HplSensirionSht11C.InterruptDATA; + + components new TimerMilliC(); + SensirionSht11LogicP.Timer -> TimerMilliC; + + components LedsC; + SensirionSht11LogicP.Leds -> LedsC; + } + +:: + + tos/chips/sht11/SensirionSht11LogicP.nc + + generic module SensirionSht11LogicP() { + provides interface SensirionSht11[ uint8_t client ]; + + uses interface GeneralIO as DATA; + uses interface GeneralIO as CLOCK; + uses interface GpioInterrupt as InterruptDATA; + + uses interface Timer; + + uses interface Leds; + } + implementation { + + ... bus protocol details omitted for brevity ... + + } + +:: + + tos/platforms/telosa/chips/sht11/HplSensirionSht11C.nc + + configuration HplSensirionSht11C { + provides interface Resource[ uint8_t id ]; + provides interface GeneralIO as DATA; + provides interface GeneralIO as SCK; + provides interface GpioInterrupt as InterruptDATA; + } + implementation { + components HplMsp430GeneralIOC; + + components new Msp430GpioC() as DATAM; + DATAM -> HplMsp430GeneralIOC.Port15; + DATA = DATAM; + + components new Msp430GpioC() as SCKM; + SCKM -> HplMsp430GeneralIOC.Port16; + SCK = SCKM; + + components new Msp430GpioC() as PWRM; + PWRM -> HplMsp430GeneralIOC.Port17; + + components HplSensirionSht11P; + HplSensirionSht11P.PWR -> PWRM; + HplSensirionSht11P.DATA -> DATAM; + HplSensirionSht11P.SCK -> SCKM; + + components new TimerMilliC(); + HplSensirionSht11P.Timer -> TimerMilliC; + + components HplMsp430InterruptC; + components new Msp430InterruptC() as InterruptDATAC; + InterruptDATAC.HplInterrupt -> HplMsp430InterruptC.Port15; + InterruptDATA = InterruptDATAC.Interrupt; + + components new FcfsArbiterC( "Sht11.Resource" ) as Arbiter; + Resource = Arbiter; + + components new SplitControlPowerManagerC(); + SplitControlPowerManagerC.SplitControl -> HplSensirionSht11P; + SplitControlPowerManagerC.ArbiterInit -> Arbiter.Init; + SplitControlPowerManagerC.ArbiterInfo -> Arbiter.ArbiterInfo; + SplitControlPowerManagerC.ResourceController -> Arbiter.ResourceController; + } + +:: + + tos/platforms/telosa/chips/sht11/HplSensirionSht11P.nc + + module HplSensirionSht11P { + provides interface SplitControl; + uses interface Timer; + uses interface GeneralIO as PWR; + uses interface GeneralIO as DATA; + uses interface GeneralIO as SCK; + } + implementation { + task void stopTask(); + + command error_t SplitControl.start() { + call PWR.makeOutput(); + call PWR.set(); + call Timer.startOneShot( 11 ); + return SUCCESS; + } + + event void Timer.fired() { + signal SplitControl.startDone( SUCCESS ); + } + + command error_t SplitControl.stop() { + call SCK.makeInput(); + call SCK.clr(); + call DATA.makeInput(); + call DATA.clr(); + call PWR.clr(); + post stopTask(); + return SUCCESS; + } + + task void stopTask() { + signal SplitControl.stopDone( SUCCESS ); + } + } diff --git a/doc/txt/tep111.txt b/doc/txt/tep111.txt index 0dc1ca44..17fe6f61 100644 --- a/doc/txt/tep111.txt +++ b/doc/txt/tep111.txt @@ -126,6 +126,11 @@ preceding it might have different lengths, and packet-level radios often require packets to be contiguous memory regions. Overall, these complexities make specifying the format of ``TOS_Msg`` very difficult. +TinyOS has traditionally used statically sized packet buffers, +rather than more dynamic approaches, such as scatter-gather I/O +in UNIX sockets (see the man page for ``recv(2)`` for details). +TinyOS 2.x continues this approach. + 2. message_t ==================================================================== @@ -143,7 +148,11 @@ This format keeps data at a fixed offset, which is important when passing a message buffer between two different link layers. If the data payload were at different offsets for different link layers, then passing a packet between two link layers would require a ``memmove(3)`` -operation (essentially, a copy). +operation (essentially, a copy). Unlike in TinyOS 1.x, where TOS_Msg +as explicitly an active messaging packet, message_t is a more general +data-link buffer. In practice, most data-link layers in TinyOS 2.x +provide active messaging, but it is possible for a non-AM stack to +share message_t with AM stacks. The header, footer, and metadata formats are all opaque. Source code cannot access fields directly. Instead, data-link layers provide access @@ -259,10 +268,11 @@ for other components. The message_t header field is an array of bytes whose size is the size of a platform's union of data-link headers. -Because packets are stored contiguously, the layout of a packet -in memory is not the same as the layout of its nesC structure. +Because radio stacks often prefer packets to be stored contiguously, +the layout of a packet in memory does not necessarily reflect the +layout of its nesC structure. -A packet header does not necessarily start at the beginning of +A packet header MAY start somewhere besides the beginning of the message_t. For example, consider the Telos platform:: typedef union message_header { @@ -377,21 +387,60 @@ the CC2420 metadata structure:: nx_uint16_t time; } cc2420_metadata_t; -5. Implementation +3.5 Variable Sized Structures +---------------------------------------------------------------- + +The message_t structure is optimized for packets with fixed-size +headers and footers. Variable-sized footers are generally easy +to implement. Variable-sized headers are a bit more difficult. +There are three general approaches that can be used. + +If the underlying link hardware is byte-based, the header can +just be stored at the beginning of the message_t, giving it +a known offset. There may be padding between the header and +the data region, but assuming a byte-based send path this merely +requires adjusting the index. + +If the underlying link hardware is packet-based, then the +protocol stack can either include metadata (e.g., in the +metadata structure) stating where the header begins or it +can place the header at a fixed position and use ``memmove(3)`` +on reception and transmit. In this latter case, on +reception the packet is continguously read into the message_t +beginning at the offset of the header structure. Once the +packet is completely received, the header can be decoded, +its length calculated, and the data region of the packet +can be moved to the ``data`` field. On transmission, +the opposite occurs: the data region (and footer if need +be) are moved to be contiguous with the header. Note that +on completion of transmission, they need to be moved back. +Alternatively, the radio stack can institute a single +copy at the botttom layer. + + + +4. Implementation ==================================================================== The definition of message_t can be found in -``tinyos-2.x/tos/types/message.h``. The definition of the CC2420 +``tinyos-2.x/tos/types/message.h``. + +The definition of the CC2420 message format can be found in ``tinyos-2.x/tos/chips/cc2420/CC2420.h``. + The defintion of the CC1000 message format can be found in -``tinyos-2.x/tos/chips/cc1000/CC1000Msg.h``. The definition +``tinyos-2.x/tos/chips/cc1000/CC1000Msg.h``. + +The definition of the standard serial stack packet format can be found in -``tinyos-2.x/tos/lib/serial/Serial.h''. The definition of -the telosb packet format can be found in +``tinyos-2.x/tos/lib/serial/Serial.h`` + +The definition of +the telos family packet format can be found in ``tinyos-2.x/tos/platform/telosa/platform_message.h`` and the micaz format can be found in ``tinyos-2.x/tos/platforms/micaz/platform_message.h``. -6. Author's Address +5. Author's Address ==================================================================== | Philip Levis diff --git a/doc/txt/tep113.txt b/doc/txt/tep113.txt index 6eb0e586..629d7370 100644 --- a/doc/txt/tep113.txt +++ b/doc/txt/tep113.txt @@ -449,11 +449,11 @@ no snooping capabilities. 6. Citations ==================================================================== -.. [TEP2] TEP 2: Hardware Abstraction Architecture. http://cvs.sourceforge.net/viewcvs.py/tinyos/tinyos-1.x/beta/teps/txt/tep2.txt?view=markup +.. [TEP2] TEP 2: Hardware Abstraction Architecture. tinyos-2.x/doc/txt/tep2.txt -.. [TEP111] TEP 111: message_t. http://cvs.sourceforge.net/viewcvs.py/tinyos/tinyos-1.x/beta/teps/txt/tep111.txt?view=markup +.. [TEP111] TEP 111: message_t. tinyos-2.x/doc/txt/tep111.txt -.. [TEP116] TEP 116: Packet Protocols. http://cvs.sourceforge.net/viewcvs.py/tinyos/tinyos-1.x/beta/teps/txt/tep116.txt?view=markup +.. [TEP116] TEP 116: Packet Protocols. tinyos-2.x/doc/txt/tep116.txt .. [HDLC] International Organization For Standardization, ISO Standard 3309-1979, "Data communication - High-level data link control procedures - Frame structure", 1979. diff --git a/doc/txt/tep115.txt b/doc/txt/tep115.txt index 8c13ccbb..f83c53ee 100644 --- a/doc/txt/tep115.txt +++ b/doc/txt/tep115.txt @@ -7,7 +7,7 @@ Power Management of Non-Virtualised Devices :Type: Documentary :Status: Draft :TinyOS-Version: 2.x -:Author: Vlado Handziski, Kevin Klues, Jan-Hinrich Hauer, Phil Levis +:Author: Kevin Klues, Vlado Handziski, Jan-Hinrich Hauer, Phil Levis :Draft-Created: 11-Jan-2006 :Draft-Version: $Revision$ diff --git a/doc/txt/tep117.txt b/doc/txt/tep117.txt index 635fde13..4aac10db 100644 --- a/doc/txt/tep117.txt +++ b/doc/txt/tep117.txt @@ -1,5 +1,5 @@ ============================ -Pins and Buses +Low-Level I/O ============================ :TEP: 117 @@ -7,7 +7,7 @@ Pins and Buses :Type: Documentary :Status: Draft :TinyOS-Version: 2.x -:Author: Phil Buonadonna +:Author: Phil Buonadonna, Jonathan Hui :Draft-Created: 23-Jan-2006 :Draft-Version: $Revision$ @@ -25,8 +25,7 @@ Abstract ==================================================================== The memo documents the TinyOS 2.x interfaces used for controlling -digital IO functionality and digital interfaces other than serial -communication covered in [tep113]. +digital IO functionality and digital interfaces. 1. Introduction @@ -34,32 +33,32 @@ communication covered in [tep113]. The canonical TinyOS device is likely to have a variety of digital interfaces. These interfaces may be divided into two broad -categories. The first are general purpose digital I/O lines (pins) -for individual digital signals at physical pins on a chip or -platform. The second are digital I/O interfaces that have predefined -communication protocol formats. The two buses covered in this -document are the Serial Peripheral Interface (SPI) and the -Inter-Integrated Circuit (I2c) or Two-Wire interface. While there are -likely other bus formats, we presume SPI and I2C to have the largest -coverage. While the UART interface is also in this category, it is -covered separately in [tep113]. - -This memo documents the interfaces used for pins and the two buses. +categories. The first are general purpose digital I/O lines (pins) for +individual digital signals at physical pins on a chip or platform. The +second are digital I/O interfaces that have predefined communication +protocol formats. The three buses covered in this document are the +Serial Peripheral Interface (SPI), the Inter-Integrated Circuit (I2C) +or Two-Wire interface, and the Universal Asynchronous +Receiver/Transmitter (UART) interface. While there are likely other +bus formats, we presume SPI, I2C, and UART to have the largest +coverage. + +This memo documents the interfaces used for pins and the three buses. 2. Pins ==================================================================== -General Purpose I/O (GPIO) pins are single, versatile digital I/O signals -individually controllable on a particular chip or platform. Each GPIO -can be placed into either an input mode or an output mode. On -some platforms a third 'tri-state' mode may exist, but this -functionality is platform specific and will not be covered in this -document. +General Purpose I/O (GPIO) pins are single, versatile digital I/O +signals individually controllable on a particular chip or +platform. Each GPIO can be placed into either an input mode or an +output mode. On some platforms a third 'tri-state' mode may exist, but +this functionality is platform specific and will not be covered in +this document. -On many platforms, a physical pin may function as either a digital GPIO -or another special function I/O such. Examples include ADC I/O or a bus -I/O. Interfaces to configure the specific function of a pin are -platform specific. +On many platforms, a physical pin may function as either a digital +GPIO or another special function I/O such. Examples include ADC I/O or +a bus I/O. Interfaces to configure the specific function of a pin are +platform specific. The objective of the interfaces described here is not to attempt to cover all possibilities of GPIO functionality and features, but to @@ -101,7 +100,9 @@ provided in other components as needed. :: async command void toggle(); async command bool get(); async command void makeInput(); + async command bool isInput(); async command void makeOutput(); + async command bool isOutput(); } @@ -109,7 +110,7 @@ provided in other components as needed. :: 2.2 GpioInterrupt -------------------------------------------------------------------- -The GPIO Interrupt HIL interface provides baseline event control for a +The GPIO Interrupt HIL interface provides baseline event control for a GPIO pin. It provides a mechanism to detect a rising edge OR a falling edge. Note that calls to enableRisingEdge and enableFallingEdge are NOT cumulative and only one edge may be detected at a time. There may @@ -119,7 +120,9 @@ through a platform specific HAL interface. :: interface GpioInterrupt { async command error_t enableRisingEdge(); + async command bool isRisingEdgeEnabled(); async command error_t enableFallingEdge(); + async command bool isFallingEdgeEnabled(); async command error_t disable(); async event void fired(); @@ -135,12 +138,15 @@ with a GPIO event. Platforms MAY provide this interface. Some platforms may have hardware support for such a feature. Other platforms may emulate this capability using the SoftCaptureC component. The interface makes not declaration of the precision or -accuracy of the timestamp with respect to the associated GPIO event. :: +accuracy of the timestamp with respect to the associated GPIO +event. :: interface GpioCapture { async command error_t captureRisingEdge(); + async command bool isRisingEdgeEnabled(); async command error_t captureFallingEdge(); + async command bool isFallingEdgeEnabled(); async event void captured(uint16_t time); async command void disable(); @@ -176,18 +182,18 @@ The interface is split into a synchronous byte level and an asynchronous packet level interface. The byte level interface is intended for short transactions (3-4 bytes) on the SPI bus. :: - interface SPIByte { - async command error_t write( uint8_t tx, uint8_t* rx ); + interface SpiByte { + async command uint8_t write( uint8_t tx ); } The packet level interface is for larger bus transactions. The -pointer/length interface permits use of hardware assist such as DMA. :: +pointer/length interface permits use of hardware assist such as +DMA. :: - interface SPIPacket { - + interface SpiPacket { async command error_t send( uint8_t* txBuf, uint8_t* rxBuf, uint16_t len ); - async event void sendDone( uint8_t* txBuf, uint8_t* rxBuf, uint16_t len, - error_t error ); + async event void sendDone( uint8_t* txBuf, uint8_t* rxBuf, uint16_t len, + error_t error ); } 3.2 I2C @@ -195,34 +201,118 @@ pointer/length interface permits use of hardware assist such as DMA. :: The Inter-Integrated Circuit (I2C) interface is another type of digital bus that is often used for chip-to-chip communication. It is -also known as a two-wire interface. +also known as a two-wire interface. -The I2CPacket interface provides for asynchronous Master mode communication on an -I2C with application framed packets. It supports only single -transfers with a start-stop condition around each transfer. +The I2CPacket interface provides for asynchronous Master mode +communication on an I2C with application framed packets. Individual +I2C START-STOP events are controllable which allows the using +component to do multiple calls within a single I2C transaction and +permits multiple START sequences Platforms providing I2C capability MUST provide this interface. :: - interface I2CPacket { - async command result_t readPacket(uint16_t _addr, uint8_t _length, uint8_t* _data); - async command result_t writePacket(uint16_t _addr, uint8_t _length, uint8_t* _data); - async event void readPacketDone(uint16_t addr, uint8_t length, uint8_t* data, result_t success); - async event void writePacketDone(uint16_t addr, uint8_t length, uint8_t* data, result_t success); + interface I2CPacket { + async command error_t read(i2c_flags_t flags, uint16_t addr, uint8_t length, u int8_t* data); + async event void readDone(error_t error, uint16_t addr, uint8_t length, uint8_t* data); + async command error_t write(i2c_flags_t flags, uint16_t addr, uint8_t length, uint8_t* data); + async event void writeDone(error_t error, uint16_t addr, uint8_t length, uint8_t* data) } +The interface is typed according to the addressing space the +underlying implementation supports. Valid type values are below. :: + + TI2CExtdAddr - Interfaces uses the extended (10-bit) addressing mode. + TI2CBasicAddr - Interfaces uses the basic (7-bit) addressing mode. + +The i2c_flags_t values are defined below. The flags define the +behavior of the operation for the call being made. These values may be +ORed together. :: + + I2C_START - Transmit an I2C STOP at the beginning of the operation. + I2C_STOP - Transmit an I2C STOP at the end of the operation. Cannot be used + with the I2C_ACK_END flag. + I2C_ACK_END - ACK the last byte sent from the buffer. This flags is only valid + a write operation. Cannot be used with the I2C_STOP flag. -4. Author's Address +3.3 UART +-------------------------------------------------------------------- + +The Universal Asynchronous Receiver/Transmitter (UART) interface is a +type of serial interconnect. The interface is "asynchronous" since it +recovers timing from the data stream itself, rather than a separate +control stream. The interface is split into an asynchronous multi-byte +level interface and a synchronous single-byte level interface. + +The multi-byte level interface, UartStream, provides a split-phase +interface for sending and receiving one or more bytes at a time. When +receiving bytes, a byte-level interrupt can be enabled or an interrupt +can be generated after receiving one or more bytes. The latter is +intended to support use cases where the number of bytes to receive is +already known. If the byte-level receive interrupt is enabled, the +receive command MUST return FAIL. If a multi-byte receive interrupt is +enabled, the enableReceiveInterrupt command MUST return FAIL. :: + + interface UartStream { + async command error_t send( uint8_t* buf, uint16_t len ); + async event void sendDone( uint8_t* buf, uint16_t len, error_t error ); + + async command error_t enableReceiveInterrupt(); + async command error_t disableReceiveInterrupt(); + async event void receivedByte( uint8_t byte ); + + async command error_t receive( uint8_t* buf, uint8_t len ); + async event void receiveDone( uint8_t* buf, uint16_t len, error_t error ); + } + +The single-byte level interface, UartByte, provides a synchronous +interface for sending and receiving a single byte. This interface is +intended to support use cases with short transactions. Because UART is +asynchronous, the receive command takes a timeout which represents +units in byte-times, after which the command returns with an +error. Note that use of this interface is discouraged if the UART baud +rate is low. :: + + interface UartByte { + async command error_t send( uint8_t byte ); + async command error_t receive( uint8_t* byte, uint8_t timeout ); + } + +4. Implementation +==================================================================== + +Example implementations of the pin interfaces can be found in tos/chips/msp430/pins, +tos/chips/atm128/pins, and tos/chips/pxa27x/gpio. + +Example implementations of the SPI interfaces can be found in tos/chips/msp430/usart, +tos/chips/atm128/spi, and tos/chips/pxa27x/ssp. + +Example implementations of the I2C interfaces can be found in tos/chips/msp430/usart, +tos/chips/atm128/i2c, and tos/chips/pxa27x/i2c. + +Example implementations of the UART interfaces can be found in tos/chips/msp430/usart, +tos/chips/atm128/uart/ and tos/chips/pxa27x/uart. + + +5. Author's Address ==================================================================== | Phil Buonadonna -| Arched Rock Corporation +| Arch Rock Corporation | 657 Mission St. Ste 600 | San Francisco, CA 94105-4120 | | phone - +1 415 692-0828 x2833 +| +| +| Jonathan Hui +| Arched Rock Corporation +| 657 Mission St. Ste 600 +| San Francisco, CA 94105-4120 +| +| phone - +1 415 692-0828 x2835 -5. Citations +6. Citations ==================================================================== .. [tep113] TEP 113: Serial Communication. diff --git a/doc/txt/tep119.txt b/doc/txt/tep119.txt index 94580b31..2f6edce1 100644 --- a/doc/txt/tep119.txt +++ b/doc/txt/tep119.txt @@ -24,7 +24,11 @@ Abstract The memo documents the interfaces, components, and semantics used by collection protocol in TinyOS 2.x. Collection provides a best-effort, -multihop delivery of packets to the root of a tree. +multihop delivery of packets to the root of *a* tree. There may be +multiple roots in a network, and in this case the semantics implemented +are of *anycast* delivery to at least one of the roots. A node sending +a packet does not specify which root the packet is destined to. + 1. Introduction ==================================================================== @@ -44,7 +48,11 @@ rather than one tree, it has a *forest* of trees. By picking a parent node, a collection protocol implicitly joins one of these trees. Collection provides a best-effort, multihop delivery of packets to one of a network's tree roots: -it is an *anycast* protocol. +it is an *anycast* protocol. The semantics is that the protocol +will make a reasonable effort to deliver the message to at least +one of the roots in the network. There are however no guarantees of +delivery, and there can be duplicates delivered to one or more +roots. There is also no ordering guarantees. Given the limited state that nodes can store and a general need for distributed tree building algorithms, simple collection protocols @@ -75,34 +83,21 @@ for a collection service outlined above. A node can perform four different roles in collection: producer, consumer, snooper, and in-network processor. Depending on their role, the nodes use different interfaces to interact with the collection -component. - -The nodes that generate data to be sent to the root are -*producers*. The producers use the Send interface [1_] to send -data to the root of the collection tree. The collection tree -identifier is be specified as a parameter to Send during -instantiation. - -Root nodes that receive data from the network are *consumers*. The -consumers use the Receive interface [1_] to receive a message -delivered by collection. The collection tree identifier is be -specified as a parameter to Receive during instantiation. +component. -The nodes that overhear messages in transit are *snoopers*. The snoopers -use the Receive interface [1_] to receive a snooped message. The -collection tree identifier is be specified as a parameter to Receive -during instantiation. - -The nodes can process a packet that are in transit. These in-network -*processors* use the Intercept interface [1_] to receive and -update a packet. The collection tree identifier is be specified as a -parameter to Intercept during instantiation. +A consumer is a root of a tree. The set of all roots and the paths that +lead to them form the collection routing infrastructure in the network. +For any connected set of nodes implementing the collection protocol +there is only one collection infrastructure, *i.e.*, all roots in this +set active at the same time are part of the same infrastructure. A node is configured to become a root by using the RootControl interface. RootControl.setRoot() MUST make the current node a root of -the tree specified during instantiation. RootControl.unsetRoot() MUST -make the current root no longer a root in the tree specified during -instantiation. RootControl.unsetRoot() MAY be called on a node that is +the the collection infrastructure. RootControl.unsetRoot() MUST +make the current root no longer a root in the collection infrastructure. +Both calls are idempotent. +RootControl.setRoot() MAY be called on a node that is already a root, to +no effect. RootControl.unsetRoot() MAY be called on a node that is not a root:: interface RootControl { @@ -111,14 +106,38 @@ not a root:: command bool isRoot(); } +The collection infrastructure can be multiplexed among independent +applications, by means of a *collection identifier*. It is important +to note that the *data* traffic in the protocol is multiplexed, +while the *control* traffic is not. + +The nodes that generate data to be sent to the root are *producers*. +The producers use the Send interface [1_] to send data to the root +of the collection tree. The collection identifier is specified as a +parameter to Send during instantiation. + +Root nodes that receive data from the network are *consumers*. The +consumers use the Receive interface [1_] to receive a message +delivered by collection. The collection identifier is specified +as a parameter to Receive during instantiation. + +The nodes that overhear messages in transit are *snoopers*. The +snoopers use the Receive interface [1_] to receive a snooped +message. The collection identifier is specified as a parameter +to Receive during instantiation. + +The nodes can process a packet that are in transit. These in-network +*processors* use the Intercept interface [1_] to receive and update +a packet. The collection identifier is specified as a parameter +to Intercept during instantiation. 3 Collection Services ==================================================================== -A collection service MUST provide one component, TreeCollectionC, +A collection service MUST provide one component, CollectionC, which has the following signature:: - configuration TreeCollectionC { + configuration CollectionC { provides { interface StdControl; interface Send[uint8_t client]; @@ -128,7 +147,6 @@ which has the following signature:: interface RootControl; interface Packet; interface CollectionPacket; - interface TreeRoutingInspect; } uses { interface CollectionId[uint8_t client]; @@ -136,12 +154,12 @@ which has the following signature:: } -TreeCollectionC MAY have additional interfaces, but they MUST have +CollectionC MAY have additional interfaces, but they MUST have default functions on all outgoing invocations (commands for uses, events for provides) of those interfaces so that it can operate properly if they are not wired. -Components SHOULD NOT wire to TreeCollectionC.Send. The generic +Components SHOULD NOT wire to CollectionC.Send. The generic component CollectionSenderC (described in section 3.1) provides a virtualized sending interface. @@ -154,41 +172,25 @@ collection_id_t generally have the same payload format, so that snoopers, intercepters, and receivers can parse it properly. Receive.receive MUST NOT be signaled on non-root -nodes. TreeCollectionC MAY signal Receive.receive on a root node when +nodes. CollectionC MAY signal Receive.receive on a root node when a data packet successfully arrives at that node. If a root node calls -Send, TreeCollectionC MUST treat it as it if were a received packet. +Send, CollectionC MUST treat it as it if were a received packet. Note that the buffer swapping semantics of Receive.receive, when -combined with the pass semantics of Send, require that TreeCollectionC +combined with the pass semantics of Send, require that CollectionC make a copy of the buffer if it signals Receive.receive. -If TreeCollectionC receives a data packet to forward and it is not a +If CollectionC receives a data packet to forward and it is not a root node, it MAY signal Intercept.forward. -If TreeCollectionC receives a data packet that a different node +If CollectionC receives a data packet that a different node is supposed to forward, it MAY signal Snoop.receive. RootControl allows a node to be made a collection tree root. -TreeCollectionC SHOULD NOT configure a node as a root by default. +CollectionC SHOULD NOT configure a node as a root by default. Packet and CollectionPacket allow components to access collection data packet fields [1_]. -TreeRoutingInspect provides information on the current position of -the node in a routing tree:: - - interface TreeRoutingInspect { - command error_t getParent(am_addr_t* parent); - command error_t getHopcount(uint8_t* hopcount); - command error_t getMetric(uint16_t* metric); - } - -In each of these commands, if the return value is not SUCCESS, the -value stored in the pointer argument is undefined. The getMetric -command provides a measure of the quality of a node's route to the -base station. This routing metric MUST be monotonically increasing -across hops. In a collection tree, if node A is the parent of node B, -then node B's metric value MUST be greater than node A's. - 3.1 CollectionSenderC -------------------------------------------------------------------- @@ -202,6 +204,8 @@ component CollectionSenderC:: } } + + This abstraction follows a similar virtualization approach to AMSenderC [1_], except that it is parameterized by a collection_id_t rather than an am_id_t. As with am_id_t, every collection_id_t SHOULD @@ -212,25 +216,30 @@ based on its collection ID and contents. ==================================================================== An implementation of this TEP can be found in -``tinyos-2.x/tos/lib/net/collection``. The implementation consists of -three major components, which are wired together to form a -CollectionC: LinkEstimatorP, TreeRoutingEngineP, and ForwardingEngineP. - -This decomposition tries to encourage evolution of components and ease -of use through modularization. Neighbor management and link estimation -are are decoupled from the routing protocol. Furthermore, the routing -protocol and route selection are decoupled from the forwarding policies, -such as queueing and timing. +``tinyos-2.x/tos/lib/net/ctp`` and ``tinyos-2.x/tos/lib/net/le``, in +the CTP protocol. It is beyond the scope of this document to fully +describe CTP, but we outline its main components. CTP will be +described in an upcoming TEP [2_]. This implementation is a +reference implementation, and is not the only possibility. It +consists of three major components, which are wired together to form +a CollectionC: LinkEstimatorP, CtpTreeRoutingEngineP, and +CtpForwardingEngineP. + +This decomposition tries to encourage evolution of components and +ease of use through modularization. Neighbor management and link +estimation are decoupled from the routing protocol. Furthermore, the +routing protocol and route selection are decoupled from the +forwarding policies, such as queueing and timing. 4.1 LinkEstimatorP -------------------------------------------------------------------- LinkEstimatorP estimates the quality of link to or from each -neighbor. Link estimation can be done in a variety of ways, and we do -not impose one here. It is decoupled from the establishment of -routes. There is a narrow interface (LinkEstimator) between the link -estimator and the routing engine. The one requirement is that the -quality returned is standardized. A larger return value from +neighbor. Link estimation can be done in a variety of ways, and we +do not impose one here. It is decoupled from the establishment of +routes. There is a narrow interface -- LinkEstimator -- between the +link estimator and the routing engine. The one requirement is that +the quality returned is standardized. A smaller return value from LinkEstimator.getQuality(), LinkEstimator.getforwardQuality(), LinkEstimator.getreserveQuality() MUST imply that the link to the neighbor is estimated to be of a higher quality than the one that @@ -238,70 +247,114 @@ results in a smaller return value. The range of value SHOULD be [0,255] and the variation in link quality in that range SHOULD be linear. Radio provided values such as LQI or RSI, beacon based link estimation to compute ETX, or their combination are some possible -approaches to estimating link qualities. LinkEstimatorP MAY have its -own control messages to compute bi-directional link qualities:: +approaches to estimating link qualities. - typedef uint16_t neighbor_t +LinkEstimatorP MAY have its own control messages to compute +bi-directional link qualities. LinkEstimatorP provides calls +(txAck(), txNoAck(), and clearDLQ()) to update the link estimates +based on successful or unsuccessful data transmission to the +neighbors. + +The user of LinkEstimatorP can call insertNeighbor() to manually +insert a node in the neighbor table, pinNeighbor() to prevent a +neighbor from being evicted, and unpinNeighbor() to restore eviction +policy:: + + typedef uint16_t neighbor_table_entry_t LinkEstimatorP { provides { + interface StdControl; + interface AMSend as Send; + interface Receive; interface LinkEstimator; - interface NeighborTable; + interface Init; + interface Packet; + interface LinkSrcPacket; } } interface LinkEstimator { - command uint8_t getLinkQuality(neighbot_t neighbor); - command uint8_t getReverseQuality(neighbot_t neighbor); - command uint8_t getForwardQuality(neighbot_t neighbor); + command uint8_t getLinkQuality(uint16_t neighbor); + command uint8_t getReverseQuality(uint16_t neighbor); + command uint8_t getForwardQuality(uint16_t neighbor); + command error_t insertNeighbor(am_addr_t neighbor); + command error_t pinNeighbor(am_addr_t neighbor); + command error_t unpinNeighbor(am_addr_t neighbor); + command error_t txAck(am_addr_t neighbor); + command error_t txNoAck(am_addr_t neighbor); + command error_t clearDLQ(am_addr_t neighbor); + event void evicted(am_addr_t neighbor); } - interface NeighborTable { - event void evicted(neighbot_t neighbor) - } -4.2 TreeRoutingEngineP +4.2 CtpRoutingEngineP -------------------------------------------------------------------- -TreeRoutingEngineP is responsible for computing routes to the roots of a -tree. It uses NeighborTable and LinkEstimator interfaces to learn +CtpRoutingEngineP is responsible for computing routes to the roots of a +tree. In traditional networking terminology, this is part of the +control plane of the network, and is does not directly forward any +data packets, which is the responsibility of CtpForwardingEngine. +The main interface between the two is UnicastNameFreeRouting. + +CtpRoutingEngineP uses the LinkEstimator interface to learn about the nodes in the neighbor table maintained by LinkEstimatorP and the quality of links to and from the neighbors. The routing protocol on which collection is implemented MUST be a tree-based routing -protocol with a single or multiple roots. TreeRoutingEngineP +protocol with a single or multiple roots. CtpRoutingEngineP allows a node to be configured as a root or a non-root node -dynamically. TreeRoutingEngineP maintains multiple candidate next hops:: - - generic module TreeRoutingEngineP(uint8_t routingTableSize) { - provides { - interface UnicastNameFreeRouting as Routing; - interface RootControl; - interface TreeRoutingInspect; - interface StdControl; - interface Init; - } - uses { - interface AMSend as BeaconSend; - interface Receive as BeaconReceive; - interface LinkEstimator; - interface AMPacket; - interface LinkSrcPacket; - interface SplitControl as RadioControl; - interface Timer as BeaconTimer; - interface Random; - interface CollectionDebug; - } +dynamically. CtpRoutingEngineP maintains multiple candidate next hops:: + + generic module CtpRoutingEngineP(uint8_t routingTableSize, + uint16_t minInterval, + uint16_t maxInterval) { + provides { + interface UnicastNameFreeRouting as Routing; + interface RootControl; + interface CtpInfo; + interface StdControl; + interface CtpRoutingPacket; + interface Init; + } + uses { + interface AMSend as BeaconSend; + interface Receive as BeaconReceive; + interface LinkEstimator; + interface AMPacket; + interface LinkSrcPacket; + interface SplitControl as RadioControl; + interface Timer as BeaconTimer; + interface Timer as RouteTimer; + interface Random; + interface CollectionDebug; + interface CtpCongestion; + } } -4.3 ForwardingEngineP + +:: + + interface UnicastNameFreeRouting { + command am_addr_t nextHop(); + + command bool hasRoute(); + event void routeFound(); + event void noRoute(); + } + + + +4.3 CtpForwardingEngineP -------------------------------------------------------------------- -The ForwardingEngineP component provides all the top level interfaces -(except RootControl) which TreeCollectionC provides and an application -uses:: +The CtpForwardingEngineP component provides all the top level interfaces +(except RootControl) which CollectionC provides and an application +uses. It deals with retransmissions, duplicate suppression, packet +timing, loop detection, and also informs the LinkEstimator of the +outcome of attempted transmissions.:: - generic module ForwardingEngineP() { + generic module CtpForwardingEngineP() { provides { interface Init; interface StdControl; @@ -311,20 +364,24 @@ uses:: interface Intercept[collection_id_t id]; interface Packet; interface CollectionPacket; + interface CtpPacket; + interface CtpCongestion; } uses { + interface SplitControl as RadioControl; interface AMSend as SubSend; interface Receive as SubReceive; interface Receive as SubSnoop; interface Packet as SubPacket; interface UnicastNameFreeRouting; - interface SplitControl as RadioControl; interface Queue as SendQueue; interface Pool as QEntryPool; interface Pool as MessagePool; interface Timer as RetxmitTimer; - interface Cache as SentCache; - interface TreeRoutingInspect; + interface LinkEstimator; + interface Timer as CongestionTimer; + interface Cache as SentCache; + interface CtpInfo; interface PacketAcknowledgements; interface Random; interface RootControl; @@ -334,13 +391,14 @@ uses:: } } -ForwardingEngineP uses a large number of interfaces, which can be + +CtpForwardingEngineP uses a large number of interfaces, which can be broken up into a few groups of functionality: * Single hop communication: SubSend, SubReceive, SubSnoop, SubPacket, PacketAcknowledgments, AMPacket - * Routing: UnicastNameFreeRouting, TreeRoutingInspect, - RootControl, CollectionId, SentCache + * Routing: UnicastNameFreeRouting, RootControl, CtpInfo, + CollectionId, SentCache * Queue and buffer management: SendQueue, MessagePool, QEntryPool * Packet timing: Random, RetxmitTimer @@ -388,4 +446,5 @@ broken up into a few groups of functionality: ==================================================================== .. [1] TEP 116: Packet Protocols +.. [2] TEP 124: The Collection Tree Protocol (CTP) - (upcoming) diff --git a/doc/txt/tep120.txt b/doc/txt/tep120.txt index 2d6b60d4..46a2c57a 100644 --- a/doc/txt/tep120.txt +++ b/doc/txt/tep120.txt @@ -483,33 +483,34 @@ standardized interfaces that allows such technology to interoperate. 9. Funding ==================================================================== -As with the IETF, individuals are responsible for their own costs, -which primarily involve meetings, travel, and generation of work -products. Membership participation will involve attendance at -Alliance meetings. Registration fees will be charged to cover costs -associated with adminstration of the meetings. - -Companies and institutions are encouraged to contribute financial and -in-kind support. It will be essential that companies provide initial -funding to create the legal structure and to establish basic IT -capabilities to host the web site and working groups. - Initially, we expect that there are no full time employees in the Alliance and that funding needs are limited to such items as lawyer's fees, web site costs, and insurance. If the Alliance eventually requires full time support personnel, the funding structure will have to be re-visited. +As with the IETF, individuals are responsible for their own costs, +which primarily involve meetings, travel, and generation of work +products. The Alliance is predominantly a volunteer organization. +Membership participation will involve attendance at +Alliance meetings. Registration fees will be charged to cover costs +associated with adminstration of the meetings. + To maintain the focus on technical excellence and meritocracy, we want to avoid the heavy-handed quid-pro-quo seen in many industrial consortiums where funding determines influence. The best use of funds and the best form of influence is direct contribution to the work -products of the Alliance. We will permit targeted contributions -toward specific working groups or technical capabilities. - -We seek to keep overall structure lean, mostly volunteer. -Focus on desired impact and recognition, rather than control. +products of the Alliance. +To keep the structure of the Alliance and its operations minimalist +and lean, membership focuses on desired impact and recognition, rather +than control. We want the best way to influence the direction of the Alliance +to be to contribute technical work and demonstrate leadership, rather than +try to control what individuals can or cannot contribute. +Companies and institutions are encouraged to contribute financial and +in-kind support. It will be essential that companies provide initial +funding to create the legal structure and to establish basic IT +capabilities to host the web site and working groups. Institutional members will pay an annual membership fee. In some cases, a contributing corporate member may provide in-kind services @@ -520,55 +521,90 @@ solicited and encouraged. In this case the donator need not become a contributing corporate member, e.g., in those cases where such a membership may be prohibited or unwanted. The costs of meetings, such as the TinyOS -technology exchange, will be covered through registration fees. - -Individuals are responsible -for their own costs such as -for travel, meeting costs, or costs for contributing -software or documentation to the Alliance. The Alliance -is primarily a volunteer organization. +technology exchange, will be covered through registration fees and +not by institutional membership fees. 10. Work Products ==================================================================== -Code base -Stable, robust core release -Rapidly evolving, innovative extensions -Reference Implementations -Tools -Data -Documentation -Standard proposals -Marketing and Promotion -Testing and Compliance -Assessments -Applications and uses of technology -Educational Materials +The broad mission of the Alliance calls for a broad range of +work products. + +Foremost among these are a set of TEPs documenting +systems and protocols as well as TEPs that provide guidance +and knowledge to the community. Technical documentation will have +robust and open reference implementations for the community to +use, refine, improve, and discuss. These reference implementations +will not preclude alternative, compatibile implementations which may +have additional features or optimizations. The Alliance Working Groups +will periodically produce periodic releases of these reference +implementations for the community to use and improve. + +The Alliance will support community contributions +of innovative extensions and systems by providing a CVS repository +to store them. +In order to keep these contributions organized for users, the +Steering Committee may nominate one or more people to caretake +the repository by setting minimal guidelines for the use of +the directory structure and migrating code as it joins the core +or falls into disuse. + +To make these technological resources more accessible and useful +to a broad embedded networks community, the Alliance will be +dedicated to providing a set of educational materials. This +includes introductory tutorials, documentation of core systems, +simple and complex example applications, and user guides. + +In addition to educational sample applications, whose purpose +is to teach new developers about the internals and workings of +the technology, the Alliance will develop and make available +several end-user applications and tools. The goal is to improve +the accessibility of the technology to end-users while +demonstrating its effectiveness. Historical examples of such applications +include Surge and TinyDB. An important part of this effort is +good documentation for users who are not expert programmers, as well +as tools and graphical environments. + 11. Conclusions ==================================================================== -The time has come to create an organizational structure to allow the effort to grow -Beyond the Berkeley + Others -It is a balancing act -Stability vs Innovation -Broad Participation vs Strong Requirements -Uniform Licensing vs Institutional Differences -Goal is to help to community to work together -Not a forum for maneuvering and intrigue -Focus on consensus building and technical soundness -Minimal mechanism to resolve rare differences -Focus on working groups and individual contributions -with architectural and organization oversight -Be pragmatic on participation -Don’t have to make deep commitments to participate -Can’t expect broad guarantees in return +By focusing on consensus building and technical excellence, the +Alliance seeks to avoid being a forum for political and economic +positioning. It will achieve this by focusing on working groups +and the contributions of individuals, while not taking strong +positions on the benefits or drawbacks of different approaches. +The variety of application domains sensornets are used in and +the huge differences in requirements mean that having a suite +of solutions, rather than a single one, is often not only +desirable but essential. + +Over the past five years, low-power embedded sensor networks have +grown from research prototypes to working systems that are being +actively deployed. Furthermore, there is a vibrant research community +that actively works to deploy these systems and collaborate with +industry, making advances quickly accessible and usable. A great +catalyst to this growth has been the presence of a large community +around a shared, free code base. + +The time has come to create an organizational structure to +allow the effort to grow further. As sensornets become more widespread, +contributions and advancements will be from an increasingly broad +demographic of users, and bringing them all together will speed +progress and improve the potential benefit these systems can bring +to society. This focus on bringing disparate groups together lies +at the heart of the Alliance. Rather than depend on strong requirements, +it depends on broad collaboration and participation, placing a minimalist +set of expectations that will encourage the exchange of ideas and +technology. + 12. Author's Address ==================================================================== | Philippe Bonnet | David Culler +| David Culler , | Deborah Estrin | Ramesh Govindan | Mike Horton @@ -580,5 +616,3 @@ Can’t expect broad guarantees in return | Matt Welsh | Adam Wolisz -| David Culler , - diff --git a/doc/txt/tep123.txt b/doc/txt/tep123.txt index 93e6b820..7cbf5aa7 100644 --- a/doc/txt/tep123.txt +++ b/doc/txt/tep123.txt @@ -130,14 +130,14 @@ The CTP data frame format is as follows:: Field definitions are as follows: - * C: Congestion notification. If a node is receiving packets faster than it can forward them, it MAY set the C field to notify other nodes. If a node hears a packet from node N with the C bit set, it MUST NOT transmit CTP data frames to N until it hears a packet from N with the C bit cleared. - * P: Routing pull. The P bit allows nodes to request routing information from other nodes. If a node hears a packet with the P bit set, it SHOULD transmit a routing frame in the near future if it has a valid route. + * C: Congestion notification. If a node is receiving packets faster than it can forward them, it MAY set the C field to notify other nodes. If a node hears a packet from node *N* with the C bit set, it MUST NOT transmit CTP data frames to *N* until it hears a packet from N with the C bit cleared. + * P: Routing pull. The P bit allows nodes to request routing information from other nodes. If a node with a valid route hears a packet with the P bit set, it SHOULD transmit a routing frame in the near future. * THL: Time Has Lived. When a node generates a CTP data frame, it MUST set THL to 0. When a node receives a CTP data frame, it MUST increment the THL. If a node receives a THL of 255, it increments it to 0. * ETX: The ETX routing metric of the single-hop sender. When a node transmits a CTP data frame, it MUST put the ETX value of its route through the single-hop destination in the ETX field. If a node receives a packet with a lower gradient than its own, then it MUST schedule a routing frame in the near future. * origin: The originating address of the packet. A node forwarding a data frame MUST NOT modify the origin field. * seqno: Origin sequence number. The originating node sets this field, and a node forwarding a data frame MUST NOT modify it. * collect_id: Higher-level protocol identifier. The origin sets this field, and a node forwarding a data frame MUST NOT modify it. - * data: the data payload, of zero or more bytes. + * data: the data payload, of zero or more bytes. A node forwarding a data frame MUST NOT modify the data payload. Together, the origin, seqno and collect_id fields denote a unique ***origin packet.*** Together, the origin, seqno, collect_id, and @@ -145,9 +145,9 @@ THL denote a unique ***packet instance*** within the network. The distinction is important for duplicate suppression in the presence of routing loops. If a node suppresses origin packets, then if asked to forward the same packet twice due to a routing loop, it will -drop the packet. However, if it suppresses packet instances, then -unless the THL has wrapped around to the identical value it had -on previous times around. +drop the packet. However, if it suppresses packet instances, then it +will route succesfully in the presence of transient loops unless the +THL happens to wrap around to a forwarded packet instance. A node MUST send CTP data frames as unicast messages with link-layer acknowledgments enabled. @@ -184,4 +184,82 @@ below its own. When a parent hears a child advertise an ETX below its own, it MUST schedule a routing frame for transmission in the near future. +6. Implementation +============================================================================== + +An implementation of CTP can be found in the tos/lib/net/ctp directory +of TinyOS 2.0. This section describes the structure of that implementation +and is not in any way part of the specification of CTP. + +This implementation has three major subcomponents: + +1) A **link estimator**, which is responsible for estimating the +single-hop ETX of communication with single-hop neighbors. + +2) A **routing engine**, which uses link estimates as well as +network-level information to decide which neighbor is the next +routing hop. + +3) A **forwarding engine**, which maintains a queue of packets +to send. It decides when and if to send them. The name is a little +misleading: the forwarding engine is responsible for forwarded traffic +as well as traffic generated on the node. + +6.1 Link Estimation +------------------------------------------------------------------------------ + +The link estimator estimates the ETX to single-hop neighbors. +The implementation uses two mechanisms to estimate the quality of a link: +periodic broadcast packets and data packets. The estimator itself +only generates broadcast packets. For data traffic, it depends on +other components telling it about acknowledged and unacknowledged +transmissions. + +The periodic broadcast packets have sequence numbers, which the +estimator uses to estimate the sender-to-receiver packet reception +rate (PRR). The data payload of periodic broadcast packets contain +these estimates. Therefore, when node A receives a link estimation +broadcast message from node B, it can use the packet header to +estimate the B-to-A PRR and the packet payload to update B's +estimate of the A-to-B PRR. + +Multiplying these two values gives a *bidirectional* PRR, or +an estimate of the probability that if A transmits a packet to B, +B will successfully hear and acknowledge the packet and A will +hear the acknowledgment. The inverse of the bidirecitonal PRR +is the ETX. + +CTP link estimation adapts its beaconing rate to be slow when +its routing table is stable and faster when changes occur. +It adjusts the beaconing interval using an algorithm similar +to the trickle dissemination protocol[2_]. CTP sends beacons +more often when one of three conditions occurs: + + 1) The routing table is empty (this also sets the P bit) + 2) The node's routing ETX increases by >= 1 trasmission + 3) The node hears a packet with the P bit set + +CTP also estimates link quality using data transmissions. This +is a direct measure of ETX. Whenever the data path transmits a +packet, it tells the link estimator the destimation and whether +it was successfully acknowledged. The estimator produces an ETX +estimate every 5 such transmissions, where 0 successes has an +ETX of 6. + +The estimator combines the beacon and data estimates by incorporating +them into an exponentially weighted moving average. Beacon-based +estimates seed the neighbor table. The expectation is that the low +beacon rate in a stable network means that for a selected route, +data estimates will outweigh beacon estimates. Additionally, as +the rate at which CTP collects data estimates is proportional to +the transmission rate, then it can quickly detect a broken link and +switch to another candidate neighbor. + +6.2 Routing Engine +------------------------------------------------------------------------------ + +The + + +