Added Rime driver for the netsim ethernode layer, renamed init.c to netsim-init.c
This commit is contained in:
parent
11627c2406
commit
4477d81be4
10 changed files with 200 additions and 51 deletions
|
@ -12,7 +12,8 @@ SENSORS = sensors.c beep.c button-sensor.c pir-sensor.c vib-sensor.c \
|
||||||
NETSIM = ether.c ethernode.c ethernode-drv.c lpm.c \
|
NETSIM = ether.c ethernode.c ethernode-drv.c lpm.c \
|
||||||
tapdev-drv.c tapdev-service.c tapdev.c rs232.c flash.c \
|
tapdev-drv.c tapdev-service.c tapdev.c rs232.c flash.c \
|
||||||
node.c nodes.c sensor.c display.c random.c radio.c \
|
node.c nodes.c sensor.c display.c random.c radio.c \
|
||||||
dlloader.c main.c init.c contiki-main.c symtab.c symbols.c tr1001.c tr1001-drv.c
|
dlloader.c main.c netsim-init.c contiki-main.c symtab.c symbols.c tr1001.c tr1001-drv.c \
|
||||||
|
ethernode-rime.c
|
||||||
|
|
||||||
CONTIKI_TARGET_SOURCEFILES = $(NETSIM) $(SENSORS)
|
CONTIKI_TARGET_SOURCEFILES = $(NETSIM) $(SENSORS)
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ include $(CONTIKI)/cpu/x86/Makefile.x86
|
||||||
|
|
||||||
### Compiler definitions
|
### Compiler definitions
|
||||||
CC = gcc
|
CC = gcc
|
||||||
LD = ld
|
LD = gcc
|
||||||
AS = as
|
AS = as
|
||||||
OBJCOPY = objcopy
|
OBJCOPY = objcopy
|
||||||
STRIP = strip
|
STRIP = strip
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
*
|
*
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
*
|
*
|
||||||
* $Id: contiki-main.c,v 1.4 2006/10/23 09:01:06 adamdunkels Exp $
|
* $Id: contiki-main.c,v 1.5 2007/03/13 13:07:47 adamdunkels Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
|
@ -41,6 +41,7 @@
|
||||||
#include "net/tapdev-drv.h"
|
#include "net/tapdev-drv.h"
|
||||||
#include "net/tapdev-service.h"
|
#include "net/tapdev-service.h"
|
||||||
#include "net/ethernode-drv.h"
|
#include "net/ethernode-drv.h"
|
||||||
|
#include "net/ethernode-rime.h"
|
||||||
#include "net/ethernode.h"
|
#include "net/ethernode.h"
|
||||||
#include "ether.h"
|
#include "ether.h"
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ static const struct uip_eth_addr ethaddr = {{0x00,0x06,0x98,0x01,0x02,0x12}};
|
||||||
SENSORS(&button_sensor, &pir_sensor, &vib_sensor, &radio_sensor);
|
SENSORS(&button_sensor, &pir_sensor, &vib_sensor, &radio_sensor);
|
||||||
|
|
||||||
PROCINIT(&sensors_process, &etimer_process, &tcpip_process,
|
PROCINIT(&sensors_process, &etimer_process, &tcpip_process,
|
||||||
ðernode_drv_process,
|
ðernode_drv_process, ðernode_rime_process,
|
||||||
&uip_fw_process);
|
&uip_fw_process);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -166,7 +167,7 @@ contiki_main(int flag)
|
||||||
leds_green(LEDS_ON);
|
leds_green(LEDS_ON);
|
||||||
|
|
||||||
autostart_start(autostart_processes);
|
autostart_start(autostart_processes);
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
int n;
|
int n;
|
||||||
n = process_run();
|
n = process_run();
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
*
|
*
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
*
|
*
|
||||||
* $Id: ether.c,v 1.4 2006/10/23 09:01:06 adamdunkels Exp $
|
* $Id: ether.c,v 1.5 2007/03/13 13:07:47 adamdunkels Exp $
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
|
@ -205,7 +205,7 @@ ether_client_init(int port)
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
u16_t
|
u16_t
|
||||||
ether_client_poll(void)
|
ether_client_poll(u8_t *buf, int bufsize)
|
||||||
{
|
{
|
||||||
int ret, len;
|
int ret, len;
|
||||||
fd_set fdset;
|
fd_set fdset;
|
||||||
|
@ -224,14 +224,14 @@ ether_client_poll(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(FD_ISSET(sc, &fdset)) {
|
if(FD_ISSET(sc, &fdset)) {
|
||||||
ret = recv(sc, &rxbuffer[0], UIP_BUFSIZE, 0);
|
ret = recv(sc, &rxbuffer[0], bufsize, 0);
|
||||||
if(ret == -1) {
|
if(ret == -1) {
|
||||||
perror("ether_client_poll: read");
|
perror("ether_client_poll: read");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
len = ret;
|
len = ret;
|
||||||
|
|
||||||
memcpy(uip_buf, &rxbuffer[sizeof(struct ether_hdr)], len);
|
memcpy(buf, &rxbuffer[sizeof(struct ether_hdr)], len);
|
||||||
radio_sensor_signal = hdr->signal;
|
radio_sensor_signal = hdr->signal;
|
||||||
|
|
||||||
if(hdr->type == PTYPE_DATA && hdr->srcid != node.id) {
|
if(hdr->type == PTYPE_DATA && hdr->srcid != node.id) {
|
||||||
|
@ -277,13 +277,13 @@ ether_server_poll(void)
|
||||||
}
|
}
|
||||||
if(FD_ISSET(s, &fdset)) {
|
if(FD_ISSET(s, &fdset)) {
|
||||||
ret = recv(s, &rxbuffer[0], UIP_BUFSIZE, 0);
|
ret = recv(s, &rxbuffer[0], UIP_BUFSIZE, 0);
|
||||||
/* printf("ether_poll: read %d bytes from (%d, %d)\n", ret, hdr->srcx, hdr->srcy);*/
|
|
||||||
if(ret == -1) {
|
if(ret == -1) {
|
||||||
perror("ether_poll: read");
|
perror("ether_poll: read");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch(hdr->type) {
|
switch(hdr->type) {
|
||||||
case PTYPE_DATA:
|
case PTYPE_DATA:
|
||||||
|
/* printf("ether_poll: read %d bytes from (%d, %d)\n", ret, hdr->srcx, hdr->srcy);*/
|
||||||
ether_put(rxbuffer, ret, hdr->srcx, hdr->srcy);
|
ether_put(rxbuffer, ret, hdr->srcx, hdr->srcy);
|
||||||
break;
|
break;
|
||||||
case PTYPE_LEDS:
|
case PTYPE_LEDS:
|
||||||
|
@ -402,7 +402,7 @@ ether_tick(void)
|
||||||
|
|
||||||
if(interference) {
|
if(interference) {
|
||||||
num_collisions++;
|
num_collisions++;
|
||||||
/* printf("Collisions %d\n", num_collisions);*/
|
printf("Collisions %d\n", num_collisions);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!interference) {
|
if(!interference) {
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
*
|
*
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
*
|
*
|
||||||
* $Id: ether.h,v 1.3 2006/10/23 09:01:06 adamdunkels Exp $
|
* $Id: ether.h,v 1.4 2007/03/13 13:07:48 adamdunkels Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef __ETHER_H__
|
#ifndef __ETHER_H__
|
||||||
#define __ETHER_H__
|
#define __ETHER_H__
|
||||||
|
@ -59,7 +59,7 @@ void ether_client_init(int port);
|
||||||
void ether_tick(void);
|
void ether_tick(void);
|
||||||
|
|
||||||
|
|
||||||
u16_t ether_client_poll(void);
|
u16_t ether_client_poll(u8_t *buf, int len);
|
||||||
void ether_server_poll(void);
|
void ether_server_poll(void);
|
||||||
|
|
||||||
void ether_put(char *packet, int len, int src_x, int src_y);
|
void ether_put(char *packet, int len, int src_x, int src_y);
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
*
|
*
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
*
|
*
|
||||||
* $Id: ethernode-drv.c,v 1.4 2006/10/10 15:58:31 adamdunkels Exp $
|
* $Id: ethernode-drv.c,v 1.5 2007/03/13 13:07:48 adamdunkels Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
|
@ -50,6 +50,7 @@ enum { NULLEVENT };
|
||||||
u8_t
|
u8_t
|
||||||
ethernode_drv_send(void)
|
ethernode_drv_send(void)
|
||||||
{
|
{
|
||||||
|
/* printf("%d: ethernode_drv_send\n", node_id);*/
|
||||||
uip_len = hc_compress(&uip_buf[UIP_LLH_LEN], uip_len);
|
uip_len = hc_compress(&uip_buf[UIP_LLH_LEN], uip_len);
|
||||||
|
|
||||||
return ethernode_send();
|
return ethernode_send();
|
||||||
|
@ -65,7 +66,7 @@ PROCESS_THREAD(ethernode_drv_process, ev, data)
|
||||||
PROCESS_WAIT_EVENT();
|
PROCESS_WAIT_EVENT();
|
||||||
|
|
||||||
/* Poll Ethernet device to see if there is a frame avaliable. */
|
/* Poll Ethernet device to see if there is a frame avaliable. */
|
||||||
uip_len = ethernode_poll();
|
uip_len = ethernode_poll(uip_buf, UIP_BUFSIZE);
|
||||||
|
|
||||||
if(uip_len > 0) {
|
if(uip_len > 0) {
|
||||||
/* printf("%d: new packet len %d\n", node_id, uip_len);*/
|
/* printf("%d: new packet len %d\n", node_id, uip_len);*/
|
||||||
|
|
82
platform/netsim/net/ethernode-rime.c
Normal file
82
platform/netsim/net/ethernode-rime.c
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2004, 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.
|
||||||
|
*
|
||||||
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
|
*
|
||||||
|
* $Id: ethernode-rime.c,v 1.1 2007/03/13 13:07:48 adamdunkels Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "contiki.h"
|
||||||
|
|
||||||
|
#include "ethernode.h"
|
||||||
|
|
||||||
|
#include "net/rime.h"
|
||||||
|
|
||||||
|
PROCESS(ethernode_rime_process, "Ethernode Rime driver");
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
PROCESS_THREAD(ethernode_rime_process, ev, data)
|
||||||
|
{
|
||||||
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
|
printf("ethernode_rime_process\n");
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
process_poll(ðernode_rime_process);
|
||||||
|
PROCESS_WAIT_EVENT();
|
||||||
|
|
||||||
|
/* Poll Ethernet device to see if there is a frame avaliable. */
|
||||||
|
{
|
||||||
|
u16_t len;
|
||||||
|
|
||||||
|
rimebuf_clear();
|
||||||
|
|
||||||
|
len = ethernode_poll(rimebuf_dataptr(), RIMEBUF_SIZE);
|
||||||
|
|
||||||
|
if(len > 0) {
|
||||||
|
|
||||||
|
rimebuf_set_datalen(len);
|
||||||
|
|
||||||
|
printf("ethernode_rime_process: received len %d\n",
|
||||||
|
len);
|
||||||
|
abc_input_packet();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PROCESS_END();
|
||||||
|
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
abc_arch_send(u8_t *buf, int len)
|
||||||
|
{
|
||||||
|
ethernode_send_buf(buf, len);
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
48
platform/netsim/net/ethernode-rime.h
Normal file
48
platform/netsim/net/ethernode-rime.h
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
* 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: ethernode-rime.h,v 1.1 2007/03/13 13:07:48 adamdunkels Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* A brief description of what this file is.
|
||||||
|
* \author
|
||||||
|
* Adam Dunkels <adam@sics.se>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __ETHERNODE_RIME_H__
|
||||||
|
#define __ETHERNODE_RIME_H__
|
||||||
|
|
||||||
|
#include "contiki.h"
|
||||||
|
|
||||||
|
PROCESS_NAME(ethernode_rime_process);
|
||||||
|
|
||||||
|
#endif /* __ETHERNODE_RIME_H__ */
|
|
@ -30,7 +30,7 @@
|
||||||
*
|
*
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
*
|
*
|
||||||
* $Id: ethernode.c,v 1.3 2006/10/23 09:01:06 adamdunkels Exp $
|
* $Id: ethernode.c,v 1.4 2007/03/13 13:07:48 adamdunkels Exp $
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
|
@ -121,22 +121,24 @@ ethernode_init(int port)
|
||||||
*/
|
*/
|
||||||
/*-------------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------------*/
|
||||||
int
|
int
|
||||||
ethernode_poll(void)
|
ethernode_poll(u8_t *buf, int bufsize)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
struct hdr *hdr = (struct hdr *)uip_buf;
|
u8_t tmpbuf[UIP_BUFSIZE];
|
||||||
|
struct hdr *hdr = (struct hdr *)tmpbuf;
|
||||||
|
|
||||||
len = ether_client_poll();
|
len = ether_client_poll(tmpbuf, UIP_BUFSIZE);
|
||||||
if(len == 0) {
|
if(len == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* printf("ethernode_poll: received data packet with len %d\n", len);*/
|
/* printf("ethernode_poll: received data packet with len %d type %d\n", len, hdr->type);*/
|
||||||
|
|
||||||
switch(hdr->type) {
|
switch(hdr->type) {
|
||||||
case TYPE_DATA:
|
case TYPE_DATA:
|
||||||
if(hdr->dest == state.id ||
|
if(hdr->dest == state.id ||
|
||||||
hdr->dest == ID_BROADCAST) {
|
hdr->dest == ID_BROADCAST) {
|
||||||
|
memcpy(buf, tmpbuf + HDR_LEN, bufsize);
|
||||||
return len - HDR_LEN;
|
return len - HDR_LEN;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -181,10 +183,24 @@ ethernode_send(void)
|
||||||
|
|
||||||
dest = ID_BROADCAST;
|
dest = ID_BROADCAST;
|
||||||
|
|
||||||
usleep(100 * (random_rand() % 1000));
|
usleep(1000 * (random_rand() % 1000));
|
||||||
|
|
||||||
do_send(TYPE_DATA, dest, hdr, len);
|
do_send(TYPE_DATA, dest, hdr, len);
|
||||||
|
|
||||||
return UIP_FW_OK;
|
return UIP_FW_OK;
|
||||||
}
|
}
|
||||||
/*-------------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------------*/
|
||||||
|
void
|
||||||
|
ethernode_send_buf(u8_t *buf, int len)
|
||||||
|
{
|
||||||
|
char tmpbuf[UIP_BUFSIZE + HDR_LEN];
|
||||||
|
struct hdr *hdr = (struct hdr *)tmpbuf;
|
||||||
|
u8_t dest;
|
||||||
|
|
||||||
|
memcpy(&tmpbuf[HDR_LEN], buf, len);
|
||||||
|
len = len + HDR_LEN;
|
||||||
|
|
||||||
|
dest = ID_BROADCAST;
|
||||||
|
do_send(TYPE_DATA, dest, hdr, len);
|
||||||
|
}
|
||||||
|
/*-------------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -1,36 +1,36 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. Neither the name of the Institute nor the names of its contributors
|
* 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
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* 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
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
*
|
*
|
||||||
* $Id: ethernode.h,v 1.1 2006/06/17 22:41:36 adamdunkels Exp $
|
* $Id: ethernode.h,v 1.2 2007/03/13 13:07:48 adamdunkels Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef __ETHERNODE_H__
|
#ifndef __ETHERNODE_H__
|
||||||
#define __ETHERNODE_H__
|
#define __ETHERNODE_H__
|
||||||
|
@ -38,9 +38,9 @@
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
|
|
||||||
void ethernode_init(int port);
|
void ethernode_init(int port);
|
||||||
int ethernode_poll(void);
|
int ethernode_poll(u8_t *buf, int bufsize);
|
||||||
u8_t ethernode_send(void);
|
u8_t ethernode_send(void);
|
||||||
|
void ethernode_send_buf(u8_t *buf, int len);
|
||||||
void ethernode_periodic(void);
|
void ethernode_periodic(void);
|
||||||
|
|
||||||
#endif /* __ETHERNODE_H__ */
|
#endif /* __ETHERNODE_H__ */
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
*
|
*
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
*
|
*
|
||||||
* $Id: node.c,v 1.3 2006/09/26 22:10:12 adamdunkels Exp $
|
* $Id: node.c,v 1.4 2007/03/13 13:07:48 adamdunkels Exp $
|
||||||
*/
|
*/
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
|
@ -64,7 +64,7 @@ node_init(int id, int posx, int posy, int b)
|
||||||
}
|
}
|
||||||
uip_sethostaddr(&addr);
|
uip_sethostaddr(&addr);
|
||||||
|
|
||||||
drift = random() % 9572627217;
|
drift = random() % 95726272;
|
||||||
|
|
||||||
init_node_log();
|
init_node_log();
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ node_time(void)
|
||||||
|
|
||||||
gettimeofday(&tv, &tz);
|
gettimeofday(&tv, &tz);
|
||||||
|
|
||||||
return tv.tv_sec * 1000 + tv.tv_usec / 1000 + drift;
|
return tv.tv_sec * 1000 + tv.tv_usec / 1000/* + drift*/;
|
||||||
}
|
}
|
||||||
/*------------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------------*/
|
||||||
unsigned long
|
unsigned long
|
||||||
|
|
Loading…
Reference in a new issue