]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
fix bug: mac header was "allocated" twice
authorandreaskoepke <andreaskoepke>
Fri, 8 Aug 2008 08:05:47 +0000 (08:05 +0000)
committerandreaskoepke <andreaskoepke>
Fri, 8 Aug 2008 08:05:47 +0000 (08:05 +0000)
tos/chips/tda5250/mac/RedMacP.nc
tos/chips/tda5250/mac/SpeckMacDP.nc

index d734b492e17f9b7be6b634c810aa7005dcd91193..d0de4d0e4b5f0aba95df81735928e491a80095f1 100644 (file)
@@ -147,12 +147,14 @@ implementation
         SUB_HEADER_TIME=PHY_HEADER_TIME + sizeof(message_header_t)*BYTE_TIME,
         SUB_FOOTER_TIME=2*BYTE_TIME, // 2 bytes crc 
         // DEFAULT_SLEEP_TIME=1625,
+#ifndef DEFAULT_SLEEP_TIME
         DEFAULT_SLEEP_TIME=2048,
         // DEFAULT_SLEEP_TIME=4096,
         // DEFAULT_SLEEP_TIME=8192,
         // DEFAULT_SLEEP_TIME=16384,
         // DEFAULT_SLEEP_TIME=32768U,
         // DEFAULT_SLEEP_TIME=65535U,
+#endif
         DATA_DETECT_TIME=17,
         RX_SETUP_TIME=102,    // time to set up receiver
         TX_SETUP_TIME=58,     // time to set up transmitter
@@ -384,7 +386,7 @@ implementation
             sT = networkSleeptime;
         }
         if(msg == NULL) return;
-        macHdr = (red_mac_header_t *)call SubPacket.getPayload(msg, sizeof(red_mac_header_t) + length);
+        macHdr = (red_mac_header_t *)call SubPacket.getPayload(msg, sizeof(red_mac_header_t));
         macHdr->repetitionCounter = sT/(length * BYTE_TIME + SUB_HEADER_TIME + SUB_FOOTER_TIME + 
                                         TX_GAP_TIME) + 1;
         atomic {
@@ -403,6 +405,8 @@ implementation
                     call Timer.start((call Random.rand16() >> 3) & ZERO_BACKOFF_MASK);
                 }
                 else {
+                    sdDebug(332);
+                    sdDebug(macHdr->repetitionCounter);
                     call Timer.start(backoff(longRetryCounter));
                 }
             }
@@ -857,7 +861,7 @@ implementation
         rxStat.duplicate = PERF_UNKNOWN;
         rxStat.repCounter = 0xff;
 #endif
-        sdDebug(190);
+        // sdDebug(190);
         if(macState == RX_P) {
             // sdDebug(191);
             if(error == SUCCESS) {
@@ -1055,7 +1059,6 @@ implementation
         if(macState == RX_P) {
             rxTime = call LocalTime32kHz.get();
             call ChannelMonitor.rxSuccess();
-            sdDebug(221);
         }
     }
     
index bc904ebf6711929686dba886f7a1e8330a74933b..daa64e713da604a94f87a48e55079be891d71ee3 100644 (file)
@@ -140,6 +140,7 @@ implementation
         
         SUB_HEADER_TIME=PHY_HEADER_TIME + sizeof(message_header_t)*BYTE_TIME,
         SUB_FOOTER_TIME=2*BYTE_TIME, // 2 bytes crc 
+#ifndef DEFAULT_SLEEP_TIME
         DEFAULT_SLEEP_TIME=1625,
         // DEFAULT_SLEEP_TIME=3250,
         // DEFAULT_SLEEP_TIME=6500,
@@ -147,6 +148,7 @@ implementation
         // DEFAULT_SLEEP_TIME=16384,
         // DEFAULT_SLEEP_TIME=32768U,
         // DEFAULT_SLEEP_TIME=65535U,
+#endif
         DATA_DETECT_TIME=17,
         RX_SETUP_TIME=102,    // time to set up receiver
         TX_SETUP_TIME=58,     // time to set up transmitter
@@ -346,7 +348,7 @@ implementation
             sT = networkSleeptime;
         }
         if(msg == NULL) return;
-        macHdr = (red_mac_header_t *)call SubPacket.getPayload(msg, sizeof(red_mac_header_t) + length);
+        macHdr = (red_mac_header_t *)call SubPacket.getPayload(msg, sizeof(red_mac_header_t));
         macHdr->repetitionCounter = sT/(length * BYTE_TIME + SUB_HEADER_TIME + SUB_FOOTER_TIME) + 1;
         atomic {
             getHeader(msg)->token = seqNo;
@@ -539,6 +541,7 @@ implementation
                 MIN_BACKOFF_MASK = (MIN_BACKOFF_MASK << 1) + 1;
             }
             MIN_BACKOFF_MASK >>= 2;
+            if(MIN_BACKOFF_MASK < 0x3ff) MIN_BACKOFF_MASK=0x3ff;
         }
 #ifdef SPECKMAC_DEBUG
         call SerialDebug.putShortDesc("SpeckMacP");
@@ -950,9 +953,9 @@ implementation
     
     async event void RadioTimeStamping.transmittedSFD(uint16_t time, message_t* p_msg ) {
         if((macState == TX) && (p_msg == txBufPtr)) {
-            getMetadata(msg)->sfdtime = call LocalTime32kHz.get();
+            getMetadata(p_msg)->sfdtime = call LocalTime32kHz.get();
             txMacHdr->time =
-                call TimeDiff32.computeDelta(getMetadata(msg)->sfdtime,
+                call TimeDiff32.computeDelta(getMetadata(p_msg)->sfdtime,
                                              getMetadata(p_msg)->time);
         }
     }