Merge branch 'master' of ssh://contiki.git.sourceforge.net/gitroot/contiki/contiki
This commit is contained in:
commit
3a3d457a57
|
@ -107,11 +107,8 @@ PROJECT_OBJECTFILES = ${addprefix $(OBJECTDIR)/,${call oname, $(PROJECT_SOURCEFI
|
||||||
ifdef APPS
|
ifdef APPS
|
||||||
APPDIRS += ${wildcard ${addprefix $(CONTIKI)/apps/, $(APPS)} \
|
APPDIRS += ${wildcard ${addprefix $(CONTIKI)/apps/, $(APPS)} \
|
||||||
${addprefix $(CONTIKI)/platform/$(TARGET)/apps/, $(APPS)} \
|
${addprefix $(CONTIKI)/platform/$(TARGET)/apps/, $(APPS)} \
|
||||||
${addprefix , $(APPS)}}
|
$(APPS)}
|
||||||
APPINCLUDES = ${foreach APP, $(APPS), ${wildcard ${foreach DIR, $(APPDIRS), $(DIR)/Makefile.$(APP)} \
|
APPINCLUDES = ${foreach APP, $(APPS), ${wildcard ${foreach DIR, $(APPDIRS), $(DIR)/Makefile.$(APP)}}}
|
||||||
$(CONTIKI)/apps/$(APP)/Makefile.$(APP) \
|
|
||||||
$(CONTIKI)/platform/$(TARGET)/apps/$(APP)/Makefile.$(APP) \
|
|
||||||
$(APP)/Makefile.$(APP)}}
|
|
||||||
-include $(APPINCLUDES)
|
-include $(APPINCLUDES)
|
||||||
APP_SOURCES = ${foreach APP, $(APPS), $($(APP)_src)}
|
APP_SOURCES = ${foreach APP, $(APPS), $($(APP)_src)}
|
||||||
DSC_SOURCES = ${foreach APP, $(APPS), $($(APP)_dsc)}
|
DSC_SOURCES = ${foreach APP, $(APPS), $($(APP)_dsc)}
|
||||||
|
|
|
@ -256,6 +256,13 @@ typedef struct periodic_resource_s periodic_resource_t;
|
||||||
void name##_handler(void *, void *, uint8_t *, uint16_t, int32_t *); \
|
void name##_handler(void *, void *, uint8_t *, uint16_t, int32_t *); \
|
||||||
resource_t resource_##name = {NULL, flags, url, attributes, name##_handler, NULL, NULL, NULL}
|
resource_t resource_##name = {NULL, flags, url, attributes, name##_handler, NULL, NULL, NULL}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Macro to define a sub-resource
|
||||||
|
* Make sure to define its parent resource beforehand and set 'parent' to that name.
|
||||||
|
*/
|
||||||
|
#define SUB_RESOURCE(name, flags, url, attributes, parent) \
|
||||||
|
resource_t resource_##name = {NULL, flags, url, attributes, parent##_handler, NULL, NULL, NULL}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Macro to define an event resource
|
* Macro to define an event resource
|
||||||
* Like periodic resources, event resources have a post_handler that manages a subscriber list.
|
* Like periodic resources, event resources have a post_handler that manages a subscriber list.
|
||||||
|
|
|
@ -555,6 +555,11 @@ PT_THREAD(neighbors(struct httpd_state *s, char *ptr))
|
||||||
|
|
||||||
#if WEBSERVER_CONF_ROUTES
|
#if WEBSERVER_CONF_ROUTES
|
||||||
extern uip_ds6_route_t uip_ds6_routing_table[];
|
extern uip_ds6_route_t uip_ds6_routing_table[];
|
||||||
|
#if WEBSERVER_CONF_ROUTE_LINKS
|
||||||
|
static const char httpd_cgi_rtesl1[] HTTPD_STRING_ATTR = "<a href=http://[";
|
||||||
|
static const char httpd_cgi_rtesl2[] HTTPD_STRING_ATTR = "]/status.shtml>";
|
||||||
|
static const char httpd_cgi_rtesl3[] HTTPD_STRING_ATTR = "</a>";
|
||||||
|
#endif
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static unsigned short
|
static unsigned short
|
||||||
make_routes(void *p)
|
make_routes(void *p)
|
||||||
|
@ -573,9 +578,6 @@ struct httpd_state *s=p;
|
||||||
j++;
|
j++;
|
||||||
|
|
||||||
#if WEBSERVER_CONF_ROUTE_LINKS
|
#if WEBSERVER_CONF_ROUTE_LINKS
|
||||||
static const char httpd_cgi_rtesl1[] HTTPD_STRING_ATTR = "<a href=http://[";
|
|
||||||
static const char httpd_cgi_rtesl2[] HTTPD_STRING_ATTR = "]/status.shtml>";
|
|
||||||
static const char httpd_cgi_rtesl3[] HTTPD_STRING_ATTR = "</a>";
|
|
||||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtesl1);
|
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtesl1);
|
||||||
numprinted += httpd_cgi_sprint_ip6(uip_ds6_routing_table[i].ipaddr, uip_appdata + numprinted);
|
numprinted += httpd_cgi_sprint_ip6(uip_ds6_routing_table[i].ipaddr, uip_appdata + numprinted);
|
||||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtesl2);
|
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtesl2);
|
||||||
|
@ -592,7 +594,7 @@ static const char httpd_cgi_rtesl3[] HTTPD_STRING_ATTR = "</a>";
|
||||||
} else {
|
} else {
|
||||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes3);
|
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes3);
|
||||||
}
|
}
|
||||||
/* If buffer nearly full, send it and wait for the next call. Could be a retransmission, or the next segment */
|
/* If buffer near full, send it and wait for the next call. Could be a retransmission, or the next segment */
|
||||||
if(numprinted > (uip_mss() - 200)) {
|
if(numprinted > (uip_mss() - 200)) {
|
||||||
s->savei=i;s->savej=j;
|
s->savei=i;s->savej=j;
|
||||||
return numprinted;
|
return numprinted;
|
||||||
|
@ -607,7 +609,40 @@ static const char httpd_cgi_rtesl3[] HTTPD_STRING_ATTR = "</a>";
|
||||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrf);
|
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
static const char httpd_cgi_defr1[] HTTPD_STRING_ATTR = "\n<big><b>RPL Parent</b></big>\n";
|
||||||
|
static const char httpd_cgi_defr2[] HTTPD_STRING_ATTR = " (%u sec)\n";
|
||||||
|
#if 0
|
||||||
|
uip_ip6addr_t *nexthop = uip_ds6_defrt_choose();
|
||||||
|
if (nexthop) {
|
||||||
|
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_defr1);
|
||||||
|
numprinted += httpd_cgi_sprint_ip6(*nexthop, uip_appdata + numprinted);
|
||||||
|
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_defr2,nexthop->lifetime.start+nexthop->lifetime.interval-clock_seconds());
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
uip_ds6_defrt_t *locdefrt;
|
||||||
|
extern uip_ds6_defrt_t uip_ds6_defrt_list[UIP_DS6_DEFRT_NB];
|
||||||
|
for(locdefrt = uip_ds6_defrt_list;
|
||||||
|
locdefrt < uip_ds6_defrt_list + UIP_DS6_DEFRT_NB; locdefrt++) {
|
||||||
|
if(locdefrt->isused) {
|
||||||
|
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_defr1);
|
||||||
|
|
||||||
|
#if WEBSERVER_CONF_ROUTE_LINKS && 0
|
||||||
|
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtesl1);
|
||||||
|
numprinted += httpd_cgi_sprint_ip6(locdefrt->ipaddr, uip_appdata + numprinted);
|
||||||
|
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtesl2);
|
||||||
|
numprinted += httpd_cgi_sprint_ip6(locdefrt->ipaddr, uip_appdata + numprinted);
|
||||||
|
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtesl3);
|
||||||
|
#else
|
||||||
|
numprinted += httpd_cgi_sprint_ip6(locdefrt->ipaddr, uip_appdata + numprinted);
|
||||||
|
#endif
|
||||||
|
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_defr2,locdefrt->lifetime.start+locdefrt->lifetime.interval-clock_seconds());
|
||||||
|
// break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
/* Signal that this was the last segment */
|
/* Signal that this was the last segment */
|
||||||
s->savei = 0;
|
s->savei = 0;
|
||||||
return numprinted;
|
return numprinted;
|
||||||
|
@ -717,8 +752,6 @@ uint8_t c;
|
||||||
adc_disable();
|
adc_disable();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
snprintf(sensor_extvoltage, sizeof(sensor_extvoltage),"%u mV",1200*0xfff/adc_reading[8]);
|
|
||||||
|
|
||||||
static const char httpd_cgi_sensorv[] HTTPD_STRING_ATTR = "<em>ADC chans :</em> %u %u %u %u %u %u %u %u \n";
|
static const char httpd_cgi_sensorv[] HTTPD_STRING_ATTR = "<em>ADC chans :</em> %u %u %u %u %u %u %u %u \n";
|
||||||
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensorv,
|
numprinted+=httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_sensorv,
|
||||||
adc_reading[0],adc_reading[1],adc_reading[2],adc_reading[3],adc_reading[4],adc_reading[5],adc_reading[6],adc_reading[7]);
|
adc_reading[0],adc_reading[1],adc_reading[2],adc_reading[3],adc_reading[4],adc_reading[5],adc_reading[6],adc_reading[7]);
|
||||||
|
@ -770,7 +803,7 @@ generate_stats(void *arg)
|
||||||
uint32_t seconds=clock_seconds();
|
uint32_t seconds=clock_seconds();
|
||||||
|
|
||||||
static const char httpd_cgi_stats[] HTTPD_STRING_ATTR = "\n<big><b>Statistics</b></big>\n";
|
static const char httpd_cgi_stats[] HTTPD_STRING_ATTR = "\n<big><b>Statistics</b></big>\n";
|
||||||
numprinted=httpd_snprintf((char *)uip_appdata + numprinted, uip_mss() - numprinted, httpd_cgi_stats);
|
numprinted=httpd_snprintf((char *)uip_appdata, uip_mss(), httpd_cgi_stats);
|
||||||
|
|
||||||
#if ENERGEST_CONF_ON
|
#if ENERGEST_CONF_ON
|
||||||
{uint8_t p1,p2;
|
{uint8_t p1,p2;
|
||||||
|
@ -1024,10 +1057,27 @@ PT_THREAD(ajax_call(struct httpd_state *s, char *ptr))
|
||||||
static int iter;
|
static int iter;
|
||||||
static char buf[128];
|
static char buf[128];
|
||||||
static uint8_t numprinted;
|
static uint8_t numprinted;
|
||||||
|
uint16_t dt;
|
||||||
PSOCK_BEGIN(&s->sout);
|
PSOCK_BEGIN(&s->sout);
|
||||||
/*TODO:pick up time from ? parameter */
|
|
||||||
timer_set(&t, 2*CLOCK_SECOND);
|
#if WEBSERVER_CONF_PASSQUERY
|
||||||
|
/* Get update time from ? string, if present */
|
||||||
|
{
|
||||||
|
uint8_t i;uint16_t dt=0;
|
||||||
|
for (i=0;i<WEBSERVER_CONF_PASSQUERY;i++) {
|
||||||
|
if (httpd_query[i] < '0' || httpd_query[i] > '9') break;
|
||||||
|
dt = dt*10 + httpd_query[i]-'0';
|
||||||
|
}
|
||||||
|
if (dt < 1) dt = 1;
|
||||||
|
// printf("dt %u\n",dt);
|
||||||
|
timer_set(&t, dt*CLOCK_SECOND);
|
||||||
|
httpd_query[i]=0; //necessary?
|
||||||
|
if (dt > WEBSERVER_CONF_TIMEOUT/2) s->ajax_timeout = 2*dt; else s->ajax_timeout = WEBSERVER_CONF_TIMEOUT;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
timer_set(&t, 2*CLOCK_SECOND);
|
||||||
|
#endif
|
||||||
|
|
||||||
iter = 0;
|
iter = 0;
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
|
@ -1064,7 +1114,8 @@ PT_THREAD(ajax_call(struct httpd_state *s, char *ptr))
|
||||||
adc_disable();
|
adc_disable();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
#if 1
|
||||||
numprinted = snprintf(buf, sizeof(buf),"b(%u);adc(%u,%u,%u,%u,%u,%u,%u,%u);",
|
numprinted = snprintf(buf, sizeof(buf),"b(%u);adc(%u,%u,%u,%u,%u,%u,%u,%u);",
|
||||||
1200*0xfff/adc_reading[8],adc_reading[0],adc_reading[1],adc_reading[2],adc_reading[3],adc_reading[4],adc_reading[5],adc_reading[6],adc_reading[7]);
|
1200*0xfff/adc_reading[8],adc_reading[0],adc_reading[1],adc_reading[2],adc_reading[3],adc_reading[4],adc_reading[5],adc_reading[6],adc_reading[7]);
|
||||||
#else
|
#else
|
||||||
|
@ -1074,14 +1125,14 @@ PT_THREAD(ajax_call(struct httpd_state *s, char *ptr))
|
||||||
}
|
}
|
||||||
if (iter<3) {
|
if (iter<3) {
|
||||||
static const char httpd_cgi_ajax11[] HTTPD_STRING_ATTR = "wt('Econtag [";
|
static const char httpd_cgi_ajax11[] HTTPD_STRING_ATTR = "wt('Econtag [";
|
||||||
static const char httpd_cgi_ajax12[] HTTPD_STRING_ATTR = "]');";
|
static const char httpd_cgi_ajax12[] HTTPD_STRING_ATTR = "]');";
|
||||||
numprinted += httpd_snprintf(buf+numprinted, sizeof(buf)-numprinted,httpd_cgi_ajax11);
|
numprinted += httpd_snprintf(buf+numprinted, sizeof(buf)-numprinted,httpd_cgi_ajax11);
|
||||||
#if WEBSERVER_CONF_PRINTADDR
|
#if WEBSERVER_CONF_PRINTADDR
|
||||||
/* Note address table is filled from the end down */
|
/* Note address table is filled from the end down */
|
||||||
{int i;
|
{int i;
|
||||||
for (i=0; i<UIP_DS6_ADDR_NB;i++) {
|
for (i=0; i<UIP_DS6_ADDR_NB;i++) {
|
||||||
if (uip_ds6_if.addr_list[i].isused) {
|
if (uip_ds6_if.addr_list[i].isused) {
|
||||||
numprinted += httpd_cgi_sprint_ip6(uip_ds6_if.addr_list[i].ipaddr, buf + numprinted);
|
numprinted += httpd_cgi_sprint_ip6(uip_ds6_if.addr_list[i].ipaddr, buf + numprinted);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1256,8 +1307,15 @@ static uint16_t c0=0x3ff,c1=0x3ff,c2=0x3ff,c3=0x3ff,c4=0x3ff,c5=0x3ff,c6=0x3ff,c
|
||||||
#if ENERGEST_CONF_ON
|
#if ENERGEST_CONF_ON
|
||||||
{
|
{
|
||||||
#if 1
|
#if 1
|
||||||
/* Send on times in percent since last update. Handle 16 bit rtimer wraparound. */
|
/* Send on times in percent since last update. Handle 16 bit rtimer wraparound.
|
||||||
/* Javascript must convert based on platform cpu, tx, rx power, e.g. 20ma*3v3=66mW*(% on time/100) */
|
* Javascript must convert based on platform cpu, tx, rx power.
|
||||||
|
* e.g. for cpu drawing 1.2ma@3v3, cp = 1.2*3.3*(% on time)/100 = 0.0396*c;
|
||||||
|
* Low power mode l is essentially zero for cpus that sleep.
|
||||||
|
* function p(c,l,t,r){cp=0.013*c;lt=0.465*t;lr=0.400*r;n=cp+lt+lr;//128rfa1@3v3,3dBm
|
||||||
|
* function p(c,l,t,r){cp=0.013*c;lt=0.317*t;lr=0.400*r;n=cp+lt+lr;//128rfa1@3v3,0dBm
|
||||||
|
* function p(c,l,t,r){cp=0.109*c;lt=0.848*t;lr=0.617*r;n=cp+lt+lr;//mc1322x@3v3,0dBm
|
||||||
|
* Precision can be increased by multiplying by another 100 before sending.
|
||||||
|
*/
|
||||||
static rtimer_clock_t last_send;
|
static rtimer_clock_t last_send;
|
||||||
rtimer_clock_t delta_time;
|
rtimer_clock_t delta_time;
|
||||||
static unsigned long last_cpu, last_lpm, last_listen, last_transmit;
|
static unsigned long last_cpu, last_lpm, last_listen, last_transmit;
|
||||||
|
@ -1267,10 +1325,10 @@ static uint16_t c0=0x3ff,c1=0x3ff,c2=0x3ff,c3=0x3ff,c4=0x3ff,c5=0x3ff,c6=0x3ff,c
|
||||||
last_send=RTIMER_NOW();
|
last_send=RTIMER_NOW();
|
||||||
static const char httpd_cgi_ajaxe1[] HTTPD_STRING_ATTR = "p(%lu,%lu,%lu,%lu);";
|
static const char httpd_cgi_ajaxe1[] HTTPD_STRING_ATTR = "p(%lu,%lu,%lu,%lu);";
|
||||||
numprinted += httpd_snprintf(buf+numprinted, sizeof(buf)-numprinted,httpd_cgi_ajaxe1,
|
numprinted += httpd_snprintf(buf+numprinted, sizeof(buf)-numprinted,httpd_cgi_ajaxe1,
|
||||||
(100UL*(energest_total_time[ENERGEST_TYPE_CPU].current - last_cpu))/delta_time,
|
(10000UL*(energest_total_time[ENERGEST_TYPE_CPU].current - last_cpu))/delta_time,
|
||||||
(100UL*(energest_total_time[ENERGEST_TYPE_LPM].current - last_lpm))/delta_time,
|
(10000UL*(energest_total_time[ENERGEST_TYPE_LPM].current - last_lpm))/delta_time,
|
||||||
(100UL*(energest_total_time[ENERGEST_TYPE_TRANSMIT].current - last_transmit))/delta_time,
|
(10000UL*(energest_total_time[ENERGEST_TYPE_TRANSMIT].current - last_transmit))/delta_time,
|
||||||
(100UL*(energest_total_time[ENERGEST_TYPE_LISTEN].current - last_listen))/delta_time);
|
(10000UL*(energest_total_time[ENERGEST_TYPE_LISTEN].current - last_listen))/delta_time);
|
||||||
last_cpu = energest_total_time[ENERGEST_TYPE_CPU].current;
|
last_cpu = energest_total_time[ENERGEST_TYPE_CPU].current;
|
||||||
last_lpm = energest_total_time[ENERGEST_TYPE_LPM].current;
|
last_lpm = energest_total_time[ENERGEST_TYPE_LPM].current;
|
||||||
last_transmit = energest_total_time[ENERGEST_TYPE_TRANSMIT].current;
|
last_transmit = energest_total_time[ENERGEST_TYPE_TRANSMIT].current;
|
||||||
|
@ -1299,8 +1357,14 @@ static uint16_t c0=0x3ff,c1=0x3ff,c2=0x3ff,c3=0x3ff,c4=0x3ff,c5=0x3ff,c6=0x3ff,c
|
||||||
#endif /* ENERGEST_CONF_ON */
|
#endif /* ENERGEST_CONF_ON */
|
||||||
|
|
||||||
PSOCK_SEND_STR(&s->sout, buf);
|
PSOCK_SEND_STR(&s->sout, buf);
|
||||||
|
/* Can do fixed intervals or fixed starting points */
|
||||||
|
#if FIXED_INTERVALS
|
||||||
timer_restart(&t);
|
timer_restart(&t);
|
||||||
PSOCK_WAIT_UNTIL(&s->sout, timer_expired(&t));
|
PSOCK_WAIT_UNTIL(&s->sout, timer_expired(&t));
|
||||||
|
#else
|
||||||
|
PSOCK_WAIT_UNTIL(&s->sout, timer_expired(&t));
|
||||||
|
timer_reset(&t);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
PSOCK_END(&s->sout);
|
PSOCK_END(&s->sout);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
function e(el){return document.getElementById(el);}
|
function e(el){return document.getElementById(el);}
|
||||||
function ls(){try{r=new XMLHttpRequest();}catch(e){alert("Browswer does not support Ajax");return false;}r.open("GET","/ajaxdata.shtml",true);
|
function ls(){try{r=new XMLHttpRequest();}catch(e){alert("Browswer does not support Ajax");return false;}r.open("GET","/ajaxdata.shtml",true);
|
||||||
x=0;r.onreadystatechange=function(){e('date').innerHTML=(new Date()).toTimeString();if(r.readyState>0){j=r.responseText.substr(x);x+=j.length;eval(j);}};r.send(null);}
|
x=0;r.onreadystatechange=function(){e('date').innerHTML=(new Date()).toTimeString();if(r.readyState>0){j=r.responseText.substr(x);x+=j.length;eval(j);}};r.send(null);}
|
||||||
|
function tb(x){var t=e('ss');if(x||t.value=="RUN"){t.value="STOP";ls();}else{t.value="RUN";r.abort();}}
|
||||||
function s(el,n,max,text){e(el).innerHTML='<table width=504 border=0 cellpadding=1 cellspacing=0>'+'<tr><td width=200>'+text+'</td>'+'<td width='+(10+300*n/max)+' bgcolor="gray"> </td>'+'<td width='+(310-300*n/max)+' bgcolor="lightgray"> </td>'+'</table>';}
|
function s(el,n,max,text){e(el).innerHTML='<table width=504 border=0 cellpadding=1 cellspacing=0>'+'<tr><td width=200>'+text+'</td>'+'<td width='+(10+300*n/max)+' bgcolor="gray"> </td>'+'<td width='+(310-300*n/max)+' bgcolor="lightgray"> </td>'+'</table>';}
|
||||||
function wt(m){document.title=m;e('v').innerHTML=m;}
|
function wt(m){document.title=m;e('v').innerHTML=m;}
|
||||||
function dc(n,d){return n.toFixed(d);}
|
function dc(n,d){return n.toFixed(d);}
|
||||||
|
@ -12,7 +13,7 @@ function ax(m){s('ax',m+2000,4000,'Acceleration (X-axis) '+m+'mg');}
|
||||||
function ay(m){s('ay',m+2000,4000,'Acceleration (Y-axis) '+m+'mg');}
|
function ay(m){s('ay',m+2000,4000,'Acceleration (Y-axis) '+m+'mg');}
|
||||||
function az(m){s('az',m+2000,4000,'Acceleration (Z-axis) '+m+'mg');}
|
function az(m){s('az',m+2000,4000,'Acceleration (Z-axis) '+m+'mg');}
|
||||||
function rs(m){s('rs',n,100,'RSSI '+n);}
|
function rs(m){s('rs',n,100,'RSSI '+n);}
|
||||||
function p(c,l,t,r){cp=0.136*c;lt=0.478*t;lr=0.412*r;n=cp+lt+lr;//128rfa1@3v3
|
function p(c,l,t,r){cp=0.00109*c;lt=0.00848*t;lr=0.00617*r;n=cp+lt+lr;//mc1322x
|
||||||
s('p',n,200,'Power consumption '+dc(n,2)+' mW');
|
s('p',n,200,'Power consumption '+dc(n,2)+' mW');
|
||||||
s('pc',cp,100,'CPU power '+dc(cp,2)+' mW');
|
s('pc',cp,100,'CPU power '+dc(cp,2)+' mW');
|
||||||
s('pr',lr,200,'Radio RX power '+dc(lr,2)+' mW');
|
s('pr',lr,200,'Radio RX power '+dc(lr,2)+' mW');
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
%! header
|
%! header
|
||||||
%!: /ajax.js
|
%!: /ajax.js
|
||||||
<input type="button" value="RUN" onclick="ls()"><input type="button" value="STOP" onclick="r.abort()"><br><span id="date"></span>
|
<input id="ss" type="button" value="STOP" onclick="tb(0)">
|
||||||
|
Interval <input id="tc" type="text" style="width:60;text-align:right;" maxlength="5" value="10" onchange="tb(1)"> seconds<br>
|
||||||
|
<span id="date"></span>
|
||||||
<div id="v"></div>
|
<div id="v"></div>
|
||||||
<pre><span id="rims"></span><div id="ener"></div></pre>
|
<pre><span id="rims"></span><div id="ener"></div></pre>
|
||||||
<h2>Sensors</h2>
|
<h2>Sensors</h2>
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
%! header
|
%! header
|
||||||
<h4>Addresses</h4>
|
<pre><big><b>Addresses</b></big>
|
||||||
%! addresses
|
%! addresses
|
||||||
<h4>Neighbors</h4>
|
|
||||||
|
<big><b>Neighbors</b></big>
|
||||||
%! neighbors
|
%! neighbors
|
||||||
<h4>Routes</h4>
|
|
||||||
|
<big><b>Routes</b></big>
|
||||||
%! routes
|
%! routes
|
||||||
<h4>Sensors</h4>
|
|
||||||
|
<big><b>Sensors</b></big>
|
||||||
%! sensors
|
%! sensors
|
||||||
|
</pre>
|
||||||
%! file-stats .
|
%! file-stats .
|
|
@ -1,10 +1,14 @@
|
||||||
%! header
|
%! header
|
||||||
<p>Addresses<br>
|
<pre><big><b>Addresses</b></big>
|
||||||
%! addresses
|
%! addresses
|
||||||
<p>Neighbors<br>
|
|
||||||
|
<big><b>Neighbors</b></big>
|
||||||
%! neighbors
|
%! neighbors
|
||||||
<p>Routes<br>
|
|
||||||
|
<big><b>Routes</b></big>
|
||||||
%! routes
|
%! routes
|
||||||
<p>Sensors<br>
|
|
||||||
|
<big><b>Sensors</b></big>
|
||||||
%! sensors
|
%! sensors
|
||||||
|
</pre>
|
||||||
%! file-stats .
|
%! file-stats .
|
|
@ -94,7 +94,6 @@ static
|
||||||
PT_THREAD(send_file(struct httpd_state *s))
|
PT_THREAD(send_file(struct httpd_state *s))
|
||||||
{
|
{
|
||||||
PSOCK_BEGIN(&s->sout);
|
PSOCK_BEGIN(&s->sout);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
PSOCK_GENERATOR_SEND(&s->sout, generate, s);
|
PSOCK_GENERATOR_SEND(&s->sout, generate, s);
|
||||||
s->file.len -= s->len;
|
s->file.len -= s->len;
|
||||||
|
@ -488,11 +487,18 @@ httpd_appcall(void *state)
|
||||||
PT_INIT(&s->outputpt);
|
PT_INIT(&s->outputpt);
|
||||||
s->state = STATE_WAITING;
|
s->state = STATE_WAITING;
|
||||||
s->timer = 0;
|
s->timer = 0;
|
||||||
|
#if WEBSERVER_CONF_AJAX
|
||||||
|
s->ajax_timeout = WEBSERVER_CONF_TIMEOUT;
|
||||||
|
#endif
|
||||||
handle_connection(s);
|
handle_connection(s);
|
||||||
} else if(s != NULL) {
|
} else if(s != NULL) {
|
||||||
if(uip_poll()) {
|
if(uip_poll()) {
|
||||||
++s->timer;
|
++s->timer;
|
||||||
if(s->timer >= 20) {
|
#if WEBSERVER_CONF_AJAX
|
||||||
|
if(s->timer >= s->ajax_timeout) {
|
||||||
|
#else
|
||||||
|
if(s->timer >= WEBSERVER_CONF_TIMEOUT) {
|
||||||
|
#endif
|
||||||
uip_abort();
|
uip_abort();
|
||||||
memb_free(&conns, s);
|
memb_free(&conns, s);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,8 @@
|
||||||
#define WEBSERVER_CONF_CONNS 2
|
#define WEBSERVER_CONF_CONNS 2
|
||||||
#define WEBSERVER_CONF_NAMESIZE 16
|
#define WEBSERVER_CONF_NAMESIZE 16
|
||||||
#define WEBSERVER_CONF_BUFSIZE 40
|
#define WEBSERVER_CONF_BUFSIZE 40
|
||||||
|
/* Short tcp timeouts allow new connections sooner */
|
||||||
|
#define WEBSERVER_CONF_TIMEOUT 20
|
||||||
/* Allow include in .shtml pages, e.g. %!: /header.html */
|
/* Allow include in .shtml pages, e.g. %!: /header.html */
|
||||||
#define WEBSERVER_CONF_INCLUDE 1
|
#define WEBSERVER_CONF_INCLUDE 1
|
||||||
/* Allow cgi in .shtml pages, e.g. %! file-stats . */
|
/* Allow cgi in .shtml pages, e.g. %! file-stats . */
|
||||||
|
@ -116,13 +118,13 @@ extern char httpd_query[WEBSERVER_CONF_PASSQUERY];
|
||||||
#define WEBSERVER_CONF_LOG 0
|
#define WEBSERVER_CONF_LOG 0
|
||||||
/* Include referrer in log */
|
/* Include referrer in log */
|
||||||
#define WEBSERVER_CONF_REFERER 0
|
#define WEBSERVER_CONF_REFERER 0
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
#elif WEBSERVER_CONF_NANO==2
|
#elif WEBSERVER_CONF_NANO==2
|
||||||
/* webserver-mini having more content */
|
/* webserver-mini having more content */
|
||||||
#define WEBSERVER_CONF_CONNS 2
|
#define WEBSERVER_CONF_CONNS 2
|
||||||
#define WEBSERVER_CONF_NAMESIZE 20
|
#define WEBSERVER_CONF_NAMESIZE 20
|
||||||
#define WEBSERVER_CONF_BUFSIZE 40
|
#define WEBSERVER_CONF_BUFSIZE 40
|
||||||
|
#define WEBSERVER_CONF_TIMEOUT 20
|
||||||
/* Allow include in .shtml pages, e.g. %!: /header.html */
|
/* Allow include in .shtml pages, e.g. %!: /header.html */
|
||||||
#define WEBSERVER_CONF_INCLUDE 1
|
#define WEBSERVER_CONF_INCLUDE 1
|
||||||
/* Allow cgi in .shtml pages, e.g. %! file-stats . */
|
/* Allow cgi in .shtml pages, e.g. %! file-stats . */
|
||||||
|
@ -148,7 +150,7 @@ extern char httpd_query[WEBSERVER_CONF_PASSQUERY];
|
||||||
//#define WEBSERVER_CONF_TICTACTOE 1 //Needs passquery of at least 10 chars
|
//#define WEBSERVER_CONF_TICTACTOE 1 //Needs passquery of at least 10 chars
|
||||||
#define WEBSERVER_CONF_AJAX 1
|
#define WEBSERVER_CONF_AJAX 1
|
||||||
#define WEBSERVER_CONF_SHOW_ROOM 0
|
#define WEBSERVER_CONF_SHOW_ROOM 0
|
||||||
//#define WEBSERVER_CONF_PASSQUERY 10
|
#define WEBSERVER_CONF_PASSQUERY 10
|
||||||
#if WEBSERVER_CONF_PASSQUERY
|
#if WEBSERVER_CONF_PASSQUERY
|
||||||
extern char httpd_query[WEBSERVER_CONF_PASSQUERY];
|
extern char httpd_query[WEBSERVER_CONF_PASSQUERY];
|
||||||
#endif
|
#endif
|
||||||
|
@ -171,6 +173,7 @@ extern char httpd_query[WEBSERVER_CONF_PASSQUERY];
|
||||||
#define WEBSERVER_CONF_CONNS 6
|
#define WEBSERVER_CONF_CONNS 6
|
||||||
#define WEBSERVER_CONF_NAMESIZE 20
|
#define WEBSERVER_CONF_NAMESIZE 20
|
||||||
#define WEBSERVER_CONF_BUFSIZE 40
|
#define WEBSERVER_CONF_BUFSIZE 40
|
||||||
|
#define WEBSERVER_CONF_TIMEOUT 20
|
||||||
/* Allow include in .shtml pages, e.g. %!: /header.html */
|
/* Allow include in .shtml pages, e.g. %!: /header.html */
|
||||||
#define WEBSERVER_CONF_INCLUDE 1
|
#define WEBSERVER_CONF_INCLUDE 1
|
||||||
/* Allow cgi in .shtml pages, e.g. %! file-stats . */
|
/* Allow cgi in .shtml pages, e.g. %! file-stats . */
|
||||||
|
@ -285,6 +288,9 @@ struct httpd_state {
|
||||||
#if WEBSERVER_CONF_LOADTIME
|
#if WEBSERVER_CONF_LOADTIME
|
||||||
clock_time_t pagetime;
|
clock_time_t pagetime;
|
||||||
#endif
|
#endif
|
||||||
|
#if WEBSERVER_CONF_AJAX
|
||||||
|
uint16_t ajax_timeout;
|
||||||
|
#endif
|
||||||
#if WEBSERVER_CONF_NEIGHBORS || WEBSERVER_CONF_ROUTES
|
#if WEBSERVER_CONF_NEIGHBORS || WEBSERVER_CONF_ROUTES
|
||||||
uint8_t starti,savei,startj,savej;
|
uint8_t starti,savei,startj,savej;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -358,11 +358,14 @@ powercycle_turn_radio_on(void)
|
||||||
static char
|
static char
|
||||||
powercycle(struct rtimer *t, void *ptr)
|
powercycle(struct rtimer *t, void *ptr)
|
||||||
{
|
{
|
||||||
|
#if SYNC_CYCLE_STARTS
|
||||||
|
static volatile rtimer_clock_t sync_cycle_start;
|
||||||
|
static volatile uint8_t sync_cycle_phase;
|
||||||
|
#endif
|
||||||
|
|
||||||
PT_BEGIN(&pt);
|
PT_BEGIN(&pt);
|
||||||
|
|
||||||
#if SYNC_CYCLE_STARTS
|
#if SYNC_CYCLE_STARTS
|
||||||
static volatile rtimer_clock_t sync_cycle_start;
|
|
||||||
static volatile uint8_t sync_cycle_phase;
|
|
||||||
sync_cycle_start = RTIMER_NOW();
|
sync_cycle_start = RTIMER_NOW();
|
||||||
#else
|
#else
|
||||||
cycle_start = RTIMER_NOW();
|
cycle_start = RTIMER_NOW();
|
||||||
|
|
|
@ -179,9 +179,6 @@ void uip_log(char *msg);
|
||||||
/** \name General variables
|
/** \name General variables
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
/** A pointer to the mac driver */
|
|
||||||
const struct mac_driver *sicslowpan_mac;
|
|
||||||
|
|
||||||
#ifdef SICSLOWPAN_NH_COMPRESSOR
|
#ifdef SICSLOWPAN_NH_COMPRESSOR
|
||||||
/** A pointer to the additional compressor */
|
/** A pointer to the additional compressor */
|
||||||
extern struct sicslowpan_nh_compressor SICSLOWPAN_NH_COMPRESSOR;
|
extern struct sicslowpan_nh_compressor SICSLOWPAN_NH_COMPRESSOR;
|
||||||
|
@ -1766,9 +1763,6 @@ input(void)
|
||||||
void
|
void
|
||||||
sicslowpan_init(void)
|
sicslowpan_init(void)
|
||||||
{
|
{
|
||||||
/* remember the mac driver */
|
|
||||||
sicslowpan_mac = &NETSTACK_MAC;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set out output function as the function to be called from uIP to
|
* Set out output function as the function to be called from uIP to
|
||||||
* send a packet.
|
* send a packet.
|
||||||
|
|
|
@ -321,6 +321,5 @@ struct sicslowpan_nh_compressor {
|
||||||
|
|
||||||
extern const struct network_driver sicslowpan_driver;
|
extern const struct network_driver sicslowpan_driver;
|
||||||
|
|
||||||
extern const struct mac_driver *sicslowpan_mac;
|
|
||||||
#endif /* __SICSLOWPAN_H__ */
|
#endif /* __SICSLOWPAN_H__ */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -145,6 +145,7 @@ create_llao(uint8_t *llao, uint8_t type) {
|
||||||
void
|
void
|
||||||
uip_nd6_ns_input(void)
|
uip_nd6_ns_input(void)
|
||||||
{
|
{
|
||||||
|
uint8_t flags;
|
||||||
PRINTF("Received NS from ");
|
PRINTF("Received NS from ");
|
||||||
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
|
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
|
||||||
PRINTF(" to ");
|
PRINTF(" to ");
|
||||||
|
@ -154,8 +155,6 @@ uip_nd6_ns_input(void)
|
||||||
PRINTF("\n");
|
PRINTF("\n");
|
||||||
UIP_STAT(++uip_stat.nd6.recv);
|
UIP_STAT(++uip_stat.nd6.recv);
|
||||||
|
|
||||||
uint8_t flags;
|
|
||||||
|
|
||||||
#if UIP_CONF_IPV6_CHECKS
|
#if UIP_CONF_IPV6_CHECKS
|
||||||
if((UIP_IP_BUF->ttl != UIP_ND6_HOP_LIMIT) ||
|
if((UIP_IP_BUF->ttl != UIP_ND6_HOP_LIMIT) ||
|
||||||
(uip_is_addr_mcast(&UIP_ND6_NS_BUF->tgtipaddr)) ||
|
(uip_is_addr_mcast(&UIP_ND6_NS_BUF->tgtipaddr)) ||
|
||||||
|
@ -390,6 +389,11 @@ uip_nd6_ns_output(uip_ipaddr_t * src, uip_ipaddr_t * dest, uip_ipaddr_t * tgt)
|
||||||
void
|
void
|
||||||
uip_nd6_na_input(void)
|
uip_nd6_na_input(void)
|
||||||
{
|
{
|
||||||
|
uint8_t is_llchange;
|
||||||
|
uint8_t is_router;
|
||||||
|
uint8_t is_solicited;
|
||||||
|
uint8_t is_override;
|
||||||
|
|
||||||
PRINTF("Received NA from");
|
PRINTF("Received NA from");
|
||||||
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
|
PRINT6ADDR(&UIP_IP_BUF->srcipaddr);
|
||||||
PRINTF("to");
|
PRINTF("to");
|
||||||
|
@ -403,11 +407,11 @@ uip_nd6_na_input(void)
|
||||||
* booleans. the three last one are not 0 or 1 but 0 or 0x80, 0x40, 0x20
|
* booleans. the three last one are not 0 or 1 but 0 or 0x80, 0x40, 0x20
|
||||||
* but it works. Be careful though, do not use tests such as is_router == 1
|
* but it works. Be careful though, do not use tests such as is_router == 1
|
||||||
*/
|
*/
|
||||||
uint8_t is_llchange = 0;
|
is_llchange = 0;
|
||||||
uint8_t is_router = ((UIP_ND6_NA_BUF->flagsreserved & UIP_ND6_NA_FLAG_ROUTER));
|
is_router = ((UIP_ND6_NA_BUF->flagsreserved & UIP_ND6_NA_FLAG_ROUTER));
|
||||||
uint8_t is_solicited =
|
is_solicited =
|
||||||
((UIP_ND6_NA_BUF->flagsreserved & UIP_ND6_NA_FLAG_SOLICITED));
|
((UIP_ND6_NA_BUF->flagsreserved & UIP_ND6_NA_FLAG_SOLICITED));
|
||||||
uint8_t is_override =
|
is_override =
|
||||||
((UIP_ND6_NA_BUF->flagsreserved & UIP_ND6_NA_FLAG_OVERRIDE));
|
((UIP_ND6_NA_BUF->flagsreserved & UIP_ND6_NA_FLAG_OVERRIDE));
|
||||||
|
|
||||||
#if UIP_CONF_IPV6_CHECKS
|
#if UIP_CONF_IPV6_CHECKS
|
||||||
|
|
|
@ -117,8 +117,10 @@ send_packet(mac_callback_t sent, void *ptr)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* here we send the data over SLIP to the radio-chip */
|
/* here we send the data over SLIP to the radio-chip */
|
||||||
|
size = 0;
|
||||||
|
#if SERIALIZE_ATTRIBUTES
|
||||||
size = packetutils_serialize_atts(&buf[3], sizeof(buf) - 3);
|
size = packetutils_serialize_atts(&buf[3], sizeof(buf) - 3);
|
||||||
|
#endif
|
||||||
if(size < 0 || size + packetbuf_totlen() + 3 > sizeof(buf)) {
|
if(size < 0 || size + packetbuf_totlen() + 3 > sizeof(buf)) {
|
||||||
PRINTF("br-rdc: send failed, too large header\n");
|
PRINTF("br-rdc: send failed, too large header\n");
|
||||||
mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1);
|
mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1);
|
||||||
|
|
|
@ -45,6 +45,8 @@
|
||||||
#undef WEBSERVER_CONF_CFS_CONNS
|
#undef WEBSERVER_CONF_CFS_CONNS
|
||||||
#define WEBSERVER_CONF_CFS_CONNS 2
|
#define WEBSERVER_CONF_CFS_CONNS 2
|
||||||
|
|
||||||
|
#define SERIALIZE_ATTRIBUTES 1
|
||||||
|
|
||||||
#define CMD_CONF_OUTPUT border_router_cmd_output
|
#define CMD_CONF_OUTPUT border_router_cmd_output
|
||||||
|
|
||||||
#undef NETSTACK_CONF_RDC
|
#undef NETSTACK_CONF_RDC
|
||||||
|
|
|
@ -125,13 +125,13 @@ void
|
||||||
ifconf(const char *tundev, const char *ipaddr)
|
ifconf(const char *tundev, const char *ipaddr)
|
||||||
{
|
{
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
ssystem("ifconfig %s inet6 `hostname` up", tundev);
|
ssystem("ifconfig %s inet `hostname` up", tundev);
|
||||||
ssystem("ifconfig %s add %s", tundev, ipaddr);
|
ssystem("ifconfig %s add %s", tundev, ipaddr);
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
ssystem("ifconfig %s inet6 %s up", tundev, ipaddr);
|
ssystem("ifconfig %s inet6 %s up", tundev, ipaddr);
|
||||||
ssystem("sysctl -w net.inet.ip.forwarding=1");
|
ssystem("sysctl -w net.inet.ip.forwarding=1");
|
||||||
#else
|
#else
|
||||||
ssystem("ifconfig %s inet6 `hostname` %s up", tundev, ipaddr);
|
ssystem("ifconfig %s inet `hostname` %s up", tundev, ipaddr);
|
||||||
ssystem("sysctl -w net.inet.ip.forwarding=1");
|
ssystem("sysctl -w net.inet.ip.forwarding=1");
|
||||||
#endif /* !linux */
|
#endif /* !linux */
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,9 @@ PROCESS_THREAD(udp_client_process, ev, data)
|
||||||
{
|
{
|
||||||
static struct etimer periodic;
|
static struct etimer periodic;
|
||||||
static struct ctimer backoff_timer;
|
static struct ctimer backoff_timer;
|
||||||
|
#if WITH_COMPOWER
|
||||||
static int print = 0;
|
static int print = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
|
|
|
@ -106,9 +106,9 @@ ifdef SYMBOLS
|
||||||
endif ## SYMBOLS
|
endif ## SYMBOLS
|
||||||
ifdef REDEF_PRINTF
|
ifdef REDEF_PRINTF
|
||||||
@echo Redefining printf
|
@echo Redefining printf
|
||||||
-$(foreach OBJ,$^, objcopy --redefine-sym printf=log_printf $(OBJ); )
|
-$(foreach OBJ,$^, $(OBJCOPY) --redefine-sym printf=log_printf $(OBJ); )
|
||||||
-$(foreach OBJ,$^, objcopy --redefine-sym puts=log_puts $(OBJ); )
|
-$(foreach OBJ,$^, $(OBJCOPY) --redefine-sym puts=log_puts $(OBJ); )
|
||||||
-$(foreach OBJ,$^, objcopy --redefine-sym putchar=log_putchar $(OBJ); )
|
-$(foreach OBJ,$^, $(OBJCOPY) --redefine-sym putchar=log_putchar $(OBJ); )
|
||||||
endif ## REDEF_PRINTF
|
endif ## REDEF_PRINTF
|
||||||
$(LINK_COMMAND_1) $^ $(LINK_COMMAND_2)
|
$(LINK_COMMAND_1) $^ $(LINK_COMMAND_2)
|
||||||
|
|
||||||
|
|
|
@ -45,9 +45,11 @@
|
||||||
#include "dev/cooja-radio.h"
|
#include "dev/cooja-radio.h"
|
||||||
|
|
||||||
#define COOJA_RADIO_BUFSIZE PACKETBUF_SIZE
|
#define COOJA_RADIO_BUFSIZE PACKETBUF_SIZE
|
||||||
|
|
||||||
#define CCA_SS_THRESHOLD -95
|
#define CCA_SS_THRESHOLD -95
|
||||||
|
|
||||||
|
#define WITH_TURNAROUND 1
|
||||||
|
#define WITH_SEND_CCA 1
|
||||||
|
|
||||||
const struct simInterface radio_interface;
|
const struct simInterface radio_interface;
|
||||||
|
|
||||||
/* COOJA */
|
/* COOJA */
|
||||||
|
@ -109,16 +111,16 @@ radio_off(void)
|
||||||
static void
|
static void
|
||||||
doInterfaceActionsBeforeTick(void)
|
doInterfaceActionsBeforeTick(void)
|
||||||
{
|
{
|
||||||
if (!simRadioHWOn) {
|
if(!simRadioHWOn) {
|
||||||
simInSize = 0;
|
simInSize = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (simReceiving) {
|
if(simReceiving) {
|
||||||
simLastSignalStrength = simSignalStrength;
|
simLastSignalStrength = simSignalStrength;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (simInSize > 0) {
|
if(simInSize > 0) {
|
||||||
process_poll(&cooja_radio_process);
|
process_poll(&cooja_radio_process);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +135,7 @@ radio_read(void *buf, unsigned short bufsize)
|
||||||
{
|
{
|
||||||
int tmp = simInSize;
|
int tmp = simInSize;
|
||||||
|
|
||||||
if (simInSize == 0) {
|
if(simInSize == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(bufsize < simInSize) {
|
if(bufsize < simInSize) {
|
||||||
|
@ -148,10 +150,25 @@ radio_read(void *buf, unsigned short bufsize)
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int
|
static int
|
||||||
|
channel_clear(void)
|
||||||
|
{
|
||||||
|
if(simSignalStrength > CCA_SS_THRESHOLD) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static int
|
||||||
radio_send(const void *payload, unsigned short payload_len)
|
radio_send(const void *payload, unsigned short payload_len)
|
||||||
{
|
{
|
||||||
int radiostate = simRadioHWOn;
|
int radiostate = simRadioHWOn;
|
||||||
|
|
||||||
|
/* Simulate turnaround time of 1ms */
|
||||||
|
#if WITH_TURNAROUND
|
||||||
|
simProcessRunValue = 1;
|
||||||
|
cooja_mt_yield();
|
||||||
|
#endif /* WITH_TURNAROUND */
|
||||||
|
|
||||||
if(!simRadioHWOn) {
|
if(!simRadioHWOn) {
|
||||||
/* Turn on radio temporarily */
|
/* Turn on radio temporarily */
|
||||||
simRadioHWOn = 1;
|
simRadioHWOn = 1;
|
||||||
|
@ -166,6 +183,13 @@ radio_send(const void *payload, unsigned short payload_len)
|
||||||
return RADIO_TX_ERR;
|
return RADIO_TX_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Transmit on CCA */
|
||||||
|
#if WITH_SEND_CCA
|
||||||
|
if(!channel_clear()) {
|
||||||
|
return RADIO_TX_COLLISION;
|
||||||
|
}
|
||||||
|
#endif /* WITH_SEND_CCA */
|
||||||
|
|
||||||
/* Copy packet data to temporary storage */
|
/* Copy packet data to temporary storage */
|
||||||
memcpy(simOutDataBuffer, payload, payload_len);
|
memcpy(simOutDataBuffer, payload, payload_len);
|
||||||
simOutSize = payload_len;
|
simOutSize = payload_len;
|
||||||
|
@ -208,15 +232,6 @@ pending_packet(void)
|
||||||
return !simReceiving && simInSize > 0;
|
return !simReceiving && simInSize > 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int
|
|
||||||
channel_clear(void)
|
|
||||||
{
|
|
||||||
if(simSignalStrength > CCA_SS_THRESHOLD) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
PROCESS_THREAD(cooja_radio_process, ev, data)
|
PROCESS_THREAD(cooja_radio_process, ev, data)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
#ifndef __CONTIKI_CONF_H__
|
#ifndef __CONTIKI_CONF_H__
|
||||||
#define __CONTIKI_CONF_H__
|
#define __CONTIKI_CONF_H__
|
||||||
|
|
||||||
|
#define PLATFORM_HAS_LEDS 1
|
||||||
|
#define PLATFORM_HAS_BUTTON 1
|
||||||
|
#define PLATFORM_HAS_BATTERY 1
|
||||||
|
|
||||||
/* DCO speed resynchronization for more robust UART, etc. */
|
/* DCO speed resynchronization for more robust UART, etc. */
|
||||||
#define DCOSYNCH_CONF_ENABLED 1
|
#define DCOSYNCH_CONF_ENABLED 1
|
||||||
#define DCOSYNCH_CONF_PERIOD 30
|
#define DCOSYNCH_CONF_PERIOD 30
|
||||||
|
@ -11,15 +15,6 @@
|
||||||
#define PROFILE_CONF_ON 0
|
#define PROFILE_CONF_ON 0
|
||||||
#define ENERGEST_CONF_ON 1
|
#define ENERGEST_CONF_ON 1
|
||||||
|
|
||||||
#ifdef __IAR_SYSTEMS_ICC__
|
|
||||||
#define __MSP430F149__ 1
|
|
||||||
#define __MSP430__ 1
|
|
||||||
#define CC_CONF_INLINE
|
|
||||||
#define BV(x) (1 << x)
|
|
||||||
#else
|
|
||||||
#define CC_CONF_INLINE inline
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define HAVE_STDINT_H
|
#define HAVE_STDINT_H
|
||||||
#include "msp430def.h"
|
#include "msp430def.h"
|
||||||
|
|
||||||
|
|
|
@ -305,8 +305,6 @@ main(void)
|
||||||
watchdog_start();
|
watchdog_start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* char *arg_alloc(char size) {return NULL;} */
|
/* char *arg_alloc(char size) {return NULL;} */
|
||||||
|
|
|
@ -1,19 +1,8 @@
|
||||||
# $Id: Makefile.z1,v 1.4 2010/11/07 08:40:24 enricmcalvo Exp $
|
# $Id: Makefile.z1,v 1.4 2010/11/07 08:40:24 enricmcalvo Exp $
|
||||||
# msp430flasher -n msp430x5437 -w "Firmware.txt" -v -z [VCC]
|
# msp430flasher -n msp430x5437 -w "Firmware.txt" -v -z [VCC]
|
||||||
|
|
||||||
ifndef IAR
|
|
||||||
GCC=1
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef GCC
|
|
||||||
CFLAGS+=-Os -g
|
|
||||||
else
|
|
||||||
IAR=1
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef IAR
|
ifdef IAR
|
||||||
CFLAGS+=-e --vla -Ohz --multiplier=32 --multiplier_location=4C0 --hw_workaround=CPU40 --core=430X --data_model small --double=32 -D__MSP430F5438A__
|
CFLAGS+=-e --vla -Ohz --multiplier=32 --multiplier_location=4C0 --hw_workaround=CPU40 --core=430X --data_model small --double=32 -D__MSP430F5438A__=1
|
||||||
CFLAGS += --diag_suppress=Pa050
|
|
||||||
#CFLAGS+=--no_cse --no_unroll --no_inline --no_code_motion --no_tbaa --debug -D__MSP430F5438A__ -e --double=32 --dlib_config 'C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.0 Evaluation\430\LIB\DLIB\dl430xsfn.h' --core=430X --data_model=small -Ol --multiplier=32 --multiplier_location=4C0 --hw_workaround=CPU40
|
#CFLAGS+=--no_cse --no_unroll --no_inline --no_code_motion --no_tbaa --debug -D__MSP430F5438A__ -e --double=32 --dlib_config 'C:\Program Files (x86)\IAR Systems\Embedded Workbench 6.0 Evaluation\430\LIB\DLIB\dl430xsfn.h' --core=430X --data_model=small -Ol --multiplier=32 --multiplier_location=4C0 --hw_workaround=CPU40
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -43,7 +32,7 @@ help:
|
||||||
@echo make help - shows this help
|
@echo make help - shows this help
|
||||||
@echo make TARGET=exp5438 savetarget - stores selection of target to avoid using TARGET= on every make invokation
|
@echo make TARGET=exp5438 savetarget - stores selection of target to avoid using TARGET= on every make invokation
|
||||||
@echo make program.upload - compiles and uploads program to connected board
|
@echo make program.upload - compiles and uploads program to connected board
|
||||||
@echo make program.upload GCC=1 - uses the mspgcc compiler instead of IAR
|
@echo make program.upload IAR=1 - uses the IAR compiler instead of mspgcc
|
||||||
@echo make program.upload NODEID=x - uploads with node_id set to x
|
@echo make program.upload NODEID=x - uploads with node_id set to x
|
||||||
|
|
||||||
CONTIKI_TARGET_DIRS = . dev apps net
|
CONTIKI_TARGET_DIRS = . dev apps net
|
||||||
|
@ -70,19 +59,12 @@ contiki-$(TARGET).a: ${addprefix $(OBJECTDIR)/,symbols.o}
|
||||||
|
|
||||||
ifdef IAR
|
ifdef IAR
|
||||||
STACKSIZE=300
|
STACKSIZE=300
|
||||||
LDFLAGS_ELF=-B -xm "$(IAR_PATH)/lib/dlib/dl430xsfn.r43" -f "$(IAR_PATH)/config/lnk430f5437.xcl" -l contiki-$(TARGET).map -Felf -yn -s __program_start -D_STACK_SIZE=$(STACKSIZE) -D_DATA16_HEAP_SIZE=$(STACKSIZE) -D_DATA20_HEAP_SIZE=$(STACKSIZE)
|
LDFLAGSNO += -B -xm "$(IAR_PATH)/lib/dlib/dl430xsfn.r43" -f "$(IAR_PATH)/config/lnk430f5437.xcl" -l contiki-$(TARGET).map -s __program_start -D_STACK_SIZE=$(STACKSIZE) -D_DATA16_HEAP_SIZE=$(STACKSIZE) -D_DATA20_HEAP_SIZE=$(STACKSIZE)
|
||||||
|
LDFLAGS += $(LDFLAGSNO) -Felf -yn
|
||||||
|
endif
|
||||||
|
|
||||||
LDFLAGS_HEX=-B -xm "$(IAR_PATH)/lib/dlib/dl430xsfn.r43" -f "$(IAR_PATH)/config/lnk430f5437.xcl" -l contiki-$(TARGET).map -Fintel-extended -s __program_start -D_STACK_SIZE=$(STACKSIZE) -D_DATA16_HEAP_SIZE=$(STACKSIZE) -D_DATA20_HEAP_SIZE=$(STACKSIZE)
|
|
||||||
|
|
||||||
LDFLAGS+=$(LDFLAGS_ELF)
|
|
||||||
|
|
||||||
%.hex: %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
|
|
||||||
$(LD) $(LDFLAGS_HEX) $(TARGET_STARTFILES) ${filter-out %.a,$^} ${filter %.a,$^} $(TARGET_LIBFILES) -o $@
|
|
||||||
|
|
||||||
else
|
|
||||||
%.hex: %.ihex
|
%.hex: %.ihex
|
||||||
mv $< $@
|
mv $< $@
|
||||||
endif
|
|
||||||
|
|
||||||
%.upload: %.hex
|
%.upload: %.hex
|
||||||
msp430flasher -n msp430x5438a -e ERASE_MAIN -w $< -v -z [VCC]
|
msp430flasher -n msp430x5438a -e ERASE_MAIN -w $< -v -z [VCC]
|
||||||
|
|
|
@ -31,19 +31,12 @@
|
||||||
|
|
||||||
|
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
|
|
||||||
#ifdef __IAR_SYSTEMS_ICC__
|
|
||||||
#include <msp430.h>
|
|
||||||
#else
|
|
||||||
#include <io.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "contiki-net.h"
|
#include "contiki-net.h"
|
||||||
|
|
||||||
#include "dev/spi.h"
|
#include "dev/spi.h"
|
||||||
#include "dev/cc2420.h"
|
#include "dev/cc2420.h"
|
||||||
#include "dev/leds.h"
|
#include "dev/leds.h"
|
||||||
|
#include "isr_compat.h"
|
||||||
|
|
||||||
#ifndef CONF_SFD_TIMESTAMPS
|
#ifndef CONF_SFD_TIMESTAMPS
|
||||||
#define CONF_SFD_TIMESTAMPS 0
|
#define CONF_SFD_TIMESTAMPS 0
|
||||||
|
@ -54,13 +47,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#ifdef __IAR_SYSTEMS_ICC__
|
ISR(CC2420_IRQ, cc24240_fifop_interrupt)
|
||||||
#pragma vector=CC2420_IRQ_VECTOR
|
|
||||||
__interrupt void
|
|
||||||
#else
|
|
||||||
interrupt(CC2420_IRQ_VECTOR)
|
|
||||||
#endif
|
|
||||||
cc24240_fifop_interrupt(void)
|
|
||||||
{
|
{
|
||||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||||
|
|
||||||
|
|
|
@ -32,18 +32,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "contiki-conf.h"
|
#include "contiki-conf.h"
|
||||||
|
|
||||||
#ifdef __IAR_SYSTEMS_ICC__
|
|
||||||
#include <msp430.h>
|
|
||||||
#else
|
|
||||||
#include <io.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "sys/energest.h"
|
#include "sys/energest.h"
|
||||||
#include "sys/clock.h"
|
#include "sys/clock.h"
|
||||||
#include "sys/etimer.h"
|
#include "sys/etimer.h"
|
||||||
#include "rtimer-arch.h"
|
#include "rtimer-arch.h"
|
||||||
|
#include "isr_compat.h"
|
||||||
|
|
||||||
#include "dev/leds.h"
|
#include "dev/leds.h"
|
||||||
|
|
||||||
|
@ -57,13 +50,7 @@ static volatile clock_time_t count = 0;
|
||||||
/* last_tar is used for calculating clock_fine, last_ccr might be better? */
|
/* last_tar is used for calculating clock_fine, last_ccr might be better? */
|
||||||
static unsigned short last_tar = 0;
|
static unsigned short last_tar = 0;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#ifdef __IAR_SYSTEMS_ICC__
|
ISR(TIMER1_A1, timera1)
|
||||||
#pragma vector=TIMER1_A1_VECTOR
|
|
||||||
__interrupt void
|
|
||||||
#else
|
|
||||||
interrupt(TIMER1_A1_VECTOR)
|
|
||||||
#endif
|
|
||||||
timera1 (void)
|
|
||||||
{
|
{
|
||||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
#ifdef __IAR_SYSTEMS_ICC__
|
|
||||||
#include <msp430.h>
|
|
||||||
#else
|
|
||||||
#include <io.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
|
@ -36,13 +36,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
#ifdef __IAR_SYSTEMS_ICC__
|
|
||||||
#include <msp430.h>
|
|
||||||
#else
|
|
||||||
#include <io.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "dev/flash.h"
|
#include "dev/flash.h"
|
||||||
|
|
|
@ -35,11 +35,6 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "contiki-conf.h"
|
#include "contiki-conf.h"
|
||||||
#ifdef __IAR_SYSTEMS_ICC__
|
|
||||||
#include <msp430.h>
|
|
||||||
#else
|
|
||||||
#include <io.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "hal_MSP-EXP430F5438.h"
|
#include "hal_MSP-EXP430F5438.h"
|
||||||
#include "hal_lcd_fonts.h"
|
#include "hal_lcd_fonts.h"
|
||||||
|
|
|
@ -42,12 +42,6 @@
|
||||||
#include "contiki-conf.h"
|
#include "contiki-conf.h"
|
||||||
#include "dev/leds.h"
|
#include "dev/leds.h"
|
||||||
|
|
||||||
#ifdef __IAR_SYSTEMS_ICC__
|
|
||||||
#include <msp430.h>
|
|
||||||
#else
|
|
||||||
#include <io.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* LED ports */
|
/* LED ports */
|
||||||
#define LEDS_CONF_RED 0x01
|
#define LEDS_CONF_RED 0x01
|
||||||
#define LEDS_CONF_GREEN 0x02
|
#define LEDS_CONF_GREEN 0x02
|
||||||
|
|
|
@ -31,12 +31,6 @@
|
||||||
* @(#)$Id: msp430.c,v 1.1 2010/08/24 16:26:38 joxe Exp $
|
* @(#)$Id: msp430.c,v 1.1 2010/08/24 16:26:38 joxe Exp $
|
||||||
*/
|
*/
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
#ifdef __IAR_SYSTEMS_ICC__
|
|
||||||
#include <msp430.h>
|
|
||||||
#else
|
|
||||||
#include <io.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#endif
|
|
||||||
#include "dev/watchdog.h"
|
#include "dev/watchdog.h"
|
||||||
#include "dev/leds.h"
|
#include "dev/leds.h"
|
||||||
#include "net/uip.h"
|
#include "net/uip.h"
|
||||||
|
|
|
@ -44,19 +44,6 @@
|
||||||
* changeable!
|
* changeable!
|
||||||
*/
|
*/
|
||||||
#define TYNDALL 1
|
#define TYNDALL 1
|
||||||
/* Test for IAR compiler */
|
|
||||||
#ifdef __IAR_SYSTEMS_ICC__
|
|
||||||
#include <intrinsics.h>
|
|
||||||
#include <in430.h>
|
|
||||||
#define dint() __disable_interrupt()
|
|
||||||
#define eint() __enable_interrupt()
|
|
||||||
#define __MSP430F5437__ 1
|
|
||||||
#define __MSP430__ 1
|
|
||||||
#define CC_CONF_INLINE
|
|
||||||
#define BV(x) (1 << x)
|
|
||||||
#else
|
|
||||||
#define CC_CONF_INLINE inline
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* CPU target speed in Hz */
|
/* CPU target speed in Hz */
|
||||||
#define F_CPU 8000000uL // 8MHz by default
|
#define F_CPU 8000000uL // 8MHz by default
|
||||||
|
|
|
@ -39,17 +39,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
#ifdef __IAR_SYSTEMS_ICC__
|
|
||||||
#include <msp430.h>
|
|
||||||
#else
|
|
||||||
#include <io.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "sys/energest.h"
|
#include "sys/energest.h"
|
||||||
#include "sys/rtimer.h"
|
#include "sys/rtimer.h"
|
||||||
#include "sys/process.h"
|
#include "sys/process.h"
|
||||||
#include "dev/watchdog.h"
|
#include "dev/watchdog.h"
|
||||||
|
#include "isr_compat.h"
|
||||||
|
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
@ -60,13 +54,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#ifdef __IAR_SYSTEMS_ICC__
|
ISR(TIMER1_A0, timera0)
|
||||||
#pragma vector=TIMER1_A0_VECTOR
|
{
|
||||||
__interrupt void
|
|
||||||
#else
|
|
||||||
interrupt(TIMER1_A0_VECTOR)
|
|
||||||
#endif
|
|
||||||
timera0 (void) {
|
|
||||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||||
|
|
||||||
watchdog_start();
|
watchdog_start();
|
||||||
|
|
|
@ -30,17 +30,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "contiki-conf.h"
|
#include "contiki-conf.h"
|
||||||
#ifdef __IAR_SYSTEMS_ICC__
|
|
||||||
#include <msp430.h>
|
|
||||||
#else
|
|
||||||
#include <io.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is SPI initialization code for the MSP430X architecture.
|
* This is SPI initialization code for the MSP430X architecture.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
unsigned char spi_busy = 0;
|
/* unsigned char spi_busy = 0; */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/*
|
/*
|
||||||
* Initialize SPI bus.
|
* Initialize SPI bus.
|
||||||
|
|
|
@ -36,13 +36,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
#ifdef __IAR_SYSTEMS_ICC__
|
|
||||||
#include <msp430.h>
|
|
||||||
#else
|
|
||||||
#include <io.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "sys/energest.h"
|
#include "sys/energest.h"
|
||||||
|
@ -50,6 +43,7 @@
|
||||||
#include "dev/watchdog.h"
|
#include "dev/watchdog.h"
|
||||||
#include "lib/ringbuf.h"
|
#include "lib/ringbuf.h"
|
||||||
#include "dev/leds.h"
|
#include "dev/leds.h"
|
||||||
|
#include "isr_compat.h"
|
||||||
|
|
||||||
static int (*uart1_input_handler)(unsigned char c);
|
static int (*uart1_input_handler)(unsigned char c);
|
||||||
|
|
||||||
|
@ -114,13 +108,7 @@ uart1_init(unsigned long ubr)
|
||||||
UCA1IE |= UCRXIE; /* Enable UCA1 RX interrupt */
|
UCA1IE |= UCRXIE; /* Enable UCA1 RX interrupt */
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#ifdef __IAR_SYSTEMS_ICC__
|
ISR(USCI_A1, uart1_rx_interrupt)
|
||||||
#pragma vector=USCI_A1_VECTOR
|
|
||||||
__interrupt void
|
|
||||||
#else
|
|
||||||
interrupt(USCI_A1_VECTOR)
|
|
||||||
#endif
|
|
||||||
uart1_rx_interrupt(void)
|
|
||||||
{
|
{
|
||||||
uint8_t c;
|
uint8_t c;
|
||||||
|
|
||||||
|
|
|
@ -32,13 +32,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "contiki-conf.h"
|
#include "contiki-conf.h"
|
||||||
#ifdef __IAR_SYSTEMS_ICC__
|
|
||||||
#include <msp430.h>
|
|
||||||
#else
|
|
||||||
#include <io.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#endif
|
|
||||||
#include "dev/watchdog.h"
|
#include "dev/watchdog.h"
|
||||||
|
#include "isr_compat.h"
|
||||||
|
|
||||||
static int counter = 0;
|
static int counter = 0;
|
||||||
|
|
||||||
|
@ -76,13 +71,7 @@ printstring(char *s)
|
||||||
#endif /* CONTIKI_TARGET_SKY */
|
#endif /* CONTIKI_TARGET_SKY */
|
||||||
#endif /* PRINT_STACK_ON_REBOOT */
|
#endif /* PRINT_STACK_ON_REBOOT */
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#ifdef __IAR_SYSTEMS_ICC__
|
ISR(WDT, watchdog_interrupt)
|
||||||
#pragma vector=WDT_VECTOR
|
|
||||||
__interrupt void
|
|
||||||
#else
|
|
||||||
interrupt(WDT_VECTOR)
|
|
||||||
#endif
|
|
||||||
watchdog_interrupt(void)
|
|
||||||
{
|
{
|
||||||
#ifdef CONTIKI_TARGET_SKY
|
#ifdef CONTIKI_TARGET_SKY
|
||||||
#if PRINT_STACK_ON_REBOOT
|
#if PRINT_STACK_ON_REBOOT
|
||||||
|
|
|
@ -170,4 +170,17 @@ public class AvrMoteMemory implements MoteMemory, AddressMemory {
|
||||||
public boolean variableExists(String varName) {
|
public boolean variableExists(String varName) {
|
||||||
return memoryMap.getLocation(varName) != null;
|
return memoryMap.getLocation(varName) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean addMemoryMonitor(int address, int size, MemoryMonitor mm) {
|
||||||
|
logger.warn("Not implemented");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeMemoryMonitor(int address, int size, MemoryMonitor mm) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public int parseInt(byte[] memorySegment) {
|
||||||
|
logger.warn("Not implemented");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,9 +270,4 @@ public class MicaZMote extends AbstractEmulatedMote implements Mote {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "MicaZ " + getID();
|
return "MicaZ " + getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MemoryMonitor createMemoryMonitor(MemoryEventHandler meh) {
|
|
||||||
logger.fatal("Not implemented");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -300,6 +300,11 @@ public class MRM extends AbstractRadioMedium {
|
||||||
for (RadioConnection conn : conns) {
|
for (RadioConnection conn : conns) {
|
||||||
for (Radio dstRadio : ((MRMRadioConnection) conn).getDestinations()) {
|
for (Radio dstRadio : ((MRMRadioConnection) conn).getDestinations()) {
|
||||||
double signalStrength = ((MRMRadioConnection) conn).getDestinationSignalStrength(dstRadio);
|
double signalStrength = ((MRMRadioConnection) conn).getDestinationSignalStrength(dstRadio);
|
||||||
|
if (conn.getSource().getChannel() >= 0 &&
|
||||||
|
dstRadio.getChannel() >= 0 &&
|
||||||
|
conn.getSource().getChannel() != dstRadio.getChannel()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (dstRadio.getCurrentSignalStrength() < signalStrength) {
|
if (dstRadio.getCurrentSignalStrength() < signalStrength) {
|
||||||
dstRadio.setCurrentSignalStrength(signalStrength);
|
dstRadio.setCurrentSignalStrength(signalStrength);
|
||||||
}
|
}
|
||||||
|
@ -313,6 +318,11 @@ public class MRM extends AbstractRadioMedium {
|
||||||
if (intfRadio.getCurrentSignalStrength() < signalStrength) {
|
if (intfRadio.getCurrentSignalStrength() < signalStrength) {
|
||||||
intfRadio.setCurrentSignalStrength(signalStrength);
|
intfRadio.setCurrentSignalStrength(signalStrength);
|
||||||
}
|
}
|
||||||
|
if (conn.getSource().getChannel() >= 0 &&
|
||||||
|
intfRadio.getChannel() >= 0 &&
|
||||||
|
conn.getSource().getChannel() != intfRadio.getChannel()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!intfRadio.isInterfered()) {
|
if (!intfRadio.isInterfered()) {
|
||||||
/*logger.warn("Radio was not interfered: " + intfRadio);*/
|
/*logger.warn("Radio was not interfered: " + intfRadio);*/
|
||||||
|
|
|
@ -238,7 +238,7 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
|
||||||
/* Create mote address memory */
|
/* Create mote address memory */
|
||||||
MapTable map = ((MspMoteType)getType()).getELF().getMap();
|
MapTable map = ((MspMoteType)getType()).getELF().getMap();
|
||||||
MapEntry[] allEntries = map.getAllEntries();
|
MapEntry[] allEntries = map.getAllEntries();
|
||||||
myMemory = new MspMoteMemory(allEntries, myCpu);
|
myMemory = new MspMoteMemory(this, allEntries, myCpu);
|
||||||
|
|
||||||
heapStartAddress = map.heapStartAddress;
|
heapStartAddress = map.heapStartAddress;
|
||||||
myCpu.reset();
|
myCpu.reset();
|
||||||
|
@ -539,84 +539,4 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
|
||||||
|
|
||||||
/*return executeCLICommand("line " + myCpu.getPC());*/
|
/*return executeCLICommand("line " + myCpu.getPC());*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public MemoryMonitor createMemoryMonitor(final MemoryEventHandler meh) {
|
|
||||||
return new MemoryMonitor() {
|
|
||||||
private boolean started = false;
|
|
||||||
private int address = -1;
|
|
||||||
private int size = -1;
|
|
||||||
private CPUMonitor myMonitor = null;
|
|
||||||
private boolean isPointer = false;
|
|
||||||
private MemoryMonitor pointedMemory = null;
|
|
||||||
public boolean start(int address, int size) {
|
|
||||||
if (started) {
|
|
||||||
return started;
|
|
||||||
}
|
|
||||||
|
|
||||||
final MemoryMonitor thisMonitor = this;
|
|
||||||
myMonitor = new CPUMonitor() {
|
|
||||||
public void cpuAction(int type, int adr, int data) {
|
|
||||||
MemoryEventType t;
|
|
||||||
if (type == CPUMonitor.MEMORY_WRITE) {
|
|
||||||
t = MemoryEventType.WRITE;
|
|
||||||
} else if (type == CPUMonitor.MEMORY_READ) {
|
|
||||||
t = MemoryEventType.READ;
|
|
||||||
} else {
|
|
||||||
t = MemoryEventType.UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
meh.event(thisMonitor, t, adr, data);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* TODO Make sure no other part of Cooja overrides this! */
|
|
||||||
for (int a = address; a < address+size; a++) {
|
|
||||||
myCpu.addWatchPoint(a, myMonitor);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.address = address;
|
|
||||||
this.size = size;
|
|
||||||
started = true;
|
|
||||||
return started;
|
|
||||||
}
|
|
||||||
public void stop() {
|
|
||||||
if (!started) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
started = false;
|
|
||||||
|
|
||||||
for (int a = address; a < address+size; a++) {
|
|
||||||
myCpu.removeWatchPoint(a, myMonitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public Mote getMote() {
|
|
||||||
return MspMote.this;
|
|
||||||
}
|
|
||||||
public int getAddress() {
|
|
||||||
return address;
|
|
||||||
}
|
|
||||||
public int getSize() {
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPointer() {
|
|
||||||
return isPointer;
|
|
||||||
}
|
|
||||||
public void setPointer(boolean isPointer, MemoryMonitor pointedMemory) {
|
|
||||||
this.isPointer = isPointer;
|
|
||||||
this.pointedMemory = pointedMemory;
|
|
||||||
}
|
|
||||||
public MemoryMonitor getPointedMemory() {
|
|
||||||
return pointedMemory;
|
|
||||||
}
|
|
||||||
|
|
||||||
private BufferAccess lastBufferAccess = null;
|
|
||||||
public void setLastBufferAccess(BufferAccess ba) {
|
|
||||||
this.lastBufferAccess = ba;
|
|
||||||
}
|
|
||||||
public BufferAccess getLastBufferAccess() {
|
|
||||||
return lastBufferAccess;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,11 +29,16 @@
|
||||||
|
|
||||||
package se.sics.cooja.mspmote;
|
package se.sics.cooja.mspmote;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import se.sics.cooja.AddressMemory;
|
import se.sics.cooja.AddressMemory;
|
||||||
|
import se.sics.cooja.Mote;
|
||||||
import se.sics.cooja.MoteMemory;
|
import se.sics.cooja.MoteMemory;
|
||||||
|
import se.sics.cooja.MoteTimeEvent;
|
||||||
|
import se.sics.cooja.TimeEvent;
|
||||||
|
import se.sics.mspsim.core.CPUMonitor;
|
||||||
import se.sics.mspsim.core.MSP430;
|
import se.sics.mspsim.core.MSP430;
|
||||||
import se.sics.mspsim.util.MapEntry;
|
import se.sics.mspsim.util.MapEntry;
|
||||||
|
|
||||||
|
@ -42,8 +47,10 @@ public class MspMoteMemory implements MoteMemory, AddressMemory {
|
||||||
private final ArrayList<MapEntry> mapEntries;
|
private final ArrayList<MapEntry> mapEntries;
|
||||||
|
|
||||||
private MSP430 cpu;
|
private MSP430 cpu;
|
||||||
|
private Mote mote;
|
||||||
|
|
||||||
public MspMoteMemory(MapEntry[] allEntries, MSP430 cpu) {
|
public MspMoteMemory(Mote mote, MapEntry[] allEntries, MSP430 cpu) {
|
||||||
|
this.mote = mote;
|
||||||
this.mapEntries = new ArrayList<MapEntry>();
|
this.mapEntries = new ArrayList<MapEntry>();
|
||||||
|
|
||||||
for (MapEntry entry: allEntries) {
|
for (MapEntry entry: allEntries) {
|
||||||
|
@ -130,13 +137,7 @@ public class MspMoteMemory implements MoteMemory, AddressMemory {
|
||||||
|
|
||||||
int varAddr = entry.getAddress();
|
int varAddr = entry.getAddress();
|
||||||
byte[] varData = getMemorySegment(varAddr, 2);
|
byte[] varData = getMemorySegment(varAddr, 2);
|
||||||
|
return parseInt(varData);
|
||||||
int retVal = 0;
|
|
||||||
int pos = 0;
|
|
||||||
retVal += ((varData[pos++] & 0xFF)) << 8;
|
|
||||||
retVal += ((varData[pos++] & 0xFF)) << 0;
|
|
||||||
|
|
||||||
return Integer.reverseBytes(retVal) >> 16; // Crop two bytes
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIntValueOf(String varName, int newVal) throws UnknownVariableException {
|
public void setIntValueOf(String varName, int newVal) throws UnknownVariableException {
|
||||||
|
@ -179,7 +180,6 @@ public class MspMoteMemory implements MoteMemory, AddressMemory {
|
||||||
MapEntry entry = getMapEntry(varName);
|
MapEntry entry = getMapEntry(varName);
|
||||||
int varAddr = entry.getAddress();
|
int varAddr = entry.getAddress();
|
||||||
|
|
||||||
// TODO Check if small/big-endian when coming from JNI?
|
|
||||||
return getMemorySegment(varAddr, length);
|
return getMemorySegment(varAddr, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,8 +187,74 @@ public class MspMoteMemory implements MoteMemory, AddressMemory {
|
||||||
MapEntry entry = getMapEntry(varName);
|
MapEntry entry = getMapEntry(varName);
|
||||||
int varAddr = entry.getAddress();
|
int varAddr = entry.getAddress();
|
||||||
|
|
||||||
// TODO Check if small/big-endian when coming from JNI?
|
|
||||||
setMemorySegment(varAddr, data);
|
setMemorySegment(varAddr, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ArrayList<MemoryCPUMonitor> cpuMonitorArray = new ArrayList<MemoryCPUMonitor>();
|
||||||
|
class MemoryCPUMonitor implements CPUMonitor {
|
||||||
|
public final MemoryMonitor mm;
|
||||||
|
public final int address;
|
||||||
|
public final int size;
|
||||||
|
|
||||||
|
public MemoryCPUMonitor(MemoryMonitor mm, int address, int size) {
|
||||||
|
this.mm = mm;
|
||||||
|
this.address = address;
|
||||||
|
this.size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cpuAction(int type, final int adr, int data) {
|
||||||
|
final MemoryEventType t;
|
||||||
|
if (type == CPUMonitor.MEMORY_WRITE) {
|
||||||
|
t = MemoryEventType.WRITE;
|
||||||
|
} else {
|
||||||
|
t = MemoryEventType.READ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* XXX Workaround to avoid using soon-obsolete data argument.
|
||||||
|
* This causes a delay between memory rw and listener notifications */
|
||||||
|
TimeEvent e = new MoteTimeEvent(mote, 0) {
|
||||||
|
public void execute(long time) {
|
||||||
|
mm.memoryChanged(MspMoteMemory.this, t, adr);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
mote.getSimulation().scheduleEvent(e, mote.getSimulation().getSimulationTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addMemoryMonitor(int address, int size, MemoryMonitor mm) {
|
||||||
|
MemoryCPUMonitor t = new MemoryCPUMonitor(mm, address, size);
|
||||||
|
cpuMonitorArray.add(t);
|
||||||
|
|
||||||
|
for (int a = address; a < address+size; a++) {
|
||||||
|
cpu.addWatchPoint(a, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeMemoryMonitor(int address, int size, MemoryMonitor mm) {
|
||||||
|
for (MemoryCPUMonitor mcm: cpuMonitorArray) {
|
||||||
|
if (mcm.mm != mm || mcm.address != address || mcm.size != size) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (int a = address; a < address+size; a++) {
|
||||||
|
cpu.removeWatchPoint(a, mcm);
|
||||||
|
}
|
||||||
|
cpuMonitorArray.remove(mcm);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int parseInt(byte[] memorySegment) {
|
||||||
|
if (memorySegment.length < 2) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int retVal = 0;
|
||||||
|
int pos = 0;
|
||||||
|
retVal += ((memorySegment[pos++] & 0xFF)) << 8;
|
||||||
|
retVal += ((memorySegment[pos++] & 0xFF)) << 0;
|
||||||
|
|
||||||
|
return Integer.reverseBytes(retVal) >> 16;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,8 +82,8 @@ public class SkyByteRadio extends Radio implements CustomDataRadio {
|
||||||
private RadioPacket lastOutgoingPacket = null;
|
private RadioPacket lastOutgoingPacket = null;
|
||||||
private RadioPacket lastIncomingPacket = null;
|
private RadioPacket lastIncomingPacket = null;
|
||||||
|
|
||||||
public SkyByteRadio(Mote mote) {
|
public SkyByteRadio(Mote m) {
|
||||||
this.mote = (MspMote)mote;
|
this.mote = (MspMote)m;
|
||||||
this.cc2420 = (CC2420) this.mote.getCPU().getChip(CC2420.class);
|
this.cc2420 = (CC2420) this.mote.getCPU().getChip(CC2420.class);
|
||||||
if (cc2420 == null) {
|
if (cc2420 == null) {
|
||||||
throw new IllegalStateException("Mote is not equipped with a CC2420");
|
throw new IllegalStateException("Mote is not equipped with a CC2420");
|
||||||
|
@ -98,6 +98,7 @@ public class SkyByteRadio extends Radio implements CustomDataRadio {
|
||||||
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
||||||
lastEvent = RadioEvent.TRANSMISSION_STARTED;
|
lastEvent = RadioEvent.TRANSMISSION_STARTED;
|
||||||
isTransmitting = true;
|
isTransmitting = true;
|
||||||
|
len = 0;
|
||||||
/*logger.debug("----- SKY TRANSMISSION STARTED -----");*/
|
/*logger.debug("----- SKY TRANSMISSION STARTED -----");*/
|
||||||
setChanged();
|
setChanged();
|
||||||
notifyObservers();
|
notifyObservers();
|
||||||
|
@ -133,9 +134,6 @@ public class SkyByteRadio extends Radio implements CustomDataRadio {
|
||||||
setChanged();
|
setChanged();
|
||||||
notifyObservers();
|
notifyObservers();
|
||||||
|
|
||||||
|
|
||||||
// System.out.println("## CC2420 Transmission finished...");
|
|
||||||
|
|
||||||
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
||||||
/*logger.debug("----- SKY TRANSMISSION FINISHED -----");*/
|
/*logger.debug("----- SKY TRANSMISSION FINISHED -----");*/
|
||||||
isTransmitting = false;
|
isTransmitting = false;
|
||||||
|
@ -150,36 +148,59 @@ public class SkyByteRadio extends Radio implements CustomDataRadio {
|
||||||
cc2420.addOperatingModeListener(new OperatingModeListener() {
|
cc2420.addOperatingModeListener(new OperatingModeListener() {
|
||||||
public void modeChanged(Chip source, int mode) {
|
public void modeChanged(Chip source, int mode) {
|
||||||
if (isReceiverOn()) {
|
if (isReceiverOn()) {
|
||||||
|
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
||||||
lastEvent = RadioEvent.HW_ON;
|
lastEvent = RadioEvent.HW_ON;
|
||||||
|
setChanged();
|
||||||
|
notifyObservers();
|
||||||
} else {
|
} else {
|
||||||
/* Radio was turned off during transmission.
|
radioOff();
|
||||||
* May for example happen if watchdog triggers */
|
|
||||||
if (isTransmitting()) {
|
|
||||||
logger.fatal("Turning off radio while transmitting");
|
|
||||||
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
|
||||||
/*logger.debug("----- SKY TRANSMISSION FINISHED -----");*/
|
|
||||||
isTransmitting = false;
|
|
||||||
lastEvent = RadioEvent.TRANSMISSION_FINISHED;
|
|
||||||
setChanged();
|
|
||||||
notifyObservers();
|
|
||||||
}
|
|
||||||
lastEvent = RadioEvent.HW_OFF;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cc2420.setChannelListener(new CC2420.ChannelListener() {
|
||||||
|
public void changedChannel(int channel) {
|
||||||
|
/* XXX Currently assumes zero channel switch time */
|
||||||
|
lastEvent = RadioEvent.UNKNOWN;
|
||||||
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
||||||
setChanged();
|
setChanged();
|
||||||
notifyObservers();
|
notifyObservers();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
cc2420.setChannelListener(new CC2420.ChannelListener() {
|
private void radioOff() {
|
||||||
public void changedChannel(int channel) {
|
/* Radio was turned off during transmission.
|
||||||
/* XXX Currently assumes zero channel switch time */
|
* May for example happen if watchdog triggers */
|
||||||
lastEvent = RadioEvent.UNKNOWN;
|
if (isTransmitting()) {
|
||||||
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
logger.warn("Turning off radio while transmitting, ending packet prematurely");
|
||||||
setChanged();
|
|
||||||
notifyObservers();
|
/* Simulate end of packet */
|
||||||
}
|
lastOutgoingPacket = new RadioPacket() {
|
||||||
});
|
public byte[] getPacketData() {
|
||||||
|
return new byte[0];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
||||||
|
lastEvent = RadioEvent.PACKET_TRANSMITTED;
|
||||||
|
/*logger.debug("----- SKY PACKET TRANSMITTED -----");*/
|
||||||
|
setChanged();
|
||||||
|
notifyObservers();
|
||||||
|
|
||||||
|
/* Register that transmission ended in radio medium */
|
||||||
|
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
||||||
|
/*logger.debug("----- SKY TRANSMISSION FINISHED -----");*/
|
||||||
|
isTransmitting = false;
|
||||||
|
lastEvent = RadioEvent.TRANSMISSION_FINISHED;
|
||||||
|
setChanged();
|
||||||
|
notifyObservers();
|
||||||
|
}
|
||||||
|
|
||||||
|
lastEventTime = SkyByteRadio.this.mote.getSimulation().getSimulationTime();
|
||||||
|
lastEvent = RadioEvent.HW_OFF;
|
||||||
|
setChanged();
|
||||||
|
notifyObservers();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Packet radio support */
|
/* Packet radio support */
|
||||||
|
|
|
@ -108,6 +108,20 @@ The COOJA Simulator
|
||||||
</java>
|
</java>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
<target name="run64" depends="init, compile, jar, copy configs">
|
||||||
|
<java fork="yes" dir="${build}" classname="se.sics.cooja.GUI" maxmemory="512m">
|
||||||
|
<sysproperty key="user.language" value="en"/>
|
||||||
|
<jvmarg value="-d64 -XX:+ShowMessageBoxOnError"/>
|
||||||
|
<arg line="${args}"/>
|
||||||
|
<env key="LD_LIBRARY_PATH" value="."/>
|
||||||
|
<classpath>
|
||||||
|
<pathelement path="${build}"/>
|
||||||
|
<pathelement location="lib/jdom.jar"/>
|
||||||
|
<pathelement location="lib/log4j.jar"/>
|
||||||
|
</classpath>
|
||||||
|
</java>
|
||||||
|
</target>
|
||||||
|
|
||||||
<target name="run_errorbox" depends="init, compile, jar, copy configs">
|
<target name="run_errorbox" depends="init, compile, jar, copy configs">
|
||||||
<java fork="yes" dir="${build}" classname="se.sics.cooja.GUI" maxmemory="512m">
|
<java fork="yes" dir="${build}" classname="se.sics.cooja.GUI" maxmemory="512m">
|
||||||
<sysproperty key="user.language" value="en"/>
|
<sysproperty key="user.language" value="en"/>
|
||||||
|
|
|
@ -6,6 +6,7 @@ PATH_AR = ar
|
||||||
PATH_SHELL = sh
|
PATH_SHELL = sh
|
||||||
PATH_C_COMPILER = gcc
|
PATH_C_COMPILER = gcc
|
||||||
PATH_OBJDUMP=objdump
|
PATH_OBJDUMP=objdump
|
||||||
|
PATH_OBJCOPY=objcopy
|
||||||
OBJDUMP_ARGS=-h
|
OBJDUMP_ARGS=-h
|
||||||
CMD_GREP_PROCESSES = grep "^PROCESS_THREAD[ ]*([^,]*,[^,]*,[^)]*)" -o -H
|
CMD_GREP_PROCESSES = grep "^PROCESS_THREAD[ ]*([^,]*,[^,]*,[^)]*)" -o -H
|
||||||
REGEXP_PARSE_PROCESSES = ([^/]*.c):PROCESS_THREAD[ ]*\\(([^,]*),[^,]*,[^)]*\\)
|
REGEXP_PARSE_PROCESSES = ([^/]*.c):PROCESS_THREAD[ ]*\\(([^,]*),[^,]*,[^)]*\\)
|
||||||
|
|
|
@ -6,6 +6,7 @@ PATH_AR = ar
|
||||||
PATH_SHELL = sh
|
PATH_SHELL = sh
|
||||||
PATH_C_COMPILER = gcc
|
PATH_C_COMPILER = gcc
|
||||||
PATH_OBJDUMP=objdump
|
PATH_OBJDUMP=objdump
|
||||||
|
PATH_OBJCOPY=objcopy
|
||||||
OBJDUMP_ARGS=-h
|
OBJDUMP_ARGS=-h
|
||||||
CMD_GREP_PROCESSES = grep "^PROCESS_THREAD[ ]*([^,]*,[^,]*,[^)]*)" -o -H
|
CMD_GREP_PROCESSES = grep "^PROCESS_THREAD[ ]*([^,]*,[^,]*,[^)]*)" -o -H
|
||||||
REGEXP_PARSE_PROCESSES = ([^/]*.c):PROCESS_THREAD[ ]*\\(([^,]*),[^,]*,[^)]*\\)
|
REGEXP_PARSE_PROCESSES = ([^/]*.c):PROCESS_THREAD[ ]*\\(([^,]*),[^,]*,[^)]*\\)
|
||||||
|
|
|
@ -6,6 +6,7 @@ PATH_AR = ar
|
||||||
PATH_SHELL = sh
|
PATH_SHELL = sh
|
||||||
PATH_C_COMPILER = gcc
|
PATH_C_COMPILER = gcc
|
||||||
PATH_OBJDUMP=objdump
|
PATH_OBJDUMP=objdump
|
||||||
|
PATH_OBJCOPY=objcopy
|
||||||
OBJDUMP_ARGS=-h
|
OBJDUMP_ARGS=-h
|
||||||
CMD_GREP_PROCESSES = grep "^PROCESS_THREAD[ ]*([^,]*,[^,]*,[^)]*)" -o -H
|
CMD_GREP_PROCESSES = grep "^PROCESS_THREAD[ ]*([^,]*,[^,]*,[^)]*)" -o -H
|
||||||
REGEXP_PARSE_PROCESSES = ([^/]*.c):PROCESS_THREAD[ ]*\\(([^,]*),[^,]*,[^)]*\\)
|
REGEXP_PARSE_PROCESSES = ([^/]*.c):PROCESS_THREAD[ ]*\\(([^,]*),[^,]*,[^)]*\\)
|
||||||
|
|
|
@ -6,6 +6,7 @@ PATH_AR = ar
|
||||||
PATH_SHELL = sh
|
PATH_SHELL = sh
|
||||||
PATH_C_COMPILER = gcc
|
PATH_C_COMPILER = gcc
|
||||||
PATH_OBJDUMP= objdump
|
PATH_OBJDUMP= objdump
|
||||||
|
PATH_OBJCOPY=objcopy
|
||||||
OBJDUMP_ARGS= -h
|
OBJDUMP_ARGS= -h
|
||||||
CMD_GREP_PROCESSES = grep "^PROCESS_THREAD[ ]*([^,]*,[^,]*,[^)]*)" -o -H
|
CMD_GREP_PROCESSES = grep "^PROCESS_THREAD[ ]*([^,]*,[^,]*,[^)]*)" -o -H
|
||||||
REGEXP_PARSE_PROCESSES = ([^/]*.c):PROCESS_THREAD[ ]*\\(([^,]*),[^,]*,[^)]*\\)
|
REGEXP_PARSE_PROCESSES = ([^/]*.c):PROCESS_THREAD[ ]*\\(([^,]*),[^,]*,[^)]*\\)
|
||||||
|
|
|
@ -6,6 +6,7 @@ PATH_AR=ar
|
||||||
PATH_SHELL = sh
|
PATH_SHELL = sh
|
||||||
PATH_C_COMPILER = gcc
|
PATH_C_COMPILER = gcc
|
||||||
PATH_OBJDUMP=objdump
|
PATH_OBJDUMP=objdump
|
||||||
|
PATH_OBJCOPY=objcopy
|
||||||
OBJDUMP_ARGS=-h
|
OBJDUMP_ARGS=-h
|
||||||
CMD_GREP_PROCESSES = grep '^PROCESS_THREAD[ ]*([^,]*,[^,]*,[^)]*)' -o -d skip -D skip -H -r
|
CMD_GREP_PROCESSES = grep '^PROCESS_THREAD[ ]*([^,]*,[^,]*,[^)]*)' -o -d skip -D skip -H -r
|
||||||
REGEXP_PARSE_PROCESSES = ([^/]*.c):PROCESS_THREAD[ ]*\\(([^,]*),[^,]*,[^)]*\\)
|
REGEXP_PARSE_PROCESSES = ([^/]*.c):PROCESS_THREAD[ ]*\\(([^,]*),[^,]*,[^)]*\\)
|
||||||
|
@ -24,7 +25,7 @@ PATH_JAVAC = javac
|
||||||
DEFAULT_PROJECTDIRS = [CONTIKI_DIR]/tools/cooja/apps/mrm;[CONTIKI_DIR]/tools/cooja/apps/mspsim;[CONTIKI_DIR]/tools/cooja/apps/avrora;[CONTIKI_DIR]/tools/cooja/apps/serial_socket;[CONTIKI_DIR]/tools/cooja/apps/collect-view
|
DEFAULT_PROJECTDIRS = [CONTIKI_DIR]/tools/cooja/apps/mrm;[CONTIKI_DIR]/tools/cooja/apps/mspsim;[CONTIKI_DIR]/tools/cooja/apps/avrora;[CONTIKI_DIR]/tools/cooja/apps/serial_socket;[CONTIKI_DIR]/tools/cooja/apps/collect-view
|
||||||
|
|
||||||
PARSE_WITH_COMMAND = true
|
PARSE_WITH_COMMAND = true
|
||||||
PARSE_COMMAND=nm -C $(LIBFILE)
|
PARSE_COMMAND=nm -n -C $(LIBFILE)
|
||||||
MAPFILE_DATA_START = ^.data[ \t]*0x([0-9A-Fa-f]*)[ \t]*0x[0-9A-Fa-f]*[ \t]*$
|
MAPFILE_DATA_START = ^.data[ \t]*0x([0-9A-Fa-f]*)[ \t]*0x[0-9A-Fa-f]*[ \t]*$
|
||||||
MAPFILE_DATA_SIZE = ^.data[ \t]*0x[0-9A-Fa-f]*[ \t]*0x([0-9A-Fa-f]*)[ \t]*$
|
MAPFILE_DATA_SIZE = ^.data[ \t]*0x[0-9A-Fa-f]*[ \t]*0x([0-9A-Fa-f]*)[ \t]*$
|
||||||
MAPFILE_BSS_START = ^.bss[ \t]*0x([0-9A-Fa-f]*)[ \t]*0x[0-9A-Fa-f]*[ \t]*$
|
MAPFILE_BSS_START = ^.bss[ \t]*0x([0-9A-Fa-f]*)[ \t]*0x[0-9A-Fa-f]*[ \t]*$
|
||||||
|
@ -35,7 +36,7 @@ MAPFILE_VAR_ADDRESS_2 = [ \t]*$
|
||||||
MAPFILE_VAR_SIZE_1 = ^
|
MAPFILE_VAR_SIZE_1 = ^
|
||||||
MAPFILE_VAR_SIZE_2 = [ \t]*(0x[0-9A-Fa-f]*)[ \t]*[^ ]*[ \t]*$
|
MAPFILE_VAR_SIZE_2 = [ \t]*(0x[0-9A-Fa-f]*)[ \t]*[^ ]*[ \t]*$
|
||||||
COMMAND_VAR_NAME_ADDRESS = ^([0-9A-Fa-f][0-9A-Fa-f]*)[ \t][^Tt][ \t]([^ ._][^ ]*)
|
COMMAND_VAR_NAME_ADDRESS = ^([0-9A-Fa-f][0-9A-Fa-f]*)[ \t][^Tt][ \t]([^ ._][^ ]*)
|
||||||
COMMAND_DATA_START = ^([0-9A-Fa-f]*)[ \t]D[ \t]_data_start__$
|
COMMAND_DATA_START = ^([0-9A-Fa-f]*)[ \t]D[ \t].*_data_start__$
|
||||||
COMMAND_DATA_END = ^([0-9A-Fa-f]*)[ \t]D[ \t]_data_end__$
|
COMMAND_DATA_END = ^([0-9A-Fa-f]*)[ \t]D[ \t].*_data_end__$
|
||||||
COMMAND_BSS_START = ^([0-9A-Fa-f]*)[ \t]B[ \t]_bss_start__$
|
COMMAND_BSS_START = ^([0-9A-Fa-f]*)[ \t]B[ \t].*_bss_start__$
|
||||||
COMMAND_BSS_END = ^([0-9A-Fa-f]*)[ \t]B[ \t]_bss_end__$
|
COMMAND_BSS_END = ^([0-9A-Fa-f]*)[ \t]B[ \t].*_bss_end__$
|
||||||
|
|
|
@ -34,9 +34,12 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
/* This is a stripped version of platform/cooja/contiki-cooja-main.c, used by
|
||||||
|
* Cooja's Contiki Mote Configuration Wizard */
|
||||||
|
|
||||||
const struct simInterface *simInterfaces[] = {NULL};
|
const struct simInterface *simInterfaces[] = {NULL};
|
||||||
|
|
||||||
long ref_var; /* Placed somewhere in the BSS section */
|
long referenceVar; /* Placed somewhere in the BSS section */
|
||||||
|
|
||||||
/* Variables with known memory addresses */
|
/* Variables with known memory addresses */
|
||||||
int var1=1;
|
int var1=1;
|
||||||
|
@ -60,8 +63,9 @@ Java_se_sics_cooja_corecomm_[CLASS_NAME]_getMemory(JNIEnv *env, jobject obj, jin
|
||||||
mem_arr,
|
mem_arr,
|
||||||
0,
|
0,
|
||||||
(size_t) length,
|
(size_t) length,
|
||||||
(jbyte *) (((long)rel_addr) + ref_var)
|
(jbyte *) (((long)rel_addr) + referenceVar)
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
|
@ -69,7 +73,7 @@ Java_se_sics_cooja_corecomm_[CLASS_NAME]_setMemory(JNIEnv *env, jobject obj, jin
|
||||||
{
|
{
|
||||||
jbyte *mem = (*env)->GetByteArrayElements(env, mem_arr, 0);
|
jbyte *mem = (*env)->GetByteArrayElements(env, mem_arr, 0);
|
||||||
memcpy(
|
memcpy(
|
||||||
(char*) (((long)rel_addr) + ref_var),
|
(char*) (((long)rel_addr) + referenceVar),
|
||||||
mem,
|
mem,
|
||||||
length);
|
length);
|
||||||
(*env)->ReleaseByteArrayElements(env, mem_arr, mem, 0);
|
(*env)->ReleaseByteArrayElements(env, mem_arr, mem, 0);
|
||||||
|
@ -85,5 +89,5 @@ Java_se_sics_cooja_corecomm_[CLASS_NAME]_tick(JNIEnv *env, jobject obj)
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_se_sics_cooja_corecomm_[CLASS_NAME]_setReferenceAddress(JNIEnv *env, jobject obj, jint addr)
|
Java_se_sics_cooja_corecomm_[CLASS_NAME]_setReferenceAddress(JNIEnv *env, jobject obj, jint addr)
|
||||||
{
|
{
|
||||||
ref_var = (((long)&ref_var) - ((long)addr));
|
referenceVar = (((long)&referenceVar) - ((long)addr));
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,6 +245,7 @@ public class GUI extends Observable {
|
||||||
"PATH_LINKER", "LINK_COMMAND_1", "LINK_COMMAND_2",
|
"PATH_LINKER", "LINK_COMMAND_1", "LINK_COMMAND_2",
|
||||||
"PATH_AR", "AR_COMMAND_1", "AR_COMMAND_2",
|
"PATH_AR", "AR_COMMAND_1", "AR_COMMAND_2",
|
||||||
"PATH_OBJDUMP", "OBJDUMP_ARGS",
|
"PATH_OBJDUMP", "OBJDUMP_ARGS",
|
||||||
|
"PATH_OBJCOPY",
|
||||||
"PATH_JAVAC",
|
"PATH_JAVAC",
|
||||||
|
|
||||||
"CONTIKI_STANDARD_PROCESSES",
|
"CONTIKI_STANDARD_PROCESSES",
|
||||||
|
@ -929,7 +930,7 @@ public class GUI extends Observable {
|
||||||
menuItem.setToolTipText("Not available in applet version");
|
menuItem.setToolTipText("Not available in applet version");
|
||||||
}
|
}
|
||||||
|
|
||||||
menuItem = new JMenuItem("Compiler configuration wizard");
|
menuItem = new JMenuItem("Contiki mote configuration wizard");
|
||||||
menuItem.setActionCommand("configuration wizard");
|
menuItem.setActionCommand("configuration wizard");
|
||||||
menuItem.addActionListener(guiEventHandler);
|
menuItem.addActionListener(guiEventHandler);
|
||||||
menu.add(menuItem);
|
menu.add(menuItem);
|
||||||
|
@ -940,14 +941,6 @@ public class GUI extends Observable {
|
||||||
|
|
||||||
menu.add(new JMenuItem(showBufferSettingsAction));
|
menu.add(new JMenuItem(showBufferSettingsAction));
|
||||||
|
|
||||||
menu.addSeparator();
|
|
||||||
|
|
||||||
menuItem = new JMenuItem("Java version: "
|
|
||||||
+ System.getProperty("java.version") + " ("
|
|
||||||
+ System.getProperty("java.vendor") + ")");
|
|
||||||
menuItem.setEnabled(false);
|
|
||||||
menu.add(menuItem);
|
|
||||||
|
|
||||||
/* Help */
|
/* Help */
|
||||||
menu = new JMenu("Help");
|
menu = new JMenu("Help");
|
||||||
menu.setMnemonic(KeyEvent.VK_H);
|
menu.setMnemonic(KeyEvent.VK_H);
|
||||||
|
@ -957,6 +950,22 @@ public class GUI extends Observable {
|
||||||
menu.add(checkBox);
|
menu.add(checkBox);
|
||||||
menuBar.add(menu);
|
menuBar.add(menu);
|
||||||
|
|
||||||
|
menu.addSeparator();
|
||||||
|
|
||||||
|
menuItem = new JMenuItem("Java version: "
|
||||||
|
+ System.getProperty("java.version") + " ("
|
||||||
|
+ System.getProperty("java.vendor") + ")");
|
||||||
|
menuItem.setEnabled(false);
|
||||||
|
menu.add(menuItem);
|
||||||
|
menuItem = new JMenuItem("System's \"os.arch\": "
|
||||||
|
+ System.getProperty("os.arch"));
|
||||||
|
menuItem.setEnabled(false);
|
||||||
|
menu.add(menuItem);
|
||||||
|
menuItem = new JMenuItem("System's \"sun.arch.data.model\": "
|
||||||
|
+ System.getProperty("sun.arch.data.model"));
|
||||||
|
menuItem.setEnabled(false);
|
||||||
|
menu.add(menuItem);
|
||||||
|
|
||||||
// Mote plugins popup menu (not available via menu bar)
|
// Mote plugins popup menu (not available via menu bar)
|
||||||
if (menuMotePluginClasses == null) {
|
if (menuMotePluginClasses == null) {
|
||||||
menuMotePluginClasses = new Vector<Class<? extends Plugin>>();
|
menuMotePluginClasses = new Vector<Class<? extends Plugin>>();
|
||||||
|
|
|
@ -148,4 +148,10 @@ public abstract class MoteInterface extends Observable {
|
||||||
public void removed() {
|
public void removed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when all mote interfaces have been added to mote.
|
||||||
|
*/
|
||||||
|
public void added() {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface represents a mote memory.
|
* This interface represents a mote memory.
|
||||||
*
|
*
|
||||||
|
@ -44,7 +45,7 @@ package se.sics.cooja;
|
||||||
* @see se.sics.cooja.SectionMoteMemory
|
* @see se.sics.cooja.SectionMoteMemory
|
||||||
* @author Fredrik Osterlind
|
* @author Fredrik Osterlind
|
||||||
*/
|
*/
|
||||||
public interface MoteMemory {
|
public interface MoteMemory extends AddressMemory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the entire memory.
|
* Clears the entire memory.
|
||||||
|
@ -77,4 +78,14 @@ public interface MoteMemory {
|
||||||
*/
|
*/
|
||||||
public int getTotalSize();
|
public int getTotalSize();
|
||||||
|
|
||||||
|
public abstract int parseInt(byte[] memorySegment);
|
||||||
|
|
||||||
|
public enum MemoryEventType { READ, WRITE };
|
||||||
|
|
||||||
|
public interface MemoryMonitor {
|
||||||
|
public void memoryChanged(MoteMemory memory, MemoryEventType type, int address);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addMemoryMonitor(int address, int size, MemoryMonitor mm);
|
||||||
|
public void removeMemoryMonitor(int address, int size, MemoryMonitor mm);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,22 +23,21 @@
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
|
||||||
* $Id: SectionMoteMemory.java,v 1.7 2010/01/20 13:33:33 fros4943 Exp $
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja;
|
package se.sics.cooja;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Properties;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a mote memory consisting of non-overlapping memory sections with
|
* Represents a mote memory consisting of non-overlapping memory sections with
|
||||||
* variables' memory addresses.
|
* symbol addresses.
|
||||||
* <p>
|
* <p>
|
||||||
* When an unhandled memory segment is set a new section is automatically
|
* When an non-existing memory segment is written, a new section is automatically
|
||||||
* created for this segment.
|
* created for this segment.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
|
@ -49,27 +48,35 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
|
||||||
|
|
||||||
private ArrayList<MoteMemorySection> sections = new ArrayList<MoteMemorySection>();
|
private ArrayList<MoteMemorySection> sections = new ArrayList<MoteMemorySection>();
|
||||||
|
|
||||||
private final Properties addresses;
|
/* readonly memory is never written to Contiki core, and is used to provide
|
||||||
|
* access to, for instance, strings */
|
||||||
|
private ArrayList<MoteMemorySection> readonlySections = new ArrayList<MoteMemorySection>();
|
||||||
|
|
||||||
|
private final HashMap<String, Integer> addresses;
|
||||||
|
|
||||||
|
/* used to map Cooja's address space to native (Contiki's) addresses */
|
||||||
|
private final int offset;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new mote memory with information about which variables exist and
|
* @param addresses Symbol addresses
|
||||||
* their relative memory addresses.
|
* @param offset Offset for internally used addresses
|
||||||
*
|
|
||||||
* @param addresses Variable addresses
|
|
||||||
*/
|
*/
|
||||||
public SectionMoteMemory(Properties addresses) {
|
public SectionMoteMemory(HashMap<String, Integer> addresses, int offset) {
|
||||||
this.addresses = addresses;
|
this.addresses = addresses;
|
||||||
|
this.offset = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getVariableNames() {
|
public String[] getVariableNames() {
|
||||||
return addresses.values().toArray(new String[0]);
|
return addresses.keySet().toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVariableAddress(String varName) throws UnknownVariableException {
|
public int getVariableAddress(String varName) throws UnknownVariableException {
|
||||||
|
/* Cooja address space */
|
||||||
if (!addresses.containsKey(varName)) {
|
if (!addresses.containsKey(varName)) {
|
||||||
throw new UnknownVariableException(varName);
|
throw new UnknownVariableException(varName);
|
||||||
}
|
}
|
||||||
return ((Integer) addresses.get(varName)).intValue();
|
|
||||||
|
return addresses.get(varName).intValue() + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIntegerLength() {
|
public int getIntegerLength() {
|
||||||
|
@ -81,16 +88,35 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getMemorySegment(int address, int size) {
|
public byte[] getMemorySegment(int address, int size) {
|
||||||
|
/* Cooja address space */
|
||||||
|
address -= offset;
|
||||||
|
|
||||||
for (MoteMemorySection section : sections) {
|
for (MoteMemorySection section : sections) {
|
||||||
if (section.includesAddr(address)
|
if (section.includesAddr(address)
|
||||||
&& section.includesAddr(address + size - 1)) {
|
&& section.includesAddr(address + size - 1)) {
|
||||||
return section.getMemorySegment(address, size);
|
return section.getMemorySegment(address, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check if in readonly section */
|
||||||
|
for (MoteMemorySection section : readonlySections) {
|
||||||
|
if (section.includesAddr(address)
|
||||||
|
&& section.includesAddr(address + size - 1)) {
|
||||||
|
return section.getMemorySegment(address, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMemorySegmentNative(int address, byte[] data) {
|
||||||
|
setMemorySegment(address+offset, data);
|
||||||
|
}
|
||||||
|
|
||||||
public void setMemorySegment(int address, byte[] data) {
|
public void setMemorySegment(int address, byte[] data) {
|
||||||
|
/* Cooja address space */
|
||||||
|
address -= offset;
|
||||||
|
|
||||||
/* TODO XXX Sections may overlap */
|
/* TODO XXX Sections may overlap */
|
||||||
for (MoteMemorySection section : sections) {
|
for (MoteMemorySection section : sections) {
|
||||||
if (section.includesAddr(address)
|
if (section.includesAddr(address)
|
||||||
|
@ -102,6 +128,13 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
|
||||||
sections.add(new MoteMemorySection(address, data));
|
sections.add(new MoteMemorySection(address, data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setReadonlyMemorySegment(int address, byte[] data) {
|
||||||
|
/* Cooja address space */
|
||||||
|
address -= offset;
|
||||||
|
|
||||||
|
readonlySections.add(new MoteMemorySection(address, data));
|
||||||
|
}
|
||||||
|
|
||||||
public int getTotalSize() {
|
public int getTotalSize() {
|
||||||
int totalSize = 0;
|
int totalSize = 0;
|
||||||
for (MoteMemorySection section : sections) {
|
for (MoteMemorySection section : sections) {
|
||||||
|
@ -120,67 +153,27 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a memory segment from this memory. The section containing the
|
* Get start address of given section in native address space.
|
||||||
* segment may be split into two sections.
|
|
||||||
*
|
*
|
||||||
* @param startAddr Start address
|
* @param sectionNr Section position
|
||||||
* @param size Length
|
|
||||||
*/
|
|
||||||
public void removeSegmentFromMemory(int startAddr, int size) {
|
|
||||||
for (MoteMemorySection section : sections) {
|
|
||||||
// Find section containing segment to remove
|
|
||||||
if (section.includesAddr(startAddr)
|
|
||||||
&& section.includesAddr(startAddr + size - 1)) {
|
|
||||||
MoteMemorySection oldSection = section;
|
|
||||||
|
|
||||||
byte[] dataFirstPart = oldSection.getMemorySegment(
|
|
||||||
oldSection.startAddr, (startAddr - oldSection.startAddr));
|
|
||||||
byte[] dataSecondPart = oldSection
|
|
||||||
.getMemorySegment(startAddr + size, (oldSection.startAddr
|
|
||||||
+ oldSection.getSize() - (startAddr + size)));
|
|
||||||
|
|
||||||
MoteMemorySection newSectionFirstPart = new MoteMemorySection(
|
|
||||||
oldSection.startAddr, dataFirstPart);
|
|
||||||
MoteMemorySection newSectionSecondPart = new MoteMemorySection(
|
|
||||||
startAddr + size, dataSecondPart);
|
|
||||||
|
|
||||||
// Remove old section, add new sections
|
|
||||||
sections.remove(oldSection);
|
|
||||||
if (newSectionFirstPart.getSize() > 0) {
|
|
||||||
sections.add(newSectionFirstPart);
|
|
||||||
}
|
|
||||||
if (newSectionSecondPart.getSize() > 0) {
|
|
||||||
sections.add(newSectionSecondPart);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get start address of section at given position.
|
|
||||||
*
|
|
||||||
* @param sectionNr
|
|
||||||
* Section position
|
|
||||||
* @return Start address of section
|
* @return Start address of section
|
||||||
*/
|
*/
|
||||||
public int getStartAddrOfSection(int sectionNr) {
|
public int getSectionNativeAddress(int sectionNr) {
|
||||||
if (sectionNr >= sections.size()) {
|
if (sectionNr >= sections.size()) {
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sections.get(sectionNr).getStartAddr();
|
return sections.get(sectionNr).getStartAddr();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get size of section at given position.
|
* Get size of section at given position.
|
||||||
*
|
*
|
||||||
* @param sectionNr
|
* @param sectionNr Section position
|
||||||
* Section position
|
|
||||||
* @return Size of section
|
* @return Size of section
|
||||||
*/
|
*/
|
||||||
public int getSizeOfSection(int sectionNr) {
|
public int getSizeOfSection(int sectionNr) {
|
||||||
if (sectionNr >= sections.size()) {
|
if (sectionNr >= sections.size()) {
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sections.get(sectionNr).getSize();
|
return sections.get(sectionNr).getSize();
|
||||||
|
@ -189,8 +182,7 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
|
||||||
/**
|
/**
|
||||||
* Get data of section at given position.
|
* Get data of section at given position.
|
||||||
*
|
*
|
||||||
* @param sectionNr
|
* @param sectionNr Section position
|
||||||
* Section position
|
|
||||||
* @return Data at section
|
* @return Data at section
|
||||||
*/
|
*/
|
||||||
public byte[] getDataOfSection(int sectionNr) {
|
public byte[] getDataOfSection(int sectionNr) {
|
||||||
|
@ -206,42 +198,22 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIntValueOf(String varName) throws UnknownVariableException {
|
public int getIntValueOf(String varName) throws UnknownVariableException {
|
||||||
// Get start address of variable
|
int varAddr = getVariableAddress(varName);
|
||||||
if (!addresses.containsKey(varName)) {
|
|
||||||
throw new UnknownVariableException(varName);
|
|
||||||
}
|
|
||||||
int varAddr = ((Integer) addresses.get(varName)).intValue();
|
|
||||||
|
|
||||||
byte[] varData = getMemorySegment(varAddr, 4);
|
byte[] varData = getMemorySegment(varAddr, 4);
|
||||||
|
|
||||||
if (varData == null) {
|
if (varData == null) {
|
||||||
throw new UnknownVariableException(varName);
|
throw new UnknownVariableException(varName);
|
||||||
}
|
}
|
||||||
|
|
||||||
int retVal = 0;
|
return parseInt(varData);
|
||||||
int pos = 0;
|
|
||||||
retVal += ((varData[pos++] & 0xFF)) << 24;
|
|
||||||
retVal += ((varData[pos++] & 0xFF)) << 16;
|
|
||||||
retVal += ((varData[pos++] & 0xFF)) << 8;
|
|
||||||
retVal += ((varData[pos++] & 0xFF)) << 0;
|
|
||||||
|
|
||||||
/* TODO Correct for all platforms? */
|
|
||||||
retVal = Integer.reverseBytes(retVal);
|
|
||||||
|
|
||||||
return retVal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIntValueOf(String varName, int newVal) throws UnknownVariableException {
|
public void setIntValueOf(String varName, int newVal) throws UnknownVariableException {
|
||||||
// Get start address of variable
|
int varAddr = getVariableAddress(varName);
|
||||||
if (!addresses.containsKey(varName)) {
|
|
||||||
throw new UnknownVariableException(varName);
|
|
||||||
}
|
|
||||||
int varAddr = ((Integer) addresses.get(varName)).intValue();
|
|
||||||
|
|
||||||
/* TODO Correct for all platforms? */
|
/* TODO Correct for all platforms? */
|
||||||
int newValToSet = Integer.reverseBytes(newVal);
|
int newValToSet = Integer.reverseBytes(newVal);
|
||||||
|
|
||||||
// Create byte array
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
byte[] varData = new byte[4];
|
byte[] varData = new byte[4];
|
||||||
|
@ -254,12 +226,7 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte getByteValueOf(String varName) throws UnknownVariableException {
|
public byte getByteValueOf(String varName) throws UnknownVariableException {
|
||||||
// Get start address of variable
|
int varAddr = getVariableAddress(varName);
|
||||||
if (!addresses.containsKey(varName)) {
|
|
||||||
throw new UnknownVariableException(varName);
|
|
||||||
}
|
|
||||||
int varAddr = ((Integer) addresses.get(varName)).intValue();
|
|
||||||
|
|
||||||
byte[] varData = getMemorySegment(varAddr, 1);
|
byte[] varData = getMemorySegment(varAddr, 1);
|
||||||
|
|
||||||
if (varData == null) {
|
if (varData == null) {
|
||||||
|
@ -270,12 +237,7 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setByteValueOf(String varName, byte newVal) throws UnknownVariableException {
|
public void setByteValueOf(String varName, byte newVal) throws UnknownVariableException {
|
||||||
// Get start address of variable
|
int varAddr = getVariableAddress(varName);
|
||||||
if (!addresses.containsKey(varName)) {
|
|
||||||
throw new UnknownVariableException(varName);
|
|
||||||
}
|
|
||||||
int varAddr = ((Integer) addresses.get(varName)).intValue();
|
|
||||||
|
|
||||||
byte[] varData = new byte[1];
|
byte[] varData = new byte[1];
|
||||||
|
|
||||||
varData[0] = newVal;
|
varData[0] = newVal;
|
||||||
|
@ -284,24 +246,12 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getByteArray(String varName, int length) throws UnknownVariableException {
|
public byte[] getByteArray(String varName, int length) throws UnknownVariableException {
|
||||||
// Get start address of variable
|
int varAddr = getVariableAddress(varName);
|
||||||
if (!addresses.containsKey(varName)) {
|
|
||||||
throw new UnknownVariableException(varName);
|
|
||||||
}
|
|
||||||
int varAddr = ((Integer) addresses.get(varName)).intValue();
|
|
||||||
|
|
||||||
// TODO Check if small/big-endian when coming from JNI?
|
|
||||||
return getMemorySegment(varAddr, length);
|
return getMemorySegment(varAddr, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setByteArray(String varName, byte[] data) throws UnknownVariableException {
|
public void setByteArray(String varName, byte[] data) throws UnknownVariableException {
|
||||||
// Get start address of variable
|
int varAddr = getVariableAddress(varName);
|
||||||
if (!addresses.containsKey(varName)) {
|
|
||||||
throw new UnknownVariableException(varName);
|
|
||||||
}
|
|
||||||
int varAddr = ((Integer) addresses.get(varName)).intValue();
|
|
||||||
|
|
||||||
// TODO Check if small/big-endian when coming from JNI?
|
|
||||||
setMemorySegment(varAddr, data);
|
setMemorySegment(varAddr, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,10 +260,9 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
|
||||||
*
|
*
|
||||||
* @author Fredrik Osterlind
|
* @author Fredrik Osterlind
|
||||||
*/
|
*/
|
||||||
private class MoteMemorySection {
|
private static class MoteMemorySection {
|
||||||
private byte[] data = null;
|
private byte[] data = null;
|
||||||
|
private final int startAddr;
|
||||||
private int startAddr;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new memory section.
|
* Create a new memory section.
|
||||||
|
@ -408,14 +357,75 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SectionMoteMemory clone() {
|
public SectionMoteMemory clone() {
|
||||||
ArrayList<MoteMemorySection> clones = new ArrayList<MoteMemorySection>();
|
ArrayList<MoteMemorySection> sectionsClone = new ArrayList<MoteMemorySection>();
|
||||||
for (MoteMemorySection section : sections) {
|
for (MoteMemorySection section : sections) {
|
||||||
clones.add(section.clone());
|
sectionsClone.add(section.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
SectionMoteMemory clone = new SectionMoteMemory(addresses);
|
SectionMoteMemory clone = new SectionMoteMemory(addresses, offset);
|
||||||
clone.sections = clones;
|
clone.sections = sectionsClone;
|
||||||
|
clone.readonlySections = readonlySections;
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ArrayList<PolledMemorySegments> polledMemories = new ArrayList<PolledMemorySegments>();
|
||||||
|
public void pollForMemoryChanges() {
|
||||||
|
for (PolledMemorySegments mem: polledMemories.toArray(new PolledMemorySegments[0])) {
|
||||||
|
mem.notifyIfChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PolledMemorySegments {
|
||||||
|
public final MemoryMonitor mm;
|
||||||
|
public final int address;
|
||||||
|
public final int size;
|
||||||
|
private byte[] oldMem;
|
||||||
|
|
||||||
|
public PolledMemorySegments(MemoryMonitor mm, int address, int size) {
|
||||||
|
this.mm = mm;
|
||||||
|
this.address = address;
|
||||||
|
this.size = size;
|
||||||
|
|
||||||
|
oldMem = getMemorySegment(address, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifyIfChanged() {
|
||||||
|
byte[] newMem = getMemorySegment(address, size);
|
||||||
|
if (Arrays.equals(oldMem, newMem)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mm.memoryChanged(SectionMoteMemory.this, MemoryEventType.WRITE, address);
|
||||||
|
oldMem = newMem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addMemoryMonitor(int address, int size, MemoryMonitor mm) {
|
||||||
|
PolledMemorySegments t = new PolledMemorySegments(mm, address, size);
|
||||||
|
polledMemories.add(t);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeMemoryMonitor(int address, int size, MemoryMonitor mm) {
|
||||||
|
for (PolledMemorySegments mcm: polledMemories) {
|
||||||
|
if (mcm.mm != mm || mcm.address != address || mcm.size != size) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
polledMemories.remove(mcm);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int parseInt(byte[] memorySegment) {
|
||||||
|
int retVal = 0;
|
||||||
|
int pos = 0;
|
||||||
|
retVal += ((memorySegment[pos++] & 0xFF)) << 24;
|
||||||
|
retVal += ((memorySegment[pos++] & 0xFF)) << 16;
|
||||||
|
retVal += ((memorySegment[pos++] & 0xFF)) << 8;
|
||||||
|
retVal += ((memorySegment[pos++] & 0xFF)) << 0;
|
||||||
|
|
||||||
|
retVal = Integer.reverseBytes(retVal);
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -790,6 +790,12 @@ public class Simulation extends Observable implements Runnable {
|
||||||
|
|
||||||
motes.add(mote);
|
motes.add(mote);
|
||||||
currentRadioMedium.registerMote(mote, Simulation.this);
|
currentRadioMedium.registerMote(mote, Simulation.this);
|
||||||
|
|
||||||
|
/* Notify mote interfaces that node was added */
|
||||||
|
for (MoteInterface i: mote.getInterfaces().getInterfaces()) {
|
||||||
|
i.added();
|
||||||
|
}
|
||||||
|
|
||||||
setChanged();
|
setChanged();
|
||||||
notifyObservers(mote);
|
notifyObservers(mote);
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,6 +154,7 @@ public class ContikiMote extends AbstractWakeupMote implements Mote {
|
||||||
myType.getCoreMemory(myMemory);
|
myType.getCoreMemory(myMemory);
|
||||||
|
|
||||||
/* Poll mote interfaces */
|
/* Poll mote interfaces */
|
||||||
|
myMemory.pollForMemoryChanges();
|
||||||
myInterfaceHandler.doActiveActionsAfterTick();
|
myInterfaceHandler.doActiveActionsAfterTick();
|
||||||
myInterfaceHandler.doPassiveActionsAfterTick();
|
myInterfaceHandler.doPassiveActionsAfterTick();
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Properties;
|
import java.util.HashMap;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
@ -199,13 +199,8 @@ public class ContikiMoteType implements MoteType {
|
||||||
// Type specific class configuration
|
// Type specific class configuration
|
||||||
private ProjectConfig myConfig = null;
|
private ProjectConfig myConfig = null;
|
||||||
|
|
||||||
private int relAddressOfReferenceVariable = 0;
|
|
||||||
|
|
||||||
private CoreComm myCoreComm = null;
|
private CoreComm myCoreComm = null;
|
||||||
|
|
||||||
// Variable name to address mappings
|
|
||||||
private Properties varAddresses = new Properties();
|
|
||||||
|
|
||||||
// Initial memory for all motes of this type
|
// Initial memory for all motes of this type
|
||||||
private SectionMoteMemory initialMemory = null;
|
private SectionMoteMemory initialMemory = null;
|
||||||
|
|
||||||
|
@ -403,14 +398,16 @@ public class ContikiMoteType implements MoteType {
|
||||||
int dataSectionAddr = -1, dataSectionSize = -1;
|
int dataSectionAddr = -1, dataSectionSize = -1;
|
||||||
int bssSectionAddr = -1, bssSectionSize = -1;
|
int bssSectionAddr = -1, bssSectionSize = -1;
|
||||||
int commonSectionAddr = -1, commonSectionSize = -1;
|
int commonSectionAddr = -1, commonSectionSize = -1;
|
||||||
|
int readonlySectionAddr = -1, readonlySectionSize = -1;
|
||||||
|
|
||||||
|
HashMap<String, Integer> addresses = new HashMap<String, Integer>();
|
||||||
if (useCommand) {
|
if (useCommand) {
|
||||||
/* Parse command output */
|
/* Parse command output */
|
||||||
String[] output = loadCommandData(getContikiFirmwareFile());
|
String[] output = loadCommandData(getContikiFirmwareFile());
|
||||||
if (output == null) {
|
if (output == null) {
|
||||||
throw new MoteTypeCreationException("No parse command output loaded");
|
throw new MoteTypeCreationException("No parse command output loaded");
|
||||||
}
|
}
|
||||||
boolean parseOK = parseCommandData(output, varAddresses);
|
boolean parseOK = parseCommandData(output, addresses);
|
||||||
if (!parseOK) {
|
if (!parseOK) {
|
||||||
logger.fatal("Command output parsing failed");
|
logger.fatal("Command output parsing failed");
|
||||||
throw new MoteTypeCreationException("Command output parsing failed");
|
throw new MoteTypeCreationException("Command output parsing failed");
|
||||||
|
@ -423,6 +420,14 @@ public class ContikiMoteType implements MoteType {
|
||||||
commonSectionAddr = parseCommandCommonSectionAddr(output);
|
commonSectionAddr = parseCommandCommonSectionAddr(output);
|
||||||
commonSectionSize = parseCommandCommonSectionSize(output);
|
commonSectionSize = parseCommandCommonSectionSize(output);
|
||||||
|
|
||||||
|
try {
|
||||||
|
readonlySectionAddr = parseCommandReadonlySectionAddr(output);
|
||||||
|
readonlySectionSize = parseCommandReadonlySectionSize(output);
|
||||||
|
} catch (Exception e) {
|
||||||
|
readonlySectionAddr = -1;
|
||||||
|
readonlySectionSize = -1;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* Parse command output */
|
/* Parse command output */
|
||||||
if (mapFile == null ||
|
if (mapFile == null ||
|
||||||
|
@ -434,7 +439,7 @@ public class ContikiMoteType implements MoteType {
|
||||||
logger.fatal("No map data could be loaded");
|
logger.fatal("No map data could be loaded");
|
||||||
throw new MoteTypeCreationException("No map data could be loaded: " + mapFile);
|
throw new MoteTypeCreationException("No map data could be loaded: " + mapFile);
|
||||||
}
|
}
|
||||||
boolean parseOK = parseMapFileData(mapData, varAddresses);
|
boolean parseOK = parseMapFileData(mapData, addresses);
|
||||||
if (!parseOK) {
|
if (!parseOK) {
|
||||||
logger.fatal("Map data parsing failed");
|
logger.fatal("Map data parsing failed");
|
||||||
throw new MoteTypeCreationException("Map data parsing failed: " + mapFile);
|
throw new MoteTypeCreationException("Map data parsing failed: " + mapFile);
|
||||||
|
@ -446,52 +451,99 @@ public class ContikiMoteType implements MoteType {
|
||||||
bssSectionSize = parseMapBssSectionSize(mapData);
|
bssSectionSize = parseMapBssSectionSize(mapData);
|
||||||
commonSectionAddr = parseMapCommonSectionAddr(mapData);
|
commonSectionAddr = parseMapCommonSectionAddr(mapData);
|
||||||
commonSectionSize = parseMapCommonSectionSize(mapData);
|
commonSectionSize = parseMapCommonSectionSize(mapData);
|
||||||
|
readonlySectionAddr = -1;
|
||||||
|
readonlySectionSize = -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (varAddresses.size() == 0) {
|
if (dataSectionAddr >= 0) {
|
||||||
|
logger.info(getContikiFirmwareFile().getName() +
|
||||||
|
": data section at 0x" + Integer.toHexString(dataSectionAddr) +
|
||||||
|
" (" + dataSectionSize + " bytes)");
|
||||||
|
} else {
|
||||||
|
logger.fatal(getContikiFirmwareFile().getName() + ": no data section found");
|
||||||
|
}
|
||||||
|
if (bssSectionAddr >= 0) {
|
||||||
|
logger.info(getContikiFirmwareFile().getName() +
|
||||||
|
": BSS section at 0x" + Integer.toHexString(bssSectionAddr) +
|
||||||
|
" (" + bssSectionSize + " bytes)");
|
||||||
|
} else {
|
||||||
|
logger.fatal(getContikiFirmwareFile().getName() + ": no BSS section found");
|
||||||
|
}
|
||||||
|
if (commonSectionAddr >= 0) {
|
||||||
|
logger.info(getContikiFirmwareFile().getName() +
|
||||||
|
": common section at 0x" + Integer.toHexString(commonSectionAddr) +
|
||||||
|
" (" + commonSectionSize + " bytes)");
|
||||||
|
} else {
|
||||||
|
logger.info(getContikiFirmwareFile().getName() + ": no common section found");
|
||||||
|
}
|
||||||
|
if (readonlySectionAddr >= 0) {
|
||||||
|
logger.info(getContikiFirmwareFile().getName() +
|
||||||
|
": readonly section at 0x" + Integer.toHexString(readonlySectionAddr) +
|
||||||
|
" (" + readonlySectionSize + " bytes)");
|
||||||
|
} else {
|
||||||
|
logger.warn(getContikiFirmwareFile().getName() + ": no readonly section found");
|
||||||
|
}
|
||||||
|
if (addresses.size() == 0) {
|
||||||
throw new MoteTypeCreationException("Library variables parsing failed");
|
throw new MoteTypeCreationException("Library variables parsing failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
/* Relative <-> absolute addresses offset */
|
|
||||||
relAddressOfReferenceVariable = (Integer) varAddresses.get("referenceVar");
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw (MoteTypeCreationException) new MoteTypeCreationException(
|
|
||||||
"JNI call error: " + e.getMessage()).initCause(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dataSectionAddr <= 0 || dataSectionSize <= 0
|
if (dataSectionAddr <= 0 || dataSectionSize <= 0
|
||||||
|| bssSectionAddr <= 0 || bssSectionSize <= 0) {
|
|| bssSectionAddr <= 0 || bssSectionSize <= 0) {
|
||||||
throw new MoteTypeCreationException("Library section addresses parsing failed");
|
throw new MoteTypeCreationException("Library section addresses parsing failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
myCoreComm.setReferenceAddress(relAddressOfReferenceVariable);
|
try {
|
||||||
|
/* Relative <-> absolute addresses offset */
|
||||||
|
int referenceVar = (Integer) addresses.get("referenceVar");
|
||||||
|
myCoreComm.setReferenceAddress(referenceVar);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw (MoteTypeCreationException) new MoteTypeCreationException(
|
||||||
|
"JNI call error: " + e.getMessage()).initCause(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We first need the value of Contiki's referenceVar, which tells us the
|
||||||
|
* memory offset between Contiki's variable and the relative addresses that
|
||||||
|
* were calculated directly from the library file.
|
||||||
|
*
|
||||||
|
* This offset will be used in Cooja in the memory abstraction to match
|
||||||
|
* Contiki's and Cooja's address spaces */
|
||||||
|
int offset;
|
||||||
|
{
|
||||||
|
SectionMoteMemory tmp = new SectionMoteMemory(addresses, 0);
|
||||||
|
byte[] data = new byte[dataSectionSize];
|
||||||
|
getCoreMemory(dataSectionAddr, dataSectionSize, data);
|
||||||
|
tmp.setMemorySegment(dataSectionAddr, data);
|
||||||
|
byte[] bss = new byte[bssSectionSize];
|
||||||
|
getCoreMemory(bssSectionAddr, bssSectionSize, bss);
|
||||||
|
tmp.setMemorySegment(bssSectionAddr, bss);
|
||||||
|
|
||||||
|
offset = tmp.getIntValueOf("referenceVar");
|
||||||
|
logger.info(getContikiFirmwareFile().getName() +
|
||||||
|
": offsetting Contiki mote address space: " + offset);
|
||||||
|
}
|
||||||
|
|
||||||
/* Create initial memory: data+bss+optional common */
|
/* Create initial memory: data+bss+optional common */
|
||||||
initialMemory = new SectionMoteMemory(varAddresses);
|
initialMemory = new SectionMoteMemory(addresses, offset);
|
||||||
|
|
||||||
byte[] initialDataSection = new byte[dataSectionSize];
|
byte[] initialDataSection = new byte[dataSectionSize];
|
||||||
getCoreMemory(dataSectionAddr, dataSectionSize, initialDataSection);
|
getCoreMemory(dataSectionAddr, dataSectionSize, initialDataSection);
|
||||||
initialMemory.setMemorySegment(dataSectionAddr, initialDataSection);
|
initialMemory.setMemorySegmentNative(dataSectionAddr, initialDataSection);
|
||||||
logger.info(getContikiFirmwareFile().getName() +
|
|
||||||
": data section at 0x" + Integer.toHexString(dataSectionAddr) +
|
|
||||||
" (" + dataSectionSize + " bytes)");
|
|
||||||
|
|
||||||
byte[] initialBssSection = new byte[bssSectionSize];
|
byte[] initialBssSection = new byte[bssSectionSize];
|
||||||
getCoreMemory(bssSectionAddr, bssSectionSize, initialBssSection);
|
getCoreMemory(bssSectionAddr, bssSectionSize, initialBssSection);
|
||||||
initialMemory.setMemorySegment(bssSectionAddr, initialBssSection);
|
initialMemory.setMemorySegmentNative(bssSectionAddr, initialBssSection);
|
||||||
logger.info(getContikiFirmwareFile().getName() +
|
|
||||||
": BSS section at 0x" + Integer.toHexString(bssSectionAddr) +
|
|
||||||
" (" + bssSectionSize + " bytes)");
|
|
||||||
|
|
||||||
if (commonSectionAddr > 0 && commonSectionSize > 0) {
|
if (commonSectionAddr >= 0 && commonSectionSize > 0) {
|
||||||
byte[] initialCommonSection = new byte[commonSectionSize];
|
byte[] initialCommonSection = new byte[commonSectionSize];
|
||||||
getCoreMemory(commonSectionAddr, commonSectionSize, initialCommonSection);
|
getCoreMemory(commonSectionAddr, commonSectionSize, initialCommonSection);
|
||||||
initialMemory.setMemorySegment(commonSectionAddr, initialCommonSection);
|
initialMemory.setMemorySegmentNative(commonSectionAddr, initialCommonSection);
|
||||||
logger.info(getContikiFirmwareFile().getName() +
|
}
|
||||||
": common section at 0x" + Integer.toHexString(commonSectionAddr) +
|
|
||||||
" (" + commonSectionSize + " bytes)");
|
/* Read "read-only" memory */
|
||||||
|
if (readonlySectionAddr >= 0 && readonlySectionSize > 0) {
|
||||||
|
byte[] readonlySection = new byte[readonlySectionSize];
|
||||||
|
getCoreMemory(readonlySectionAddr, readonlySectionSize, readonlySection);
|
||||||
|
initialMemory.setReadonlyMemorySegment(readonlySectionAddr+offset, readonlySection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -524,7 +576,7 @@ public class ContikiMoteType implements MoteType {
|
||||||
public void setCoreMemory(SectionMoteMemory mem) {
|
public void setCoreMemory(SectionMoteMemory mem) {
|
||||||
for (int i = 0; i < mem.getNumberOfSections(); i++) {
|
for (int i = 0; i < mem.getNumberOfSections(); i++) {
|
||||||
setCoreMemory(
|
setCoreMemory(
|
||||||
mem.getStartAddrOfSection(i),
|
mem.getSectionNativeAddress(i) /* native address space */,
|
||||||
mem.getSizeOfSection(i), mem.getDataOfSection(i));
|
mem.getSizeOfSection(i), mem.getDataOfSection(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -538,8 +590,7 @@ public class ContikiMoteType implements MoteType {
|
||||||
* @param varAddresses
|
* @param varAddresses
|
||||||
* Properties that should contain the name to addresses mappings.
|
* Properties that should contain the name to addresses mappings.
|
||||||
*/
|
*/
|
||||||
public static boolean parseMapFileData(String[] mapFileData,
|
public static boolean parseMapFileData(String[] mapFileData, HashMap<String, Integer> varAddresses) {
|
||||||
Properties varAddresses) {
|
|
||||||
String[] varNames = getMapFileVarNames(mapFileData);
|
String[] varNames = getMapFileVarNames(mapFileData);
|
||||||
if (varNames == null || varNames.length == 0) {
|
if (varNames == null || varNames.length == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -565,7 +616,7 @@ public class ContikiMoteType implements MoteType {
|
||||||
* @param output Command output
|
* @param output Command output
|
||||||
* @param addresses Variable addresses mappings
|
* @param addresses Variable addresses mappings
|
||||||
*/
|
*/
|
||||||
public static boolean parseCommandData(String[] output, Properties addresses) {
|
public static boolean parseCommandData(String[] output, HashMap<String, Integer> addresses) {
|
||||||
int nrNew = 0, nrOld = 0, nrMismatch = 0;
|
int nrNew = 0, nrOld = 0, nrMismatch = 0;
|
||||||
|
|
||||||
Pattern pattern =
|
Pattern pattern =
|
||||||
|
@ -615,10 +666,9 @@ public class ContikiMoteType implements MoteType {
|
||||||
*/
|
*/
|
||||||
public void getCoreMemory(SectionMoteMemory mem) {
|
public void getCoreMemory(SectionMoteMemory mem) {
|
||||||
for (int i = 0; i < mem.getNumberOfSections(); i++) {
|
for (int i = 0; i < mem.getNumberOfSections(); i++) {
|
||||||
int startAddr = mem.getStartAddrOfSection(i);
|
int startAddr = mem.getSectionNativeAddress(i); /* native address space */
|
||||||
int size = mem.getSizeOfSection(i);
|
int size = mem.getSizeOfSection(i);
|
||||||
byte[] data = mem.getDataOfSection(i);
|
byte[] data = mem.getDataOfSection(i);
|
||||||
|
|
||||||
getCoreMemory(startAddr, size, data);
|
getCoreMemory(startAddr, size, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -689,12 +739,10 @@ public class ContikiMoteType implements MoteType {
|
||||||
* @param varName Name of variable
|
* @param varName Name of variable
|
||||||
* @return Relative memory address of variable or -1 if not found
|
* @return Relative memory address of variable or -1 if not found
|
||||||
*/
|
*/
|
||||||
public static int getMapFileVarAddress(String[] mapFileData, String varName, Properties varAddresses) {
|
private static int getMapFileVarAddress(String[] mapFileData, String varName, HashMap<String, Integer> varAddresses) {
|
||||||
int varAddr;
|
Integer varAddrInteger;
|
||||||
String varAddrString;
|
if ((varAddrInteger = varAddresses.get(varName)) != null) {
|
||||||
if ((varAddrString = varAddresses.getProperty(varName)) != null) {
|
return varAddrInteger.intValue();
|
||||||
varAddr = Integer.parseInt(varAddrString);
|
|
||||||
return varAddr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String regExp =
|
String regExp =
|
||||||
|
@ -704,9 +752,9 @@ public class ContikiMoteType implements MoteType {
|
||||||
String retString = getFirstMatchGroup(mapFileData, regExp, 1);
|
String retString = getFirstMatchGroup(mapFileData, regExp, 1);
|
||||||
|
|
||||||
if (retString != null) {
|
if (retString != null) {
|
||||||
varAddresses.setProperty(varName, Integer.toString(Integer.parseInt(
|
varAddrInteger = Integer.parseInt(retString.trim(), 16);
|
||||||
retString.trim(), 16)));
|
varAddresses.put(varName, varAddrInteger);
|
||||||
return Integer.parseInt(retString.trim(), 16);
|
return varAddrInteger.intValue();
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -760,7 +808,7 @@ public class ContikiMoteType implements MoteType {
|
||||||
return varNames.toArray(new String[0]);
|
return varNames.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getAllVariableNames(String[] lines,
|
private static String[] getAllVariableNames(String[] lines,
|
||||||
int startAddress, int endAddress) {
|
int startAddress, int endAddress) {
|
||||||
ArrayList<String> varNames = new ArrayList<String>();
|
ArrayList<String> varNames = new ArrayList<String>();
|
||||||
|
|
||||||
|
@ -915,6 +963,21 @@ public class ContikiMoteType implements MoteType {
|
||||||
return end - start;
|
return end - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int parseCommandReadonlySectionAddr(String[] output) {
|
||||||
|
return parseFirstHexInt("^([0-9A-Fa-f]*)[ \t]t[ \t].text$", output);
|
||||||
|
}
|
||||||
|
private static int parseCommandReadonlySectionSize(String[] output) {
|
||||||
|
int start = parseCommandReadonlySectionAddr(output);
|
||||||
|
if (start < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Extract the last specified address, assuming that the interval covers all the memory */
|
||||||
|
String last = output[output.length-1];
|
||||||
|
int lastAddress = Integer.parseInt(last.split("[ \t]")[0],16);
|
||||||
|
return lastAddress - start;
|
||||||
|
}
|
||||||
|
|
||||||
private static int getRelVarAddr(String mapFileData[], String varName) {
|
private static int getRelVarAddr(String mapFileData[], String varName) {
|
||||||
String regExp =
|
String regExp =
|
||||||
GUI.getExternalToolsSetting("MAPFILE_VAR_ADDRESS_1") +
|
GUI.getExternalToolsSetting("MAPFILE_VAR_ADDRESS_1") +
|
||||||
|
|
|
@ -495,6 +495,7 @@ public class CompileContiki {
|
||||||
env.add(new String[] { "COOJA_SOURCEDIRS", "" });
|
env.add(new String[] { "COOJA_SOURCEDIRS", "" });
|
||||||
env.add(new String[] { "COOJA_SOURCEFILES", "" });
|
env.add(new String[] { "COOJA_SOURCEFILES", "" });
|
||||||
env.add(new String[] { "CC", GUI.getExternalToolsSetting("PATH_C_COMPILER") });
|
env.add(new String[] { "CC", GUI.getExternalToolsSetting("PATH_C_COMPILER") });
|
||||||
|
env.add(new String[] { "OBJCOPY", GUI.getExternalToolsSetting("PATH_OBJCOPY") });
|
||||||
env.add(new String[] { "EXTRA_CC_ARGS", ccFlags });
|
env.add(new String[] { "EXTRA_CC_ARGS", ccFlags });
|
||||||
env.add(new String[] { "LD", GUI.getExternalToolsSetting("PATH_LINKER") });
|
env.add(new String[] { "LD", GUI.getExternalToolsSetting("PATH_LINKER") });
|
||||||
env.add(new String[] { "LINK_COMMAND_1", link1 });
|
env.add(new String[] { "LINK_COMMAND_1", link1 });
|
||||||
|
|
|
@ -50,7 +50,7 @@ import java.io.InputStreamReader;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.Properties;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import javax.swing.Box;
|
import javax.swing.Box;
|
||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
|
@ -66,11 +66,12 @@ import javax.swing.JScrollPane;
|
||||||
|
|
||||||
import se.sics.cooja.CoreComm;
|
import se.sics.cooja.CoreComm;
|
||||||
import se.sics.cooja.GUI;
|
import se.sics.cooja.GUI;
|
||||||
import se.sics.cooja.SectionMoteMemory;
|
|
||||||
import se.sics.cooja.MoteType.MoteTypeCreationException;
|
import se.sics.cooja.MoteType.MoteTypeCreationException;
|
||||||
|
import se.sics.cooja.SectionMoteMemory;
|
||||||
import se.sics.cooja.contikimote.ContikiMoteType;
|
import se.sics.cooja.contikimote.ContikiMoteType;
|
||||||
|
|
||||||
/* TODO Test common section */
|
/* TODO Test common section */
|
||||||
|
/* TODO Test readonly section */
|
||||||
|
|
||||||
public class ConfigurationWizard extends JDialog {
|
public class ConfigurationWizard extends JDialog {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
@ -141,7 +142,7 @@ public class ConfigurationWizard extends JDialog {
|
||||||
private static File cLibraryFile;
|
private static File cLibraryFile;
|
||||||
private static String javaLibraryName;
|
private static String javaLibraryName;
|
||||||
private static CoreComm javaLibrary;
|
private static CoreComm javaLibrary;
|
||||||
private static Properties addresses;
|
private static HashMap<String, Integer> addresses;
|
||||||
private static int relDataSectionAddr;
|
private static int relDataSectionAddr;
|
||||||
private static int dataSectionSize;
|
private static int dataSectionSize;
|
||||||
private static int relBssSectionAddr;
|
private static int relBssSectionAddr;
|
||||||
|
@ -195,7 +196,7 @@ public class ConfigurationWizard extends JDialog {
|
||||||
"Changes made in this wizard are reflected in menu Settings, External tools paths.\n" +
|
"Changes made in this wizard are reflected in menu Settings, External tools paths.\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"NOTE: You do not need to complete this wizard for emulating motes, such as Sky motes.\n",
|
"NOTE: You do not need to complete this wizard for emulating motes, such as Sky motes.\n",
|
||||||
"Configuration Wizard",
|
"Contiki mote configuration wizard",
|
||||||
JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE,
|
JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE,
|
||||||
null, options, options[0]);
|
null, options, options[0]);
|
||||||
|
|
||||||
|
@ -756,7 +757,7 @@ public class ConfigurationWizard extends JDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
testOutput.addMessage("### Parsing map file data for addresses");
|
testOutput.addMessage("### Parsing map file data for addresses");
|
||||||
addresses = new Properties();
|
addresses = new HashMap<String, Integer>();
|
||||||
boolean parseOK = ContikiMoteType.parseMapFileData(mapData, addresses);
|
boolean parseOK = ContikiMoteType.parseMapFileData(mapData, addresses);
|
||||||
if (!parseOK) {
|
if (!parseOK) {
|
||||||
testOutput.addMessage("### Error: Failed parsing map file data", MessageList.ERROR);
|
testOutput.addMessage("### Error: Failed parsing map file data", MessageList.ERROR);
|
||||||
|
@ -836,7 +837,7 @@ public class ConfigurationWizard extends JDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
testOutput.addMessage("### Parsing command output for addresses");
|
testOutput.addMessage("### Parsing command output for addresses");
|
||||||
addresses = new Properties();
|
addresses = new HashMap<String, Integer>();
|
||||||
boolean parseOK = ContikiMoteType.parseCommandData(commandData, addresses);
|
boolean parseOK = ContikiMoteType.parseCommandData(commandData, addresses);
|
||||||
if (!parseOK) {
|
if (!parseOK) {
|
||||||
testOutput.addMessage("### Error: Failed parsing command output", MessageList.ERROR);
|
testOutput.addMessage("### Error: Failed parsing command output", MessageList.ERROR);
|
||||||
|
@ -930,11 +931,11 @@ public class ConfigurationWizard extends JDialog {
|
||||||
testOutput.addMessage("### Testing Contiki library memory replacement");
|
testOutput.addMessage("### Testing Contiki library memory replacement");
|
||||||
|
|
||||||
testOutput.addMessage("### Configuring Contiki using parsed reference address");
|
testOutput.addMessage("### Configuring Contiki using parsed reference address");
|
||||||
int relRefAddress = (Integer) addresses.get("ref_var");
|
if (!addresses.containsKey("referenceVar")) {
|
||||||
if (!addresses.containsKey("ref_var")) {
|
testOutput.addMessage("Could not find address of referenceVar", MessageList.ERROR);
|
||||||
testOutput.addMessage("Could not find address of ref_var", MessageList.ERROR);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
int relRefAddress = (Integer) addresses.get("referenceVar");
|
||||||
javaLibrary.setReferenceAddress(relRefAddress);
|
javaLibrary.setReferenceAddress(relRefAddress);
|
||||||
|
|
||||||
testOutput.addMessage("### Creating data and BSS memory sections");
|
testOutput.addMessage("### Creating data and BSS memory sections");
|
||||||
|
@ -942,7 +943,7 @@ public class ConfigurationWizard extends JDialog {
|
||||||
byte[] initialBssSection = new byte[bssSectionSize];
|
byte[] initialBssSection = new byte[bssSectionSize];
|
||||||
javaLibrary.getMemory(relDataSectionAddr, dataSectionSize, initialDataSection);
|
javaLibrary.getMemory(relDataSectionAddr, dataSectionSize, initialDataSection);
|
||||||
javaLibrary.getMemory(relBssSectionAddr, bssSectionSize, initialBssSection);
|
javaLibrary.getMemory(relBssSectionAddr, bssSectionSize, initialBssSection);
|
||||||
SectionMoteMemory memory = new SectionMoteMemory(addresses);
|
SectionMoteMemory memory = new SectionMoteMemory(addresses, 0);
|
||||||
memory.setMemorySegment(relDataSectionAddr, initialDataSection);
|
memory.setMemorySegment(relDataSectionAddr, initialDataSection);
|
||||||
memory.setMemorySegment(relBssSectionAddr, initialBssSection);
|
memory.setMemorySegment(relBssSectionAddr, initialBssSection);
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,7 @@ import se.sics.cooja.ClassDescription;
|
||||||
import se.sics.cooja.GUI;
|
import se.sics.cooja.GUI;
|
||||||
import se.sics.cooja.Mote;
|
import se.sics.cooja.Mote;
|
||||||
import se.sics.cooja.MoteInterface;
|
import se.sics.cooja.MoteInterface;
|
||||||
import se.sics.cooja.SimEventCentral.LogOutputEvent;
|
import se.sics.cooja.SimEventCentral.MoteCountListener;
|
||||||
import se.sics.cooja.SimEventCentral.LogOutputListener;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mote2Mote Relations is used to show mote relations in simulated
|
* Mote2Mote Relations is used to show mote relations in simulated
|
||||||
|
@ -83,13 +82,32 @@ public class Mote2MoteRelations extends MoteInterface {
|
||||||
private ArrayList<Mote> relations = new ArrayList<Mote>();
|
private ArrayList<Mote> relations = new ArrayList<Mote>();
|
||||||
private GUI gui;
|
private GUI gui;
|
||||||
|
|
||||||
private LogOutputListener logListener;
|
private Observer logObserver = new Observer() {
|
||||||
|
public void update(Observable o, Object arg) {
|
||||||
|
String msg = ((Log) o).getLastLogMessage();
|
||||||
|
handleNewLog(msg);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
private MoteCountListener moteCountListener;
|
||||||
|
|
||||||
public Mote2MoteRelations(Mote mote) {
|
public Mote2MoteRelations(Mote mote) {
|
||||||
this.mote = mote;
|
this.mote = mote;
|
||||||
this.gui = mote.getSimulation().getGUI();
|
this.gui = mote.getSimulation().getGUI();
|
||||||
|
}
|
||||||
|
|
||||||
mote.getSimulation().getEventCentral().addLogOutputListener(logListener = new LogOutputListener() {
|
public void added() {
|
||||||
|
super.added();
|
||||||
|
|
||||||
|
/* Observe log interfaces */
|
||||||
|
for (MoteInterface mi: mote.getInterfaces().getInterfaces()) {
|
||||||
|
if (mi instanceof Log) {
|
||||||
|
((Log)mi).addObserver(logObserver);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Observe other motes: if removed, remove our relations to them too */
|
||||||
|
mote.getSimulation().getEventCentral().addMoteCountListener(moteCountListener = new MoteCountListener() {
|
||||||
public void moteWasAdded(Mote mote) {
|
public void moteWasAdded(Mote mote) {
|
||||||
/* Ignored */
|
/* Ignored */
|
||||||
}
|
}
|
||||||
|
@ -106,28 +124,28 @@ public class Mote2MoteRelations extends MoteInterface {
|
||||||
relations.remove(mote);
|
relations.remove(mote);
|
||||||
gui.removeMoteRelation(Mote2MoteRelations.this.mote, mote);
|
gui.removeMoteRelation(Mote2MoteRelations.this.mote, mote);
|
||||||
}
|
}
|
||||||
public void newLogOutput(LogOutputEvent ev) {
|
|
||||||
if (ev.getMote() != Mote2MoteRelations.this.mote) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
handleNewLog(ev.msg);
|
|
||||||
}
|
|
||||||
public void removedLogOutput(LogOutputEvent ev) {
|
|
||||||
/* Ignored */
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removed() {
|
public void removed() {
|
||||||
super.removed();
|
super.removed();
|
||||||
|
|
||||||
|
/* Stop observing log interfaces */
|
||||||
|
for (MoteInterface mi: mote.getInterfaces().getInterfaces()) {
|
||||||
|
if (mi instanceof Log) {
|
||||||
|
((Log)mi).deleteObserver(logObserver);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logObserver = null;
|
||||||
|
|
||||||
|
/* Remove all relations to other motes */
|
||||||
Mote[] relationsArr = relations.toArray(new Mote[0]);
|
Mote[] relationsArr = relations.toArray(new Mote[0]);
|
||||||
for (Mote m: relationsArr) {
|
for (Mote m: relationsArr) {
|
||||||
gui.removeMoteRelation(Mote2MoteRelations.this.mote, m);
|
gui.removeMoteRelation(Mote2MoteRelations.this.mote, m);
|
||||||
}
|
}
|
||||||
relations.clear();
|
relations.clear();
|
||||||
|
|
||||||
mote.getSimulation().getEventCentral().removeLogOutputListener(logListener);
|
mote.getSimulation().getEventCentral().removeMoteCountListener(moteCountListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleNewLog(String msg) {
|
private void handleNewLog(String msg) {
|
||||||
|
|
|
@ -46,8 +46,6 @@ import org.jdom.Element;
|
||||||
import se.sics.cooja.ClassDescription;
|
import se.sics.cooja.ClassDescription;
|
||||||
import se.sics.cooja.Mote;
|
import se.sics.cooja.Mote;
|
||||||
import se.sics.cooja.MoteInterface;
|
import se.sics.cooja.MoteInterface;
|
||||||
import se.sics.cooja.SimEventCentral.LogOutputEvent;
|
|
||||||
import se.sics.cooja.SimEventCentral.LogOutputListener;
|
|
||||||
import se.sics.cooja.plugins.skins.AttributeVisualizerSkin;
|
import se.sics.cooja.plugins.skins.AttributeVisualizerSkin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,33 +84,38 @@ public class MoteAttributes extends MoteInterface {
|
||||||
|
|
||||||
private HashMap<String, Object> attributes = new HashMap<String, Object>();
|
private HashMap<String, Object> attributes = new HashMap<String, Object>();
|
||||||
|
|
||||||
private LogOutputListener logListener;
|
private Observer logObserver = new Observer() {
|
||||||
|
public void update(Observable o, Object arg) {
|
||||||
|
String msg = ((Log) o).getLastLogMessage();
|
||||||
|
handleNewLog(msg);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
public MoteAttributes(Mote mote) {
|
public MoteAttributes(Mote mote) {
|
||||||
this.mote = mote;
|
this.mote = mote;
|
||||||
|
}
|
||||||
|
|
||||||
mote.getSimulation().getEventCentral().addLogOutputListener(logListener = new LogOutputListener() {
|
public void added() {
|
||||||
public void moteWasAdded(Mote mote) {
|
super.added();
|
||||||
/* Ignored */
|
|
||||||
|
/* Observe log interfaces */
|
||||||
|
for (MoteInterface mi: mote.getInterfaces().getInterfaces()) {
|
||||||
|
if (mi instanceof Log) {
|
||||||
|
((Log)mi).addObserver(logObserver);
|
||||||
}
|
}
|
||||||
public void moteWasRemoved(Mote mote) {
|
}
|
||||||
/* Ignored */
|
|
||||||
}
|
|
||||||
public void newLogOutput(LogOutputEvent ev) {
|
|
||||||
if (ev.getMote() != MoteAttributes.this.mote) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
handleNewLog(ev.msg);
|
|
||||||
}
|
|
||||||
public void removedLogOutput(LogOutputEvent ev) {
|
|
||||||
/* Ignored */
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removed() {
|
public void removed() {
|
||||||
super.removed();
|
super.removed();
|
||||||
mote.getSimulation().getEventCentral().removeLogOutputListener(logListener);
|
|
||||||
|
/* Stop observing log interfaces */
|
||||||
|
for (MoteInterface mi: mote.getInterfaces().getInterfaces()) {
|
||||||
|
if (mi instanceof Log) {
|
||||||
|
((Log)mi).deleteObserver(logObserver);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logObserver = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleNewLog(String msg) {
|
private void handleNewLog(String msg) {
|
||||||
|
|
|
@ -41,13 +41,12 @@ import javax.swing.JPanel;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
|
||||||
import se.sics.cooja.AddressMemory;
|
|
||||||
import se.sics.cooja.ClassDescription;
|
import se.sics.cooja.ClassDescription;
|
||||||
import se.sics.cooja.Mote;
|
import se.sics.cooja.Mote;
|
||||||
import se.sics.cooja.MoteInterface;
|
import se.sics.cooja.MoteInterface;
|
||||||
import se.sics.cooja.MoteTimeEvent;
|
import se.sics.cooja.MoteMemory;
|
||||||
import se.sics.cooja.Simulation;
|
import se.sics.cooja.MoteMemory.MemoryEventType;
|
||||||
import se.sics.cooja.TimeEvent;
|
import se.sics.cooja.MoteMemory.MemoryMonitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read-only interface to Rime address read from Contiki variable: rimeaddr_node_addr.
|
* Read-only interface to Rime address read from Contiki variable: rimeaddr_node_addr.
|
||||||
|
@ -59,37 +58,27 @@ import se.sics.cooja.TimeEvent;
|
||||||
@ClassDescription("Rime address")
|
@ClassDescription("Rime address")
|
||||||
public class RimeAddress extends MoteInterface {
|
public class RimeAddress extends MoteInterface {
|
||||||
private static Logger logger = Logger.getLogger(RimeAddress.class);
|
private static Logger logger = Logger.getLogger(RimeAddress.class);
|
||||||
private AddressMemory moteMem;
|
private MoteMemory moteMem;
|
||||||
|
|
||||||
public static final int RIME_ADDR_LENGTH = 2;
|
public static final int RIME_ADDR_LENGTH = 2;
|
||||||
|
|
||||||
|
private MemoryMonitor memMonitor = null;
|
||||||
|
|
||||||
public RimeAddress(final Mote mote) {
|
public RimeAddress(final Mote mote) {
|
||||||
moteMem = (AddressMemory) mote.getMemory();
|
moteMem = mote.getMemory();
|
||||||
|
if (hasRimeAddress()) {
|
||||||
/* Detect startup address (only zeroes) */
|
memMonitor = new MemoryMonitor() {
|
||||||
TimeEvent updateWhenAddressReady = new MoteTimeEvent(mote, 0) {
|
public void memoryChanged(MoteMemory memory, MemoryEventType type, int address) {
|
||||||
public void execute(long t) {
|
if (type != MemoryEventType.WRITE) {
|
||||||
if (!hasRimeAddress()) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
String addrString = getAddressString();
|
|
||||||
addrString = addrString.replace(".", "");
|
|
||||||
addrString = addrString.replace("0", "");
|
|
||||||
if (!addrString.isEmpty()) {
|
|
||||||
setChanged();
|
setChanged();
|
||||||
notifyObservers();
|
notifyObservers();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
/* Postpone until address has been set */
|
/* TODO XXX Timeout? */
|
||||||
mote.getSimulation().scheduleEvent(
|
moteMem.addMemoryMonitor(moteMem.getVariableAddress("rimeaddr_node_addr"), RIME_ADDR_LENGTH, memMonitor);
|
||||||
this,
|
}
|
||||||
mote.getSimulation().getSimulationTime() + Simulation.MILLISECOND);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
updateWhenAddressReady.execute(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasRimeAddress() {
|
public boolean hasRimeAddress() {
|
||||||
|
@ -140,6 +129,13 @@ public class RimeAddress extends MoteInterface {
|
||||||
this.deleteObserver(observer);
|
this.deleteObserver(observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removed() {
|
||||||
|
super.removed();
|
||||||
|
if (memMonitor != null) {
|
||||||
|
moteMem.removeMemoryMonitor(moteMem.getVariableAddress("rimeaddr_node_addr"), RIME_ADDR_LENGTH, memMonitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Collection<Element> getConfigXML() {
|
public Collection<Element> getConfigXML() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ package se.sics.cooja.motes;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Observable;
|
import java.util.Observable;
|
||||||
import java.util.Observer;
|
import java.util.Observer;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
@ -90,7 +91,7 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme
|
||||||
public AbstractApplicationMote(MoteType moteType, Simulation sim) {
|
public AbstractApplicationMote(MoteType moteType, Simulation sim) {
|
||||||
setSimulation(sim);
|
setSimulation(sim);
|
||||||
this.moteType = moteType;
|
this.moteType = moteType;
|
||||||
this.memory = new SectionMoteMemory(new Properties());
|
this.memory = new SectionMoteMemory(new HashMap<String, Integer>(), 0);
|
||||||
this.moteInterfaces = new MoteInterfaceHandler(this, moteType.getMoteInterfaceClasses());
|
this.moteInterfaces = new MoteInterfaceHandler(this, moteType.getMoteInterfaceClasses());
|
||||||
this.moteInterfaces.getRadio().addObserver(radioDataObserver);
|
this.moteInterfaces.getRadio().addObserver(radioDataObserver);
|
||||||
requestImmediateWakeup();
|
requestImmediateWakeup();
|
||||||
|
@ -145,7 +146,7 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme
|
||||||
public boolean setConfigXML(Simulation simulation,
|
public boolean setConfigXML(Simulation simulation,
|
||||||
Collection<Element> configXML, boolean visAvailable) {
|
Collection<Element> configXML, boolean visAvailable) {
|
||||||
setSimulation(simulation);
|
setSimulation(simulation);
|
||||||
this.memory = new SectionMoteMemory(new Properties());
|
this.memory = new SectionMoteMemory(new HashMap<String, Integer>(), 0);
|
||||||
moteInterfaces.getRadio().addObserver(radioDataObserver);
|
moteInterfaces.getRadio().addObserver(radioDataObserver);
|
||||||
|
|
||||||
for (Element element : configXML) {
|
for (Element element : configXML) {
|
||||||
|
|
|
@ -64,27 +64,4 @@ public abstract class AbstractEmulatedMote extends AbstractWakeupMote implements
|
||||||
public String getStackTrace() {
|
public String getStackTrace() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface MemoryMonitor {
|
|
||||||
public boolean start(int address, int size);
|
|
||||||
public void stop();
|
|
||||||
public Mote getMote();
|
|
||||||
public int getAddress();
|
|
||||||
public int getSize();
|
|
||||||
|
|
||||||
public void setLastBufferAccess(BufferAccess ba);
|
|
||||||
public BufferAccess getLastBufferAccess();
|
|
||||||
|
|
||||||
public boolean isPointer();
|
|
||||||
public void setPointer(boolean isPointer, MemoryMonitor pointedMemory);
|
|
||||||
public MemoryMonitor getPointedMemory();
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum MemoryEventType { READ, WRITE, UNKNOWN };
|
|
||||||
public interface MemoryEventHandler {
|
|
||||||
public void event(MemoryMonitor mm, MemoryEventType type, int adr, int data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract MemoryMonitor createMemoryMonitor(MemoryEventHandler meh);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -147,6 +147,11 @@ public abstract class AbstractRadioMedium extends RadioMedium {
|
||||||
conn.getSource().setCurrentSignalStrength(SS_STRONG);
|
conn.getSource().setCurrentSignalStrength(SS_STRONG);
|
||||||
}
|
}
|
||||||
for (Radio dstRadio : conn.getDestinations()) {
|
for (Radio dstRadio : conn.getDestinations()) {
|
||||||
|
if (conn.getSource().getChannel() >= 0 &&
|
||||||
|
dstRadio.getChannel() >= 0 &&
|
||||||
|
conn.getSource().getChannel() != dstRadio.getChannel()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (dstRadio.getCurrentSignalStrength() < SS_STRONG) {
|
if (dstRadio.getCurrentSignalStrength() < SS_STRONG) {
|
||||||
dstRadio.setCurrentSignalStrength(SS_STRONG);
|
dstRadio.setCurrentSignalStrength(SS_STRONG);
|
||||||
}
|
}
|
||||||
|
@ -159,7 +164,11 @@ public abstract class AbstractRadioMedium extends RadioMedium {
|
||||||
if (intfRadio.getCurrentSignalStrength() < SS_STRONG) {
|
if (intfRadio.getCurrentSignalStrength() < SS_STRONG) {
|
||||||
intfRadio.setCurrentSignalStrength(SS_STRONG);
|
intfRadio.setCurrentSignalStrength(SS_STRONG);
|
||||||
}
|
}
|
||||||
|
if (conn.getSource().getChannel() >= 0 &&
|
||||||
|
intfRadio.getChannel() >= 0 &&
|
||||||
|
conn.getSource().getChannel() != intfRadio.getChannel()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!intfRadio.isInterfered()) {
|
if (!intfRadio.isInterfered()) {
|
||||||
/*logger.warn("Radio was not interfered");*/
|
/*logger.warn("Radio was not interfered");*/
|
||||||
intfRadio.interfereAnyReception();
|
intfRadio.interfereAnyReception();
|
||||||
|
|
|
@ -287,6 +287,12 @@ public class UDGM extends AbstractRadioMedium {
|
||||||
conn.getSource().setCurrentSignalStrength(SS_STRONG);
|
conn.getSource().setCurrentSignalStrength(SS_STRONG);
|
||||||
}
|
}
|
||||||
for (Radio dstRadio : conn.getDestinations()) {
|
for (Radio dstRadio : conn.getDestinations()) {
|
||||||
|
if (conn.getSource().getChannel() >= 0 &&
|
||||||
|
dstRadio.getChannel() >= 0 &&
|
||||||
|
conn.getSource().getChannel() != dstRadio.getChannel()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
double dist = conn.getSource().getPosition().getDistanceTo(dstRadio.getPosition());
|
double dist = conn.getSource().getPosition().getDistanceTo(dstRadio.getPosition());
|
||||||
|
|
||||||
double maxTxDist = TRANSMITTING_RANGE
|
double maxTxDist = TRANSMITTING_RANGE
|
||||||
|
@ -303,6 +309,12 @@ public class UDGM extends AbstractRadioMedium {
|
||||||
/* Set signal strength to below weak on interfered */
|
/* Set signal strength to below weak on interfered */
|
||||||
for (RadioConnection conn : conns) {
|
for (RadioConnection conn : conns) {
|
||||||
for (Radio intfRadio : conn.getInterfered()) {
|
for (Radio intfRadio : conn.getInterfered()) {
|
||||||
|
if (conn.getSource().getChannel() >= 0 &&
|
||||||
|
intfRadio.getChannel() >= 0 &&
|
||||||
|
conn.getSource().getChannel() != intfRadio.getChannel()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
double dist = conn.getSource().getPosition().getDistanceTo(intfRadio.getPosition());
|
double dist = conn.getSource().getPosition().getDistanceTo(intfRadio.getPosition());
|
||||||
|
|
||||||
double maxTxDist = TRANSMITTING_RANGE
|
double maxTxDist = TRANSMITTING_RANGE
|
||||||
|
|
Loading…
Reference in a new issue