From 12860ce5d4171b9910d17614aa9dece1f9f59959 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Wed, 20 Mar 2013 19:53:26 +0000 Subject: [PATCH 1/4] Fix #183 (short term fix) This is a temporary fix for #183, so that things can build cleanly until the issue is fixed properly. If RIMESTATS_CONF_ENABLED is 0, rimestats.foo will always read as 0, since RIMESTATS_ADD(foo) doesn't do anything --- core/net/rime/rimestats.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/net/rime/rimestats.h b/core/net/rime/rimestats.h index 607aa78ad..d40c9b684 100644 --- a/core/net/rime/rimestats.h +++ b/core/net/rime/rimestats.h @@ -55,8 +55,9 @@ struct rimestats { unsigned long lltx, llrx; }; -#if RIMESTATS_CONF_ENABLED extern struct rimestats rimestats; + +#if RIMESTATS_CONF_ENABLED #define RIMESTATS_ADD(x) rimestats.x++ #else /* RIMESTATS_CONF_ENABLED */ #define RIMESTATS_ADD(x) From 62366813b06f97ba4aafca52cd6d2a33cef97cc5 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Wed, 20 Mar 2013 21:05:19 +0000 Subject: [PATCH 2/4] Provide a macro to read rimestats when enabled --- core/net/rime/rimestats.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/net/rime/rimestats.h b/core/net/rime/rimestats.h index d40c9b684..abdc509de 100644 --- a/core/net/rime/rimestats.h +++ b/core/net/rime/rimestats.h @@ -55,12 +55,15 @@ struct rimestats { unsigned long lltx, llrx; }; +#if RIMESTATS_CONF_ENABLED +/* Don't access this variable directly, use RIMESTATS_ADD and RIMESTATS_GET */ extern struct rimestats rimestats; -#if RIMESTATS_CONF_ENABLED #define RIMESTATS_ADD(x) rimestats.x++ +#define RIMESTATS_GET(x) rimestats.x #else /* RIMESTATS_CONF_ENABLED */ #define RIMESTATS_ADD(x) +#define RIMESTATS_GET(x) 0 #endif /* RIMESTATS_CONF_ENABLED */ #endif /* __RIMESTATS_H__ */ From 8c0cf50dca3cf96a7f58fc77c2ccc5c4860cd671 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Wed, 20 Mar 2013 21:04:36 +0000 Subject: [PATCH 3/4] Rename RIMESTATS_CONF_ON to RIMESTATS_CONF_ENABLED --- apps/webserver-nano/httpd-cgi.c | 4 ++-- platform/avr-atmega128rfa1/contiki-conf.h | 2 +- platform/avr-raven/contiki-conf.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/webserver-nano/httpd-cgi.c b/apps/webserver-nano/httpd-cgi.c index de0b8c675..feff68aaa 100644 --- a/apps/webserver-nano/httpd-cgi.c +++ b/apps/webserver-nano/httpd-cgi.c @@ -856,7 +856,7 @@ generate_stats(void *arg) } #endif -#if RIMESTATS_CONF_ON +#if RIMESTATS_CONF_ENABLED #include "net/rime/rimestats.h" static const char httpd_cgi_sensor21[] HTTPD_STRING_ATTR = "Packets (RIMESTATS): Tx=%5lu Rx=%5lu TxL=%4lu RxL=%4lu\n"; numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor21, @@ -1295,7 +1295,7 @@ static uint16_t c0=0x3ff,c1=0x3ff,c2=0x3ff,c3=0x3ff,c4=0x3ff,c5=0x3ff,c6=0x3ff,c } #endif -#if RIMESTATS_CONF_ON +#if RIMESTATS_CONF_ENABLED #include "net/rime/rimestats.h" static const char httpd_cgi_ajaxr1[] HTTPD_STRING_ATTR ="rime(%lu,%lu,%lu,%lu);"; diff --git a/platform/avr-atmega128rfa1/contiki-conf.h b/platform/avr-atmega128rfa1/contiki-conf.h index aeec6959a..bf561ff31 100644 --- a/platform/avr-atmega128rfa1/contiki-conf.h +++ b/platform/avr-atmega128rfa1/contiki-conf.h @@ -244,7 +244,7 @@ typedef unsigned short uip_stats_t; /* Not tested much yet */ #define WITH_PHASE_OPTIMIZATION 0 #define CONTIKIMAC_CONF_COMPOWER 1 -#define RIMESTATS_CONF_ON 1 +#define RIMESTATS_CONF_ENABLED 1 #define NETSTACK_CONF_FRAMER framer_802154 #define NETSTACK_CONF_RADIO rf230_driver #define CHANNEL_802_15_4 26 diff --git a/platform/avr-raven/contiki-conf.h b/platform/avr-raven/contiki-conf.h index 733b3cacb..e41aa6f1e 100644 --- a/platform/avr-raven/contiki-conf.h +++ b/platform/avr-raven/contiki-conf.h @@ -254,7 +254,7 @@ typedef unsigned short uip_stats_t; /* Not tested much yet */ #define WITH_PHASE_OPTIMIZATION 0 #define CONTIKIMAC_CONF_COMPOWER 1 -#define RIMESTATS_CONF_ON 1 +#define RIMESTATS_CONF_ENABLED 1 #define NETSTACK_CONF_FRAMER framer_802154 #define NETSTACK_CONF_RADIO rf230_driver #define CHANNEL_802_15_4 26 From db078cf7e8392a1eb1609999711f2bc1a56c2430 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Wed, 20 Mar 2013 21:08:47 +0000 Subject: [PATCH 4/4] Replace reads of rimestats with RIMESTATS_GET(x) --- apps/webserver-nano/httpd-cgi.c | 6 ++-- core/lib/print-stats.c | 16 +++++----- examples/cc2530dk/udp-ipv6/project-conf.h | 1 + examples/cc2530dk/udp-ipv6/server.c | 8 ++--- examples/sensinode/broadcast-rime.c | 12 ++++---- examples/sensinode/udp-ipv6/project-conf.h | 1 + examples/sensinode/udp-ipv6/server.c | 8 ++--- examples/sky/sky-collect.c | 36 +++++++++++----------- 8 files changed, 45 insertions(+), 43 deletions(-) diff --git a/apps/webserver-nano/httpd-cgi.c b/apps/webserver-nano/httpd-cgi.c index feff68aaa..cf85697ec 100644 --- a/apps/webserver-nano/httpd-cgi.c +++ b/apps/webserver-nano/httpd-cgi.c @@ -860,7 +860,7 @@ generate_stats(void *arg) #include "net/rime/rimestats.h" static const char httpd_cgi_sensor21[] HTTPD_STRING_ATTR = "Packets (RIMESTATS): Tx=%5lu Rx=%5lu TxL=%4lu RxL=%4lu\n"; numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensor21, - rimestats.tx,rimestats.rx,rimestats.lltx-rimestats.tx,rimestats.llrx-rimestats.rx); + RIMESTATS_GET(tx),RIMESTATS_GET(rx),RIMESTATS_GET(lltx)-RIMESTATS_GET(tx),RIMESTATS_GET(llrx)-RIMESTATS_GET(rx)); #endif #if RADIOSTATS @@ -1300,7 +1300,7 @@ static uint16_t c0=0x3ff,c1=0x3ff,c2=0x3ff,c3=0x3ff,c4=0x3ff,c5=0x3ff,c6=0x3ff,c #include "net/rime/rimestats.h" static const char httpd_cgi_ajaxr1[] HTTPD_STRING_ATTR ="rime(%lu,%lu,%lu,%lu);"; numprinted += httpd_snprintf(buf+numprinted, sizeof(buf)-numprinted,httpd_cgi_ajaxr1, - rimestats.tx,rimestats.rx,rimestats.lltx-rimestats.tx,rimestats.llrx-rimestats.rx); + RIMESTATS_GET(tx),RIMESTATS_GET(rx),RIMESTATS_GET(lltx)-RIMESTATS_GET(tx),RIMESTATS_GET(llrx)-RIMESTATS_GET(rx)); #endif #if ENERGEST_CONF_ON @@ -1498,4 +1498,4 @@ uint8_t httpd_cgi_sprint_ip6(uip_ip6addr_t addr, char * result) return (result - starting); } -#endif /* WEBSERVER_CONF_PRINTADDR */ \ No newline at end of file +#endif /* WEBSERVER_CONF_PRINTADDR */ diff --git a/core/lib/print-stats.c b/core/lib/print-stats.c index 6354cf7e3..ce7b0dddf 100644 --- a/core/lib/print-stats.c +++ b/core/lib/print-stats.c @@ -59,14 +59,14 @@ print_stats(void) PRINTA("S %d.%d clock %lu tx %lu rx %lu rtx %lu rrx %lu rexmit %lu acktx %lu noacktx %lu ackrx %lu timedout %lu badackrx %lu toolong %lu tooshort %lu badsynch %lu badcrc %lu contentiondrop %lu sendingdrop %lu lltx %lu llrx %lu\n", rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1], clock_seconds(), - rimestats.tx, rimestats.rx, - rimestats.reliabletx, rimestats.reliablerx, - rimestats.rexmit, rimestats.acktx, rimestats.noacktx, - rimestats.ackrx, rimestats.timedout, rimestats.badackrx, - rimestats.toolong, rimestats.tooshort, - rimestats.badsynch, rimestats.badcrc, - rimestats.contentiondrop, rimestats.sendingdrop, - rimestats.lltx, rimestats.llrx); + RIMESTATS_GET(tx), RIMESTATS_GET(rx), + RIMESTATS_GET(reliabletx), RIMESTATS_GET(reliablerx), + RIMESTATS_GET(rexmit), RIMESTATS_GET(acktx), RIMESTATS_GET(noacktx), + RIMESTATS_GET(ackrx), RIMESTATS_GET(timedout), RIMESTATS_GET(badackrx), + RIMESTATS_GET(toolong), RIMESTATS_GET(tooshort), + RIMESTATS_GET(badsynch), RIMESTATS_GET(badcrc), + RIMESTATS_GET(contentiondrop), RIMESTATS_GET(sendingdrop), + RIMESTATS_GET(lltx), RIMESTATS_GET(llrx)); #endif /* RIMESTATS_CONF_ENABLED */ #if ENERGEST_CONF_ON PRINTA("E %d.%d clock %lu cpu %lu lpm %lu irq %lu gled %lu yled %lu rled %lu tx %lu listen %lu sensors %lu serial %lu\n", diff --git a/examples/cc2530dk/udp-ipv6/project-conf.h b/examples/cc2530dk/udp-ipv6/project-conf.h index 7df716ebd..fb37ebfc3 100644 --- a/examples/cc2530dk/udp-ipv6/project-conf.h +++ b/examples/cc2530dk/udp-ipv6/project-conf.h @@ -44,5 +44,6 @@ #define BUTTON_SENSOR_CONF_ON 1 #define UIP_CONF_ICMP6 1 +#define RIMESTATS_CONF_ENABLED 1 #endif /* PROJECT_CONF_H_ */ diff --git a/examples/cc2530dk/udp-ipv6/server.c b/examples/cc2530dk/udp-ipv6/server.c index ae8c3d65c..f341472e9 100644 --- a/examples/cc2530dk/udp-ipv6/server.c +++ b/examples/cc2530dk/udp-ipv6/server.c @@ -92,10 +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_GET(toolong), RIMESTATS_GET(tooshort), + RIMESTATS_GET(badsynch), RIMESTATS_GET(badcrc)); + PRINTF("llrx=%lu, lltx=%lu, rx=%lu, tx=%lu\n", RIMESTATS_GET(llrx), + RIMESTATS_GET(lltx), RIMESTATS_GET(rx), RIMESTATS_GET(tx)); } #endif /*---------------------------------------------------------------------------*/ diff --git a/examples/sensinode/broadcast-rime.c b/examples/sensinode/broadcast-rime.c index c6beab0d2..dd6b96867 100644 --- a/examples/sensinode/broadcast-rime.c +++ b/examples/sensinode/broadcast-rime.c @@ -36,7 +36,6 @@ * \author * Adam Dunkels */ - #include "contiki.h" #include "net/rime.h" #include "lib/random.h" @@ -72,11 +71,12 @@ 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); + PRINTF(" TX=%lu , RX=%lu\n", RIMESTATS_GET(tx), RIMESTATS_GET(rx)); + PRINTF("LL-TX=%lu , LL-RX=%lu\n", RIMESTATS_GET(lltx), RIMESTATS_GET(llrx)); + PRINTF(" Long=%lu , Short=%lu\n", RIMESTATS_GET(toolong), + RIMESTATS_GET(tooshort)); + PRINTF("T/Out=%lu , CCA-Err=%lu\n", RIMESTATS_GET(timedout), + RIMESTATS_GET(contentiondrop)); } static const struct broadcast_callbacks bc_rx = { broadcast_recv }; diff --git a/examples/sensinode/udp-ipv6/project-conf.h b/examples/sensinode/udp-ipv6/project-conf.h index fafe10a2f..17dd8fe8b 100644 --- a/examples/sensinode/udp-ipv6/project-conf.h +++ b/examples/sensinode/udp-ipv6/project-conf.h @@ -45,5 +45,6 @@ #define PROJECT_CONF_H_ #define BUTTON_SENSOR_CONF_ON 1 +#define RIMESTATS_CONF_ENABLED 1 #endif /* PROJECT_CONF_H_ */ diff --git a/examples/sensinode/udp-ipv6/server.c b/examples/sensinode/udp-ipv6/server.c index e7346cebf..d569d1102 100644 --- a/examples/sensinode/udp-ipv6/server.c +++ b/examples/sensinode/udp-ipv6/server.c @@ -104,10 +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_GET(toolong), RIMESTATS_GET(tooshort), + RIMESTATS_GET(badsynch), RIMESTATS_GET(badcrc)); + PRINTF("llrx=%lu, lltx=%lu, rx=%lu, tx=%lu\n", RIMESTATS_GET(llrx), + RIMESTATS_GET(lltx), RIMESTATS_GET(rx), RIMESTATS_GET(tx)); } #else #define print_stats() diff --git a/examples/sky/sky-collect.c b/examples/sky/sky-collect.c index 25ce36f33..5bcd1af8b 100644 --- a/examples/sky/sky-collect.c +++ b/examples/sky/sky-collect.c @@ -246,24 +246,24 @@ PROCESS_THREAD(test_collect_process, ev, data) msg->best_neighbor_rtmetric = n->rtmetric; } - msg->tx = rimestats.tx; - msg->rx = rimestats.rx; - msg->reliabletx = rimestats.reliabletx; - msg->reliablerx = rimestats.reliablerx; - msg->rexmit = rimestats.rexmit; - msg->acktx = rimestats.acktx; - msg->noacktx = rimestats.noacktx; - msg->ackrx = rimestats.ackrx; - msg->timedout = rimestats.timedout; - msg->badackrx = rimestats.badackrx; - msg->toolong = rimestats.toolong; - msg->tooshort = rimestats.tooshort; - msg->badsynch = rimestats.badsynch; - msg->badcrc = rimestats.badcrc; - msg->contentiondrop = rimestats.contentiondrop; - msg->sendingdrop = rimestats.sendingdrop; - msg->lltx = rimestats.lltx; - msg->llrx = rimestats.llrx; + msg->tx = RIMESTATS_GET(tx); + msg->rx = RIMESTATS_GET(rx); + msg->reliabletx = RIMESTATS_GET(reliabletx); + msg->reliablerx = RIMESTATS_GET(reliablerx); + msg->rexmit = RIMESTATS_GET(rexmit); + msg->acktx = RIMESTATS_GET(acktx); + msg->noacktx = RIMESTATS_GET(noacktx); + msg->ackrx = RIMESTATS_GET(ackrx); + msg->timedout = RIMESTATS_GET(timedout); + msg->badackrx = RIMESTATS_GET(badackrx); + msg->toolong = RIMESTATS_GET(toolong); + msg->tooshort = RIMESTATS_GET(tooshort); + msg->badsynch = RIMESTATS_GET(badsynch); + msg->badcrc = RIMESTATS_GET(badcrc); + msg->contentiondrop = RIMESTATS_GET(contentiondrop); + msg->sendingdrop = RIMESTATS_GET(sendingdrop); + msg->lltx = RIMESTATS_GET(lltx); + msg->llrx = RIMESTATS_GET(llrx); #if TIMESYNCH_CONF_ENABLED msg->timestamp = timesynch_time(); #else