]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Merge branch 'master' into debian/2.1.0
authorR. Steve McKown <rsmckown@gmail.com>
Fri, 23 Apr 2010 23:13:10 +0000 (17:13 -0600)
committerR. Steve McKown <rsmckown@gmail.com>
Fri, 23 Apr 2010 23:13:10 +0000 (17:13 -0600)
support/sdk/java/net/tinyos/message/Makefile
support/sdk/java/net/tinyos/packet/Makefile
tinyos.sh
tools/platforms/msp430/pybsl/cp210x_rt/cp210xrtmodule.c
tools/tinyos/ncc/mig.in
tools/tinyos/ncc/ncg.in
tos/platforms/tmicore/PlatformSerialC.nc
tos/platforms/tmicore/PlatformSerialP.nc [new file with mode: 0644]

index 291c73e010a18469a01ae8645d5fbe15e0542fff..67a6db48226812dafacd290b640a555dba3e872b 100644 (file)
@@ -5,7 +5,6 @@ INITIAL_TARGETS = SerialPacket.class SerialPacket.java
 ROOT = ../../..
 include $(ROOT)/Makefile.include
 
-TOS=$(shell ncc -print-tosdir)
 SERIAL_H = $(TOSDIR)/lib/serial/Serial.h
 
 SerialPacket.java: $(SERIAL_H) FORCE
index a8754031a4dac6e53efb96353a95f23e5d27c173..29cb31710aa2e876daec8a4db522c8560038fb95 100644 (file)
@@ -5,8 +5,7 @@ INITIAL_TARGETS = Serial.class Serial.java
 ROOT = ../../..
 include $(ROOT)/Makefile.include
 
-TOS=$(shell ncc -print-tosdir)
-SERIAL_H = $(TOS)/lib/serial/Serial.h
+SERIAL_H = $(TOSDIR)/lib/serial/Serial.h
 
 Serial.java: $(SERIAL_H) FORCE
        ncg -o $@ -java-classname=net.tinyos.packet.Serial java $(SERIAL_H) Serial.h
index 20814c4eca631b46c7b3c0b23692709c18ce7063..f7e1368f061121d0451e8c3ba346bb50da997dbe 100644 (file)
--- a/tinyos.sh
+++ b/tinyos.sh
-#! /usr/bin/env bash
-# Here we setup the environment
-# variables needed by the tinyos 
-# make system
+#!/usr/bin/env bash
+#
+# Here we setup the environment variables needed by the tinyos make system.
+# Users source this script from their shell to setup tinyos for their login,
+# and may source again at any time to change which installed TinyOS source
+# tree their code shall be built against.
 
+TOSCFG=~/.tosrc
 TOSBASE=/opt/tinyos
+RCFILES="$HOME/.bashrc $HOME/.shrc $HOME/.kshrc $HOME/.cshrc $ENV"
 
-# $1 is a directory or tos version number
-# returns a fully rooted and valid TOSROOT
-getdir()
+# $1 is a directory or tos version number returns a fully rooted and valid
+# TOSROOT, or nothing.
+gettosroot()
 {
     if [ -d "$1" -a -d "$1/tos" ]; then
-       echo "$1"
+       echo $(cd $1 && pwd)
     elif [ -d "$TOSBASE/$1" -a -d "$TOSBASE/$1/tos" ]; then
        echo "$TOSBASE/$1"
     fi
 }
 
-# Clear TOS environment
-if [ -n "$TOSROOT" ]; then
-    CLASSPATH=$(echo $CLASSPATH | sed -e "s|:$TOSROOT/support/sdk/java||")
-fi
-unset TOSDIR MAKERULES
+# Update CLASSPATH by replacing the element value in $1 with the element value 
+# in $2.  An empty $2 removes element $1, if present.  An empty $1, or $1 not
+# present, adds $2.
+updclasspath()
+{
+    local jpath="support/sdk/java/tinyos.jar"
+    if [ -n "$1" -a -n "$2" ] && \
+           echo "$CLASSPATH" | grep -q "$1/$jpath"; then
+       CLASSPATH=$(echo $CLASSPATH | sed -e "s|:$1/$jpath|:$2/$jpath|")
+    elif [ -n "$2" ]; then
+       CLASSPATH="$CLASSPATH:$2/$jpath"
+    elif [ -n "$1" ]; then
+       CLASSPATH=$(echo $CLASSPATH | sed -e "s|:$1/$jpath||")
+    fi
+    export CLASSPATH
+}
 
-# Set TOS environment
-TOSROOT=$(getdir "$1")
-if [ -z "$TOSROOT" ]; then
-    TOSROOT=$(cat ~/.tosrc 2>/dev/null)
-fi
+# Install a tinyos.sh invocation in user shell rc files.
+installshrc()
+{
+    for rc in $RCFILES; do
+       if [ -f $rc ] && ! grep -q "$TOSBASE/tinyos.sh" $rc; then
+           echo "[ -d $TOSBASE ] && . $TOSBASE/tinyos.sh" >> $rc 2>/dev/null
+       fi
+    done
+}
+
+# Uninstall the tinyos.sh invocation in user shell rc files.
+uninstallshrc()
+{
+    for rc in $RCFILES; do
+       if [ -f $rc ] && grep -q "$TOSBASE/tinyos.sh" $rc; then
+           grep -v "$TOSBASE/tinyos.sh" $rc > $rc.$$
+           mv -f $rc.$$ $rc
+       fi
+    done
+}
+
+# List available TinyOS source versions
+listsources()
+{
+    echo -n "Available sources:"
+    find $TOSBASE -maxdepth 2 -name tos -type d 2>/dev/null | sort | \
+           while read dir; do
+       echo -n "  $(basename -- $(dirname -- $dir))"
+    done
+    echo
+}
+
+# MAIN
+
+if [ "$1" = "-t" ]; then
+    # Display TOS environment
+    if [ -z "$TOSROOT" ]; then
+       echo "tinyos: NOT configured"
+    else
+       echo "TOSROOT=$TOSROOT"
+    fi
+elif [ "$1" = "-l" ]; then
+    listsources
+elif [ "$1" = "-h" ]; then
+    cat <<EOF1
+Each TinyOS user must type the following to configure their login:
+
+    . $TOSBASE/tinyos.sh <version>
+
+<version> is the version of an installed source tree or the filesystem path to
+a TinyOS source tree
 
-if [ -z "$TOSROOT" ]; then
-    echo "No TinyOS source directory found.  Usage:" >&2
-    echo "source /opt/tinyos/tinyos.sh [<version> | <directory>]" >&2
-    export TOSROOT TOSDIR MAKERULES
+EOF1
+    listsources
+    cat <<EOF2
+
+Run this command at any time to change the TinyOS source tree for the current
+and all future shell invocations.  The tree setting is persistent across
+logins.
+EOF2
+elif [ "$(basename -- $0)" = tinyos.sh ]; then
+    # Operations below here cannot be executed in a sub-shell
+    echo "tinyos: must be sourced"
+elif [ "$1" = "-u" ]; then
+    if [ -f $TOSCFG ]; then
+       uninstallshrc
+       updclasspath "$TOSROOT" ""
+       unset TOSROOT TOSDIR MAKERULES
+       rm -f "$TOSCFG"
+       echo "tinyos: environment uninstalled for $(whoami)"
+    else
+       echo "tinyos: environment not installed for $(whoami)"
+    fi
 else
-    echo "Setting up for TinyOS source in $TOSROOT"
-    echo "$TOSROOT" > ~/.tosrc
-    TOSDIR="$TOSROOT/tos"
-    CLASSPATH=$CLASSPATH:$TOSROOT/support/sdk/java
-    MAKERULES="$TOSROOT/support/make/Makerules"
-    export TOSROOT TOSDIR CLASSPATH MAKERULES
+    # Get TOSROOT, either from command line or cached in $TOSCFG
+    if [ -n "$1" ]; then
+       newroot=$(gettosroot "$1")
+       if [ -n "$newroot" ]; then
+           echo "$TOSROOT" > "$TOSCFG"
+           installshrc
+           echo "tinyos: now using $newroot"
+       else
+           echo "tinyos: invalid version; try -h option"
+       fi
+    else
+       newroot=$(cat "$TOSCFG" 2>/dev/null)
+       if [ -z "$newroot" ]; then
+           echo "tinyos: NOT configured; try -h option"
+       fi
+    fi
+
+    # Set TOS environment
+    if [ -n "$newroot" ]; then
+       updclasspath "$TOSROOT" "$newroot"
+       TOSROOT="$newroot"
+       TOSDIR="$TOSROOT/tos"
+       MAKERULES="$TOSROOT/support/make/Makerules"
+    fi
 fi
-unset TOSBASE tmp
+export TOSROOT TOSDIR MAKERULES
+unset TOSBASE RCFILES
+
+# vi: sw=4
index 393ed4772c2943fa0d887b41acd77a07e57ebb20..860c03d3d0a02f81046bc25089376610e29aad3d 100644 (file)
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+
 /**
  * @author R. Steve McKown <rsmckown@gmail.com>
  */
+
 #include <Python.h>
 #include <windows.h>
 #include <io.h>
index 3dc8712788c05218278b54d4d99ef84d37d91f42..61cbfc2564ba9e1ab5dc0ca963931ee3092ae399 100644 (file)
@@ -10,7 +10,8 @@
 
 prefix="@prefix@";
 exec_prefix="@exec_prefix@";
-exec "@nescc_prefix@/bin/nescc-mig" "-nescc=$exec_prefix/bin/ncc" "$@"
+#exec "@nescc_prefix@/bin/nescc-mig" "-nescc=$exec_prefix/bin/ncc" "$@"
+exec "@nescc_prefix@/bin/nescc-mig" "-nescc=ncc" "$@"
 err=$?
 echo "Couldn't execute @nescc_prefix@/bin/nescc-mig" >&2
 exit $err
index 6bcb50d28be4e9a87bcffaaa5c9e6958fd3937c7..4633bf38163259f4b9cb4e77a99f147aab31014d 100644 (file)
@@ -10,7 +10,8 @@
 
 prefix="@prefix@";
 exec_prefix="@exec_prefix@";
-exec "@nescc_prefix@/bin/nescc-ncg" "-nescc=$exec_prefix/bin/ncc" "$@"
+#exec "@nescc_prefix@/bin/nescc-ncg" "-nescc=$exec_prefix/bin/ncc" "$@"
+exec "@nescc_prefix@/bin/nescc-ncg" "-nescc=ncc" "$@"
 err=$?
 echo "Couldn't execute @nescc_prefix@/bin/nescc-ncg" >&2
 exit $err
index 35b1d8c6e36df6175547f160fbb782ac863e8bf5..06cb3241843f4fd3b2bc3915e2d9ac33241c004d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Titanium Mirror, Inc.
+ * Copyright (c) 2008-2010, Titanium Mirror, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  */
  
 configuration PlatformSerialC {
-  provides interface Resource;
+  provides interface StdControl;
   provides interface UartStream;
   provides interface UartByte;
 }
 implementation {
   components new Msp430UartA1C() as UartC;
-  Resource = UartC;
   UartStream = UartC;
   UartByte = UartC;
 
+  components PlatformSerialP;
+  StdControl = PlatformSerialP;
+  PlatformSerialP.Resource -> UartC;
+
 #if 0 /* If you want to change the configuration... */
   components SomeConfigurationComponentC as ConfigC;
   UartC.AsyncConfigure -> ConfigC;
diff --git a/tos/platforms/tmicore/PlatformSerialP.nc b/tos/platforms/tmicore/PlatformSerialP.nc
new file mode 100644 (file)
index 0000000..ae0fb9f
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2010, Titanium Mirror, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universität Berlin nor the names
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author R. Steve McKown <rsmckown@gmail.com>
+ */
+
+module PlatformSerialP {
+  provides interface StdControl;
+  uses interface Resource;
+}
+implementation {
+  command error_t StdControl.start()
+  {
+    return call Resource.immediateRequest();
+  }
+
+  command error_t StdControl.stop()
+  {
+    call Resource.release();
+    return SUCCESS;
+  }
+
+  event void Resource.granted() {}
+}