From 8078ef7705454527fac329dde96c20341dee6b7e Mon Sep 17 00:00:00 2001 From: nvt Date: Thu, 17 Mar 2011 20:21:56 +0100 Subject: [PATCH 1/7] ROOT_RANK is now a macro function. --- core/net/rpl/rpl-timers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/net/rpl/rpl-timers.c b/core/net/rpl/rpl-timers.c index 7c039712b..aa5e6d086 100644 --- a/core/net/rpl/rpl-timers.c +++ b/core/net/rpl/rpl-timers.c @@ -112,7 +112,7 @@ new_dio_interval(rpl_dag_t *dag) dag->version, dag->dio_totint, dag->dio_totsend, dag->dio_totrecv,dag->dio_intcurrent, - dag->rank == ROOT_RANK ? "BLUE" : "ORANGE"); + dag->rank == ROOT_RANK(dag) ? "BLUE" : "ORANGE"); #endif /* RPL_CONF_STATS */ /* reset the redundancy counter */ From 55c4df8ee782a8aa018e468e4a4e786a8a1c7eed Mon Sep 17 00:00:00 2001 From: nvt Date: Thu, 17 Mar 2011 20:29:38 +0100 Subject: [PATCH 2/7] Slight generalization to make it easier to switch metric. --- core/net/neighbor-info.c | 56 ++++++++++++++++++++-------------------- core/net/neighbor-info.h | 3 ++- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/core/net/neighbor-info.c b/core/net/neighbor-info.c index aa9424978..c36a2b8a5 100644 --- a/core/net/neighbor-info.c +++ b/core/net/neighbor-info.c @@ -48,38 +48,38 @@ #define ETX_ALPHA 90 #define ETX_NOACK_PENALTY ETX_LIMIT /*---------------------------------------------------------------------------*/ -NEIGHBOR_ATTRIBUTE(uint8_t, etx, NULL); +NEIGHBOR_ATTRIBUTE(link_metric_t, etx, NULL); static neighbor_info_subscriber_t subscriber_callback; /*---------------------------------------------------------------------------*/ static void -update_etx(const rimeaddr_t *dest, int packet_etx) +update_metric(const rimeaddr_t *dest, int packet_metric) { - uint8_t *etxp; - uint8_t recorded_etx, new_etx; + link_metric_t *metricp; + link_metric_t recorded_metric, new_metric; - etxp = (uint8_t *)neighbor_attr_get_data(&etx, dest); - packet_etx = NEIGHBOR_INFO_ETX2FIX(packet_etx); - if(etxp == NULL || *etxp == 0) { - recorded_etx = NEIGHBOR_INFO_ETX2FIX(ETX_LIMIT); - new_etx = packet_etx; + metricp = (link_metric_t *)neighbor_attr_get_data(&etx, dest); + packet_metric = NEIGHBOR_INFO_ETX2FIX(packet_metric); + if(metricp == NULL || *metricp == 0) { + recorded_metric = NEIGHBOR_INFO_ETX2FIX(ETX_LIMIT); + new_metric = packet_metric; } else { - recorded_etx = *etxp; + recorded_metric = *metricp; /* Update the EWMA of the ETX for the neighbor. */ - new_etx = ((uint16_t)recorded_etx * ETX_ALPHA + - (uint16_t)packet_etx * (ETX_SCALE - ETX_ALPHA)) / ETX_SCALE; + new_metric = ((uint16_t)recorded_metric * ETX_ALPHA + + (uint16_t)packet_metric * (ETX_SCALE - ETX_ALPHA)) / ETX_SCALE; } PRINTF("neighbor-info: ETX changed from %d to %d (packet ETX = %d) %d\n", - NEIGHBOR_INFO_FIX2ETX(recorded_etx), - NEIGHBOR_INFO_FIX2ETX(new_etx), - NEIGHBOR_INFO_FIX2ETX(packet_etx), + NEIGHBOR_INFO_FIX2ETX(recorded_metric), + NEIGHBOR_INFO_FIX2ETX(new_metric), + NEIGHBOR_INFO_FIX2ETX(packet_metric), dest->u8[7]); if(neighbor_attr_has_neighbor(dest)) { - neighbor_attr_set_data(&etx, dest, &new_etx); - if(new_etx != recorded_etx && subscriber_callback != NULL) { - subscriber_callback(dest, 1, new_etx); + neighbor_attr_set_data(&etx, dest, &new_metric); + if(new_metric != recorded_metric && subscriber_callback != NULL) { + subscriber_callback(dest, 1, new_metric); } } } @@ -103,7 +103,7 @@ void neighbor_info_packet_sent(int status, int numtx) { const rimeaddr_t *dest; - uint8_t packet_etx; + link_metric_t packet_metric; dest = packetbuf_addr(PACKETBUF_ADDR_RECEIVER); if(rimeaddr_cmp(dest, &rimeaddr_null)) { @@ -116,14 +116,14 @@ neighbor_info_packet_sent(int status, int numtx) switch(status) { case MAC_TX_OK: - packet_etx = numtx; + packet_metric = numtx; add_neighbor(dest); break; case MAC_TX_COLLISION: - packet_etx = numtx; + packet_metric = numtx; break; case MAC_TX_NOACK: - packet_etx = ETX_NOACK_PENALTY; + packet_metric = ETX_NOACK_PENALTY; break; default: /* Do not penalize the ETX when collisions or transmission @@ -131,7 +131,7 @@ neighbor_info_packet_sent(int status, int numtx) return; } - update_etx(dest, packet_etx); + update_metric(dest, packet_metric); } /*---------------------------------------------------------------------------*/ void @@ -162,12 +162,12 @@ neighbor_info_subscribe(neighbor_info_subscriber_t s) return 0; } /*---------------------------------------------------------------------------*/ -uint8_t -neighbor_info_get_etx(const rimeaddr_t *addr) +link_metric_t +neighbor_info_get_metric(const rimeaddr_t *addr) { - uint8_t *etxp; + link_metric_t *metricp; - etxp = (uint8_t *)neighbor_attr_get_data(&etx, addr); - return etxp == NULL ? ETX_LIMIT : *etxp; + metricp = (link_metric_t *)neighbor_attr_get_data(&etx, addr); + return metricp == NULL ? ETX_LIMIT : *metricp; } /*---------------------------------------------------------------------------*/ diff --git a/core/net/neighbor-info.h b/core/net/neighbor-info.h index 09dd84ed4..f292c2ef1 100644 --- a/core/net/neighbor-info.h +++ b/core/net/neighbor-info.h @@ -52,6 +52,7 @@ #define NEIGHBOR_INFO_FIX2ETX(fix) ((fix) / NEIGHBOR_INFO_ETX_DIVISOR) typedef void (*neighbor_info_subscriber_t)(const rimeaddr_t *, int known, int etx); +typedef uint8_t link_metric_t; /** * Notify the neighbor information module about the status of @@ -85,6 +86,6 @@ int neighbor_info_subscribe(neighbor_info_subscriber_t); * * \return Returns ETX if the neighbor exists, and 0 if not. */ -uint8_t neighbor_info_get_etx(const rimeaddr_t *addr); +link_metric_t neighbor_info_get_etx(const rimeaddr_t *addr); #endif /* NEIGHBOR_INFO_H */ From 46cffcf114b061677ace5450cbcf9a739cad20b3 Mon Sep 17 00:00:00 2001 From: Nicolas Tsiftes Date: Mon, 21 Mar 2011 09:17:54 +0100 Subject: [PATCH 3/7] Made it possible to access the results externally. --- apps/unit-test/unit-test.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/unit-test/unit-test.h b/apps/unit-test/unit-test.h index d11747cb0..e12fff50d 100644 --- a/apps/unit-test/unit-test.h +++ b/apps/unit-test/unit-test.h @@ -174,6 +174,17 @@ typedef struct unit_test { } \ } while(0) +/** + * Obtain the result of a certain unit test. + * + * If the unit test has not yet been executed, this macro returns + * unit_test_failed. Otherwise it returns the result of the last + * execution of the unit test. + * + * \param name The name of the unit test. + */ +#define UNIT_TEST_RESULT(name) (unit_test_##name.result) + /* The default print function. */ void unit_test_print_report(const unit_test_t *utp); From d8d94d0cd8398bec8d250f460eab738a65c61be6 Mon Sep 17 00:00:00 2001 From: Fredrik Osterlind Date: Mon, 21 Mar 2011 14:14:16 +0100 Subject: [PATCH 4/7] bugfix in writing tinyos addresses --- .../cooja/mspmote/interfaces/MspMoteID.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspMoteID.java b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspMoteID.java index 66e767511..0c8f61ce3 100644 --- a/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspMoteID.java +++ b/tools/cooja/apps/mspsim/src/se/sics/cooja/mspmote/interfaces/MspMoteID.java @@ -109,6 +109,34 @@ public class MspMoteID extends MoteID { } }); } + if (moteMem.variableExists("ActiveMessageAddressC__addr")) { + this.mote.getCPU().setBreakPoint(moteMem.getVariableAddress("ActiveMessageAddressC__addr"), new CPUMonitor() { + public void cpuAction(int type, int adr, int data) { + if (type != MEMORY_WRITE) { + return; + } + if (data == moteID) { + return; + } + Simulation s = mote.getSimulation(); + s.scheduleEvent(writeIDEvent, s.getSimulationTime()); + } + }); + } + if (moteMem.variableExists("ActiveMessageAddressC$addr")) { + this.mote.getCPU().setBreakPoint(moteMem.getVariableAddress("ActiveMessageAddressC$addr"), new CPUMonitor() { + public void cpuAction(int type, int adr, int data) { + if (type != MEMORY_WRITE) { + return; + } + if (data == moteID) { + return; + } + Simulation s = mote.getSimulation(); + s.scheduleEvent(writeIDEvent, s.getSimulationTime()); + } + }); + } } public int getMoteID() { From 5dd7500d0b3f2e3046df98802d6727c2a9bfaf6e Mon Sep 17 00:00:00 2001 From: dak664 Date: Mon, 21 Mar 2011 11:10:30 -0400 Subject: [PATCH 5/7] Add configurable auto cca threshold and implement driver cca call. Show smallest rssi in jackdaw menu. --- .../radio/rf230bb/atmega128rfa1_registermap.h | 6 +++ cpu/avr/radio/rf230bb/rf230bb.c | 39 ++++++++++++++++--- cpu/avr/radio/rf230bb/rf230bb.h | 5 +-- platform/avr-ravenusb/cdc_task.c | 7 +++- platform/avr-ravenusb/contiki-conf.h | 7 +++- 5 files changed, 53 insertions(+), 11 deletions(-) diff --git a/cpu/avr/radio/rf230bb/atmega128rfa1_registermap.h b/cpu/avr/radio/rf230bb/atmega128rfa1_registermap.h index 0c7bd53cb..3edd23cab 100644 --- a/cpu/avr/radio/rf230bb/atmega128rfa1_registermap.h +++ b/cpu/avr/radio/rf230bb/atmega128rfa1_registermap.h @@ -73,6 +73,12 @@ #define RG_CSMA_BE CSMA_BE #define RG_CSMA_SEED_0 CSMA_SEED_0 #define RG_PHY_RSSI PHY_RSSI +#define SR_CCA_MODE 0x08, 0x60, 5 +//#define SR_CCA_CS_THRES 0x09, 0xf0, 4 +#define SR_CCA_ED_THRES 0x09, 0x0f, 0 +#define SR_CCA_REQUEST 0x08, 0x80, 7 +#define SR_CCA_DONE 0x01, 0x80, 7 +#define SR_CCA_STATUS 0x01, 0x40, 6 /* RF230 register assignments, for reference */ diff --git a/cpu/avr/radio/rf230bb/rf230bb.c b/cpu/avr/radio/rf230bb/rf230bb.c index 19aa8b253..9ee74f3f5 100644 --- a/cpu/avr/radio/rf230bb/rf230bb.c +++ b/cpu/avr/radio/rf230bb/rf230bb.c @@ -209,8 +209,7 @@ static int rf230_receiving_packet(void); static int pending_packet(void); static int rf230_cca(void); -signed char rf230_last_rssi; -uint8_t rf230_last_correlation; +uint8_t rf230_last_correlation,rf230_last_rssi,rf230_smallest_rssi; const struct radio_driver rf230_driver = { @@ -714,6 +713,24 @@ rf230_init(void) hal_register_write(RG_CSMA_SEED_0,hal_register_read(RG_PHY_RSSI) );//upper two RSSI reg bits RND_VALUE are random in rf231 // hal_register_write(CSMA_SEED_1,42 ); + /* CCA Mode Mode 1=Energy above threshold 2=Carrier sense only 3=Both 0=Either (RF231 only) */ +//hal_subregister_write(SR_CCA_MODE,1); //1 is the power-on default + + /* Carrier sense threshold (not implemented in RF230 or RF231) */ +// hal_subregister_write(SR_CCA_CS_THRES,1); + + /* 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 */ +#if RF230_CONF_CCA_THRES < -91 +#warning RF230_CONF_CCA_THRES below hardware limit, setting to -91dBm + hal_subregister_write(SR_CCA_ED_THRES,0); +#elif RF230_CONF_CCA_THRES > -61 +#warning RF230_CONF_CCA_THRES above hardware limit, setting to -61dBm + hal_subregister_write(SR_CCA_ED_THRES,15); +#else + hal_subregister_write(SR_CCA_ED_THRES,(RF230_CONF_CCA_THRES+91)/2); +#endif + /* Use automatic CRC unless manual is specified */ #if RF230_CONF_CHECKSUM hal_subregister_write(SR_TX_AUTO_CRC_ON, 0); @@ -883,7 +900,6 @@ rf230_transmit(unsigned short payload_len) } RELEASE_LOCK(); - if (tx_result==1) { //success, data pending from adressee tx_result=0; //Just show success? } else if (tx_result==3) { //CSMA channel access failure @@ -1332,6 +1348,10 @@ if (RF230_receive_on) { #endif #endif /* speed vs. generality */ + /* Save the smallest rssi. The display routine can reset by setting it to zero */ + if ((rf230_smallest_rssi==0) || (rf230_last_rssi Date: Mon, 21 Mar 2011 21:28:43 +0100 Subject: [PATCH 6/7] Made energest configuration configurable --- platform/sky/contiki-conf.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/sky/contiki-conf.h b/platform/sky/contiki-conf.h index 8eeda6a22..fb4af671d 100644 --- a/platform/sky/contiki-conf.h +++ b/platform/sky/contiki-conf.h @@ -95,7 +95,9 @@ #define SHELL_VARS_CONF_RAM_END 0x2000 #define PROFILE_CONF_ON 0 +#ifndef ENERGEST_CONF_ON #define ENERGEST_CONF_ON 1 +#endif /* ENERGEST_CONF_ON */ #define ELFLOADER_CONF_TEXT_IN_ROM 0 #ifndef ELFLOADER_CONF_DATAMEMORY_SIZE From 6457f765b34dbf30a3632d0c01e101d4ab1b1f70 Mon Sep 17 00:00:00 2001 From: Niclas Finne Date: Mon, 21 Mar 2011 21:39:45 +0100 Subject: [PATCH 7/7] Do not include ant runtime in classpath (avoids compilation warning with Ant 1.8+) --- tools/coffee-manager/build.xml | 2 +- tools/cooja/apps/avrora/build.xml | 3 ++- tools/cooja/apps/mrm/build.xml | 3 ++- tools/cooja/apps/mspsim/build.xml | 3 ++- tools/cooja/apps/native_gateway/build.xml | 3 ++- tools/cooja/apps/serial_socket/build.xml | 2 +- tools/cooja/build.xml | 5 +++-- tools/cooja/examples/appmote_rimeabc/build.xml | 2 +- tools/cooja/examples/project_new_interface/build.xml | 3 ++- tools/cooja/examples/project_new_plugin/build.xml | 3 ++- tools/cooja/examples/project_new_radiomedium/build.xml | 3 ++- 11 files changed, 20 insertions(+), 12 deletions(-) diff --git a/tools/coffee-manager/build.xml b/tools/coffee-manager/build.xml index cd082759e..0712f73c6 100644 --- a/tools/coffee-manager/build.xml +++ b/tools/coffee-manager/build.xml @@ -7,7 +7,7 @@ - + diff --git a/tools/cooja/apps/avrora/build.xml b/tools/cooja/apps/avrora/build.xml index 2b6d83033..32e4dcf26 100644 --- a/tools/cooja/apps/avrora/build.xml +++ b/tools/cooja/apps/avrora/build.xml @@ -23,7 +23,8 @@ - + diff --git a/tools/cooja/apps/mrm/build.xml b/tools/cooja/apps/mrm/build.xml index b9049eeb7..0b4e7dd65 100644 --- a/tools/cooja/apps/mrm/build.xml +++ b/tools/cooja/apps/mrm/build.xml @@ -12,7 +12,8 @@ - + diff --git a/tools/cooja/apps/mspsim/build.xml b/tools/cooja/apps/mspsim/build.xml index d877f4e7a..e1b5dac71 100644 --- a/tools/cooja/apps/mspsim/build.xml +++ b/tools/cooja/apps/mspsim/build.xml @@ -36,7 +36,8 @@ - + diff --git a/tools/cooja/apps/native_gateway/build.xml b/tools/cooja/apps/native_gateway/build.xml index 1dbfa8bd3..a290a3d8c 100644 --- a/tools/cooja/apps/native_gateway/build.xml +++ b/tools/cooja/apps/native_gateway/build.xml @@ -23,7 +23,8 @@ Requires pre-installation of Jpcap and (Windows-only) WinPcap. - + diff --git a/tools/cooja/apps/serial_socket/build.xml b/tools/cooja/apps/serial_socket/build.xml index 0872d8d59..7164eb260 100644 --- a/tools/cooja/apps/serial_socket/build.xml +++ b/tools/cooja/apps/serial_socket/build.xml @@ -10,7 +10,7 @@ - + diff --git a/tools/cooja/build.xml b/tools/cooja/build.xml index f57d0f82a..96bdf532d 100644 --- a/tools/cooja/build.xml +++ b/tools/cooja/build.xml @@ -68,7 +68,8 @@ The COOJA Simulator - + @@ -189,7 +190,7 @@ The COOJA Simulator - + diff --git a/tools/cooja/examples/appmote_rimeabc/build.xml b/tools/cooja/examples/appmote_rimeabc/build.xml index 7ca5753d2..06dd4c1d4 100644 --- a/tools/cooja/examples/appmote_rimeabc/build.xml +++ b/tools/cooja/examples/appmote_rimeabc/build.xml @@ -9,7 +9,7 @@ - + diff --git a/tools/cooja/examples/project_new_interface/build.xml b/tools/cooja/examples/project_new_interface/build.xml index 4df9641b3..b0a765559 100644 --- a/tools/cooja/examples/project_new_interface/build.xml +++ b/tools/cooja/examples/project_new_interface/build.xml @@ -13,7 +13,8 @@ - + diff --git a/tools/cooja/examples/project_new_plugin/build.xml b/tools/cooja/examples/project_new_plugin/build.xml index 8143949c7..7b3e78e58 100644 --- a/tools/cooja/examples/project_new_plugin/build.xml +++ b/tools/cooja/examples/project_new_plugin/build.xml @@ -13,7 +13,8 @@ - + diff --git a/tools/cooja/examples/project_new_radiomedium/build.xml b/tools/cooja/examples/project_new_radiomedium/build.xml index 7e89b0427..81b0174bb 100644 --- a/tools/cooja/examples/project_new_radiomedium/build.xml +++ b/tools/cooja/examples/project_new_radiomedium/build.xml @@ -13,7 +13,8 @@ - +