diff --git a/.gitignore b/.gitignore index 88efbfdea..4fbc088a5 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/.travis.yml b/.travis.yml index 8e80e7bd4..f24c9a1e9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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" diff --git a/cpu/cc2430/dev/bus.c b/cpu/cc2430/dev/bus.c index 4d8584466..0108cde58 100644 --- a/cpu/cc2430/dev/bus.c +++ b/cpu/cc2430/dev/bus.c @@ -44,7 +44,7 @@ /*---------------------------------------------------------------------------*/ void -bus_init (void) +bus_init(void) { CLKCON = (0x00 | OSC32K); /* 32k internal */ while(CLKCON != (0x00 | OSC32K)); diff --git a/cpu/cc2430/dev/cc2430_rf.c b/cpu/cc2430/dev/cc2430_rf.c index 7d6d5ecbd..ac897c28c 100644 --- a/cpu/cc2430/dev/cc2430_rf.c +++ b/cpu/cc2430/dev/cc2430_rf.c @@ -263,7 +263,7 @@ cc2430_rf_set_addr(unsigned pan, unsigned addr, const uint8_t *ieee_addr) if(ieee_addr != NULL) { ptr = &IEEE_ADDR7; /* LSB first, MSB last for 802.15.4 addresses in CC2420 */ - for (f = 0; f < 8; f++) { + for(f = 0; f < 8; f++) { *ptr-- = ieee_addr[f]; } } @@ -396,10 +396,10 @@ prepare(const void *payload, unsigned short payload_len) PRINTF("cc2430_rf: data = "); /* Send the phy length byte first */ RFD = payload_len + CHECKSUM_LEN; /* Payload plus FCS */ - PRINTF("(%d)", payload_len+CHECKSUM_LEN); + PRINTF("(%d)", payload_len + CHECKSUM_LEN); for(i = 0; i < payload_len; i++) { - RFD = ((unsigned char*) (payload))[i]; - PRINTF("%02X", ((unsigned char*)(payload))[i]); + RFD = ((unsigned char *)(payload))[i]; + PRINTF("%02X", ((unsigned char *)(payload))[i]); } PRINTF("\n"); @@ -460,7 +460,7 @@ transmit(unsigned short transmit_len) ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT); ENERGEST_ON(ENERGEST_TYPE_LISTEN); - if(rf_flags & WAS_OFF){ + if(rf_flags & WAS_OFF) { off(); } @@ -510,7 +510,7 @@ read(void *buf, unsigned short bufsize) } if(len <= CC2430_MIN_PACKET_LEN) { - PRINTF("error: too short\n"); + PRINTF("error: too short\n"); RIMESTATS_ADD(tooshort); flush_rx(); @@ -518,7 +518,7 @@ read(void *buf, unsigned short bufsize) } if(len - CHECKSUM_LEN > bufsize) { - PRINTF("error: too long\n"); + PRINTF("error: too long\n"); RIMESTATS_ADD(toolong); flush_rx(); @@ -538,11 +538,11 @@ read(void *buf, unsigned short bufsize) PRINTF("(%d)", len); len -= CHECKSUM_LEN; for(i = 0; i < len; ++i) { - ((unsigned char*)(buf))[i] = RFD; + ((unsigned char *)(buf))[i] = RFD; #if CC2430_RF_CONF_HEXDUMP - uart1_writeb(((unsigned char*)(buf))[i]); + uart1_writeb(((unsigned char *)(buf))[i]); #endif - PRINTF("%02X", ((unsigned char*)(buf))[i]); + PRINTF("%02X", ((unsigned char *)(buf))[i]); } PRINTF("\n"); @@ -570,17 +570,17 @@ read(void *buf, unsigned short bufsize) RIMESTATS_ADD(badcrc); flush_rx(); return 0; -} + } /* If FIFOP==1 and FIFO==0 then we had a FIFO overflow at some point. */ if((RFSTATUS & (FIFO | FIFOP)) == FIFOP) { /* * If we reach here means that there might be more intact packets in the * FIFO despite the overflow. This can happen with bursts of small packets. - * + * * Only flush if the FIFO is actually empty. If not, then next pass we will * pick up one more packet or flush due to an error. - */ + */ if(!RXFIFOCNT) { flush_rx(); } @@ -646,14 +646,14 @@ on(void) RSSIH = 0xd2; /* -84dbm = 0xd2 default, 0xe0 -70 dbm */ RFPWR &= ~RREG_RADIO_PD; /* make sure it's powered */ - while ((RFIF & IRQ_RREG_ON) == 0); /* wait for power up */ + while((RFIF & IRQ_RREG_ON) == 0); /* wait for power up */ /* Make sure the RREG On Interrupt Flag is 0 next time we get called */ RFIF &= ~IRQ_RREG_ON; cc2430_rf_command(ISRXON); cc2430_rf_command(ISFLUSHRX); - while (RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + ONOFF_TIME)); + while(RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + ONOFF_TIME)); } PRINTF("cc2430_rf_rx_enable done\n"); @@ -686,18 +686,17 @@ off(void) return 1; } /*---------------------------------------------------------------------------*/ -const struct radio_driver cc2430_rf_driver = -{ - init, - prepare, - transmit, - send, - read, - channel_clear, - receiving_packet, - pending_packet, - on, - off, +const struct radio_driver cc2430_rf_driver = { + init, + prepare, + transmit, + send, + read, + channel_clear, + receiving_packet, + pending_packet, + on, + off, }; /*---------------------------------------------------------------------------*/ #if !NETSTACK_CONF_SHORTCUTS diff --git a/cpu/cc2430/dev/cc2430_rf.h b/cpu/cc2430/dev/cc2430_rf.h index 9ef949726..f9ec32566 100644 --- a/cpu/cc2430/dev/cc2430_rf.h +++ b/cpu/cc2430/dev/cc2430_rf.h @@ -16,15 +16,14 @@ #endif /* Constants */ -typedef enum rf_address_mode_t -{ - RF_DECODER_NONE = 0, - RF_DECODER_COORDINATOR, - RF_SOFTACK_MONITOR, - RF_MONITOR, - RF_SOFTACK_CLIENT, - RF_DECODER_ON -}rf_address_mode_t; +typedef enum rf_address_mode_t { + RF_DECODER_NONE = 0, + RF_DECODER_COORDINATOR, + RF_SOFTACK_MONITOR, + RF_MONITOR, + RF_SOFTACK_CLIENT, + RF_DECODER_ON +} rf_address_mode_t; /*CSP command set*/ #define SSTOP 0xDF @@ -79,10 +78,10 @@ uint8_t cc2430_rf_power_set(uint8_t new_power); void cc2430_rf_set_addr(unsigned pan, unsigned addr, const uint8_t *ieee_addr); #if !NETSTACK_CONF_SHORTCUTS -extern void cc2430_rf_ISR( void ) __interrupt (RF_VECTOR); +extern void cc2430_rf_ISR(void) __interrupt(RF_VECTOR); #endif #if CC2430_RFERR_INTERRUPT -extern void cc2430_rf_error_ISR( void ) __interrupt (RFERR_VECTOR); +extern void cc2430_rf_error_ISR(void) __interrupt(RFERR_VECTOR); #endif #ifdef HAVE_RF_DMA diff --git a/cpu/cc2430/dev/cc2430_rf_intr.c b/cpu/cc2430/dev/cc2430_rf_intr.c index b19a1156b..85b9879c9 100644 --- a/cpu/cc2430/dev/cc2430_rf_intr.c +++ b/cpu/cc2430/dev/cc2430_rf_intr.c @@ -61,7 +61,7 @@ PROCESS_NAME(cc2430_rf_process); #pragma exclude bits #endif void -cc2430_rf_ISR( void ) __interrupt (RF_VECTOR) +cc2430_rf_ISR(void) __interrupt(RF_VECTOR) { EA = 0; ENERGEST_ON(ENERGEST_TYPE_IRQ); @@ -70,9 +70,9 @@ cc2430_rf_ISR( void ) __interrupt (RF_VECTOR) * Just double check the flag. */ if(RFIF & IRQ_FIFOP) { - RF_RX_LED_ON(); - /* Poll the RF process which calls cc2430_rf_read() */ - process_poll(&cc2430_rf_process); + RF_RX_LED_ON(); + /* Poll the RF process which calls cc2430_rf_read() */ + process_poll(&cc2430_rf_process); } S1CON &= ~(RFIF_0 | RFIF_1); @@ -92,7 +92,7 @@ cc2430_rf_ISR( void ) __interrupt (RF_VECTOR) #pragma exclude bits #endif void -cc2430_rf_error_ISR( void ) __interrupt (RFERR_VECTOR) +cc2430_rf_error_ISR(void) __interrupt(RFERR_VECTOR) { EA = 0; TCON_RFERRIF = 0; diff --git a/cpu/cc2430/dev/clock.c b/cpu/cc2430/dev/clock.c index e36a11297..c0b8f2c9d 100644 --- a/cpu/cc2430/dev/clock.c +++ b/cpu/cc2430/dev/clock.c @@ -98,14 +98,14 @@ clock_init(void) CLKCON = OSC32K | TICKSPD2 | TICKSPD1; /* tickspeed 500 kHz for timers[1-4] */ /* Initialize tick value */ - timer_value = ST0; /* ST low bits [7:0] */ - timer_value += ((unsigned long int) ST1) << 8; /* middle bits [15:8] */ - timer_value += ((unsigned long int) ST2) << 16; /* high bits [23:16] */ - timer_value += TICK_VAL; /* Init value 256 */ - ST2 = (unsigned char) (timer_value >> 16); - ST1 = (unsigned char) (timer_value >> 8); - ST0 = (unsigned char) timer_value; - + timer_value = ST0; /* ST low bits [7:0] */ + timer_value += ((unsigned long int)ST1) << 8; /* middle bits [15:8] */ + timer_value += ((unsigned long int)ST2) << 16; /* high bits [23:16] */ + timer_value += TICK_VAL; /* Init value 256 */ + ST2 = (unsigned char)(timer_value >> 16); + ST1 = (unsigned char)(timer_value >> 8); + ST0 = (unsigned char)timer_value; + IEN0_STIE = 1; /* IEN0.STIE acknowledge Sleep Timer Interrupt */ } /*---------------------------------------------------------------------------*/ @@ -131,15 +131,15 @@ clock_ISR(void) __interrupt(ST_VECTOR) * Next interrupt occurs after the current time + TICK_VAL */ timer_value = ST0; - timer_value += ((unsigned long int) ST1) << 8; - timer_value += ((unsigned long int) ST2) << 16; + timer_value += ((unsigned long int)ST1) << 8; + timer_value += ((unsigned long int)ST2) << 16; timer_value += TICK_VAL; - ST2 = (unsigned char) (timer_value >> 16); - ST1 = (unsigned char) (timer_value >> 8); - ST0 = (unsigned char) timer_value; - + ST2 = (unsigned char)(timer_value >> 16); + ST1 = (unsigned char)(timer_value >> 8); + ST0 = (unsigned char)timer_value; + ++count; - + /* Make sure the CLOCK_CONF_SECOND is a power of two, to ensure that the modulo operation below becomes a logical and and not an expensive divide. Algorithm from Wikipedia: @@ -160,7 +160,7 @@ clock_ISR(void) __interrupt(ST_VECTOR) etimer_request_poll(); } #endif - + IRCON_STIF = 0; ENERGEST_OFF(ENERGEST_TYPE_IRQ); ENABLE_INTERRUPTS(); diff --git a/cpu/cc2430/dev/dma.c b/cpu/cc2430/dev/dma.c index d549850c5..2c198acc3 100644 --- a/cpu/cc2430/dev/dma.c +++ b/cpu/cc2430/dev/dma.c @@ -16,7 +16,7 @@ #if DMA_ON struct dma_config dma_conf[DMA_CHANNEL_COUNT]; /* DMA Descriptors */ -struct process * dma_callback[DMA_CHANNEL_COUNT]; +struct process *dma_callback[DMA_CHANNEL_COUNT]; /*---------------------------------------------------------------------------*/ void dma_init(void) @@ -30,7 +30,7 @@ dma_init(void) } /* The address of the descriptor for Channel 0 is configured separately */ - tmp_ptr = (uint16_t) &(dma_conf[0]); + tmp_ptr = (uint16_t)&(dma_conf[0]); DMA0CFGH = tmp_ptr >> 8; DMA0CFGL = tmp_ptr; @@ -40,7 +40,7 @@ dma_init(void) * derived by the SoC */ #if (DMA_CHANNEL_COUNT > 1) - tmp_ptr = (uint16_t) &(dma_conf[1]); + tmp_ptr = (uint16_t)&(dma_conf[1]); DMA1CFGH = tmp_ptr >> 8; DMA1CFGL = tmp_ptr; #endif @@ -53,7 +53,7 @@ dma_init(void) * completes, the ISR will poll this process. */ void -dma_associate_process(struct process * p, uint8_t c) +dma_associate_process(struct process *p, uint8_t c) { if((!c) || (c >= DMA_CHANNEL_COUNT)) { return; diff --git a/cpu/cc2430/dev/dma.h b/cpu/cc2430/dev/dma.h index d88167734..30060b40f 100644 --- a/cpu/cc2430/dev/dma.h +++ b/cpu/cc2430/dev/dma.h @@ -138,11 +138,11 @@ extern dma_config_t dma_conf[DMA_CHANNEL_COUNT]; /* Functions Declarations */ void dma_init(void); -void dma_associate_process (struct process * p, uint8_t c); +void dma_associate_process(struct process *p, uint8_t c); /* Only link the ISR when DMA_ON is .... on */ #if DMA_ON -void dma_ISR( void ) __interrupt (DMA_VECTOR); +void dma_ISR(void) __interrupt(DMA_VECTOR); #endif #endif /*__DMA_H*/ diff --git a/cpu/cc2430/dev/dma_intr.c b/cpu/cc2430/dev/dma_intr.c index 1e8dbe2aa..01e96c8ac 100644 --- a/cpu/cc2430/dev/dma_intr.c +++ b/cpu/cc2430/dev/dma_intr.c @@ -16,7 +16,7 @@ #include "cc2430_sfr.h" #if DMA_ON -extern struct process * dma_callback[DMA_CHANNEL_COUNT]; +extern struct process *dma_callback[DMA_CHANNEL_COUNT]; #endif /*---------------------------------------------------------------------------*/ @@ -37,17 +37,17 @@ extern void spi_rx_dma_callback(void); #pragma exclude bits #endif void -dma_ISR(void) __interrupt (DMA_VECTOR) +dma_ISR(void) __interrupt(DMA_VECTOR) { #if DMA_ON uint8_t i; #endif - EA=0; + EA = 0; IRCON_DMAIF = 0; #ifdef HAVE_RF_DMA if((DMAIRQ & 1) != 0) { DMAIRQ &= ~1; - DMAARM=0x81; + DMAARM = 0x81; rf_dma_callback_isr(); } #endif diff --git a/cpu/cc2430/dev/uart0.h b/cpu/cc2430/dev/uart0.h index 7ac56e9f6..8a1357639 100644 --- a/cpu/cc2430/dev/uart0.h +++ b/cpu/cc2430/dev/uart0.h @@ -20,12 +20,12 @@ void uart0_init(); void uart0_writeb(uint8_t byte); -void uart0_set_input(int (*input)(unsigned char c)); +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); +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 */ diff --git a/cpu/cc2430/dev/uart1.h b/cpu/cc2430/dev/uart1.h index 53022a902..1a4b7e9fa 100644 --- a/cpu/cc2430/dev/uart1.h +++ b/cpu/cc2430/dev/uart1.h @@ -22,10 +22,10 @@ void uart1_writeb(uint8_t byte); void uart1_set_input(int (*input)(unsigned char c)); #if UART_ONE_CONF_WITH_INPUT -void uart1_rx_ISR( void ) __interrupt (URX1_VECTOR); -void uart1_tx_ISR( void ) __interrupt (UTX1_VECTOR); +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 */ diff --git a/cpu/cc2430/dev/uart_intr.c b/cpu/cc2430/dev/uart_intr.c index 8e087791f..17a5427aa 100644 --- a/cpu/cc2430/dev/uart_intr.c +++ b/cpu/cc2430/dev/uart_intr.c @@ -21,16 +21,16 @@ #include "sys/energest.h" #if UART_ZERO_ENABLE -static int (*uart0_input_handler)(unsigned char c); +static int (* uart0_input_handler)(unsigned char c); #endif #if UART_ONE_ENABLE -static int (*uart1_input_handler)(unsigned char c); +static int (* uart1_input_handler)(unsigned char c); #endif #if UART_ZERO_ENABLE /*---------------------------------------------------------------------------*/ void -uart0_set_input(int (*input)(unsigned char c)) +uart0_set_input(int (* input)(unsigned char c)) { uart0_input_handler = input; } @@ -41,7 +41,7 @@ uart0_set_input(int (*input)(unsigned char c)) #pragma exclude bits #endif void -uart0_rx_ISR(void) __interrupt (URX0_VECTOR) +uart0_rx_ISR(void) __interrupt(URX0_VECTOR) { ENERGEST_ON(ENERGEST_TYPE_IRQ); TCON_URX0IF = 0; @@ -52,7 +52,7 @@ uart0_rx_ISR(void) __interrupt (URX0_VECTOR) } /*---------------------------------------------------------------------------*/ void -uart0_tx_ISR( void ) __interrupt (UTX0_VECTOR) +uart0_tx_ISR(void) __interrupt(UTX0_VECTOR) { } #pragma restore @@ -60,7 +60,7 @@ uart0_tx_ISR( void ) __interrupt (UTX0_VECTOR) #if UART_ONE_ENABLE /*---------------------------------------------------------------------------*/ void -uart1_set_input(int (*input)(unsigned char c)) +uart1_set_input(int (* input)(unsigned char c)) { uart1_input_handler = input; } @@ -71,7 +71,7 @@ uart1_set_input(int (*input)(unsigned char c)) #pragma exclude bits #endif void -uart1_rx_ISR(void) __interrupt (URX1_VECTOR) +uart1_rx_ISR(void) __interrupt(URX1_VECTOR) { ENERGEST_ON(ENERGEST_TYPE_IRQ); TCON_URX1IF = 0; @@ -82,7 +82,7 @@ uart1_rx_ISR(void) __interrupt (URX1_VECTOR) } /*---------------------------------------------------------------------------*/ void -uart1_tx_ISR( void ) __interrupt (UTX1_VECTOR) +uart1_tx_ISR(void) __interrupt(UTX1_VECTOR) { } #pragma restore diff --git a/cpu/cc2430/dev/watchdog-cc2430.c b/cpu/cc2430/dev/watchdog-cc2430.c index 47df7a1c8..f8c4646a5 100644 --- a/cpu/cc2430/dev/watchdog-cc2430.c +++ b/cpu/cc2430/dev/watchdog-cc2430.c @@ -52,7 +52,7 @@ #pragma exclude bits #endif void -cc4230_watchdog_ISR(void) __interrupt (WDT_VECTOR) +cc4230_watchdog_ISR(void) __interrupt(WDT_VECTOR) { EA = 0; ENERGEST_ON(ENERGEST_TYPE_IRQ); diff --git a/cpu/cc2430/mtarch.h b/cpu/cc2430/mtarch.h index b228150ab..381737888 100644 --- a/cpu/cc2430/mtarch.h +++ b/cpu/cc2430/mtarch.h @@ -29,16 +29,16 @@ * */ - /* - * \file - * Stub header file for cc2430 multi-threading. It doesn't do anything, it - * just exists so that mt.c can compile cleanly. - * - * This is based on the original mtarch.h for z80 by Takahide Matsutsuka - * - * \author - * George Oikonomou - - */ +/* + * \file + * Stub header file for cc2430 multi-threading. It doesn't do anything, it + * just exists so that mt.c can compile cleanly. + * + * This is based on the original mtarch.h for z80 by Takahide Matsutsuka + * + * \author + * George Oikonomou - + */ #ifndef __MTARCH_H__ #define __MTARCH_H__ @@ -47,4 +47,3 @@ struct mtarch_thread { }; #endif /* __MTARCH_H__ */ - diff --git a/cpu/cc2430/rtimer-arch.c b/cpu/cc2430/rtimer-arch.c index d2ec784c9..1abff5c08 100644 --- a/cpu/cc2430/rtimer-arch.c +++ b/cpu/cc2430/rtimer-arch.c @@ -95,8 +95,8 @@ rtimer_arch_schedule(rtimer_clock_t t) PRINTF("rtimer_arch_schedule(%u)\n", t); /* set the compare mode values so we can get an interrupt after t */ - T1CC1L = (unsigned char) t; - T1CC1H = (unsigned char) (t >> 8); + T1CC1L = (unsigned char)t; + T1CC1H = (unsigned char)(t >> 8); PRINTF("T1CC1=%u, t=%u\n", (T1CC1L + (T1CC1H << 8)), t); /* Turn on compare mode interrupt */ @@ -109,7 +109,7 @@ rtimer_arch_schedule(rtimer_clock_t t) #pragma exclude bits #endif void -cc2430_timer_1_ISR(void) __interrupt (T1_VECTOR) +cc2430_timer_1_ISR(void) __interrupt(T1_VECTOR) { IEN1_T1IE = 0; /* Ignore Timer 1 Interrupts */ ENERGEST_ON(ENERGEST_TYPE_IRQ); diff --git a/cpu/cc2430/rtimer-arch.h b/cpu/cc2430/rtimer-arch.h index c44046c62..a29f1bae5 100644 --- a/cpu/cc2430/rtimer-arch.h +++ b/cpu/cc2430/rtimer-arch.h @@ -57,6 +57,6 @@ #define rtimer_arch_now() ((rtimer_clock_t)(T1CNTL + (T1CNTH << 8))) -void cc2430_timer_1_ISR(void) __interrupt (T1_VECTOR); +void cc2430_timer_1_ISR(void) __interrupt(T1_VECTOR); #endif /* __RTIMER_ARCH_H__ */ diff --git a/cpu/cc2430/stack.c b/cpu/cc2430/stack.c index 0a26330fa..7043b2edf 100644 --- a/cpu/cc2430/stack.c +++ b/cpu/cc2430/stack.c @@ -60,7 +60,7 @@ poison_loop: uint8_t stack_get_max(void) { - __data uint8_t * sp = (__data uint8_t *) 0xff; + __data uint8_t *sp = (__data uint8_t *)0xff; uint8_t free = 0; while(*sp-- == STACK_POISON) { diff --git a/cpu/cc253x/dev/cc2530-rf.c b/cpu/cc253x/dev/cc2530-rf.c index a07125f0b..25b16ea84 100644 --- a/cpu/cc253x/dev/cc2530-rf.c +++ b/cpu/cc253x/dev/cc2530-rf.c @@ -67,9 +67,9 @@ #define RF_TX_LED_OFF() leds_off(LEDS_GREEN); #else #define RF_RX_LED_ON() -#define RF_RX_LED_OFF() +#define RF_RX_LED_OFF() #define RF_TX_LED_ON() -#define RF_TX_LED_OFF() +#define RF_TX_LED_OFF() #endif /*---------------------------------------------------------------------------*/ #define DEBUG 0 @@ -240,8 +240,8 @@ prepare(const void *payload, unsigned short payload_len) /* Send the phy length byte first */ RFD = payload_len + CHECKSUM_LEN; /* Payload plus FCS */ for(i = 0; i < payload_len; i++) { - RFD = ((unsigned char*) (payload))[i]; - PUTHEX(((unsigned char*)(payload))[i]); + RFD = ((unsigned char *)(payload))[i]; + PUTHEX(((unsigned char *)(payload))[i]); } PUTSTRING("\n"); @@ -264,7 +264,7 @@ transmit(unsigned short transmit_len) t0 = RTIMER_NOW(); on(); rf_flags |= WAS_OFF; - while (RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + ONOFF_TIME)); + while(RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + ONOFF_TIME)); } if(channel_clear() == CC2530_RF_CCA_BUSY) { @@ -305,7 +305,7 @@ transmit(unsigned short transmit_len) ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT); ENERGEST_ON(ENERGEST_TYPE_LISTEN); - if(rf_flags & WAS_OFF){ + if(rf_flags & WAS_OFF) { off(); } @@ -379,11 +379,11 @@ read(void *buf, unsigned short bufsize) PUTSTRING(" bytes) = "); len -= CHECKSUM_LEN; for(i = 0; i < len; ++i) { - ((unsigned char*)(buf))[i] = RFD; + ((unsigned char *)(buf))[i] = RFD; #if CC2530_RF_CONF_HEXDUMP - io_arch_writeb(((unsigned char*)(buf))[i]); + io_arch_writeb(((unsigned char *)(buf))[i]); #endif - PUTHEX(((unsigned char*)(buf))[i]); + PUTHEX(((unsigned char *)(buf))[i]); } PUTSTRING("\n"); @@ -483,17 +483,16 @@ off(void) return 1; } /*---------------------------------------------------------------------------*/ -const struct radio_driver cc2530_rf_driver = -{ - init, - prepare, - transmit, - send, - read, - channel_clear, - receiving_packet, - pending_packet, - on, - off, +const struct radio_driver cc2530_rf_driver = { + init, + prepare, + transmit, + send, + read, + channel_clear, + receiving_packet, + pending_packet, + on, + off, }; /*---------------------------------------------------------------------------*/ diff --git a/cpu/cc253x/dev/clock.c b/cpu/cc253x/dev/clock.c index e82def45c..ff1c4cf4a 100644 --- a/cpu/cc253x/dev/clock.c +++ b/cpu/cc253x/dev/clock.c @@ -121,13 +121,13 @@ clock_init(void) /* Initialize tick value */ timer_value = ST0; - timer_value += ((unsigned long int) ST1) << 8; - timer_value += ((unsigned long int) ST2) << 16; + timer_value += ((unsigned long int)ST1) << 8; + timer_value += ((unsigned long int)ST2) << 16; timer_value += TICK_VAL; - ST2 = (unsigned char) (timer_value >> 16); - ST1 = (unsigned char) (timer_value >> 8); - ST0 = (unsigned char) timer_value; - + ST2 = (unsigned char)(timer_value >> 16); + ST1 = (unsigned char)(timer_value >> 8); + ST0 = (unsigned char)timer_value; + STIE = 1; /* IEN0.STIE interrupt enable */ } /*---------------------------------------------------------------------------*/ @@ -147,15 +147,15 @@ clock_isr(void) __interrupt(ST_VECTOR) * Next interrupt occurs after the current time + TICK_VAL */ timer_value = ST0; - timer_value += ((unsigned long int) ST1) << 8; - timer_value += ((unsigned long int) ST2) << 16; + timer_value += ((unsigned long int)ST1) << 8; + timer_value += ((unsigned long int)ST2) << 16; timer_value += TICK_VAL; - ST2 = (unsigned char) (timer_value >> 16); - ST1 = (unsigned char) (timer_value >> 8); - ST0 = (unsigned char) timer_value; - + ST2 = (unsigned char)(timer_value >> 16); + ST1 = (unsigned char)(timer_value >> 8); + ST0 = (unsigned char)timer_value; + ++count; - + /* Make sure the CLOCK_CONF_SECOND is a power of two, to ensure that the modulo operation below becomes a logical and and not an expensive divide. Algorithm from Wikipedia: @@ -167,7 +167,7 @@ clock_isr(void) __interrupt(ST_VECTOR) if(count % CLOCK_CONF_SECOND == 0) { ++seconds; } - + #if CLOCK_CONF_STACK_FRIENDLY sleep_flag = 1; #else @@ -176,7 +176,7 @@ clock_isr(void) __interrupt(ST_VECTOR) etimer_request_poll(); } #endif - + STIF = 0; /* IRCON.STIF */ ENERGEST_OFF(ENERGEST_TYPE_IRQ); ENABLE_INTERRUPTS(); diff --git a/cpu/cc253x/dev/dma.c b/cpu/cc253x/dev/dma.c index 9a4c5db01..93e01cf1d 100644 --- a/cpu/cc253x/dev/dma.c +++ b/cpu/cc253x/dev/dma.c @@ -17,7 +17,7 @@ #if DMA_ON struct dma_config dma_conf[DMA_CHANNEL_COUNT]; /* DMA Descriptors */ -struct process * dma_callback[DMA_CHANNEL_COUNT]; +struct process *dma_callback[DMA_CHANNEL_COUNT]; /*---------------------------------------------------------------------------*/ void dma_init(void) @@ -31,7 +31,7 @@ dma_init(void) } /* The address of the descriptor for Channel 0 is configured separately */ - tmp_ptr = (uint16_t) &(dma_conf[0]); + tmp_ptr = (uint16_t)&(dma_conf[0]); DMA0CFGH = tmp_ptr >> 8; DMA0CFGL = tmp_ptr; @@ -41,7 +41,7 @@ dma_init(void) * derived by the SoC */ #if (DMA_CHANNEL_COUNT > 1) - tmp_ptr = (uint16_t) &(dma_conf[1]); + tmp_ptr = (uint16_t)&(dma_conf[1]); DMA1CFGH = tmp_ptr >> 8; DMA1CFGL = tmp_ptr; #endif @@ -54,7 +54,7 @@ dma_init(void) * completes, the ISR will poll this process. */ void -dma_associate_process(struct process * p, uint8_t c) +dma_associate_process(struct process *p, uint8_t c) { if((!c) || (c >= DMA_CHANNEL_COUNT)) { return; @@ -80,15 +80,15 @@ dma_reset(uint8_t c) return; } DMA_ABORT(c); - dma_conf[c].src_h = (uint16_t) &dummy >> 8; - dma_conf[c].src_l = (uint16_t) &dummy; - dma_conf[c].dst_h = (uint16_t) &dummy >> 8; - dma_conf[c].dst_l = (uint16_t) &dummy; + dma_conf[c].src_h = (uint16_t)&dummy >> 8; + dma_conf[c].src_l = (uint16_t)&dummy; + dma_conf[c].dst_h = (uint16_t)&dummy >> 8; + dma_conf[c].dst_l = (uint16_t)&dummy; dma_conf[c].len_h = 0; 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)); } diff --git a/cpu/cc253x/dev/dma.h b/cpu/cc253x/dev/dma.h index 7f767bc68..606be2ae6 100644 --- a/cpu/cc253x/dev/dma.h +++ b/cpu/cc253x/dev/dma.h @@ -139,12 +139,12 @@ extern dma_config_t dma_conf[DMA_CHANNEL_COUNT]; /* Functions Declarations */ void dma_init(void); -void dma_associate_process (struct process * p, uint8_t c); +void dma_associate_process(struct process *p, uint8_t c); void dma_reset(uint8_t c); /* Only link the ISR when DMA_ON is .... on */ #if DMA_ON -void dma_isr( void ) __interrupt (DMA_VECTOR); +void dma_isr(void) __interrupt(DMA_VECTOR); #endif #endif /*__DMA_H*/ diff --git a/cpu/cc253x/dev/dma_intr.c b/cpu/cc253x/dev/dma_intr.c index 633fb3cda..863691e9e 100644 --- a/cpu/cc253x/dev/dma_intr.c +++ b/cpu/cc253x/dev/dma_intr.c @@ -16,7 +16,7 @@ #include "cc253x.h" #if DMA_ON -extern struct process * dma_callback[DMA_CHANNEL_COUNT]; +extern struct process *dma_callback[DMA_CHANNEL_COUNT]; #endif /*---------------------------------------------------------------------------*/ @@ -38,17 +38,17 @@ extern void spi_rx_dma_callback(void); #pragma exclude bits #endif void -dma_isr(void) __interrupt (DMA_VECTOR) +dma_isr(void) __interrupt(DMA_VECTOR) { #if DMA_ON uint8_t i; #endif - EA=0; + EA = 0; DMAIF = 0; #ifdef HAVE_RF_DMA if((DMAIRQ & 1) != 0) { DMAIRQ = ~1; - DMAARM=0x81; + DMAARM = 0x81; rf_dma_callback_isr(); } #endif diff --git a/cpu/cc253x/dev/port2.h b/cpu/cc253x/dev/port2.h index f70d5d036..10f9774ec 100644 --- a/cpu/cc253x/dev/port2.h +++ b/cpu/cc253x/dev/port2.h @@ -38,7 +38,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. struct cc253x_p2_handler { struct cc253x_p2_handler *next; - uint8_t (*cb) (void); + uint8_t (* cb)(void); }; void cc253x_p2_register_handler(struct cc253x_p2_handler *h); diff --git a/cpu/cc253x/dev/uart-intr.c b/cpu/cc253x/dev/uart-intr.c index ebe1814c1..89b7c8fb1 100644 --- a/cpu/cc253x/dev/uart-intr.c +++ b/cpu/cc253x/dev/uart-intr.c @@ -18,16 +18,16 @@ #include "dev/leds.h" #if UART0_ENABLE -static int (*uart0_input_handler)(unsigned char c); +static int (* uart0_input_handler)(unsigned char c); #endif #if UART1_ENABLE -static int (*uart1_input_handler)(unsigned char c); +static int (* uart1_input_handler)(unsigned char c); #endif #if UART0_ENABLE /*---------------------------------------------------------------------------*/ void -uart0_set_input(int (*input)(unsigned char c)) +uart0_set_input(int (* input)(unsigned char c)) { uart0_input_handler = input; } @@ -39,7 +39,7 @@ uart0_set_input(int (*input)(unsigned char c)) #pragma exclude bits #endif void -uart0_rx_isr(void) __interrupt (URX0_VECTOR) +uart0_rx_isr(void) __interrupt(URX0_VECTOR) { ENERGEST_ON(ENERGEST_TYPE_IRQ); leds_toggle(LEDS_YELLOW); @@ -55,7 +55,7 @@ uart0_rx_isr(void) __interrupt (URX0_VECTOR) #if UART1_ENABLE /*---------------------------------------------------------------------------*/ void -uart1_set_input(int (*input)(unsigned char c)) +uart1_set_input(int (* input)(unsigned char c)) { uart1_input_handler = input; } @@ -67,7 +67,7 @@ uart1_set_input(int (*input)(unsigned char c)) #pragma exclude bits #endif void -uart1_rx_isr(void) __interrupt (URX1_VECTOR) +uart1_rx_isr(void) __interrupt(URX1_VECTOR) { ENERGEST_ON(ENERGEST_TYPE_IRQ); URX1IF = 0; diff --git a/cpu/cc253x/dev/uart0.h b/cpu/cc253x/dev/uart0.h index 45839e120..3245964bf 100644 --- a/cpu/cc253x/dev/uart0.h +++ b/cpu/cc253x/dev/uart0.h @@ -20,10 +20,10 @@ void uart0_init(); void uart0_writeb(uint8_t byte); -void uart0_set_input(int (*input)(unsigned char c)); +void uart0_set_input(int (* input)(unsigned char c)); #if UART0_CONF_WITH_INPUT -void uart0_rx_isr( void ) __interrupt (URX0_VECTOR); +void uart0_rx_isr(void) __interrupt(URX0_VECTOR); /* Macro to turn on / off UART RX Interrupt */ #define UART0_RX_INT(v) do { URX0IE = v; } while(0) #define UART0_RX_EN() do { U0CSR |= UCSR_RE; } while(0) diff --git a/cpu/cc253x/dev/uart1.h b/cpu/cc253x/dev/uart1.h index aea8bec48..203cfaa02 100644 --- a/cpu/cc253x/dev/uart1.h +++ b/cpu/cc253x/dev/uart1.h @@ -20,9 +20,9 @@ void uart1_init(); void uart1_writeb(uint8_t byte); -void uart1_set_input(int (*input)(unsigned char c)); +void uart1_set_input(int (* input)(unsigned char c)); #if UART1_CONF_WITH_INPUT -void uart1_rx_isr( void ) __interrupt (URX1_VECTOR); +void uart1_rx_isr(void) __interrupt(URX1_VECTOR); /* Macro to turn on / off UART RX Interrupt */ #define UART1_RX_INT(v) do { URX1IE = v; } while(0) #else diff --git a/cpu/cc253x/mtarch.h b/cpu/cc253x/mtarch.h index 89d7766e2..2272d7a5b 100644 --- a/cpu/cc253x/mtarch.h +++ b/cpu/cc253x/mtarch.h @@ -29,16 +29,16 @@ * */ - /* - * \file - * Stub header file for multi-threading. It doesn't do anything, it - * just exists so that mt.c can compile cleanly. - * - * This is based on the original mtarch.h for z80 by Takahide Matsutsuka - * - * \author - * George Oikonomou - - */ +/* + * \file + * Stub header file for multi-threading. It doesn't do anything, it + * just exists so that mt.c can compile cleanly. + * + * This is based on the original mtarch.h for z80 by Takahide Matsutsuka + * + * \author + * George Oikonomou - + */ #ifndef __MTARCH_H__ #define __MTARCH_H__ @@ -47,4 +47,3 @@ struct mtarch_thread { }; #endif /* __MTARCH_H__ */ - diff --git a/cpu/cc253x/rtimer-arch.c b/cpu/cc253x/rtimer-arch.c index 6bf4405ca..71262910c 100644 --- a/cpu/cc253x/rtimer-arch.c +++ b/cpu/cc253x/rtimer-arch.c @@ -87,8 +87,8 @@ rtimer_arch_schedule(rtimer_clock_t t) /* Switch to capture mode before writing T1CC1x and * set the compare mode values so we can get an interrupt after t */ RT_MODE_CAPTURE(); - T1CC1L = (unsigned char) t; - T1CC1H = (unsigned char) (t >> 8); + T1CC1L = (unsigned char)t; + T1CC1H = (unsigned char)(t >> 8); RT_MODE_COMPARE(); /* Turn on compare mode interrupt */ diff --git a/cpu/cc253x/stack.c b/cpu/cc253x/stack.c index d6daf25a6..d116b02f2 100644 --- a/cpu/cc253x/stack.c +++ b/cpu/cc253x/stack.c @@ -60,7 +60,7 @@ poison_loop: uint8_t stack_get_max(void) { - __data uint8_t * sp = (__data uint8_t *) 0xff; + __data uint8_t *sp = (__data uint8_t *)0xff; uint8_t free = 0; while(*sp-- == STACK_POISON) { diff --git a/examples/cc2530dk/blink-hello.c b/examples/cc2530dk/blink-hello.c index 478f9a42d..14bc73151 100644 --- a/examples/cc2530dk/blink-hello.c +++ b/examples/cc2530dk/blink-hello.c @@ -33,7 +33,7 @@ PROCESS_THREAD(hello_world_process, ev, data) if(ev == PROCESS_EVENT_TIMER) { printf("Sensor says #%u\n", count); - count ++; + count++; etimer_reset(&et_hello); } diff --git a/examples/cc2530dk/border-router/border-router.c b/examples/cc2530dk/border-router/border-router.c index f9bb052de..c524a6f74 100644 --- a/examples/cc2530dk/border-router/border-router.c +++ b/examples/cc2530dk/border-router/border-router.c @@ -75,7 +75,7 @@ print_local_addresses(void) CC_NON_BANKED PUTSTRING(" "); PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr); PUTCHAR('\n'); - if (state == ADDR_TENTATIVE) { + if(state == ADDR_TENTATIVE) { uip_ds6_if.addr_list[i].state = ADDR_PREFERRED; } } diff --git a/examples/cc2530dk/border-router/slip-bridge.c b/examples/cc2530dk/border-router/slip-bridge.c index f4c6dc08c..0a37b85dd 100644 --- a/examples/cc2530dk/border-router/slip-bridge.c +++ b/examples/cc2530dk/border-router/slip-bridge.c @@ -57,7 +57,7 @@ static void slip_input_callback(void) { PRINTF("SIN: %u\n", uip_len); - if((char) uip_buf[0] == '!') { + if((char)uip_buf[0] == '!') { PRINTF("Got configuration message of type %c\n", uip_buf[1]); uip_len = 0; if((char)uip_buf[1] == 'P') { diff --git a/examples/cc2530dk/sensors-demo.c b/examples/cc2530dk/sensors-demo.c index 5707fc96b..8b9b56be6 100644 --- a/examples/cc2530dk/sensors-demo.c +++ b/examples/cc2530dk/sensors-demo.c @@ -91,7 +91,7 @@ PROCESS_THREAD(buttons_test_process, ev, data) PROCESS_BEGIN(); - while (1) { + while(1) { PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event); @@ -113,7 +113,7 @@ PROCESS_THREAD(sensors_test_process, ev, data) /* Sensor Values */ static int rv; - static struct sensors_sensor * sensor; + static struct sensors_sensor *sensor; static float sane = 0; static int dec; static float frac; @@ -127,7 +127,7 @@ PROCESS_THREAD(sensors_test_process, ev, data) /* Set an etimer. We take sensor readings when it expires and reset it. */ etimer_set(&et, CLOCK_SECOND * 2); - while (1) { + while(1) { PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); @@ -136,7 +136,7 @@ PROCESS_THREAD(sensors_test_process, ev, data) * Return value -1 means sensor not available or turned off in conf */ sensor = sensors_find(ADC_SENSOR); - if (sensor) { + if(sensor) { PRINTF("------------------\n"); leds_on(LEDS_RED); /* @@ -189,5 +189,5 @@ PROCESS_THREAD(sensors_test_process, ev, data) etimer_reset(&et); } PROCESS_END(); - } +} /*---------------------------------------------------------------------------*/ diff --git a/examples/cc2530dk/sniffer/netstack.c b/examples/cc2530dk/sniffer/netstack.c index 2551f82fe..d59acc3fe 100644 --- a/examples/cc2530dk/sniffer/netstack.c +++ b/examples/cc2530dk/sniffer/netstack.c @@ -47,4 +47,3 @@ netstack_init(void) NETSTACK_RADIO.init(); } /*---------------------------------------------------------------------------*/ - diff --git a/examples/cc2530dk/sniffer/stub-rdc.c b/examples/cc2530dk/sniffer/stub-rdc.c index 063a43659..a4db0710d 100644 --- a/examples/cc2530dk/sniffer/stub-rdc.c +++ b/examples/cc2530dk/sniffer/stub-rdc.c @@ -88,13 +88,13 @@ init(void) } /*---------------------------------------------------------------------------*/ const struct rdc_driver stub_rdc_driver = { - "stub-rdc", - init, - send, - send_list, - input, - on, - off, - cca, + "stub-rdc", + init, + send, + send_list, + input, + on, + off, + cca, }; /*---------------------------------------------------------------------------*/ diff --git a/examples/cc2530dk/timer-test.c b/examples/cc2530dk/timer-test.c index 7d9844676..a56ca4d70 100644 --- a/examples/cc2530dk/timer-test.c +++ b/examples/cc2530dk/timer-test.c @@ -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); @@ -82,13 +83,13 @@ PROCESS_THREAD(clock_test_process, ev, data) printf("Rtimer Test, 1 sec (%u rtimer ticks):\n", RTIMER_SECOND); i = 0; while(i < 5) { - etimer_set(&et, 2*CLOCK_SECOND); + etimer_set(&et, 2 * CLOCK_SECOND); printf("=======================\n"); ct = clock_time(); 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, + if(rtimer_set(&rt, rt_for, 1, (void (*)(struct rtimer *, void *))rt_callback, NULL) != RTIMER_OK) { printf("Error setting\n"); } diff --git a/examples/cc2530dk/udp-ipv6/client.c b/examples/cc2530dk/udp-ipv6/client.c index 224a775af..afbe758ef 100644 --- a/examples/cc2530dk/udp-ipv6/client.c +++ b/examples/cc2530dk/udp-ipv6/client.c @@ -81,7 +81,7 @@ static void timeout_handler(void) { static int seq_id; - struct uip_udp_conn * this_conn; + struct uip_udp_conn *this_conn; leds_on(LEDS_RED); memset(buf, 0, MAX_PAYLOAD_LEN); @@ -117,7 +117,7 @@ PROCESS_THREAD(udp_client_process, ev, data) PROCESS_BEGIN(); PRINTF("UDP client process started\n"); - uip_ip6addr(&ipaddr,0xfe80,0,0,0,0x0215,0x2000,0x0002,0x2145); + uip_ip6addr(&ipaddr, 0xfe80, 0, 0, 0, 0x0215, 0x2000, 0x0002, 0x2145); /* new connection with remote host */ l_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL); if(!l_conn) { @@ -128,9 +128,9 @@ PROCESS_THREAD(udp_client_process, ev, data) PRINTF("Link-Local connection with "); PRINT6ADDR(&l_conn->ripaddr); PRINTF(" local/remote port %u/%u\n", - UIP_HTONS(l_conn->lport), UIP_HTONS(l_conn->rport)); + UIP_HTONS(l_conn->lport), UIP_HTONS(l_conn->rport)); - uip_ip6addr(&ipaddr,0xaaaa,0,0,0,0x0215,0x2000,0x0002,0x2145); + uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0x0215, 0x2000, 0x0002, 0x2145); g_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL); if(!g_conn) { PRINTF("udp_new g_conn error.\n"); @@ -140,7 +140,7 @@ PROCESS_THREAD(udp_client_process, ev, data) PRINTF("Global connection with "); PRINT6ADDR(&g_conn->ripaddr); PRINTF(" local/remote port %u/%u\n", - UIP_HTONS(g_conn->lport), UIP_HTONS(g_conn->rport)); + UIP_HTONS(g_conn->lport), UIP_HTONS(g_conn->rport)); etimer_set(&et, SEND_INTERVAL); diff --git a/examples/cc2530dk/udp-ipv6/ping6.c b/examples/cc2530dk/udp-ipv6/ping6.c index bab5db911..e6b9e6537 100644 --- a/examples/cc2530dk/udp-ipv6/ping6.c +++ b/examples/cc2530dk/udp-ipv6/ping6.c @@ -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); @@ -104,9 +105,9 @@ PROCESS_THREAD(ping6_process, ev, data) PRINTF("ping6 running.\n"); PRINTF("Button 1: 5 pings 16 byte payload.\n"); - uip_ip6addr(&dest_addr,0xaaaa,0,0,0,0x0215,0x2000,0x0002,0x2145); + uip_ip6addr(&dest_addr, 0xaaaa, 0, 0, 0, 0x0215, 0x2000, 0x0002, 0x2145); count = 0; - + icmp6_new(NULL); while(1) { @@ -124,7 +125,7 @@ PROCESS_THREAD(ping6_process, ev, data) PRINTF("Echo Reply\n"); } } - + PROCESS_END(); } /*---------------------------------------------------------------------------*/ diff --git a/examples/cc2530dk/udp-ipv6/server.c b/examples/cc2530dk/udp-ipv6/server.c index 8fc1e0ae0..21cfc62a9 100644 --- a/examples/cc2530dk/udp-ipv6/server.c +++ b/examples/cc2530dk/udp-ipv6/server.c @@ -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 /*---------------------------------------------------------------------------*/ @@ -112,7 +113,7 @@ print_local_addresses(void) PRINTF(" "); PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr); PRINTF("\n"); - if (state == ADDR_TENTATIVE) { + if(state == ADDR_TENTATIVE) { uip_ds6_if.addr_list[i].state = ADDR_PREFERRED; } } @@ -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); @@ -167,7 +169,7 @@ PROCESS_THREAD(udp_server_process, ev, data) tcpip_handler(); #if (BUTTON_SENSOR_ON && (DEBUG==DEBUG_PRINT)) } else if(ev == sensors_event && data == &button_sensor) { - print_stats(); + print_stats(); #endif /* BUTTON_SENSOR_ON */ } } diff --git a/examples/sensinode/Makefile b/examples/sensinode/Makefile index c3b33f6e4..773998539 100644 --- a/examples/sensinode/Makefile +++ b/examples/sensinode/Makefile @@ -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) diff --git a/examples/sensinode/README b/examples/sensinode/README index 04901ca45..e5afab2bb 100644 --- a/examples/sensinode/README +++ b/examples/sensinode/README @@ -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 @@ -54,4 +47,4 @@ event-post Demonstrating the interaction between two processes with custom blink-hello Hello World with LED blinking. timer-test Same as clock_test above + testing the rtimer-arch code border-router 802.15.4 to SLIP bridge example. The node will forward packets - from the 15.4 network to its UART (and thus a connected PC over SLIP) \ No newline at end of file + from the 15.4 network to its UART (and thus a connected PC over SLIP) diff --git a/examples/sensinode/blink-hello.c b/examples/sensinode/blink-hello.c index 593589041..80d2fb9ad 100644 --- a/examples/sensinode/blink-hello.c +++ b/examples/sensinode/blink-hello.c @@ -10,82 +10,53 @@ #include "contiki.h" #include "dev/leds.h" -#include /* For printf() */ +#include /*---------------------------------------------------------------------------*/ -/* 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); */ + static struct etimer timer; + static int count; - /* if the event is the timer event as expected... */ - if(ev == PROCESS_EVENT_TIMER) - { - /* do the process work */ - 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 */ + PROCESS_BEGIN(); + + etimer_set(&timer, CLOCK_CONF_SECOND * 4); + count = 0; + + while(1) { + + PROCESS_WAIT_EVENT(); + + if(ev == PROCESS_EVENT_TIMER) { + printf("Sensor says no... #%d\r\n", count); + count++; + + etimer_reset(&timer); } - /* any process must end with this, even if it is never reached. */ - PROCESS_END(); + } + + PROCESS_END(); } /*---------------------------------------------------------------------------*/ /* Implementation of the second process */ PROCESS_THREAD(blink_process, ev, data) { - static struct etimer timer; - PROCESS_BEGIN(); - - while (1) - { - /* we set the timer from here every time */ - 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(); + static struct etimer timer; + PROCESS_BEGIN(); + + while(1) { + etimer_set(&timer, CLOCK_CONF_SECOND); + + PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER); + + printf("Blink... (state %0.2X).\r\n", leds_get()); + leds_toggle(LEDS_GREEN); + } + PROCESS_END(); } /*---------------------------------------------------------------------------*/ diff --git a/examples/sensinode/border-router/border-router.c b/examples/sensinode/border-router/border-router.c index 01dc99d3e..9cab28e42 100644 --- a/examples/sensinode/border-router/border-router.c +++ b/examples/sensinode/border-router/border-router.c @@ -71,11 +71,11 @@ print_local_addresses(void) CC_NON_BANKED for(i = 0; i < UIP_DS6_ADDR_NB; i++) { state = uip_ds6_if.addr_list[i].state; if(uip_ds6_if.addr_list[i].isused && (state == ADDR_TENTATIVE || state - == ADDR_PREFERRED)) { + == ADDR_PREFERRED)) { PUTSTRING(" "); PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr); PUTCHAR('\n'); - if (state == ADDR_TENTATIVE) { + if(state == ADDR_TENTATIVE) { uip_ds6_if.addr_list[i].state = ADDR_PREFERRED; } } diff --git a/examples/sensinode/border-router/slip-bridge.c b/examples/sensinode/border-router/slip-bridge.c index bfa8afbc9..ac7c67d14 100644 --- a/examples/sensinode/border-router/slip-bridge.c +++ b/examples/sensinode/border-router/slip-bridge.c @@ -58,7 +58,7 @@ static void slip_input_callback(void) { PRINTF("SIN: %u\n", uip_len); - if((char) uip_buf[0] == '!') { + if((char)uip_buf[0] == '!') { PRINTF("Got configuration message of type %c\n", uip_buf[1]); uip_len = 0; if((char)uip_buf[1] == 'P') { diff --git a/examples/sensinode/broadcast-rime.c b/examples/sensinode/broadcast-rime.c index d46c5cb5f..c6beab0d2 100644 --- a/examples/sensinode/broadcast-rime.c +++ b/examples/sensinode/broadcast-rime.c @@ -58,21 +58,25 @@ 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); PRINTF("LL-TX=%lu , LL-RX=%lu\n", rimestats.lltx, rimestats.llrx); PRINTF(" Long=%lu , Short=%lu\n", rimestats.toolong, rimestats.tooshort); PRINTF("T/Out=%lu , CCA-Err=%lu\n", rimestats.timedout, - rimestats.contentiondrop); + rimestats.contentiondrop); } static const struct broadcast_callbacks bc_rx = { broadcast_recv }; @@ -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,8 +102,9 @@ 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()); - if (broadcast_send(&broadcast) == 0) { + PRINTF("Sending %u bytes: 0x%04x\n", packetbuf_datalen(), + *(uint16_t *)packetbuf_dataptr()); + if(broadcast_send(&broadcast) == 0) { PRINTF("Error Sending\n"); } diff --git a/examples/sensinode/cc2431-location-engine/blind-node.c b/examples/sensinode/cc2431-location-engine/blind-node.c index d50865522..7fd40623d 100644 --- a/examples/sensinode/cc2431-location-engine/blind-node.c +++ b/examples/sensinode/cc2431-location-engine/blind-node.c @@ -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; @@ -243,11 +245,11 @@ PROCESS_THREAD(blindnode_bcast_rec, ev, data) * Just hard-coding measurement parameters here. * Ideally, this should be part of a calibration mechanism */ - parameters.alpha=SAMPLE_ALPHA; - parameters.x_min=0; - parameters.x_delta=255; - parameters.y_min=0; - parameters.y_delta=255; + parameters.alpha = SAMPLE_ALPHA; + parameters.x_min = 0; + parameters.x_delta = 255; + parameters.y_min = 0; + parameters.y_delta = 255; set_imaginary_ref_nodes(); @@ -263,13 +265,15 @@ PROCESS_THREAD(blindnode_bcast_rec, ev, data) * With the hard-coded parameters and locations, we will calculate * for all possible values of n [0 , 31] */ - parameters.n=n; + 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)); + packetbuf_copyfrom(&coords, 2 * sizeof(uint8_t)); broadcast_send(&broadcast); } PROCESS_END(); diff --git a/examples/sensinode/energy-scan/netstack.c b/examples/sensinode/energy-scan/netstack.c index 2551f82fe..d59acc3fe 100644 --- a/examples/sensinode/energy-scan/netstack.c +++ b/examples/sensinode/energy-scan/netstack.c @@ -47,4 +47,3 @@ netstack_init(void) NETSTACK_RADIO.init(); } /*---------------------------------------------------------------------------*/ - diff --git a/examples/sensinode/energy-scan/stub-rdc.c b/examples/sensinode/energy-scan/stub-rdc.c index c131d953d..ed335fc70 100644 --- a/examples/sensinode/energy-scan/stub-rdc.c +++ b/examples/sensinode/energy-scan/stub-rdc.c @@ -88,13 +88,13 @@ init(void) } /*---------------------------------------------------------------------------*/ const struct rdc_driver stub_rdc_driver = { - "stub-rdc", - init, - send, - send_list, - input, - on, - off, - cca, + "stub-rdc", + init, + send, + send_list, + input, + on, + off, + cca, }; /*---------------------------------------------------------------------------*/ diff --git a/examples/sensinode/event-post/event-post.c b/examples/sensinode/event-post/event-post.c index ed249eeed..7a091cfa7 100644 --- a/examples/sensinode/event-post/event-post.c +++ b/examples/sensinode/event-post/event-post.c @@ -14,119 +14,85 @@ #include "contiki.h" //#include "dev/leds.h" #include -#include /* For printf() */ +#include #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; + static struct etimer timer; + 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.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; + es.s_val = SHRT_MAX - 2; + es.i_val = INT_MAX - 2; + es.l_val = LONG_MAX - 2; + es.ll_val = LONG_MAX - 2; + 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) - { - printf("Sensor process: Wait for timer event...\r\n"); - /* Wait on our timer */ - PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER); + event_data_ready = process_alloc_event(); - /* blip */ - /* leds_toggle(LEDS_BLUE); */ + printf("Contiki allocated event ID %d.\r\n", event_data_ready); - /* Set the 'sensor' value before throwing the event */ - printf("Sensor Process: Incrementing values...\r\n"); - es.s_val++; - es.i_val++; - es.l_val++; - es.ll_val++; - es.u8_val++; - es.u16_val++; - es.u32_val++; + etimer_set(&timer, CLOCK_CONF_SECOND * 2); - /* 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); + while(1) { + printf("Sensor process: Wait for timer event...\r\n"); - /* reset the timer so we can wait on it again */ - etimer_reset(&timer); + PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_TIMER); - } - PROCESS_END(); + printf("Sensor Process: Incrementing values...\r\n"); + es.s_val++; + es.i_val++; + es.l_val++; + es.ll_val++; + es.u8_val++; + es.u16_val++; + es.u32_val++; + + printf("Sensor Process: Generating 'Data Ready' event.\r\n"); + process_post(&print_process, event_data_ready, &es); + + etimer_reset(&timer); + + } + PROCESS_END(); } /*---------------------------------------------------------------------------*/ /* Implementation of "Print Process" */ PROCESS_THREAD(print_process, ev, data) { - struct event_struct * sd; + struct event_struct *sd; - PROCESS_BEGIN(); - - while (1) - { - /* Stop here and wait until "event_data_ready" occurs */ - 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); - printf(" i: %d\r\n", sd->i_val); - printf(" l: %ld\r\n", sd->l_val); - printf(" ll: %lld\r\n", sd->ll_val); - printf(" u8: %u\r\n", sd->u8_val); - printf(" u16: %u\r\n", sd->u16_val); - printf(" u32: %lu\r\n", sd->u32_val); + PROCESS_BEGIN(); - /* aaaaand back to waiting for the next event */ - } - PROCESS_END(); + while(1) { + + PROCESS_WAIT_EVENT_UNTIL(ev == event_data_ready); + + sd = data; + printf("Print Process - Data Ready:\r\n"); + printf(" s: %d\r\n", sd->s_val); + printf(" i: %d\r\n", sd->i_val); + printf(" l: %ld\r\n", sd->l_val); + printf(" ll: %lld\r\n", sd->ll_val); + printf(" u8: %u\r\n", sd->u8_val); + printf(" u16: %u\r\n", sd->u16_val); + printf(" u32: %lu\r\n", sd->u32_val); + + } + PROCESS_END(); } /*---------------------------------------------------------------------------*/ diff --git a/examples/sensinode/event-post/event-post.h b/examples/sensinode/event-post/event-post.h index f43934438..650d38b4a 100644 --- a/examples/sensinode/event-post/event-post.h +++ b/examples/sensinode/event-post/event-post.h @@ -10,11 +10,11 @@ #define EVENT_POST_H_ struct event_struct { - short s_val; - int i_val; - long l_val; + short s_val; + int i_val; + long l_val; long long ll_val; - uint8_t u8_val; + uint8_t u8_val; uint16_t u16_val; uint32_t u32_val; }; diff --git a/examples/sensinode/hello_world.c b/examples/sensinode/hello_world.c deleted file mode 100644 index ec3d2c3d6..000000000 --- a/examples/sensinode/hello_world.c +++ /dev/null @@ -1,23 +0,0 @@ -/** - * \file - * Basic hello world example - * \author - * Zach Shelby - */ - -#include "contiki.h" -#include /* 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(); -} -/*---------------------------------------------------------------------------*/ diff --git a/examples/sensinode/rf_test_rx.c b/examples/sensinode/rf_test_rx.c deleted file mode 100644 index 4d816f845..000000000 --- a/examples/sensinode/rf_test_rx.c +++ /dev/null @@ -1,60 +0,0 @@ -/** - * \file - * RF test suite, receiver - * \author - * Zach Shelby - */ - -#include "contiki.h" -#include "net/rime.h" -#include /* 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(); -} -/*---------------------------------------------------------------------------*/ diff --git a/examples/sensinode/rf_test_tx.c b/examples/sensinode/rf_test_tx.c deleted file mode 100644 index d2ed92cdb..000000000 --- a/examples/sensinode/rf_test_tx.c +++ /dev/null @@ -1,50 +0,0 @@ -/** - * \file - * RF test suite, transmitter - * \author - * Zach Shelby - */ - -#include "contiki.h" -#include "net/rime.h" -#include /* 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(); -} -/*---------------------------------------------------------------------------*/ diff --git a/examples/sensinode/sensors-ipv6/sensors-driver.c b/examples/sensinode/sensors-ipv6/sensors-driver.c index 148d2b3a4..c3e90a13b 100644 --- a/examples/sensinode/sensors-ipv6/sensors-driver.c +++ b/examples/sensinode/sensors-ipv6/sensors-driver.c @@ -77,11 +77,11 @@ /*---------------------------------------------------------------------------*/ int8_t -read_sensor(char * rs) +read_sensor(char *rs) { /* Sensor Values */ static int rv; - static struct sensors_sensor * sensor; + static struct sensors_sensor *sensor; /* Those 3 variables are only used for debugging */ #if DEBUG @@ -93,7 +93,7 @@ read_sensor(char * rs) uint8_t len = 0; sensor = sensors_find(ADC_SENSOR); - if (!sensor) { + if(!sensor) { PRINTF("ADC not found\n"); return (SENSOR_ADC_OFF); } @@ -103,13 +103,13 @@ read_sensor(char * rs) r = uip_ntohs(r); PRINTF("R=%u\n", r); - if (r & REQUEST_BIT_CHIPID) { + if(r & REQUEST_BIT_CHIPID) { uint8_t chipid = CHIPID; memcpy(rs + len, &chipid, sizeof(chipid)); len += sizeof(chipid); PRINTF("ChipID=0x%02x\n", chipid); } - if (r & REQUEST_BIT_UPTIME) { + if(r & REQUEST_BIT_UPTIME) { /* Uptime */ unsigned long l; @@ -118,33 +118,33 @@ read_sensor(char * rs) len += sizeof(l); PRINTF("Uptime=%lu secs\n", uip_ntohl(l)); } - if (r & REQUEST_BIT_LIGHT) { + if(r & REQUEST_BIT_LIGHT) { rv = sensor->value(ADC_SENSOR_TYPE_LIGHT); if(rv != -1) { #if DEBUG 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); #endif memcpy(rs + len, &rv, sizeof(rv)); len += sizeof(rv); } } - if (r & REQUEST_BIT_TEMP) { + if(r & REQUEST_BIT_TEMP) { rv = sensor->value(ADC_SENSOR_TYPE_TEMP); if(rv != -1) { #if DEBUG 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); #endif memcpy(rs + len, &rv, sizeof(rv)); len += sizeof(rv); } } - if (r & (REQUEST_BIT_VDD | REQUEST_BIT_BAT)) { + if(r & (REQUEST_BIT_VDD | REQUEST_BIT_BAT)) { /* We want VDD for both cases */ rv = sensor->value(ADC_SENSOR_TYPE_VDD); if(rv != -1) { @@ -152,7 +152,7 @@ read_sensor(char * rs) sane = rv * 3.75 / 2047; dec = sane; frac = sane - dec; - PRINTF("Supply=%d.%02uV (%d)\n", dec, (unsigned int)(frac*100), rv); + PRINTF("Supply=%d.%02uV (%d)\n", dec, (unsigned int)(frac * 100), rv); /* Store rv temporarily in dec so we can use it for the battery */ dec = rv; #endif @@ -160,21 +160,21 @@ read_sensor(char * rs) len += sizeof(rv); } /* And then carry on with battery if needed */ - if (r & REQUEST_BIT_BAT) { + if(r & REQUEST_BIT_BAT) { rv = sensor->value(ADC_SENSOR_TYPE_BATTERY); if(rv != -1) { #if DEBUG sane = (11.25 * rv * dec) / (0x7FE002); dec = sane; frac = sane - dec; - PRINTF(" Batt.=%d.%02uV (%d)\n", dec, (unsigned int)(frac*100), rv); + PRINTF(" Batt.=%d.%02uV (%d)\n", dec, (unsigned int)(frac * 100), rv); #endif memcpy(rs + len, &rv, sizeof(rv)); len += sizeof(rv); } } } - if (r & REQUEST_BIT_ACC) { + if(r & REQUEST_BIT_ACC) { rv = sensor->value(ADC_SENSOR_TYPE_ACC_X); if(rv != -1) { #if DEBUG @@ -187,7 +187,7 @@ read_sensor(char * rs) if(sane < 0 && dec == 0) { PRINTF('-'); } - PRINTF("%d.%02ug (%d)\n", dec, (unsigned int)(frac*100), rv); + PRINTF("%d.%02ug (%d)\n", dec, (unsigned int)(frac * 100), rv); #endif memcpy(rs + len, &rv, sizeof(rv)); len += sizeof(rv); @@ -203,7 +203,7 @@ read_sensor(char * rs) if(sane < 0 && dec == 0) { PRINTF('-'); } - PRINTF("%d.%02ug (%d)\n", dec, (unsigned int)(frac*100), rv); + PRINTF("%d.%02ug (%d)\n", dec, (unsigned int)(frac * 100), rv); #endif memcpy(rs + len, &rv, sizeof(rv)); len += sizeof(rv); @@ -219,25 +219,25 @@ read_sensor(char * rs) if(sane < 0 && dec == 0) { PRINTF('-'); } - PRINTF("%d.%02ug (%d)\n", dec, (unsigned int)(frac*100), rv); + PRINTF("%d.%02ug (%d)\n", dec, (unsigned int)(frac * 100), rv); #endif memcpy(rs + len, &rv, sizeof(rv)); len += sizeof(rv); } } - if (r & REQUEST_BIT_L1_SET) { + if(r & REQUEST_BIT_L1_SET) { leds_toggle(LEDS_GREEN); } - if (r & REQUEST_BIT_L2_SET) { + if(r & REQUEST_BIT_L2_SET) { leds_toggle(LEDS_RED); } - if (r & REQUEST_BIT_LED_GET) { + if(r & REQUEST_BIT_LED_GET) { uint8_t leds = leds_get(); memcpy(rs + len, &leds, sizeof(leds)); len += sizeof(leds); PRINTF(" LED 2=%u\n", leds); } - if (r & REQUEST_BIT_P0_GET) { + if(r & REQUEST_BIT_P0_GET) { uint8_t p0 = P0_3; memcpy(rs + len, &p0, sizeof(p0)); len += sizeof(p0); diff --git a/examples/sensinode/sensors-ipv6/sensors-ipv6.c b/examples/sensinode/sensors-ipv6/sensors-ipv6.c index bf07a595c..839daf50e 100644 --- a/examples/sensinode/sensors-ipv6/sensors-ipv6.c +++ b/examples/sensinode/sensors-ipv6/sensors-ipv6.c @@ -79,7 +79,7 @@ static uint16_t len; #define SENSOR_ADC_OFF 1 #define SENSOR_UNKNOWN 2 -int8_t read_sensor(char * rs); +int8_t read_sensor(char *rs); /*---------------------------------------------------------------------------*/ extern const struct sensors_sensor adc_sensor; /*---------------------------------------------------------------------------*/ @@ -98,7 +98,7 @@ tcpip_handler(void) PRINT6ADDR(&UIP_IP_BUF->srcipaddr); PRINTF("]:%u\n", UIP_HTONS(UIP_UDP_BUF->srcport)); len = read_sensor(buf); - if( len ) { + if(len) { server_conn->rport = UIP_UDP_BUF->srcport; uip_ipaddr_copy(&server_conn->ripaddr, &UIP_IP_BUF->srcipaddr); uip_udp_packet_send(server_conn, buf, len); diff --git a/examples/sensinode/sensors/sensors-example.c b/examples/sensinode/sensors/sensors-example.c index 33277b77d..9dbba9793 100644 --- a/examples/sensinode/sensors/sensors-example.c +++ b/examples/sensinode/sensors/sensors-example.c @@ -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; } @@ -138,7 +140,7 @@ PROCESS_THREAD(buttons_test_process, ev, data) PROCESS_BEGIN(); - while (1) { + while(1) { PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event); @@ -165,7 +167,7 @@ PROCESS_THREAD(sensors_test_process, ev, data) /* Sensor Values */ static int rv; - static struct sensors_sensor * sensor; + static struct sensors_sensor *sensor; static float sane = 0; static int dec; static float frac; @@ -187,7 +189,7 @@ PROCESS_THREAD(sensors_test_process, ev, data) /* Set an etimer. We take sensor readings when it expires and reset it. */ etimer_set(&et, CLOCK_SECOND * 2); - while (1) { + while(1) { PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); @@ -196,7 +198,7 @@ PROCESS_THREAD(sensors_test_process, ev, data) * Return value -1 means sensor not available or turned off in conf */ sensor = sensors_find(ADC_SENSOR); - if (sensor) { + if(sensor) { putstring("------------------\n"); leds_on(LEDS_RED); /* @@ -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 @@ -263,7 +266,7 @@ PROCESS_THREAD(sensors_test_process, ev, data) if(sane < 0 && dec == 0) { putchar('-'); } - PRINTF("%d.%02ug (%d)\n", dec, (unsigned int)(frac*100), rv); + PRINTF("%d.%02ug (%d)\n", dec, (unsigned int)(frac * 100), rv); } rv = sensor->value(ADC_SENSOR_TYPE_ACC_Y); if(rv != -1) { @@ -275,7 +278,7 @@ PROCESS_THREAD(sensors_test_process, ev, data) if(sane < 0 && dec == 0) { putchar('-'); } - PRINTF("%d.%02ug (%d)\n", dec, (unsigned int)(frac*100), rv); + PRINTF("%d.%02ug (%d)\n", dec, (unsigned int)(frac * 100), rv); } rv = sensor->value(ADC_SENSOR_TYPE_ACC_Z); if(rv != -1) { @@ -287,7 +290,7 @@ PROCESS_THREAD(sensors_test_process, ev, data) if(sane < 0 && dec == 0) { putchar('-'); } - PRINTF("%d.%02ug (%d)\n", dec, (unsigned int)(frac*100), rv); + PRINTF("%d.%02ug (%d)\n", dec, (unsigned int)(frac * 100), rv); } /* * Light: Vishay Semiconductors TEPT4400 @@ -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. @@ -326,7 +330,7 @@ PROCESS_THREAD(sensors_test_process, ev, data) sane = rv * 3.75 / 2047; dec = sane; frac = sane - dec; - PRINTF("Supply=%d.%02uV (%d)\n", dec, (unsigned int)(frac*100), rv); + PRINTF("Supply=%d.%02uV (%d)\n", dec, (unsigned int)(frac * 100), rv); /* Store rv temporarily in dec so we can use it for the battery */ dec = rv; } @@ -356,7 +360,7 @@ PROCESS_THREAD(sensors_test_process, ev, data) sane = (11.25 * rv * dec) / (0x7FE002); dec = sane; frac = sane - dec; - PRINTF(" Batt.=%d.%02uV (%d)\n", dec, (unsigned int)(frac*100), rv); + PRINTF(" Batt.=%d.%02uV (%d)\n", dec, (unsigned int)(frac * 100), rv); #if SEND_BATTERY_INFO sd.bat = rv; packetbuf_copyfrom(&sd, sizeof(sd)); @@ -368,5 +372,5 @@ PROCESS_THREAD(sensors_test_process, ev, data) etimer_reset(&et); } PROCESS_END(); - } +} /*---------------------------------------------------------------------------*/ diff --git a/examples/sensinode/serial-flash/flash.c b/examples/sensinode/serial-flash/flash.c index a796b7513..4ac6048c9 100644 --- a/examples/sensinode/serial-flash/flash.c +++ b/examples/sensinode/serial-flash/flash.c @@ -256,7 +256,7 @@ PROCESS_THREAD(serial_flash_process, ev, data) while(M25P16_WIP()); /* Drop to Deep Power Down */ m25p16_dp(); - counter ++; + counter++; } n740_analog_activate(); } diff --git a/examples/sensinode/sniffer/netstack.c b/examples/sensinode/sniffer/netstack.c index 2551f82fe..d59acc3fe 100644 --- a/examples/sensinode/sniffer/netstack.c +++ b/examples/sensinode/sniffer/netstack.c @@ -47,4 +47,3 @@ netstack_init(void) NETSTACK_RADIO.init(); } /*---------------------------------------------------------------------------*/ - diff --git a/examples/sensinode/sniffer/stub-rdc.c b/examples/sensinode/sniffer/stub-rdc.c index 063a43659..a4db0710d 100644 --- a/examples/sensinode/sniffer/stub-rdc.c +++ b/examples/sensinode/sniffer/stub-rdc.c @@ -88,13 +88,13 @@ init(void) } /*---------------------------------------------------------------------------*/ const struct rdc_driver stub_rdc_driver = { - "stub-rdc", - init, - send, - send_list, - input, - on, - off, - cca, + "stub-rdc", + init, + send, + send_list, + input, + on, + off, + cca, }; /*---------------------------------------------------------------------------*/ diff --git a/examples/sensinode/timer-test.c b/examples/sensinode/timer-test.c index 7d9844676..df954bccc 100644 --- a/examples/sensinode/timer-test.c +++ b/examples/sensinode/timer-test.c @@ -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); @@ -73,7 +74,7 @@ PROCESS_THREAD(clock_test_process, ev, data) end_count = RTIMER_NOW(); diff = end_count - start_count; printf("Requested: %u usec, Real: %u rtimer ticks = ~%u us\n", - 10000 * i, diff, diff * 64); + 10000 * i, diff, diff * 64); i++; } #endif @@ -82,14 +83,14 @@ PROCESS_THREAD(clock_test_process, ev, data) printf("Rtimer Test, 1 sec (%u rtimer ticks):\n", RTIMER_SECOND); i = 0; while(i < 5) { - etimer_set(&et, 2*CLOCK_SECOND); + etimer_set(&et, 2 * CLOCK_SECOND); printf("=======================\n"); ct = clock_time(); 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); diff --git a/examples/sensinode/udp-ipv6/client.c b/examples/sensinode/udp-ipv6/client.c index 0cb13e3f6..8ad6520d5 100644 --- a/examples/sensinode/udp-ipv6/client.c +++ b/examples/sensinode/udp-ipv6/client.c @@ -88,7 +88,7 @@ static void timeout_handler(void) { static int seq_id; - struct uip_udp_conn * this_conn; + struct uip_udp_conn *this_conn; leds_on(LEDS_RED); memset(buf, 0, MAX_PAYLOAD_LEN); @@ -131,9 +131,9 @@ print_local_addresses(void) for(i = 0; i < UIP_DS6_ADDR_NB; i++) { state = uip_ds6_if.addr_list[i].state; if(uip_ds6_if.addr_list[i].isused && (state == ADDR_TENTATIVE || state - == ADDR_PREFERRED)) { + == ADDR_PREFERRED)) { PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr); - if (state == ADDR_TENTATIVE) { + if(state == ADDR_TENTATIVE) { uip_ds6_if.addr_list[i].state = ADDR_PREFERRED; } PRINTF(" state: %u.\n", uip_ds6_if.addr_list[i].state); @@ -168,7 +168,7 @@ PROCESS_THREAD(udp_client_process, ev, data) print_local_addresses(); - uip_ip6addr(&ipaddr,0xfe80,0,0,0,0x0215,0x2000,0x0002,0x0302); + uip_ip6addr(&ipaddr, 0xfe80, 0, 0, 0, 0x0215, 0x2000, 0x0002, 0x0302); /* new connection with remote host */ l_conn = udp_new(&ipaddr, UIP_HTONS(3000), NULL); if(!l_conn) { @@ -179,10 +179,11 @@ PROCESS_THREAD(udp_client_process, ev, data) PRINTF("Link-Local connection with "); PRINT6ADDR(&l_conn->ripaddr); PRINTF(" local/remote port %u/%u\n", - UIP_HTONS(l_conn->lport), UIP_HTONS(l_conn->rport)); + 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"); @@ -192,7 +193,7 @@ PROCESS_THREAD(udp_client_process, ev, data) PRINTF("Global connection with "); PRINT6ADDR(&g_conn->ripaddr); PRINTF(" local/remote port %u/%u\n", - UIP_HTONS(g_conn->lport), UIP_HTONS(g_conn->rport)); + UIP_HTONS(g_conn->lport), UIP_HTONS(g_conn->rport)); #endif etimer_set(&et, SEND_INTERVAL); diff --git a/examples/sensinode/udp-ipv6/ping6.c b/examples/sensinode/udp-ipv6/ping6.c index 396edbc94..ab5c4f81b 100644 --- a/examples/sensinode/udp-ipv6/ping6.c +++ b/examples/sensinode/udp-ipv6/ping6.c @@ -101,18 +101,19 @@ ping6handler() /*---------------------------------------------------------------------------*/ PROCESS_THREAD(ping6_process, ev, data) { - + #if (CONTIKI_TARGET_SENSINODE && BUTTON_SENSOR_ON) - static struct sensors_sensor * btn; + static struct sensors_sensor *btn; #endif PROCESS_BEGIN(); 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 */ #if (CONTIKI_TARGET_SENSINODE && BUTTON_SENSOR_ON) btn = sensors_find(BUTTON_1_SENSOR); @@ -132,7 +133,7 @@ PROCESS_THREAD(ping6_process, ev, data) ping6handler(); } } - + PROCESS_END(); } /*---------------------------------------------------------------------------*/ diff --git a/examples/sensinode/udp-ipv6/server.c b/examples/sensinode/udp-ipv6/server.c index ca56364ae..e7346cebf 100644 --- a/examples/sensinode/udp-ipv6/server.c +++ b/examples/sensinode/udp-ipv6/server.c @@ -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() @@ -122,11 +123,11 @@ print_local_addresses(void) for(i = 0; i < UIP_DS6_ADDR_NB; i++) { state = uip_ds6_if.addr_list[i].state; if(uip_ds6_if.addr_list[i].isused && (state == ADDR_TENTATIVE || state - == ADDR_PREFERRED)) { + == ADDR_PREFERRED)) { PRINTF(" "); PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr); PRINTF("\n"); - if (state == ADDR_TENTATIVE) { + if(state == ADDR_TENTATIVE) { uip_ds6_if.addr_list[i].state = ADDR_PREFERRED; } } @@ -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); diff --git a/platform/cc2530dk/contiki-main.c b/platform/cc2530dk/contiki-main.c index b5ac1555e..1935470bc 100644 --- a/platform/cc2530dk/contiki-main.c +++ b/platform/cc2530dk/contiki-main.c @@ -65,7 +65,7 @@ fade(int l) CC_NON_BANKED volatile int i, a; int k, j; for(k = 0; k < 400; ++k) { - j = k > 200? 400 - k: k; + j = k > 200 ? 400 - k : k; leds_on(l); for(i = 0; i < j; ++i) { @@ -84,9 +84,9 @@ set_rime_addr(void) CC_NON_BANKED char i; #if CC2530_CONF_MAC_FROM_PRIMARY - __xdata unsigned char * macp = &X_IEEE_ADDR; + __xdata unsigned char *macp = &X_IEEE_ADDR; #else - __code unsigned char * macp = (__code unsigned char *) 0xFFE8; + __code unsigned char *macp = (__code unsigned char *)0xFFE8; #endif PUTSTRING("Rime is 0x"); diff --git a/platform/cc2530dk/debug.c b/platform/cc2530dk/debug.c index 1773eff52..36131227a 100644 --- a/platform/cc2530dk/debug.c +++ b/platform/cc2530dk/debug.c @@ -50,8 +50,7 @@ putdec(uint8_t c) c %= div; if((disp != 0) || (hassent) || (div == 1)) { hassent = 1; - putchar('0'+disp); + putchar('0' + disp); } } } - diff --git a/platform/cc2530dk/dev/button-sensor.c b/platform/cc2530dk/dev/button-sensor.c index c1a6f593c..4f5f1347d 100644 --- a/platform/cc2530dk/dev/button-sensor.c +++ b/platform/cc2530dk/dev/button-sensor.c @@ -40,26 +40,26 @@ 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) { + switch(type) { case SENSORS_ACTIVE: case SENSORS_READY: return BUTTON_IRQ_ENABLED(1); - } + } 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,26 +88,26 @@ 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) { + switch(type) { case SENSORS_ACTIVE: case SENSORS_READY: return BUTTON_IRQ_ENABLED(2); - } + } return 0; } /*---------------------------------------------------------------------------*/ -static -int configure_b2(int type, int value) +static int +configure_b2(int type, int value) { switch(type) { case SENSORS_HW_INIT: diff --git a/platform/cc2530dk/dev/leds-arch.c b/platform/cc2530dk/dev/leds-arch.c index e899893dd..566fb000c 100644 --- a/platform/cc2530dk/dev/leds-arch.c +++ b/platform/cc2530dk/dev/leds-arch.c @@ -59,9 +59,9 @@ unsigned char leds_arch_get(void) { #if MODEL_CC2531 - return (unsigned char) (LED1_PIN | ((LED2_PIN ^ 0x01) << 1)); + return (unsigned char)(LED1_PIN | ((LED2_PIN ^ 0x01) << 1)); #else - return (unsigned char) (LED1_PIN | (LED2_PIN << 1) | (LED3_PIN << 2)); + return (unsigned char)(LED1_PIN | (LED2_PIN << 1) | (LED3_PIN << 2)); #endif } /*---------------------------------------------------------------------------*/ diff --git a/platform/cc2530dk/dev/smartrf-sensors.c b/platform/cc2530dk/dev/smartrf-sensors.c index 87d4935cc..4bac66dab 100644 --- a/platform/cc2530dk/dev/smartrf-sensors.c +++ b/platform/cc2530dk/dev/smartrf-sensors.c @@ -43,15 +43,15 @@ const struct sensors_sensor *sensors[] = { #if ADC_SENSOR_ON - &adc_sensor, + &adc_sensor, #endif #if BUTTON_SENSOR_ON - &button_1_sensor, + &button_1_sensor, #if MODEL_CC2531 - &button_2_sensor, + &button_2_sensor, #endif #endif - 0 + 0 }; unsigned char sensors_flags[(sizeof(sensors) / sizeof(struct sensors_sensor *))]; diff --git a/platform/cc2530dk/dev/usb-serial.c b/platform/cc2530dk/dev/usb-serial.c index 403813cb6..4f766abb7 100644 --- a/platform/cc2530dk/dev/usb-serial.c +++ b/platform/cc2530dk/dev/usb-serial.c @@ -104,20 +104,20 @@ static uint8_t buffered_data = 0; #endif /* Callback to the input handler */ -static int (*input_handler)(unsigned char c); +static int (* input_handler)(unsigned char c); /*---------------------------------------------------------------------------*/ uint8_t * usb_class_get_string_descriptor(uint16_t lang, uint8_t string) { switch (string) { case 0: - return (uint8_t *) &lang_id; + return (uint8_t *)&lang_id; case 1: - return (uint8_t *) &string_manufacturer; + return (uint8_t *)&string_manufacturer; case 2: - return (uint8_t *) &string_product; + return (uint8_t *)&string_product; case 3: - return (uint8_t *) &string_serial_nr; + return (uint8_t *)&string_serial_nr; default: return NULL; } @@ -271,7 +271,7 @@ PROCESS_THREAD(usb_serial_process, ev, data) } /*---------------------------------------------------------------------------*/ void -usb_serial_set_input(int (*input)(unsigned char c)) +usb_serial_set_input(int (* input)(unsigned char c)) { input_handler = input; } diff --git a/platform/cc2530dk/dev/usb-serial.h b/platform/cc2530dk/dev/usb-serial.h index 3af06b37e..bc7784e49 100644 --- a/platform/cc2530dk/dev/usb-serial.h +++ b/platform/cc2530dk/dev/usb-serial.h @@ -46,7 +46,7 @@ void usb_serial_init(void); void usb_serial_writeb(uint8_t); -void usb_serial_set_input(int (*input)(unsigned char c)); +void usb_serial_set_input(int (* input)(unsigned char c)); #if USB_SERIAL_CONF_BUFFERED void usb_serial_flush(void); diff --git a/platform/cc2530dk/viztool.c b/platform/cc2530dk/viztool.c index 642cb2f5c..4c37fc114 100644 --- a/platform/cc2530dk/viztool.c +++ b/platform/cc2530dk/viztool.c @@ -41,6 +41,7 @@ #include "contiki.h" #include "contiki-lib.h" #include "contiki-net.h" +#include "net/uip-ds6-route.h" #include @@ -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 @@ -90,7 +92,7 @@ process_request() CC_NON_BANKED for(i = buf[1]; i < UIP_DS6_NBR_NB; i++) { if(uip_ds6_nbr_cache[i].isused) { entry_size = sizeof(i) + sizeof(uip_ipaddr_t) + sizeof(uip_lladdr_t) - + sizeof(uip_ds6_nbr_cache[i].state); + + sizeof(uip_ds6_nbr_cache[i].state); PRINTF("%02u: ", i); PRINT6ADDR(&uip_ds6_nbr_cache[i].ipaddr); PRINTF(" - "); @@ -104,7 +106,7 @@ process_request() CC_NON_BANKED memcpy(buf + len, &uip_ds6_nbr_cache[i].lladdr, sizeof(uip_lladdr_t)); len += sizeof(uip_lladdr_t); memcpy(buf + len, &uip_ds6_nbr_cache[i].state, - sizeof(uip_ds6_nbr_cache[i].state)); + sizeof(uip_ds6_nbr_cache[i].state)); len += sizeof(uip_ds6_nbr_cache[i].state); count++; @@ -117,85 +119,85 @@ 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; } } } - } else if (buf[0] == REQUEST_TYPE_DRT) { + } 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); - 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); - - PRINT6ADDR(&uip_ds6_defrt_list[i].ipaddr); - PRINTF(" - %u\n", uip_ds6_defrt_list[i].isinfinite); - count++; - left -= entry_size; - - if(left < entry_size) { - break; - } - } + PRINTF("Default Route\n"); + addr = uip_ds6_defrt_choose(); + if(addr != NULL) { + defrt = uip_ds6_defrt_lookup(addr); } - } else if (buf[0] == REQUEST_TYPE_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, &defrt->ipaddr, sizeof(defrt->ipaddr)); + len += sizeof(defrt->ipaddr); + memcpy(buf + len, &defrt->isinfinite, sizeof(defrt->isinfinite)); + len += sizeof(defrt->isinfinite); + + PRINT6ADDR(&defrt->ipaddr); + PRINTF(" - %u\n", defrt->isinfinite); + count++; + left -= entry_size; + } + } else if(buf[0] == REQUEST_TYPE_ADDR) { PRINTF("Unicast Addresses\n"); for(i = buf[1]; i < UIP_DS6_ADDR_NB; i++) { if(uip_ds6_if.addr_list[i].isused) { @@ -204,7 +206,7 @@ process_request() CC_NON_BANKED memcpy(buf + len, &i, sizeof(i)); len += sizeof(i); memcpy(buf + len, &uip_ds6_if.addr_list[i].ipaddr, - sizeof(uip_ds6_if.addr_list[i].ipaddr)); + sizeof(uip_ds6_if.addr_list[i].ipaddr)); len += sizeof(uip_ds6_if.addr_list[i].ipaddr); PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr); @@ -217,7 +219,7 @@ process_request() CC_NON_BANKED } } } - } else if (buf[0] == REQUEST_TYPE_TOTALS) { + } else if(buf[0] == REQUEST_TYPE_TOTALS) { memset(&buf[2], 0, 4); for(i = 0; i < UIP_DS6_ADDR_NB; i++) { if(uip_ds6_if.addr_list[i].isused) { @@ -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 { diff --git a/platform/sensinode/apps/batmon/batmon.c b/platform/sensinode/apps/batmon/batmon.c index a4e59ab28..184404199 100644 --- a/platform/sensinode/apps/batmon/batmon.c +++ b/platform/sensinode/apps/batmon/batmon.c @@ -91,7 +91,7 @@ struct flash_address { static struct flash_address f; static struct record r; -static struct sensors_sensor * s; +static struct sensors_sensor *s; static struct etimer et; #define FLASH_START_ADDR 0x1E0000 #define FLASH_END_ADDR 0x1FFFFF @@ -201,7 +201,7 @@ PROCESS_THREAD(batmon_process, ev, data) PRINTF("BatMon\n", sizeof(r)); s = sensors_find(ADC_SENSOR); - if (!s) { + if(!s) { PRINTF("BatMon: ADC not found\n"); PROCESS_EXIT(); } diff --git a/platform/sensinode/contiki-conf.h b/platform/sensinode/contiki-conf.h index 610c3cf54..440d65948 100644 --- a/platform/sensinode/contiki-conf.h +++ b/platform/sensinode/contiki-conf.h @@ -206,7 +206,7 @@ /* ND and Routing */ #ifndef UIP_CONF_ROUTER -#define UIP_CONF_ROUTER 1 +#define UIP_CONF_ROUTER 1 #endif /* Prevent SDCC compile error when UIP_CONF_ROUTER == 0 */ diff --git a/platform/sensinode/contiki-sensinode-main.c b/platform/sensinode/contiki-sensinode-main.c index 27cc1a1ae..a13e440d2 100644 --- a/platform/sensinode/contiki-sensinode-main.c +++ b/platform/sensinode/contiki-sensinode-main.c @@ -77,7 +77,7 @@ fade(int l) CC_NON_BANKED volatile int i, a; int k, j; for(k = 0; k < 400; ++k) { - j = k > 200? 400 - k: k; + j = k > 200 ? 400 - k : k; leds_on(l); for(i = 0; i < j; ++i) { @@ -96,7 +96,7 @@ set_rime_addr(void) CC_NON_BANKED uint8_t *addr_long = NULL; uint16_t addr_short = 0; char i; - __code unsigned char * macp; + __code unsigned char *macp; PUTSTRING("Rime is 0x"); PUTHEX(sizeof(rimeaddr_t)); @@ -119,7 +119,7 @@ set_rime_addr(void) CC_NON_BANKED FMAP = 3; /* Set our pointer to the correct address and fetch 8 bytes of MAC */ - macp = (__code unsigned char *) 0xFFF8; + macp = (__code unsigned char *)0xFFF8; for(i = (RIMEADDR_SIZE - 1); i >= 0; --i) { rimeaddr_node_addr.u8[i] = *macp; @@ -343,7 +343,7 @@ main(void) nop __endasm; - if (SLEEP & SLEEP_MODE0) { + if(SLEEP & SLEEP_MODE0) { #endif /* LPM_MODE==LPM_MODE_PM2 */ ENERGEST_OFF(ENERGEST_TYPE_CPU); diff --git a/platform/sensinode/debug.c b/platform/sensinode/debug.c index 390c2ff06..f2fcb9498 100644 --- a/platform/sensinode/debug.c +++ b/platform/sensinode/debug.c @@ -54,7 +54,7 @@ putdec(uint8_t c) c %= div; if((disp != 0) || (hassent) || (div == 1)) { hassent = 1; - putchar('0'+disp); + putchar('0' + disp); } } } diff --git a/platform/sensinode/dev/adc-sensor.c b/platform/sensinode/dev/adc-sensor.c index 8de2deb04..c039adafa 100644 --- a/platform/sensinode/dev/adc-sensor.c +++ b/platform/sensinode/dev/adc-sensor.c @@ -134,8 +134,8 @@ value(int type) static int status(int type) { - return ready; - } + return ready; +} /*---------------------------------------------------------------------------*/ /* * On N740 we can control Ill and Acc individually: @@ -203,9 +203,9 @@ configure(int type, int value) ready |= ADC_VAL_LIGHT_ON; } #endif /* LIGHT_SENSOR_ON */ - n740_ser_par_set(ser_par_val); + n740_ser_par_set(ser_par_val); #endif /* MODEL_N740 */ - } + } return ready; } diff --git a/platform/sensinode/dev/button-sensor.c b/platform/sensinode/dev/button-sensor.c index a2bda01c2..7b9c82ab4 100644 --- a/platform/sensinode/dev/button-sensor.c +++ b/platform/sensinode/dev/button-sensor.c @@ -59,25 +59,25 @@ 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) { + switch(type) { case SENSORS_ACTIVE: case SENSORS_READY: return BUTTON_1_IRQ_ENABLED(); - } + } return 0; } /*---------------------------------------------------------------------------*/ -static -int configure_b1(int type, int value) +static int +configure_b1(int type, int value) { switch(type) { case SENSORS_HW_INIT: @@ -92,7 +92,7 @@ int configure_b1(int type, int value) timer_set(&debouncetimer[0], 0); BUTTON_1_IRQ_FLAG_OFF(); BUTTON_1_ENABLE_IRQ(); -} + } } else { BUTTON_1_DISABLE_IRQ(); } @@ -101,16 +101,16 @@ 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) { + switch(type) { case SENSORS_ACTIVE: case SENSORS_READY: return BUTTON_2_IRQ_ENABLED(); @@ -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: diff --git a/platform/sensinode/dev/m25p16.c b/platform/sensinode/dev/m25p16.c index d842a3421..f1cbdebfd 100644 --- a/platform/sensinode/dev/m25p16.c +++ b/platform/sensinode/dev/m25p16.c @@ -146,7 +146,7 @@ m25p16_wrdi() } /*---------------------------------------------------------------------------*/ void -m25p16_rdid(struct m25p16_rdid * rdid) +m25p16_rdid(struct m25p16_rdid *rdid) { uint8_t i; @@ -237,7 +237,7 @@ m25p16_pp(uint8_t * addr, uint8_t * buff, uint8_t buff_len) } /* Write the bytes */ - for(i=0; iconfigure(SENSORS_ACTIVE, 1); sensor = sensors_next(sensor); } @@ -73,7 +73,7 @@ sensinode_sensors_deactivate() { struct sensors_sensor *sensor; sensor = sensors_first(); - while (sensor) { + while(sensor) { sensor->configure(SENSORS_ACTIVE, 0); sensor = sensors_next(sensor); } diff --git a/platform/sensinode/disco.c b/platform/sensinode/disco.c index 39e023980..ccfbf3f09 100644 --- a/platform/sensinode/disco.c +++ b/platform/sensinode/disco.c @@ -76,7 +76,7 @@ void batmon_log(uint8_t trigger); #endif /*---------------------------------------------------------------------------*/ static struct uip_udp_conn *server_conn; -static struct disco_request_pdu * req; +static struct disco_request_pdu *req; static struct disco_response_pdu resp; static struct disco_seed seed; static uint8_t state; @@ -92,7 +92,7 @@ extern void *uip_appdata; __xdata __at(BOOTTY_CMD_LOCATION) static uint8_t bd; /*---------------------------------------------------------------------------*/ -static void timer_handler(void * p); +static void timer_handler(void *p); /*---------------------------------------------------------------------------*/ static void abort() CC_NON_BANKED @@ -116,9 +116,9 @@ restart_timer(uint16_t t) CC_NON_BANKED } /*---------------------------------------------------------------------------*/ static void -timer_handler(void * p) +timer_handler(void *p) { - uint8_t * s = p; + uint8_t *s = p; uint8_t wip; PRINTF("Disco: @ %lu, s: %u\n", clock_seconds(), *s); @@ -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; diff --git a/platform/sensinode/viztool.c b/platform/sensinode/viztool.c index 642cb2f5c..4c37fc114 100644 --- a/platform/sensinode/viztool.c +++ b/platform/sensinode/viztool.c @@ -41,6 +41,7 @@ #include "contiki.h" #include "contiki-lib.h" #include "contiki-net.h" +#include "net/uip-ds6-route.h" #include @@ -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 @@ -90,7 +92,7 @@ process_request() CC_NON_BANKED for(i = buf[1]; i < UIP_DS6_NBR_NB; i++) { if(uip_ds6_nbr_cache[i].isused) { entry_size = sizeof(i) + sizeof(uip_ipaddr_t) + sizeof(uip_lladdr_t) - + sizeof(uip_ds6_nbr_cache[i].state); + + sizeof(uip_ds6_nbr_cache[i].state); PRINTF("%02u: ", i); PRINT6ADDR(&uip_ds6_nbr_cache[i].ipaddr); PRINTF(" - "); @@ -104,7 +106,7 @@ process_request() CC_NON_BANKED memcpy(buf + len, &uip_ds6_nbr_cache[i].lladdr, sizeof(uip_lladdr_t)); len += sizeof(uip_lladdr_t); memcpy(buf + len, &uip_ds6_nbr_cache[i].state, - sizeof(uip_ds6_nbr_cache[i].state)); + sizeof(uip_ds6_nbr_cache[i].state)); len += sizeof(uip_ds6_nbr_cache[i].state); count++; @@ -117,85 +119,85 @@ 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; } } } - } else if (buf[0] == REQUEST_TYPE_DRT) { + } 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); - 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); - - PRINT6ADDR(&uip_ds6_defrt_list[i].ipaddr); - PRINTF(" - %u\n", uip_ds6_defrt_list[i].isinfinite); - count++; - left -= entry_size; - - if(left < entry_size) { - break; - } - } + PRINTF("Default Route\n"); + addr = uip_ds6_defrt_choose(); + if(addr != NULL) { + defrt = uip_ds6_defrt_lookup(addr); } - } else if (buf[0] == REQUEST_TYPE_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, &defrt->ipaddr, sizeof(defrt->ipaddr)); + len += sizeof(defrt->ipaddr); + memcpy(buf + len, &defrt->isinfinite, sizeof(defrt->isinfinite)); + len += sizeof(defrt->isinfinite); + + PRINT6ADDR(&defrt->ipaddr); + PRINTF(" - %u\n", defrt->isinfinite); + count++; + left -= entry_size; + } + } else if(buf[0] == REQUEST_TYPE_ADDR) { PRINTF("Unicast Addresses\n"); for(i = buf[1]; i < UIP_DS6_ADDR_NB; i++) { if(uip_ds6_if.addr_list[i].isused) { @@ -204,7 +206,7 @@ process_request() CC_NON_BANKED memcpy(buf + len, &i, sizeof(i)); len += sizeof(i); memcpy(buf + len, &uip_ds6_if.addr_list[i].ipaddr, - sizeof(uip_ds6_if.addr_list[i].ipaddr)); + sizeof(uip_ds6_if.addr_list[i].ipaddr)); len += sizeof(uip_ds6_if.addr_list[i].ipaddr); PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr); @@ -217,7 +219,7 @@ process_request() CC_NON_BANKED } } } - } else if (buf[0] == REQUEST_TYPE_TOTALS) { + } else if(buf[0] == REQUEST_TYPE_TOTALS) { memset(&buf[2], 0, 4); for(i = 0; i < UIP_DS6_ADDR_NB; i++) { if(uip_ds6_if.addr_list[i].isused) { @@ -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 { diff --git a/regression-tests/01-compile/Makefile b/regression-tests/01-compile/Makefile index 2a6bceb2d..67047b68c 100644 --- a/regression-tests/01-compile/Makefile +++ b/regression-tests/01-compile/Makefile @@ -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=