[Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/TestFtsp FtspDataLogger.java, NONE, 1.1 Makefile, NONE, 1.1 README.txt, NONE, 1.1 TestFtsp.h, NONE, 1.1 TestFtspAppC.nc, NONE, 1.1 TestFtspC.nc, NONE, 1.1
David Gay
idgay at users.sourceforge.net
Wed Jul 2 10:42:44 PDT 2008
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/TestFTSP FTSPDataLogger.java, 1.1, NONE Makefile, 1.3, NONE README.txt, 1.1, NONE TestFTSP.h, 1.2, NONE TestFTSPAppC.nc, 1.2, NONE TestFTSPC.nc, 1.2, NONE
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/TestLPL Makefile, 1.2, NONE README.txt, 1.5, NONE TestLplAppC.nc, 1.7, NONE TestLplC.nc, 1.4, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-2.x/apps/tests/TestFtsp
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv22967/TestFtsp
Added Files:
FtspDataLogger.java Makefile README.txt TestFtsp.h
TestFtspAppC.nc TestFtspC.nc
Log Message:
renames
--- NEW FILE: FtspDataLogger.java ---
/* 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();
}
}
--- NEW FILE: Makefile ---
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)
--- NEW FILE: README.txt ---
TestFtsp
-------------------------------------------------------------------------------
Author/Contact:
---------------
Brano Kusy: branislav.kusy at gmail.com
Janos Sallai: janos.sallai at vanderbilt.edu
Miklos Maroti: mmaroti at 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
--- NEW FILE: TestFtsp.h ---
/*
* 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 at isis.vanderbilt.edu)
* Ported to T2: 3/17/08 by Brano Kusy (branislav.kusy at 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
--- NEW FILE: TestFtspAppC.nc ---
/*
* 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 at isis.vanderbilt.edu)
* Ported to T2: 3/17/08 by Brano Kusy (branislav.kusy at gmail.com)
*/
#include "TestFtsp.h"
#include "RadioCountToLeds.h"
module TestFtspAppC
{
uses
{
interface GlobalTime<TMilli>;
interface TimeSyncInfo;
interface Receive;
interface AMSend;
interface Packet;
interface Leds;
interface PacketTimeStamp<TMilli,uint32_t>;
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){}
}
--- NEW FILE: TestFtspC.nc ---
/*
* 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 at isis.vanderbilt.edu)
* Ported to T2: 3/17/08 by Brano Kusy (branislav.kusy at 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;
}
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/TestFTSP FTSPDataLogger.java, 1.1, NONE Makefile, 1.3, NONE README.txt, 1.1, NONE TestFTSP.h, 1.2, NONE TestFTSPAppC.nc, 1.2, NONE TestFTSPC.nc, 1.2, NONE
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/TestLPL Makefile, 1.2, NONE README.txt, 1.5, NONE TestLplAppC.nc, 1.7, NONE TestLplC.nc, 1.4, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-2-commits
mailing list