[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/rf230 PacketLastTouch.nc, NONE, 1.1 TimeSyncMessageC.nc, NONE, 1.1 TimeSyncMessageP.nc, NONE, 1.1 TimeSyncPacket.nc, NONE, 1.1 TimeSyncSend.nc, NONE, 1.1 DefaultMacC.nc, 1.2, 1.3 DefaultPacket.h, 1.1, 1.2 DefaultPacketC.nc, 1.1, 1.2 DefaultPacketP.nc, 1.1, 1.2 RF230LayerC.nc, 1.2, 1.3 RF230LayerP.nc, 1.3, 1.4 DefaultMac.h, 1.1, NONE notes.txt, 1.1, NONE

Miklos Maroti mmaroti at users.sourceforge.net
Wed Mar 12 12:42:58 PDT 2008


Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv26880/tos/chips/rf230

Modified Files:
	DefaultMacC.nc DefaultPacket.h DefaultPacketC.nc 
	DefaultPacketP.nc RF230LayerC.nc RF230LayerP.nc 
Added Files:
	PacketLastTouch.nc TimeSyncMessageC.nc TimeSyncMessageP.nc 
	TimeSyncPacket.nc TimeSyncSend.nc 
Removed Files:
	DefaultMac.h notes.txt 
Log Message:
updated TimeSyncMessage implementation

--- NEW FILE: PacketLastTouch.nc ---
/*
 * Copyright (c) 2007, Vanderbilt University
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
 * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * Author: Miklos Maroti
 */

interface PacketLastTouch
{
	/**
	 * Requests the touch event to be called back just before the message
	 * transmission starts.
	 */
	async command void request(message_t* msg);

	/**
	 * Cancels any pending requests.
	 */
	async command void cancel(message_t* msg);

	/**
	 * This event is called by the MAC layer when the tranmission of the
	 * message starts (the SFD byte is already transmitted and the packet
	 * is already time stamped). In this method the packet payload can be
	 * updated. This method MUST do absolutely minimal processing, and 
	 * should complete in 1-2 microseconds.
	 */
	async event void touch(message_t* msg);
}

--- NEW FILE: TimeSyncMessageC.nc ---
/*
 * Copyright (c) 2007, Vanderbilt University
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
 * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * Author: Miklos Maroti
 */

#include <Timer.h>
#include <AM.h>

configuration TimeSyncMessageC
{
	provides
	{
		interface TimeSyncSend<TMicro> as TimeSyncSendMicro[am_id_t id];
		interface TimeSyncPacket<TMicro> as TimeSyncPacketMicro;
		interface LocalTime<TMicro> as LocalTimeMicro;

		interface TimeSyncSend<TMilli> as TimeSyncSendMilli[am_id_t id];
		interface TimeSyncPacket<TMilli> as TimeSyncPacketMilli;
		interface LocalTime<TMilli> as LocalTimeMilli;

		interface SplitControl;
		interface Receive[uint8_t id];
		interface Receive as Snoop[am_id_t id];
		interface Packet;
		interface AMPacket;
		interface PacketAcknowledgements;
	}
}

implementation
{
	components TimeSyncMessageP, ActiveMessageC, LocalTimeMilliC;

	TimeSyncSendMicro = TimeSyncMessageP;
	TimeSyncPacketMicro = TimeSyncMessageP;
	LocalTimeMicro = ActiveMessageC;

	TimeSyncSendMilli = TimeSyncMessageP;
	TimeSyncPacketMilli = TimeSyncMessageP;
	LocalTimeMilli = LocalTimeMilliC;

	Packet = TimeSyncMessageP;
	TimeSyncMessageP.SubSend -> ActiveMessageC.AMSend;
	TimeSyncMessageP.SubPacket -> ActiveMessageC.Packet;

	TimeSyncMessageP.LocalTimeMilli -> LocalTimeMilliC;

	SplitControl = ActiveMessageC;
	Receive	= ActiveMessageC.Receive;
	Snoop = ActiveMessageC.Snoop;
	AMPacket = ActiveMessageC;
	PacketAcknowledgements = ActiveMessageC;
}

--- NEW FILE: TimeSyncMessageP.nc ---
/*
 * Copyright (c) 2007, Vanderbilt University
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
 * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * Author: Miklos Maroti
 */

module TimeSyncMessageP
{
	provides
	{
		interface TimeSyncSend<TMicro> as TimeSyncSendMicro[uint8_t id];
		interface TimeSyncSend<TMilli> as TimeSyncSendMilli[uint8_t id];
		interface Packet;
		interface TimeSyncPacket<TMicro> as TimeSyncPacketMicro;
		interface TimeSyncPacket<TMilli> as TimeSyncPacketMilli;
	}

	uses
	{
		interface AMSend as SubSend[uint8_t id];
		interface Packet as SubPacket;
		interface PacketTimeStamp<TMicro,uint32_t>;
		interface PacketLastTouch;

		interface LocalTime<TMicro> as LocalTimeMicro;
		interface LocalTime<TMilli> as LocalTimeMilli;
	}
}

implementation
{
/*----------------- Packet -----------------*/

	typedef nx_struct timesync_footer_t
	{
		nx_uint32_t time_offset;	// in micorsec
	} timesync_footer_t;

	typedef struct timesync_local_t
	{
		uint32_t event_time;		// in microsec
	} timesync_local_t;

	inline timesync_footer_t* getFooter(message_t* msg)
	{
		return (timesync_footer_t*)(msg->data + call SubPacket.payloadLength(msg) - sizeof(timesync_footer_t));
	}

	inline timesync_local_t* getLocal(message_t* msg)
	{
		return (timesync_local_t*)(msg->data + call SubPacket.maxPayloadLength() - sizeof(timesync_local_t));
	}

	command void Packet.clear(message_t* msg) 
	{
		call SubPacket.clear(msg);
		call PacketLastTouch.cancel(msg);	// TODO: check if we need to do this
	}

	command void Packet.setPayloadLength(message_t* msg, uint8_t len) 
	{
		call SubPacket.setPayloadLength(msg, len + sizeof(timesync_footer_t));
	}

	command uint8_t Packet.payloadLength(message_t* msg) 
	{
		return call SubPacket.payloadLength(msg) - sizeof(timesync_footer_t);
	}

	command uint8_t Packet.maxPayloadLength()
	{
		return call SubPacket.maxPayloadLength() - sizeof(timesync_footer_t) - sizeof(timesync_local_t);
	}

	command void* Packet.getPayload(message_t* msg, uint8_t len)
	{
		return call SubPacket.getPayload(msg, len + sizeof(timesync_footer_t) + sizeof(timesync_local_t));
	}

/*----------------- TimeSyncSendMicro -----------------*/

	command error_t TimeSyncSendMicro.send[am_id_t id](uint32_t event_time, am_addr_t addr, message_t* msg, uint8_t len)
	{
		timesync_local_t* local = getLocal(msg);

		local->event_time = event_time;

		call PacketLastTouch.request(msg);

		return call SubSend.send[id](addr, msg, len);
	}

	command error_t TimeSyncSendMicro.cancel[am_id_t id](message_t* msg)
	{
		call PacketLastTouch.cancel(msg);
		return call SubSend.cancel[id](msg);
	}

	default event void TimeSyncSendMicro.sendDone[am_id_t id](message_t* msg, error_t error)
	{
	}

	command uint8_t TimeSyncSendMicro.maxPayloadLength[am_id_t id]()
	{
		return call SubSend.maxPayloadLength[id]() - sizeof(timesync_footer_t);
	}

	command void* TimeSyncSendMicro.getPayload[am_id_t id](message_t* msg, uint8_t len)
	{
		return call SubSend.getPayload[id](msg, len + sizeof(timesync_footer_t));
	}

/*----------------- TimeSyncSendMilli -----------------*/

	command error_t TimeSyncSendMilli.send[am_id_t id](uint32_t event_time, am_addr_t addr, message_t* msg, uint8_t len)
	{
		timesync_local_t* local = getLocal(msg);

		// compute elapsed time in millisecond
		event_time = ((event_time - call LocalTimeMilli.get()) << 10) + call LocalTimeMicro.get();

		local->event_time = event_time;

		call PacketLastTouch.request(msg);

		return call SubSend.send[id](addr, msg, len);
	}

	command error_t TimeSyncSendMilli.cancel[am_id_t id](message_t* msg)
	{
		return call SubSend.cancel[id](msg);
	}

	default event void TimeSyncSendMilli.sendDone[am_id_t id](message_t* msg, error_t error)
	{
	}

	command uint8_t TimeSyncSendMilli.maxPayloadLength[am_id_t id]()
	{
		return call SubSend.maxPayloadLength[id]() - sizeof(timesync_footer_t);
	}

	command void* TimeSyncSendMilli.getPayload[am_id_t id](message_t* msg, uint8_t len)
	{
		return call SubSend.getPayload[id](msg, len + sizeof(timesync_footer_t));
	}

	/*----------------- SubSend.sendDone -------------------*/

	event void SubSend.sendDone[am_id_t id](message_t* msg, error_t error)
	{
		signal TimeSyncSendMicro.sendDone[id](msg, error);
		signal TimeSyncSendMilli.sendDone[id](msg, error);
	}

	/*----------------- PacketLastTouch.touch -------------------*/

	enum
	{
		TIMESYNC_INVALID_STAMP = 0x80000000L,
	};

	async event void PacketLastTouch.touch(message_t* msg)
	{
		timesync_footer_t* footer = footer = getFooter(msg);
		timesync_local_t* local;

		if( call PacketTimeStamp.isSet(msg) )
		{
			local = getLocal(msg);

			footer->time_offset = local->event_time - call PacketTimeStamp.get(msg);
		}
		else
			footer->time_offset = TIMESYNC_INVALID_STAMP;
	}

	/*----------------- TimeSyncPacketMicro -----------------*/

	async command bool TimeSyncPacketMicro.hasValidTime(message_t* msg)
	{
		timesync_footer_t* footer = getFooter(msg);

		return call PacketTimeStamp.isSet(msg) && footer->time_offset != TIMESYNC_INVALID_STAMP;
	}

	async command uint32_t TimeSyncPacketMicro.getEventTime(message_t* msg)
	{
		timesync_footer_t* footer = getFooter(msg);

		return (uint32_t)(footer->time_offset) + call PacketTimeStamp.get(msg);
	}

	/*----------------- TimeSyncPacketMilli -----------------*/

	async command bool TimeSyncPacketMilli.hasValidTime(message_t* msg)
	{
		timesync_footer_t* footer = getFooter(msg);

		return call PacketTimeStamp.isSet(msg) && footer->time_offset != TIMESYNC_INVALID_STAMP;
	}

	async command uint32_t TimeSyncPacketMilli.getEventTime(message_t* msg)
	{
		timesync_footer_t* footer = getFooter(msg);

		// time offset compared to now in microsec, important that this is signed
		int32_t elapsed = (uint32_t)(footer->time_offset) + call PacketTimeStamp.get(msg) - call LocalTimeMicro.get();

		return (elapsed >> 10) + call LocalTimeMilli.get();
	}
}

--- NEW FILE: TimeSyncPacket.nc ---
/*
 * Copyright (c) 2007, Vanderbilt University
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
 * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * Author: Miklos Maroti
 */

interface TimeSyncPacket<precision_tag>
{
	/**
	 * Returns TRUE if the value returned by <tt>getTime</tt> can be trusted.
	 * Under certain circumstances the received message cannot be properly 
	 * time stamped, so the sender-receiver synchronization cannot be finished
	 * on the receiver side. In this case, this command returns FALSE.
	 * This command MUST BE called only on the receiver side and only for 
	 * messages transmitted via the TimeSyncSend interface.
	 */
	async command bool hasValidTime(message_t* msg);

	/**
	 * This command should be called by the receiver of a message. The time 
	 * of the synchronization event is returned as expressed in the local
	 * clock of the caller. This command MUST BE called only on the receiver
	 * side and only for messages transmitted via the TimeSyncSend interface.
	 */
	async command uint32_t getEventTime(message_t* msg);
}

--- NEW FILE: TimeSyncSend.nc ---
/*
 * Copyright (c) 2007, Vanderbilt University
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE VANDERBILT UNIVERSITY BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE VANDERBILT
 * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE VANDERBILT UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 */

/**
  * @author Philip Levis
  * @author Miklos Maroti
  *
  * @see TimeSyncPacket
  */ 

#include <TinyError.h>
#include <message.h>
#include <AM.h>

interface TimeSyncSend<precision_tag>
{
	/**
	* This command sends a regular message just like <tt>AMSend.send</tt>, but 
	* it also performs sender-receiver time synchronization. The <tt>event_time</tt>
	* parameter holds the time of some event as expressed in the local clock of 
	* the sender. The receiver can obtain the time of this event (expressed in its
	* own local time) via the <tt>TimeSyncPacket</tt> interface.
	*
	* @param addr   address to which to send the packet
	* @param msg    the packet
	* @param len    the length of the data in the packet payload
	* @param time	the synchronization point to be transfered with the message
	* @return       SUCCESS if the request to send succeeded and a
	*               sendDone will be signaled later, EBUSY if the
	*               abstraction cannot send now but will be able to
	*               later, or FAIL if the communication layer is not
	*               in a state that can send (e.g., off).
    * @see          sendDone
	*/ 
	command error_t send(uint32_t event_time, am_addr_t addr, message_t* msg, uint8_t len);

	/**
	* Cancel a requested transmission. Returns SUCCESS if the 
	* transmission was canceled properly (not sent in its
	* entirety). Note that the component may not know
	* if the send was successfully canceled, if the radio is
	* handling much of the logic; in this case, a component
	* should be conservative and return an appropriate error code.
	* A successful call to cancel must always result in a 
	* sendFailed event, and never a sendSucceeded event.
	* 
	* @param  msg     the packet whose transmission should be cancelled.
	* @return SUCCESS if the transmission was cancelled, FAIL otherwise.
	* @see    sendDone
	*/
	command error_t cancel(message_t* msg);

	/** 
	* Signaled in response to an accepted send request. <tt>msg</tt> is
	* the message buffer sent, and <tt>error</tt> indicates whether
	* the send was successful.
	*
	* @param  msg   the packet which was submitted as a send request
	* @param  error SUCCESS if it was sent successfully, FAIL if it was not,
	*               ECANCEL if it was cancelled
	* @see send
	* @see cancel
	*/ 
	event void sendDone(message_t* msg, error_t error);

	/**
	* Return the maximum payload length that this communication layer
	* can provide. This command behaves identically to
	* <tt>Packet.maxPayloadLength</tt> and is included in this
	* interface as a convenience.
	*
	* @return the maximum payload length
	*/
	command uint8_t maxPayloadLength();

	/**
	* Return a pointer to a protocol's payload region in a packet.
	* This command behaves identically to <tt>Packet.getPayload</tt>
	* (minus the length parameter) and is included in this interface
	* as a convenience.
	*
	* @param  msg    the packet
	* @return        the payload of the packet
	*/
	command void* getPayload(message_t* msg, uint8_t len);
}

Index: DefaultMacC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230/DefaultMacC.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DefaultMacC.nc	20 Feb 2008 01:01:48 -0000	1.2
--- DefaultMacC.nc	12 Mar 2008 19:42:56 -0000	1.3
***************
*** 40,44 ****
  		interface PacketField<uint8_t> as PacketLinkQuality;
  		interface PacketTimeStamp<TRF230, uint16_t>;
- 		interface PacketTimeSynch<TRF230, uint16_t>;
  	}
  }
--- 40,43 ----
***************
*** 61,65 ****
  	PacketLinkQuality = DefaultPacketC.PacketLinkQuality;
  	PacketTimeStamp = DefaultPacketC.PacketTimeStamp;
- 	PacketTimeSynch = DefaultPacketC.PacketTimeSynch;
  
  	components ActiveMessageLayerC;
--- 60,63 ----
***************
*** 113,117 ****
  	RF230LayerC.PacketLinkQuality -> DefaultPacketC.PacketLinkQuality;
  	RF230LayerC.PacketTransmitPower -> DefaultPacketC.PacketTransmitPower;
! 	RF230LayerC.PacketTimeStamping -> DefaultPacketC.PacketTimeStamping;
! 	RF230LayerC.PacketTimeSynchron -> DefaultPacketC.PacketTimeSynchron;
  }
--- 111,114 ----
  	RF230LayerC.PacketLinkQuality -> DefaultPacketC.PacketLinkQuality;
  	RF230LayerC.PacketTransmitPower -> DefaultPacketC.PacketTransmitPower;
! 	RF230LayerC.PacketTimeStamp -> DefaultPacketC.PacketTimeStamp;
  }

Index: DefaultPacket.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230/DefaultPacket.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DefaultPacket.h	20 Feb 2008 01:01:48 -0000	1.1
--- DefaultPacket.h	12 Mar 2008 19:42:56 -0000	1.2
***************
*** 44,57 ****
  };
  
- typedef nx_struct defpacket_footer_t
- {
- 	nx_uint16_t timeoffset;
- } defpacket_footer_t;
- 
- enum defpacket_footer_enum
- {
- 	// just to signal missing time offsets
- 	DEFPACKET_INVALID_TIMEOFFSET = 0x7317,
- };
- 
  #endif//__DEFAULTPACKET_H__
--- 44,46 ----

Index: DefaultPacketC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230/DefaultPacketC.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DefaultPacketC.nc	20 Feb 2008 01:01:48 -0000	1.1
--- DefaultPacketC.nc	12 Mar 2008 19:42:56 -0000	1.2
***************
*** 33,41 ****
  		interface PacketField<uint8_t> as PacketLinkQuality;
  		interface PacketField<uint8_t> as PacketTransmitPower;
- 		interface PacketField<uint16_t> as PacketTimeStamping;
- 		interface PacketField<uint16_t> as PacketTimeSynchron;
  
  		interface PacketTimeStamp<TRF230, uint16_t>;
- 		interface PacketTimeSynch<TRF230, uint16_t>;
  	}
  }
--- 33,38 ----
***************
*** 52,59 ****
  	PacketLinkQuality = DefaultPacketP.PacketLinkQuality;
  	PacketTransmitPower = DefaultPacketP.PacketTransmitPower;
- 	PacketTimeStamping = DefaultPacketP.PacketTimeStamping;
- 	PacketTimeSynchron = DefaultPacketP.PacketTimeSynchron;
- 
  	PacketTimeStamp = DefaultPacketP.PacketTimeStamp;
- 	PacketTimeSynch = DefaultPacketP.PacketTimeSynch;
  }
--- 49,52 ----

Index: DefaultPacketP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230/DefaultPacketP.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DefaultPacketP.nc	20 Feb 2008 01:01:48 -0000	1.1
--- DefaultPacketP.nc	12 Mar 2008 19:42:56 -0000	1.2
***************
*** 32,40 ****
  		interface PacketField<uint8_t> as PacketLinkQuality;
  		interface PacketField<uint8_t> as PacketTransmitPower;
- 		interface PacketField<uint16_t> as PacketTimeStamping;
- 		interface PacketField<uint16_t> as PacketTimeSynchron;
  
  		interface PacketTimeStamp<TRF230, uint16_t>;
- 		interface PacketTimeSynch<TRF230, uint16_t>;
  	}
  
--- 32,37 ----
***************
*** 47,71 ****
  implementation
  {
! /*----------------- Async Packet -----------------*/
! 
! #define PACKET_OVERHEAD ((sizeof(ieee154_header_t) - 1) + sizeof(defpacket_footer_t) + sizeof(ieee154_footer_t))
! 
! 	// async Packet.payloadLength
! 	inline uint8_t getPayloadLength(message_t* msg)
! 	{
! 		//	sizeof(ieee154_header_t) - 1 : the ieee154 header minus the length field
! 		//	sizeof(defpacket_footer_t) : footer containing the embedded time offset
! 		//	sizeof(ieee154_footer_t) : the size of the CRC (not transmitted)
! 
! 		return call IEEE154Packet.getLength(msg) - PACKET_OVERHEAD;
! 	}
! 
! 	// async Pakcet.maxPayloadLength
! 	inline uint8_t getMaxPayloadLength()
  	{
! 		return TOSH_DATA_LENGTH;
! 	}
! 
! /*----------------- Accessors -----------------*/
  
  	inline defpacket_metadata_t* getMeta(message_t* msg)
--- 44,53 ----
  implementation
  {
! 	enum
  	{
! 		PACKET_LENGTH_INCREASE = 
! 			sizeof(defpacket_header_t) - 1	// the 8-bit length field is not counted
! 			+ sizeof(ieee154_footer_t),		// the CRC is not stored in memory
! 	};
  
  	inline defpacket_metadata_t* getMeta(message_t* msg)
***************
*** 74,82 ****
  	}
  
- 	inline defpacket_footer_t* getFooter(message_t* msg)
- 	{
- 		return (defpacket_footer_t*)(msg->data + getPayloadLength(msg));
- 	}
- 
  /*----------------- Packet -----------------*/
  
--- 56,59 ----
***************
*** 91,110 ****
  		getMeta(msg)->flags = DEFPACKET_CLEAR_METADATA;
  	}
!   
  	inline command void Packet.setPayloadLength(message_t* msg, uint8_t len) 
  	{
! 		call IEEE154Packet.setLength(msg, len + PACKET_OVERHEAD);
  	}
!   
  	inline command uint8_t Packet.payloadLength(message_t* msg) 
  	{
! 		return getPayloadLength(msg);
  	}
!   
  	inline command uint8_t Packet.maxPayloadLength()
  	{
! 		return getMaxPayloadLength();
  	}
!   
  	command void* Packet.getPayload(message_t* msg, uint8_t len)
  	{
--- 68,89 ----
  		getMeta(msg)->flags = DEFPACKET_CLEAR_METADATA;
  	}
! 
  	inline command void Packet.setPayloadLength(message_t* msg, uint8_t len) 
  	{
! 		call IEEE154Packet.setLength(msg, len + PACKET_LENGTH_INCREASE);
  	}
! 
! 	// TODO: make Packet.payloadLength async
  	inline command uint8_t Packet.payloadLength(message_t* msg) 
  	{
! 		return call IEEE154Packet.getLength(msg) - PACKET_LENGTH_INCREASE;
  	}
! 
! 	// TODO: make Packet.maxPayloadLength async
  	inline command uint8_t Packet.maxPayloadLength()
  	{
! 		return TOSH_DATA_LENGTH;
  	}
! 
  	command void* Packet.getPayload(message_t* msg, uint8_t len)
  	{
***************
*** 159,178 ****
  /*----------------- PacketTimeStamp -----------------*/
  
! 	async command bool PacketTimeStamping.isSet(message_t* msg)
  	{
  		return getMeta(msg)->flags & DEFPACKET_TIMESTAMP;
  	}
  
! 	async command uint16_t PacketTimeStamping.get(message_t* msg)
  	{
  		return getMeta(msg)->timestamp;
  	}
  
! 	async command void PacketTimeStamping.clear(message_t* msg)
  	{
  		getMeta(msg)->flags &= ~DEFPACKET_TIMESTAMP;
  	}
  
! 	async command void PacketTimeStamping.set(message_t* msg, uint16_t value)
  	{
  		getMeta(msg)->flags |= DEFPACKET_TIMESTAMP;
--- 138,157 ----
  /*----------------- PacketTimeStamp -----------------*/
  
! 	async command bool PacketTimeStamp.isSet(message_t* msg)
  	{
  		return getMeta(msg)->flags & DEFPACKET_TIMESTAMP;
  	}
  
! 	async command uint16_t PacketTimeStamp.get(message_t* msg)
  	{
  		return getMeta(msg)->timestamp;
  	}
  
! 	async command void PacketTimeStamp.clear(message_t* msg)
  	{
  		getMeta(msg)->flags &= ~DEFPACKET_TIMESTAMP;
  	}
  
! 	async command void PacketTimeStamp.set(message_t* msg, uint16_t value)
  	{
  		getMeta(msg)->flags |= DEFPACKET_TIMESTAMP;
***************
*** 180,257 ****
  	}
  
- 	inline async command bool PacketTimeStamp.isSet(message_t* msg)
- 	{
- 		return call PacketTimeStamping.isSet(msg);
- 	}
- 
- 	inline async command uint16_t PacketTimeStamp.get(message_t* msg)
- 	{
- 		return call PacketTimeStamping.get(msg);
- 	}
- 
- 	inline async command void PacketTimeStamp.clear(message_t* msg)
- 	{
- 		call PacketTimeStamping.clear(msg);
- 	}
- 
- 	inline async command void PacketTimeStamp.set(message_t* msg, uint16_t value)
- 	{
- 		call PacketTimeStamping.set(msg, value);
- 	}
- 
- /*----------------- PacketTimeSynch -----------------*/
- 
- 	async command bool PacketTimeSynchron.isSet(message_t* msg)
- 	{
- 		// just sanity check if the length is not initialized
- 		if( getPayloadLength(msg) > getMaxPayloadLength() )
- 			return FALSE;
- 
- 		return getFooter(msg)->timeoffset != DEFPACKET_INVALID_TIMEOFFSET;
- 	}
- 
- 	async command uint16_t PacketTimeSynchron.get(message_t* msg)
- 	{
- 		return getFooter(msg)->timeoffset;
- 	}
- 
- 	async command void PacketTimeSynchron.clear(message_t* msg)
- 	{
- 		// just sanity check if the length is not initialized
- 		if( getPayloadLength(msg) <= getMaxPayloadLength() )
- 			getFooter(msg)->timeoffset = DEFPACKET_INVALID_TIMEOFFSET;
- 	}
- 
- 	async command void PacketTimeSynchron.set(message_t* msg, uint16_t value)
- 	{
- 		if( getPayloadLength(msg) > getMaxPayloadLength() )
- 			return;
- 
- 		if( value == DEFPACKET_INVALID_TIMEOFFSET )
- 			++value;
- 
- 		getFooter(msg)->timeoffset = value;
- 	}
- 
- 	inline async command bool PacketTimeSynch.isSet(message_t* msg)
- 	{
- 		return call PacketTimeSynchron.isSet(msg);
- 	}
- 
- 	inline async command uint16_t PacketTimeSynch.get(message_t* msg)
- 	{
- 		return call PacketTimeSynchron.get(msg);
- 	}
- 
- 	inline async command void PacketTimeSynch.clear(message_t* msg)
- 	{
- 		call PacketTimeSynchron.clear(msg);
- 	}
- 
- 	inline async command void PacketTimeSynch.set(message_t* msg, uint16_t value)
- 	{
- 		call PacketTimeSynchron.set(msg, value);
- 	}
- 
  /*----------------- Global fields -----------------*/
  
--- 159,162 ----

Index: RF230LayerC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230/RF230LayerC.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** RF230LayerC.nc	20 Feb 2008 01:01:48 -0000	1.2
--- RF230LayerC.nc	12 Mar 2008 19:42:56 -0000	1.3
***************
*** 37,42 ****
  		interface PacketField<uint8_t> as PacketLinkQuality;
  		interface PacketField<uint8_t> as PacketTransmitPower;
! 		interface PacketField<uint16_t> as PacketTimeStamping;
! 		interface PacketField<uint16_t> as PacketTimeSynchron;
  	}
  }
--- 37,41 ----
  		interface PacketField<uint8_t> as PacketLinkQuality;
  		interface PacketField<uint8_t> as PacketTransmitPower;
! 		interface PacketTimeStamp<TRF230, uint16_t>;
  	}
  }
***************
*** 54,59 ****
  	PacketLinkQuality = RF230LayerP.PacketLinkQuality;
  	PacketTransmitPower = RF230LayerP.PacketTransmitPower;
! 	PacketTimeStamping = RF230LayerP.PacketTimeStamping;
! 	PacketTimeSynchron = RF230LayerP.PacketTimeSynchron;
  
  	RF230LayerP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
--- 53,57 ----
  	PacketLinkQuality = RF230LayerP.PacketLinkQuality;
  	PacketTransmitPower = RF230LayerP.PacketTransmitPower;
! 	PacketTimeStamp = RF230LayerP.PacketTimeStamp;
  
  	RF230LayerP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];

Index: RF230LayerP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230/RF230LayerP.nc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** RF230LayerP.nc	20 Feb 2008 01:01:48 -0000	1.3
--- RF230LayerP.nc	12 Mar 2008 19:42:56 -0000	1.4
***************
*** 57,63 ****
  		interface RF230Config;
  		interface PacketField<uint8_t> as PacketLinkQuality;
- 		interface PacketField<uint16_t> as PacketTimeStamping;
- 		interface PacketField<uint16_t> as PacketTimeSynchron;
  		interface PacketField<uint8_t> as PacketTransmitPower;
  		interface Tasklet;
  		interface RadioAlarm;
--- 57,62 ----
  		interface RF230Config;
  		interface PacketField<uint8_t> as PacketLinkQuality;
  		interface PacketField<uint8_t> as PacketTransmitPower;
+ 		interface PacketTimeStamp<TRF230, uint16_t>;
  		interface Tasklet;
  		interface RadioAlarm;
***************
*** 432,439 ****
  		length -= 2;
  
- 		// calculate and embed the time offset
- 		if( call PacketTimeSynchron.isSet(msg) )
- 			call PacketTimeSynchron.set(msg, call PacketTimeSynchron.get(msg) - time);
- 
  		do {
  			call HplRF230.spiSplitReadWrite(*(data++));
--- 431,434 ----
***************
*** 477,485 ****
  		}
  
! 		// TODO: be nicer for retransmissions
! 		// clear the embedded time stamp field
! 		call PacketTimeSynchron.clear(msg);
! 
! 		call PacketTimeStamping.set(msg, time);
  
  		// wait for the TRX_END interrupt
--- 472,476 ----
  		}
  
! 		call PacketTimeStamp.set(msg, time);
  
  		// wait for the TRX_END interrupt
***************
*** 570,577 ****
  		cmd = CMD_NONE;
  
- 		// we need a correct time stamp of the message
- 		if( call PacketTimeSynchron.isSet(rxMsg) && call PacketTimeStamping.isSet(rxMsg) )
- 			call PacketTimeSynchron.set(rxMsg, call PacketTimeSynchron.get(rxMsg) + call PacketTimeStamping.get(rxMsg));
- 
  		// signal only if it has passed the CRC check
  		if( crc == 0 )
--- 561,564 ----
***************
*** 665,671 ****
  					 */
  					if( irq == RF230_IRQ_RX_START ) // just to be cautious
! 						call PacketTimeStamping.set(rxMsg, time - RX_SFD_DELAY);
  					else
! 						call PacketTimeStamping.clear(rxMsg);
  
  					cmd = CMD_RECEIVE;
--- 652,658 ----
  					 */
  					if( irq == RF230_IRQ_RX_START ) // just to be cautious
! 						call PacketTimeStamp.set(rxMsg, time - RX_SFD_DELAY);
  					else
! 						call PacketTimeStamp.clear(rxMsg);
  
  					cmd = CMD_RECEIVE;

--- DefaultMac.h DELETED ---

--- notes.txt DELETED ---



More information about the Tinyos-2-commits mailing list