Merge branch 'master' of ssh://contiki.git.sourceforge.net/gitroot/contiki/contiki

This commit is contained in:
Joakim Eriksson 2011-03-22 10:46:46 +01:00
commit 590b0a1696
22 changed files with 145 additions and 53 deletions

View file

@ -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);

View file

@ -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;
}
/*---------------------------------------------------------------------------*/

View file

@ -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 */

View file

@ -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 */

View file

@ -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 */

View file

@ -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<rf230_smallest_rssi))
rf230_smallest_rssi=rf230_last_rssi;
// rf230_last_correlation = rxframe[rxframe_head].lqi;
packetbuf_set_attr(PACKETBUF_ATTR_RSSI, rf230_last_rssi);
packetbuf_set_attr(PACKETBUF_ATTR_LINK_QUALITY, rf230_last_correlation);
@ -1451,10 +1471,18 @@ rf230_cca(void)
rf230_on();
}
// cca = CCA_IS_1;
DEBUGFLOW('c');
cca=1;
/* CCA Mode Mode 1=Energy above threshold 2=Carrier sense only 3=Both 0=Either (RF231 only) */
/* Use the current mode. Note triggering a manual CCA is not recommended in extended mode */
//hal_subregister_write(SR_CCA_MODE,1);
/* Start the CCA, wait till done, return result */
hal_subregister_write(SR_CCA_REQUEST,1);
delay_us(TIME_CCA);
//while ((hal_register_read(RG_TRX_STATUS) & 0x80) == 0 ) {continue;}
while (!hal_subregister_read(SR_CCA_DONE)) {continue;}
cca=hal_subregister_read(SR_CCA_STATUS);
if(radio_was_off) {
rf230_off();
}
@ -1481,4 +1509,3 @@ pending_packet(void)
return pending;
}
/*---------------------------------------------------------------------------*/

View file

@ -214,8 +214,7 @@ uint8_t rf230_get_txpower(void);
void rf230_set_promiscuous_mode(bool isPromiscuous);
bool rf230_is_ready_to_send();
extern signed char rf230_last_rssi;
extern uint8_t rf230_last_correlation;
extern uint8_t rf230_last_correlation,rf230_last_rssi,rf230_smallest_rssi;
uint8_t rf230_get_raw_rssi(void);
@ -223,4 +222,4 @@ uint8_t rf230_get_raw_rssi(void);
#endif
/** @} */
/*EOF*/
/*EOF*/

View file

@ -562,7 +562,12 @@ extern uip_ds6_netif_t uip_ds6_if;
PRINTF_P(PSTR(" * Operates on channel %d\n\r"), rf230_get_channel());
PRINTF_P(PSTR(" * TX Power(0=3dBm, 15=-17.2dBm): %d\n\r"), rf230_get_txpower());
#endif
PRINTF_P(PSTR(" * Current/Last RSSI: %d/%ddBm\n\r"), -91+(rf230_rssi()-1), -91+(rf230_last_rssi-1));
if (rf230_smallest_rssi) {
PRINTF_P(PSTR(" * Current/Last/Smallest RSSI: %d/%d/%ddBm\n\r"), -91+(rf230_rssi()-1), -91+(rf230_last_rssi-1),-91+(rf230_smallest_rssi-1));
rf230_smallest_rssi=0;
} else {
PRINTF_P(PSTR(" * Current/Last/Smallest RSSI: %d/%d/--dBm\n\r"), -91+(rf230_rssi()-1), -91+(rf230_last_rssi-1));
}
#else /* RF230BB */
PRINTF_P(PSTR(" * Operates on channel %d\n\r"), radio_get_operating_channel());

View file

@ -266,11 +266,16 @@ extern void mac_log_802_15_4_rx(const uint8_t* buffer, size_t total_len);
/* AUTOACK receive mode gives better rssi measurements, even if ACK is never requested */
#define RF230_CONF_AUTOACK 1
/* Request 802.15.4 ACK on all packets sent by sicslowpan.c (else autoretry) */
/* Broadcasts will be duplicated by the retry count! */
/* Broadcasts will be duplicated by the retry count, since no one will ACK them! */
#define SICSLOWPAN_CONF_ACK_ALL 0
/* Number of auto retry attempts 0-15 (0 implies don't use extended TX_ARET_ON mode with CCA) */
#define RF230_CONF_AUTORETRIES 1
/* CCA theshold energy -91 to -61 dBm (default -77). Set this smaller than the expected minimum rssi to avoid packet collisions */
/* The Jackdaw menu 'm' command is helpful for determining the smallest ever received rssi */
#define RF230_CONF_CCA_THRES -85
/* Allow 6loWPAN fragmentation (more efficient for large payloads over a reliable channel) */
#define SICSLOWPAN_CONF_FRAG 1
/* Timeout for fragment reassembly. A reissued browser GET will also cancel reassembly, typically in 2-3 seconds */
#define SICSLOWPAN_CONF_MAXAGE 3
#elif 0 /* Contiki-mac radio cycling */

View file

@ -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

View file

@ -7,7 +7,7 @@
<target name="compile" depends="init">
<mkdir dir="build"/>
<javac srcdir="se/sics/coffee" destdir="build" />
<javac srcdir="se/sics/coffee" destdir="build" includeantruntime="false" />
</target>
<target name="clean" depends="init">

View file

@ -23,7 +23,8 @@
</target>
<target name="compile" depends="init">
<javac srcdir="${src}" destdir="${build}" debug="on">
<javac srcdir="${src}" destdir="${build}" debug="on"
includeantruntime="false">
<classpath>
<pathelement location="${avrora_jar}"/>
<pathelement location="${cooja_jar}"/>

View file

@ -12,7 +12,8 @@
<target name="compile" depends="init">
<mkdir dir="${build}"/>
<javac srcdir="${java}" destdir="${build}" debug="on">
<javac srcdir="${java}" destdir="${build}" debug="on"
includeantruntime="false">
<classpath>
<pathelement path="."/>
<pathelement location="${cooja_jar}"/>

View file

@ -36,7 +36,8 @@
</target>
<target name="compile" depends="init,mspsim,coffee">
<javac srcdir="${src}" destdir="${build}" debug="on">
<javac srcdir="${src}" destdir="${build}" debug="on"
includeantruntime="false">
<classpath>
<pathelement location="${mspsim_jar}"/>
<pathelement location="${coffee_jar}"/>

View file

@ -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() {

View file

@ -23,7 +23,8 @@ Requires pre-installation of Jpcap and (Windows-only) WinPcap.
<target name="compile" depends="init">
<mkdir dir="${build}"/>
<javac srcdir="${java}" destdir="${build}" debug="on">
<javac srcdir="${java}" destdir="${build}" debug="on"
includeantruntime="false">
<classpath>
<pathelement path="."/>
<pathelement location="${cooja_jar}"/>

View file

@ -10,7 +10,7 @@
<target name="compile" depends="init">
<mkdir dir="build"/>
<javac srcdir="java" destdir="build" debug="on">
<javac srcdir="java" destdir="build" debug="on" includeantruntime="false">
<classpath>
<pathelement path="."/>
<pathelement location="${cooja_jar}"/>

View file

@ -68,7 +68,8 @@ The COOJA Simulator
<target name="compile" depends="init">
<mkdir dir="${build}"/>
<javac srcdir="${java}" destdir="${build}" debug="on">
<javac srcdir="${java}" destdir="${build}" debug="on"
includeantruntime="false">
<classpath>
<pathelement path="."/>
<pathelement location="lib/jdom.jar"/>
@ -189,7 +190,7 @@ The COOJA Simulator
</target>
<target name="java_version" depends="init">
<exec executable="javac" dir="${build}">
<exec executable="javac" dir="${build}" includeantruntime="false">
<arg value="-version"/>
</exec>
</target>

View file

@ -9,7 +9,7 @@
</target>
<target name="compile" depends="init">
<javac srcdir="." destdir="." debug="on">
<javac srcdir="." destdir="." debug="on" includeantruntime="false">
<classpath>
<pathelement location="${cooja_jar}"/>
</classpath>

View file

@ -13,7 +13,8 @@
<target name="compile" depends="init">
<mkdir dir="${build}"/>
<javac srcdir="${src}" destdir="${build}" debug="on">
<javac srcdir="${src}" destdir="${build}" debug="on"
includeantruntime="false">
<classpath>
<pathelement location="${cooja_jar}"/>
</classpath>

View file

@ -13,7 +13,8 @@
<target name="compile" depends="init">
<mkdir dir="${build}"/>
<javac srcdir="${src}" destdir="${build}" debug="on">
<javac srcdir="${src}" destdir="${build}" debug="on"
includeantruntime="false">
<classpath>
<pathelement location="${cooja_jar}"/>
</classpath>

View file

@ -13,7 +13,8 @@
<target name="compile" depends="init">
<mkdir dir="${build}"/>
<javac srcdir="${src}" destdir="${build}" debug="on">
<javac srcdir="${src}" destdir="${build}" debug="on"
includeantruntime="false">
<classpath>
<pathelement location="${cooja_jar}"/>
</classpath>