]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/rf2xx/layers/SlottedCollisionLayerP.nc
make traffic monitor optional
[tinyos-2.x.git] / tos / chips / rf2xx / layers / SlottedCollisionLayerP.nc
index 500fef8673c28845b627ecf4e62c3f9e3a754394..ce1610e7425f63009b9150fe11667000bc13f386 100644 (file)
@@ -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) - 1) >> ERROR_DECAY;
                if( isBetween(exponent, schedule1, start, length) )
                        error1 += ERROR_COLLISION; 
 
-               error2 -= error2 >> ERROR_DECAY;
+               error2 -= (error1 + (1<<ERROR_DECAY) - 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;