You can do that using the LocalTime and the PacketTimestamp
interfaces. In the sendDone event, you can figure out the time delay
between transmitting the SFD byte and invoking the sendDone event as
follows:

  event void AMSend.sendDone(message_t* bufPtr, error_t error) {
      uint32_t txSfdTime;
      uint32_t sendDoneEventTime;

      sendDoneEventTime = call LocalTime.get();

      if(call PacketTimeStamp.isValid(bufPtr)) {
          txSfdTime = call PacketTimeStamp.timestamp(bufPtr);
          dt = sendDoneEventTime - txSfdTime;

          // use dt here however you wish (printf, diagmsg, etc.)

      }
  }


Similarly, on the receiver side, you can figure out the time delay
between receiving the SFD byte and the invocation of the receive
event.

  event message_t* Receive.receive(message_t* bufPtr,
                                   void* payload, uint8_t len) {
      uint32_t rxSfdTime;
      uint32_t receiveEventTime;

      receiveEventTime = call LocalTime.get();

      if(call PacketTimeStamp.isValid(bufPtr)) {
        rxSfdTime = call PacketTimeStamp.timestamp(bufPtr);
        dt = receiveEventTime - rxSfdTime;

        // use dt here however you wish (printf, diagmsg, etc.)

      }

      return bufPtr;
  }

The sum of the two delays (the one on the transmitter's side and the
one on the receiver) will give you the time between the sendDone and
the receive events.

Janos

On Tue, Feb 1, 2011 at 4:24 PM, ranal fernando <[email protected]> wrote:
> my belief is that it is hard to sync time between mote to capture a very
> little time between the Send.sendDone() and Receive.receive().
>
> you can get the Send.sendDone() separately (without trying to send it using
> the same packet) & calculate (get theĀ  Receive.receive() time separately).
>
> i'm really not sure whether this will give the exact answer. (because at the
> destination, packet processing also will take some time before
> signalingReceive.receive() )
>
>
> ranal fernando
>
> ________________________________
> Date: Sat, 29 Jan 2011 22:28:26 -0500
> From: [email protected]
> To: [email protected]
> Subject: [Tinyos-help] how to measure interval btw Send.sendDone() and
> Receive.receive()?
>
> Hi everyone,
> Assuming sender and receiver are synchronous, I want to measure the time
> interval between two events: namely, Send.sendDone() event of a packet at
> the sender and Receive.receive() event of the packet at the receiver.
> Initially I decided to put timestamp of Send.sendDone() event in the packet
> and timestamp Receive.receive() event at the receiver, the interval could be
> obtained by the difference of the two timestamps. However, packet payload is
> loaded prior to calling Send.send() thus before Send.sendDone(), it is
> impossible to timestamp Send.sendDone() event and place the timestamp in the
> packet. Can anyone give me some suggestion on how this may be achieved?
> Thanks very much.
>
> --
> -Xiaohui Liu
>
> _______________________________________________ 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
>

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

Reply via email to