[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/rf2xx/rf212 RF212Ieee154MessageC.nc, NONE, 1.1 RF212ActiveMessage.h, 1.2, 1.3 RF212ActiveMessageC.nc, 1.5, 1.6 RF212ActiveMessageP.nc, 1.5, 1.6 RF212DriverConfig.nc, 1.2, 1.3 RF212DriverLayer.h, 1.1, 1.2 RF212DriverLayerC.nc, 1.2, 1.3 RF212DriverLayerP.nc, 1.3, 1.4

Miklos Maroti mmaroti at users.sourceforge.net
Mon Apr 6 19:27:46 PDT 2009


Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf212
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10384/rf212

Modified Files:
	RF212ActiveMessage.h RF212ActiveMessageC.nc 
	RF212ActiveMessageP.nc RF212DriverConfig.nc RF212DriverLayer.h 
	RF212DriverLayerC.nc RF212DriverLayerP.nc 
Added Files:
	RF212Ieee154MessageC.nc 
Log Message:
reorganized packet header handling, added RF212Ieee154MessageC for BLIP

--- NEW FILE: RF212Ieee154MessageC.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 <RadioConfig.h>

configuration RF212Ieee154MessageC
{
	provides 
	{
		interface SplitControl;

		interface Ieee154Send;
		interface Receive as Ieee154Receive;
		interface Ieee154Packet;
		interface Packet;
		interface PacketAcknowledgements;
		interface LowPowerListening;
		interface PacketLink;

		interface RadioChannel;

		interface PacketField<uint8_t> as PacketLinkQuality;
		interface PacketField<uint8_t> as PacketTransmitPower;
		interface PacketField<uint8_t> as PacketRSSI;

		interface LocalTime<TRadio> as LocalTimeRadio;
		interface PacketTimeStamp<TRadio, uint32_t> as PacketTimeStampRadio;
		interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
	}
}

implementation
{
	components RF212ActiveMessageP, RadioAlarmC;

#ifdef RADIO_DEBUG
	components AssertC;
#endif

	RF212ActiveMessageP.IEEE154MessageLayer -> IEEE154MessageLayerC;
	RF212ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
	RF212ActiveMessageP.PacketTimeStamp -> TimeStampingLayerC;
	RF212ActiveMessageP.RF212Packet -> RF212DriverLayerC;

// -------- IEEE154 Message

	components IEEE154MessageLayerC;
	IEEE154MessageLayerC.SubPacket -> LowPowerListeningLayerC;
	IEEE154MessageLayerC.SubSend -> UniqueLayerC;
	Ieee154Send = IEEE154MessageLayerC;
	Packet = IEEE154MessageLayerC;
	Ieee154Receive = LowPowerListeningLayerC;
	Ieee154Packet = IEEE154MessageLayerC;

// -------- UniqueLayer Send part (wired twice)

	components UniqueLayerC;
	UniqueLayerC.Config -> RF212ActiveMessageP;
	UniqueLayerC.SubSend -> LowPowerListeningLayerC;

// -------- Low Power Listening 

#ifdef LOW_POWER_LISTENING
	components LowPowerListeningLayerC;
	LowPowerListeningLayerC.Config -> RF212ActiveMessageP;
	LowPowerListeningLayerC.PacketAcknowledgements -> SoftwareAckLayerC;
#else	
	components LowPowerListeningDummyC as LowPowerListeningLayerC;
#endif
	LowPowerListeningLayerC.SubControl -> MessageBufferLayerC;
	LowPowerListeningLayerC.SubSend -> PacketLinkLayerC;
	LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC;
	LowPowerListeningLayerC.SubPacket -> PacketLinkLayerC;
	SplitControl = LowPowerListeningLayerC;
	LowPowerListening = LowPowerListeningLayerC;

// -------- Packet Link

	components PacketLinkLayerC;
	PacketLink = PacketLinkLayerC;
	PacketLinkLayerC.PacketAcknowledgements -> SoftwareAckLayerC;
	PacketLinkLayerC.SubSend -> MessageBufferLayerC;
	PacketLinkLayerC.SubPacket -> TimeStampingLayerC;

// -------- MessageBuffer

	components MessageBufferLayerC;
	MessageBufferLayerC.Packet -> IEEE154MessageLayerC;	// to get the payload for the Ieee154Receive.receive
	MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC;
	MessageBufferLayerC.RadioReceive -> UniqueLayerC;
	MessageBufferLayerC.RadioState -> TrafficMonitorLayerC;
	RadioChannel = MessageBufferLayerC;

// -------- UniqueLayer receive part (wired twice)

	UniqueLayerC.SubReceive -> TrafficMonitorLayerC;

// -------- Traffic Monitor

	components TrafficMonitorLayerC;
	TrafficMonitorLayerC.Config -> RF212ActiveMessageP;
	TrafficMonitorLayerC.SubSend -> CollisionAvoidanceLayerC;
	TrafficMonitorLayerC.SubReceive -> CollisionAvoidanceLayerC;
	TrafficMonitorLayerC.SubState -> RF212DriverLayerC;

// -------- CollisionAvoidance

#ifdef SLOTTED_MAC
	components SlottedCollisionLayerC as CollisionAvoidanceLayerC;
#else
	components RandomCollisionLayerC as CollisionAvoidanceLayerC;
#endif
	CollisionAvoidanceLayerC.Config -> RF212ActiveMessageP;
	CollisionAvoidanceLayerC.SubSend -> SoftwareAckLayerC;
	CollisionAvoidanceLayerC.SubReceive -> SoftwareAckLayerC;

// -------- SoftwareAcknowledgement

	components SoftwareAckLayerC;
	SoftwareAckLayerC.Config -> RF212ActiveMessageP;
	SoftwareAckLayerC.SubSend -> CsmaLayerC;
	SoftwareAckLayerC.SubReceive -> RF212DriverLayerC;
	PacketAcknowledgements = SoftwareAckLayerC;

// -------- Carrier Sense

	components new DummyLayerC() as CsmaLayerC;
	CsmaLayerC.Config -> RF212ActiveMessageP;
	CsmaLayerC -> RF212DriverLayerC.RadioSend;
	CsmaLayerC -> RF212DriverLayerC.RadioCCA;

// -------- TimeStamping

	components TimeStampingLayerC;
	TimeStampingLayerC.LocalTimeRadio -> RF212DriverLayerC;
	TimeStampingLayerC.SubPacket -> MetadataFlagsLayerC;
	PacketTimeStampRadio = TimeStampingLayerC;
	PacketTimeStampMilli = TimeStampingLayerC;

// -------- MetadataFlags

	components MetadataFlagsLayerC;
	MetadataFlagsLayerC.SubPacket -> RF212DriverLayerC;

// -------- RF212 Driver

	components RF212DriverLayerC;
	RF212DriverLayerC.Config -> RF212ActiveMessageP;
	RF212DriverLayerC.PacketTimeStamp -> TimeStampingLayerC;
	PacketTransmitPower = RF212DriverLayerC.PacketTransmitPower;
	PacketLinkQuality = RF212DriverLayerC.PacketLinkQuality;
	PacketRSSI = RF212DriverLayerC.PacketRSSI;
	LocalTimeRadio = RF212DriverLayerC;
}

Index: RF212ActiveMessage.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf212/RF212ActiveMessage.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** RF212ActiveMessage.h	4 Apr 2009 00:43:55 -0000	1.2
--- RF212ActiveMessage.h	7 Apr 2009 02:27:44 -0000	1.3
***************
*** 36,39 ****
--- 36,40 ----
  typedef nx_struct rf212packet_header_t
  {
+ 	rf212_header_t rf212;
  	ieee154_header_t ieee154;
  #ifndef TFRAMES_ENABLED
***************
*** 50,56 ****
  typedef struct rf212packet_metadata_t
  {
- 	flags_metadata_t flags;
- 	rf212_metadata_t rf212;
- 	timestamp_metadata_t timestamp;
  #ifdef LOW_POWER_LISTENING
  	lpl_metadata_t lpl;
--- 51,54 ----
***************
*** 59,62 ****
--- 57,63 ----
  	link_metadata_t link;
  #endif
+ 	timestamp_metadata_t timestamp;
+ 	flags_metadata_t flags;
+ 	rf212_metadata_t rf212;
  } rf212packet_metadata_t;
  

Index: RF212ActiveMessageC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf212/RF212ActiveMessageC.nc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** RF212ActiveMessageC.nc	4 Apr 2009 00:43:55 -0000	1.5
--- RF212ActiveMessageC.nc	7 Apr 2009 02:27:44 -0000	1.6
***************
*** 66,70 ****
  	RF212ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
  	RF212ActiveMessageP.PacketTimeStamp -> TimeStampingLayerC;
! 	Packet = RF212ActiveMessageP;
  
  // -------- Active Message
--- 66,71 ----
  	RF212ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
  	RF212ActiveMessageP.PacketTimeStamp -> TimeStampingLayerC;
! 	RF212ActiveMessageP.ActiveMessagePacket -> ActiveMessageLayerC;
! 	RF212ActiveMessageP.RF212Packet -> RF212DriverLayerC;
  
  // -------- Active Message
***************
*** 74,78 ****
--- 75,81 ----
  	ActiveMessageLayerC.SubSend -> LowpanNetworkLayerC;
  	ActiveMessageLayerC.SubReceive -> LowpanNetworkLayerC;
+ 	ActiveMessageLayerC.SubPacket ->LowpanNetworkLayerC;
  	AMSend = ActiveMessageLayerC;
+ 	Packet = ActiveMessageLayerC;
  	Receive = ActiveMessageLayerC.Receive;
  	Snoop = ActiveMessageLayerC.Snoop;
***************
*** 85,97 ****
  #else
  	components LowpanNetworkLayerC;
- 	LowpanNetworkLayerC.Config -> RF212ActiveMessageP;
  #endif
  	LowpanNetworkLayerC.SubSend -> UniqueLayerC;
  	LowpanNetworkLayerC.SubReceive -> LowPowerListeningLayerC;
  
! // -------- IEEE154 Packet
  
  	components IEEE154MessageLayerC;
! 	IEEE154MessageLayerC.Config -> RF212ActiveMessageP;
  
  // -------- UniqueLayer Send part (wired twice)
--- 88,100 ----
  #else
  	components LowpanNetworkLayerC;
  #endif
  	LowpanNetworkLayerC.SubSend -> UniqueLayerC;
  	LowpanNetworkLayerC.SubReceive -> LowPowerListeningLayerC;
+ 	LowpanNetworkLayerC.SubPacket -> IEEE154MessageLayerC;
  
! // -------- IEEE154 Message
  
  	components IEEE154MessageLayerC;
! 	IEEE154MessageLayerC.SubPacket -> LowPowerListeningLayerC;
  
  // -------- UniqueLayer Send part (wired twice)
***************
*** 113,116 ****
--- 116,120 ----
  	LowPowerListeningLayerC.SubSend -> PacketLinkLayerC;
  	LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC;
+ 	LowPowerListeningLayerC.SubPacket -> PacketLinkLayerC;
  	SplitControl = LowPowerListeningLayerC;
  	LowPowerListening = LowPowerListeningLayerC;
***************
*** 121,125 ****
  	components PacketLinkLayerC;
  	PacketLink = PacketLinkLayerC;
- 	PacketLinkLayerC.PacketLinkMetadata -> RF212ActiveMessageP;
  	PacketLinkLayerC.PacketAcknowledgements -> SoftwareAckLayerC;
  #else
--- 125,128 ----
***************
*** 127,135 ****
  #endif
  	PacketLinkLayerC.SubSend -> MessageBufferLayerC;
  
  // -------- MessageBuffer
  
  	components MessageBufferLayerC;
! 	MessageBufferLayerC.Packet -> RF212ActiveMessageP;
  	MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC;
  	MessageBufferLayerC.RadioReceive -> UniqueLayerC;
--- 130,139 ----
  #endif
  	PacketLinkLayerC.SubSend -> MessageBufferLayerC;
+ 	PacketLinkLayerC.SubPacket -> TimeStampingLayerC;
  
  // -------- MessageBuffer
  
  	components MessageBufferLayerC;
! 	MessageBufferLayerC.Packet -> ActiveMessageLayerC;
  	MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC;
  	MessageBufferLayerC.RadioReceive -> UniqueLayerC;
***************
*** 175,183 ****
  	CsmaLayerC -> RF212DriverLayerC.RadioCCA;
  
  // -------- RF212 Driver
  
  	components RF212DriverLayerC;
! 	RF212DriverLayerC.PacketRF212Metadata -> RF212ActiveMessageP;
! 	RF212DriverLayerC.RF212DriverConfig -> RF212ActiveMessageP;
  	RF212DriverLayerC.PacketTimeStamp -> TimeStampingLayerC;
  	PacketTransmitPower = RF212DriverLayerC.PacketTransmitPower;
--- 179,199 ----
  	CsmaLayerC -> RF212DriverLayerC.RadioCCA;
  
+ // -------- TimeStamping
+ 
+ 	components TimeStampingLayerC;
+ 	TimeStampingLayerC.LocalTimeRadio -> RF212DriverLayerC;
+ 	TimeStampingLayerC.SubPacket -> MetadataFlagsLayerC;
+ 	PacketTimeStampRadio = TimeStampingLayerC;
+ 	PacketTimeStampMilli = TimeStampingLayerC;
+ 
+ // -------- MetadataFlags
+ 
+ 	components MetadataFlagsLayerC;
+ 	MetadataFlagsLayerC.SubPacket -> RF212DriverLayerC;
+ 
  // -------- RF212 Driver
  
  	components RF212DriverLayerC;
! 	RF212DriverLayerC.Config -> RF212ActiveMessageP;
  	RF212DriverLayerC.PacketTimeStamp -> TimeStampingLayerC;
  	PacketTransmitPower = RF212DriverLayerC.PacketTransmitPower;
***************
*** 185,200 ****
  	PacketRSSI = RF212DriverLayerC.PacketRSSI;
  	LocalTimeRadio = RF212DriverLayerC;
- 
- // -------- MetadataFlags
- 
- 	components MetadataFlagsLayerC;
- 	MetadataFlagsLayerC.PacketFlagsMetadata -> RF212ActiveMessageP;
- 
- // -------- TimeStamping
- 
- 	components TimeStampingLayerC;
- 	TimeStampingLayerC.LocalTimeRadio -> RF212DriverLayerC;
- 	TimeStampingLayerC.PacketTimeStampMetadata -> RF212ActiveMessageP;
- 	PacketTimeStampRadio = TimeStampingLayerC;
- 	PacketTimeStampMilli = TimeStampingLayerC;
  }
--- 201,203 ----

Index: RF212ActiveMessageP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf212/RF212ActiveMessageP.nc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** RF212ActiveMessageP.nc	4 Apr 2009 00:43:55 -0000	1.5
--- RF212ActiveMessageP.nc	7 Apr 2009 02:27:44 -0000	1.6
***************
*** 38,57 ****
  		interface SlottedCollisionConfig;
  		interface ActiveMessageConfig;
- 		interface LowpanNetworkConfig;
- 		interface IEEE154MessageConfig;
  		interface DummyConfig;
  
- 		interface Packet;
- 
- 		interface PacketData<flags_metadata_t> as PacketFlagsMetadata;
- 		interface PacketData<rf212_metadata_t> as PacketRF212Metadata;
- 		interface PacketData<timestamp_metadata_t> as PacketTimeStampMetadata;
- 
  #ifdef LOW_POWER_LISTENING
  		interface LowPowerListeningConfig;
  #endif
- #ifdef PACKET_LINK
- 		interface PacketData<link_metadata_t> as PacketLinkMetadata;
- #endif
  	}
  
--- 38,46 ----
***************
*** 60,63 ****
--- 49,54 ----
  		interface IEEE154MessageLayer;
  		interface RadioAlarm;
+ 		interface RadioPacket as ActiveMessagePacket;
+ 		interface RadioPacket as RF212Packet;
  
  		interface PacketTimeStamp<TRadio, uint32_t>;
***************
*** 67,98 ****
  implementation
  {
- 	rf212packet_header_t* getHeader(message_t* msg)
- 	{
- 		return (rf212packet_header_t*)(msg->data - sizeof(rf212packet_header_t));
- 	}
- 
- 	rf212packet_metadata_t* getMeta(message_t* msg)
- 	{
- 		return (rf212packet_metadata_t*)(msg->metadata);
- 	}
  
  /*----------------- RF212DriverConfig -----------------*/
  
! 	async command uint8_t RF212DriverConfig.getLength(message_t* msg)
  	{
! 		return call IEEE154MessageLayer.getLength(msg);
  	}
  
! 	async command void RF212DriverConfig.setLength(message_t* msg, uint8_t len)
  	{
! 		call IEEE154MessageLayer.setLength(msg, len);
  	}
  
! 	async command uint8_t* RF212DriverConfig.getPayload(message_t* msg)
  	{
! 		return ((uint8_t*)(call IEEE154MessageConfig.getHeader(msg))) + 1;
  	}
  
! 	async command uint8_t RF212DriverConfig.getHeaderLength()
  	{
  		// we need the fcf, dsn, destpan and dest
--- 58,80 ----
  implementation
  {
  
  /*----------------- RF212DriverConfig -----------------*/
  
! 	async command uint8_t RF212DriverConfig.headerLength(message_t* msg)
  	{
! 		return offsetof(message_t, data) - sizeof(rf212packet_header_t);
  	}
  
! 	async command uint8_t RF212DriverConfig.maxPayloadLength()
  	{
! 		return sizeof(rf212packet_header_t) + TOSH_DATA_LENGTH;
  	}
  
! 	async command uint8_t RF212DriverConfig.metadataLength(message_t* msg)
  	{
! 		return 0;
  	}
  
! 	async command uint8_t RF212DriverConfig.headerPreloadLength()
  	{
  		// we need the fcf, dsn, destpan and dest
***************
*** 100,109 ****
  	}
  
- 	async command uint8_t RF212DriverConfig.getMaxLength()
- 	{
- 		// note, that the ieee154_footer_t is not stored, but we should include it here
- 		return sizeof(rf212packet_header_t) - 1 + TOSH_DATA_LENGTH + sizeof(ieee154_footer_t);
- 	}
- 
  	async command bool RF212DriverConfig.requiresRssiCca(message_t* msg)
  	{
--- 82,85 ----
***************
*** 177,192 ****
  /*----------------- ActiveMessageConfig -----------------*/
  
! 	command error_t ActiveMessageConfig.checkPacket(message_t* msg)
! 	{
! 		// the user forgot to call clear, we should return EINVAL
! 		if( ! call IEEE154MessageLayer.isDataFrame(msg) )
! 			call Packet.clear(msg);
! 
! 		return SUCCESS;
! 	}
! 
! 	command activemessage_header_t* ActiveMessageConfig.getHeader(message_t* msg)
  	{
! 		return &(getHeader(msg)->am);
  	}
  
--- 153,159 ----
  /*----------------- ActiveMessageConfig -----------------*/
  
! 	command bool ActiveMessageConfig.forgotToClear(message_t* msg)
  	{
! 		return ! call IEEE154MessageLayer.isDataFrame(msg);
  	}
  
***************
*** 250,254 ****
  		 */
  
! 		uint8_t len = call IEEE154MessageLayer.getLength(msg);
  		return call IEEE154MessageLayer.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10;
  	}
--- 217,221 ----
  		 */
  
! 		uint8_t len = call RF212Packet.payloadLength(msg);
  		return call IEEE154MessageLayer.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10;
  	}
***************
*** 347,373 ****
  	}
  
- /*----------------- LowpanNetwork -----------------*/
- 
- 	command lowpan_header_t* LowpanNetworkConfig.getHeader(message_t* msg)
- 	{
- 		return &(getHeader(msg)->lowpan);
- 	}
- 
- /*----------------- IEEE154Message -----------------*/
- 
- 	async command ieee154_header_t* IEEE154MessageConfig.getHeader(message_t* msg)
- 	{
- 		return &(getHeader(msg)->ieee154);
- 	}
- 
  /*----------------- LowPowerListening -----------------*/
  
  #ifdef LOW_POWER_LISTENING
  
- 	async command lpl_metadata_t* LowPowerListeningConfig.metadata(message_t* msg)
- 	{
- 		return &(getMeta(msg)->lpl);
- 	}
- 
  	async command bool LowPowerListeningConfig.getAckRequired(message_t* msg)
  	{
--- 314,321 ----
***************
*** 377,448 ****
  #endif
  
- /*----------------- Headers and Metadata -----------------*/
- 
- 	async command flags_metadata_t* PacketFlagsMetadata.get(message_t* msg)
- 	{
- 		return &(getMeta(msg)->flags);
- 	}
- 
- 	async command rf212_metadata_t* PacketRF212Metadata.get(message_t* msg)
- 	{
- 		return &(getMeta(msg)->rf212);
- 	}
- 
- 	async command timestamp_metadata_t* PacketTimeStampMetadata.get(message_t* msg)
- 	{
- 		return &(getMeta(msg)->timestamp);
- 	}
- 
- #ifdef PACKET_LINK
- 	async command link_metadata_t* PacketLinkMetadata.get(message_t* msg)
- 	{
- 		return &(getMeta(msg)->link);
- 	}
- #endif
- 
- /*----------------- Packet -----------------*/
- 
- 	enum
- 	{
- 		PACKET_LENGTH_INCREASE =
- 			sizeof(rf212packet_header_t) - 1	// the 8-bit length field is not counted
- 			+ sizeof(ieee154_footer_t),		// the CRC is not stored in memory
- 	};
- 
- 	command void Packet.clear(message_t* msg)
- 	{
- 		signal PacketFlagsMetadata.clear(msg);
- 		signal PacketRF212Metadata.clear(msg);
- 		signal PacketTimeStampMetadata.clear(msg);
- #ifdef LOW_POWER_LISTENING
- 		signal LowPowerListeningConfig.clear(msg);
- #endif
- #ifdef PACKET_LINK
- 		signal PacketLinkMetadata.clear(msg);
- #endif
- 		call IEEE154MessageLayer.createDataFrame(msg);
- 	}
- 
- 	command void Packet.setPayloadLength(message_t* msg, uint8_t len)
- 	{
- 		call IEEE154MessageLayer.setLength(msg, len + PACKET_LENGTH_INCREASE);
- 	}
- 
- 	command uint8_t Packet.payloadLength(message_t* msg)
- 	{
- 		return call IEEE154MessageLayer.getLength(msg) - PACKET_LENGTH_INCREASE;
- 	}
- 
- 	command uint8_t Packet.maxPayloadLength()
- 	{
- 		return TOSH_DATA_LENGTH;
- 	}
- 
- 	command void* Packet.getPayload(message_t* msg, uint8_t len)
- 	{
- 		if( len > TOSH_DATA_LENGTH )
- 			return NULL;
- 
- 		return msg->data;
- 	}
  }
--- 325,327 ----

Index: RF212DriverConfig.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf212/RF212DriverConfig.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** RF212DriverConfig.nc	27 Mar 2009 21:54:56 -0000	1.2
--- RF212DriverConfig.nc	7 Apr 2009 02:27:44 -0000	1.3
***************
*** 22,48 ****
   */
  
- /**
-  * This interface needs to be implemented by the MAC to control the behaviour 
-  * of the RF212DriverLayerC component.
-  */
  interface RF212DriverConfig
  {
  	/**
! 	 * Returns the length of the PHY payload (including the FCF field).
! 	 * This value must be in the range [3, 127].
  	 */
! 	async command uint8_t getLength(message_t* msg);
  
  	/**
! 	 * Sets the length of the PHY payload.
  	 */
! 	async command void setLength(message_t* msg, uint8_t len);
  
  	/**
! 	 * Returns a pointer to the start of the PHY payload that contains 
! 	 * getLength()-2 number of bytes. The FCF field (CRC-16) is not stored,
! 	 * but automatically appended / verified.
  	 */
! 	async command uint8_t* getPayload(message_t* msg);
  
  	/**
--- 22,43 ----
   */
  
  interface RF212DriverConfig
  {
  	/**
! 	 * Returns the length of a dummy header to align the payload properly.
  	 */
! 	async command uint8_t headerLength(message_t* msg);
  
  	/**
! 	 * Returns the maximum length of the PHY payload including the 
! 	 * length field but not counting the FCF field.
  	 */
! 	async command uint8_t maxPayloadLength();
  
  	/**
! 	 * Returns the length of a dummy metadata section to align the
! 	 * metadata section properly.
  	 */
! 	async command uint8_t metadataLength(message_t* msg);
  
  	/**
***************
*** 51,60 ****
  	 * then that event is fired earlier. The header length must be at least one.
  	 */
! 	async command uint8_t getHeaderLength();
! 
! 	/**
! 	 * Returns the maximum PHY length that can be set via the setLength command
! 	 */
! 	async command uint8_t getMaxLength();
  
  	/**
--- 46,50 ----
  	 * then that event is fired earlier. The header length must be at least one.
  	 */
! 	async command uint8_t headerPreloadLength();
  
  	/**

Index: RF212DriverLayer.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf212/RF212DriverLayer.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** RF212DriverLayer.h	2 Apr 2009 22:10:07 -0000	1.1
--- RF212DriverLayer.h	7 Apr 2009 02:27:44 -0000	1.2
***************
*** 25,28 ****
--- 25,33 ----
  #define __RF212DRIVERLAYER_H__
  
+ typedef nx_struct rf212_header_t
+ {
+ 	nxle_uint8_t length;
+ } rf212_header_t;
+ 
  typedef struct rf212_metadata_t
  {

Index: RF212DriverLayerC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf212/RF212DriverLayerC.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** RF212DriverLayerC.nc	2 Apr 2009 22:10:07 -0000	1.2
--- RF212DriverLayerC.nc	7 Apr 2009 02:27:44 -0000	1.3
***************
*** 1,4 ****
  /*
!  * Copyright (c) 2009, Vanderbilt University
   * All rights reserved.
   *
--- 1,4 ----
  /*
!  * Copyright (c) 2007, Vanderbilt University
   * All rights reserved.
   *
***************
*** 33,36 ****
--- 33,37 ----
  		interface RadioReceive;
  		interface RadioCCA;
+ 		interface RadioPacket;
  
  		interface PacketField<uint8_t> as PacketTransmitPower;
***************
*** 44,50 ****
  	uses
  	{
! 		interface RF212DriverConfig;
  		interface PacketTimeStamp<TRadio, uint32_t>;
- 		interface PacketData<rf212_metadata_t> as PacketRF212Metadata;
  	}
  }
--- 45,50 ----
  	uses
  	{
! 		interface RF212DriverConfig as Config;
  		interface PacketTimeStamp<TRadio, uint32_t>;
  	}
  }
***************
*** 58,66 ****
  	RadioReceive = RF212DriverLayerP;
  	RadioCCA = RF212DriverLayerP;
  
  	LocalTimeRadio = HplRF212C;
  
! 	RF212DriverConfig = RF212DriverLayerP;
! 	PacketRF212Metadata = RF212DriverLayerP;
  
  	PacketTransmitPower = RF212DriverLayerP.PacketTransmitPower;
--- 58,66 ----
  	RadioReceive = RF212DriverLayerP;
  	RadioCCA = RF212DriverLayerP;
+ 	RadioPacket = RF212DriverLayerP;
  
  	LocalTimeRadio = HplRF212C;
  
! 	Config = RF212DriverLayerP;
  
  	PacketTransmitPower = RF212DriverLayerP.PacketTransmitPower;

Index: RF212DriverLayerP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf212/RF212DriverLayerP.nc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** RF212DriverLayerP.nc	2 Apr 2009 22:10:07 -0000	1.3
--- RF212DriverLayerP.nc	7 Apr 2009 02:27:44 -0000	1.4
***************
*** 39,42 ****
--- 39,43 ----
  		interface RadioReceive;
  		interface RadioCCA;
+ 		interface RadioPacket;
  
  		interface PacketField<uint8_t> as PacketTransmitPower;
***************
*** 61,67 ****
  		interface LocalTime<TRadio>;
  
! 		interface RF212DriverConfig;
  
- 		interface PacketData<rf212_metadata_t> as PacketRF212Metadata;
  		interface PacketFlag as TransmitPowerFlag;
  		interface PacketFlag as RSSIFlag;
--- 62,67 ----
  		interface LocalTime<TRadio>;
  
! 		interface RF212DriverConfig as Config;
  
  		interface PacketFlag as TransmitPowerFlag;
  		interface PacketFlag as RSSIFlag;
***************
*** 81,84 ****
--- 81,99 ----
  implementation
  {
+ 	rf212_header_t* getHeader(message_t* msg)
+ 	{
+ 		return ((void*)msg) + call Config.headerLength(msg);
+ 	}
+ 
+ 	void* getPayload(message_t* msg)
+ 	{
+ 		return ((void*)msg) + call RadioPacket.headerLength(msg);
+ 	}
+ 
+ 	rf212_metadata_t* getMeta(message_t* msg)
+ 	{
+ 		return ((void*)msg) + sizeof(message_t) - call RadioPacket.metadataLength(msg);
+ 	}
+ 
  /*----------------- STATE -----------------*/
  
***************
*** 421,425 ****
  		}
  
! 		if( call RF212DriverConfig.requiresRssiCca(msg) 
  				&& (readRegister(RF212_PHY_RSSI) & RF212_RSSI_MASK) > ((rssiClear + rssiBusy) >> 3) )
  			return EBUSY;
--- 436,440 ----
  		}
  
! 		if( call Config.requiresRssiCca(msg) 
  				&& (readRegister(RF212_PHY_RSSI) & RF212_RSSI_MASK) > ((rssiClear + rssiBusy) >> 3) )
  			return EBUSY;
***************
*** 429,433 ****
  		// do something useful, just to wait a little
  		time32 = call LocalTime.get();
! 		timesync = call PacketTimeSyncOffset.isSet(msg) ? msg->data + call PacketTimeSyncOffset.get(msg) : 0;
  
  		// we have missed an incoming message in this short amount of time
--- 444,448 ----
  		// do something useful, just to wait a little
  		time32 = call LocalTime.get();
! 		timesync = call PacketTimeSyncOffset.isSet(msg) ? ((void*)msg) + call PacketTimeSyncOffset.get(msg) : 0;
  
  		// we have missed an incoming message in this short amount of time
***************
*** 452,457 ****
  		call FastSpiByte.splitWrite(RF212_CMD_FRAME_WRITE);
  
! 		length = call RF212DriverConfig.getLength(msg);
! 		data = call RF212DriverConfig.getPayload(msg);
  
  		// length | data[0] ... data[length-3] | automatically generated FCS
--- 467,472 ----
  		call FastSpiByte.splitWrite(RF212_CMD_FRAME_WRITE);
  
! 		data = getPayload(msg);
! 		length = getHeader(msg)->length;
  
  		// length | data[0] ... data[length-3] | automatically generated FCS
***************
*** 461,465 ****
  		length -= 2;
  
! 		header = call RF212DriverConfig.getHeaderLength();
  		if( header > length )
  			header = length;
--- 476,480 ----
  		length -= 2;
  
! 		header = call Config.headerPreloadLength();
  		if( header > length )
  			header = length;
***************
*** 505,514 ****
  		if( call DiagMsg.record() )
  		{
! 			length = call RF212DriverConfig.getLength(msg);
  
  			call DiagMsg.str("tx");
  			call DiagMsg.uint16(time);
  			call DiagMsg.uint8(length);
! 			call DiagMsg.hex8s(data, length - 2);
  			call DiagMsg.send();
  		}
--- 520,529 ----
  		if( call DiagMsg.record() )
  		{
! 			length = getHeader(msg)->length;
  
  			call DiagMsg.str("tx");
  			call DiagMsg.uint16(time);
  			call DiagMsg.uint8(length);
! 			call DiagMsg.hex8s(getPayload(msg), length - 2);
  			call DiagMsg.send();
  		}
***************
*** 564,568 ****
  
  		// if correct length
! 		if( length >= 3 && length <= call RF212DriverConfig.getMaxLength() )
  		{
  			uint8_t read;
--- 579,583 ----
  
  		// if correct length
! 		if( length >= 3 && length <= call RadioPacket.maxPayloadLength() + 2 )
  		{
  			uint8_t read;
***************
*** 572,577 ****
  			call FastSpiByte.splitWrite(0);
  
! 			call RF212DriverConfig.setLength(rxMsg, length);
! 			data = call RF212DriverConfig.getPayload(rxMsg);
  			crc = 0;
  
--- 587,592 ----
  			call FastSpiByte.splitWrite(0);
  
! 			data = getPayload(rxMsg);
! 			getHeader(rxMsg)->length = length;
  			crc = 0;
  
***************
*** 579,583 ****
  			length -= 2;
  
! 			read = call RF212DriverConfig.getHeaderLength();
  			if( length < read )
  				read = length;
--- 594,598 ----
  			length -= 2;
  
! 			read = call Config.headerPreloadLength();
  			if( length < read )
  				read = length;
***************
*** 610,621 ****
  		if( call DiagMsg.record() )
  		{
! 			length = call RF212DriverConfig.getLength(rxMsg);
  
  			call DiagMsg.str("rx");
  			call DiagMsg.uint32(call PacketTimeStamp.isValid(rxMsg) ? call PacketTimeStamp.timestamp(rxMsg) : 0);
  			call DiagMsg.uint16(call RadioAlarm.getNow());
! 			call DiagMsg.uint8(crc == 0);
  			call DiagMsg.uint8(length);
! 			call DiagMsg.hex8s(call RF212DriverConfig.getPayload(rxMsg), length - 2);
  			call DiagMsg.send();
  		}
--- 625,636 ----
  		if( call DiagMsg.record() )
  		{
! 			length = getHeader(rxMsg)->length;
  
  			call DiagMsg.str("rx");
  			call DiagMsg.uint32(call PacketTimeStamp.isValid(rxMsg) ? call PacketTimeStamp.timestamp(rxMsg) : 0);
  			call DiagMsg.uint16(call RadioAlarm.getNow());
! 			call DiagMsg.uint8(crc != 0);
  			call DiagMsg.uint8(length);
! 			call DiagMsg.hex8s(getPayload(rxMsg), length - 2);
  			call DiagMsg.send();
  		}
***************
*** 824,834 ****
  	}
  
! /*----------------- PACKET -----------------*/
  
! 	async event void PacketRF212Metadata.clear(message_t* msg)
  	{
  	}
  
! // --- TransmitPower
  
  	async command bool PacketTransmitPower.isSet(message_t* msg)
--- 839,881 ----
  	}
  
! /*----------------- RadioPacket -----------------*/
! 	
! 	async command uint8_t RadioPacket.headerLength(message_t* msg)
! 	{
! 		return call Config.headerLength(msg) + sizeof(rf212_header_t);
! 	}
  
! 	async command uint8_t RadioPacket.payloadLength(message_t* msg)
! 	{
! 		return getHeader(msg)->length - 2;
! 	}
! 
! 	async command void RadioPacket.setPayloadLength(message_t* msg, uint8_t length)
  	{
+ 		ASSERT( 1 <= length && length <= 125 );
+ 		ASSERT( call RadioPacket.headerLength(msg) + length + call RadioPacket.metadataLength(msg) <= sizeof(message_t) );
+ 
+ 		// we add the length of the CRC, which is automatically generated
+ 		getHeader(msg)->length = length + 2;
  	}
  
! 	async command uint8_t RadioPacket.maxPayloadLength()
! 	{
! 		ASSERT( call Config.maxPayloadLength() <= 125 );
! 
! 		return call Config.maxPayloadLength() - sizeof(rf212_header_t);
! 	}
! 
! 	async command uint8_t RadioPacket.metadataLength(message_t* msg)
! 	{
! 		return call Config.metadataLength(msg) + sizeof(rf212_metadata_t);
! 	}
! 
! 	async command void RadioPacket.clear(message_t* msg)
! 	{
! 		// all flags are automatically cleared
! 	}
! 
! /*----------------- PacketTransmitPower -----------------*/
  
  	async command bool PacketTransmitPower.isSet(message_t* msg)
***************
*** 839,843 ****
  	async command uint8_t PacketTransmitPower.get(message_t* msg)
  	{
! 		return (call PacketRF212Metadata.get(msg))->power;
  	}
  
--- 886,890 ----
  	async command uint8_t PacketTransmitPower.get(message_t* msg)
  	{
! 		return getMeta(msg)->power;
  	}
  
***************
*** 850,857 ****
  	{
  		call TransmitPowerFlag.set(msg);
! 		(call PacketRF212Metadata.get(msg))->power = value;
  	}
  
! // --- RSSI
  
  	async command bool PacketRSSI.isSet(message_t* msg)
--- 897,904 ----
  	{
  		call TransmitPowerFlag.set(msg);
! 		getMeta(msg)->power = value;
  	}
  
! /*----------------- PacketRSSI -----------------*/
  
  	async command bool PacketRSSI.isSet(message_t* msg)
***************
*** 862,866 ****
  	async command uint8_t PacketRSSI.get(message_t* msg)
  	{
! 		return (call PacketRF212Metadata.get(msg))->rssi;
  	}
  
--- 909,913 ----
  	async command uint8_t PacketRSSI.get(message_t* msg)
  	{
! 		return getMeta(msg)->rssi;
  	}
  
***************
*** 876,890 ****
  
  		call RSSIFlag.set(msg);
! 		(call PacketRF212Metadata.get(msg))->rssi = value;
  	}
  
! // --- TimeSyncOffset
! 
! 	enum
! 	{
! 		PACKET_LENGTH_INCREASE =
! 			sizeof(rf212packet_header_t) - 1	// the 8-bit length field is not counted
! 			+ sizeof(ieee154_footer_t),		// the CRC is not stored in memory
! 	};
  
  	async command bool PacketTimeSyncOffset.isSet(message_t* msg)
--- 923,930 ----
  
  		call RSSIFlag.set(msg);
! 		getMeta(msg)->rssi = value;
  	}
  
! /*----------------- PacketTimeSyncOffset -----------------*/
  
  	async command bool PacketTimeSyncOffset.isSet(message_t* msg)
***************
*** 895,899 ****
  	async command uint8_t PacketTimeSyncOffset.get(message_t* msg)
  	{
! 		return call RF212DriverConfig.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_absolute_t);
  	}
  
--- 935,939 ----
  	async command uint8_t PacketTimeSyncOffset.get(message_t* msg)
  	{
! 		return call RadioPacket.headerLength(msg) + call RadioPacket.payloadLength(msg) - sizeof(timesync_absolute_t);
  	}
  
***************
*** 906,915 ****
  	{
  		// we do not store the value, the time sync field is always the last 4 bytes
! 		ASSERT( call RF212DriverConfig.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_absolute_t) == value );
  
  		call TimeSyncFlag.set(msg);
  	}
  
! // --- LinkQuality
  
  	async command bool PacketLinkQuality.isSet(message_t* msg)
--- 946,955 ----
  	{
  		// we do not store the value, the time sync field is always the last 4 bytes
! 		ASSERT( call PacketTimeSyncOffset.get(msg) == value );
  
  		call TimeSyncFlag.set(msg);
  	}
  
! /*----------------- PacketLinkQuality -----------------*/
  
  	async command bool PacketLinkQuality.isSet(message_t* msg)
***************
*** 920,924 ****
  	async command uint8_t PacketLinkQuality.get(message_t* msg)
  	{
! 		return (call PacketRF212Metadata.get(msg))->lqi;
  	}
  
--- 960,964 ----
  	async command uint8_t PacketLinkQuality.get(message_t* msg)
  	{
! 		return getMeta(msg)->lqi;
  	}
  
***************
*** 929,933 ****
  	async command void PacketLinkQuality.set(message_t* msg, uint8_t value)
  	{
! 		(call PacketRF212Metadata.get(msg))->lqi = value;
  	}
  }
--- 969,973 ----
  	async command void PacketLinkQuality.set(message_t* msg, uint8_t value)
  	{
! 		getMeta(msg)->lqi = value;
  	}
  }



More information about the Tinyos-2-commits mailing list