Bugfixes, updates
This commit is contained in:
parent
a9e8e9f4fe
commit
940da856de
27 changed files with 557 additions and 288 deletions
|
@ -3,6 +3,6 @@ ifndef TARGET
|
|||
TARGET=netsim
|
||||
endif
|
||||
all: test-abc test-meshroute test-treeroute test-trickle test-uabc \
|
||||
test-rudolph0 test-rudolph1
|
||||
test-rudolph0 test-rudolph1 test-rudolph2 test-rucb
|
||||
|
||||
include $(CONTIKI)/Makefile.include
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: test-rudolph1.c,v 1.6 2007/04/02 18:06:35 adamdunkels Exp $
|
||||
* $Id: test-rudolph1.c,v 1.7 2007/05/15 08:10:32 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,9 @@
|
|||
|
||||
#include "dev/leds.h"
|
||||
|
||||
#include "cfs/cfs-ram.h"
|
||||
#include "cfs/cfs.h"
|
||||
|
||||
#include "sys/rtimer.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -67,7 +69,7 @@ write_chunk(struct rudolph1_conn *c, int offset, int flag,
|
|||
ether_set_text(buf);
|
||||
}
|
||||
#endif /* NETSIM */
|
||||
|
||||
|
||||
if(flag == RUDOLPH1_FLAG_NEWFILE) {
|
||||
/*printf("+++ rudolph1 new file incoming at %lu\n", clock_time());*/
|
||||
leds_on(LEDS_RED);
|
||||
|
@ -80,14 +82,14 @@ write_chunk(struct rudolph1_conn *c, int offset, int flag,
|
|||
int ret;
|
||||
cfs_seek(fd, offset);
|
||||
ret = cfs_write(fd, data, datalen);
|
||||
/* printf("write_chunk wrote %d bytes at %d, %d\n", ret, offset, (unsigned char)data[0]);*/
|
||||
}
|
||||
|
||||
cfs_close(fd);
|
||||
|
||||
if(flag == RUDOLPH1_FLAG_LASTCHUNK) {
|
||||
int i;
|
||||
/* printf("+++ rudolph1 entire file received at %lu\n", clock_time());*/
|
||||
printf("+++ rudolph1 entire file received at %d, %d\n",
|
||||
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]);
|
||||
leds_off(LEDS_RED);
|
||||
leds_on(LEDS_YELLOW);
|
||||
|
||||
|
@ -96,7 +98,9 @@ write_chunk(struct rudolph1_conn *c, int offset, int flag,
|
|||
unsigned char buf;
|
||||
cfs_read(fd, &buf, 1);
|
||||
if(buf != (unsigned char)i) {
|
||||
printf("error: diff at %d, %d != %d\n", i, i, buf);
|
||||
printf("%d.%d: error: diff at %d, %d != %d\n",
|
||||
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
|
||||
i, i, buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +120,9 @@ read_chunk(struct rudolph1_conn *c, int offset, char *to, int maxsize)
|
|||
|
||||
cfs_seek(fd, offset);
|
||||
ret = cfs_read(fd, to, maxsize);
|
||||
/* printf("read_chunk %d bytes at %d, %d\n", ret, offset, (unsigned char)to[0]);*/
|
||||
/* printf("%d.%d: read_chunk %d bytes at %d, %d\n",
|
||||
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
|
||||
ret, offset, (unsigned char)to[0]);*/
|
||||
cfs_close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
@ -124,11 +130,24 @@ const static struct rudolph1_callbacks rudolph1_call = {write_chunk,
|
|||
read_chunk};
|
||||
static struct rudolph1_conn rudolph1;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "node-id.h"
|
||||
static void
|
||||
log_queuelen(struct rtimer *t, void *ptr)
|
||||
{
|
||||
#if NETSIM
|
||||
extern u8_t queuebuf_len, queuebuf_ref_len;
|
||||
node_log("%d %d\n",
|
||||
queuebuf_len,
|
||||
queuebuf_ref_len);
|
||||
rtimer_set(t, RTIMER_TIME(t) + RTIMER_ARCH_SECOND, 1,
|
||||
log_queuelen, ptr);
|
||||
#endif /* NETSIM */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
PROCESS_THREAD(test_rudolph1_process, ev, data)
|
||||
{
|
||||
static int fd;
|
||||
static struct rtimer t;
|
||||
PROCESS_EXITHANDLER(rudolph1_close(&rudolph1);)
|
||||
PROCESS_BEGIN();
|
||||
|
||||
|
@ -138,6 +157,9 @@ PROCESS_THREAD(test_rudolph1_process, ev, data)
|
|||
rudolph1_open(&rudolph1, 128, &rudolph1_call);
|
||||
button_sensor.activate();
|
||||
|
||||
rtimer_set(&t, RTIMER_NOW() + RTIMER_ARCH_SECOND, 1,
|
||||
log_queuelen, NULL);
|
||||
|
||||
PROCESS_PAUSE();
|
||||
|
||||
if(rimeaddr_node_addr.u8[0] == 1 &&
|
||||
|
|
175
examples/rime/test-rudolph2.c
Normal file
175
examples/rime/test-rudolph2.c
Normal file
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
* 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-rudolph2.c,v 1.1 2007/05/15 08:10:32 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Testing the rudolph2 code in Rime
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "net/rime/rudolph2.h"
|
||||
|
||||
#include "dev/button-sensor.h"
|
||||
|
||||
#include "dev/leds.h"
|
||||
|
||||
#include "cfs/cfs.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define FILESIZE 2000
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(test_rudolph2_process, "Rudolph2 test");
|
||||
AUTOSTART_PROCESSES(&test_rudolph2_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
write_chunk(struct rudolph2_conn *c, int offset, int flag,
|
||||
char *data, int datalen)
|
||||
{
|
||||
int fd;
|
||||
#if NETSIM
|
||||
{
|
||||
char buf[100];
|
||||
sprintf(buf, "%d%%", (100 * (offset + datalen)) / FILESIZE);
|
||||
ether_set_text(buf);
|
||||
}
|
||||
#endif /* NETSIM */
|
||||
|
||||
if(flag == RUDOLPH2_FLAG_NEWFILE) {
|
||||
/*printf("+++ rudolph2 new file incoming at %lu\n", clock_time());*/
|
||||
leds_on(LEDS_RED);
|
||||
fd = cfs_open("codeprop.out", CFS_WRITE);
|
||||
} else {
|
||||
fd = cfs_open("codeprop.out", CFS_WRITE + CFS_APPEND);
|
||||
}
|
||||
|
||||
if(datalen > 0) {
|
||||
int ret;
|
||||
cfs_seek(fd, offset);
|
||||
ret = cfs_write(fd, data, datalen);
|
||||
}
|
||||
|
||||
cfs_close(fd);
|
||||
|
||||
if(flag == RUDOLPH2_FLAG_LASTCHUNK) {
|
||||
int i;
|
||||
printf("+++ rudolph2 entire file received at %d, %d\n",
|
||||
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]);
|
||||
leds_off(LEDS_RED);
|
||||
leds_on(LEDS_YELLOW);
|
||||
|
||||
fd = cfs_open("hej", CFS_READ);
|
||||
for(i = 0; i < FILESIZE; ++i) {
|
||||
unsigned char buf;
|
||||
cfs_read(fd, &buf, 1);
|
||||
if(buf != (unsigned char)i) {
|
||||
printf("%d.%d: error: diff at %d, %d != %d\n",
|
||||
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
|
||||
i, i, buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if NETSIM
|
||||
ether_send_done();
|
||||
#endif
|
||||
cfs_close(fd);
|
||||
}
|
||||
}
|
||||
static int
|
||||
read_chunk(struct rudolph2_conn *c, int offset, char *to, int maxsize)
|
||||
{
|
||||
int fd;
|
||||
int ret;
|
||||
|
||||
fd = cfs_open("hej", CFS_READ);
|
||||
|
||||
cfs_seek(fd, offset);
|
||||
ret = cfs_read(fd, to, maxsize);
|
||||
/* printf("%d.%d: read_chunk %d bytes at %d, %d\n",
|
||||
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
|
||||
ret, offset, (unsigned char)to[0]);*/
|
||||
cfs_close(fd);
|
||||
return ret;
|
||||
}
|
||||
const static struct rudolph2_callbacks rudolph2_call = {write_chunk,
|
||||
read_chunk};
|
||||
static struct rudolph2_conn rudolph2;
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "node-id.h"
|
||||
|
||||
PROCESS_THREAD(test_rudolph2_process, ev, data)
|
||||
{
|
||||
static int fd;
|
||||
PROCESS_EXITHANDLER(rudolph2_close(&rudolph2);)
|
||||
PROCESS_BEGIN();
|
||||
|
||||
PROCESS_PAUSE();
|
||||
|
||||
|
||||
rudolph2_open(&rudolph2, 128, &rudolph2_call);
|
||||
button_sensor.activate();
|
||||
|
||||
PROCESS_PAUSE();
|
||||
|
||||
if(rimeaddr_node_addr.u8[0] == 1 &&
|
||||
rimeaddr_node_addr.u8[1] == 1) {
|
||||
{
|
||||
int i;
|
||||
|
||||
fd = cfs_open("hej", CFS_WRITE);
|
||||
for(i = 0; i < FILESIZE; i++) {
|
||||
unsigned char buf = i;
|
||||
cfs_write(fd, &buf, 1);
|
||||
}
|
||||
cfs_close(fd);
|
||||
}
|
||||
rudolph2_send(&rudolph2, CLOCK_SECOND * 2);
|
||||
#if NETSIM
|
||||
ether_send_done();
|
||||
#endif /* NETSIM */
|
||||
|
||||
}
|
||||
|
||||
while(1) {
|
||||
|
||||
PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event &&
|
||||
data == &button_sensor);
|
||||
rudolph2_stop(&rudolph2);
|
||||
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: test-trickle.c,v 1.4 2007/03/31 18:43:45 adamdunkels Exp $
|
||||
* $Id: test-trickle.c,v 1.5 2007/05/15 08:10:32 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -65,7 +65,7 @@ PROCESS_THREAD(test_trickle_process, ev, data)
|
|||
PROCESS_EXITHANDLER(trickle_close(&trickle);)
|
||||
PROCESS_BEGIN();
|
||||
|
||||
trickle_open(&trickle, 128, &trickle_call);
|
||||
trickle_open(&trickle, CLOCK_SECOND, 128, &trickle_call);
|
||||
button_sensor.activate();
|
||||
|
||||
while(1) {
|
||||
|
@ -73,7 +73,7 @@ PROCESS_THREAD(test_trickle_process, ev, data)
|
|||
data == &button_sensor);
|
||||
|
||||
rimebuf_copyfrom("Hello, world", 13);
|
||||
trickle_send(&trickle, TRICKLE_SECOND / 4);
|
||||
trickle_send(&trickle);
|
||||
|
||||
}
|
||||
PROCESS_END();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue