X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fchips%2Frf2xx%2Flayers%2FSlottedCollisionLayerP.nc;h=ce1610e7425f63009b9150fe11667000bc13f386;hb=00e708814493e030803019f2a98f3fe7e707805d;hp=500fef8673c28845b627ecf4e62c3f9e3a754394;hpb=7cb3053eaa216416d4833656f2ffbee14a5c0970;p=tinyos-2.x.git diff --git a/tos/chips/rf2xx/layers/SlottedCollisionLayerP.nc b/tos/chips/rf2xx/layers/SlottedCollisionLayerP.nc index 500fef86..ce1610e7 100644 --- a/tos/chips/rf2xx/layers/SlottedCollisionLayerP.nc +++ b/tos/chips/rf2xx/layers/SlottedCollisionLayerP.nc @@ -73,6 +73,8 @@ implementation /* ----- schedule selection ----- */ + void printStats(); + tasklet_async event bool SubReceive.header(message_t* msg) { return signal RadioReceive.header(msg); @@ -112,11 +114,11 @@ implementation uint16_t start = call Config.getCollisionWindowStart(msg); uint16_t length = call Config.getCollisionWindowLength(msg); - error1 -= error1 >> ERROR_DECAY; + error1 -= (error1 + (1<> ERROR_DECAY; if( isBetween(exponent, schedule1, start, length) ) error1 += ERROR_COLLISION; - error2 -= error2 >> ERROR_DECAY; + error2 -= (error1 + (1<> ERROR_DECAY; if( isBetween(exponent, schedule2, start, length) ) error2 += ERROR_COLLISION; @@ -133,24 +135,9 @@ implementation schedule2 = getNextRandom(); } - return signal RadioReceive.receive(msg); - } - - void printStats(); - - tasklet_async event void Config.timerTick() - { - if( error1 >= (1 << ERROR_DECAY) ) - error1 -= error1 >> ERROR_DECAY; - else if( error1 > 0 ) - --error1; - - if( error2 >= (1 << ERROR_DECAY) ) - error2 -= error2 >> ERROR_DECAY; - else if( error2 > 0 ) - --error2; - printStats(); + + return signal RadioReceive.receive(msg); } /* ------ transmit ------ */ @@ -196,6 +183,8 @@ implementation call RadioAlarm.wait(backoff); txTime = time + backoff; + printStats(); + return SUCCESS; } @@ -256,7 +245,7 @@ implementation tasklet_norace uint8_t count; void printStats() { - if( ++count > 10 && call DiagMsg.record() ) + if( ++count > 50 && call DiagMsg.record() ) { count = 0;