From: idgay Date: Wed, 2 Jul 2008 17:42:42 +0000 (+0000) Subject: renames X-Git-Tag: release_tinyos_2_1_0_0~125 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=83c555c63d035fd7e3cd1c448de564bf7fa60864 renames --- diff --git a/apps/tests/TestFTSP/FTSPDataLogger.java b/apps/tests/TestFTSP/FTSPDataLogger.java deleted file mode 100644 index 3b96c8fc..00000000 --- a/apps/tests/TestFTSP/FTSPDataLogger.java +++ /dev/null @@ -1,120 +0,0 @@ -/* tab:4 - * "Copyright (c) 2000-2003 The Regents of the University of California. - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose, without fee, and without written agreement is - * hereby granted, provided that the above copyright notice, the following - * two paragraphs and the author appear in all copies of this software. - * - * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT - * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF - * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." - * - * Copyright (c) 2002-2007 Intel Corporation - * All rights reserved. - * - * This file is distributed under the terms in the attached INTEL-LICENSE - * file. If you do not find these files, copies can be found by writing to - * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, - * 94704. Attention: Intel License Inquiry. - */ - - -/** - * @author Brano Kusy - */ - -import java.io.FileOutputStream; -import java.io.PrintStream; -import net.tinyos.message.*; -import net.tinyos.util.*; - -public class FTSPDataLogger implements MessageListener { - public class RunWhenShuttingDown extends Thread { - public void run() - { - System.out.println("Control-C caught. Shutting down..."); - if (outReport!=null) - outReport.close(); - } - } - - MoteIF mote; // For talking to the antitheft root node - - void connect() - { - try { - mote = new MoteIF(PrintStreamMessenger.err); - mote.registerListener(new TestFTSPMsg(), this); - System.out.println("Connection ok!"); - } - catch(Exception e) { - e.printStackTrace(); - System.exit(2); - } - } - PrintStream outReport = null; - - public FTSPDataLogger() { - connect(); - Runtime.getRuntime().addShutdownHook(new RunWhenShuttingDown()); - String name=""+System.currentTimeMillis(); - try - { - outReport = new PrintStream(new FileOutputStream(name+".report")); - outReport.println("#[JAVA_TIME] [NODE_ID] [SEQ_NUM] [GLOB_TIME] [IS_TIME_VALID]"); - } - catch (Exception e) - { - System.out.println("FTSPDataLogger.FTSPDataLogger(): "+e.toString()); - } - } - - public void writeReprot(TestFTSPMsg tspr) - { - String foo = (System.currentTimeMillis() - +" "+tspr.get_src_addr()+" "+tspr.get_counter() - +" "+tspr.get_global_rx_timestamp()+" "+tspr.get_is_synced()); - outReport.println(foo); - System.out.println(foo); - outReport.flush(); - } - - public void writeFullReprot(TestFTSPMsg tspr) - { - String foo = (System.currentTimeMillis() - +" "+tspr.get_src_addr() - +" "+tspr.get_counter() - +" "+tspr.get_local_rx_timestamp() - +" "+tspr.get_global_rx_timestamp() - +" "+tspr.get_skew_times_1000000() - +" "+tspr.get_is_synced() - +" "+tspr.get_ftsp_root_addr() - +" "+tspr.get_ftsp_seq() - +" "+tspr.get_ftsp_table_entries()); - outReport.println(foo); - System.out.println(foo); - outReport.flush(); - } - - public void messageReceived(int dest_addr, Message msg) - { - if (msg instanceof TestFTSPMsg) - //writeFullReprot((TestFTSPMsg)msg); - writeReprot((TestFTSPMsg)msg); - } - - /* Just start the app... */ - public static void main(String[] args) - { - new FTSPDataLogger(); - } -} \ No newline at end of file diff --git a/apps/tests/TestFTSP/Makefile b/apps/tests/TestFTSP/Makefile deleted file mode 100644 index 78a66671..00000000 --- a/apps/tests/TestFTSP/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -BUILD_EXTRA_DEPS = FTSPDataLogger.class -CLEAN_EXTRA = *.class TestFTSPMsg.java - -FTSPDataLogger.class: TestFTSPMsg.java - javac *.java - -TestFTSPMsg.java: TestFTSP.h - mig java -target=$(PLATFORM) $(CFLAGS) -java-classname=TestFTSPMsg TestFTSP.h test_ftsp_msg -o $@ - -COMPONENT=TestFTSPC - -PFLAGS += -DTIMESYNC_RATE=3 -#PFLAGS += -DTIMESYNC_DEBUG - -PFLAGS += -I$(TOSDIR)/lib/ftsp -I$(TOSDIR)/../apps/RadioCountToLeds - -include $(MAKERULES) diff --git a/apps/tests/TestFTSP/README.txt b/apps/tests/TestFTSP/README.txt deleted file mode 100644 index 7009039d..00000000 --- a/apps/tests/TestFTSP/README.txt +++ /dev/null @@ -1,88 +0,0 @@ -TestFTSP - -------------------------------------------------------------------------------- -Author/Contact: ---------------- - Brano Kusy: branislav.kusy@gmail.com - Janos Sallai: janos.sallai@vanderbilt.edu - Miklos Maroti: mmaroti@gmail.com - -------------------------------------------------------------------------------- -DESCRIPTION: ------------- - The TestFTSP application tests the Flooding Time Synchronization Protocol - (FTSP) implementation. A network of motes programmed with TestFTSP run the - FTSP protocol to time synchronize, and sends to the base station the global - reception timestamps of messages broadcast by a dedicated beacon mote - programmed with RadioCountToLeds. Ideally, the global reception timestamps of - the same RadioCountToLeds message should agree for all TestFTSP motes (with a - small synchronization error). - -------------------------------------------------------------------------------- -SUPPORTED PLATFORMS: --------------------------------------------- - The supported platforms are micaz, telosb and iris. - -------------------------------------------------------------------------------- -STEP BY STEP GUIDE TO RUN OUR TEST SCENARIO: --------------------------------------------- - - program one mote with apps/RadioCountToLeds - - program multiple motes with TestFTSP - - program a mote with apps/BaseStation, leave it on the programming board - - turn on all the motes - - start the FTSPDataLogger java application (type "java FTSPDataLogger") - -------------------------------------------------------------------------------- -REPORTED DATA: --------------- - The most important reported data is the global time of arrival of the beacons. - The beacon msg arrives to all clients at the same time instant, thus reported - global times should be the same for all clients for the same sequence number. - - Each message contains: - - the time of message reception by the java app [JAVA_TIME] - - the node ID of the mote that is sending this report [NODE_ID] - - the sequence number of the RadioCountToLeds message that is increased - for each new polling msg [SEQ_NUM] - - the global time when the polling message arrived [GLOB_TIME] - - a result_t value indicating if the timestamp is valid [IS_TIME_VALID] - (a result_t of 0 denotes a valid timestamp) - -If the application is running correctly, then the output should show -reports from the different FTSP nodes with valid timestamps and similar -global time values. For example, this is a trace with two FTSP nodes, -with IDs 1 and 5: - -1214516486569 1 10916 433709 0 -1214516486569 5 10916 433709 0 -1214516486809 5 10917 433964 0 -1214516486809 1 10917 433963 0 -1214516487045 5 10918 434210 0 -1214516487053 1 10918 434210 0 -1214516487285 1 10919 434454 0 -1214516487293 5 10919 434455 0 - -One way to test if FTSP is operating correctly is to turn off one of -the FTSP nodes. For a short time, that node's global times will differ -significantly and its valid flag will not be 0. For example, this -is what it looks like when node 1 in the earlier trace is reset: - -1214516490953 5 10934 438208 0 -1214516491201 5 10935 438460 0 -1214516491441 5 10936 438712 0 -1214516491685 5 10937 438964 0 -1214516492169 5 10939 439455 0 -1214516492417 1 10940 243 1 -1214516492421 5 10940 439706 0 -1214516492665 5 10941 439960 0 -1214516492669 1 10941 497 1 -1214516492905 5 10942 440213 0 -... -1214516497541 1 10961 5495 1 -1214516497549 5 10961 444958 0 -1214516497793 1 10962 5747 1 -1214516498025 1 10963 445456 0 -1214516498033 5 10963 445455 0 -1214516498277 5 10964 445705 0 -1214516498285 1 10964 445707 0 -1214516498521 1 10965 445964 0 diff --git a/apps/tests/TestFTSP/TestFTSP.h b/apps/tests/TestFTSP/TestFTSP.h deleted file mode 100644 index c5ded365..00000000 --- a/apps/tests/TestFTSP/TestFTSP.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2002, Vanderbilt University - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose, without fee, and without written agreement is - * hereby granted, provided that the above copyright notice, the following - * two paragraphs and the author appear in all copies of this software. - * - * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT - * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT - * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * @author: Miklos Maroti, Brano Kusy (kusy@isis.vanderbilt.edu) - * Ported to T2: 3/17/08 by Brano Kusy (branislav.kusy@gmail.com) - */ - -#ifndef TEST_FTSP_H -#define TEST_FTSP_H - -typedef nx_struct test_ftsp_msg -{ - nx_uint16_t src_addr; - nx_uint16_t counter; - nx_uint32_t local_rx_timestamp; - nx_uint32_t global_rx_timestamp; - nx_uint32_t skew_times_1000000; - nx_uint8_t is_synced; - nx_uint16_t ftsp_root_addr; - nx_uint8_t ftsp_seq; - nx_uint8_t ftsp_table_entries; -} test_ftsp_msg_t; - -enum -{ - AM_TEST_FTSP_MSG = 137 -}; - -#endif diff --git a/apps/tests/TestFTSP/TestFTSPAppC.nc b/apps/tests/TestFTSP/TestFTSPAppC.nc deleted file mode 100644 index f3634e20..00000000 --- a/apps/tests/TestFTSP/TestFTSPAppC.nc +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2002, Vanderbilt University - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose, without fee, and without written agreement is - * hereby granted, provided that the above copyright notice, the following - * two paragraphs and the author appear in all copies of this software. - * - * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT - * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT - * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * @author: Miklos Maroti, Brano Kusy (kusy@isis.vanderbilt.edu) - * Ported to T2: 3/17/08 by Brano Kusy (branislav.kusy@gmail.com) - */ - -#include "TestFTSP.h" -#include "RadioCountToLeds.h" - -module TestFTSPAppC -{ - uses - { - interface GlobalTime; - interface TimeSyncInfo; - interface Receive; - interface AMSend; - interface Packet; - interface Leds; - interface PacketTimeStamp; - interface Boot; - interface SplitControl as RadioControl; - } -} - -implementation -{ - message_t msg; - bool locked = FALSE; - - event void Boot.booted() { - call RadioControl.start(); - } - - event message_t* Receive.receive(message_t* msgPtr, void* payload, uint8_t len) - { - call Leds.led0Toggle(); - if (!locked && call PacketTimeStamp.isValid(msgPtr)) { - radio_count_msg_t* rcm = (radio_count_msg_t*)call Packet.getPayload(msgPtr, sizeof(radio_count_msg_t)); - test_ftsp_msg_t* report = (test_ftsp_msg_t*)call Packet.getPayload(&msg, sizeof(test_ftsp_msg_t)); - - uint32_t rxTimestamp = call PacketTimeStamp.timestamp(msgPtr); - - report->src_addr = TOS_NODE_ID; - report->counter = rcm->counter; - report->local_rx_timestamp = rxTimestamp; - report->is_synced = call GlobalTime.local2Global(&rxTimestamp); - report->global_rx_timestamp = rxTimestamp; - report->skew_times_1000000 = (uint32_t)call TimeSyncInfo.getSkew()*1000000UL; - report->ftsp_root_addr = call TimeSyncInfo.getRootID(); - report->ftsp_seq = call TimeSyncInfo.getSeqNum(); - report->ftsp_table_entries = call TimeSyncInfo.getNumEntries(); - - if (call AMSend.send(AM_BROADCAST_ADDR, &msg, sizeof(test_ftsp_msg_t)) == SUCCESS) { - locked = TRUE; - } - } - - return msgPtr; - } - - event void AMSend.sendDone(message_t* ptr, error_t success) { - locked = FALSE; - return; - } - - event void RadioControl.startDone(error_t err) {} - event void RadioControl.stopDone(error_t error){} -} diff --git a/apps/tests/TestFTSP/TestFTSPC.nc b/apps/tests/TestFTSP/TestFTSPC.nc deleted file mode 100644 index f32d3ae1..00000000 --- a/apps/tests/TestFTSP/TestFTSPC.nc +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2002, Vanderbilt University - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose, without fee, and without written agreement is - * hereby granted, provided that the above copyright notice, the following - * two paragraphs and the author appear in all copies of this software. - * - * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT - * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT - * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - * @author: Miklos Maroti, Brano Kusy (kusy@isis.vanderbilt.edu) - * Ported to T2: 3/17/08 by Brano Kusy (branislav.kusy@gmail.com) - */ - -#include "TestFTSP.h" -#include "RadioCountToLeds.h" - -configuration TestFTSPC { -} - -implementation { - components MainC, TimeSyncC; - - MainC.SoftwareInit -> TimeSyncC; - TimeSyncC.Boot -> MainC; - - components TestFTSPAppC as App; - App.Boot -> MainC; - - components ActiveMessageC; - App.RadioControl -> ActiveMessageC; - App.Receive -> ActiveMessageC.Receive[AM_RADIO_COUNT_MSG]; - App.AMSend -> ActiveMessageC.AMSend[AM_TEST_FTSP_MSG]; - App.Packet -> ActiveMessageC; - App.PacketTimeStamp -> ActiveMessageC; - - components LedsC; - - App.GlobalTime -> TimeSyncC; - App.TimeSyncInfo -> TimeSyncC; - App.Leds -> LedsC; - -} diff --git a/apps/tests/TestFtsp/FtspDataLogger.java b/apps/tests/TestFtsp/FtspDataLogger.java new file mode 100644 index 00000000..168fa0fb --- /dev/null +++ b/apps/tests/TestFtsp/FtspDataLogger.java @@ -0,0 +1,120 @@ +/* tab:4 + * "Copyright (c) 2000-2003 The Regents of the University of California. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF + * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." + * + * Copyright (c) 2002-2007 Intel Corporation + * All rights reserved. + * + * This file is distributed under the terms in the attached INTEL-LICENSE + * file. If you do not find these files, copies can be found by writing to + * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, + * 94704. Attention: Intel License Inquiry. + */ + + +/** + * @author Brano Kusy + */ + +import java.io.FileOutputStream; +import java.io.PrintStream; +import net.tinyos.message.*; +import net.tinyos.util.*; + +public class FtspDataLogger implements MessageListener { + public class RunWhenShuttingDown extends Thread { + public void run() + { + System.out.println("Control-C caught. Shutting down..."); + if (outReport!=null) + outReport.close(); + } + } + + MoteIF mote; // For talking to the antitheft root node + + void connect() + { + try { + mote = new MoteIF(PrintStreamMessenger.err); + mote.registerListener(new TestFtspMsg(), this); + System.out.println("Connection ok!"); + } + catch(Exception e) { + e.printStackTrace(); + System.exit(2); + } + } + PrintStream outReport = null; + + public FtspDataLogger() { + connect(); + Runtime.getRuntime().addShutdownHook(new RunWhenShuttingDown()); + String name=""+System.currentTimeMillis(); + try + { + outReport = new PrintStream(new FileOutputStream(name+".report")); + outReport.println("#[JAVA_TIME] [NODE_ID] [SEQ_NUM] [GLOB_TIME] [IS_TIME_VALID]"); + } + catch (Exception e) + { + System.out.println("FtspDataLogger.FtspDataLogger(): "+e.toString()); + } + } + + public void writeReprot(TestFtspMsg tspr) + { + String foo = (System.currentTimeMillis() + +" "+tspr.get_src_addr()+" "+tspr.get_counter() + +" "+tspr.get_global_rx_timestamp()+" "+tspr.get_is_synced()); + outReport.println(foo); + System.out.println(foo); + outReport.flush(); + } + + public void writeFullReprot(TestFtspMsg tspr) + { + String foo = (System.currentTimeMillis() + +" "+tspr.get_src_addr() + +" "+tspr.get_counter() + +" "+tspr.get_local_rx_timestamp() + +" "+tspr.get_global_rx_timestamp() + +" "+tspr.get_skew_times_1000000() + +" "+tspr.get_is_synced() + +" "+tspr.get_ftsp_root_addr() + +" "+tspr.get_ftsp_seq() + +" "+tspr.get_ftsp_table_entries()); + outReport.println(foo); + System.out.println(foo); + outReport.flush(); + } + + public void messageReceived(int dest_addr, Message msg) + { + if (msg instanceof TestFtspMsg) + //writeFullReprot((TestFtspMsg)msg); + writeReprot((TestFtspMsg)msg); + } + + /* Just start the app... */ + public static void main(String[] args) + { + new FtspDataLogger(); + } +} \ No newline at end of file diff --git a/apps/tests/TestFtsp/Makefile b/apps/tests/TestFtsp/Makefile new file mode 100644 index 00000000..eb8f79a6 --- /dev/null +++ b/apps/tests/TestFtsp/Makefile @@ -0,0 +1,17 @@ +BUILD_EXTRA_DEPS = FtspDataLogger.class +CLEAN_EXTRA = *.class TestFtspMsg.java + +FtspDataLogger.class: TestFtspMsg.java + javac *.java + +TestFtspMsg.java: TestFtsp.h + mig java -target=$(PLATFORM) $(CFLAGS) -java-classname=TestFtspMsg TestFtsp.h test_ftsp_msg -o $@ + +COMPONENT=TestFtspC + +PFLAGS += -DTIMESYNC_RATE=3 +#PFLAGS += -DTIMESYNC_DEBUG + +PFLAGS += -I$(TOSDIR)/lib/ftsp -I$(TOSDIR)/../apps/RadioCountToLeds + +include $(MAKERULES) diff --git a/apps/tests/TestFtsp/README.txt b/apps/tests/TestFtsp/README.txt new file mode 100644 index 00000000..23ca3644 --- /dev/null +++ b/apps/tests/TestFtsp/README.txt @@ -0,0 +1,88 @@ +TestFtsp + +------------------------------------------------------------------------------- +Author/Contact: +--------------- + Brano Kusy: branislav.kusy@gmail.com + Janos Sallai: janos.sallai@vanderbilt.edu + Miklos Maroti: mmaroti@gmail.com + +------------------------------------------------------------------------------- +DESCRIPTION: +------------ + The TestFtsp application tests the Flooding Time Synchronization Protocol + (FTSP) implementation. A network of motes programmed with TestFtsp run the + FTSP protocol to time synchronize, and sends to the base station the global + reception timestamps of messages broadcast by a dedicated beacon mote + programmed with RadioCountToLeds. Ideally, the global reception timestamps of + the same RadioCountToLeds message should agree for all TestFtsp motes (with a + small synchronization error). + +------------------------------------------------------------------------------- +SUPPORTED PLATFORMS: +-------------------------------------------- + The supported platforms are micaz, telosb and iris. + +------------------------------------------------------------------------------- +STEP BY STEP GUIDE TO RUN OUR TEST SCENARIO: +-------------------------------------------- + - program one mote with apps/RadioCountToLeds + - program multiple motes with TestFtsp + - program a mote with apps/BaseStation, leave it on the programming board + - turn on all the motes + - start the FtspDataLogger java application (type "java FtspDataLogger") + +------------------------------------------------------------------------------- +REPORTED DATA: +-------------- + The most important reported data is the global time of arrival of the beacons. + The beacon msg arrives to all clients at the same time instant, thus reported + global times should be the same for all clients for the same sequence number. + + Each message contains: + - the time of message reception by the java app [JAVA_TIME] + - the node ID of the mote that is sending this report [NODE_ID] + - the sequence number of the RadioCountToLeds message that is increased + for each new polling msg [SEQ_NUM] + - the global time when the polling message arrived [GLOB_TIME] + - a result_t value indicating if the timestamp is valid [IS_TIME_VALID] + (a result_t of 0 denotes a valid timestamp) + +If the application is running correctly, then the output should show +reports from the different FTSP nodes with valid timestamps and similar +global time values. For example, this is a trace with two FTSP nodes, +with IDs 1 and 5: + +1214516486569 1 10916 433709 0 +1214516486569 5 10916 433709 0 +1214516486809 5 10917 433964 0 +1214516486809 1 10917 433963 0 +1214516487045 5 10918 434210 0 +1214516487053 1 10918 434210 0 +1214516487285 1 10919 434454 0 +1214516487293 5 10919 434455 0 + +One way to test if FTSP is operating correctly is to turn off one of +the FTSP nodes. For a short time, that node's global times will differ +significantly and its valid flag will not be 0. For example, this +is what it looks like when node 1 in the earlier trace is reset: + +1214516490953 5 10934 438208 0 +1214516491201 5 10935 438460 0 +1214516491441 5 10936 438712 0 +1214516491685 5 10937 438964 0 +1214516492169 5 10939 439455 0 +1214516492417 1 10940 243 1 +1214516492421 5 10940 439706 0 +1214516492665 5 10941 439960 0 +1214516492669 1 10941 497 1 +1214516492905 5 10942 440213 0 +... +1214516497541 1 10961 5495 1 +1214516497549 5 10961 444958 0 +1214516497793 1 10962 5747 1 +1214516498025 1 10963 445456 0 +1214516498033 5 10963 445455 0 +1214516498277 5 10964 445705 0 +1214516498285 1 10964 445707 0 +1214516498521 1 10965 445964 0 diff --git a/apps/tests/TestFtsp/TestFtsp.h b/apps/tests/TestFtsp/TestFtsp.h new file mode 100644 index 00000000..c5ded365 --- /dev/null +++ b/apps/tests/TestFtsp/TestFtsp.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2002, Vanderbilt University + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT + * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * @author: Miklos Maroti, Brano Kusy (kusy@isis.vanderbilt.edu) + * Ported to T2: 3/17/08 by Brano Kusy (branislav.kusy@gmail.com) + */ + +#ifndef TEST_FTSP_H +#define TEST_FTSP_H + +typedef nx_struct test_ftsp_msg +{ + nx_uint16_t src_addr; + nx_uint16_t counter; + nx_uint32_t local_rx_timestamp; + nx_uint32_t global_rx_timestamp; + nx_uint32_t skew_times_1000000; + nx_uint8_t is_synced; + nx_uint16_t ftsp_root_addr; + nx_uint8_t ftsp_seq; + nx_uint8_t ftsp_table_entries; +} test_ftsp_msg_t; + +enum +{ + AM_TEST_FTSP_MSG = 137 +}; + +#endif diff --git a/apps/tests/TestFtsp/TestFtspAppC.nc b/apps/tests/TestFtsp/TestFtspAppC.nc new file mode 100644 index 00000000..11d8ea8d --- /dev/null +++ b/apps/tests/TestFtsp/TestFtspAppC.nc @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2002, Vanderbilt University + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT + * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * @author: Miklos Maroti, Brano Kusy (kusy@isis.vanderbilt.edu) + * Ported to T2: 3/17/08 by Brano Kusy (branislav.kusy@gmail.com) + */ + +#include "TestFtsp.h" +#include "RadioCountToLeds.h" + +module TestFtspAppC +{ + uses + { + interface GlobalTime; + interface TimeSyncInfo; + interface Receive; + interface AMSend; + interface Packet; + interface Leds; + interface PacketTimeStamp; + interface Boot; + interface SplitControl as RadioControl; + } +} + +implementation +{ + message_t msg; + bool locked = FALSE; + + event void Boot.booted() { + call RadioControl.start(); + } + + event message_t* Receive.receive(message_t* msgPtr, void* payload, uint8_t len) + { + call Leds.led0Toggle(); + if (!locked && call PacketTimeStamp.isValid(msgPtr)) { + radio_count_msg_t* rcm = (radio_count_msg_t*)call Packet.getPayload(msgPtr, sizeof(radio_count_msg_t)); + test_ftsp_msg_t* report = (test_ftsp_msg_t*)call Packet.getPayload(&msg, sizeof(test_ftsp_msg_t)); + + uint32_t rxTimestamp = call PacketTimeStamp.timestamp(msgPtr); + + report->src_addr = TOS_NODE_ID; + report->counter = rcm->counter; + report->local_rx_timestamp = rxTimestamp; + report->is_synced = call GlobalTime.local2Global(&rxTimestamp); + report->global_rx_timestamp = rxTimestamp; + report->skew_times_1000000 = (uint32_t)call TimeSyncInfo.getSkew()*1000000UL; + report->ftsp_root_addr = call TimeSyncInfo.getRootID(); + report->ftsp_seq = call TimeSyncInfo.getSeqNum(); + report->ftsp_table_entries = call TimeSyncInfo.getNumEntries(); + + if (call AMSend.send(AM_BROADCAST_ADDR, &msg, sizeof(test_ftsp_msg_t)) == SUCCESS) { + locked = TRUE; + } + } + + return msgPtr; + } + + event void AMSend.sendDone(message_t* ptr, error_t success) { + locked = FALSE; + return; + } + + event void RadioControl.startDone(error_t err) {} + event void RadioControl.stopDone(error_t error){} +} diff --git a/apps/tests/TestFtsp/TestFtspC.nc b/apps/tests/TestFtsp/TestFtspC.nc new file mode 100644 index 00000000..e0a0ea2c --- /dev/null +++ b/apps/tests/TestFtsp/TestFtspC.nc @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2002, Vanderbilt University + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT + * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * @author: Miklos Maroti, Brano Kusy (kusy@isis.vanderbilt.edu) + * Ported to T2: 3/17/08 by Brano Kusy (branislav.kusy@gmail.com) + */ + +#include "TestFtsp.h" +#include "RadioCountToLeds.h" + +configuration TestFtspC { +} + +implementation { + components MainC, TimeSyncC; + + MainC.SoftwareInit -> TimeSyncC; + TimeSyncC.Boot -> MainC; + + components TestFtspAppC as App; + App.Boot -> MainC; + + components ActiveMessageC; + App.RadioControl -> ActiveMessageC; + App.Receive -> ActiveMessageC.Receive[AM_RADIO_COUNT_MSG]; + App.AMSend -> ActiveMessageC.AMSend[AM_TEST_FTSP_MSG]; + App.Packet -> ActiveMessageC; + App.PacketTimeStamp -> ActiveMessageC; + + components LedsC; + + App.GlobalTime -> TimeSyncC; + App.TimeSyncInfo -> TimeSyncC; + App.Leds -> LedsC; + +} diff --git a/apps/tests/TestLPL/Makefile b/apps/tests/TestLPL/Makefile deleted file mode 100644 index 1c579628..00000000 --- a/apps/tests/TestLPL/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -COMPONENT=TestLplAppC - -include $(MAKERULES) - diff --git a/apps/tests/TestLPL/README.txt b/apps/tests/TestLPL/README.txt deleted file mode 100644 index 1add1755..00000000 --- a/apps/tests/TestLPL/README.txt +++ /dev/null @@ -1,57 +0,0 @@ -README for TestLPL -Author/Contact: tinyos-help@millennium.berkeley.edu - -Description: - -A simple low-power-listening test app, which cycles through different -low-power-listening settings every ~32s, repeating every ~256s. - -This application currently runs on motes using the CC1000, CC2420 and -RF230 radios. To compile for motes with CC2420 or RF230 radios, you -must do: - env CFLAGS="-DLOW_POWER_LISTENING" make - -This application blinks LED 0 every time it sends a message, and toggles -LED 1 every time it receives a message. If this application is -working correctly (see caveat about timing below), you should see -both nodes toggling LED 1. - -Its low-power-listening settings are as follows (repeating every 256s): - -0-32s: receive: fully on - send: every second, to fully on listener - -32-64s: receive: fully on - send: every second, to low-power-listeners with 100ms interval - -64-96s: receive: low-power-listening with 250ms interval - send: every second, to low-power-listeners with 250ms interval - -96-128s: receive: low-power-listening with 250ms interval - send: every second, to fully on listener - -128-160s: receive: low-power-listening with 10ms interval - send: every second, to low-power-listeners with 10ms interval - -160-192s: receive: low-power-listening with 2000ms interval - send: every 7 seconds, to low-power-listeners with 2000ms interval - -192-224s: receive: low-power-listening with 1% duty cycle - send: every 7 seconds, to low-power-listeners with 1% duty cycle - -224-256s: receive: low-power-listening with 0.1% duty cycle - send: every 7 seconds, to low-power-listeners with 0.1% duty cycle - -Whether two motes running TestLPL can receive each others messages depends -on their current send and receive low-power-listening settings. If you reset -two such motes at the same time, they will be able to receive each other's -messages in the following intervals: 0-96s and 128-256s. - -Tools: - -None. - -Known bugs/limitations: - -None. - diff --git a/apps/tests/TestLPL/TestLplAppC.nc b/apps/tests/TestLPL/TestLplAppC.nc deleted file mode 100644 index 5c3e29b9..00000000 --- a/apps/tests/TestLPL/TestLplAppC.nc +++ /dev/null @@ -1,66 +0,0 @@ -// $Id$ - -/* tab:4 - * "Copyright (c) 2000-2005 The Regents of the University of California. - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose, without fee, and without written agreement is - * hereby granted, provided that the above copyright notice, the following - * two paragraphs and the author appear in all copies of this software. - * - * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT - * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF - * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." - * - * Copyright (c) 2002-2005 Intel Corporation - * All rights reserved. - * - * This file is distributed under the terms in the attached INTEL-LICENSE - * file. If you do not find these files, copies can be found by writing to - * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, - * 94704. Attention: Intel License Inquiry. - */ - -/** - * Simple test code for low-power-listening. Sends a sequence of packets, - * changing the low-power-listening settings every ~32s. See README.txt - * for more details. - * - * @author Philip Levis, David Gay - * @date Oct 27 2006 - */ - -configuration TestLplAppC {} -implementation { - components MainC, TestLplC as App, LedsC; - components ActiveMessageC; - components new TimerMilliC(); -#if defined(PLATFORM_MICA2) || defined(PLATFORM_MICA2DOT) - components CC1000CsmaRadioC as LplRadio; -#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_TELOSB) || defined(PLATFORM_SHIMMER) || defined(PLATFORM_INTELMOTE2) - components CC2420ActiveMessageC as LplRadio; -#elif defined(PLATFORM_IRIS) - components RF230ActiveMessageC as LplRadio; -#else -#error "LPL testing not supported on this platform" -#endif - - App.Boot -> MainC.Boot; - - App.Receive -> ActiveMessageC.Receive[240]; - App.AMSend -> ActiveMessageC.AMSend[240]; - App.SplitControl -> ActiveMessageC; - App.Leds -> LedsC; - App.MilliTimer -> TimerMilliC; - App.LowPowerListening -> LplRadio; -} - - diff --git a/apps/tests/TestLPL/TestLplC.nc b/apps/tests/TestLPL/TestLplC.nc deleted file mode 100644 index 0920f136..00000000 --- a/apps/tests/TestLPL/TestLplC.nc +++ /dev/null @@ -1,144 +0,0 @@ -// $Id$ - -/* tab:4 - * "Copyright (c) 2000-2005 The Regents of the University of California. - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose, without fee, and without written agreement is - * hereby granted, provided that the above copyright notice, the following - * two paragraphs and the author appear in all copies of this software. - * - * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT - * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF - * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." - * - * Copyright (c) 2002-2003 Intel Corporation - * All rights reserved. - * - * This file is distributed under the terms in the attached INTEL-LICENSE - * file. If you do not find these files, copies can be found by writing to - * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, - * 94704. Attention: Intel License Inquiry. - */ - -#include "Timer.h" - -/** - * Simple test code for low-power-listening. Sends a sequence of packets, - * changing the low-power-listening settings every ~32s. See README.txt - * for more details. - * - * @author Philip Levis, David Gay - * @date Oct 27 2006 - */ - -module TestLplC { - uses { - interface Leds; - interface Boot; - interface Receive; - interface AMSend; - interface Timer as MilliTimer; - interface SplitControl; - interface LowPowerListening; - } -} -implementation -{ - message_t packet; - bool locked; - uint8_t counter = 0, sendSkip; - int16_t sendInterval; - - event void Boot.booted() { - call SplitControl.start(); - } - - void nextLplState() - { - switch (counter >> 5) { - case 0: - sendSkip = 0; - sendInterval = 0; - call LowPowerListening.setLocalSleepInterval(0); - break; - case 1: - sendInterval = 100; /* Send to sleepy listener */ - break; - case 2: - sendInterval = -1; /* Send to listener like us */ - call LowPowerListening.setLocalSleepInterval(250); - break; - case 3: - sendInterval = 0; /* Send to awake listener */ - break; - case 4: - sendInterval = -1; /* Send to listener like us */ - call LowPowerListening.setLocalSleepInterval(10); - break; - case 5: - sendSkip = 7; /* Send every 7s */ - call LowPowerListening.setLocalSleepInterval(2000); - break; - case 6: - call LowPowerListening.setLocalDutyCycle(100); - break; - case 7: - call LowPowerListening.setLocalDutyCycle(10); - break; - } - } - - event void MilliTimer.fired() - { - counter++; - if (!(counter & 31)) - nextLplState(); - - if (!locked && ((counter & sendSkip) == sendSkip)) - { - if (sendInterval >= 0) - call LowPowerListening.setRxSleepInterval(&packet, sendInterval); - if (call AMSend.send(AM_BROADCAST_ADDR, &packet, 0) == SUCCESS) - { - call Leds.led0On(); - locked = TRUE; - } - } - } - - event message_t* Receive.receive(message_t* bufPtr, - void* payload, uint8_t len) - { - call Leds.led1Toggle(); - return bufPtr; - } - - event void AMSend.sendDone(message_t* bufPtr, error_t error) - { - if (&packet == bufPtr) - { - locked = FALSE; - call Leds.led0Off(); - } - } - - event void SplitControl.startDone(error_t err) - { - call MilliTimer.startPeriodic(1000); - } - - event void SplitControl.stopDone(error_t err) { } -} - - - - diff --git a/apps/tests/TestLpl/Makefile b/apps/tests/TestLpl/Makefile new file mode 100644 index 00000000..1c579628 --- /dev/null +++ b/apps/tests/TestLpl/Makefile @@ -0,0 +1,4 @@ +COMPONENT=TestLplAppC + +include $(MAKERULES) + diff --git a/apps/tests/TestLpl/README.txt b/apps/tests/TestLpl/README.txt new file mode 100644 index 00000000..1add1755 --- /dev/null +++ b/apps/tests/TestLpl/README.txt @@ -0,0 +1,57 @@ +README for TestLPL +Author/Contact: tinyos-help@millennium.berkeley.edu + +Description: + +A simple low-power-listening test app, which cycles through different +low-power-listening settings every ~32s, repeating every ~256s. + +This application currently runs on motes using the CC1000, CC2420 and +RF230 radios. To compile for motes with CC2420 or RF230 radios, you +must do: + env CFLAGS="-DLOW_POWER_LISTENING" make + +This application blinks LED 0 every time it sends a message, and toggles +LED 1 every time it receives a message. If this application is +working correctly (see caveat about timing below), you should see +both nodes toggling LED 1. + +Its low-power-listening settings are as follows (repeating every 256s): + +0-32s: receive: fully on + send: every second, to fully on listener + +32-64s: receive: fully on + send: every second, to low-power-listeners with 100ms interval + +64-96s: receive: low-power-listening with 250ms interval + send: every second, to low-power-listeners with 250ms interval + +96-128s: receive: low-power-listening with 250ms interval + send: every second, to fully on listener + +128-160s: receive: low-power-listening with 10ms interval + send: every second, to low-power-listeners with 10ms interval + +160-192s: receive: low-power-listening with 2000ms interval + send: every 7 seconds, to low-power-listeners with 2000ms interval + +192-224s: receive: low-power-listening with 1% duty cycle + send: every 7 seconds, to low-power-listeners with 1% duty cycle + +224-256s: receive: low-power-listening with 0.1% duty cycle + send: every 7 seconds, to low-power-listeners with 0.1% duty cycle + +Whether two motes running TestLPL can receive each others messages depends +on their current send and receive low-power-listening settings. If you reset +two such motes at the same time, they will be able to receive each other's +messages in the following intervals: 0-96s and 128-256s. + +Tools: + +None. + +Known bugs/limitations: + +None. + diff --git a/apps/tests/TestLpl/TestLplAppC.nc b/apps/tests/TestLpl/TestLplAppC.nc new file mode 100644 index 00000000..5c3e29b9 --- /dev/null +++ b/apps/tests/TestLpl/TestLplAppC.nc @@ -0,0 +1,66 @@ +// $Id$ + +/* tab:4 + * "Copyright (c) 2000-2005 The Regents of the University of California. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF + * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." + * + * Copyright (c) 2002-2005 Intel Corporation + * All rights reserved. + * + * This file is distributed under the terms in the attached INTEL-LICENSE + * file. If you do not find these files, copies can be found by writing to + * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, + * 94704. Attention: Intel License Inquiry. + */ + +/** + * Simple test code for low-power-listening. Sends a sequence of packets, + * changing the low-power-listening settings every ~32s. See README.txt + * for more details. + * + * @author Philip Levis, David Gay + * @date Oct 27 2006 + */ + +configuration TestLplAppC {} +implementation { + components MainC, TestLplC as App, LedsC; + components ActiveMessageC; + components new TimerMilliC(); +#if defined(PLATFORM_MICA2) || defined(PLATFORM_MICA2DOT) + components CC1000CsmaRadioC as LplRadio; +#elif defined(PLATFORM_MICAZ) || defined(PLATFORM_TELOSB) || defined(PLATFORM_SHIMMER) || defined(PLATFORM_INTELMOTE2) + components CC2420ActiveMessageC as LplRadio; +#elif defined(PLATFORM_IRIS) + components RF230ActiveMessageC as LplRadio; +#else +#error "LPL testing not supported on this platform" +#endif + + App.Boot -> MainC.Boot; + + App.Receive -> ActiveMessageC.Receive[240]; + App.AMSend -> ActiveMessageC.AMSend[240]; + App.SplitControl -> ActiveMessageC; + App.Leds -> LedsC; + App.MilliTimer -> TimerMilliC; + App.LowPowerListening -> LplRadio; +} + + diff --git a/apps/tests/TestLpl/TestLplC.nc b/apps/tests/TestLpl/TestLplC.nc new file mode 100644 index 00000000..0920f136 --- /dev/null +++ b/apps/tests/TestLpl/TestLplC.nc @@ -0,0 +1,144 @@ +// $Id$ + +/* tab:4 + * "Copyright (c) 2000-2005 The Regents of the University of California. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF + * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." + * + * Copyright (c) 2002-2003 Intel Corporation + * All rights reserved. + * + * This file is distributed under the terms in the attached INTEL-LICENSE + * file. If you do not find these files, copies can be found by writing to + * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA, + * 94704. Attention: Intel License Inquiry. + */ + +#include "Timer.h" + +/** + * Simple test code for low-power-listening. Sends a sequence of packets, + * changing the low-power-listening settings every ~32s. See README.txt + * for more details. + * + * @author Philip Levis, David Gay + * @date Oct 27 2006 + */ + +module TestLplC { + uses { + interface Leds; + interface Boot; + interface Receive; + interface AMSend; + interface Timer as MilliTimer; + interface SplitControl; + interface LowPowerListening; + } +} +implementation +{ + message_t packet; + bool locked; + uint8_t counter = 0, sendSkip; + int16_t sendInterval; + + event void Boot.booted() { + call SplitControl.start(); + } + + void nextLplState() + { + switch (counter >> 5) { + case 0: + sendSkip = 0; + sendInterval = 0; + call LowPowerListening.setLocalSleepInterval(0); + break; + case 1: + sendInterval = 100; /* Send to sleepy listener */ + break; + case 2: + sendInterval = -1; /* Send to listener like us */ + call LowPowerListening.setLocalSleepInterval(250); + break; + case 3: + sendInterval = 0; /* Send to awake listener */ + break; + case 4: + sendInterval = -1; /* Send to listener like us */ + call LowPowerListening.setLocalSleepInterval(10); + break; + case 5: + sendSkip = 7; /* Send every 7s */ + call LowPowerListening.setLocalSleepInterval(2000); + break; + case 6: + call LowPowerListening.setLocalDutyCycle(100); + break; + case 7: + call LowPowerListening.setLocalDutyCycle(10); + break; + } + } + + event void MilliTimer.fired() + { + counter++; + if (!(counter & 31)) + nextLplState(); + + if (!locked && ((counter & sendSkip) == sendSkip)) + { + if (sendInterval >= 0) + call LowPowerListening.setRxSleepInterval(&packet, sendInterval); + if (call AMSend.send(AM_BROADCAST_ADDR, &packet, 0) == SUCCESS) + { + call Leds.led0On(); + locked = TRUE; + } + } + } + + event message_t* Receive.receive(message_t* bufPtr, + void* payload, uint8_t len) + { + call Leds.led1Toggle(); + return bufPtr; + } + + event void AMSend.sendDone(message_t* bufPtr, error_t error) + { + if (&packet == bufPtr) + { + locked = FALSE; + call Leds.led0Off(); + } + } + + event void SplitControl.startDone(error_t err) + { + call MilliTimer.startPeriodic(1000); + } + + event void SplitControl.stopDone(error_t err) { } +} + + + +