From 404c2cc0a32db961101307dd0c00ee1b05b27449 Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Tue, 20 Mar 2007 12:21:17 +0000 Subject: [PATCH] Moved all Rime examples into examples/rime directory --- examples/meshroute/Makefile | 5 - examples/rime/Makefile | 5 + examples/{meshroute => rime}/test-abc.c | 2 +- examples/{meshroute => rime}/test-meshroute.c | 2 +- examples/rime/test-rudolph.c | 116 ++++++++++++++++++ examples/{treeroute => rime}/test-treeroute.c | 2 +- examples/rime/test-trickle.c | 78 ++++++++++++ examples/rime/test-uabc.c | 44 +++++++ examples/treeroute/Makefile | 5 - 9 files changed, 246 insertions(+), 13 deletions(-) delete mode 100644 examples/meshroute/Makefile create mode 100644 examples/rime/Makefile rename examples/{meshroute => rime}/test-abc.c (97%) rename examples/{meshroute => rime}/test-meshroute.c (97%) create mode 100644 examples/rime/test-rudolph.c rename examples/{treeroute => rime}/test-treeroute.c (98%) create mode 100644 examples/rime/test-trickle.c create mode 100644 examples/rime/test-uabc.c delete mode 100644 examples/treeroute/Makefile diff --git a/examples/meshroute/Makefile b/examples/meshroute/Makefile deleted file mode 100644 index 13cd3eb25..000000000 --- a/examples/meshroute/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -CONTIKI = ../.. -#APPS = meshroute -all: test-meshroute - -include $(CONTIKI)/Makefile.include diff --git a/examples/rime/Makefile b/examples/rime/Makefile new file mode 100644 index 000000000..12b9c7ad3 --- /dev/null +++ b/examples/rime/Makefile @@ -0,0 +1,5 @@ +CONTIKI = ../.. +APPS = rudolph +all: test-abc test-meshroute test-rudolph test-treeroute test-trickle test-uabc + +include $(CONTIKI)/Makefile.include diff --git a/examples/meshroute/test-abc.c b/examples/rime/test-abc.c similarity index 97% rename from examples/meshroute/test-abc.c rename to examples/rime/test-abc.c index ce2c80a80..9fe6680c9 100644 --- a/examples/meshroute/test-abc.c +++ b/examples/rime/test-abc.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: test-abc.c,v 1.2 2007/03/19 19:24:36 adamdunkels Exp $ + * $Id: test-abc.c,v 1.1 2007/03/20 12:21:19 adamdunkels Exp $ */ /** diff --git a/examples/meshroute/test-meshroute.c b/examples/rime/test-meshroute.c similarity index 97% rename from examples/meshroute/test-meshroute.c rename to examples/rime/test-meshroute.c index 4a4bfa352..9bb1c4b51 100644 --- a/examples/meshroute/test-meshroute.c +++ b/examples/rime/test-meshroute.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: test-meshroute.c,v 1.2 2007/03/19 19:24:36 adamdunkels Exp $ + * $Id: test-meshroute.c,v 1.1 2007/03/20 12:21:19 adamdunkels Exp $ */ /** diff --git a/examples/rime/test-rudolph.c b/examples/rime/test-rudolph.c new file mode 100644 index 000000000..f7436717f --- /dev/null +++ b/examples/rime/test-rudolph.c @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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. + * + * This file is part of the Contiki operating system. + * + * $Id: test-rudolph.c,v 1.1 2007/03/20 12:21:19 adamdunkels Exp $ + */ + +/** + * \file + * Testing the rudolph0 code in Rime + * \author + * Adam Dunkels + */ + +#include "contiki.h" +#include "rudolph0.h" + +#include "dev/button-sensor.h" + +#include "dev/leds.h" + +#include "cfs/cfs-ram.h" + +#include +/*---------------------------------------------------------------------------*/ +PROCESS(test_rudolph0_process, "RUDOLPH0 test"); +AUTOSTART_PROCESSES(&test_rudolph0_process); +/*---------------------------------------------------------------------------*/ +static int +newfile(struct rudolph0_conn *c) +{ + printf("+++ rudolph0 new file incoming at %lu\n", clock_time()); + fflush(NULL); + return cfs_open("hej", CFS_WRITE); +} +static void +recv(struct rudolph0_conn *c, int cfs_fd) +{ + int fd; + int i; + + printf("+++ rudolph0 entire file received at %lu\n", clock_time()); + fflush(NULL); + cfs_close(cfs_fd); + + + fd = cfs_open("hej", CFS_READ); + for(i = 0; i < 200; ++i) { + unsigned char buf; + cfs_read(fd, &buf, 1); + if(buf != i) { + printf("error: diff at %d, %d != %d\n", i, i, buf); + } + } +} +const static struct rudolph0_callbacks rudolph0_call = {newfile, + recv}; +static struct rudolph0_conn rudolph0; +/*---------------------------------------------------------------------------*/ +PROCESS_THREAD(test_rudolph0_process, ev, data) +{ + PROCESS_BEGIN(); + + process_start(&cfs_ram_process, NULL); + PROCESS_PAUSE(); + + { + int i, fd; + + fd = cfs_open("hej", CFS_WRITE); + for(i = 0; i < 200; i++) { + unsigned char buf = i; + cfs_write(fd, &buf, 1); + } + cfs_close(fd); + } + + rudolph0_open(&rudolph0, 128, &rudolph0_call); + button_sensor.activate(); + + while(1) { + PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event && + data == &button_sensor); + + rudolph0_send(&rudolph0, cfs_open("hej", CFS_READ)); + + } + PROCESS_END(); +} +/*---------------------------------------------------------------------------*/ diff --git a/examples/treeroute/test-treeroute.c b/examples/rime/test-treeroute.c similarity index 98% rename from examples/treeroute/test-treeroute.c rename to examples/rime/test-treeroute.c index cfc0d1256..dc5c5bfe4 100644 --- a/examples/treeroute/test-treeroute.c +++ b/examples/rime/test-treeroute.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: test-treeroute.c,v 1.2 2007/03/19 19:24:36 adamdunkels Exp $ + * $Id: test-treeroute.c,v 1.1 2007/03/20 12:21:19 adamdunkels Exp $ */ /** diff --git a/examples/rime/test-trickle.c b/examples/rime/test-trickle.c new file mode 100644 index 000000000..c012379aa --- /dev/null +++ b/examples/rime/test-trickle.c @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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. + * + * This file is part of the Contiki operating system. + * + * $Id: test-trickle.c,v 1.1 2007/03/20 12:21:19 adamdunkels Exp $ + */ + +/** + * \file + * Testing the trickle code in Rime + * \author + * Adam Dunkels + */ + +#include "contiki.h" +#include "net/rime/trickle.h" + +#include "dev/button-sensor.h" + +#include "dev/leds.h" + +#include +/*---------------------------------------------------------------------------*/ +PROCESS(test_trickle_process, "TRICKLE test"); +AUTOSTART_PROCESSES(&test_trickle_process); +/*---------------------------------------------------------------------------*/ +static void +trickle_recv(struct trickle_conn *c) +{ + printf("trickle message received '%s'\n", (char *)rimebuf_dataptr()); +} +const static struct trickle_callbacks trickle_call = {trickle_recv}; +static struct trickle_conn trickle; +/*---------------------------------------------------------------------------*/ +PROCESS_THREAD(test_trickle_process, ev, data) +{ + PROCESS_BEGIN(); + + trickle_open(&trickle, 128, &trickle_call); + button_sensor.activate(); + + while(1) { + PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event && + data == &button_sensor); + + rimebuf_copyfrom("Hej", 4); + trickle_send(&trickle); + + } + PROCESS_END(); +} +/*---------------------------------------------------------------------------*/ diff --git a/examples/rime/test-uabc.c b/examples/rime/test-uabc.c new file mode 100644 index 000000000..62249140a --- /dev/null +++ b/examples/rime/test-uabc.c @@ -0,0 +1,44 @@ + +#include "net/rime/uabc.h" +#include "contiki.h" +/*---------------------------------------------------------------------------*/ +PROCESS(test_uabc_process, ""); +AUTOSTART_PROCESSES(&test_uabc_process); +/*---------------------------------------------------------------------------*/ +static void +recv(struct uabc_conn *c) +{ + printf("recv\n"); +} +static void +sent(struct uabc_conn *c) +{ + printf("sent\n"); +} +static void +dropped(struct uabc_conn *c) +{ + printf("dropped\n"); +} +static const struct uabc_callbacks callbacks = { recv, sent, dropped }; +/*---------------------------------------------------------------------------*/ +PROCESS_THREAD(test_uabc_process, ev, data) +{ + static struct uabc_conn c; + PROCESS_BEGIN(); + + uabc_open(&c, 128, &callbacks); + + while(1) { + static struct etimer et; + etimer_set(&et, CLOCK_SECOND * 4); + PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); + rimebuf_copyfrom("Hej", 4); + uabc_send(&c, CLOCK_SECOND); + + + } + + PROCESS_END(); +} +/*---------------------------------------------------------------------------*/ diff --git a/examples/treeroute/Makefile b/examples/treeroute/Makefile deleted file mode 100644 index 095952ac9..000000000 --- a/examples/treeroute/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -CFLAGS += -CONTIKI = /home/adam/contiki-2.x -all: test-treeroute - -include $(CONTIKI)/Makefile.include