From: andreaskoepke Date: Wed, 9 Jul 2008 12:48:43 +0000 (+0000) Subject: be more careful with conversion X-Git-Tag: release_tinyos_2_1_0_0~98 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=a089233293d8ccdd76bc789d9cbb23a515e25eff be more careful with conversion --- diff --git a/tos/platforms/eyesIFX/LocalTimeP.nc b/tos/platforms/eyesIFX/LocalTimeP.nc index f637469d..2136381a 100644 --- a/tos/platforms/eyesIFX/LocalTimeP.nc +++ b/tos/platforms/eyesIFX/LocalTimeP.nc @@ -94,7 +94,7 @@ implementation { } async command uint32_t LocalTimeTMilli.get() { - return (call LocalTime32kHz.get() / 32); + return (call WideLocalTime.get() / 32); } } diff --git a/tos/platforms/eyesIFX/PacketStampC.nc b/tos/platforms/eyesIFX/PacketStampC.nc index a28d9946..88f1a0a1 100644 --- a/tos/platforms/eyesIFX/PacketStampC.nc +++ b/tos/platforms/eyesIFX/PacketStampC.nc @@ -35,7 +35,10 @@ configuration PacketStampC { } implementation { components PacketStampP as PS; + components LocalTimeC as LT; + PacketTimeStamp32khz = PS; PacketTimeStampMilli = PS; + PS.LocalTimeMilli -> LT; } diff --git a/tos/platforms/eyesIFX/PacketStampP.nc b/tos/platforms/eyesIFX/PacketStampP.nc index 5893a1b8..e92f3c27 100644 --- a/tos/platforms/eyesIFX/PacketStampP.nc +++ b/tos/platforms/eyesIFX/PacketStampP.nc @@ -34,6 +34,9 @@ module PacketStampP { interface PacketTimeStamp as PacketTimeStamp32khz; interface PacketTimeStamp as PacketTimeStampMilli; } + uses { + interface LocalTime as LocalTimeMilli; + } } implementation { async command bool PacketTimeStamp32khz.isValid(message_t* msg) { @@ -47,14 +50,15 @@ implementation { async command void PacketTimeStamp32khz.set(message_t* msg, uint32_t value) { getMetadata(msg)->time = value; } - async command bool PacketTimeStampMilli.isValid(message_t* msg) { return TRUE; } async command void PacketTimeStampMilli.clear(message_t* msg) { } async command uint32_t PacketTimeStampMilli.timestamp(message_t* msg) { - return (getMetadata(msg)->time / 32); + uint32_t now = call LocalTimeMilli.get(); + uint32_t delay = (now * 32) - (getMetadata(msg)->time); + return now - (delay / 32); } async command void PacketTimeStampMilli.set(message_t* msg, uint32_t value) { getMetadata(msg)->time = value * 32; diff --git a/tos/platforms/eyesIFX/TimeSyncMessageC.nc b/tos/platforms/eyesIFX/TimeSyncMessageC.nc index 963fafff..03ace249 100644 --- a/tos/platforms/eyesIFX/TimeSyncMessageC.nc +++ b/tos/platforms/eyesIFX/TimeSyncMessageC.nc @@ -51,7 +51,8 @@ configuration TimeSyncMessageC { implementation { components TimeSyncMessageP as TS; components ActiveMessageC as AM; - + components LocalTimeC as LT; + SplitControl = AM; Receive = AM.Receive; @@ -64,6 +65,7 @@ implementation { TS.SubSend -> AM.AMSend; TS.AMPacket -> AM.AMPacket; + TS.LocalTimeMilli -> LT; TimeSyncAMSend32khz = TS; TimeSyncAMSendMilli = TS; diff --git a/tos/platforms/eyesIFX/TimeSyncMessageP.nc b/tos/platforms/eyesIFX/TimeSyncMessageP.nc index 6748e144..9eceba8b 100644 --- a/tos/platforms/eyesIFX/TimeSyncMessageP.nc +++ b/tos/platforms/eyesIFX/TimeSyncMessageP.nc @@ -43,6 +43,7 @@ module TimeSyncMessageP { uses { interface AMSend as SubSend[am_id_t id]; interface AMPacket; + interface LocalTime as LocalTimeMilli; } } implementation { @@ -111,7 +112,9 @@ implementation { } command uint32_t TimeSyncPacketMilli.eventTime(message_t* msg) { - return (getMetadata(msg)->time / 32); + uint32_t now = call LocalTimeMilli.get(); + uint32_t delay = (now * 32) - (getMetadata(msg)->time); + return now - (delay / 32); }; event void SubSend.sendDone[uint8_t id](message_t* msg, error_t result) {