Hi,

I have used the RadioTimeStamping interface to insert timestamps into 
radio packets 'on the fly'. In TinyOS 2.0 the interface was provided by 
the configuration CC2420TransmitC. The implementation could be found in 
the module CC2420TransmitP.

Look at the revision 1.1 here:  
http://tinyos.cvs.sourceforge.net/viewvc/tinyos/tinyos-2.x/tos/chips/cc2420/transmit/CC2420TransmitP.nc?revision=1.1&view=markup

As you see, this module provides interface RadioTimeStamping as 
TimeStamp. When the start of frame delimiter (SFD) is transmitted, 
CaptureSFD.captured event is signaled (line 259). This event 'brings' 
the 16-bit reading of the TimerB (time) captured at the moment of SFD 
transmission. Then the signal TimeStamp.transmittedSFD (line 267) can 
'bring' that time value to some user of RadioTimeStamping interface. 
Similarly, when SFD is received, TimeStamp.receivedSFD is signaled (line 
305) and it gives you the time of SFD reception.

Of course, in your top-level configuration you need to wire that 
interface, e.g. 'App.RadioTimeStamping->CC2420TransmitC.TimeStamp'. In 
your application component you need to write a line like this 'uses 
interface RadioTimeStamping' and provide event handlers like these:

 async event void RadioTimeStamping.transmittedSFD(uint16_t time, 
message_t* p_msg){
/*your handler*/
}

   async event void RadioTimeStamping.receivedSFD(uint16_t time){
/*your handler*/
}


In order to insert the time value in the transmitted packet I called the 
command 'modify' of the CC2420Transmit interface (provided by the very 
same CC2420TransmitP, line 204) in the RadioTimeStamping.transmittedSFD 
event handler. Notice that TimerB is clocked by 32768 Hz oscillator, so 
it overflows each 2 seconds. If you wish to get 32-bit time value you 
can read 32-bit timer value (using an interface like 
Alarm<T32khz,uint32_t>) and substitute 16-bit variable 'time' returned 
by RadioTimeStamping.transmittedSFD for the lower bits of the timer 
value - in a similar way as it is done in the new version of 
CC2420TransmitP, line 239:

 
http://tinyos.cvs.sourceforge.net/viewvc/tinyos/tinyos-2.x/tos/chips/cc2420/transmit/CC2420TransmitP.nc?revision=1.10&view=markup


In TinyOS 2.1 the interface RadioTimeStamping is not supported. As far 
as I understand, the interface PacketTimestamp does not allow the 
receiver to retrieve the sender's timestamp from the received radio 
packet. It can only give you the time of transmission on the sender's 
side and the time of reception on the receiver's side (it is recommended 
to call the command 'timestamp' from the receiveDone or sendDone event 
handlers). But you can use interfaces TimeSyncAMSend and TimeSyncPacket 
if you wish to do some synchronization operations (as described in TEP 133).


Ahmed Ebaid wrote:
> Hey
> I wonder if anyone has used the RadioTimeStamping interface in 
> tinyOS2.x, it is not very clear to me how to use it.
> Any Suggestions.
> Thanks
>
> -- 
> Ahmed Ebaid
> PhD Student
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


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

Reply via email to