From e9cdacbf517c94f2c7e66a94aebdc0528f6be66c Mon Sep 17 00:00:00 2001 From: Oliver Hahm Date: Thu, 29 Mar 2012 16:27:20 +0200 Subject: [PATCH] [projects test_rpl] [sys net sixlowpan rpl] * removed vtimer_init from rpl_init * some transceiver watchdog workaround foobar --- projects/test_rpl/main.c | 49 ++++++++++++++++++++++++++++++++++--- sys/net/sixlowpan/rpl/rpl.c | 1 - 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/projects/test_rpl/main.c b/projects/test_rpl/main.c index edcfa51793..18f6770c15 100644 --- a/projects/test_rpl/main.c +++ b/projects/test_rpl/main.c @@ -14,7 +14,29 @@ #include "sys/net/sixlowpan/rpl/rpl.h" #include "sys/net/sixlowpan/rpl/rpl_dodag.h" +#define TR_WD_STACKSIZE (256) + +char tr_wd_stack[TR_WD_STACKSIZE]; + +void wakeup_thread(void) { + while (1) { + if (thread_getstatus(transceiver_pid) == STATUS_SLEEPING) { + vtimer_usleep(100 * 1000); + if (thread_getstatus(transceiver_pid) == STATUS_SLEEPING) { + puts("WAKEUP!"); + thread_wakeup(transceiver_pid); + } + } + vtimer_usleep(1000 * 1000); + + } +} + void init(char *str){ + transceiver_command_t tcmd; + msg_t m; + uint8_t chan = 10; + char command; uint16_t r_addr; @@ -54,9 +76,21 @@ void init(char *str){ break; default: printf("ERROR: Unknown command '%c'\n", command); - break; + return; } -} + + /* set channel to 10 */ + tcmd.transceivers = TRANSCEIVER_CC1100; + tcmd.data = &chan; + m.type = SET_CHANNEL; + m.content.ptr = (void*) &tcmd; + + msg_send_receive(&m, &m, transceiver_pid); + + /* start transceiver watchdog */ + thread_create(tr_wd_stack, TR_WD_STACKSIZE, PRIORITY_MAIN-3, CREATE_STACKTEST, wakeup_thread, "TX/RX WD"); + + } void table(char *str){ rpl_routing_entry_t * rtable; @@ -89,9 +123,17 @@ void dodag(char *str){ } extern void cc1100_print_config(void); +extern void cc1100_print_statistic(void); void cc1100_cfg(char* unused) { cc1100_print_config(); + puts("============================================="); + cc1100_print_statistic(); +} + + +void wakeup(char* unused) { + thread_wakeup(10); } const shell_command_t shell_commands[] = { @@ -99,12 +141,13 @@ const shell_command_t shell_commands[] = { {"table", "", table}, {"dodag", "", dodag}, {"cc1100", "", cc1100_cfg}, + {"wakeup", "", wakeup}, {NULL, NULL, NULL} }; int main(void) { printf("RPL Test Application\n"); - vtimer_init(); + posix_open(uart0_handler_pid, 0); diff --git a/sys/net/sixlowpan/rpl/rpl.c b/sys/net/sixlowpan/rpl/rpl.c index 54ffcc9f78..87d6faa6df 100644 --- a/sys/net/sixlowpan/rpl/rpl.c +++ b/sys/net/sixlowpan/rpl/rpl.c @@ -142,7 +142,6 @@ rpl_of_t *rpl_get_of_for_ocp(uint16_t ocp){ } uint8_t rpl_init(transceiver_type_t trans, uint16_t rpl_address){ - vtimer_init(); mutex_init(&rpl_send_mutex); mutex_init(&rpl_recv_mutex); if(rpl_address == 0){