[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/rf2xx/rf230 RF230ActiveMessage.h, 1.2, 1.3 RF230ActiveMessageC.nc, 1.5, 1.6 RF230ActiveMessageP.nc, 1.6, 1.7 RF230DriverConfig.nc, 1.2, 1.3 RF230DriverLayer.h, 1.1, 1.2 RF230DriverLayerC.nc, 1.2, 1.3 RF230DriverLayerP.nc, 1.5, 1.6

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/rf230
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10384/rf230

Modified Files:
	RF230ActiveMessage.h RF230ActiveMessageC.nc 
	RF230ActiveMessageP.nc RF230DriverConfig.nc RF230DriverLayer.h 
	RF230DriverLayerC.nc RF230DriverLayerP.nc 
Log Message:
reorganized packet header handling, added RF212Ieee154MessageC for BLIP

Index: RF230ActiveMessage.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf230/RF230ActiveMessage.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** RF230ActiveMessage.h	4 Apr 2009 00:43:55 -0000	1.2
--- RF230ActiveMessage.h	7 Apr 2009 02:27:44 -0000	1.3
***************
*** 36,39 ****
--- 36,40 ----
  typedef nx_struct rf230packet_header_t
  {
+ 	rf230_header_t rf230;
  	ieee154_header_t ieee154;
  #ifndef TFRAMES_ENABLED
***************
*** 50,56 ****
  typedef struct rf230packet_metadata_t
  {
- 	flags_metadata_t flags;
- 	rf230_metadata_t rf230;
- 	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;
+ 	rf230_metadata_t rf230;
  } rf230packet_metadata_t;
  

Index: RF230ActiveMessageC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** RF230ActiveMessageC.nc	4 Apr 2009 00:43:55 -0000	1.5
--- RF230ActiveMessageC.nc	7 Apr 2009 02:27:44 -0000	1.6
***************
*** 66,70 ****
  	RF230ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
  	RF230ActiveMessageP.PacketTimeStamp -> TimeStampingLayerC;
! 	Packet = RF230ActiveMessageP;
  
  // -------- Active Message
--- 66,71 ----
  	RF230ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
  	RF230ActiveMessageP.PacketTimeStamp -> TimeStampingLayerC;
! 	RF230ActiveMessageP.ActiveMessagePacket -> ActiveMessageLayerC;
! 	RF230ActiveMessageP.RF230Packet -> RF230DriverLayerC;
  
  // -------- 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 -> RF230ActiveMessageP;
  #endif
  	LowpanNetworkLayerC.SubSend -> UniqueLayerC;
  	LowpanNetworkLayerC.SubReceive -> LowPowerListeningLayerC;
  
! // -------- IEEE154 Packet
  
  	components IEEE154MessageLayerC;
! 	IEEE154MessageLayerC.Config -> RF230ActiveMessageP;
  
  // -------- 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 -> RF230ActiveMessageP;
  	PacketLinkLayerC.PacketAcknowledgements -> SoftwareAckLayerC;
  #else
--- 125,128 ----
***************
*** 127,135 ****
  #endif
  	PacketLinkLayerC.SubSend -> MessageBufferLayerC;
  
  // -------- MessageBuffer
  
  	components MessageBufferLayerC;
! 	MessageBufferLayerC.Packet -> RF230ActiveMessageP;
  	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 -> RF230DriverLayerC.RadioCCA;
  
  // -------- RF230 Driver
  
  	components RF230DriverLayerC;
! 	RF230DriverLayerC.PacketRF230Metadata -> RF230ActiveMessageP;
! 	RF230DriverLayerC.RF230DriverConfig -> RF230ActiveMessageP;
  	RF230DriverLayerC.PacketTimeStamp -> TimeStampingLayerC;
  	PacketTransmitPower = RF230DriverLayerC.PacketTransmitPower;
--- 179,199 ----
  	CsmaLayerC -> RF230DriverLayerC.RadioCCA;
  
+ // -------- TimeStamping
+ 
+ 	components TimeStampingLayerC;
+ 	TimeStampingLayerC.LocalTimeRadio -> RF230DriverLayerC;
+ 	TimeStampingLayerC.SubPacket -> MetadataFlagsLayerC;
+ 	PacketTimeStampRadio = TimeStampingLayerC;
+ 	PacketTimeStampMilli = TimeStampingLayerC;
+ 
+ // -------- MetadataFlags
+ 
+ 	components MetadataFlagsLayerC;
+ 	MetadataFlagsLayerC.SubPacket -> RF230DriverLayerC;
+ 
  // -------- RF230 Driver
  
  	components RF230DriverLayerC;
! 	RF230DriverLayerC.Config -> RF230ActiveMessageP;
  	RF230DriverLayerC.PacketTimeStamp -> TimeStampingLayerC;
  	PacketTransmitPower = RF230DriverLayerC.PacketTransmitPower;
***************
*** 185,200 ****
  	PacketRSSI = RF230DriverLayerC.PacketRSSI;
  	LocalTimeRadio = RF230DriverLayerC;
- 
- // -------- MetadataFlags
- 
- 	components MetadataFlagsLayerC;
- 	MetadataFlagsLayerC.PacketFlagsMetadata -> RF230ActiveMessageP;
- 
- // -------- TimeStamping
- 
- 	components TimeStampingLayerC;
- 	TimeStampingLayerC.LocalTimeRadio -> RF230DriverLayerC;
- 	TimeStampingLayerC.PacketTimeStampMetadata -> RF230ActiveMessageP;
- 	PacketTimeStampRadio = TimeStampingLayerC;
- 	PacketTimeStampMilli = TimeStampingLayerC;
  }
--- 201,203 ----

Index: RF230ActiveMessageP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** RF230ActiveMessageP.nc	4 Apr 2009 00:43:55 -0000	1.6
--- RF230ActiveMessageP.nc	7 Apr 2009 02:27:44 -0000	1.7
***************
*** 38,57 ****
  		interface SlottedCollisionConfig;
  		interface ActiveMessageConfig;
- 		interface LowpanNetworkConfig;
- 		interface IEEE154MessageConfig;
  		interface DummyConfig;
  
- 		interface Packet;
- 
- 		interface PacketData<flags_metadata_t> as PacketFlagsMetadata;
- 		interface PacketData<rf230_metadata_t> as PacketRF230Metadata;
- 		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 RF230Packet;
  
  		interface PacketTimeStamp<TRadio, uint32_t>;
***************
*** 67,98 ****
  implementation
  {
- 	rf230packet_header_t* getHeader(message_t* msg)
- 	{
- 		return (rf230packet_header_t*)(msg->data - sizeof(rf230packet_header_t));
- 	}
- 
- 	rf230packet_metadata_t* getMeta(message_t* msg)
- 	{
- 		return (rf230packet_metadata_t*)(msg->metadata);
- 	}
  
  /*----------------- RF230DriverConfig -----------------*/
  
! 	async command uint8_t RF230DriverConfig.getLength(message_t* msg)
  	{
! 		return call IEEE154MessageLayer.getLength(msg);
  	}
  
! 	async command void RF230DriverConfig.setLength(message_t* msg, uint8_t len)
  	{
! 		call IEEE154MessageLayer.setLength(msg, len);
  	}
  
! 	async command uint8_t* RF230DriverConfig.getPayload(message_t* msg)
  	{
! 		return ((uint8_t*)(call IEEE154MessageConfig.getHeader(msg))) + 1;
  	}
  
! 	async command uint8_t RF230DriverConfig.getHeaderLength()
  	{
  		// we need the fcf, dsn, destpan and dest
--- 58,80 ----
  implementation
  {
  
  /*----------------- RF230DriverConfig -----------------*/
  
! 	async command uint8_t RF230DriverConfig.headerLength(message_t* msg)
  	{
! 		return offsetof(message_t, data) - sizeof(rf230packet_header_t);
  	}
  
! 	async command uint8_t RF230DriverConfig.maxPayloadLength()
  	{
! 		return sizeof(rf230packet_header_t) + TOSH_DATA_LENGTH;
  	}
  
! 	async command uint8_t RF230DriverConfig.metadataLength(message_t* msg)
  	{
! 		return 0;
  	}
  
! 	async command uint8_t RF230DriverConfig.headerPreloadLength()
  	{
  		// we need the fcf, dsn, destpan and dest
***************
*** 100,109 ****
  	}
  
- 	async command uint8_t RF230DriverConfig.getMaxLength()
- 	{
- 		// note, that the ieee154_footer_t is not stored, but we should include it here
- 		return sizeof(rf230packet_header_t) - 1 + TOSH_DATA_LENGTH + sizeof(ieee154_footer_t);
- 	}
- 
  	async command bool RF230DriverConfig.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 RF230Packet.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 rf230_metadata_t* PacketRF230Metadata.get(message_t* msg)
- 	{
- 		return &(getMeta(msg)->rf230);
- 	}
- 
- 	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(rf230packet_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 PacketRF230Metadata.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: RF230DriverConfig.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf230/RF230DriverConfig.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** RF230DriverConfig.nc	27 Mar 2009 21:55:10 -0000	1.2
--- RF230DriverConfig.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 RF230DriverLayerC component.
-  */
  interface RF230DriverConfig
  {
  	/**
! 	 * 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 RF230DriverConfig
  {
  	/**
! 	 * 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: RF230DriverLayer.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf230/RF230DriverLayer.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** RF230DriverLayer.h	2 Apr 2009 22:10:07 -0000	1.1
--- RF230DriverLayer.h	7 Apr 2009 02:27:44 -0000	1.2
***************
*** 25,28 ****
--- 25,33 ----
  #define __RF230DRIVERLAYER_H__
  
+ typedef nx_struct rf230_header_t
+ {
+ 	nxle_uint8_t length;
+ } rf230_header_t;
+ 
  typedef struct rf230_metadata_t
  {

Index: RF230DriverLayerC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf230/RF230DriverLayerC.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** RF230DriverLayerC.nc	2 Apr 2009 22:10:07 -0000	1.2
--- RF230DriverLayerC.nc	7 Apr 2009 02:27:44 -0000	1.3
***************
*** 33,36 ****
--- 33,37 ----
  		interface RadioReceive;
  		interface RadioCCA;
+ 		interface RadioPacket;
  
  		interface PacketField<uint8_t> as PacketTransmitPower;
***************
*** 44,50 ****
  	uses
  	{
! 		interface RF230DriverConfig;
  		interface PacketTimeStamp<TRadio, uint32_t>;
- 		interface PacketData<rf230_metadata_t> as PacketRF230Metadata;
  	}
  }
--- 45,50 ----
  	uses
  	{
! 		interface RF230DriverConfig as Config;
  		interface PacketTimeStamp<TRadio, uint32_t>;
  	}
  }
***************
*** 58,66 ****
  	RadioReceive = RF230DriverLayerP;
  	RadioCCA = RF230DriverLayerP;
  
  	LocalTimeRadio = HplRF230C;
  
! 	RF230DriverConfig = RF230DriverLayerP;
! 	PacketRF230Metadata = RF230DriverLayerP;
  
  	PacketTransmitPower = RF230DriverLayerP.PacketTransmitPower;
--- 58,66 ----
  	RadioReceive = RF230DriverLayerP;
  	RadioCCA = RF230DriverLayerP;
+ 	RadioPacket = RF230DriverLayerP;
  
  	LocalTimeRadio = HplRF230C;
  
! 	Config = RF230DriverLayerP;
  
  	PacketTransmitPower = RF230DriverLayerP.PacketTransmitPower;

Index: RF230DriverLayerP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf2xx/rf230/RF230DriverLayerP.nc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** RF230DriverLayerP.nc	2 Apr 2009 22:10:07 -0000	1.5
--- RF230DriverLayerP.nc	7 Apr 2009 02:27:44 -0000	1.6
***************
*** 39,42 ****
--- 39,43 ----
  		interface RadioReceive;
  		interface RadioCCA;
+ 		interface RadioPacket;
  
  		interface PacketField<uint8_t> as PacketTransmitPower;
***************
*** 61,67 ****
  		interface LocalTime<TRadio>;
  
! 		interface RF230DriverConfig;
  
- 		interface PacketData<rf230_metadata_t> as PacketRF230Metadata;
  		interface PacketFlag as TransmitPowerFlag;
  		interface PacketFlag as RSSIFlag;
--- 62,67 ----
  		interface LocalTime<TRadio>;
  
! 		interface RF230DriverConfig as Config;
  
  		interface PacketFlag as TransmitPowerFlag;
  		interface PacketFlag as RSSIFlag;
***************
*** 81,84 ****
--- 81,99 ----
  implementation
  {
+ 	rf230_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);
+ 	}
+ 
+ 	rf230_metadata_t* getMeta(message_t* msg)
+ 	{
+ 		return ((void*)msg) + sizeof(message_t) - call RadioPacket.metadataLength(msg);
+ 	}
+ 
  /*----------------- STATE -----------------*/
  
***************
*** 421,425 ****
  		}
  
! 		if( call RF230DriverConfig.requiresRssiCca(msg) 
  				&& (readRegister(RF230_PHY_RSSI) & RF230_RSSI_MASK) > ((rssiClear + rssiBusy) >> 3) )
  			return EBUSY;
--- 436,440 ----
  		}
  
! 		if( call Config.requiresRssiCca(msg) 
  				&& (readRegister(RF230_PHY_RSSI) & RF230_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
***************
*** 454,459 ****
  		call FastSpiByte.splitWrite(RF230_CMD_FRAME_WRITE);
  
! 		length = call RF230DriverConfig.getLength(msg);
! 		data = call RF230DriverConfig.getPayload(msg);
  
  		// length | data[0] ... data[length-3] | automatically generated FCS
--- 469,474 ----
  		call FastSpiByte.splitWrite(RF230_CMD_FRAME_WRITE);
  
! 		data = getPayload(msg);
! 		length = getHeader(msg)->length;
  
  		// length | data[0] ... data[length-3] | automatically generated FCS
***************
*** 463,467 ****
  		length -= 2;
  
! 		header = call RF230DriverConfig.getHeaderLength();
  		if( header > length )
  			header = length;
--- 478,482 ----
  		length -= 2;
  
! 		header = call Config.headerPreloadLength();
  		if( header > length )
  			header = length;
***************
*** 516,525 ****
  		if( call DiagMsg.record() )
  		{
! 			length = call RF230DriverConfig.getLength(msg);
  
  			call DiagMsg.str("tx");
  			call DiagMsg.uint16(time);
  			call DiagMsg.uint8(length);
! 			call DiagMsg.hex8s(data, length - 2);
  			call DiagMsg.send();
  		}
--- 531,540 ----
  		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();
  		}
***************
*** 575,579 ****
  
  		// if correct length
! 		if( length >= 3 && length <= call RF230DriverConfig.getMaxLength() )
  		{
  			uint8_t read;
--- 590,594 ----
  
  		// if correct length
! 		if( length >= 3 && length <= call RadioPacket.maxPayloadLength() + 2 )
  		{
  			uint8_t read;
***************
*** 583,588 ****
  			call FastSpiByte.splitWrite(0);
  
! 			call RF230DriverConfig.setLength(rxMsg, length);
! 			data = call RF230DriverConfig.getPayload(rxMsg);
  			crc = 0;
  
--- 598,603 ----
  			call FastSpiByte.splitWrite(0);
  
! 			data = getPayload(rxMsg);
! 			getHeader(rxMsg)->length = length;
  			crc = 0;
  
***************
*** 590,594 ****
  			length -= 2;
  
! 			read = call RF230DriverConfig.getHeaderLength();
  			if( length < read )
  				read = length;
--- 605,609 ----
  			length -= 2;
  
! 			read = call Config.headerPreloadLength();
  			if( length < read )
  				read = length;
***************
*** 623,627 ****
  		if( call DiagMsg.record() )
  		{
! 			length = call RF230DriverConfig.getLength(rxMsg);
  
  			call DiagMsg.str("rx");
--- 638,642 ----
  		if( call DiagMsg.record() )
  		{
! 			length = getHeader(rxMsg)->length;
  
  			call DiagMsg.str("rx");
***************
*** 630,634 ****
  			call DiagMsg.uint8(crc != 0);
  			call DiagMsg.uint8(length);
! 			call DiagMsg.hex8s(call RF230DriverConfig.getPayload(rxMsg), length - 2);
  			call DiagMsg.send();
  		}
--- 645,649 ----
  			call DiagMsg.uint8(crc != 0);
  			call DiagMsg.uint8(length);
! 			call DiagMsg.hex8s(getPayload(rxMsg), length - 2);
  			call DiagMsg.send();
  		}
***************
*** 837,847 ****
  	}
  
! /*----------------- PACKET -----------------*/
  
! 	async event void PacketRF230Metadata.clear(message_t* msg)
  	{
  	}
  
! // --- TransmitPower
  
  	async command bool PacketTransmitPower.isSet(message_t* msg)
--- 852,894 ----
  	}
  
! /*----------------- RadioPacket -----------------*/
! 	
! 	async command uint8_t RadioPacket.headerLength(message_t* msg)
! 	{
! 		return call Config.headerLength(msg) + sizeof(rf230_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(rf230_header_t);
! 	}
! 
! 	async command uint8_t RadioPacket.metadataLength(message_t* msg)
! 	{
! 		return call Config.metadataLength(msg) + sizeof(rf230_metadata_t);
! 	}
! 
! 	async command void RadioPacket.clear(message_t* msg)
! 	{
! 		// all flags are automatically cleared
! 	}
! 
! /*----------------- PacketTransmitPower -----------------*/
  
  	async command bool PacketTransmitPower.isSet(message_t* msg)
***************
*** 852,856 ****
  	async command uint8_t PacketTransmitPower.get(message_t* msg)
  	{
! 		return (call PacketRF230Metadata.get(msg))->power;
  	}
  
--- 899,903 ----
  	async command uint8_t PacketTransmitPower.get(message_t* msg)
  	{
! 		return getMeta(msg)->power;
  	}
  
***************
*** 863,870 ****
  	{
  		call TransmitPowerFlag.set(msg);
! 		(call PacketRF230Metadata.get(msg))->power = value;
  	}
  
! // --- RSSI
  
  	async command bool PacketRSSI.isSet(message_t* msg)
--- 910,917 ----
  	{
  		call TransmitPowerFlag.set(msg);
! 		getMeta(msg)->power = value;
  	}
  
! /*----------------- PacketRSSI -----------------*/
  
  	async command bool PacketRSSI.isSet(message_t* msg)
***************
*** 875,879 ****
  	async command uint8_t PacketRSSI.get(message_t* msg)
  	{
! 		return (call PacketRF230Metadata.get(msg))->rssi;
  	}
  
--- 922,926 ----
  	async command uint8_t PacketRSSI.get(message_t* msg)
  	{
! 		return getMeta(msg)->rssi;
  	}
  
***************
*** 889,903 ****
  
  		call RSSIFlag.set(msg);
! 		(call PacketRF230Metadata.get(msg))->rssi = value;
  	}
  
! // --- TimeSyncOffset
! 
! 	enum
! 	{
! 		PACKET_LENGTH_INCREASE =
! 			sizeof(rf230packet_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)
--- 936,943 ----
  
  		call RSSIFlag.set(msg);
! 		getMeta(msg)->rssi = value;
  	}
  
! /*----------------- PacketTimeSyncOffset -----------------*/
  
  	async command bool PacketTimeSyncOffset.isSet(message_t* msg)
***************
*** 908,912 ****
  	async command uint8_t PacketTimeSyncOffset.get(message_t* msg)
  	{
! 		return call RF230DriverConfig.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_absolute_t);
  	}
  
--- 948,952 ----
  	async command uint8_t PacketTimeSyncOffset.get(message_t* msg)
  	{
! 		return call RadioPacket.headerLength(msg) + call RadioPacket.payloadLength(msg) - sizeof(timesync_absolute_t);
  	}
  
***************
*** 919,928 ****
  	{
  		// we do not store the value, the time sync field is always the last 4 bytes
! 		ASSERT( call RF230DriverConfig.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_absolute_t) == value );
  
  		call TimeSyncFlag.set(msg);
  	}
  
! // --- LinkQuality
  
  	async command bool PacketLinkQuality.isSet(message_t* msg)
--- 959,968 ----
  	{
  		// 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)
***************
*** 933,937 ****
  	async command uint8_t PacketLinkQuality.get(message_t* msg)
  	{
! 		return (call PacketRF230Metadata.get(msg))->lqi;
  	}
  
--- 973,977 ----
  	async command uint8_t PacketLinkQuality.get(message_t* msg)
  	{
! 		return getMeta(msg)->lqi;
  	}
  
***************
*** 942,946 ****
  	async command void PacketLinkQuality.set(message_t* msg, uint8_t value)
  	{
! 		(call PacketRF230Metadata.get(msg))->lqi = value;
  	}
  }
--- 982,986 ----
  	async command void PacketLinkQuality.set(message_t* msg, uint8_t value)
  	{
! 		getMeta(msg)->lqi = value;
  	}
  }



More information about the Tinyos-2-commits mailing list