Hi all,

tos/chips/cc2420/transmit/CC2420TransmitP's getTime32() will sometimes return 
a 32-bit time value that is newer than recent_time, when by definition by its 
use in CaptureSFD.captured(), the 16-bit value is always older than 
recent_time.

Here's an example that fails with the current getTime32():
recent_time = 0x01a36234
time =  0xcdda
returns 0x01a3cdda
The correct value should be 0x01a2cdda.

-----
diff --git a/tos/chips/cc2420/transmit/CC2420TransmitP.nc 
b/tos/chips/cc2420/tra
index a8367e5..3f9be74 100644
--- a/tos/chips/cc2420/transmit/CC2420TransmitP.nc
+++ b/tos/chips/cc2420/transmit/CC2420TransmitP.nc
@@ -238,8 +238,9 @@ implementation {

   inline uint32_t getTime32(uint16_t time)
   {
-    uint32_t recent_time=call BackoffTimer.getNow();
-    return recent_time + (int16_t)(time - recent_time);
+    uint32_t recent_time = call BackoffTimer.getNow();
+    return (recent_time & 0xffff0000) + time -
+            (time > (recent_time & 0xffff) ? 0x10000 : 0);
   }

   /**
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to