From 02fcf5835a77c1169f8840dde0f7ce949d34e7d6 Mon Sep 17 00:00:00 2001 From: Joakim Eriksson Date: Thu, 7 Apr 2011 17:44:07 +0200 Subject: [PATCH 01/18] fixed RPL to handle inifinite rank better --- core/net/rpl/rpl-dag.c | 12 ++++++++++-- core/net/uip-ds6.c | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/core/net/rpl/rpl-dag.c b/core/net/rpl/rpl-dag.c index bcd16a514..664422f0a 100644 --- a/core/net/rpl/rpl-dag.c +++ b/core/net/rpl/rpl-dag.c @@ -342,13 +342,20 @@ rpl_select_parent(rpl_dag_t *dag) best = NULL; for(p = list_head(dag->parents); p != NULL; p = p->next) { - if(best == NULL) { + if(p->rank == INFINITE_RANK) { + /* ignore this neighbor */ + } else if(best == NULL) { best = p; } else { best = dag->of->best_parent(best, p); } } + if(best == NULL) { + /* need to handle update of best... */ + return NULL; + } + if(dag->preferred_parent != best) { dag->preferred_parent = best; /* Cache the value. */ dag->of->update_metric_container(dag); @@ -642,7 +649,8 @@ rpl_process_parent_event(rpl_dag_t *dag, rpl_parent_t *p) rpl_reset_dio_timer(dag, 1); } - if(!acceptable_rank(dag, dag->of->calculate_rank(NULL, parent_rank))) { + if(parent_rank == INFINITE_RANK || + !acceptable_rank(dag, dag->of->calculate_rank(NULL, parent_rank))) { /* The candidate parent is no longer valid: the rank increase resulting from the choice of it as a parent would be too high. */ return 0; diff --git a/core/net/uip-ds6.c b/core/net/uip-ds6.c index 9d794cc17..7e3cf1882 100644 --- a/core/net/uip-ds6.c +++ b/core/net/uip-ds6.c @@ -47,7 +47,7 @@ #include "net/uip-ds6.h" #include "net/uip-packetqueue.h" -#define DEBUG DEBUG_ANNOTATE +#define DEBUG DEBUG_NONE #include "net/uip-debug.h" #ifdef UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED From 581d081ffec4db9d7c4663faee229ee80dc99bd1 Mon Sep 17 00:00:00 2001 From: dak664 Date: Thu, 7 Apr 2011 17:44:10 -0400 Subject: [PATCH 02/18] Don't use RF230_CONF_CCA_THRES if it is not defined. --- cpu/avr/radio/rf230bb/rf230bb.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cpu/avr/radio/rf230bb/rf230bb.c b/cpu/avr/radio/rf230bb/rf230bb.c index fc9005704..8383327d4 100644 --- a/cpu/avr/radio/rf230bb/rf230bb.c +++ b/cpu/avr/radio/rf230bb/rf230bb.c @@ -742,14 +742,20 @@ void rf230_warm_reset(void) { /* CCA energy threshold = -91dB + 2*SR_CCA_ED_THRESH. Reset defaults to -77dB */ /* Use RF230 base of -91; RF231 base is -90 according to datasheet */ +#ifdef RF230_CONF_CCA_THRES #if RF230_CONF_CCA_THRES < -91 +#warning #warning RF230_CONF_CCA_THRES below hardware limit, setting to -91dBm +#warning hal_subregister_write(SR_CCA_ED_THRES,0); #elif RF230_CONF_CCA_THRES > -61 +#warning #warning RF230_CONF_CCA_THRES above hardware limit, setting to -61dBm +#warning hal_subregister_write(SR_CCA_ED_THRES,15); #else hal_subregister_write(SR_CCA_ED_THRES,(RF230_CONF_CCA_THRES+91)/2); +#endif #endif /* Use automatic CRC unless manual is specified */ From 89741bd322c16ba59151fd3c1c22b9daec278d62 Mon Sep 17 00:00:00 2001 From: dak664 Date: Thu, 7 Apr 2011 17:47:54 -0400 Subject: [PATCH 03/18] Exit on watchdog reboot call --- cpu/native/watchdog.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cpu/native/watchdog.c b/cpu/native/watchdog.c index 0fbff9f21..6aa44e196 100644 --- a/cpu/native/watchdog.c +++ b/cpu/native/watchdog.c @@ -32,6 +32,7 @@ */ #include "dev/watchdog.h" +#include /*---------------------------------------------------------------------------*/ void @@ -57,5 +58,7 @@ watchdog_stop(void) void watchdog_reboot(void) { + // Death by watchdog. + exit(-1); } /*---------------------------------------------------------------------------*/ From 2e14df3981061cb42fb7ea3ca85e8a9f61ae964f Mon Sep 17 00:00:00 2001 From: dak664 Date: Fri, 8 Apr 2011 15:15:16 -0400 Subject: [PATCH 04/18] Options to extend mc1322x fifo to RAM buffer, or use hardware flow control with tunslip6. --- cpu/mc1322x/lib/include/uart1.h | 22 ++++- cpu/mc1322x/lib/uart1.c | 80 +++++++++++++++---- cpu/mc1322x/src/default_lowlevel.c | 23 ++++-- .../redbee-econotag/contiki-mc1322x-main.c | 2 +- tools/tunslip6.c | 18 +++-- 5 files changed, 115 insertions(+), 30 deletions(-) diff --git a/cpu/mc1322x/lib/include/uart1.h b/cpu/mc1322x/lib/include/uart1.h index d80eac65d..4e635e930 100644 --- a/cpu/mc1322x/lib/include/uart1.h +++ b/cpu/mc1322x/lib/include/uart1.h @@ -70,9 +70,29 @@ #define UART2_UCTS ((volatile uint32_t *) ( UART2_BASE + UCTS )) #define UART2_UBRCNT ((volatile uint32_t *) ( UART2_BASE + UBRCNT )) -extern volatile uint32_t u1_head, u1_tail; +/* The mc1322x has a 32 byte hardware FIFO for transmitted characters. + * Currently it is always filled from a larger RAM buffer. It would be + * possible to eliminate that overhead by filling directly from a chain + * of data buffer pointers, but printf's would be not so easy. + */ +#define UART1_TX_BUFFERSIZE 1024 +extern volatile uint32_t u1_tx_head, u1_tx_tail; void uart1_putc(char c); + +/* The mc1322x has a 32 byte hardware FIFO for received characters. + * If a larger rx buffersize is specified the FIFO will be extended into RAM. + * RAM transfers will occur on interrupt when the FIFO is nearly full. + * If a smaller buffersize is specified hardware flow control will be + * initiated at that FIFO level. + * Set to 32 for no flow control or RAM buffer. + */ +#define UART1_RX_BUFFERSIZE 128 +#if UART1_RX_BUFFERSIZE > 32 +extern volatile uint32_t u1_rx_head, u1_rx_tail; +#define uart1_can_get() ((u1_rx_head!=u1_rx_tail) || (*UART1_URXCON > 0)) +#else #define uart1_can_get() (*UART1_URXCON > 0) +#endif uint8_t uart1_getc(void); diff --git a/cpu/mc1322x/lib/uart1.c b/cpu/mc1322x/lib/uart1.c index 0d3fbd807..b3df668c7 100644 --- a/cpu/mc1322x/lib/uart1.c +++ b/cpu/mc1322x/lib/uart1.c @@ -36,43 +36,91 @@ #include #include -volatile char u1_tx_buf[1024]; -volatile uint32_t u1_head, u1_tail; +volatile char u1_tx_buf[UART1_TX_BUFFERSIZE]; +volatile uint32_t u1_tx_head, u1_tx_tail; + +#if UART1_RX_BUFFERSIZE > 32 +volatile char u1_rx_buf[UART1_RX_BUFFERSIZE-32]; +volatile uint32_t u1_rx_head, u1_rx_tail; +#endif void uart1_isr(void) { + +#if UART1_RX_BUFFERSIZE > 32 + if (*UART1_USTAT & ( 1 << 6)) { //receive interrupt + while( *UART1_URXCON != 0 ) { //flush the hardware fifo into the software buffer + uint32_t u1_rx_tail_next; + u1_rx_tail_next = u1_rx_tail+1; + if (u1_rx_tail_next >= sizeof(u1_rx_buf)) + u1_rx_tail_next = 0; + if (u1_rx_head != u1_rx_tail_next) { + u1_rx_buf[u1_rx_tail]= *UART1_UDATA; + u1_rx_tail = u1_rx_tail_next; + } + } + return; + } +#endif + while( *UART1_UTXCON != 0 ) { - if (u1_head == u1_tail) { + if (u1_tx_head == u1_tx_tail) { +#if UART1_RX_BUFFERSIZE > 32 + *UART1_UCON |= (1 << 13); /*disable tx interrupt */ +#else disable_irq(UART1); +#endif return; } - *UART1_UDATA = u1_tx_buf[u1_tail]; - u1_tail++; - if (u1_tail >= sizeof(u1_tx_buf)) - u1_tail = 0; + + *UART1_UDATA = u1_tx_buf[u1_tx_tail]; + u1_tx_tail++; + if (u1_tx_tail >= sizeof(u1_tx_buf)) + u1_tx_tail = 0; } } void uart1_putc(char c) { /* disable UART1 since */ - /* UART1 isr modifies u1_head and u1_tail */ - disable_irq(UART1); + /* UART1 isr modifies u1_tx_head and u1_tx_tail */ +#if UART1_RX_BUFFERSIZE > 32 + *UART1_UCON |= (1 << 13); /*disable tx interrupt */ +#else + disable_irq(UART1); +#endif - if( (u1_head == u1_tail) && + if( (u1_tx_head == u1_tx_tail) && (*UART1_UTXCON != 0)) { *UART1_UDATA = c; } else { - u1_tx_buf[u1_head] = c; - u1_head += 1; - if (u1_head >= sizeof(u1_tx_buf)) - u1_head = 0; - if (u1_head == u1_tail) { /* drop chars when no room */ - if (u1_head) { u1_head -=1; } else { u1_head = sizeof(u1_tx_buf); } + u1_tx_buf[u1_tx_head] = c; + u1_tx_head += 1; + if (u1_tx_head >= sizeof(u1_tx_buf)) + u1_tx_head = 0; + if (u1_tx_head == u1_tx_tail) { /* drop chars when no room */ + if (u1_tx_head) { u1_tx_head -=1; } else { u1_tx_head = sizeof(u1_tx_buf); } } + +#if UART1_RX_BUFFERSIZE > 32 + *UART1_UCON &= ~(1 << 13); /*enable tx interrupt */ +#else enable_irq(UART1); +#endif + } } uint8_t uart1_getc(void) { +#if UART1_RX_BUFFERSIZE > 32 +/* First pull from the ram buffer */ +uint8_t c=0; + if (u1_rx_head != u1_rx_tail) { + c = u1_rx_buf[u1_rx_head++]; + if (u1_rx_head >= sizeof(u1_rx_buf)) + u1_rx_head=0; + return c; + } +#endif +/* Then pull from the hardware fifo */ while(uart1_can_get() == 0) { continue; } return *UART1_UDATA; } diff --git a/cpu/mc1322x/src/default_lowlevel.c b/cpu/mc1322x/src/default_lowlevel.c index 1f603f113..27b35a889 100644 --- a/cpu/mc1322x/src/default_lowlevel.c +++ b/cpu/mc1322x/src/default_lowlevel.c @@ -47,7 +47,7 @@ void default_vreg_init(void) { void uart1_init(uint16_t inc, uint16_t mod, uint8_t samp) { - /* UART must be disabled to set the baudrate */ + /* UART must be disabled to set the baudrate */ *UART1_UCON = 0; *UART1_UBRCNT = ( inc << 16 ) | mod; @@ -63,18 +63,27 @@ void uart1_init(uint16_t inc, uint16_t mod, uint8_t samp) { /* you must enable the peripheral first BEFORE setting the function in GPIO_FUNC_SEL */ /* From the datasheet: "The peripheral function will control operation of the pad IF */ /* THE PERIPHERAL IS ENABLED. */ - *UART1_UCON = (1 << 0) | (1 << 1); /* enable receive, transmit */ + +#if UART1_RX_BUFFERSIZE > 32 + *UART1_UCON = (1 << 0) | (1 << 1) ; /* enable receive, transmit, and both interrupts */ + *UART1_URXCON = 30; /* interrupt when fifo is nearly full */ + u1_rx_head = 0; u1_rx_tail = 0; +#elif UART1_RX_BUFFERSIZE < 32 /* enable receive, transmit, flow control, disable rx interrupt */ + *UART1_UCON = (1 << 0) | (1 << 1) | (1 << 12) | (1 << 14); + *UART1_UCTS = UART1_RX_BUFFERSIZE; /* drop cts when tx buffer at trigger level */ + *GPIO_FUNC_SEL1 = ( (0x01 << (0*2)) | (0x01 << (1*2)) ); /* set GPIO17-16 to UART1 CTS and RTS */ +#else + *UART1_UCON = (1 << 0) | (1 << 1) | (1 << 14); /* enable receive, transmit, disable rx interrupt */ +#endif + if(samp == UCON_SAMP_16X) set_bit(*UART1_UCON,UCON_SAMP); *GPIO_FUNC_SEL0 = ( (0x01 << (14*2)) | (0x01 << (15*2)) ); /* set GPIO15-14 to UART (UART1 TX and RX)*/ - + /* interrupt when there are this number or more bytes free in the TX buffer*/ *UART1_UTXCON = 16; + u1_tx_head = 0; u1_tx_tail = 0; - u1_head = 0; u1_tail = 0; - - /* tx and rx interrupts are enabled in the UART by default */ - /* see status register bits 13 and 14 */ /* enable UART1 interrupts in the interrupt controller */ enable_irq(UART1); } diff --git a/platform/redbee-econotag/contiki-mc1322x-main.c b/platform/redbee-econotag/contiki-mc1322x-main.c index 268d1602a..e49282d65 100644 --- a/platform/redbee-econotag/contiki-mc1322x-main.c +++ b/platform/redbee-econotag/contiki-mc1322x-main.c @@ -48,6 +48,7 @@ #include "lib/random.h" #include "net/netstack.h" #include "net/mac/frame802154.h" +#include "lib/include/uart1.h" #if WITH_UIP6 #include "net/sicslowpan.h" @@ -490,7 +491,6 @@ main(void) cop_service(); #endif - /* TODO: replace this with a uart rx interrupt */ if(uart1_input_handler != NULL) { if(uart1_can_get()) { uart1_input_handler(uart1_getc()); diff --git a/tools/tunslip6.c b/tools/tunslip6.c index 82ab3f433..2b1c28acf 100644 --- a/tools/tunslip6.c +++ b/tools/tunslip6.c @@ -60,7 +60,7 @@ const char *netmask; int slipfd = 0; uint16_t basedelay=0,delaymsec=0; uint32_t startsec,startmsec,delaystartsec,delaystartmsec; -int timestamp = 0; +int timestamp = 0, flowcontrol=0; int ssystem(const char *fmt, ...) __attribute__((__format__ (__printf__, 1, 2))); @@ -172,7 +172,7 @@ serial_to_tun(FILE *inslip, int outfd) if(inbufptr >= sizeof(uip.inbuf)) { inbufptr = 0; if(timestamp) stamptime(); - fprintf(stderr, "*** dropping too large packet\n"); + fprintf(stderr, "*** dropping large %d byte packet\n",inbufptr); } ret = fread(&c, 1, 1, inslip); #ifdef linux @@ -459,7 +459,10 @@ stty_telos(int fd) /* Nonblocking read. */ tty.c_cc[VTIME] = 0; tty.c_cc[VMIN] = 0; - tty.c_cflag &= ~CRTSCTS; + if (flowcontrol) + tty.c_cflag |= CRTSCTS; + else + tty.c_cflag &= ~CRTSCTS; tty.c_cflag &= ~HUPCL; tty.c_cflag &= ~CLOCAL; @@ -616,12 +619,16 @@ main(int argc, char **argv) prog = argv[0]; setvbuf(stdout, NULL, _IOLBF, 0); /* Line buffered output. */ - while((c = getopt(argc, argv, "B:D:Lhs:t:v::d::a:p:T")) != -1) { + while((c = getopt(argc, argv, "B:H:D:Lhs:t:v::d::a:p:T")) != -1) { switch(c) { case 'B': baudrate = atoi(optarg); break; + case 'H': + flowcontrol=1; + break; + case 'L': timestamp=1; break; @@ -671,6 +678,7 @@ fprintf(stderr,"usage: %s [options] ipaddress\n", prog); fprintf(stderr,"example: tunslip6 -L -v2 -s ttyUSB1 aaaa::1/64\n"); fprintf(stderr,"Options are:\n"); fprintf(stderr," -B baudrate 9600,19200,38400,57600,115200 (default)\n"); +fprintf(stderr," -H Hardware CTS/RTS flow control (default disabled)\n"); fprintf(stderr," -L Log output format (adds time stamps)\n"); fprintf(stderr," -s siodev Serial device (default /dev/ttyUSB0)\n"); fprintf(stderr," -T Make tap interface (default is tun interface)\n"); @@ -696,7 +704,7 @@ exit(1); argv += (optind - 1); if(argc != 2 && argc != 3) { - err(1, "usage: %s [-B baudrate] [-L] [-s siodev] [-t tundev] [-T] [-v verbosity] [-d delay] [-a serveraddress] [-p serverport] ipaddress", prog); + err(1, "usage: %s [-B baudrate] [-H] [-L] [-s siodev] [-t tundev] [-T] [-v verbosity] [-d delay] [-a serveraddress] [-p serverport] ipaddress", prog); } ipaddr = argv[1]; From 199d51275d9756f28c052257f37269b1d0d0a8e1 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Sun, 10 Apr 2011 12:38:11 +0200 Subject: [PATCH 05/18] Removed section about (recently deleted) VC solution file. --- platform/win32/README | 4 ---- 1 file changed, 4 deletions(-) diff --git a/platform/win32/README b/platform/win32/README index ec1e30379..3ac201adc 100644 --- a/platform/win32/README +++ b/platform/win32/README @@ -21,10 +21,6 @@ extend two makefiles are necessary: - Makefile plays the role of a Contiki 2.x project Makefile - Makefile.win32 is an ordinary (yet complex) Contiki 2.x Makefile.$(TARGET) -As an alternative to building with Cygwin, gcc and the Contiki 2.x build system -it is also possible to use Microsoft Visual Studio 2008 (including the Express -Edition) by loading platform/win32/contiki.sln. - As platform/win32/Makefile.win32 includes cpu/native/Makefile.native the WinPcap library is used for network I/O. Please consult cpu/native/net/README-WPCAP for further details. From f2678ff7b48ee793bc84397521dc0e4d13fd03fd Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Sun, 10 Apr 2011 12:43:24 +0200 Subject: [PATCH 06/18] Renamed README to README.1X --- platform/win32/{README => README-1.X} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename platform/win32/{README => README-1.X} (100%) diff --git a/platform/win32/README b/platform/win32/README-1.X similarity index 100% rename from platform/win32/README rename to platform/win32/README-1.X From 7c3adef1c8e1f4b78353df6a803eb9cbf46f7f2a Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Sun, 10 Apr 2011 13:21:39 +0200 Subject: [PATCH 07/18] Added dependency handling and README.VC --- platform/win32/Makefile.win32 | 4 ++-- platform/win32/README-VC | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 platform/win32/README-VC diff --git a/platform/win32/Makefile.win32 b/platform/win32/Makefile.win32 index 560da313c..1765e9a8d 100644 --- a/platform/win32/Makefile.win32 +++ b/platform/win32/Makefile.win32 @@ -36,8 +36,7 @@ TARGET_LIBFILES = /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a CONTIKI_TARGET_DIRS = . cfs ctk loader -CONTIKI_TARGET_SOURCEFILES = contiki-main.c clock.c cfs-win32-dir.c \ - ctk-console.c +CONTIKI_TARGET_SOURCEFILES = contiki-main.c clock.c cfs-win32-dir.c ctk-console.c CONTIKI_SOURCEFILES += $(CTK) cfs-posix.c ctk-conio.c wpcap.c wpcap-drv.c \ $(CONTIKI_TARGET_SOURCEFILES) @@ -88,6 +87,7 @@ VCFLAGS = -Od -Z7 $(filter-out -Wall -g -O,$(CFLAGS)) CUSTOM_RULE_C_TO_OBJECTDIR_O = 1 $(OBJECTDIR)/%.o: %.c cl -nologo $(VCFLAGS) -c $< -Fo$@ + @makedepend $(CFLAGS) -o.o -f- $< 2> nul: | sed -e s!$(<:.c=.o)!$@! -e s!\\!/!g > $(@:.o=.d) CUSTOM_RULE_C_TO_CO = 1 %.co: %.c diff --git a/platform/win32/README-VC b/platform/win32/README-VC new file mode 100644 index 000000000..d0a5009d5 --- /dev/null +++ b/platform/win32/README-VC @@ -0,0 +1,18 @@ +The 'win32' target allows projects to be built using two different toolchains: + +1. GCC / Cygwin + +Start your build from a Cygwin Shell and set TARGET=win32 to use this toolchain. +The result will be similiar to the 'minimal-net' target. The advantage of 'win32' +over 'minimal-net' is the support for GUI applications using the Contiki Toolkit +(CTK). For this reason several projects in the /examples directory are built in +the target 'win32' by default. + +2. VC++ / GnuWin + +Start your build from a VC++ Command Prompt and set TARGET=win32 to use this +toolchain. You need however a few addional tools in your PATH: +- cp.exe / rm.exe (http://gnuwin32.sourceforge.net/packages/coreutils.htm) +- make.exe (http://gnuwin32.sourceforge.net/packages/make.htm) +- sed.exe (http://gnuwin32.sourceforge.net/packages/sed.htm) +- makedepend.exe (http://llg.cubic.org/docs/vc7.html) From b19fb0ac9e2ce1ed662b56c40e3cae924d2541b5 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Sun, 10 Apr 2011 17:08:50 +0200 Subject: [PATCH 08/18] Activate Telnet-server GUI-support only for project builds. --- platform/win32/contiki-conf.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/win32/contiki-conf.h b/platform/win32/contiki-conf.h index f13080fe4..e41deae4d 100644 --- a/platform/win32/contiki-conf.h +++ b/platform/win32/contiki-conf.h @@ -153,7 +153,9 @@ typedef unsigned short uip_stats_t; #define SHELL_GUI_CONF_YSIZE 30 +#ifdef PLATFORM_BUILD #define TELNETD_CONF_GUI 1 +#endif /* PLATFORM_BUILD */ #ifdef PLATFORM_BUILD From 91dd236c55f93eee9a474931a58fa56450043582 Mon Sep 17 00:00:00 2001 From: dogan yazar Date: Tue, 12 Apr 2011 00:09:15 +0200 Subject: [PATCH 09/18] Changes for minimal-net and bug fix for buffer handling. --- apps/rest-coap/coap-server.c | 6 +-- apps/rest-common/buffer.c | 1 + apps/rest-common/static-routing.c | 3 ++ apps/rest-common/static-routing.h | 2 + apps/rest-http/http-server.c | 4 +- examples/rest-example/rest-server-example.c | 41 ++++++++++++--------- 6 files changed, 35 insertions(+), 22 deletions(-) diff --git a/apps/rest-coap/coap-server.c b/apps/rest-coap/coap-server.c index 4b462fbb7..62ff76870 100644 --- a/apps/rest-coap/coap-server.c +++ b/apps/rest-coap/coap-server.c @@ -12,7 +12,7 @@ #include "dev/leds.h" -#if !UIP_CONF_IPV6_RPL +#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) #include "static-routing.h" #endif @@ -491,10 +491,10 @@ PROCESS_THREAD(coap_server, ev, data) PRINTF("COAP SERVER\n"); /* if static routes are used rather than RPL */ -#if !UIP_CONF_IPV6_RPL +#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) set_global_address(); configure_routing(); -#endif /*!UIP_CONF_IPV6_RPL*/ +#endif current_tid = random_rand(); diff --git a/apps/rest-common/buffer.c b/apps/rest-common/buffer.c index 3860027bd..630f21d3e 100644 --- a/apps/rest-common/buffer.c +++ b/apps/rest-common/buffer.c @@ -19,6 +19,7 @@ delete_buffer(void) { if (data_buffer) { free(data_buffer); + data_buffer = NULL; buffer_index = 0; buffer_size = 0; } diff --git a/apps/rest-common/static-routing.c b/apps/rest-common/static-routing.c index 32704dd14..91cff3719 100644 --- a/apps/rest-common/static-routing.c +++ b/apps/rest-common/static-routing.c @@ -7,6 +7,8 @@ #include "static-routing.h" +#if !defined (CONTIKI_TARGET_MINIMAL_NET) /* Any other targets will be added here (&& ! defined (OTHER))*/ + #define DEBUG 0 #if DEBUG #include @@ -66,3 +68,4 @@ void configure_routing(void) } } #endif /*!UIP_CONF_IPV6_RPL*/ +#endif /*CONTIKI_TARGET_MINIMAL_NET*/ diff --git a/apps/rest-common/static-routing.h b/apps/rest-common/static-routing.h index 591e06b81..fc255ba4f 100644 --- a/apps/rest-common/static-routing.h +++ b/apps/rest-common/static-routing.h @@ -8,6 +8,7 @@ #ifndef STATICROUTING_H_ #define STATICROUTING_H_ +#if !defined (CONTIKI_TARGET_MINIMAL_NET) #define NODE_IP(nodeid,type,ipaddr) NODE_##nodeid##_##type(ipaddr) /*desktop machine*/ @@ -56,4 +57,5 @@ do{\ void set_global_address(void); void configure_routing(void); +#endif /*CONTIKI_TARGET_MINIMAL_NET*/ #endif /* STATICROUTING_H_ */ diff --git a/apps/rest-http/http-server.c b/apps/rest-http/http-server.c index 6a361b182..4b84f8923 100644 --- a/apps/rest-http/http-server.c +++ b/apps/rest-http/http-server.c @@ -7,7 +7,7 @@ #include "buffer.h" #include "rest-util.h" -#if !UIP_CONF_IPV6_RPL +#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) #include "static-routing.h" #endif @@ -586,7 +586,7 @@ PROCESS_THREAD(http_server, ev, data) PROCESS_BEGIN(); /* if static routes are used rather than RPL */ -#if !UIP_CONF_IPV6_RPL +#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) set_global_address(); configure_routing(); #endif /*!UIP_CONF_IPV6_RPL*/ diff --git a/examples/rest-example/rest-server-example.c b/examples/rest-example/rest-server-example.c index d4d1018a2..bfc489dfa 100644 --- a/examples/rest-example/rest-server-example.c +++ b/examples/rest-example/rest-server-example.c @@ -5,10 +5,12 @@ #include "contiki-net.h" #include "rest.h" +#if defined (CONTIKI_TARGET_SKY) /* Any other targets will be added here (&& defined (OTHER))*/ #include "dev/light-sensor.h" #include "dev/battery-sensor.h" #include "dev/sht11-sensor.h" #include "dev/leds.h" +#endif /*defined (CONTIKI_TARGET_SKY)*/ #define DEBUG 1 #if DEBUG @@ -36,9 +38,24 @@ helloworld_handler(REQUEST* request, RESPONSE* response) sprintf(temp,"Hello World!\n"); rest_set_header_content_type(response, TEXT_PLAIN); - rest_set_response_payload(response, temp, strlen(temp)); + rest_set_response_payload(response, (uint8_t*)temp, strlen(temp)); } +RESOURCE(discover, METHOD_GET, ".well-known/core"); +void +discover_handler(REQUEST* request, RESPONSE* response) +{ + char temp[100]; + int index = 0; + index += sprintf(temp + index, "%s,", ";n=\"HelloWorld\""); + index += sprintf(temp + index, "%s,", ";n=\"LedControl\""); + index += sprintf(temp + index, "%s", ";n=\"Light\""); + + rest_set_response_payload(response, (uint8_t*)temp, strlen(temp)); + rest_set_header_content_type(response, APPLICATION_LINK_FORMAT); +} + +#if defined (CONTIKI_TARGET_SKY) /*A simple actuator example, depending on the color query parameter and post variable mode, corresponding led is activated or deactivated*/ RESOURCE(led, METHOD_POST | METHOD_PUT , "led"); @@ -120,20 +137,8 @@ toggle_handler(REQUEST* request, RESPONSE* response) { leds_toggle(LEDS_RED); } +#endif /*defined (CONTIKI_TARGET_SKY)*/ -RESOURCE(discover, METHOD_GET, ".well-known/core"); -void -discover_handler(REQUEST* request, RESPONSE* response) -{ - char temp[100]; - int index = 0; - index += sprintf(temp + index, "%s,", ";n=\"HelloWorld\""); - index += sprintf(temp + index, "%s,", ";n=\"LedControl\""); - index += sprintf(temp + index, "%s", ";n=\"Light\""); - - rest_set_response_payload(response, temp, strlen(temp)); - rest_set_header_content_type(response, APPLICATION_LINK_FORMAT); -} PROCESS(rest_server_example, "Rest Server Example"); AUTOSTART_PROCESSES(&rest_server_example); @@ -148,14 +153,16 @@ PROCESS_THREAD(rest_server_example, ev, data) PRINTF("HTTP Server\n"); #endif - SENSORS_ACTIVATE(light_sensor); - rest_init(); - rest_activate_resource(&resource_helloworld); +#if defined (CONTIKI_TARGET_SKY) + SENSORS_ACTIVATE(light_sensor); rest_activate_resource(&resource_led); rest_activate_resource(&resource_light); rest_activate_resource(&resource_toggle); +#endif /*defined (CONTIKI_TARGET_SKY)*/ + + rest_activate_resource(&resource_helloworld); rest_activate_resource(&resource_discover); PROCESS_END(); From 4432a2e551926936d607874621bde1efb6e5f5d4 Mon Sep 17 00:00:00 2001 From: dogan yazar Date: Tue, 12 Apr 2011 00:54:19 +0200 Subject: [PATCH 10/18] Bugfix for Post method not allowed. --- apps/rest-http/http-common.h | 7 +++---- apps/rest-http/http-server.c | 2 -- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/apps/rest-http/http-common.h b/apps/rest-http/http-common.h index 4bb346248..e70115c2b 100644 --- a/apps/rest-http/http-common.h +++ b/apps/rest-http/http-common.h @@ -50,10 +50,9 @@ extern const char* header_delimiter; /*HTTP method types*/ typedef enum { HTTP_METHOD_GET = (1 << 0), - HTTP_METHOD_HEAD = (1 << 1), - HTTP_METHOD_POST = (1 << 2), - HTTP_METHOD_PUT = (1 << 3), - HTTP_METHOD_DELETE = (1 << 4) + HTTP_METHOD_POST = (1 << 1), + HTTP_METHOD_PUT = (1 << 2), + HTTP_METHOD_DELETE = (1 << 3) } http_method_t; //DY : FIXME right now same enum names with COAP with different values. Will this work fine? diff --git a/apps/rest-http/http-server.c b/apps/rest-http/http-server.c index 4b84f8923..5c882bac9 100644 --- a/apps/rest-http/http-server.c +++ b/apps/rest-http/http-server.c @@ -235,8 +235,6 @@ is_method_handled(connection_state_t* conn_state, const char* method) /*other method types can be added here if needed*/ if(strncmp(method, http_get_string, 3) == 0) { conn_state->request.request_type = HTTP_METHOD_GET; - } else if(strncmp(method, http_head_string, 4) == 0) { - conn_state->request.request_type = HTTP_METHOD_HEAD; } else if (strncmp(method, http_post_string, 4) == 0) { conn_state->request.request_type = HTTP_METHOD_POST; } else if (strncmp(method, http_put_string, 3) == 0) { From 4181e4774e494572be5a6f8f1e2421a52239fd2c Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Tue, 12 Apr 2011 07:52:14 +0200 Subject: [PATCH 11/18] Updated to configure MAC using NETSTACK --- examples/sky-ip/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/sky-ip/Makefile b/examples/sky-ip/Makefile index 5ee10fcd8..348c563dc 100644 --- a/examples/sky-ip/Makefile +++ b/examples/sky-ip/Makefile @@ -1,9 +1,9 @@ CONTIKI_PROJECT = sky-webserver all: sky-webserver sky-telnet-server telnet-tweet -PLATFORM_BUILD=1 # This is needed to avoid the shell to include the httpd-cfs version of the websrerver +PLATFORM_BUILD=1 # This is needed to avoid the shell to include the httpd-cfs version of the webserver APPS = webserver twitter telnetd -CFLAGS = -DWITH_UIP=1 -I. #-DWITH_NULLMAC=1 -DEFINES=MAC_DRIVER=cxmac_driver,MAC_CHANNEL_CHECK_RATE=8 +CFLAGS = -DWITH_UIP=1 -I. +DEFINES=NETSTACK_CONF_RDC=cxmac_driver,NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE=8 # The webserver application normally contains a built-in file system and support # for server-side includes. From 6facc252a26cbc7d4c4423fa88ae8a3c78089553 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Tue, 12 Apr 2011 07:54:05 +0200 Subject: [PATCH 12/18] Updated to latest collect-neighbor API --- examples/sky-ip/ajax-cgi.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/examples/sky-ip/ajax-cgi.c b/examples/sky-ip/ajax-cgi.c index 5a11b616e..a1e32381f 100644 --- a/examples/sky-ip/ajax-cgi.c +++ b/examples/sky-ip/ajax-cgi.c @@ -54,6 +54,7 @@ #include "lib/petsciiconv.h" static struct httpd_cgi_call *calls = NULL; +static struct collect_neighbor_list neighbor_list; /*---------------------------------------------------------------------------*/ static @@ -168,7 +169,7 @@ static unsigned short make_neighbor(void *arg) { struct httpd_state *s = (struct httpd_state *)arg; - struct collect_neighbor *n = collect_neighbor_get(s->u.count); + struct collect_neighbor *n = collect_neighbor_list_get(&neighbor_list, s->u.count); if(n == NULL) { return 0; @@ -188,12 +189,12 @@ PT_THREAD(neighborscall(struct httpd_state *s, char *ptr)) announcement_listen(1); - /* printf("neighbor_num %d\n", neighbor_num());*/ + /* printf("neighbor_num %d\n", collect_neighbor_list_num(&neighbor_list)); */ - for(s->u.count = 0; s->u.count < collect_neighbor_num(); s->u.count++) { - /* printf("count %d\n", s->u.count);*/ - if(collect_neighbor_get(s->u.count) != NULL) { - /* printf("!= NULL\n");*/ + for(s->u.count = 0; s->u.count < collect_neighbor_list_num(&neighbor_list); s->u.count++) { + /* printf("count %d\n", s->u.count); */ + if(collect_neighbor_list_get(&neighbor_list, s->u.count) != NULL) { + /* printf("!= NULL\n"); */ PSOCK_GENERATOR_SEND(&s->sout, make_neighbor, s); } } @@ -208,14 +209,14 @@ received_announcement(struct announcement *a, const rimeaddr_t *from, { struct collect_neighbor *n; - /* printf("adv_received %d.%d\n", from->u8[0], from->u8[1]);*/ + /* printf("adv_received %d.%d\n", from->u8[0], from->u8[1]); */ - n = collect_neighbor_find(from); + n = collect_neighbor_list_find(&neighbor_list, from); if(n == NULL) { - collect_neighbor_add(from, value, 1); + collect_neighbor_list_add(&neighbor_list, from, value); } else { - collect_neighbor_update(n, value); + collect_neighbor_update_rtmetric(n, value); } } @@ -241,8 +242,11 @@ httpd_cgi_init(void) announcement_register(&announcement, 31, received_announcement); + announcement_set_value(&announcement, 0); announcement_listen(2); + collect_neighbor_list_new(&neighbor_list); + collect_neighbor_init(); /* neighbor_discovery_open(&conn, 31, CLOCK_SECOND * 4, CLOCK_SECOND * 20, From 61fa812351040ba7c1b12db793c6752062304136 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Tue, 12 Apr 2011 08:15:29 +0200 Subject: [PATCH 13/18] Added missing separators in Javascript. Fixed sensors web page to use the right Javascript function to reload sensor data. --- examples/sky-ip/httpd-fs/sensors.shtml | 6 +- examples/sky-ip/httpd-fsdata.c | 434 ++++++++++++------------- examples/sky-ip/sensors-script.js | 18 +- 3 files changed, 226 insertions(+), 232 deletions(-) diff --git a/examples/sky-ip/httpd-fs/sensors.shtml b/examples/sky-ip/httpd-fs/sensors.shtml index fb04e3d12..aaab099cd 100644 --- a/examples/sky-ip/httpd-fs/sensors.shtml +++ b/examples/sky-ip/httpd-fs/sensors.shtml @@ -1,11 +1,11 @@ %!: /header.html

Node %! nodeid

-Reload +Reload

Environment

@@ -22,5 +22,3 @@ var start;i=new Image(50,60)i.src="spin.gif"function load(){var img=document.get

0
%!: /footer.html - - diff --git a/examples/sky-ip/httpd-fsdata.c b/examples/sky-ip/httpd-fsdata.c index 7801efb8e..fbeaea5c8 100644 --- a/examples/sky-ip/httpd-fsdata.c +++ b/examples/sky-ip/httpd-fsdata.c @@ -1,4 +1,4 @@ -/*********Generated by contiki/tools/makefsdata on 2010-02-03*********/ +/*********Generated by contiki/tools/makefsdata on 2011-04-11*********/ const char data_sensordata_shtml[30] = { @@ -7,7 +7,7 @@ const char data_sensordata_shtml[30] = { 0x25, 0x21, 0x20, 0x73, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x73, 0x0a, 0x00}; -const char data_sensors_shtml[2264] = { +const char data_sensors_shtml[2221] = { /* /sensors.shtml */ 0x2f, 0x73, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x00, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, @@ -15,226 +15,222 @@ const char data_sensors_shtml[2264] = { 0x72, 0x69, 0x70, 0x74, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x6a, 0x61, 0x76, 0x61, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x22, 0x3e, 0x0a, 0x76, - 0x61, 0x72, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x3b, 0x69, - 0x3d, 0x6e, 0x65, 0x77, 0x20, 0x49, 0x6d, 0x61, 0x67, 0x65, - 0x28, 0x35, 0x30, 0x2c, 0x36, 0x30, 0x29, 0x69, 0x2e, 0x73, - 0x72, 0x63, 0x3d, 0x22, 0x73, 0x70, 0x69, 0x6e, 0x2e, 0x67, - 0x69, 0x66, 0x22, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x28, 0x29, 0x7b, 0x76, - 0x61, 0x72, 0x20, 0x69, 0x6d, 0x67, 0x3d, 0x64, 0x6f, 0x63, - 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x67, 0x65, 0x74, 0x45, - 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x49, 0x64, - 0x28, 0x22, 0x73, 0x70, 0x69, 0x6e, 0x22, 0x29, 0x3b, 0x69, - 0x6d, 0x67, 0x2e, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x48, 0x54, - 0x4d, 0x4c, 0x3d, 0x27, 0x26, 0x6e, 0x62, 0x73, 0x70, 0x3b, - 0x27, 0x3b, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x61, 0x74, 0x61, - 0x28, 0x29, 0x7d, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x61, 0x74, 0x61, - 0x28, 0x29, 0x7b, 0x76, 0x61, 0x72, 0x20, 0x72, 0x3b, 0x74, - 0x72, 0x79, 0x7b, 0x72, 0x3d, 0x6e, 0x65, 0x77, 0x20, 0x58, - 0x4d, 0x4c, 0x48, 0x74, 0x74, 0x70, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x28, 0x29, 0x7d, 0x63, 0x61, 0x74, 0x63, - 0x68, 0x28, 0x65, 0x29, 0x7b, 0x74, 0x72, 0x79, 0x7b, 0x72, - 0x3d, 0x6e, 0x65, 0x77, 0x20, 0x41, 0x63, 0x74, 0x69, 0x76, - 0x65, 0x58, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x28, 0x22, - 0x4d, 0x73, 0x78, 0x6d, 0x6c, 0x32, 0x2e, 0x58, 0x4d, 0x4c, - 0x48, 0x54, 0x54, 0x50, 0x22, 0x29, 0x7d, 0x63, 0x61, 0x74, - 0x63, 0x68, 0x28, 0x65, 0x29, 0x7b, 0x74, 0x72, 0x79, 0x7b, - 0x72, 0x3d, 0x6e, 0x65, 0x77, 0x20, 0x41, 0x63, 0x74, 0x69, - 0x76, 0x65, 0x58, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x28, - 0x22, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, - 0x2e, 0x58, 0x4d, 0x4c, 0x48, 0x54, 0x54, 0x50, 0x22, 0x29, - 0x7d, 0x63, 0x61, 0x74, 0x63, 0x68, 0x28, 0x65, 0x29, 0x7b, - 0x61, 0x6c, 0x65, 0x72, 0x74, 0x28, 0x22, 0x59, 0x6f, 0x75, - 0x72, 0x20, 0x62, 0x72, 0x6f, 0x77, 0x73, 0x65, 0x72, 0x20, - 0x64, 0x6f, 0x65, 0x73, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x73, - 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x20, 0x41, 0x4a, 0x41, - 0x58, 0x21, 0x22, 0x29, 0x3b, 0x72, 0x65, 0x74, 0x75, 0x72, - 0x6e, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x7d, 0x7d, 0x7d, - 0x72, 0x2e, 0x6f, 0x6e, 0x72, 0x65, 0x61, 0x64, 0x79, 0x73, - 0x74, 0x61, 0x74, 0x65, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, - 0x3d, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, - 0x29, 0x7b, 0x69, 0x66, 0x28, 0x72, 0x2e, 0x72, 0x65, 0x61, - 0x64, 0x79, 0x53, 0x74, 0x61, 0x74, 0x65, 0x3d, 0x3d, 0x31, + 0x61, 0x72, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x2c, 0x64, + 0x3d, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x3b, + 0x69, 0x3d, 0x6e, 0x65, 0x77, 0x20, 0x49, 0x6d, 0x61, 0x67, + 0x65, 0x28, 0x35, 0x30, 0x2c, 0x36, 0x30, 0x29, 0x3b, 0x69, + 0x2e, 0x73, 0x72, 0x63, 0x3d, 0x22, 0x73, 0x70, 0x69, 0x6e, + 0x2e, 0x67, 0x69, 0x66, 0x22, 0x3b, 0x66, 0x75, 0x6e, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x28, 0x29, 0x7b, 0x76, 0x61, 0x72, 0x20, 0x69, 0x6d, 0x67, 0x3d, - 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x67, - 0x65, 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, - 0x79, 0x49, 0x64, 0x28, 0x22, 0x73, 0x70, 0x69, 0x6e, 0x22, - 0x29, 0x3b, 0x69, 0x6d, 0x67, 0x2e, 0x69, 0x6e, 0x6e, 0x65, - 0x72, 0x48, 0x54, 0x4d, 0x4c, 0x3d, 0x27, 0x3c, 0x69, 0x6d, - 0x67, 0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, 0x73, 0x70, 0x69, - 0x6e, 0x2e, 0x67, 0x69, 0x66, 0x22, 0x3e, 0x27, 0x7d, 0x69, - 0x66, 0x28, 0x72, 0x2e, 0x72, 0x65, 0x61, 0x64, 0x79, 0x53, - 0x74, 0x61, 0x74, 0x65, 0x3d, 0x3d, 0x34, 0x29, 0x7b, 0x76, - 0x61, 0x72, 0x20, 0x69, 0x6d, 0x67, 0x3d, 0x64, 0x6f, 0x63, - 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x67, 0x65, 0x74, 0x45, - 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x49, 0x64, - 0x28, 0x22, 0x73, 0x70, 0x69, 0x6e, 0x22, 0x29, 0x3b, 0x69, - 0x6d, 0x67, 0x2e, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x48, 0x54, - 0x4d, 0x4c, 0x3d, 0x27, 0x74, 0x6f, 0x6f, 0x6b, 0x20, 0x27, - 0x2b, 0x28, 0x28, 0x6e, 0x65, 0x77, 0x20, 0x44, 0x61, 0x74, - 0x65, 0x28, 0x29, 0x29, 0x2e, 0x67, 0x65, 0x74, 0x54, 0x69, - 0x6d, 0x65, 0x28, 0x29, 0x2d, 0x73, 0x74, 0x61, 0x72, 0x74, - 0x2e, 0x67, 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x28, 0x29, - 0x29, 0x2f, 0x31, 0x30, 0x30, 0x30, 0x2b, 0x27, 0x20, 0x73, - 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x27, 0x3b, 0x65, 0x76, - 0x61, 0x6c, 0x28, 0x72, 0x2e, 0x72, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x54, 0x65, 0x78, 0x74, 0x29, 0x7d, 0x7d, - 0x73, 0x74, 0x61, 0x72, 0x74, 0x3d, 0x6e, 0x65, 0x77, 0x20, - 0x44, 0x61, 0x74, 0x65, 0x28, 0x29, 0x3b, 0x72, 0x2e, 0x6f, - 0x70, 0x65, 0x6e, 0x28, 0x22, 0x47, 0x45, 0x54, 0x22, 0x2c, - 0x22, 0x2f, 0x73, 0x65, 0x6e, 0x73, 0x6f, 0x72, 0x64, 0x61, - 0x74, 0x61, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x2c, - 0x74, 0x72, 0x75, 0x65, 0x29, 0x3b, 0x72, 0x2e, 0x73, 0x65, - 0x6e, 0x64, 0x28, 0x6e, 0x75, 0x6c, 0x6c, 0x29, 0x7d, 0x66, - 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x65, 0x28, - 0x65, 0x6c, 0x29, 0x7b, 0x64, 0x3d, 0x64, 0x6f, 0x63, 0x75, - 0x6d, 0x65, 0x6e, 0x74, 0x3b, 0x69, 0x66, 0x28, 0x64, 0x2e, - 0x67, 0x65, 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, - 0x42, 0x79, 0x49, 0x64, 0x29, 0x7b, 0x72, 0x65, 0x74, 0x75, - 0x72, 0x6e, 0x20, 0x64, 0x2e, 0x67, 0x65, 0x74, 0x45, 0x6c, - 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x49, 0x64, 0x28, - 0x65, 0x6c, 0x29, 0x7d, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x69, - 0x66, 0x28, 0x64, 0x2e, 0x61, 0x6c, 0x6c, 0x29, 0x7b, 0x72, - 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x64, 0x2e, 0x61, 0x6c, - 0x6c, 0x5b, 0x65, 0x6c, 0x5d, 0x7d, 0x7d, 0x66, 0x75, 0x6e, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x73, 0x28, 0x65, 0x6c, - 0x2c, 0x6e, 0x2c, 0x6d, 0x61, 0x78, 0x2c, 0x74, 0x65, 0x78, - 0x74, 0x29, 0x7b, 0x65, 0x28, 0x65, 0x6c, 0x29, 0x2e, 0x69, + 0x64, 0x2e, 0x67, 0x65, 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, + 0x6e, 0x74, 0x42, 0x79, 0x49, 0x64, 0x28, 0x22, 0x73, 0x70, + 0x69, 0x6e, 0x22, 0x29, 0x3b, 0x69, 0x6d, 0x67, 0x2e, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x48, 0x54, 0x4d, 0x4c, 0x3d, 0x27, - 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, - 0x74, 0x68, 0x3d, 0x35, 0x30, 0x34, 0x20, 0x62, 0x6f, 0x72, - 0x64, 0x65, 0x72, 0x3d, 0x30, 0x20, 0x63, 0x65, 0x6c, 0x6c, - 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3d, 0x31, 0x20, - 0x63, 0x65, 0x6c, 0x6c, 0x73, 0x70, 0x61, 0x63, 0x69, 0x6e, - 0x67, 0x3d, 0x30, 0x3e, 0x27, 0x2b, 0x27, 0x3c, 0x74, 0x72, - 0x3e, 0x3c, 0x74, 0x64, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, - 0x3d, 0x32, 0x30, 0x30, 0x3e, 0x27, 0x2b, 0x74, 0x65, 0x78, - 0x74, 0x2b, 0x27, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x27, 0x2b, - 0x27, 0x3c, 0x74, 0x64, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, - 0x3d, 0x27, 0x2b, 0x28, 0x33, 0x30, 0x30, 0x2a, 0x6e, 0x2f, - 0x6d, 0x61, 0x78, 0x29, 0x2b, 0x27, 0x20, 0x62, 0x67, 0x63, - 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x67, 0x72, 0x61, 0x79, - 0x22, 0x3e, 0x26, 0x6e, 0x62, 0x73, 0x70, 0x3b, 0x3c, 0x2f, - 0x74, 0x64, 0x3e, 0x27, 0x2b, 0x27, 0x3c, 0x74, 0x64, 0x20, - 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x27, 0x2b, 0x28, 0x33, - 0x30, 0x30, 0x2d, 0x33, 0x30, 0x30, 0x2a, 0x6e, 0x2f, 0x6d, - 0x61, 0x78, 0x29, 0x2b, 0x27, 0x20, 0x62, 0x67, 0x63, 0x6f, - 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x6c, 0x69, 0x67, 0x68, 0x74, - 0x67, 0x72, 0x61, 0x79, 0x22, 0x3e, 0x26, 0x6e, 0x62, 0x73, - 0x70, 0x3b, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x27, 0x2b, 0x27, - 0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0x27, 0x7d, - 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x64, - 0x63, 0x28, 0x6e, 0x2c, 0x64, 0x29, 0x7b, 0x72, 0x65, 0x74, - 0x75, 0x72, 0x6e, 0x20, 0x6e, 0x2e, 0x74, 0x6f, 0x46, 0x69, - 0x78, 0x65, 0x64, 0x28, 0x64, 0x29, 0x7d, 0x66, 0x75, 0x6e, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x28, 0x6d, 0x29, - 0x7b, 0x6e, 0x3d, 0x64, 0x63, 0x28, 0x2d, 0x33, 0x39, 0x2e, - 0x36, 0x2b, 0x30, 0x2e, 0x30, 0x31, 0x2a, 0x6d, 0x2c, 0x31, - 0x29, 0x3b, 0x73, 0x28, 0x27, 0x74, 0x65, 0x6d, 0x70, 0x27, - 0x2c, 0x6e, 0x2c, 0x34, 0x30, 0x2c, 0x27, 0x54, 0x65, 0x6d, - 0x70, 0x65, 0x72, 0x61, 0x74, 0x75, 0x72, 0x65, 0x20, 0x27, - 0x2b, 0x6e, 0x2b, 0x27, 0x20, 0x26, 0x64, 0x65, 0x67, 0x3b, - 0x43, 0x27, 0x29, 0x7d, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x20, 0x68, 0x28, 0x6d, 0x29, 0x7b, 0x6e, 0x3d, - 0x64, 0x63, 0x28, 0x2d, 0x34, 0x2b, 0x30, 0x2e, 0x30, 0x34, - 0x30, 0x35, 0x2a, 0x6d, 0x2d, 0x32, 0x2e, 0x38, 0x65, 0x2d, - 0x36, 0x2a, 0x28, 0x6d, 0x2a, 0x6d, 0x29, 0x2c, 0x32, 0x29, - 0x3b, 0x73, 0x28, 0x27, 0x68, 0x75, 0x6d, 0x27, 0x2c, 0x6e, - 0x2c, 0x31, 0x30, 0x30, 0x2c, 0x27, 0x48, 0x75, 0x6d, 0x69, - 0x64, 0x69, 0x74, 0x79, 0x20, 0x27, 0x2b, 0x6e, 0x2b, 0x27, - 0x25, 0x27, 0x29, 0x7d, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x20, 0x6c, 0x31, 0x28, 0x6d, 0x29, 0x7b, 0x6e, - 0x3d, 0x64, 0x63, 0x28, 0x2e, 0x37, 0x36, 0x32, 0x39, 0x33, - 0x39, 0x34, 0x33, 0x37, 0x35, 0x2a, 0x6d, 0x2c, 0x30, 0x29, - 0x3b, 0x73, 0x28, 0x27, 0x6c, 0x31, 0x27, 0x2c, 0x6e, 0x2c, - 0x32, 0x30, 0x30, 0x2c, 0x27, 0x4c, 0x69, 0x67, 0x68, 0x74, - 0x20, 0x31, 0x20, 0x27, 0x2b, 0x6e, 0x29, 0x7d, 0x66, 0x75, - 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x32, 0x28, - 0x6d, 0x29, 0x7b, 0x6e, 0x3d, 0x64, 0x63, 0x28, 0x2e, 0x34, - 0x36, 0x39, 0x33, 0x36, 0x30, 0x33, 0x2a, 0x6d, 0x2c, 0x30, - 0x29, 0x3b, 0x73, 0x28, 0x27, 0x6c, 0x32, 0x27, 0x2c, 0x6e, - 0x2c, 0x32, 0x30, 0x30, 0x2c, 0x27, 0x4c, 0x69, 0x67, 0x68, - 0x74, 0x20, 0x32, 0x20, 0x27, 0x2b, 0x6e, 0x29, 0x7d, 0x66, - 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x72, 0x73, - 0x28, 0x6d, 0x29, 0x7b, 0x6e, 0x3d, 0x6d, 0x2b, 0x34, 0x35, - 0x3b, 0x73, 0x28, 0x27, 0x72, 0x73, 0x27, 0x2c, 0x6e, 0x2c, - 0x31, 0x30, 0x30, 0x2c, 0x27, 0x52, 0x53, 0x53, 0x49, 0x20, - 0x27, 0x2b, 0x6e, 0x29, 0x7d, 0x66, 0x75, 0x6e, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x20, 0x70, 0x28, 0x63, 0x2c, 0x6c, 0x2c, - 0x74, 0x2c, 0x72, 0x29, 0x7b, 0x74, 0x6d, 0x3d, 0x63, 0x2b, - 0x6c, 0x3b, 0x63, 0x70, 0x3d, 0x63, 0x2a, 0x31, 0x2e, 0x38, - 0x2f, 0x74, 0x6d, 0x3b, 0x6c, 0x70, 0x3d, 0x6c, 0x2a, 0x30, - 0x2e, 0x30, 0x35, 0x34, 0x35, 0x2f, 0x74, 0x6d, 0x3b, 0x6c, - 0x74, 0x3d, 0x74, 0x2a, 0x31, 0x37, 0x2e, 0x37, 0x2f, 0x74, - 0x6d, 0x3b, 0x6c, 0x72, 0x3d, 0x72, 0x2a, 0x32, 0x30, 0x2f, - 0x74, 0x6d, 0x3b, 0x6e, 0x3d, 0x63, 0x70, 0x2b, 0x6c, 0x70, - 0x2b, 0x6c, 0x74, 0x2b, 0x6c, 0x72, 0x3b, 0x73, 0x28, 0x27, - 0x70, 0x27, 0x2c, 0x6e, 0x2c, 0x33, 0x30, 0x2c, 0x27, 0x50, - 0x6f, 0x77, 0x65, 0x72, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x75, - 0x6d, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x27, 0x2b, 0x64, - 0x63, 0x28, 0x6e, 0x2c, 0x32, 0x29, 0x2b, 0x27, 0x20, 0x6d, - 0x57, 0x27, 0x29, 0x3b, 0x73, 0x28, 0x27, 0x70, 0x63, 0x27, - 0x2c, 0x63, 0x70, 0x2c, 0x33, 0x30, 0x2c, 0x27, 0x43, 0x50, - 0x55, 0x20, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x20, 0x27, 0x2b, - 0x64, 0x63, 0x28, 0x63, 0x70, 0x2c, 0x32, 0x29, 0x2b, 0x27, - 0x20, 0x6d, 0x57, 0x27, 0x29, 0x3b, 0x73, 0x28, 0x27, 0x70, - 0x6c, 0x27, 0x2c, 0x6c, 0x70, 0x2c, 0x33, 0x30, 0x2c, 0x27, - 0x4c, 0x50, 0x4d, 0x20, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x20, - 0x27, 0x2b, 0x64, 0x63, 0x28, 0x6c, 0x70, 0x2c, 0x32, 0x29, - 0x2b, 0x27, 0x20, 0x6d, 0x57, 0x27, 0x29, 0x3b, 0x73, 0x28, - 0x27, 0x70, 0x72, 0x27, 0x2c, 0x6c, 0x72, 0x2c, 0x33, 0x30, - 0x2c, 0x27, 0x52, 0x61, 0x64, 0x69, 0x6f, 0x20, 0x52, 0x58, - 0x20, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x20, 0x27, 0x2b, 0x64, - 0x63, 0x28, 0x6c, 0x72, 0x2c, 0x32, 0x29, 0x2b, 0x27, 0x20, - 0x6d, 0x57, 0x27, 0x29, 0x3b, 0x73, 0x28, 0x27, 0x70, 0x74, - 0x27, 0x2c, 0x6c, 0x74, 0x2c, 0x33, 0x30, 0x2c, 0x27, 0x52, - 0x61, 0x64, 0x69, 0x6f, 0x20, 0x54, 0x58, 0x20, 0x70, 0x6f, - 0x77, 0x65, 0x72, 0x20, 0x27, 0x2b, 0x64, 0x63, 0x28, 0x6c, - 0x74, 0x2c, 0x32, 0x29, 0x2b, 0x27, 0x20, 0x6d, 0x57, 0x27, + 0x26, 0x6e, 0x62, 0x73, 0x70, 0x3b, 0x27, 0x3b, 0x6c, 0x6f, + 0x61, 0x64, 0x44, 0x61, 0x74, 0x61, 0x28, 0x29, 0x7d, 0x66, + 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x6f, + 0x61, 0x64, 0x44, 0x61, 0x74, 0x61, 0x28, 0x29, 0x7b, 0x76, + 0x61, 0x72, 0x20, 0x72, 0x3b, 0x74, 0x72, 0x79, 0x7b, 0x72, + 0x3d, 0x6e, 0x65, 0x77, 0x20, 0x58, 0x4d, 0x4c, 0x48, 0x74, + 0x74, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x28, + 0x29, 0x7d, 0x63, 0x61, 0x74, 0x63, 0x68, 0x28, 0x65, 0x29, + 0x7b, 0x74, 0x72, 0x79, 0x7b, 0x72, 0x3d, 0x6e, 0x65, 0x77, + 0x20, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x58, 0x4f, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x28, 0x22, 0x4d, 0x73, 0x78, 0x6d, + 0x6c, 0x32, 0x2e, 0x58, 0x4d, 0x4c, 0x48, 0x54, 0x54, 0x50, + 0x22, 0x29, 0x7d, 0x63, 0x61, 0x74, 0x63, 0x68, 0x28, 0x65, + 0x29, 0x7b, 0x74, 0x72, 0x79, 0x7b, 0x72, 0x3d, 0x6e, 0x65, + 0x77, 0x20, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x58, 0x4f, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x28, 0x22, 0x4d, 0x69, 0x63, + 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x2e, 0x58, 0x4d, 0x4c, + 0x48, 0x54, 0x54, 0x50, 0x22, 0x29, 0x7d, 0x63, 0x61, 0x74, + 0x63, 0x68, 0x28, 0x65, 0x29, 0x7b, 0x61, 0x6c, 0x65, 0x72, + 0x74, 0x28, 0x22, 0x59, 0x6f, 0x75, 0x72, 0x20, 0x62, 0x72, + 0x6f, 0x77, 0x73, 0x65, 0x72, 0x20, 0x64, 0x6f, 0x65, 0x73, + 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x73, 0x75, 0x70, 0x70, 0x6f, + 0x72, 0x74, 0x20, 0x41, 0x4a, 0x41, 0x58, 0x21, 0x22, 0x29, + 0x3b, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x61, + 0x6c, 0x73, 0x65, 0x7d, 0x7d, 0x7d, 0x72, 0x2e, 0x6f, 0x6e, + 0x72, 0x65, 0x61, 0x64, 0x79, 0x73, 0x74, 0x61, 0x74, 0x65, + 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x3d, 0x66, 0x75, 0x6e, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x29, 0x7b, 0x69, 0x66, + 0x28, 0x72, 0x2e, 0x72, 0x65, 0x61, 0x64, 0x79, 0x53, 0x74, + 0x61, 0x74, 0x65, 0x3d, 0x3d, 0x31, 0x29, 0x7b, 0x76, 0x61, + 0x72, 0x20, 0x69, 0x6d, 0x67, 0x3d, 0x64, 0x2e, 0x67, 0x65, + 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, + 0x49, 0x64, 0x28, 0x22, 0x73, 0x70, 0x69, 0x6e, 0x22, 0x29, + 0x3b, 0x69, 0x6d, 0x67, 0x2e, 0x69, 0x6e, 0x6e, 0x65, 0x72, + 0x48, 0x54, 0x4d, 0x4c, 0x3d, 0x27, 0x3c, 0x69, 0x6d, 0x67, + 0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, 0x73, 0x70, 0x69, 0x6e, + 0x2e, 0x67, 0x69, 0x66, 0x22, 0x3e, 0x27, 0x7d, 0x69, 0x66, + 0x28, 0x72, 0x2e, 0x72, 0x65, 0x61, 0x64, 0x79, 0x53, 0x74, + 0x61, 0x74, 0x65, 0x3d, 0x3d, 0x34, 0x29, 0x7b, 0x76, 0x61, + 0x72, 0x20, 0x69, 0x6d, 0x67, 0x3d, 0x64, 0x2e, 0x67, 0x65, + 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, + 0x49, 0x64, 0x28, 0x22, 0x73, 0x70, 0x69, 0x6e, 0x22, 0x29, + 0x3b, 0x69, 0x6d, 0x67, 0x2e, 0x69, 0x6e, 0x6e, 0x65, 0x72, + 0x48, 0x54, 0x4d, 0x4c, 0x3d, 0x27, 0x74, 0x6f, 0x6f, 0x6b, + 0x20, 0x27, 0x2b, 0x28, 0x28, 0x6e, 0x65, 0x77, 0x20, 0x44, + 0x61, 0x74, 0x65, 0x28, 0x29, 0x29, 0x2e, 0x67, 0x65, 0x74, + 0x54, 0x69, 0x6d, 0x65, 0x28, 0x29, 0x2d, 0x73, 0x74, 0x61, + 0x72, 0x74, 0x2e, 0x67, 0x65, 0x74, 0x54, 0x69, 0x6d, 0x65, + 0x28, 0x29, 0x29, 0x2f, 0x31, 0x30, 0x30, 0x30, 0x2b, 0x27, + 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x27, 0x3b, + 0x65, 0x76, 0x61, 0x6c, 0x28, 0x72, 0x2e, 0x72, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x65, 0x78, 0x74, 0x29, + 0x7d, 0x7d, 0x3b, 0x73, 0x74, 0x61, 0x72, 0x74, 0x3d, 0x6e, + 0x65, 0x77, 0x20, 0x44, 0x61, 0x74, 0x65, 0x28, 0x29, 0x3b, + 0x72, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x28, 0x22, 0x47, 0x45, + 0x54, 0x22, 0x2c, 0x22, 0x2f, 0x73, 0x65, 0x6e, 0x73, 0x6f, + 0x72, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x73, 0x68, 0x74, 0x6d, + 0x6c, 0x22, 0x2c, 0x74, 0x72, 0x75, 0x65, 0x29, 0x3b, 0x72, + 0x2e, 0x73, 0x65, 0x6e, 0x64, 0x28, 0x6e, 0x75, 0x6c, 0x6c, 0x29, 0x7d, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x20, 0x69, 0x28, 0x6e, 0x29, 0x7b, 0x65, 0x28, 0x27, 0x69, - 0x27, 0x29, 0x2e, 0x69, 0x6e, 0x6e, 0x65, 0x72, 0x48, 0x54, - 0x4d, 0x4c, 0x3d, 0x6e, 0x7d, 0x0a, 0x3c, 0x2f, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x3e, 0x0a, 0x3c, 0x68, 0x31, 0x3e, - 0x4e, 0x6f, 0x64, 0x65, 0x0a, 0x25, 0x21, 0x20, 0x6e, 0x6f, - 0x64, 0x65, 0x69, 0x64, 0x0a, 0x3c, 0x2f, 0x68, 0x31, 0x3e, - 0x0a, 0x3c, 0x61, 0x20, 0x6f, 0x6e, 0x63, 0x6c, 0x69, 0x63, - 0x6b, 0x3d, 0x22, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x65, 0x6e, - 0x73, 0x6f, 0x72, 0x64, 0x61, 0x74, 0x61, 0x28, 0x29, 0x3b, - 0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x23, 0x22, - 0x3e, 0x52, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x3c, 0x2f, 0x61, - 0x3e, 0x0a, 0x3c, 0x73, 0x70, 0x61, 0x6e, 0x20, 0x69, 0x64, - 0x3d, 0x22, 0x73, 0x70, 0x69, 0x6e, 0x22, 0x3e, 0x20, 0x3c, - 0x2f, 0x73, 0x70, 0x61, 0x6e, 0x3e, 0x0a, 0x3c, 0x68, 0x32, - 0x3e, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, - 0x6e, 0x74, 0x3c, 0x2f, 0x68, 0x32, 0x3e, 0x0a, 0x3c, 0x64, - 0x69, 0x76, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x74, 0x65, 0x6d, - 0x70, 0x22, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x0a, - 0x3c, 0x64, 0x69, 0x76, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x68, - 0x75, 0x6d, 0x22, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, - 0x0a, 0x3c, 0x68, 0x32, 0x3e, 0x4c, 0x69, 0x67, 0x68, 0x74, - 0x3c, 0x2f, 0x68, 0x32, 0x3e, 0x0a, 0x3c, 0x64, 0x69, 0x76, - 0x20, 0x69, 0x64, 0x3d, 0x22, 0x6c, 0x31, 0x22, 0x3e, 0x3c, - 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x0a, 0x3c, 0x64, 0x69, 0x76, - 0x20, 0x69, 0x64, 0x3d, 0x22, 0x6c, 0x32, 0x22, 0x3e, 0x3c, - 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x0a, 0x3c, 0x68, 0x32, 0x3e, - 0x50, 0x6f, 0x77, 0x65, 0x72, 0x3c, 0x2f, 0x68, 0x32, 0x3e, - 0x0a, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x69, 0x64, 0x3d, 0x22, - 0x70, 0x22, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x0a, + 0x20, 0x65, 0x28, 0x65, 0x6c, 0x29, 0x7b, 0x69, 0x66, 0x28, + 0x64, 0x2e, 0x67, 0x65, 0x74, 0x45, 0x6c, 0x65, 0x6d, 0x65, + 0x6e, 0x74, 0x42, 0x79, 0x49, 0x64, 0x29, 0x7b, 0x72, 0x65, + 0x74, 0x75, 0x72, 0x6e, 0x20, 0x64, 0x2e, 0x67, 0x65, 0x74, + 0x45, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x79, 0x49, + 0x64, 0x28, 0x65, 0x6c, 0x29, 0x7d, 0x69, 0x66, 0x28, 0x64, + 0x2e, 0x61, 0x6c, 0x6c, 0x29, 0x7b, 0x72, 0x65, 0x74, 0x75, + 0x72, 0x6e, 0x20, 0x64, 0x2e, 0x61, 0x6c, 0x6c, 0x5b, 0x65, + 0x6c, 0x5d, 0x7d, 0x7d, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x20, 0x73, 0x28, 0x65, 0x6c, 0x2c, 0x6e, 0x2c, + 0x6d, 0x61, 0x78, 0x2c, 0x74, 0x65, 0x78, 0x74, 0x29, 0x7b, + 0x65, 0x28, 0x65, 0x6c, 0x29, 0x2e, 0x69, 0x6e, 0x6e, 0x65, + 0x72, 0x48, 0x54, 0x4d, 0x4c, 0x3d, 0x27, 0x3c, 0x74, 0x61, + 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, + 0x35, 0x30, 0x34, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, + 0x3d, 0x30, 0x20, 0x63, 0x65, 0x6c, 0x6c, 0x70, 0x61, 0x64, + 0x64, 0x69, 0x6e, 0x67, 0x3d, 0x31, 0x20, 0x63, 0x65, 0x6c, + 0x6c, 0x73, 0x70, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x3d, 0x30, + 0x3e, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x20, 0x77, + 0x69, 0x64, 0x74, 0x68, 0x3d, 0x32, 0x30, 0x30, 0x3e, 0x27, + 0x2b, 0x74, 0x65, 0x78, 0x74, 0x2b, 0x27, 0x3c, 0x2f, 0x74, + 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x20, 0x77, 0x69, 0x64, 0x74, + 0x68, 0x3d, 0x27, 0x2b, 0x28, 0x33, 0x30, 0x30, 0x2a, 0x6e, + 0x2f, 0x6d, 0x61, 0x78, 0x29, 0x2b, 0x27, 0x20, 0x62, 0x67, + 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x67, 0x72, 0x61, + 0x79, 0x22, 0x3e, 0x26, 0x6e, 0x62, 0x73, 0x70, 0x3b, 0x3c, + 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x20, 0x77, 0x69, + 0x64, 0x74, 0x68, 0x3d, 0x27, 0x2b, 0x28, 0x33, 0x30, 0x30, + 0x2d, 0x33, 0x30, 0x30, 0x2a, 0x6e, 0x2f, 0x6d, 0x61, 0x78, + 0x29, 0x2b, 0x27, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, + 0x72, 0x3d, 0x22, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x67, 0x72, + 0x61, 0x79, 0x22, 0x3e, 0x26, 0x6e, 0x62, 0x73, 0x70, 0x3b, + 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x61, 0x62, + 0x6c, 0x65, 0x3e, 0x27, 0x7d, 0x66, 0x75, 0x6e, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x20, 0x64, 0x63, 0x28, 0x6e, 0x2c, 0x64, + 0x29, 0x7b, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6e, + 0x2e, 0x74, 0x6f, 0x46, 0x69, 0x78, 0x65, 0x64, 0x28, 0x64, + 0x29, 0x7d, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x20, 0x74, 0x28, 0x6d, 0x29, 0x7b, 0x6e, 0x3d, 0x64, 0x63, + 0x28, 0x2d, 0x33, 0x39, 0x2e, 0x36, 0x2b, 0x30, 0x2e, 0x30, + 0x31, 0x2a, 0x6d, 0x2c, 0x31, 0x29, 0x3b, 0x73, 0x28, 0x27, + 0x74, 0x65, 0x6d, 0x70, 0x27, 0x2c, 0x6e, 0x2c, 0x34, 0x30, + 0x2c, 0x27, 0x54, 0x65, 0x6d, 0x70, 0x65, 0x72, 0x61, 0x74, + 0x75, 0x72, 0x65, 0x20, 0x27, 0x2b, 0x6e, 0x2b, 0x27, 0x20, + 0x26, 0x64, 0x65, 0x67, 0x3b, 0x43, 0x27, 0x29, 0x7d, 0x66, + 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x68, 0x28, + 0x6d, 0x29, 0x7b, 0x6e, 0x3d, 0x64, 0x63, 0x28, 0x2d, 0x34, + 0x2b, 0x30, 0x2e, 0x30, 0x34, 0x30, 0x35, 0x2a, 0x6d, 0x2d, + 0x32, 0x2e, 0x38, 0x65, 0x2d, 0x36, 0x2a, 0x28, 0x6d, 0x2a, + 0x6d, 0x29, 0x2c, 0x32, 0x29, 0x3b, 0x73, 0x28, 0x27, 0x68, + 0x75, 0x6d, 0x27, 0x2c, 0x6e, 0x2c, 0x31, 0x30, 0x30, 0x2c, + 0x27, 0x48, 0x75, 0x6d, 0x69, 0x64, 0x69, 0x74, 0x79, 0x20, + 0x27, 0x2b, 0x6e, 0x2b, 0x27, 0x25, 0x27, 0x29, 0x7d, 0x66, + 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x31, + 0x28, 0x6d, 0x29, 0x7b, 0x6e, 0x3d, 0x64, 0x63, 0x28, 0x2e, + 0x37, 0x36, 0x32, 0x39, 0x33, 0x39, 0x34, 0x33, 0x37, 0x35, + 0x2a, 0x6d, 0x2c, 0x30, 0x29, 0x3b, 0x73, 0x28, 0x27, 0x6c, + 0x31, 0x27, 0x2c, 0x6e, 0x2c, 0x32, 0x30, 0x30, 0x2c, 0x27, + 0x4c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x31, 0x20, 0x27, 0x2b, + 0x6e, 0x29, 0x7d, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x20, 0x6c, 0x32, 0x28, 0x6d, 0x29, 0x7b, 0x6e, 0x3d, + 0x64, 0x63, 0x28, 0x2e, 0x34, 0x36, 0x39, 0x33, 0x36, 0x30, + 0x33, 0x2a, 0x6d, 0x2c, 0x30, 0x29, 0x3b, 0x73, 0x28, 0x27, + 0x6c, 0x32, 0x27, 0x2c, 0x6e, 0x2c, 0x32, 0x30, 0x30, 0x2c, + 0x27, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x20, 0x32, 0x20, 0x27, + 0x2b, 0x6e, 0x29, 0x7d, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x20, 0x72, 0x73, 0x28, 0x6d, 0x29, 0x7b, 0x6e, + 0x3d, 0x6d, 0x2b, 0x34, 0x35, 0x3b, 0x73, 0x28, 0x27, 0x72, + 0x73, 0x27, 0x2c, 0x6e, 0x2c, 0x31, 0x30, 0x30, 0x2c, 0x27, + 0x52, 0x53, 0x53, 0x49, 0x20, 0x27, 0x2b, 0x6e, 0x29, 0x7d, + 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x70, + 0x28, 0x63, 0x2c, 0x6c, 0x2c, 0x74, 0x2c, 0x72, 0x29, 0x7b, + 0x74, 0x6d, 0x3d, 0x63, 0x2b, 0x6c, 0x3b, 0x63, 0x70, 0x3d, + 0x63, 0x2a, 0x31, 0x2e, 0x38, 0x2f, 0x74, 0x6d, 0x3b, 0x6c, + 0x70, 0x3d, 0x6c, 0x2a, 0x30, 0x2e, 0x30, 0x35, 0x34, 0x35, + 0x2f, 0x74, 0x6d, 0x3b, 0x6c, 0x74, 0x3d, 0x74, 0x2a, 0x31, + 0x37, 0x2e, 0x37, 0x2f, 0x74, 0x6d, 0x3b, 0x6c, 0x72, 0x3d, + 0x72, 0x2a, 0x32, 0x30, 0x2f, 0x74, 0x6d, 0x3b, 0x6e, 0x3d, + 0x63, 0x70, 0x2b, 0x6c, 0x70, 0x2b, 0x6c, 0x74, 0x2b, 0x6c, + 0x72, 0x3b, 0x73, 0x28, 0x27, 0x70, 0x27, 0x2c, 0x6e, 0x2c, + 0x33, 0x30, 0x2c, 0x27, 0x50, 0x6f, 0x77, 0x65, 0x72, 0x20, + 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x20, 0x27, 0x2b, 0x64, 0x63, 0x28, 0x6e, 0x2c, 0x32, + 0x29, 0x2b, 0x27, 0x20, 0x6d, 0x57, 0x27, 0x29, 0x3b, 0x73, + 0x28, 0x27, 0x70, 0x63, 0x27, 0x2c, 0x63, 0x70, 0x2c, 0x33, + 0x30, 0x2c, 0x27, 0x43, 0x50, 0x55, 0x20, 0x70, 0x6f, 0x77, + 0x65, 0x72, 0x20, 0x27, 0x2b, 0x64, 0x63, 0x28, 0x63, 0x70, + 0x2c, 0x32, 0x29, 0x2b, 0x27, 0x20, 0x6d, 0x57, 0x27, 0x29, + 0x3b, 0x73, 0x28, 0x27, 0x70, 0x6c, 0x27, 0x2c, 0x6c, 0x70, + 0x2c, 0x33, 0x30, 0x2c, 0x27, 0x4c, 0x50, 0x4d, 0x20, 0x70, + 0x6f, 0x77, 0x65, 0x72, 0x20, 0x27, 0x2b, 0x64, 0x63, 0x28, + 0x6c, 0x70, 0x2c, 0x32, 0x29, 0x2b, 0x27, 0x20, 0x6d, 0x57, + 0x27, 0x29, 0x3b, 0x73, 0x28, 0x27, 0x70, 0x72, 0x27, 0x2c, + 0x6c, 0x72, 0x2c, 0x33, 0x30, 0x2c, 0x27, 0x52, 0x61, 0x64, + 0x69, 0x6f, 0x20, 0x52, 0x58, 0x20, 0x70, 0x6f, 0x77, 0x65, + 0x72, 0x20, 0x27, 0x2b, 0x64, 0x63, 0x28, 0x6c, 0x72, 0x2c, + 0x32, 0x29, 0x2b, 0x27, 0x20, 0x6d, 0x57, 0x27, 0x29, 0x3b, + 0x73, 0x28, 0x27, 0x70, 0x74, 0x27, 0x2c, 0x6c, 0x74, 0x2c, + 0x33, 0x30, 0x2c, 0x27, 0x52, 0x61, 0x64, 0x69, 0x6f, 0x20, + 0x54, 0x58, 0x20, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x20, 0x27, + 0x2b, 0x64, 0x63, 0x28, 0x6c, 0x74, 0x2c, 0x32, 0x29, 0x2b, + 0x27, 0x20, 0x6d, 0x57, 0x27, 0x29, 0x7d, 0x66, 0x75, 0x6e, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x28, 0x6e, 0x29, + 0x7b, 0x65, 0x28, 0x27, 0x69, 0x27, 0x29, 0x2e, 0x69, 0x6e, + 0x6e, 0x65, 0x72, 0x48, 0x54, 0x4d, 0x4c, 0x3d, 0x6e, 0x7d, + 0x0a, 0x3c, 0x2f, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x3e, + 0x0a, 0x3c, 0x68, 0x31, 0x3e, 0x4e, 0x6f, 0x64, 0x65, 0x0a, + 0x25, 0x21, 0x20, 0x6e, 0x6f, 0x64, 0x65, 0x69, 0x64, 0x0a, + 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x0a, 0x3c, 0x61, 0x20, 0x6f, + 0x6e, 0x63, 0x6c, 0x69, 0x63, 0x6b, 0x3d, 0x22, 0x6c, 0x6f, + 0x61, 0x64, 0x44, 0x61, 0x74, 0x61, 0x28, 0x29, 0x3b, 0x22, + 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x23, 0x22, 0x3e, + 0x52, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x3c, 0x2f, 0x61, 0x3e, + 0x0a, 0x3c, 0x73, 0x70, 0x61, 0x6e, 0x20, 0x69, 0x64, 0x3d, + 0x22, 0x73, 0x70, 0x69, 0x6e, 0x22, 0x3e, 0x20, 0x3c, 0x2f, + 0x73, 0x70, 0x61, 0x6e, 0x3e, 0x0a, 0x3c, 0x68, 0x32, 0x3e, + 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, + 0x74, 0x3c, 0x2f, 0x68, 0x32, 0x3e, 0x0a, 0x3c, 0x64, 0x69, + 0x76, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x74, 0x65, 0x6d, 0x70, + 0x22, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x0a, 0x3c, + 0x64, 0x69, 0x76, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x68, 0x75, + 0x6d, 0x22, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x0a, + 0x3c, 0x68, 0x32, 0x3e, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x3c, + 0x2f, 0x68, 0x32, 0x3e, 0x0a, 0x3c, 0x64, 0x69, 0x76, 0x20, + 0x69, 0x64, 0x3d, 0x22, 0x6c, 0x31, 0x22, 0x3e, 0x3c, 0x2f, + 0x64, 0x69, 0x76, 0x3e, 0x0a, 0x3c, 0x64, 0x69, 0x76, 0x20, + 0x69, 0x64, 0x3d, 0x22, 0x6c, 0x32, 0x22, 0x3e, 0x3c, 0x2f, + 0x64, 0x69, 0x76, 0x3e, 0x0a, 0x3c, 0x68, 0x32, 0x3e, 0x50, + 0x6f, 0x77, 0x65, 0x72, 0x3c, 0x2f, 0x68, 0x32, 0x3e, 0x0a, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x70, - 0x63, 0x22, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x0a, - 0x3c, 0x64, 0x69, 0x76, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x70, - 0x6c, 0x22, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x0a, - 0x3c, 0x64, 0x69, 0x76, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x70, - 0x72, 0x22, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x0a, - 0x3c, 0x64, 0x69, 0x76, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x70, - 0x74, 0x22, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x0a, - 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x0a, 0x3c, - 0x64, 0x69, 0x76, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x69, 0x22, - 0x3e, 0x30, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x0a, 0x25, - 0x21, 0x3a, 0x20, 0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, - 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x0a, 0x0a, 0x0a, 0x00}; + 0x22, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x0a, 0x3c, + 0x64, 0x69, 0x76, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x70, 0x63, + 0x22, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x0a, 0x3c, + 0x64, 0x69, 0x76, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x70, 0x6c, + 0x22, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x0a, 0x3c, + 0x64, 0x69, 0x76, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x70, 0x72, + 0x22, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x0a, 0x3c, + 0x64, 0x69, 0x76, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x70, 0x74, + 0x22, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x0a, 0x3c, + 0x62, 0x72, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x0a, 0x3c, 0x64, + 0x69, 0x76, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x69, 0x22, 0x3e, + 0x30, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0x0a, 0x25, 0x21, + 0x3a, 0x20, 0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, + 0x68, 0x74, 0x6d, 0x6c, 0x0a, 0x00}; const char data_footer_html[39] = { /* /footer.html */ @@ -455,4 +451,4 @@ const struct httpd_fsdata_file file_index_html[] ={{ file_header_html, d #define HTTPD_FS_ROOT file_index_html #define HTTPD_FS_NUMFILES 8 -#define HTTPD_FS_SIZE 4050 +#define HTTPD_FS_SIZE 4007 diff --git a/examples/sky-ip/sensors-script.js b/examples/sky-ip/sensors-script.js index d7f423a3f..59761fdf3 100644 --- a/examples/sky-ip/sensors-script.js +++ b/examples/sky-ip/sensors-script.js @@ -1,11 +1,11 @@ /* This is the uncompressed version of the script in httpd-fs/sensordata.shtml */ -var start; +var start, d = document; -i = new Image(50,60) -i.src = "spin.gif" +i = new Image(50,60); +i.src = "spin.gif"; function load() { - var img = document.getElementById("spin"); + var img = d.getElementById("spin"); img.innerHTML = ' '; loadData(); } @@ -25,27 +25,27 @@ function loadData() { } r.onreadystatechange = function() { if(r.readyState == 1) { - var img = document.getElementById("spin"); + var img = d.getElementById("spin"); img.innerHTML = ''; } if(r.readyState == 4) { - var img = document.getElementById("spin"); + var img = d.getElementById("spin"); img.innerHTML = 'took ' + ((new Date()).getTime() - start.getTime()) / 1000 + ' seconds'; eval(r.responseText); } - } + }; start = new Date(); r.open("GET", "/sensordata.shtml", true); r.send(null); } function e(el) { - d = document; if(d.getElementById) { return d.getElementById(el); - } else if (d.all) { + } + if (d.all) { return d.all[el]; } } From 07f3df45beb9faf8acbdf7a32100bc31ed651208 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Tue, 12 Apr 2011 14:12:09 +0200 Subject: [PATCH 14/18] Converted scope-local variables into function-local variables. The 6502-specific LC implementation doesn't allow for scope-local vaiables between PT_BEGIN/PROCESS_BEGIN/PSOCK_BEGIN and PT_BEGIN/PROCESS_END/PSOCK_END. --- apps/rest-http/http-server.c | 23 ++++++++++++++++------- apps/shell/shell-base64.c | 8 ++++---- apps/shell/shell-file.c | 13 ++++++------- apps/shell/shell-ping.c | 6 ++---- apps/shell/shell-rsh.c | 5 +++-- apps/shell/shell-sendtest.c | 2 +- apps/shell/shell-text.c | 15 +++++++-------- apps/shell/shell-time.c | 8 ++++---- apps/shell/shell-vars.c | 4 ++-- apps/shell/shell.c | 6 +++--- core/net/dhcpc.c | 4 ++-- 11 files changed, 50 insertions(+), 44 deletions(-) diff --git a/apps/rest-http/http-server.c b/apps/rest-http/http-server.c index 6a361b182..34aa0b59f 100644 --- a/apps/rest-http/http-server.c +++ b/apps/rest-http/http-server.c @@ -392,10 +392,12 @@ content_type_t http_get_header_content_type(http_request_t* request) static PT_THREAD(handle_request(connection_state_t* conn_state)) { + static int error; + const char* content_len; + PSOCK_BEGIN(&(conn_state->sin)); - static int error; - const char* content_len = NULL; + content_len = NULL; error = HTTP_NO_ERROR; /*always reinit static variables due to protothreads*/ @@ -512,14 +514,19 @@ PT_THREAD(handle_request(connection_state_t* conn_state)) static PT_THREAD(send_data(connection_state_t* conn_state)) { + uint16_t index; + http_response_t* response; + http_header_t* header; + uint8_t* buffer; + PSOCK_BEGIN(&(conn_state->sout)); PRINTF("send_data -> \n"); - uint16_t index = 0; - http_response_t* response = &conn_state->response; - http_header_t* header = response->headers; - uint8_t* buffer = allocate_buffer(200); + index = 0; + response = &conn_state->response; + header = response->headers; + buffer = allocate_buffer(200); /*FIXME: what is the best solution here to send the data. Right now, if buffer is not allocated, no data is sent!*/ if (buffer) { @@ -583,6 +590,8 @@ PROCESS(http_server, "Httpd Process"); PROCESS_THREAD(http_server, ev, data) { + connection_state_t *conn_state; + PROCESS_BEGIN(); /* if static routes are used rather than RPL */ @@ -603,7 +612,7 @@ PROCESS_THREAD(http_server, ev, data) while(1) { PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event); - connection_state_t *conn_state = (connection_state_t *)data; + conn_state = (connection_state_t *)data; if(uip_connected()) { PRINTF("##Connected##\n"); diff --git a/apps/shell/shell-base64.c b/apps/shell/shell-base64.c index 39298f041..91d280161 100644 --- a/apps/shell/shell-base64.c +++ b/apps/shell/shell-base64.c @@ -117,13 +117,13 @@ base64_add_char(struct base64_decoder_state *s, char c) /*---------------------------------------------------------------------------*/ PROCESS_THREAD(shell_dec64_process, ev, data) { + struct shell_input *input; + struct base64_decoder_state s; + int i; + PROCESS_BEGIN(); while(1) { - struct shell_input *input; - struct base64_decoder_state s; - int i; - PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input); input = data; diff --git a/apps/shell/shell-file.c b/apps/shell/shell-file.c index 2371b3fe9..d9e746c93 100644 --- a/apps/shell/shell-file.c +++ b/apps/shell/shell-file.c @@ -103,6 +103,7 @@ PROCESS_THREAD(shell_ls_process, ev, data) PROCESS_THREAD(shell_append_process, ev, data) { static int fd = 0; + struct shell_input *input; PROCESS_EXITHANDLER(cfs_close(fd)); @@ -115,7 +116,6 @@ PROCESS_THREAD(shell_append_process, ev, data) "append: could not open file for writing: ", data); } else { while(1) { - struct shell_input *input; PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input); input = data; /* printf("cat input %d %d\n", input->len1, input->len2);*/ @@ -139,6 +139,7 @@ PROCESS_THREAD(shell_append_process, ev, data) PROCESS_THREAD(shell_write_process, ev, data) { static int fd = 0; + struct shell_input *input; int r; PROCESS_EXITHANDLER(cfs_close(fd)); @@ -152,7 +153,6 @@ PROCESS_THREAD(shell_write_process, ev, data) "write: could not open file for writing: ", data); } else { while(1) { - struct shell_input *input; PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input); input = data; /* printf("cat input %d %d\n", input->len1, input->len2);*/ @@ -187,11 +187,14 @@ PROCESS_THREAD(shell_write_process, ev, data) PROCESS_THREAD(shell_read_process, ev, data) { static int fd = 0; + static int block_size = MAX_BLOCKSIZE; char *next; char filename[MAX_FILENAME_LEN]; int len; int offset = 0; - static int block_size = MAX_BLOCKSIZE; + char buf[MAX_BLOCKSIZE]; + struct shell_input *input; + PROCESS_EXITHANDLER(cfs_close(fd)); PROCESS_BEGIN(); @@ -236,10 +239,6 @@ PROCESS_THREAD(shell_read_process, ev, data) } else { while(1) { - char buf[MAX_BLOCKSIZE]; - int len; - struct shell_input *input; - len = cfs_read(fd, buf, block_size); if(len <= 0) { cfs_close(fd); diff --git a/apps/shell/shell-ping.c b/apps/shell/shell-ping.c index 5f8de1b80..4957a4fa7 100644 --- a/apps/shell/shell-ping.c +++ b/apps/shell/shell-ping.c @@ -133,8 +133,9 @@ send_ping(uip_ipaddr_t *dest_addr) /*---------------------------------------------------------------------------*/ PROCESS_THREAD(shell_ping_process, ev, data) { + static struct etimer e; struct shell_input *input; - + PROCESS_BEGIN(); if(data == NULL) { @@ -149,9 +150,6 @@ PROCESS_THREAD(shell_ping_process, ev, data) running = 1; while(running) { - static struct etimer e; - - etimer_set(&e, CLOCK_SECOND * 10); PROCESS_WAIT_EVENT(); diff --git a/apps/shell/shell-rsh.c b/apps/shell/shell-rsh.c index 946ec4145..95a13b83e 100644 --- a/apps/shell/shell-rsh.c +++ b/apps/shell/shell-rsh.c @@ -67,6 +67,7 @@ PROCESS(shell_rsh_server_process, "rsh server"); PROCESS_THREAD(shell_rsh_process, ev, data) { static rimeaddr_t receiver; + struct shell_input *input; const char *nextptr; char buf[40]; @@ -88,7 +89,6 @@ PROCESS_THREAD(shell_rsh_process, ev, data) meshconn_connect(&meshconn, &receiver); while(1) { - struct shell_input *input; PROCESS_WAIT_EVENT(); if(ev == shell_event_input) { input = data; @@ -114,6 +114,8 @@ PROCESS_THREAD(shell_rsh_process, ev, data) /*---------------------------------------------------------------------------*/ PROCESS_THREAD(shell_rsh_server_process, ev, data) { + struct shell_input *input; + PROCESS_BEGIN(); while(1) { @@ -123,7 +125,6 @@ PROCESS_THREAD(shell_rsh_server_process, ev, data) if(ev == PROCESS_EVENT_EXITED) { front_process = NULL; } else if(ev == shell_event_input) { - struct shell_input *input; input = data; packetbuf_clear(); memcpy(packetbuf_dataptr(), input->data1, input->len1); diff --git a/apps/shell/shell-sendtest.c b/apps/shell/shell-sendtest.c index ba83d71ec..2fa7213a0 100644 --- a/apps/shell/shell-sendtest.c +++ b/apps/shell/shell-sendtest.c @@ -117,10 +117,10 @@ print_usage(void) PROCESS_THREAD(shell_sendtest_process, ev, data) { static rimeaddr_t receiver; + static unsigned long cpu, lpm, rx, tx; const char *nextptr; const char *args; char buf[40]; - static unsigned long cpu, lpm, rx, tx; unsigned long cpu2, lpm2, rx2, tx2; PROCESS_BEGIN(); diff --git a/apps/shell/shell-text.c b/apps/shell/shell-text.c index 5bcd840b5..d80d3cb4e 100644 --- a/apps/shell/shell-text.c +++ b/apps/shell/shell-text.c @@ -131,6 +131,7 @@ PROCESS_THREAD(shell_binprint_process, ev, data) uint16_t *ptr; int i; char buf[2*64], *bufptr; + uint16_t val; PROCESS_BEGIN(); @@ -145,9 +146,8 @@ PROCESS_THREAD(shell_binprint_process, ev, data) bufptr = buf; ptr = (uint16_t *)input->data1; for(i = 0; i < input->len1 && i < input->len1 - 1; i += 2) { - uint16_t data; - memcpy(&data, ptr, sizeof(data)); - bufptr += sprintf(bufptr, "%u ", data); + memcpy(&val, ptr, sizeof(val)); + bufptr += sprintf(bufptr, "%u ", val); if(bufptr - buf >= sizeof(buf) - 6) { shell_output_str(&binprint_command, buf, ""); bufptr = buf; @@ -160,9 +160,8 @@ PROCESS_THREAD(shell_binprint_process, ev, data) ptr = (uint16_t *)input->data2; for(i = 0; i < input->len2 && i < input->len2 - 1; i += 2) { - uint16_t data; - memcpy(&data, ptr, sizeof(data)); - bufptr += sprintf(bufptr, "%u ", data); + memcpy(&val, ptr, sizeof(val)); + bufptr += sprintf(bufptr, "%u ", val); if(bufptr - buf >= sizeof(buf) - 6) { shell_output_str(&binprint_command, buf, ""); bufptr = buf; @@ -180,8 +179,9 @@ PROCESS_THREAD(shell_binprint_process, ev, data) /*---------------------------------------------------------------------------*/ PROCESS_THREAD(shell_size_process, ev, data) { - struct shell_input *input; static unsigned long size; + struct shell_input *input; + char buf[10]; PROCESS_BEGIN(); size = 0; @@ -193,7 +193,6 @@ PROCESS_THREAD(shell_size_process, ev, data) size += input->len1 + input->len2; if(input->len1 + input->len2 == 0) { - char buf[10]; snprintf(buf, sizeof(buf), "%lu", size); shell_output_str(&size_command, buf, ""); PROCESS_EXIT(); diff --git a/apps/shell/shell-time.c b/apps/shell/shell-time.c index 2e7ffad88..4999354cd 100644 --- a/apps/shell/shell-time.c +++ b/apps/shell/shell-time.c @@ -91,11 +91,11 @@ PROCESS_THREAD(shell_time_process, ev, data) uint16_t time[2]; } msg; unsigned long newtime; + const char *nextptr; PROCESS_BEGIN(); if(data != NULL) { - const char *nextptr; newtime = shell_strtolong(data, &nextptr); if(data != nextptr) { shell_set_time(newtime); @@ -122,6 +122,7 @@ PROCESS_THREAD(shell_time_process, ev, data) /*---------------------------------------------------------------------------*/ PROCESS_THREAD(shell_timestamp_process, ev, data) { + struct shell_input *input; struct msg { uint16_t len; uint16_t time[2]; @@ -132,7 +133,6 @@ PROCESS_THREAD(shell_timestamp_process, ev, data) PROCESS_BEGIN(); while(1) { - struct shell_input *input; PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input); input = data; if(input->len1 + input->len2 == 0) { @@ -161,7 +161,9 @@ PROCESS_THREAD(shell_timestamp_process, ev, data) PROCESS_THREAD(shell_repeat_server_process, ev, data) { static char *command; + static struct process *started_process; char command_copy[MAX_COMMANDLENGTH]; + int ret; if(ev == shell_event_input) { goto exit; @@ -174,8 +176,6 @@ PROCESS_THREAD(shell_repeat_server_process, ev, data) PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_CONTINUE && data == &shell_repeat_process); { - int ret; - static struct process *started_process; strncpy(command_copy, command, MAX_COMMANDLENGTH); ret = shell_start_command(command_copy, (int)strlen(command_copy), &repeat_command, &started_process); diff --git a/apps/shell/shell-vars.c b/apps/shell/shell-vars.c index dd1982b67..1957ffc51 100644 --- a/apps/shell/shell-vars.c +++ b/apps/shell/shell-vars.c @@ -90,6 +90,8 @@ PROCESS_THREAD(shell_vars_process, ev, data) PROCESS_THREAD(shell_var_process, ev, data) { int i; + int j; + char numbuf[32]; PROCESS_BEGIN(); @@ -99,8 +101,6 @@ PROCESS_THREAD(shell_var_process, ev, data) for(i = 0; i < symbols_nelts; ++i) { if(symbols[i].name != NULL && strncmp(symbols[i].name, data, strlen(symbols[i].name)) == 0) { - char numbuf[32]; - int j; sprintf(numbuf, " %d", *((int *)symbols[i].value)); shell_output_str(&var_command, (char *)symbols[i].name, numbuf); diff --git a/apps/shell/shell.c b/apps/shell/shell.c index 5a9c01ad3..3302fa2d8 100644 --- a/apps/shell/shell.c +++ b/apps/shell/shell.c @@ -410,6 +410,8 @@ shell_register_command(struct shell_command *c) PROCESS_THREAD(shell_process, ev, data) { static struct process *started_process; + struct shell_input *input; + int ret; PROCESS_BEGIN(); /* Let the system start up before showing the prompt. */ @@ -420,9 +422,7 @@ PROCESS_THREAD(shell_process, ev, data) PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input); { - struct shell_input *input = data; - int ret; - + input = data; ret = shell_start_command(input->data1, input->len1, NULL, &started_process); diff --git a/core/net/dhcpc.c b/core/net/dhcpc.c index a7213a51a..241f5d3e4 100644 --- a/core/net/dhcpc.c +++ b/core/net/dhcpc.c @@ -271,6 +271,8 @@ msg_for_me(void) static PT_THREAD(handle_dhcp(process_event_t ev, void *data)) { + clock_time_t ticks; + PT_BEGIN(&s.pt); init: @@ -350,7 +352,6 @@ PT_THREAD(handle_dhcp(process_event_t ev, void *data)) } while(s.ticks > 0) { - clock_time_t ticks; ticks = IMIN(s.ticks, MAX_TICKS); s.ticks -= ticks; etimer_set(&s.etimer, ticks); @@ -368,7 +369,6 @@ PT_THREAD(handle_dhcp(process_event_t ev, void *data)) /* renewing: */ xid++; do { - clock_time_t ticks; while(ev != tcpip_event) { tcpip_poll_udp(s.conn); PT_YIELD(&s.pt); From 31a14c3d90a08cb2b959110b66eec2243023246a Mon Sep 17 00:00:00 2001 From: dogan yazar Date: Wed, 13 Apr 2011 00:07:47 +0200 Subject: [PATCH 15/18] Commented periodic resource related stuff for the sake of small code print and added minimal-net configuration in README. --- apps/rest-common/rest.c | 3 ++- examples/rest-example/README | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/apps/rest-common/rest.c b/apps/rest-common/rest.c index a7264e432..c1b383c44 100644 --- a/apps/rest-common/rest.c +++ b/apps/rest-common/rest.c @@ -291,6 +291,7 @@ PROCESS_THREAD(rest_manager_process, ev, data) PROCESS_PAUSE(); /*Periodic resources are only available to COAP implementation*/ +#if 0 #ifdef WITH_COAP periodic_resource_t* periodic_resource = NULL; for (periodic_resource = (periodic_resource_t*)list_head(restful_periodic_services); periodic_resource; periodic_resource = periodic_resource->next) { @@ -327,6 +328,6 @@ PROCESS_THREAD(rest_manager_process, ev, data) } } #endif /*WITH_COAP*/ - +#endif PROCESS_END(); } diff --git a/examples/rest-example/README b/examples/rest-example/README index 9c270cad4..d7cdcc202 100644 --- a/examples/rest-example/README +++ b/examples/rest-example/README @@ -10,7 +10,7 @@ Each resource has a handler function which is called by the REST layer to serve (i.e. "helloworld" resource has a handler function named "helloworld_handler" which is called when a web service request is received for "helloworld" resource.) -To run REST examples in COOJA under Linux +To run REST examples in COOJA on Linux -------------------------------------------- Accessing the server from outside: @@ -50,9 +50,10 @@ Client periodically accesses resources of server and prints the payload. Note: If the generated binary is bigger than the MOTE code size, then you will get a "region text is full" error. Right now, REST+HTTP example uses (Contiki + ContikiMAC + uIPv6 + RPL + HTTP Server + REST Layer) which does not fit in Tmote Sky memory. To save same code space and make the example fit, you can define static routes rather than using RPL or use nullrdc rather than ContikiMAC. +If border router does not fit, then first try to update the Makefile of border router in /examples/ipv6/rpl-border-router by +setting WITH_WEBSERVER=0. - -To run REST server on real nodes under Linux +To run REST server on real nodes (i.e. tmote sky) -------------------------------------------- 1. Program the nodes with the rest-server-example @@ -71,7 +72,19 @@ To run REST server on real nodes under Linux 5. Test the connectivity by pinging them. ping6 -6. Remaining parts are the same with the COOJA example. (i.e. if it is a COAP Server, it is available at :61616) +6. Remaining parts are the same with the COOJA example. (i.e. if it is a COAP Server, it's available at :61616) + + +To run REST server with minimal-net on Linux +-------------------------------------------- +1. Compile with minimal-net setting. + make rest-server-example TARGET=minimal-net + +2. Run the generated executable with sudo and note the IP address of the server which will be printed right after. + sudo ./rest-server-example.minimal-net + +3. How to access and test the server is same with the other settings. (i.e. if it is a COAP Server, +it's available at :61616 and if it's a HTTP Server it is available at :8080) To Do From af4ce9ba9ef76a7dbe62e955bbcbeb78e4346c66 Mon Sep 17 00:00:00 2001 From: Adam Dunkels Date: Wed, 13 Apr 2011 14:10:02 +0200 Subject: [PATCH 16/18] Bugfix: idle power consumption was sometimes misestimated for transmissions, when a duty cycle rtimer fired in the middle of a transmission --- core/net/mac/contikimac.c | 96 +++++++-------------------------------- 1 file changed, 16 insertions(+), 80 deletions(-) diff --git a/core/net/mac/contikimac.c b/core/net/mac/contikimac.c index b841e9cd9..82c027b07 100644 --- a/core/net/mac/contikimac.c +++ b/core/net/mac/contikimac.c @@ -301,12 +301,8 @@ schedule_powercycle(struct rtimer *t, rtimer_clock_t time) time = RTIMER_NOW() - RTIMER_TIME(t) + 2; } -#if NURTIMER - r = rtimer_reschedule(t, time, 1); -#else r = rtimer_set(t, RTIMER_TIME(t) + time, 1, (void (*)(struct rtimer *, void *))powercycle, NULL); -#endif if(r != RTIMER_OK) { printf("schedule_powercycle: could not set rtimer\n"); } @@ -323,12 +319,8 @@ schedule_powercycle_fixed(struct rtimer *t, rtimer_clock_t fixed_time) fixed_time = RTIMER_NOW() + 1; } -#if NURTIMER - r = rtimer_reschedule(t, RTIMER_TIME(t) - time, 1); -#else r = rtimer_set(t, fixed_time, 1, (void (*)(struct rtimer *, void *))powercycle, NULL); -#endif if(r != RTIMER_OK) { printf("schedule_powercycle: could not set rtimer\n"); } @@ -337,8 +329,14 @@ schedule_powercycle_fixed(struct rtimer *t, rtimer_clock_t fixed_time) static void powercycle_turn_radio_off(void) { + uint8_t was_on = radio_is_on; if(we_are_sending == 0) { off(); +#if CONTIKIMAC_CONF_COMPOWER + if(was_on && !radio_is_on) { + compower_accumulate(&compower_idle_activity); + } +#endif /* CONTIKIMAC_CONF_COMPOWER */ } } static void @@ -363,16 +361,11 @@ powercycle(struct rtimer *t, void *ptr) cycle_start += CYCLE_TIME; if(WITH_STREAMING && is_streaming) { -#if NURTIMER - if(!RTIMER_CLOCK_LT(cycle_start, RTIMER_NOW(), stream_until)) -#else - if(!RTIMER_CLOCK_LT(RTIMER_NOW(), stream_until)) -#endif - { - is_streaming = 0; - rimeaddr_copy(&is_streaming_to, &rimeaddr_null); - rimeaddr_copy(&is_streaming_to_too, &rimeaddr_null); - } + if(!RTIMER_CLOCK_LT(RTIMER_NOW(), stream_until)) { + is_streaming = 0; + rimeaddr_copy(&is_streaming_to, &rimeaddr_null); + rimeaddr_copy(&is_streaming_to_too, &rimeaddr_null); + } } packet_seen = 0; @@ -384,11 +377,7 @@ powercycle(struct rtimer *t, void *ptr) powercycle_turn_radio_on(); // schedule_powercycle_fixed(t, t0 + CCA_CHECK_TIME); #if 0 -#if NURTIMER - while(RTIMER_CLOCK_LT(t0, RTIMER_NOW(), t0 + CCA_CHECK_TIME)); -#else while(RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + CCA_CHECK_TIME)); -#endif #endif /* 0 */ /* Check if a packet is seen in the air. If so, we keep the radio on for a while (LISTEN_TIME_AFTER_PACKET_DETECTED) to @@ -401,10 +390,6 @@ powercycle(struct rtimer *t, void *ptr) break; } powercycle_turn_radio_off(); -#if CONTIKIMAC_CONF_COMPOWER - compower_accumulate(&compower_idle_activity); -#endif /* CONTIKIMAC_CONF_COMPOWER */ - } // schedule_powercycle_fixed(t, t0 + CCA_CHECK_TIME + CCA_SLEEP_TIME); schedule_powercycle_fixed(t, RTIMER_NOW() + CCA_SLEEP_TIME); @@ -441,9 +426,6 @@ powercycle(struct rtimer *t, void *ptr) } if(silence_periods > MAX_SILENCE_PERIODS) { powercycle_turn_radio_off(); -#if CONTIKIMAC_CONF_COMPOWER - compower_accumulate(&compower_idle_activity); -#endif /* CONTIKIMAC_CONF_COMPOWER */ break; } if(WITH_FAST_SLEEP && @@ -451,9 +433,6 @@ powercycle(struct rtimer *t, void *ptr) !(NETSTACK_RADIO.receiving_packet() || NETSTACK_RADIO.pending_packet())) { powercycle_turn_radio_off(); -#if CONTIKIMAC_CONF_COMPOWER - compower_accumulate(&compower_idle_activity); -#endif /* CONTIKIMAC_CONF_COMPOWER */ break; } if(NETSTACK_RADIO.pending_packet()) { @@ -469,9 +448,6 @@ powercycle(struct rtimer *t, void *ptr) !RTIMER_CLOCK_LT(RTIMER_NOW(), (start + LISTEN_TIME_AFTER_PACKET_DETECTED))) { powercycle_turn_radio_off(); -#if CONTIKIMAC_CONF_COMPOWER - compower_accumulate(&compower_idle_activity); -#endif /* CONTIKIMAC_CONF_COMPOWER */ } } } @@ -766,11 +742,7 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr) for(i = 0; i < CCA_COUNT_MAX; ++i) { t0 = RTIMER_NOW(); on(); -#if NURTIMER - while(RTIMER_CLOCK_LT(t0, RTIMER_NOW(), t0 + CCA_CHECK_TIME)); -#else while(RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + CCA_CHECK_TIME)) { } -#endif if(NETSTACK_RADIO.channel_clear() == 0) { collisions++; off(); @@ -778,11 +750,7 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr) } off(); t0 = RTIMER_NOW(); -#if NURTIMER - while(RTIMER_CLOCK_LT(t0, RTIMER_NOW(), t0 + CCA_SLEEP_TIME)); -#else while(RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + CCA_SLEEP_TIME)) { } -#endif } } @@ -801,15 +769,9 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr) watchdog_periodic(); t0 = RTIMER_NOW(); -#if NURTIMER - for(strobes = 0, collisions = 0; - got_strobe_ack == 0 && collisions == 0 && - RTIMER_CLOCK_LT(t0, RTIMER_NOW(), t0 + STROBE_TIME); strobes++) { -#else for(strobes = 0, collisions = 0; got_strobe_ack == 0 && collisions == 0 && RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + STROBE_TIME); strobes++) { -#endif watchdog_periodic(); @@ -830,21 +792,15 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr) ret = NETSTACK_RADIO.transmit(transmit_len); wt = RTIMER_NOW(); -#if NURTIMER - while(RTIMER_CLOCK_LT(wt, RTIMER_NOW(), wt + INTER_PACKET_INTERVAL)); -#else while(RTIMER_CLOCK_LT(RTIMER_NOW(), wt + INTER_PACKET_INTERVAL)) { } -#endif + if(!is_broadcast && (NETSTACK_RADIO.receiving_packet() || NETSTACK_RADIO.pending_packet() || NETSTACK_RADIO.channel_clear() == 0)) { uint8_t ackbuf[ACK_LEN]; wt = RTIMER_NOW(); -#if NURTIMER - while(RTIMER_CLOCK_LT(wt, RTIMER_NOW(), wt + AFTER_ACK_DETECTECT_WAIT_TIME)); -#else while(RTIMER_CLOCK_LT(RTIMER_NOW(), wt + AFTER_ACK_DETECTECT_WAIT_TIME)) { } -#endif + len = NETSTACK_RADIO.read(ackbuf, ACK_LEN); if(len == ACK_LEN) { got_strobe_ack = 1; @@ -1088,22 +1044,16 @@ send_announcement(void *ptr) for(i = 0; i < CCA_COUNT_MAX; ++i) { t = RTIMER_NOW(); on(); -#if NURTIMER - while(RTIMER_CLOCK_LT(t, RTIMER_NOW(), t + CCA_CHECK_TIME)); -#else while(RTIMER_CLOCK_LT(RTIMER_NOW(), t + CCA_CHECK_TIME)); -#endif + if(NETSTACK_RADIO.channel_clear() == 0) { collisions++; off(); break; } off(); -#if NURTIMER - while(RTIMER_CLOCK_LT(t0, RTIMER_NOW(), t + CCA_SLEEP_TIME + CCA_CHECK_TIME)); -#else while(RTIMER_CLOCK_LT(RTIMER_NOW(), t + CCA_SLEEP_TIME + CCA_CHECK_TIME)) { } -#endif + } if(collisions == 0) { @@ -1112,11 +1062,8 @@ send_announcement(void *ptr) NETSTACK_RADIO.transmit(transmit_len); t = RTIMER_NOW(); -#if NURTIMER - while(RTIMER_CLOCK_LT(t, RTIMER_NOW(), t + INTER_PACKET_INTERVAL)); -#else while(RTIMER_CLOCK_LT(RTIMER_NOW(), t + INTER_PACKET_INTERVAL)) { } -#endif + NETSTACK_RADIO.transmit(transmit_len); } we_are_sending = 0; @@ -1158,15 +1105,8 @@ init(void) { radio_is_on = 0; PT_INIT(&pt); -#if NURTIMER - rtimer_setup(&rt, RTIMER_HARD, - (void (*)(struct rtimer *, void *, int status))powercycle, - NULL); - rtimer_schedule(&rt, CYCLE_TIME, 1); -#else rtimer_set(&rt, RTIMER_NOW() + CYCLE_TIME, 1, (void (*)(struct rtimer *, void *))powercycle, NULL); -#endif contikimac_is_on = 1; @@ -1187,12 +1127,8 @@ turn_on(void) if(contikimac_is_on == 0) { contikimac_is_on = 1; contikimac_keep_radio_on = 0; -#if NURTIMER - rtimer_schedule(&rt, CYCLE_TIME, 1); -#else rtimer_set(&rt, RTIMER_NOW() + CYCLE_TIME, 1, (void (*)(struct rtimer *, void *))powercycle, NULL); -#endif } return 1; } From 74f1754d88a5a05bdecf09041f17ad0e4695e7ec Mon Sep 17 00:00:00 2001 From: Adam Dunkels Date: Wed, 13 Apr 2011 14:10:39 +0200 Subject: [PATCH 17/18] Bugfix: energy consumption for retransmissions was miscounted --- core/net/mac/csma.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/net/mac/csma.c b/core/net/mac/csma.c index 6a82e3717..e2776e35d 100644 --- a/core/net/mac/csma.c +++ b/core/net/mac/csma.c @@ -241,6 +241,13 @@ packet_sent(void *ptr, int status, int num_transmissions) PRINTF("csma: retransmitting with time %lu %p\n", time, q); ctimer_set(&transmit_timer, time, transmit_queued_packet, NULL); + + /* This is needed to correctly attribute energy that we spent + transmitting this packet. */ + q = list_head(queued_packet_list); + queuebuf_free(q->buf); + q->buf = queuebuf_new_from_packetbuf(); + } else { PRINTF("csma: drop with status %d after %d transmissions, %d collisions\n", status, q->transmissions, q->collisions); From 813489633c6dd34f3b27026b19bd786ca1d115bc Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Fri, 15 Apr 2011 15:49:43 +0200 Subject: [PATCH 18/18] Added missing include --- cpu/msp430/dev/uart0x.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cpu/msp430/dev/uart0x.c b/cpu/msp430/dev/uart0x.c index bb452e674..f8abd5b3b 100644 --- a/cpu/msp430/dev/uart0x.c +++ b/cpu/msp430/dev/uart0x.c @@ -34,6 +34,7 @@ */ #include +#include #include #include "sys/energest.h"