Merge pull request #59 from g-oikonomou/8051-regressions
8051-based ports: Regression tests and code cleanup
This commit is contained in:
commit
70e46f3248
85 changed files with 669 additions and 837 deletions
13
.gitignore
vendored
13
.gitignore
vendored
|
@ -41,3 +41,16 @@ tools/cooja/apps/serial_socket/lib/
|
|||
tools/coffee-manager/coffee.jar
|
||||
tools/cooja/apps/avrora/lib/cooja_avrora.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
|
||||
|
|
|
@ -4,10 +4,16 @@ before_script:
|
|||
## Install these mainline toolchains for all build types
|
||||
- "sudo apt-get -qq install gcc-msp430 || 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
|
||||
- "[ $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 \
|
||||
| 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
|
||||
- "[ $MAKE_TARGETS = cooja ] && java -version && ant -q -f tools/cooja/build.xml jar || true"
|
||||
|
||||
|
|
|
@ -686,8 +686,7 @@ off(void)
|
|||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const struct radio_driver cc2430_rf_driver =
|
||||
{
|
||||
const struct radio_driver cc2430_rf_driver = {
|
||||
init,
|
||||
prepare,
|
||||
transmit,
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
#endif
|
||||
|
||||
/* Constants */
|
||||
typedef enum rf_address_mode_t
|
||||
{
|
||||
typedef enum rf_address_mode_t {
|
||||
RF_DECODER_NONE = 0,
|
||||
RF_DECODER_COORDINATOR,
|
||||
RF_SOFTACK_MONITOR,
|
||||
|
|
|
@ -25,7 +25,7 @@ void uart0_set_input(int (*input)(unsigned char c));
|
|||
void uart0_rx_ISR(void) __interrupt(URX0_VECTOR);
|
||||
void uart0_tx_ISR(void) __interrupt(UTX0_VECTOR);
|
||||
/* 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 /* UART_0_H */
|
||||
|
|
|
@ -25,7 +25,7 @@ void uart1_set_input(int (*input)(unsigned char c));
|
|||
void uart1_rx_ISR(void) __interrupt(URX1_VECTOR);
|
||||
void uart1_tx_ISR(void) __interrupt(UTX1_VECTOR);
|
||||
/* 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
|
||||
#define UART1_RX_INT(v)
|
||||
#endif /* UART_ONE_CONF_WITH_INPUT */
|
||||
|
|
|
@ -47,4 +47,3 @@ struct mtarch_thread {
|
|||
};
|
||||
|
||||
#endif /* __MTARCH_H__ */
|
||||
|
||||
|
|
|
@ -483,8 +483,7 @@ off(void)
|
|||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
const struct radio_driver cc2530_rf_driver =
|
||||
{
|
||||
const struct radio_driver cc2530_rf_driver = {
|
||||
init,
|
||||
prepare,
|
||||
transmit,
|
||||
|
|
|
@ -88,7 +88,7 @@ dma_reset(uint8_t c)
|
|||
dma_conf[c].len_l = 1;
|
||||
dma_conf[c].wtt = DMA_BLOCK;
|
||||
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);
|
||||
while(DMAARM & (1 << c));
|
||||
}
|
||||
|
|
|
@ -47,4 +47,3 @@ struct mtarch_thread {
|
|||
};
|
||||
|
||||
#endif /* __MTARCH_H__ */
|
||||
|
||||
|
|
|
@ -47,4 +47,3 @@ netstack_init(void)
|
|||
NETSTACK_RADIO.init();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
|
|
|
@ -48,7 +48,8 @@ AUTOSTART_PROCESSES(&clock_test_process);
|
|||
/*---------------------------------------------------------------------------*/
|
||||
#if TEST_RTIMER
|
||||
void
|
||||
rt_callback(struct rtimer *t, void *ptr) {
|
||||
rt_callback(struct rtimer *t, void *ptr)
|
||||
{
|
||||
rt_now = RTIMER_NOW();
|
||||
ct = clock_time();
|
||||
printf("Task called at %u (clock = %u)\n", rt_now, ct);
|
||||
|
|
|
@ -72,7 +72,8 @@ ping6handler()
|
|||
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[1] = (uint8_t)((uip_len - 40) & 0x00FF);
|
||||
|
||||
|
|
|
@ -92,9 +92,10 @@ static void
|
|||
print_stats()
|
||||
{
|
||||
PRINTF("tl=%lu, ts=%lu, bs=%lu, bc=%lu\n",
|
||||
rimestats.toolong, rimestats.tooshort, rimestats.badsynch, rimestats.badcrc);
|
||||
PRINTF("llrx=%lu, lltx=%lu, rx=%lu, tx=%lu\n",
|
||||
rimestats.llrx, rimestats.lltx, rimestats.rx, rimestats.tx);
|
||||
rimestats.toolong, rimestats.tooshort, rimestats.badsynch,
|
||||
rimestats.badcrc);
|
||||
PRINTF("llrx=%lu, lltx=%lu, rx=%lu, tx=%lu\n", rimestats.llrx,
|
||||
rimestats.lltx, rimestats.rx, rimestats.tx);
|
||||
}
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -131,7 +132,8 @@ create_dag()
|
|||
|
||||
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) {
|
||||
uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
|
||||
rpl_set_prefix(dag, &ipaddr, 64);
|
||||
|
|
|
@ -8,9 +8,6 @@ DEFINES+=MODEL_N740
|
|||
# These examples don't need code banking so we turn it off
|
||||
#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
|
||||
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
|
|
@ -36,13 +36,6 @@ make hello_world DEFINES=MODEL_N601
|
|||
These make options are defined in /platform/sensinode/Makefile.sensinode
|
||||
|
||||
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
|
||||
addresses. Button 1 on the client will send an echo request.
|
||||
broadcast-rime Just a broadcast rime example, slightly modified
|
||||
|
|
|
@ -10,61 +10,36 @@
|
|||
#include "contiki.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(blink_process, "LED blink process");
|
||||
|
||||
/* We require the processes to be started automatically */
|
||||
AUTOSTART_PROCESSES(&hello_world_process, &blink_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Implementation of the first process */
|
||||
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 int count;
|
||||
|
||||
/* any process must start with this. */
|
||||
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);
|
||||
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... */
|
||||
if(ev == PROCESS_EVENT_TIMER)
|
||||
{
|
||||
/* do the process work */
|
||||
while(1) {
|
||||
|
||||
PROCESS_WAIT_EVENT();
|
||||
|
||||
if(ev == PROCESS_EVENT_TIMER) {
|
||||
printf("Sensor says no... #%d\r\n", count);
|
||||
count++;
|
||||
|
||||
/* reset the timer so it will generate an other event
|
||||
* the exact same time after it expired (periodicity guaranteed) */
|
||||
etimer_reset(&timer);
|
||||
}
|
||||
|
||||
/* and loop */
|
||||
}
|
||||
/* any process must end with this, even if it is never reached. */
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -74,16 +49,12 @@ PROCESS_THREAD(blink_process, ev, data)
|
|||
static struct etimer timer;
|
||||
PROCESS_BEGIN();
|
||||
|
||||
while (1)
|
||||
{
|
||||
/* we set the timer from here every time */
|
||||
while(1) {
|
||||
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);
|
||||
|
||||
printf("Blink... (state %0.2X).\r\n", leds_get());
|
||||
/* update the LEDs */
|
||||
leds_toggle(LEDS_GREEN);
|
||||
}
|
||||
PROCESS_END();
|
||||
|
|
|
@ -58,14 +58,18 @@
|
|||
PROCESS(example_broadcast_process, "BROADCAST example");
|
||||
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);
|
||||
PRINTF("broadcast message received from %02x.%02x\n", from->u8[0], from->u8[1]);
|
||||
PRINTF("Size=0x%02x: '0x%04x'\n", packetbuf_datalen(), *(uint16_t *) packetbuf_dataptr());
|
||||
PRINTF("broadcast message received from %02x.%02x\n", from->u8[0],
|
||||
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(" TX=%lu , RX=%lu\n", rimestats.tx, rimestats.rx);
|
||||
|
@ -90,7 +94,7 @@ PROCESS_THREAD(example_broadcast_process, ev, data)
|
|||
PRINTF("Start\n");
|
||||
broadcast_open(&broadcast, BROADCAST_CHANNEL, &bc_rx);
|
||||
PRINTF("Open Broadcast Connection, channel %u\n", BROADCAST_CHANNEL);
|
||||
// leds_off(LEDS_ALL);
|
||||
|
||||
while(1) {
|
||||
|
||||
/* Delay 2-4 seconds */
|
||||
|
@ -98,7 +102,8 @@ PROCESS_THREAD(example_broadcast_process, ev, data)
|
|||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||
leds_on(LEDS_GREEN);
|
||||
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) {
|
||||
PRINTF("Error Sending\n");
|
||||
}
|
||||
|
|
|
@ -181,7 +181,8 @@ broadcast_recv(struct broadcast_conn *c, const rimeaddr_t *from)
|
|||
/* Convert RSSI to the loc. eng. format */
|
||||
parameters.rssi[from->u8[1] - 1] = (-2 * rssi);
|
||||
/* 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;
|
||||
|
@ -194,7 +195,8 @@ broadcast_recv(struct broadcast_conn *c, const rimeaddr_t *from)
|
|||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
set_imaginary_ref_nodes() {
|
||||
set_imaginary_ref_nodes()
|
||||
{
|
||||
ref_coords[0].x = 1;
|
||||
ref_coords[0].y = 5;
|
||||
parameters.rssi[0] = SAMPLE_RSSI;
|
||||
|
@ -266,7 +268,9 @@ PROCESS_THREAD(blindnode_bcast_rec, ev, data)
|
|||
parameters.n = n;
|
||||
calculate();
|
||||
n++;
|
||||
if(n==32) { n=0; }
|
||||
if(n == 32) {
|
||||
n = 0;
|
||||
}
|
||||
|
||||
/* Send our calculated location to some monitoring node */
|
||||
packetbuf_copyfrom(&coords, 2 * sizeof(uint8_t));
|
||||
|
|
|
@ -47,4 +47,3 @@ netstack_init(void)
|
|||
NETSTACK_RADIO.init();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
|
|
|
@ -14,67 +14,44 @@
|
|||
#include "contiki.h"
|
||||
//#include "dev/leds.h"
|
||||
#include <limits.h>
|
||||
#include <stdio.h> /* For printf() */
|
||||
#include <stdio.h>
|
||||
#include "event-post.h"
|
||||
|
||||
/* This is our event type */
|
||||
static process_event_t event_data_ready;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Declare the two processes here */
|
||||
PROCESS(sensor_process, "Sensor process");
|
||||
PROCESS(print_process, "Print process");
|
||||
|
||||
/* Tell Contiki that we want them to start automatically */
|
||||
AUTOSTART_PROCESSES(&sensor_process, &print_process);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Implementation "Sensor Process" */
|
||||
PROCESS_THREAD(sensor_process, ev, data)
|
||||
{
|
||||
/* static variables to preserve values across consecutive calls of this
|
||||
* process. */
|
||||
/* Set an etimer */
|
||||
static struct etimer timer;
|
||||
/* And the 'sensor' monitoring variable */
|
||||
static struct event_struct es;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
/* Set some near-the-limit initial values */
|
||||
/* signed primitives */
|
||||
es.s_val = SHRT_MAX - 2;
|
||||
es.i_val = INT_MAX - 2;
|
||||
es.l_val = LONG_MAX - 2;
|
||||
/* sizeof(long long) == sizeof(long) on sensinodes - see other examples*/
|
||||
es.ll_val = LONG_MAX - 2;
|
||||
/* and some typedef-ed unsigned variables */
|
||||
es.u8_val = UCHAR_MAX - 2;
|
||||
es.u16_val = USHRT_MAX - 2;
|
||||
es.u32_val = ULONG_MAX - 2;
|
||||
|
||||
/* allocate the required 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);
|
||||
|
||||
/* 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);
|
||||
|
||||
while (1)
|
||||
{
|
||||
while(1) {
|
||||
printf("Sensor process: Wait for timer event...\r\n");
|
||||
/* Wait on our 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");
|
||||
es.s_val++;
|
||||
es.i_val++;
|
||||
|
@ -84,13 +61,9 @@ PROCESS_THREAD(sensor_process, ev, data)
|
|||
es.u16_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");
|
||||
process_post(&print_process, event_data_ready, &es);
|
||||
|
||||
/* reset the timer so we can wait on it again */
|
||||
etimer_reset(&timer);
|
||||
|
||||
}
|
||||
|
@ -105,16 +78,10 @@ PROCESS_THREAD(print_process, ev, data)
|
|||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
while (1)
|
||||
{
|
||||
/* Stop here and wait until "event_data_ready" occurs */
|
||||
while(1) {
|
||||
|
||||
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;
|
||||
printf("Print Process - Data Ready:\r\n");
|
||||
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(" u32: %lu\r\n", sd->u32_val);
|
||||
|
||||
/* aaaaand back to waiting for the next event */
|
||||
}
|
||||
PROCESS_END();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -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();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -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();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -110,7 +110,9 @@
|
|||
#define SEND_BATTERY_INFO 0
|
||||
#if SEND_BATTERY_INFO
|
||||
#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;
|
||||
}
|
||||
|
||||
|
@ -217,7 +219,8 @@ PROCESS_THREAD(sensors_test_process, ev, data)
|
|||
sane = ((rv * 0.61065 - 773) / 2.45);
|
||||
dec = sane;
|
||||
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
|
||||
|
@ -305,7 +308,8 @@ PROCESS_THREAD(sensors_test_process, ev, data)
|
|||
sane = (float)(rv * 0.4071);
|
||||
dec = sane;
|
||||
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.
|
||||
|
|
|
@ -47,4 +47,3 @@ netstack_init(void)
|
|||
NETSTACK_RADIO.init();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
|
|
|
@ -48,7 +48,8 @@ AUTOSTART_PROCESSES(&clock_test_process);
|
|||
/*---------------------------------------------------------------------------*/
|
||||
#if TEST_RTIMER
|
||||
void
|
||||
rt_callback(struct rtimer *t, void *ptr) {
|
||||
rt_callback(struct rtimer *t, void *ptr)
|
||||
{
|
||||
rt_now = RTIMER_NOW();
|
||||
ct = clock_time();
|
||||
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_for = rt_now + RTIMER_SECOND;
|
||||
printf("Now=%u (clock = %u) - For=%u\n", rt_now, ct, rt_for);
|
||||
if (rtimer_set(&rt, rt_for, 1,
|
||||
(void (*)(struct rtimer *, void *))rt_callback, NULL) != RTIMER_OK) {
|
||||
if(rtimer_set(&rt, rt_for, 1, (rtimer_callback_t) rt_callback, NULL) !=
|
||||
RTIMER_OK) {
|
||||
printf("Error setting\n");
|
||||
}
|
||||
|
||||
|
@ -99,7 +100,8 @@ PROCESS_THREAD(clock_test_process, ev, data)
|
|||
#endif
|
||||
|
||||
#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;
|
||||
while(i < 10) {
|
||||
etimer_set(&et, CLOCK_SECOND);
|
||||
|
|
|
@ -182,7 +182,8 @@ PROCESS_THREAD(udp_client_process, ev, data)
|
|||
UIP_HTONS(l_conn->lport), UIP_HTONS(l_conn->rport));
|
||||
|
||||
#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);
|
||||
if(!g_conn) {
|
||||
PRINTF("udp_new g_conn error.\n");
|
||||
|
|
|
@ -110,7 +110,8 @@ PROCESS_THREAD(ping6_process, ev, data)
|
|||
PRINTF("ping6 running.\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;
|
||||
|
||||
/* Check if we have buttons */
|
||||
|
|
|
@ -104,9 +104,10 @@ static void
|
|||
print_stats()
|
||||
{
|
||||
PRINTF("tl=%lu, ts=%lu, bs=%lu, bc=%lu\n",
|
||||
rimestats.toolong, rimestats.tooshort, rimestats.badsynch, rimestats.badcrc);
|
||||
PRINTF("llrx=%lu, lltx=%lu, rx=%lu, tx=%lu\n",
|
||||
rimestats.llrx, rimestats.lltx, rimestats.rx, rimestats.tx);
|
||||
rimestats.toolong, rimestats.tooshort, rimestats.badsynch,
|
||||
rimestats.badcrc);
|
||||
PRINTF("llrx=%lu, lltx=%lu, rx=%lu, tx=%lu\n", rimestats.llrx,
|
||||
rimestats.lltx, rimestats.rx, rimestats.tx);
|
||||
}
|
||||
#else
|
||||
#define print_stats()
|
||||
|
@ -145,7 +146,8 @@ create_dag()
|
|||
|
||||
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) {
|
||||
uip_ip6addr(&ipaddr, 0x2001, 0x630, 0x301, 0x6453, 0, 0, 0, 0);
|
||||
rpl_set_prefix(dag, &ipaddr, 64);
|
||||
|
|
|
@ -54,4 +54,3 @@ putdec(uint8_t c)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,15 +40,15 @@ static CC_AT_DATA struct timer debouncetimer;
|
|||
/*---------------------------------------------------------------------------*/
|
||||
/* Button 1 - SmartRF and cc2531 USB Dongle */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
int value_b1(int type)
|
||||
static int
|
||||
value_b1(int type)
|
||||
{
|
||||
type;
|
||||
return BUTTON_READ(1) || !timer_expired(&debouncetimer);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
int status_b1(int type)
|
||||
static int
|
||||
status_b1(int type)
|
||||
{
|
||||
switch(type) {
|
||||
case SENSORS_ACTIVE:
|
||||
|
@ -58,8 +58,8 @@ int status_b1(int type)
|
|||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
int configure_b1(int type, int value)
|
||||
static int
|
||||
configure_b1(int type, int value)
|
||||
{
|
||||
switch(type) {
|
||||
case SENSORS_HW_INIT:
|
||||
|
@ -88,15 +88,15 @@ int configure_b1(int type, int value)
|
|||
/* Button 2 - cc2531 USb Dongle only */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if MODEL_CC2531
|
||||
static
|
||||
int value_b2(int type)
|
||||
static int
|
||||
value_b2(int type)
|
||||
{
|
||||
type;
|
||||
return BUTTON_READ(2) || !timer_expired(&debouncetimer);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
int status_b2(int type)
|
||||
static int
|
||||
status_b2(int type)
|
||||
{
|
||||
switch(type) {
|
||||
case SENSORS_ACTIVE:
|
||||
|
@ -106,8 +106,8 @@ int status_b2(int type)
|
|||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
int configure_b2(int type, int value)
|
||||
static int
|
||||
configure_b2(int type, int value)
|
||||
{
|
||||
switch(type) {
|
||||
case SENSORS_HW_INIT:
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "contiki.h"
|
||||
#include "contiki-lib.h"
|
||||
#include "contiki-net.h"
|
||||
#include "net/uip-ds6-route.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
@ -68,9 +69,10 @@ static int8_t len;
|
|||
#define REQUEST_TYPE_TOTALS 0xFF
|
||||
|
||||
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_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
|
||||
process_request() CC_NON_BANKED
|
||||
|
@ -117,52 +119,52 @@ process_request() CC_NON_BANKED
|
|||
}
|
||||
} else if(buf[0] == REQUEST_TYPE_RT) {
|
||||
uint32_t flip = 0;
|
||||
|
||||
PRINTF("Routing table\n");
|
||||
for(i = buf[1]; i < UIP_DS6_ROUTE_NB; i++) {
|
||||
if(uip_ds6_routing_table[i].isused) {
|
||||
entry_size = sizeof(i) + sizeof(uip_ds6_routing_table[i].ipaddr)
|
||||
+ sizeof(uip_ds6_routing_table[i].length)
|
||||
+ sizeof(uip_ds6_routing_table[i].metric)
|
||||
+ sizeof(uip_ds6_routing_table[i].nexthop)
|
||||
+ sizeof(uip_ds6_routing_table[i].state.lifetime)
|
||||
+ sizeof(uip_ds6_routing_table[i].state.learned_from);
|
||||
rt = uip_ds6_route_list_head();
|
||||
|
||||
for(i = buf[1]; i < uip_ds6_route_num_routes(); i++) {
|
||||
if(rt != NULL) {
|
||||
entry_size = sizeof(i) + sizeof(rt->ipaddr)
|
||||
+ sizeof(rt->length)
|
||||
+ sizeof(rt->metric)
|
||||
+ sizeof(rt->nexthop)
|
||||
+ sizeof(rt->state.lifetime)
|
||||
+ sizeof(rt->state.learned_from);
|
||||
|
||||
memcpy(buf + len, &i, sizeof(i));
|
||||
len += sizeof(i);
|
||||
memcpy(buf + len, &uip_ds6_routing_table[i].ipaddr,
|
||||
sizeof(uip_ds6_routing_table[i].ipaddr));
|
||||
len += sizeof(uip_ds6_routing_table[i].ipaddr);
|
||||
memcpy(buf + len, &uip_ds6_routing_table[i].length,
|
||||
sizeof(uip_ds6_routing_table[i].length));
|
||||
len += sizeof(uip_ds6_routing_table[i].length);
|
||||
memcpy(buf + len, &uip_ds6_routing_table[i].metric,
|
||||
sizeof(uip_ds6_routing_table[i].metric));
|
||||
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);
|
||||
memcpy(buf + len, &rt->ipaddr, sizeof(rt->ipaddr));
|
||||
len += sizeof(rt->ipaddr);
|
||||
memcpy(buf + len, &rt->length, sizeof(rt->length));
|
||||
len += sizeof(rt->length);
|
||||
memcpy(buf + len, &rt->metric, sizeof(rt->metric));
|
||||
len += sizeof(rt->metric);
|
||||
memcpy(buf + len, &rt->nexthop, sizeof(rt->nexthop));
|
||||
len += sizeof(rt->nexthop);
|
||||
|
||||
PRINT6ADDR(&uip_ds6_routing_table[i].ipaddr);
|
||||
PRINTF(" - %02x", uip_ds6_routing_table[i].length);
|
||||
PRINTF(" - %02x", uip_ds6_routing_table[i].metric);
|
||||
PRINT6ADDR(&rt->ipaddr);
|
||||
PRINTF(" - %02x", rt->length);
|
||||
PRINTF(" - %02x", rt->metric);
|
||||
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));
|
||||
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,
|
||||
sizeof(uip_ds6_routing_table[i].state.learned_from));
|
||||
len += sizeof(uip_ds6_routing_table[i].state.learned_from);
|
||||
memcpy(buf + len, &rt->state.learned_from,
|
||||
sizeof(rt->state.learned_from));
|
||||
len += sizeof(rt->state.learned_from);
|
||||
|
||||
PRINTF(" - %02x [%u]\n", uip_ds6_routing_table[i].state.learned_from,
|
||||
entry_size);
|
||||
PRINTF(" - %02x [%u]\n", rt->state.learned_from, entry_size);
|
||||
|
||||
count++;
|
||||
left -= entry_size;
|
||||
|
||||
rt = list_item_next(rt);
|
||||
|
||||
if(left < entry_size) {
|
||||
break;
|
||||
}
|
||||
|
@ -170,30 +172,30 @@ process_request() CC_NON_BANKED
|
|||
}
|
||||
} else if(buf[0] == REQUEST_TYPE_DRT) {
|
||||
uint32_t flip = 0;
|
||||
PRINTF("Default Routes\n");
|
||||
for(i = buf[1]; i < UIP_DS6_DEFRT_NB; i++) {
|
||||
if(uip_ds6_defrt_list[i].isused) {
|
||||
entry_size = sizeof(i) + sizeof(uip_ds6_defrt_list[i].ipaddr)
|
||||
+ sizeof(uip_ds6_defrt_list[i].isinfinite);
|
||||
|
||||
PRINTF("Default Route\n");
|
||||
addr = uip_ds6_defrt_choose();
|
||||
if(addr != NULL) {
|
||||
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));
|
||||
len += sizeof(i);
|
||||
memcpy(buf + len, &uip_ds6_defrt_list[i].ipaddr,
|
||||
sizeof(uip_ds6_defrt_list[i].ipaddr));
|
||||
len += sizeof(uip_ds6_defrt_list[i].ipaddr);
|
||||
memcpy(buf + len, &uip_ds6_defrt_list[i].isinfinite,
|
||||
sizeof(uip_ds6_defrt_list[i].isinfinite));
|
||||
len += sizeof(uip_ds6_defrt_list[i].isinfinite);
|
||||
memcpy(buf + len, &defrt->ipaddr, sizeof(defrt->ipaddr));
|
||||
len += sizeof(defrt->ipaddr);
|
||||
memcpy(buf + len, &defrt->isinfinite, sizeof(defrt->isinfinite));
|
||||
len += sizeof(defrt->isinfinite);
|
||||
|
||||
PRINT6ADDR(&uip_ds6_defrt_list[i].ipaddr);
|
||||
PRINTF(" - %u\n", uip_ds6_defrt_list[i].isinfinite);
|
||||
PRINT6ADDR(&defrt->ipaddr);
|
||||
PRINTF(" - %u\n", defrt->isinfinite);
|
||||
count++;
|
||||
left -= entry_size;
|
||||
|
||||
if(left < entry_size) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(buf[0] == REQUEST_TYPE_ADDR) {
|
||||
PRINTF("Unicast Addresses\n");
|
||||
|
@ -229,16 +231,10 @@ process_request() CC_NON_BANKED
|
|||
buf[3]++;
|
||||
}
|
||||
}
|
||||
for(i = 0; i < UIP_DS6_ROUTE_NB; i++) {
|
||||
if(uip_ds6_routing_table[i].isused) {
|
||||
buf[4]++;
|
||||
}
|
||||
}
|
||||
for(i = 0; i < UIP_DS6_DEFRT_NB; i++) {
|
||||
if(uip_ds6_defrt_list[i].isused) {
|
||||
buf[5]++;
|
||||
}
|
||||
}
|
||||
|
||||
buf[4] = uip_ds6_route_num_routes();
|
||||
buf[5] = 1;
|
||||
|
||||
len += 4;
|
||||
count = 4;
|
||||
} else {
|
||||
|
|
|
@ -59,14 +59,14 @@ HWCONF_PORT_0_IRQ(BUTTON_2, 7)
|
|||
#endif /* MODEL_N711 */
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
int value_b1(int type)
|
||||
static int
|
||||
value_b1(int type)
|
||||
{
|
||||
return BUTTON_1_READ() || !timer_expired(&debouncetimer[0]);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
int status_b1(int type)
|
||||
static int
|
||||
status_b1(int type)
|
||||
{
|
||||
switch(type) {
|
||||
case SENSORS_ACTIVE:
|
||||
|
@ -76,8 +76,8 @@ int status_b1(int type)
|
|||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
int configure_b1(int type, int value)
|
||||
static int
|
||||
configure_b1(int type, int value)
|
||||
{
|
||||
switch(type) {
|
||||
case SENSORS_HW_INIT:
|
||||
|
@ -101,14 +101,14 @@ int configure_b1(int type, int value)
|
|||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
int value_b2(int type)
|
||||
static int
|
||||
value_b2(int type)
|
||||
{
|
||||
return BUTTON_2_READ() || !timer_expired(&debouncetimer[1]);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
int status_b2(int type)
|
||||
static int
|
||||
status_b2(int type)
|
||||
{
|
||||
switch(type) {
|
||||
case SENSORS_ACTIVE:
|
||||
|
@ -118,8 +118,8 @@ int status_b2(int type)
|
|||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
int configure_b2(int type, int value)
|
||||
static int
|
||||
configure_b2(int type, int value)
|
||||
{
|
||||
switch(type) {
|
||||
case SENSORS_HW_INIT:
|
||||
|
|
|
@ -281,7 +281,8 @@ m25p16_dp()
|
|||
* Release Deep Power Down. We do NOT read the Electronic Signature
|
||||
*/
|
||||
void
|
||||
m25p16_res() {
|
||||
m25p16_res()
|
||||
{
|
||||
select();
|
||||
bit_bang_write(M25P16_I_RES);
|
||||
deselect();
|
||||
|
@ -296,7 +297,8 @@ m25p16_res() {
|
|||
* \return The old style Electronic Signature. This must be 0x14
|
||||
*/
|
||||
uint8_t
|
||||
m25p16_res_res() {
|
||||
m25p16_res_res()
|
||||
{
|
||||
uint8_t rv;
|
||||
|
||||
select();
|
||||
|
|
|
@ -213,7 +213,8 @@ cmd_init() CC_NON_BANKED
|
|||
static uint8_t
|
||||
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) {
|
||||
resp.status = DISCO_ERR_BAD_LEN;
|
||||
return DISCO_RESP_LEN_ERR;
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "contiki.h"
|
||||
#include "contiki-lib.h"
|
||||
#include "contiki-net.h"
|
||||
#include "net/uip-ds6-route.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
@ -68,9 +69,10 @@ static int8_t len;
|
|||
#define REQUEST_TYPE_TOTALS 0xFF
|
||||
|
||||
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_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
|
||||
process_request() CC_NON_BANKED
|
||||
|
@ -117,52 +119,52 @@ process_request() CC_NON_BANKED
|
|||
}
|
||||
} else if(buf[0] == REQUEST_TYPE_RT) {
|
||||
uint32_t flip = 0;
|
||||
|
||||
PRINTF("Routing table\n");
|
||||
for(i = buf[1]; i < UIP_DS6_ROUTE_NB; i++) {
|
||||
if(uip_ds6_routing_table[i].isused) {
|
||||
entry_size = sizeof(i) + sizeof(uip_ds6_routing_table[i].ipaddr)
|
||||
+ sizeof(uip_ds6_routing_table[i].length)
|
||||
+ sizeof(uip_ds6_routing_table[i].metric)
|
||||
+ sizeof(uip_ds6_routing_table[i].nexthop)
|
||||
+ sizeof(uip_ds6_routing_table[i].state.lifetime)
|
||||
+ sizeof(uip_ds6_routing_table[i].state.learned_from);
|
||||
rt = uip_ds6_route_list_head();
|
||||
|
||||
for(i = buf[1]; i < uip_ds6_route_num_routes(); i++) {
|
||||
if(rt != NULL) {
|
||||
entry_size = sizeof(i) + sizeof(rt->ipaddr)
|
||||
+ sizeof(rt->length)
|
||||
+ sizeof(rt->metric)
|
||||
+ sizeof(rt->nexthop)
|
||||
+ sizeof(rt->state.lifetime)
|
||||
+ sizeof(rt->state.learned_from);
|
||||
|
||||
memcpy(buf + len, &i, sizeof(i));
|
||||
len += sizeof(i);
|
||||
memcpy(buf + len, &uip_ds6_routing_table[i].ipaddr,
|
||||
sizeof(uip_ds6_routing_table[i].ipaddr));
|
||||
len += sizeof(uip_ds6_routing_table[i].ipaddr);
|
||||
memcpy(buf + len, &uip_ds6_routing_table[i].length,
|
||||
sizeof(uip_ds6_routing_table[i].length));
|
||||
len += sizeof(uip_ds6_routing_table[i].length);
|
||||
memcpy(buf + len, &uip_ds6_routing_table[i].metric,
|
||||
sizeof(uip_ds6_routing_table[i].metric));
|
||||
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);
|
||||
memcpy(buf + len, &rt->ipaddr, sizeof(rt->ipaddr));
|
||||
len += sizeof(rt->ipaddr);
|
||||
memcpy(buf + len, &rt->length, sizeof(rt->length));
|
||||
len += sizeof(rt->length);
|
||||
memcpy(buf + len, &rt->metric, sizeof(rt->metric));
|
||||
len += sizeof(rt->metric);
|
||||
memcpy(buf + len, &rt->nexthop, sizeof(rt->nexthop));
|
||||
len += sizeof(rt->nexthop);
|
||||
|
||||
PRINT6ADDR(&uip_ds6_routing_table[i].ipaddr);
|
||||
PRINTF(" - %02x", uip_ds6_routing_table[i].length);
|
||||
PRINTF(" - %02x", uip_ds6_routing_table[i].metric);
|
||||
PRINT6ADDR(&rt->ipaddr);
|
||||
PRINTF(" - %02x", rt->length);
|
||||
PRINTF(" - %02x", rt->metric);
|
||||
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));
|
||||
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,
|
||||
sizeof(uip_ds6_routing_table[i].state.learned_from));
|
||||
len += sizeof(uip_ds6_routing_table[i].state.learned_from);
|
||||
memcpy(buf + len, &rt->state.learned_from,
|
||||
sizeof(rt->state.learned_from));
|
||||
len += sizeof(rt->state.learned_from);
|
||||
|
||||
PRINTF(" - %02x [%u]\n", uip_ds6_routing_table[i].state.learned_from,
|
||||
entry_size);
|
||||
PRINTF(" - %02x [%u]\n", rt->state.learned_from, entry_size);
|
||||
|
||||
count++;
|
||||
left -= entry_size;
|
||||
|
||||
rt = list_item_next(rt);
|
||||
|
||||
if(left < entry_size) {
|
||||
break;
|
||||
}
|
||||
|
@ -170,30 +172,30 @@ process_request() CC_NON_BANKED
|
|||
}
|
||||
} else if(buf[0] == REQUEST_TYPE_DRT) {
|
||||
uint32_t flip = 0;
|
||||
PRINTF("Default Routes\n");
|
||||
for(i = buf[1]; i < UIP_DS6_DEFRT_NB; i++) {
|
||||
if(uip_ds6_defrt_list[i].isused) {
|
||||
entry_size = sizeof(i) + sizeof(uip_ds6_defrt_list[i].ipaddr)
|
||||
+ sizeof(uip_ds6_defrt_list[i].isinfinite);
|
||||
|
||||
PRINTF("Default Route\n");
|
||||
addr = uip_ds6_defrt_choose();
|
||||
if(addr != NULL) {
|
||||
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));
|
||||
len += sizeof(i);
|
||||
memcpy(buf + len, &uip_ds6_defrt_list[i].ipaddr,
|
||||
sizeof(uip_ds6_defrt_list[i].ipaddr));
|
||||
len += sizeof(uip_ds6_defrt_list[i].ipaddr);
|
||||
memcpy(buf + len, &uip_ds6_defrt_list[i].isinfinite,
|
||||
sizeof(uip_ds6_defrt_list[i].isinfinite));
|
||||
len += sizeof(uip_ds6_defrt_list[i].isinfinite);
|
||||
memcpy(buf + len, &defrt->ipaddr, sizeof(defrt->ipaddr));
|
||||
len += sizeof(defrt->ipaddr);
|
||||
memcpy(buf + len, &defrt->isinfinite, sizeof(defrt->isinfinite));
|
||||
len += sizeof(defrt->isinfinite);
|
||||
|
||||
PRINT6ADDR(&uip_ds6_defrt_list[i].ipaddr);
|
||||
PRINTF(" - %u\n", uip_ds6_defrt_list[i].isinfinite);
|
||||
PRINT6ADDR(&defrt->ipaddr);
|
||||
PRINTF(" - %u\n", defrt->isinfinite);
|
||||
count++;
|
||||
left -= entry_size;
|
||||
|
||||
if(left < entry_size) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(buf[0] == REQUEST_TYPE_ADDR) {
|
||||
PRINTF("Unicast Addresses\n");
|
||||
|
@ -229,16 +231,10 @@ process_request() CC_NON_BANKED
|
|||
buf[3]++;
|
||||
}
|
||||
}
|
||||
for(i = 0; i < UIP_DS6_ROUTE_NB; i++) {
|
||||
if(uip_ds6_routing_table[i].isused) {
|
||||
buf[4]++;
|
||||
}
|
||||
}
|
||||
for(i = 0; i < UIP_DS6_DEFRT_NB; i++) {
|
||||
if(uip_ds6_defrt_list[i].isused) {
|
||||
buf[5]++;
|
||||
}
|
||||
}
|
||||
|
||||
buf[4] = uip_ds6_route_num_routes();
|
||||
buf[5] = 1;
|
||||
|
||||
len += 4;
|
||||
count = 4;
|
||||
} else {
|
||||
|
|
|
@ -13,6 +13,8 @@ hello-world/native \
|
|||
hello-world/sky \
|
||||
hello-world/wismote \
|
||||
hello-world/z1 \
|
||||
hello-world/sensinode \
|
||||
hello-world/cc2530dk \
|
||||
ipv6/rpl-border-router/econotag \
|
||||
collect/sky \
|
||||
er-rest-example/sky \
|
||||
|
@ -34,7 +36,15 @@ webserver/minimal-net \
|
|||
webserver-ipv6/sky \
|
||||
webserver-ipv6/econotag \
|
||||
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=
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue