Merge pull request #59 from g-oikonomou/8051-regressions

8051-based ports: Regression tests and code cleanup
This commit is contained in:
Adam Dunkels 2012-12-16 21:42:36 -08:00
commit 70e46f3248
85 changed files with 669 additions and 837 deletions

13
.gitignore vendored
View File

@ -41,3 +41,16 @@ tools/cooja/apps/serial_socket/lib/
tools/coffee-manager/coffee.jar tools/coffee-manager/coffee.jar
tools/cooja/apps/avrora/lib/cooja_avrora.jar tools/cooja/apps/avrora/lib/cooja_avrora.jar
tools/cooja/apps/collect-view/cooja-collect-view.jar tools/cooja/apps/collect-view/cooja-collect-view.jar
# sdcc build artifacts
contiki-sensinode.lib
contiki-cc2530dk.lib
*.ihx
*.hex
*.mem
*.lk
*.omf
*.cdb
*.banks
*.sensinode
*.cc2530dk

View File

@ -4,10 +4,16 @@ before_script:
## Install these mainline toolchains for all build types ## Install these mainline toolchains for all build types
- "sudo apt-get -qq install gcc-msp430 || true" - "sudo apt-get -qq install gcc-msp430 || true"
- "sudo apt-get -qq install gcc-avr avr-libc || true" - "sudo apt-get -qq install gcc-avr avr-libc || true"
- "sudo apt-get -qq install srecord || true"
## Install toolchain for mc1233x in care-free way ## Install toolchain for mc1233x in care-free way
- "[ $BUILD_TYPE = compile ] && curl -s \ - "[ $BUILD_TYPE = compile ] && curl -s \
https://sourcery.mentor.com/public/gnu_toolchain/arm-none-eabi/arm-2008q3-66-arm-none-eabi-i686-pc-linux-gnu.tar.bz2 \ https://sourcery.mentor.com/public/gnu_toolchain/arm-none-eabi/arm-2008q3-66-arm-none-eabi-i686-pc-linux-gnu.tar.bz2 \
| tar xjf - -C /tmp/ && sudo cp -f -r /tmp/arm-2008q3/* /usr/ && rm -rf /tmp/arm-2008q3 && arm-none-eabi-gcc --version || true" | tar xjf - -C /tmp/ && sudo cp -f -r /tmp/arm-2008q3/* /usr/ && rm -rf /tmp/arm-2008q3 && arm-none-eabi-gcc --version || true"
## Install SDCC from a purpose-built bundle
- "[ $BUILD_TYPE = compile ] && curl -s \
https://raw.github.com/wiki/g-oikonomou/contiki-sensinode/files/sdcc-r7100.tar.gz \
| tar xzf - -C /tmp/ && sudo cp -f -r /tmp/sdcc-r7100/* /usr/local/ && rm -rf /tmp/sdcc-r7100 && sdcc --version || true"
## Compile cooja.jar only when it's going to be needed ## Compile cooja.jar only when it's going to be needed
- "[ $MAKE_TARGETS = cooja ] && java -version && ant -q -f tools/cooja/build.xml jar || true" - "[ $MAKE_TARGETS = cooja ] && java -version && ant -q -f tools/cooja/build.xml jar || true"

View File

@ -686,8 +686,7 @@ off(void)
return 1; return 1;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
const struct radio_driver cc2430_rf_driver = const struct radio_driver cc2430_rf_driver = {
{
init, init,
prepare, prepare,
transmit, transmit,

View File

@ -16,8 +16,7 @@
#endif #endif
/* Constants */ /* Constants */
typedef enum rf_address_mode_t typedef enum rf_address_mode_t {
{
RF_DECODER_NONE = 0, RF_DECODER_NONE = 0,
RF_DECODER_COORDINATOR, RF_DECODER_COORDINATOR,
RF_SOFTACK_MONITOR, RF_SOFTACK_MONITOR,

View File

@ -25,7 +25,7 @@ void uart0_set_input(int (*input)(unsigned char c));
void uart0_rx_ISR(void) __interrupt(URX0_VECTOR); void uart0_rx_ISR(void) __interrupt(URX0_VECTOR);
void uart0_tx_ISR(void) __interrupt(UTX0_VECTOR); void uart0_tx_ISR(void) __interrupt(UTX0_VECTOR);
/* Macro to turn on / off UART RX Interrupt */ /* Macro to turn on / off UART RX Interrupt */
#define UART0_RX_INT(v) IEN0_URX0IE = v #define UART0_RX_INT(v) do { IEN0_URX0IE = v; } while(0)
#endif #endif
#endif /* UART_0_H */ #endif /* UART_0_H */

View File

@ -25,7 +25,7 @@ void uart1_set_input(int (*input)(unsigned char c));
void uart1_rx_ISR(void) __interrupt(URX1_VECTOR); void uart1_rx_ISR(void) __interrupt(URX1_VECTOR);
void uart1_tx_ISR(void) __interrupt(UTX1_VECTOR); void uart1_tx_ISR(void) __interrupt(UTX1_VECTOR);
/* Macro to turn on / off UART RX Interrupt */ /* Macro to turn on / off UART RX Interrupt */
#define UART1_RX_INT(v) IEN0_URX1IE = v #define UART1_RX_INT(v) do { IEN0_URX1IE = v; } while(0)
#else #else
#define UART1_RX_INT(v) #define UART1_RX_INT(v)
#endif /* UART_ONE_CONF_WITH_INPUT */ #endif /* UART_ONE_CONF_WITH_INPUT */

View File

@ -47,4 +47,3 @@ struct mtarch_thread {
}; };
#endif /* __MTARCH_H__ */ #endif /* __MTARCH_H__ */

View File

@ -483,8 +483,7 @@ off(void)
return 1; return 1;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
const struct radio_driver cc2530_rf_driver = const struct radio_driver cc2530_rf_driver = {
{
init, init,
prepare, prepare,
transmit, transmit,

View File

@ -88,7 +88,7 @@ dma_reset(uint8_t c)
dma_conf[c].len_l = 1; dma_conf[c].len_l = 1;
dma_conf[c].wtt = DMA_BLOCK; dma_conf[c].wtt = DMA_BLOCK;
dma_conf[c].inc_prio = DMA_PRIO_GUARANTEED; dma_conf[c].inc_prio = DMA_PRIO_GUARANTEED;
DMA_TRIGGER(c); // The operation order is important DMA_TRIGGER(c); /** The operation order is important */
DMA_ARM(c); DMA_ARM(c);
while(DMAARM & (1 << c)); while(DMAARM & (1 << c));
} }

View File

@ -47,4 +47,3 @@ struct mtarch_thread {
}; };
#endif /* __MTARCH_H__ */ #endif /* __MTARCH_H__ */

View File

@ -47,4 +47,3 @@ netstack_init(void)
NETSTACK_RADIO.init(); NETSTACK_RADIO.init();
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View File

@ -48,7 +48,8 @@ AUTOSTART_PROCESSES(&clock_test_process);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#if TEST_RTIMER #if TEST_RTIMER
void void
rt_callback(struct rtimer *t, void *ptr) { rt_callback(struct rtimer *t, void *ptr)
{
rt_now = RTIMER_NOW(); rt_now = RTIMER_NOW();
ct = clock_time(); ct = clock_time();
printf("Task called at %u (clock = %u)\n", rt_now, ct); printf("Task called at %u (clock = %u)\n", rt_now, ct);

View File

@ -72,7 +72,8 @@ ping6handler()
count, PING6_DATALEN); count, PING6_DATALEN);
uip_len = UIP_ICMPH_LEN + UIP_ICMP6_ECHO_REQUEST_LEN + UIP_IPH_LEN + PING6_DATALEN; uip_len = UIP_ICMPH_LEN + UIP_ICMP6_ECHO_REQUEST_LEN + UIP_IPH_LEN
+ PING6_DATALEN;
UIP_IP_BUF->len[0] = (uint8_t)((uip_len - 40) >> 8); UIP_IP_BUF->len[0] = (uint8_t)((uip_len - 40) >> 8);
UIP_IP_BUF->len[1] = (uint8_t)((uip_len - 40) & 0x00FF); UIP_IP_BUF->len[1] = (uint8_t)((uip_len - 40) & 0x00FF);

View File

@ -92,9 +92,10 @@ static void
print_stats() print_stats()
{ {
PRINTF("tl=%lu, ts=%lu, bs=%lu, bc=%lu\n", PRINTF("tl=%lu, ts=%lu, bs=%lu, bc=%lu\n",
rimestats.toolong, rimestats.tooshort, rimestats.badsynch, rimestats.badcrc); rimestats.toolong, rimestats.tooshort, rimestats.badsynch,
PRINTF("llrx=%lu, lltx=%lu, rx=%lu, tx=%lu\n", rimestats.badcrc);
rimestats.llrx, rimestats.lltx, rimestats.rx, rimestats.tx); PRINTF("llrx=%lu, lltx=%lu, rx=%lu, tx=%lu\n", rimestats.llrx,
rimestats.lltx, rimestats.rx, rimestats.tx);
} }
#endif #endif
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -131,7 +132,8 @@ create_dag()
print_local_addresses(); print_local_addresses();
dag = rpl_set_root(RPL_DEFAULT_INSTANCE, &uip_ds6_get_global(ADDR_PREFERRED)->ipaddr); dag = rpl_set_root(RPL_DEFAULT_INSTANCE,
&uip_ds6_get_global(ADDR_PREFERRED)->ipaddr);
if(dag != NULL) { if(dag != NULL) {
uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0); uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
rpl_set_prefix(dag, &ipaddr, 64); rpl_set_prefix(dag, &ipaddr, 64);

View File

@ -8,9 +8,6 @@ DEFINES+=MODEL_N740
# These examples don't need code banking so we turn it off # These examples don't need code banking so we turn it off
#HAVE_BANKING=1 #HAVE_BANKING=1
CONTIKI_PROJECT = hello_world clock_test rf_test_rx rf_test_tx
# New examples added by George Oikonomou - Loughborough University
CONTIKI_PROJECT += timer-test blink-hello broadcast-rime CONTIKI_PROJECT += timer-test blink-hello broadcast-rime
all: $(CONTIKI_PROJECT) all: $(CONTIKI_PROJECT)

View File

@ -36,13 +36,6 @@ make hello_world DEFINES=MODEL_N601
These make options are defined in /platform/sensinode/Makefile.sensinode These make options are defined in /platform/sensinode/Makefile.sensinode
Descriptions of applications: Descriptions of applications:
hello_world A simple hello world app.
clock_test Test and example of sys/clock.h related features.
rf_test_tx Test for transmitting packets
rf_test_rc Test for receiving packets
Recent Additions:
udp-ipv6 UDP client-server example over uIPv6. Uses link-local and global udp-ipv6 UDP client-server example over uIPv6. Uses link-local and global
addresses. Button 1 on the client will send an echo request. addresses. Button 1 on the client will send an echo request.
broadcast-rime Just a broadcast rime example, slightly modified broadcast-rime Just a broadcast rime example, slightly modified

View File

@ -10,61 +10,36 @@
#include "contiki.h" #include "contiki.h"
#include "dev/leds.h" #include "dev/leds.h"
#include <stdio.h> /* For printf() */ #include <stdio.h>
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* We declare the two processes */
PROCESS(hello_world_process, "Hello world process"); PROCESS(hello_world_process, "Hello world process");
PROCESS(blink_process, "LED blink process"); PROCESS(blink_process, "LED blink process");
/* We require the processes to be started automatically */
AUTOSTART_PROCESSES(&hello_world_process, &blink_process); AUTOSTART_PROCESSES(&hello_world_process, &blink_process);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Implementation of the first process */ /* Implementation of the first process */
PROCESS_THREAD(hello_world_process, ev, data) PROCESS_THREAD(hello_world_process, ev, data)
{ {
/* variables are declared static to ensure their values are maintained
between subsequent calls.
All the code between PROCESS_THREAD and PROCESS_BEGIN() runs each time
the process is invoked. */
static struct etimer timer; static struct etimer timer;
static int count; static int count;
/* any process must start with this. */
PROCESS_BEGIN(); PROCESS_BEGIN();
/* set the etimer module to generate an event in one second.
CLOCK_CONF_SECOND is #define as 128 */
etimer_set(&timer, CLOCK_CONF_SECOND * 4); etimer_set(&timer, CLOCK_CONF_SECOND * 4);
count = 0; count = 0;
/* Don't declare variables after PROCESS_BEGIN.
* While it will compile fine with TARGET=native (gcc is happy),
* SDCC doesn't like it. Soon as you try TARGET=sensinode you will get:
* syntax error: token -> 'int' ;
* Try uncommenting the line below and observe the results */
/* int whoops = 0;
* whoops = 0; */
while (1)
{
/* wait here for an event to happen */
PROCESS_WAIT_EVENT();
/* This achieves the same
* PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER); */
/* if the event is the timer event as expected... */ while(1) {
if(ev == PROCESS_EVENT_TIMER)
{ PROCESS_WAIT_EVENT();
/* do the process work */
if(ev == PROCESS_EVENT_TIMER) {
printf("Sensor says no... #%d\r\n", count); printf("Sensor says no... #%d\r\n", count);
count++; count++;
/* reset the timer so it will generate an other event
* the exact same time after it expired (periodicity guaranteed) */
etimer_reset(&timer); etimer_reset(&timer);
} }
/* and loop */
} }
/* any process must end with this, even if it is never reached. */
PROCESS_END(); PROCESS_END();
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -74,16 +49,12 @@ PROCESS_THREAD(blink_process, ev, data)
static struct etimer timer; static struct etimer timer;
PROCESS_BEGIN(); PROCESS_BEGIN();
while (1) while(1) {
{
/* we set the timer from here every time */
etimer_set(&timer, CLOCK_CONF_SECOND); etimer_set(&timer, CLOCK_CONF_SECOND);
/* and wait until the event we receive is the one we're waiting for */
PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER); PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER);
printf("Blink... (state %0.2X).\r\n", leds_get()); printf("Blink... (state %0.2X).\r\n", leds_get());
/* update the LEDs */
leds_toggle(LEDS_GREEN); leds_toggle(LEDS_GREEN);
} }
PROCESS_END(); PROCESS_END();

View File

@ -58,14 +58,18 @@
PROCESS(example_broadcast_process, "BROADCAST example"); PROCESS(example_broadcast_process, "BROADCAST example");
AUTOSTART_PROCESSES(&example_broadcast_process); AUTOSTART_PROCESSES(&example_broadcast_process);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void broadcast_recv(struct broadcast_conn *c, const rimeaddr_t *from) static void
broadcast_recv(struct broadcast_conn *c, const rimeaddr_t *from)
{ {
leds_toggle(LEDS_RED); leds_toggle(LEDS_RED);
PRINTF("broadcast message received from %02x.%02x\n", from->u8[0], from->u8[1]); PRINTF("broadcast message received from %02x.%02x\n", from->u8[0],
PRINTF("Size=0x%02x: '0x%04x'\n", packetbuf_datalen(), *(uint16_t *) packetbuf_dataptr()); from->u8[1]);
PRINTF("Size=0x%02x: '0x%04x'\n", packetbuf_datalen(),
*(uint16_t *)packetbuf_dataptr());
} }
/*---------------------------------------------------------------------------*/
static void print_rime_stats() static void
print_rime_stats()
{ {
PRINTF("\nNetwork Stats\n"); PRINTF("\nNetwork Stats\n");
PRINTF(" TX=%lu , RX=%lu\n", rimestats.tx, rimestats.rx); PRINTF(" TX=%lu , RX=%lu\n", rimestats.tx, rimestats.rx);
@ -90,7 +94,7 @@ PROCESS_THREAD(example_broadcast_process, ev, data)
PRINTF("Start\n"); PRINTF("Start\n");
broadcast_open(&broadcast, BROADCAST_CHANNEL, &bc_rx); broadcast_open(&broadcast, BROADCAST_CHANNEL, &bc_rx);
PRINTF("Open Broadcast Connection, channel %u\n", BROADCAST_CHANNEL); PRINTF("Open Broadcast Connection, channel %u\n", BROADCAST_CHANNEL);
// leds_off(LEDS_ALL);
while(1) { while(1) {
/* Delay 2-4 seconds */ /* Delay 2-4 seconds */
@ -98,7 +102,8 @@ PROCESS_THREAD(example_broadcast_process, ev, data)
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
leds_on(LEDS_GREEN); leds_on(LEDS_GREEN);
packetbuf_copyfrom(&counter, sizeof(counter)); packetbuf_copyfrom(&counter, sizeof(counter));
PRINTF("Sending %u bytes: 0x%04x\n", packetbuf_datalen(), *(uint16_t *) packetbuf_dataptr()); PRINTF("Sending %u bytes: 0x%04x\n", packetbuf_datalen(),
*(uint16_t *)packetbuf_dataptr());
if(broadcast_send(&broadcast) == 0) { if(broadcast_send(&broadcast) == 0) {
PRINTF("Error Sending\n"); PRINTF("Error Sending\n");
} }

View File

@ -181,7 +181,8 @@ broadcast_recv(struct broadcast_conn *c, const rimeaddr_t *from)
/* Convert RSSI to the loc. eng. format */ /* Convert RSSI to the loc. eng. format */
parameters.rssi[from->u8[1] - 1] = (-2 * rssi); parameters.rssi[from->u8[1] - 1] = (-2 * rssi);
/* Raw dump the packetbuf into the ref_coords struct */ /* Raw dump the packetbuf into the ref_coords struct */
memcpy(&ref_coords[from->u8[1] - 1], packetbuf_dataptr(), 2 * sizeof(uint8_t)); memcpy(&ref_coords[from->u8[1] - 1], packetbuf_dataptr(),
2 * sizeof(uint8_t));
} }
return; return;
@ -194,7 +195,8 @@ broadcast_recv(struct broadcast_conn *c, const rimeaddr_t *from)
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void static void
set_imaginary_ref_nodes() { set_imaginary_ref_nodes()
{
ref_coords[0].x = 1; ref_coords[0].x = 1;
ref_coords[0].y = 5; ref_coords[0].y = 5;
parameters.rssi[0] = SAMPLE_RSSI; parameters.rssi[0] = SAMPLE_RSSI;
@ -266,7 +268,9 @@ PROCESS_THREAD(blindnode_bcast_rec, ev, data)
parameters.n = n; parameters.n = n;
calculate(); calculate();
n++; n++;
if(n==32) { n=0; } if(n == 32) {
n = 0;
}
/* Send our calculated location to some monitoring node */ /* Send our calculated location to some monitoring node */
packetbuf_copyfrom(&coords, 2 * sizeof(uint8_t)); packetbuf_copyfrom(&coords, 2 * sizeof(uint8_t));

View File

@ -47,4 +47,3 @@ netstack_init(void)
NETSTACK_RADIO.init(); NETSTACK_RADIO.init();
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View File

@ -14,67 +14,44 @@
#include "contiki.h" #include "contiki.h"
//#include "dev/leds.h" //#include "dev/leds.h"
#include <limits.h> #include <limits.h>
#include <stdio.h> /* For printf() */ #include <stdio.h>
#include "event-post.h" #include "event-post.h"
/* This is our event type */ /* This is our event type */
static process_event_t event_data_ready; static process_event_t event_data_ready;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Declare the two processes here */ /* Declare the two processes here */
PROCESS(sensor_process, "Sensor process"); PROCESS(sensor_process, "Sensor process");
PROCESS(print_process, "Print process"); PROCESS(print_process, "Print process");
/* Tell Contiki that we want them to start automatically */
AUTOSTART_PROCESSES(&sensor_process, &print_process); AUTOSTART_PROCESSES(&sensor_process, &print_process);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Implementation "Sensor Process" */
PROCESS_THREAD(sensor_process, ev, data) PROCESS_THREAD(sensor_process, ev, data)
{ {
/* static variables to preserve values across consecutive calls of this
* process. */
/* Set an etimer */
static struct etimer timer; static struct etimer timer;
/* And the 'sensor' monitoring variable */
static struct event_struct es; static struct event_struct es;
PROCESS_BEGIN(); PROCESS_BEGIN();
/* Set some near-the-limit initial values */
/* signed primitives */
es.s_val = SHRT_MAX - 2; es.s_val = SHRT_MAX - 2;
es.i_val = INT_MAX - 2; es.i_val = INT_MAX - 2;
es.l_val = LONG_MAX - 2; es.l_val = LONG_MAX - 2;
/* sizeof(long long) == sizeof(long) on sensinodes - see other examples*/
es.ll_val = LONG_MAX - 2; es.ll_val = LONG_MAX - 2;
/* and some typedef-ed unsigned variables */
es.u8_val = UCHAR_MAX - 2; es.u8_val = UCHAR_MAX - 2;
es.u16_val = USHRT_MAX - 2; es.u16_val = USHRT_MAX - 2;
es.u32_val = ULONG_MAX - 2; es.u32_val = ULONG_MAX - 2;
/* allocate the required event */
event_data_ready = process_alloc_event(); event_data_ready = process_alloc_event();
/* process_event_t is actually a u_char. What did the OS allocate for us? */
printf("Contiki allocated event ID %d.\r\n", event_data_ready); printf("Contiki allocated event ID %d.\r\n", event_data_ready);
/* Set a timer here. We will generate an event every times this timer expires
* etimer_set accepts clock ticks as its 2nd argument.
* CLOCK_CONF_SECOND is the number of ticks per second.
* This CLOCK_CONF_SECOND * N = N seconds */
etimer_set(&timer, CLOCK_CONF_SECOND * 2); etimer_set(&timer, CLOCK_CONF_SECOND * 2);
while (1) while(1) {
{
printf("Sensor process: Wait for timer event...\r\n"); printf("Sensor process: Wait for timer event...\r\n");
/* Wait on our timer */
PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER); PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER);
/* blip */
/* leds_toggle(LEDS_BLUE); */
/* Set the 'sensor' value before throwing the event */
printf("Sensor Process: Incrementing values...\r\n"); printf("Sensor Process: Incrementing values...\r\n");
es.s_val++; es.s_val++;
es.i_val++; es.i_val++;
@ -84,13 +61,9 @@ PROCESS_THREAD(sensor_process, ev, data)
es.u16_val++; es.u16_val++;
es.u32_val++; es.u32_val++;
/* Post our event.
* N.B. es is declared static.
* Try passing a volatile variable and observe the results... */
printf("Sensor Process: Generating 'Data Ready' event.\r\n"); printf("Sensor Process: Generating 'Data Ready' event.\r\n");
process_post(&print_process, event_data_ready, &es); process_post(&print_process, event_data_ready, &es);
/* reset the timer so we can wait on it again */
etimer_reset(&timer); etimer_reset(&timer);
} }
@ -105,16 +78,10 @@ PROCESS_THREAD(print_process, ev, data)
PROCESS_BEGIN(); PROCESS_BEGIN();
while (1) while(1) {
{
/* Stop here and wait until "event_data_ready" occurs */
PROCESS_WAIT_EVENT_UNTIL(ev == event_data_ready); PROCESS_WAIT_EVENT_UNTIL(ev == event_data_ready);
/* When the event occurs, the incoming data will be stored in
* process_data_t data (careful, this is void *)
*
* Print away...
* es is volatile, we need to set it = data again and dereference it. */
sd = data; sd = data;
printf("Print Process - Data Ready:\r\n"); printf("Print Process - Data Ready:\r\n");
printf(" s: %d\r\n", sd->s_val); printf(" s: %d\r\n", sd->s_val);
@ -125,7 +92,6 @@ PROCESS_THREAD(print_process, ev, data)
printf(" u16: %u\r\n", sd->u16_val); printf(" u16: %u\r\n", sd->u16_val);
printf(" u32: %lu\r\n", sd->u32_val); printf(" u32: %lu\r\n", sd->u32_val);
/* aaaaand back to waiting for the next event */
} }
PROCESS_END(); PROCESS_END();
} }

View File

@ -1,23 +0,0 @@
/**
* \file
* Basic hello world example
* \author
* Zach Shelby <zach@sensinode.com>
*/
#include "contiki.h"
#include <stdio.h> /* For printf() */
/*---------------------------------------------------------------------------*/
PROCESS(hello_world_process, "Hello world process");
AUTOSTART_PROCESSES(&hello_world_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(hello_world_process, ev, data)
{
PROCESS_BEGIN();
printf("Hello World!\n");
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,60 +0,0 @@
/**
* \file
* RF test suite, receiver
* \author
* Zach Shelby <zach@sensinode.com>
*/
#include "contiki.h"
#include "net/rime.h"
#include <stdio.h> /* For printf() */
/*---------------------------------------------------------------------------*/
PROCESS(rf_test_process, "RF test RX process");
AUTOSTART_PROCESSES(&rf_test_process);
static struct etimer et;
static struct broadcast_conn bc;
static const struct broadcast_callbacks broadcast_callbacks = {recv_bc};
static struct unicast_conn uc;
static const struct unicast_callbacks unicast_callbacks = {recv_uc};
static void
recv_bc(struct broadcast_conn *c, rimeaddr_t *from)
{
printf("broadcast from %02x.%02x len = %d buf = %s\n",
from->u8[0],
from->u8[1],
packetbuf_datalen(),
(char *)packetbuf_dataptr());
}
static void
recv_uc(struct unicast_conn *c, rimeaddr_t *from)
{
printf("unicast from %02x.%02x len = %d buf = %s\n",
from->u8[0],
from->u8[1],
packetbuf_datalen(),
(char *)packetbuf_dataptr());
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(rf_test_process, ev, data)
{
PROCESS_BEGIN();
printf("\nStarting CC2430 RF test suite...\n");
broadcast_open(&bc, 128, &broadcast_callbacks);
unicast_open(&uc, 128, &unicast_callbacks);
while(1) {
etimer_set(&et, CLOCK_SECOND);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
etimer_reset(&et);
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -1,50 +0,0 @@
/**
* \file
* RF test suite, transmitter
* \author
* Zach Shelby <zach@sensinode.com>
*/
#include "contiki.h"
#include "net/rime.h"
#include <stdio.h> /* For printf() */
/*---------------------------------------------------------------------------*/
PROCESS(rf_test_process, "RF test TX process");
AUTOSTART_PROCESSES(&rf_test_process);
static struct etimer et;
static struct broadcast_conn bc;
static struct unicast_conn uc;
rimeaddr_t addr;
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(rf_test_process, ev, data)
{
PROCESS_BEGIN();
printf("\nStarting CC2430 RF test suite...\n");
broadcast_open(&bc, 128, 0);
unicast_open(&uc, 128, 0);
while(1) {
etimer_set(&et, CLOCK_SECOND);
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
etimer_reset(&et);
printf("Sending broadcast packet\n");
packetbuf_copyfrom("Hello everyone", 14);
broadcast_send(&bc);
// TODO: Fix, freezes on unicast_send()
// printf("Sending unicast packet\n");
// addr.u8[0] = 0;
// addr.u8[1] = 2;
// packetbuf_copyfrom("Hello you", 9);
// unicast_send(&uc, &addr);
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/

View File

@ -110,7 +110,9 @@
#define SEND_BATTERY_INFO 0 #define SEND_BATTERY_INFO 0
#if SEND_BATTERY_INFO #if SEND_BATTERY_INFO
#include "sensors-example.h" #include "sensors-example.h"
static void bc_rx(struct broadcast_conn *c, const rimeaddr_t *from) { static void
bc_rx(struct broadcast_conn *c, const rimeaddr_t *from)
{
return; return;
} }
@ -217,7 +219,8 @@ PROCESS_THREAD(sensors_test_process, ev, data)
sane = ((rv * 0.61065 - 773) / 2.45); sane = ((rv * 0.61065 - 773) / 2.45);
dec = sane; dec = sane;
frac = sane - dec; frac = sane - dec;
PRINTF(" Temp=%d.%02u C (%d)\n", dec, (unsigned int)(frac*100), rv); PRINTF(" Temp=%d.%02u C (%d)\n", dec, (unsigned int)(frac * 100),
rv);
} }
/* /*
* Accelerometer: Freescale Semiconductor MMA7340L * Accelerometer: Freescale Semiconductor MMA7340L
@ -305,7 +308,8 @@ PROCESS_THREAD(sensors_test_process, ev, data)
sane = (float)(rv * 0.4071); sane = (float)(rv * 0.4071);
dec = sane; dec = sane;
frac = sane - dec; frac = sane - dec;
PRINTF(" Light=%d.%02ulux (%d)\n", dec, (unsigned int)(frac*100), rv); PRINTF(" Light=%d.%02ulux (%d)\n", dec, (unsigned int)(frac * 100),
rv);
} }
/* /*
* Power Supply Voltage. * Power Supply Voltage.

View File

@ -47,4 +47,3 @@ netstack_init(void)
NETSTACK_RADIO.init(); NETSTACK_RADIO.init();
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View File

@ -48,7 +48,8 @@ AUTOSTART_PROCESSES(&clock_test_process);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#if TEST_RTIMER #if TEST_RTIMER
void void
rt_callback(struct rtimer *t, void *ptr) { rt_callback(struct rtimer *t, void *ptr)
{
rt_now = RTIMER_NOW(); rt_now = RTIMER_NOW();
ct = clock_time(); ct = clock_time();
printf("Task called at %u (clock = %u)\n", rt_now, ct); printf("Task called at %u (clock = %u)\n", rt_now, ct);
@ -88,8 +89,8 @@ PROCESS_THREAD(clock_test_process, ev, data)
rt_now = RTIMER_NOW(); rt_now = RTIMER_NOW();
rt_for = rt_now + RTIMER_SECOND; rt_for = rt_now + RTIMER_SECOND;
printf("Now=%u (clock = %u) - For=%u\n", rt_now, ct, rt_for); printf("Now=%u (clock = %u) - For=%u\n", rt_now, ct, rt_for);
if (rtimer_set(&rt, rt_for, 1, if(rtimer_set(&rt, rt_for, 1, (rtimer_callback_t) rt_callback, NULL) !=
(void (*)(struct rtimer *, void *))rt_callback, NULL) != RTIMER_OK) { RTIMER_OK) {
printf("Error setting\n"); printf("Error setting\n");
} }
@ -99,7 +100,8 @@ PROCESS_THREAD(clock_test_process, ev, data)
#endif #endif
#if TEST_ETIMER #if TEST_ETIMER
printf("Clock tick and etimer test, 1 sec (%u clock ticks):\n", CLOCK_SECOND); printf("Clock tick and etimer test, 1 sec (%u clock ticks):\n",
CLOCK_SECOND);
i = 0; i = 0;
while(i < 10) { while(i < 10) {
etimer_set(&et, CLOCK_SECOND); etimer_set(&et, CLOCK_SECOND);

View File

@ -182,7 +182,8 @@ PROCESS_THREAD(udp_client_process, ev, data)
UIP_HTONS(l_conn->lport), UIP_HTONS(l_conn->rport)); UIP_HTONS(l_conn->lport), UIP_HTONS(l_conn->rport));
#if UIP_CONF_ROUTER #if UIP_CONF_ROUTER
uip_ip6addr(&ipaddr,0x2001,0x630,0x301,0x6453,0x0215,0x2000,0x0002,0x0302); uip_ip6addr(&ipaddr, 0x2001, 0x630, 0x301, 0x6453, 0x0215, 0x2000, 0x0002,
0x0302);
g_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL); g_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL);
if(!g_conn) { if(!g_conn) {
PRINTF("udp_new g_conn error.\n"); PRINTF("udp_new g_conn error.\n");

View File

@ -110,7 +110,8 @@ PROCESS_THREAD(ping6_process, ev, data)
PRINTF("ping6 running.\n"); PRINTF("ping6 running.\n");
PRINTF("Button 1: 5 pings 16 byte payload.\n"); PRINTF("Button 1: 5 pings 16 byte payload.\n");
uip_ip6addr(&dest_addr,0x2001,0x470,0x55,0,0x0215,0x2000,0x0002,0x0302); uip_ip6addr(&dest_addr, 0x2001, 0x470, 0x55, 0, 0x0215, 0x2000, 0x0002,
0x0302);
count = 0; count = 0;
/* Check if we have buttons */ /* Check if we have buttons */

View File

@ -104,9 +104,10 @@ static void
print_stats() print_stats()
{ {
PRINTF("tl=%lu, ts=%lu, bs=%lu, bc=%lu\n", PRINTF("tl=%lu, ts=%lu, bs=%lu, bc=%lu\n",
rimestats.toolong, rimestats.tooshort, rimestats.badsynch, rimestats.badcrc); rimestats.toolong, rimestats.tooshort, rimestats.badsynch,
PRINTF("llrx=%lu, lltx=%lu, rx=%lu, tx=%lu\n", rimestats.badcrc);
rimestats.llrx, rimestats.lltx, rimestats.rx, rimestats.tx); PRINTF("llrx=%lu, lltx=%lu, rx=%lu, tx=%lu\n", rimestats.llrx,
rimestats.lltx, rimestats.rx, rimestats.tx);
} }
#else #else
#define print_stats() #define print_stats()
@ -145,7 +146,8 @@ create_dag()
print_local_addresses(); print_local_addresses();
dag = rpl_set_root(RPL_DEFAULT_INSTANCE, &uip_ds6_get_global(ADDR_PREFERRED)->ipaddr); dag = rpl_set_root(RPL_DEFAULT_INSTANCE,
&uip_ds6_get_global(ADDR_PREFERRED)->ipaddr);
if(dag != NULL) { if(dag != NULL) {
uip_ip6addr(&ipaddr, 0x2001, 0x630, 0x301, 0x6453, 0, 0, 0, 0); uip_ip6addr(&ipaddr, 0x2001, 0x630, 0x301, 0x6453, 0, 0, 0, 0);
rpl_set_prefix(dag, &ipaddr, 64); rpl_set_prefix(dag, &ipaddr, 64);

View File

@ -54,4 +54,3 @@ putdec(uint8_t c)
} }
} }
} }

View File

@ -40,15 +40,15 @@ static CC_AT_DATA struct timer debouncetimer;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Button 1 - SmartRF and cc2531 USB Dongle */ /* Button 1 - SmartRF and cc2531 USB Dongle */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static static int
int value_b1(int type) value_b1(int type)
{ {
type; type;
return BUTTON_READ(1) || !timer_expired(&debouncetimer); return BUTTON_READ(1) || !timer_expired(&debouncetimer);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static static int
int status_b1(int type) status_b1(int type)
{ {
switch(type) { switch(type) {
case SENSORS_ACTIVE: case SENSORS_ACTIVE:
@ -58,8 +58,8 @@ int status_b1(int type)
return 0; return 0;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static static int
int configure_b1(int type, int value) configure_b1(int type, int value)
{ {
switch(type) { switch(type) {
case SENSORS_HW_INIT: case SENSORS_HW_INIT:
@ -88,15 +88,15 @@ int configure_b1(int type, int value)
/* Button 2 - cc2531 USb Dongle only */ /* Button 2 - cc2531 USb Dongle only */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#if MODEL_CC2531 #if MODEL_CC2531
static static int
int value_b2(int type) value_b2(int type)
{ {
type; type;
return BUTTON_READ(2) || !timer_expired(&debouncetimer); return BUTTON_READ(2) || !timer_expired(&debouncetimer);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static static int
int status_b2(int type) status_b2(int type)
{ {
switch(type) { switch(type) {
case SENSORS_ACTIVE: case SENSORS_ACTIVE:
@ -106,8 +106,8 @@ int status_b2(int type)
return 0; return 0;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static static int
int configure_b2(int type, int value) configure_b2(int type, int value)
{ {
switch(type) { switch(type) {
case SENSORS_HW_INIT: case SENSORS_HW_INIT:

View File

@ -41,6 +41,7 @@
#include "contiki.h" #include "contiki.h"
#include "contiki-lib.h" #include "contiki-lib.h"
#include "contiki-net.h" #include "contiki-net.h"
#include "net/uip-ds6-route.h"
#include <string.h> #include <string.h>
@ -68,9 +69,10 @@ static int8_t len;
#define REQUEST_TYPE_TOTALS 0xFF #define REQUEST_TYPE_TOTALS 0xFF
extern uip_ds6_netif_t uip_ds6_if; extern uip_ds6_netif_t uip_ds6_if;
extern uip_ds6_route_t uip_ds6_routing_table[UIP_DS6_ROUTE_NB];
extern uip_ds6_nbr_t uip_ds6_nbr_cache[UIP_DS6_NBR_NB]; extern uip_ds6_nbr_t uip_ds6_nbr_cache[UIP_DS6_NBR_NB];
extern uip_ds6_defrt_t uip_ds6_defrt_list[UIP_DS6_DEFRT_NB]; static uip_ds6_route_t *rt;
static uip_ds6_defrt_t *defrt;
static uip_ipaddr_t *addr;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static uint8_t static uint8_t
process_request() CC_NON_BANKED process_request() CC_NON_BANKED
@ -117,52 +119,52 @@ process_request() CC_NON_BANKED
} }
} else if(buf[0] == REQUEST_TYPE_RT) { } else if(buf[0] == REQUEST_TYPE_RT) {
uint32_t flip = 0; uint32_t flip = 0;
PRINTF("Routing table\n"); PRINTF("Routing table\n");
for(i = buf[1]; i < UIP_DS6_ROUTE_NB; i++) { rt = uip_ds6_route_list_head();
if(uip_ds6_routing_table[i].isused) {
entry_size = sizeof(i) + sizeof(uip_ds6_routing_table[i].ipaddr) for(i = buf[1]; i < uip_ds6_route_num_routes(); i++) {
+ sizeof(uip_ds6_routing_table[i].length) if(rt != NULL) {
+ sizeof(uip_ds6_routing_table[i].metric) entry_size = sizeof(i) + sizeof(rt->ipaddr)
+ sizeof(uip_ds6_routing_table[i].nexthop) + sizeof(rt->length)
+ sizeof(uip_ds6_routing_table[i].state.lifetime) + sizeof(rt->metric)
+ sizeof(uip_ds6_routing_table[i].state.learned_from); + sizeof(rt->nexthop)
+ sizeof(rt->state.lifetime)
+ sizeof(rt->state.learned_from);
memcpy(buf + len, &i, sizeof(i)); memcpy(buf + len, &i, sizeof(i));
len += sizeof(i); len += sizeof(i);
memcpy(buf + len, &uip_ds6_routing_table[i].ipaddr, memcpy(buf + len, &rt->ipaddr, sizeof(rt->ipaddr));
sizeof(uip_ds6_routing_table[i].ipaddr)); len += sizeof(rt->ipaddr);
len += sizeof(uip_ds6_routing_table[i].ipaddr); memcpy(buf + len, &rt->length, sizeof(rt->length));
memcpy(buf + len, &uip_ds6_routing_table[i].length, len += sizeof(rt->length);
sizeof(uip_ds6_routing_table[i].length)); memcpy(buf + len, &rt->metric, sizeof(rt->metric));
len += sizeof(uip_ds6_routing_table[i].length); len += sizeof(rt->metric);
memcpy(buf + len, &uip_ds6_routing_table[i].metric, memcpy(buf + len, &rt->nexthop, sizeof(rt->nexthop));
sizeof(uip_ds6_routing_table[i].metric)); len += sizeof(rt->nexthop);
len += sizeof(uip_ds6_routing_table[i].metric);
memcpy(buf + len, &uip_ds6_routing_table[i].nexthop,
sizeof(uip_ds6_routing_table[i].nexthop));
len += sizeof(uip_ds6_routing_table[i].nexthop);
PRINT6ADDR(&uip_ds6_routing_table[i].ipaddr); PRINT6ADDR(&rt->ipaddr);
PRINTF(" - %02x", uip_ds6_routing_table[i].length); PRINTF(" - %02x", rt->length);
PRINTF(" - %02x", uip_ds6_routing_table[i].metric); PRINTF(" - %02x", rt->metric);
PRINTF(" - "); PRINTF(" - ");
PRINT6ADDR(&uip_ds6_routing_table[i].nexthop); PRINT6ADDR(&rt->nexthop);
flip = uip_htonl(uip_ds6_routing_table[i].state.lifetime); flip = uip_htonl(rt->state.lifetime);
memcpy(buf + len, &flip, sizeof(flip)); memcpy(buf + len, &flip, sizeof(flip));
len += sizeof(flip); len += sizeof(flip);
PRINTF(" - %08lx", uip_ds6_routing_table[i].state.lifetime); PRINTF(" - %08lx", rt->state.lifetime);
memcpy(buf + len, &uip_ds6_routing_table[i].state.learned_from, memcpy(buf + len, &rt->state.learned_from,
sizeof(uip_ds6_routing_table[i].state.learned_from)); sizeof(rt->state.learned_from));
len += sizeof(uip_ds6_routing_table[i].state.learned_from); len += sizeof(rt->state.learned_from);
PRINTF(" - %02x [%u]\n", uip_ds6_routing_table[i].state.learned_from, PRINTF(" - %02x [%u]\n", rt->state.learned_from, entry_size);
entry_size);
count++; count++;
left -= entry_size; left -= entry_size;
rt = list_item_next(rt);
if(left < entry_size) { if(left < entry_size) {
break; break;
} }
@ -170,30 +172,30 @@ process_request() CC_NON_BANKED
} }
} else if(buf[0] == REQUEST_TYPE_DRT) { } else if(buf[0] == REQUEST_TYPE_DRT) {
uint32_t flip = 0; uint32_t flip = 0;
PRINTF("Default Routes\n");
for(i = buf[1]; i < UIP_DS6_DEFRT_NB; i++) { PRINTF("Default Route\n");
if(uip_ds6_defrt_list[i].isused) { addr = uip_ds6_defrt_choose();
entry_size = sizeof(i) + sizeof(uip_ds6_defrt_list[i].ipaddr) if(addr != NULL) {
+ sizeof(uip_ds6_defrt_list[i].isinfinite); defrt = uip_ds6_defrt_lookup(addr);
}
i = buf[1];
if(defrt != NULL && i < 1) {
entry_size = sizeof(i) + sizeof(defrt->ipaddr)
+ sizeof(defrt->isinfinite);
memcpy(buf + len, &i, sizeof(i)); memcpy(buf + len, &i, sizeof(i));
len += sizeof(i); len += sizeof(i);
memcpy(buf + len, &uip_ds6_defrt_list[i].ipaddr, memcpy(buf + len, &defrt->ipaddr, sizeof(defrt->ipaddr));
sizeof(uip_ds6_defrt_list[i].ipaddr)); len += sizeof(defrt->ipaddr);
len += sizeof(uip_ds6_defrt_list[i].ipaddr); memcpy(buf + len, &defrt->isinfinite, sizeof(defrt->isinfinite));
memcpy(buf + len, &uip_ds6_defrt_list[i].isinfinite, len += sizeof(defrt->isinfinite);
sizeof(uip_ds6_defrt_list[i].isinfinite));
len += sizeof(uip_ds6_defrt_list[i].isinfinite);
PRINT6ADDR(&uip_ds6_defrt_list[i].ipaddr); PRINT6ADDR(&defrt->ipaddr);
PRINTF(" - %u\n", uip_ds6_defrt_list[i].isinfinite); PRINTF(" - %u\n", defrt->isinfinite);
count++; count++;
left -= entry_size; left -= entry_size;
if(left < entry_size) {
break;
}
}
} }
} else if(buf[0] == REQUEST_TYPE_ADDR) { } else if(buf[0] == REQUEST_TYPE_ADDR) {
PRINTF("Unicast Addresses\n"); PRINTF("Unicast Addresses\n");
@ -229,16 +231,10 @@ process_request() CC_NON_BANKED
buf[3]++; buf[3]++;
} }
} }
for(i = 0; i < UIP_DS6_ROUTE_NB; i++) {
if(uip_ds6_routing_table[i].isused) { buf[4] = uip_ds6_route_num_routes();
buf[4]++; buf[5] = 1;
}
}
for(i = 0; i < UIP_DS6_DEFRT_NB; i++) {
if(uip_ds6_defrt_list[i].isused) {
buf[5]++;
}
}
len += 4; len += 4;
count = 4; count = 4;
} else { } else {

View File

@ -59,14 +59,14 @@ HWCONF_PORT_0_IRQ(BUTTON_2, 7)
#endif /* MODEL_N711 */ #endif /* MODEL_N711 */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static static int
int value_b1(int type) value_b1(int type)
{ {
return BUTTON_1_READ() || !timer_expired(&debouncetimer[0]); return BUTTON_1_READ() || !timer_expired(&debouncetimer[0]);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static static int
int status_b1(int type) status_b1(int type)
{ {
switch(type) { switch(type) {
case SENSORS_ACTIVE: case SENSORS_ACTIVE:
@ -76,8 +76,8 @@ int status_b1(int type)
return 0; return 0;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static static int
int configure_b1(int type, int value) configure_b1(int type, int value)
{ {
switch(type) { switch(type) {
case SENSORS_HW_INIT: case SENSORS_HW_INIT:
@ -101,14 +101,14 @@ int configure_b1(int type, int value)
return 0; return 0;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static static int
int value_b2(int type) value_b2(int type)
{ {
return BUTTON_2_READ() || !timer_expired(&debouncetimer[1]); return BUTTON_2_READ() || !timer_expired(&debouncetimer[1]);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static static int
int status_b2(int type) status_b2(int type)
{ {
switch(type) { switch(type) {
case SENSORS_ACTIVE: case SENSORS_ACTIVE:
@ -118,8 +118,8 @@ int status_b2(int type)
return 0; return 0;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static static int
int configure_b2(int type, int value) configure_b2(int type, int value)
{ {
switch(type) { switch(type) {
case SENSORS_HW_INIT: case SENSORS_HW_INIT:

View File

@ -281,7 +281,8 @@ m25p16_dp()
* Release Deep Power Down. We do NOT read the Electronic Signature * Release Deep Power Down. We do NOT read the Electronic Signature
*/ */
void void
m25p16_res() { m25p16_res()
{
select(); select();
bit_bang_write(M25P16_I_RES); bit_bang_write(M25P16_I_RES);
deselect(); deselect();
@ -296,7 +297,8 @@ m25p16_res() {
* \return The old style Electronic Signature. This must be 0x14 * \return The old style Electronic Signature. This must be 0x14
*/ */
uint8_t uint8_t
m25p16_res_res() { m25p16_res_res()
{
uint8_t rv; uint8_t rv;
select(); select();

View File

@ -213,7 +213,8 @@ cmd_init() CC_NON_BANKED
static uint8_t static uint8_t
cmd_write() CC_NON_BANKED cmd_write() CC_NON_BANKED
{ {
PRINTF("Disco: Write 0x%02x%02x%02x\n", req->addr[0], req->addr[1], req->addr[2]); PRINTF("Disco: Write 0x%02x%02x%02x\n", req->addr[0], req->addr[1],
req->addr[2]);
if(uip_datalen() != DISCO_LEN_WRITE) { if(uip_datalen() != DISCO_LEN_WRITE) {
resp.status = DISCO_ERR_BAD_LEN; resp.status = DISCO_ERR_BAD_LEN;
return DISCO_RESP_LEN_ERR; return DISCO_RESP_LEN_ERR;

View File

@ -41,6 +41,7 @@
#include "contiki.h" #include "contiki.h"
#include "contiki-lib.h" #include "contiki-lib.h"
#include "contiki-net.h" #include "contiki-net.h"
#include "net/uip-ds6-route.h"
#include <string.h> #include <string.h>
@ -68,9 +69,10 @@ static int8_t len;
#define REQUEST_TYPE_TOTALS 0xFF #define REQUEST_TYPE_TOTALS 0xFF
extern uip_ds6_netif_t uip_ds6_if; extern uip_ds6_netif_t uip_ds6_if;
extern uip_ds6_route_t uip_ds6_routing_table[UIP_DS6_ROUTE_NB];
extern uip_ds6_nbr_t uip_ds6_nbr_cache[UIP_DS6_NBR_NB]; extern uip_ds6_nbr_t uip_ds6_nbr_cache[UIP_DS6_NBR_NB];
extern uip_ds6_defrt_t uip_ds6_defrt_list[UIP_DS6_DEFRT_NB]; static uip_ds6_route_t *rt;
static uip_ds6_defrt_t *defrt;
static uip_ipaddr_t *addr;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static uint8_t static uint8_t
process_request() CC_NON_BANKED process_request() CC_NON_BANKED
@ -117,52 +119,52 @@ process_request() CC_NON_BANKED
} }
} else if(buf[0] == REQUEST_TYPE_RT) { } else if(buf[0] == REQUEST_TYPE_RT) {
uint32_t flip = 0; uint32_t flip = 0;
PRINTF("Routing table\n"); PRINTF("Routing table\n");
for(i = buf[1]; i < UIP_DS6_ROUTE_NB; i++) { rt = uip_ds6_route_list_head();
if(uip_ds6_routing_table[i].isused) {
entry_size = sizeof(i) + sizeof(uip_ds6_routing_table[i].ipaddr) for(i = buf[1]; i < uip_ds6_route_num_routes(); i++) {
+ sizeof(uip_ds6_routing_table[i].length) if(rt != NULL) {
+ sizeof(uip_ds6_routing_table[i].metric) entry_size = sizeof(i) + sizeof(rt->ipaddr)
+ sizeof(uip_ds6_routing_table[i].nexthop) + sizeof(rt->length)
+ sizeof(uip_ds6_routing_table[i].state.lifetime) + sizeof(rt->metric)
+ sizeof(uip_ds6_routing_table[i].state.learned_from); + sizeof(rt->nexthop)
+ sizeof(rt->state.lifetime)
+ sizeof(rt->state.learned_from);
memcpy(buf + len, &i, sizeof(i)); memcpy(buf + len, &i, sizeof(i));
len += sizeof(i); len += sizeof(i);
memcpy(buf + len, &uip_ds6_routing_table[i].ipaddr, memcpy(buf + len, &rt->ipaddr, sizeof(rt->ipaddr));
sizeof(uip_ds6_routing_table[i].ipaddr)); len += sizeof(rt->ipaddr);
len += sizeof(uip_ds6_routing_table[i].ipaddr); memcpy(buf + len, &rt->length, sizeof(rt->length));
memcpy(buf + len, &uip_ds6_routing_table[i].length, len += sizeof(rt->length);
sizeof(uip_ds6_routing_table[i].length)); memcpy(buf + len, &rt->metric, sizeof(rt->metric));
len += sizeof(uip_ds6_routing_table[i].length); len += sizeof(rt->metric);
memcpy(buf + len, &uip_ds6_routing_table[i].metric, memcpy(buf + len, &rt->nexthop, sizeof(rt->nexthop));
sizeof(uip_ds6_routing_table[i].metric)); len += sizeof(rt->nexthop);
len += sizeof(uip_ds6_routing_table[i].metric);
memcpy(buf + len, &uip_ds6_routing_table[i].nexthop,
sizeof(uip_ds6_routing_table[i].nexthop));
len += sizeof(uip_ds6_routing_table[i].nexthop);
PRINT6ADDR(&uip_ds6_routing_table[i].ipaddr); PRINT6ADDR(&rt->ipaddr);
PRINTF(" - %02x", uip_ds6_routing_table[i].length); PRINTF(" - %02x", rt->length);
PRINTF(" - %02x", uip_ds6_routing_table[i].metric); PRINTF(" - %02x", rt->metric);
PRINTF(" - "); PRINTF(" - ");
PRINT6ADDR(&uip_ds6_routing_table[i].nexthop); PRINT6ADDR(&rt->nexthop);
flip = uip_htonl(uip_ds6_routing_table[i].state.lifetime); flip = uip_htonl(rt->state.lifetime);
memcpy(buf + len, &flip, sizeof(flip)); memcpy(buf + len, &flip, sizeof(flip));
len += sizeof(flip); len += sizeof(flip);
PRINTF(" - %08lx", uip_ds6_routing_table[i].state.lifetime); PRINTF(" - %08lx", rt->state.lifetime);
memcpy(buf + len, &uip_ds6_routing_table[i].state.learned_from, memcpy(buf + len, &rt->state.learned_from,
sizeof(uip_ds6_routing_table[i].state.learned_from)); sizeof(rt->state.learned_from));
len += sizeof(uip_ds6_routing_table[i].state.learned_from); len += sizeof(rt->state.learned_from);
PRINTF(" - %02x [%u]\n", uip_ds6_routing_table[i].state.learned_from, PRINTF(" - %02x [%u]\n", rt->state.learned_from, entry_size);
entry_size);
count++; count++;
left -= entry_size; left -= entry_size;
rt = list_item_next(rt);
if(left < entry_size) { if(left < entry_size) {
break; break;
} }
@ -170,30 +172,30 @@ process_request() CC_NON_BANKED
} }
} else if(buf[0] == REQUEST_TYPE_DRT) { } else if(buf[0] == REQUEST_TYPE_DRT) {
uint32_t flip = 0; uint32_t flip = 0;
PRINTF("Default Routes\n");
for(i = buf[1]; i < UIP_DS6_DEFRT_NB; i++) { PRINTF("Default Route\n");
if(uip_ds6_defrt_list[i].isused) { addr = uip_ds6_defrt_choose();
entry_size = sizeof(i) + sizeof(uip_ds6_defrt_list[i].ipaddr) if(addr != NULL) {
+ sizeof(uip_ds6_defrt_list[i].isinfinite); defrt = uip_ds6_defrt_lookup(addr);
}
i = buf[1];
if(defrt != NULL && i < 1) {
entry_size = sizeof(i) + sizeof(defrt->ipaddr)
+ sizeof(defrt->isinfinite);
memcpy(buf + len, &i, sizeof(i)); memcpy(buf + len, &i, sizeof(i));
len += sizeof(i); len += sizeof(i);
memcpy(buf + len, &uip_ds6_defrt_list[i].ipaddr, memcpy(buf + len, &defrt->ipaddr, sizeof(defrt->ipaddr));
sizeof(uip_ds6_defrt_list[i].ipaddr)); len += sizeof(defrt->ipaddr);
len += sizeof(uip_ds6_defrt_list[i].ipaddr); memcpy(buf + len, &defrt->isinfinite, sizeof(defrt->isinfinite));
memcpy(buf + len, &uip_ds6_defrt_list[i].isinfinite, len += sizeof(defrt->isinfinite);
sizeof(uip_ds6_defrt_list[i].isinfinite));
len += sizeof(uip_ds6_defrt_list[i].isinfinite);
PRINT6ADDR(&uip_ds6_defrt_list[i].ipaddr); PRINT6ADDR(&defrt->ipaddr);
PRINTF(" - %u\n", uip_ds6_defrt_list[i].isinfinite); PRINTF(" - %u\n", defrt->isinfinite);
count++; count++;
left -= entry_size; left -= entry_size;
if(left < entry_size) {
break;
}
}
} }
} else if(buf[0] == REQUEST_TYPE_ADDR) { } else if(buf[0] == REQUEST_TYPE_ADDR) {
PRINTF("Unicast Addresses\n"); PRINTF("Unicast Addresses\n");
@ -229,16 +231,10 @@ process_request() CC_NON_BANKED
buf[3]++; buf[3]++;
} }
} }
for(i = 0; i < UIP_DS6_ROUTE_NB; i++) {
if(uip_ds6_routing_table[i].isused) { buf[4] = uip_ds6_route_num_routes();
buf[4]++; buf[5] = 1;
}
}
for(i = 0; i < UIP_DS6_DEFRT_NB; i++) {
if(uip_ds6_defrt_list[i].isused) {
buf[5]++;
}
}
len += 4; len += 4;
count = 4; count = 4;
} else { } else {

View File

@ -13,6 +13,8 @@ hello-world/native \
hello-world/sky \ hello-world/sky \
hello-world/wismote \ hello-world/wismote \
hello-world/z1 \ hello-world/z1 \
hello-world/sensinode \
hello-world/cc2530dk \
ipv6/rpl-border-router/econotag \ ipv6/rpl-border-router/econotag \
collect/sky \ collect/sky \
er-rest-example/sky \ er-rest-example/sky \
@ -34,7 +36,15 @@ webserver/minimal-net \
webserver-ipv6/sky \ webserver-ipv6/sky \
webserver-ipv6/econotag \ webserver-ipv6/econotag \
wget/minimal-net \ wget/minimal-net \
z1/z1 z1/z1 \
sensinode/sensinode \
sensinode/border-router/sensinode \
sensinode/udp-ipv6/sensinode \
sensinode/sniffer/sensinode \
cc2530dk/cc2530dk \
cc2530dk/border-router/cc2530dk \
cc2530dk/udp-ipv6/cc2530dk \
cc2530dk/sniffer/cc2530dk
TOOLS= TOOLS=