[Tinyos-2-commits] CVS: tinyos-2.x/apps/UDPEcho Makefile, NONE, 1.1 Makefile.local, NONE, 1.1 README, NONE, 1.1 UDPEchoC.nc, NONE, 1.1 UDPEchoP.nc, NONE, 1.1 UDPReport.h, NONE, 1.1 volumes-at45db.xml, NONE, 1.1 volumes-stm25p.xml, NONE, 1.1

sdhsdh sdhsdh at users.sourceforge.net
Mon Jan 19 16:33:24 PST 2009


Update of /cvsroot/tinyos/tinyos-2.x/apps/UDPEcho
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv7358/UDPEcho

Added Files:
	Makefile Makefile.local README UDPEchoC.nc UDPEchoP.nc 
	UDPReport.h volumes-at45db.xml volumes-stm25p.xml 
Log Message:
 - commit blip stack apps



--- NEW FILE: Makefile ---
COMPONENT=UDPEchoC

# uncomment this for network programming support
# BOOTLOADER=tosboot

# radio opts
CFLAGS += -DCC2420_DEF_CHANNEL=15
# CFLAGS += -DCC2420_DEF_RFPOWER=4

# if this is set, motes will send debugging information to the address
# listed.
# CFLAGS += -DREPORT_DEST=\"2001:470:1f04:56d::64\"

# sim/test harness
# CFLAGS += -I../IPBaseStation
# CFLAGS += -DDBG_TRACK_FLOWS -DDBG_FLOWS_REPORT

# printf debugs.  works only on telosb/tmote sky
# CFLAGS += -DPRINTFUART_ENABLED


include $(MAKERULES)


--- NEW FILE: Makefile.local ---
# -*- makefile -*-

SOURCES=$(LOWPAN_ROOT)/support/sdk/c/lib6lowpan/lib6lowpan.c  \
	$(LOWPAN_ROOT)/support/sdk/c/lib6lowpan/lib6lowpanIP.c \
	$(LOWPAN_ROOT)/support/sdk/c/lib6lowpan/lib6lowpanFrag.c \
	$(LOWPAN_ROOT)/support/sdk/c/lib6lowpan/in_cksum.c \
	$(LOWPAN_ROOT)/support/sdk/c/lib6lowpan/ip_malloc.c \
	$(LOWPAN_ROOT)/tos/lib/net/b6lowpan/table.c
OBJS=$(SOURCES:%.c=%.o)

remake: $(OBJS)
	make micaz sim-sf lowpan
	g++ -shared -fPIC  simbuild/micaz/pytossim.o simbuild/micaz/sim.o simbuild/micaz/tossim.o simbuild/micaz/c-support.o simbuild/micaz/c-sf.o simbuild/micaz/sf.o simbuild/micaz/throttle.o $(OBJS) -lstdc++  -lm -o _TOSSIMmodule.so
	make -f Makefile.local cppdriver

cppdriver:
	g++ -g -c -o sim/Driver.o sim/Driver.c -I$(TOSROOT)/tos/lib/tossim/
	g++ -o sim/Driver sim/Driver.o simbuild/micaz/tossim.o simbuild/micaz/sim.o simbuild/micaz/c-support.o simbuild/micaz/c-sf.o simbuild/micaz/sf.o simbuild/micaz/throttle.o $(OBJS)
# simbuild/micaz/c-sf.o       simbuild/micaz/pytossim.o  simbuild/micaz/sim.o       simbuild/micaz/tossim.o
# simbuild/micaz/c-support.o  simbuild/micaz/sf.o        simbuild/micaz/throttle.o



clean:
	rm $(OBJS)

%.o: %.c
	$(CC) -c -fPIC -o $@ $<

msg:	
	mig -DMIG -I$(LOWPAN_ROOT)/tos/lib/net/b6lowpan -I$(LOWPAN_ROOT)/support/sdk/c/lib6lowpan  python -python-classname=UdpReport UDPReport.h udp_report -o UdpReport.py
	mig -DMIG -I$(LOWPAN_ROOT)/tos/lib/net/b6lowpan -I$(LOWPAN_ROOT)/support/sdk/c/lib6lowpan  python -python-classname=TestDriverMsg TestDriver.h testdriver_msg -o TestDriverMsg.py

--- NEW FILE: README ---

 A simple application which verifies the 6loWPAN stack is functioning
correctly.  A mote running this will respond to ICMP Echo requests
(0x80), and provide a UDP echo service on port 7 (a la rfc862).



--- NEW FILE: UDPEchoC.nc ---
/*
 * "Copyright (c) 2008 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."
 *
 */

#include <6lowpan.h>
#include "TestDriver.h"

configuration UDPEchoC {

} implementation {
  components MainC, LedsC;
  components UDPEchoP;

  UDPEchoP.Boot -> MainC;
  UDPEchoP.Leds -> LedsC;

  components new TimerMilliC();
  components IPDispatchC;

  UDPEchoP.RadioControl -> IPDispatchC;
  components new UdpSocketC() as Echo,
    new UdpSocketC() as Status;
  UDPEchoP.Echo -> Echo;

  UDPEchoP.Status -> Status;

  UDPEchoP.StatusTimer -> TimerMilliC;

  UDPEchoP.IPStats -> IPDispatchC.IPStats;
  UDPEchoP.RouteStats -> IPDispatchC.RouteStats;
  UDPEchoP.ICMPStats -> IPDispatchC.ICMPStats;

  components RandomC;
  UDPEchoP.Random -> RandomC;

  components UDPShellC;

#ifdef SIM
  components BaseStationC;
#endif
#ifdef DBG_TRACK_FLOWS
  components TestDriverP, SerialActiveMessageC as Serial;
  components ICMPResponderC, IPRoutingP;
  components new TimerMilliC() as Mark;
  TestDriverP.Boot -> MainC;
  TestDriverP.SerialControl -> Serial;
  TestDriverP.ICMPPing -> ICMPResponderC.ICMPPing[unique("PING")];
  TestDriverP.CmdReceive -> Serial.Receive[AM_TESTDRIVER_MSG];
  TestDriverP.IPRouting -> IPRoutingP;
  TestDriverP.DoneSend -> Serial.AMSend[AM_TESTDRIVER_MSG];
  TestDriverP.RadioControl -> IPDispatchC;
  TestDriverP.MarkTimer -> Mark;
#endif
}

--- NEW FILE: UDPEchoP.nc ---
/*
 * "Copyright (c) 2008 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."
 *
 */

#include <IPDispatch.h>
#include <lib6lowpan.h>
#include <ip.h>
#include <lib6lowpan.h>
#include <ip.h>

#include "UDPReport.h"
#include "PrintfUART.h"

#define REPORT_PERIOD 45L

module UDPEchoP {
  uses {
    interface Boot;
    interface SplitControl as RadioControl;

    interface UDP as Echo;
    interface UDP as Status;

    interface Leds;
    
    interface Timer<TMilli> as StatusTimer;
   
    interface Statistics<ip_statistics_t> as IPStats;
    interface Statistics<route_statistics_t> as RouteStats;
    interface Statistics<icmp_statistics_t> as ICMPStats;

    interface Random;
  }

} implementation {

  bool timerStarted;
  udp_statistics_t stats;
  struct sockaddr_in6 route_dest;

#ifndef SIM
#define CHECK_NODE_ID
#else
#define CHECK_NODE_ID if (TOS_NODE_ID == BASESTATION_ID) return
#endif

  event void Boot.booted() {
    CHECK_NODE_ID;
    call RadioControl.start();
    timerStarted = FALSE;

    call IPStats.clear();
    call RouteStats.clear();
    call ICMPStats.clear();
    printfUART_init();

    stats.total = 0;
    stats.failed = 0;

#ifdef REPORT_DEST
    route_dest.sin6_port = hton16(7000);
    inet6_aton(REPORT_DEST, &route_dest.sin6_addr);
    call StatusTimer.startOneShot(call Random.rand16() % (1024 * REPORT_PERIOD));
#endif

    dbg("Boot", "booted: %i\n", TOS_NODE_ID);
    call Echo.bind(7);
    call Status.bind(7001);
  }

  event void RadioControl.startDone(error_t e) {

  }

  event void RadioControl.stopDone(error_t e) {

  }

  event void Status.recvfrom(struct sockaddr_in6 *from, void *data, 
                             uint16_t len, struct ip_metadata *meta) {

  }

  event void Echo.recvfrom(struct sockaddr_in6 *from, void *data, 
                           uint16_t len, struct ip_metadata *meta) {
    CHECK_NODE_ID;
    call Echo.sendto(from, data, len);
  }

  enum {
    STATUS_SIZE = // sizeof(ip_statistics_t) + 
    sizeof(route_statistics_t) +
    sizeof(icmp_statistics_t) + sizeof(udp_statistics_t),
  };


  event void StatusTimer.fired() {
    uint8_t status[STATUS_SIZE];
    nx_struct udp_report *payload;
    CHECK_NODE_ID;

    stats.total++;
    
    if (!timerStarted) {
      call StatusTimer.startPeriodic(1024 * REPORT_PERIOD);
      timerStarted = TRUE;
    }

    payload = (nx_struct udp_report *)status;
    
    stats.seqno++;
    stats.sender = TOS_NODE_ID;

    // memcpy(&payload->ip,    call IPStats.get(),    sizeof(ip_statistics_t));
    call RouteStats.get(&payload->route);
    call ICMPStats.get(&payload->icmp);
    memcpy(&payload->udp,   &stats,                sizeof(udp_statistics_t));

    call Status.sendto(&route_dest, status, STATUS_SIZE);
  }
}

--- NEW FILE: UDPReport.h ---
/*
 * "Copyright (c) 2008 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."
 *
 */
#ifndef _UDPREPORT_H
#define _UDPREPORT_H

#include <IPDispatch.h>

nx_struct udp_report {
  // ip_statistics_t    ip;
  udp_statistics_t   udp;
  icmp_statistics_t  icmp;
  route_statistics_t route;
} ;

#endif

--- NEW FILE: volumes-at45db.xml ---
<volume_table>
  <volume name="GOLDENIMAGE" size="65536" base="0" />
  <volume name="DELUGE1" size="65536"/>
  <volume name="DELUGE2" size="65536"/>
  <volume name="DELUGE3" size="65536"/>
</volume_table>
--- NEW FILE: volumes-stm25p.xml ---
<volume_table>
  <volume name="GOLDENIMAGE" size="65536" base="983040" />
  <volume name="DELUGE1" size="65536"/>
  <volume name="DELUGE2" size="65536"/>
  <volume name="DELUGE3" size="65536"/>
</volume_table>


More information about the Tinyos-2-commits mailing list