[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/rf230 RF230LayerP.nc, 1.17, 1.18 RF230Packet.h, 1.2, 1.3 RF230PacketP.nc, 1.2, 1.3 TimeSyncMessage.h, 1.2, 1.3 TimeSyncMessageP.nc, 1.5, 1.6
Miklos Maroti
mmaroti at users.sourceforge.net
Thu Jun 5 13:44:24 PDT 2008
Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv28595/tos/chips/rf230
Modified Files:
RF230LayerP.nc RF230Packet.h RF230PacketP.nc TimeSyncMessage.h
TimeSyncMessageP.nc
Log Message:
RF230: timesync changes to lower memory usage
Index: RF230LayerP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230/RF230LayerP.nc,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** RF230LayerP.nc 5 Jun 2008 19:43:21 -0000 1.17
--- RF230LayerP.nc 5 Jun 2008 20:44:21 -0000 1.18
***************
*** 26,29 ****
--- 26,30 ----
#include <Tasklet.h>
#include <RadioAssert.h>
+ #include <TimeSyncMessage.h>
module RF230LayerP
***************
*** 393,407 ****
uint8_t header;
uint32_t time32;
if( cmd != CMD_NONE || state != STATE_RX_ON || ! isSpiAcquired() || radioIrq )
return EBUSY;
- if( call RF230Config.requiresRssiCca(msg)
- && (readRegister(RF230_PHY_RSSI) & RF230_RSSI_MASK) > ((rssiClear + rssiBusy) >> 3) )
- return EBUSY;
-
- writeRegister(RF230_TRX_STATE, RF230_PLL_ON);
-
- // do something useful, just to wait a little
length = (call PacketTransmitPower.isSet(msg) ?
call PacketTransmitPower.get(msg) : RF230_DEF_RFPOWER) & RF230_TX_PWR_MASK;
--- 394,402 ----
uint8_t header;
uint32_t time32;
+ void* timesync;
if( cmd != CMD_NONE || state != STATE_RX_ON || ! isSpiAcquired() || radioIrq )
return EBUSY;
length = (call PacketTransmitPower.isSet(msg) ?
call PacketTransmitPower.get(msg) : RF230_DEF_RFPOWER) & RF230_TX_PWR_MASK;
***************
*** 413,417 ****
--- 408,420 ----
}
+ if( call RF230Config.requiresRssiCca(msg)
+ && (readRegister(RF230_PHY_RSSI) & RF230_RSSI_MASK) > ((rssiClear + rssiBusy) >> 3) )
+ return EBUSY;
+
+ writeRegister(RF230_TRX_STATE, RF230_PLL_ON);
+
+ // 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
***************
*** 459,464 ****
time32 += (int16_t)(time) - (int16_t)(time32);
! if( call PacketTimeSyncOffset.isSet(msg) )
! ((timesync_footer_t*)(msg->data + call PacketTimeSyncOffset.get(msg)))->time_offset += time32;
do {
--- 462,467 ----
time32 += (int16_t)(time) - (int16_t)(time32);
! if( timesync != 0 )
! *(timesync_relative_t*)timesync = (*(timesync_absolute_t*)timesync) - time32;
do {
***************
*** 499,504 ****
#endif
! if( call PacketTimeSyncOffset.isSet(msg) )
! ((timesync_footer_t*)(msg->data + call PacketTimeSyncOffset.get(msg)))->time_offset -= time32;
call PacketTimeStamp.set(msg, time32);
--- 502,507 ----
#endif
! if( timesync != 0 )
! *(timesync_absolute_t*)timesync = (*(timesync_relative_t*)timesync) + time32;
call PacketTimeStamp.set(msg, time32);
Index: RF230Packet.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230/RF230Packet.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** RF230Packet.h 29 May 2008 18:57:53 -0000 1.2
--- RF230Packet.h 5 Jun 2008 20:44:21 -0000 1.3
***************
*** 26,30 ****
#include <IEEE154Packet.h>
- #include <TimeSyncMessage.h>
typedef ieee154_header_t rf230packet_header_t;
--- 26,29 ----
***************
*** 32,36 ****
typedef nx_struct rf230packet_footer_t
{
! timesync_footer_t timesync;
} rf230packet_footer_t;
--- 31,35 ----
typedef nx_struct rf230packet_footer_t
{
! // the time stamp is not recorded here, time stamped messaged cannot have max length
} rf230packet_footer_t;
Index: RF230PacketP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230/RF230PacketP.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** RF230PacketP.nc 29 May 2008 18:57:53 -0000 1.2
--- RF230PacketP.nc 5 Jun 2008 20:44:21 -0000 1.3
***************
*** 23,26 ****
--- 23,27 ----
#include <RF230Packet.h>
+ #include <TimeSyncMessage.h>
module RF230PacketP
***************
*** 251,255 ****
async command uint8_t PacketTimeSyncOffset.get(message_t* msg)
{
! return call IEEE154Packet.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_footer_t);
}
--- 252,256 ----
async command uint8_t PacketTimeSyncOffset.get(message_t* msg)
{
! return call IEEE154Packet.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_absolute_t);
}
Index: TimeSyncMessage.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230/TimeSyncMessage.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TimeSyncMessage.h 29 May 2008 18:57:53 -0000 1.2
--- TimeSyncMessage.h 5 Jun 2008 20:44:21 -0000 1.3
***************
*** 25,32 ****
#define __TIMESYNCMESSAGE_H__
! typedef nx_struct timesync_footer_t
! {
! nx_int32_t time_offset; // in micorsec
! } timesync_footer_t;
#endif//__TIMESYNCMESSAGE_H__
--- 25,33 ----
#define __TIMESYNCMESSAGE_H__
! // this value is sent in the air
! typedef nx_int32_t timesync_relative_t;
!
! // this value is stored in memory
! typedef uint32_t timesync_absolute_t;
#endif//__TIMESYNCMESSAGE_H__
Index: TimeSyncMessageP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/rf230/TimeSyncMessageP.nc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** TimeSyncMessageP.nc 29 May 2008 20:09:33 -0000 1.5
--- TimeSyncMessageP.nc 5 Jun 2008 20:44:21 -0000 1.6
***************
*** 55,62 ****
{
// TODO: change the Packet.payloadLength and Packet.maxPayloadLength commands to async
! inline timesync_footer_t* getFooter(message_t* msg)
{
! // we use the payload length we export (the smaller one)
! return (timesync_footer_t*)(msg->data + call Packet.payloadLength(msg));
}
--- 55,62 ----
{
// TODO: change the Packet.payloadLength and Packet.maxPayloadLength commands to async
! inline void* getFooter(message_t* msg)
{
! // we use the payload length that we export (the smaller one)
! return msg->data + call Packet.payloadLength(msg);
}
***************
*** 70,89 ****
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);
}
command void* Packet.getPayload(message_t* msg, uint8_t len)
{
! return call SubPacket.getPayload(msg, len + sizeof(timesync_footer_t));
}
--- 70,89 ----
command void Packet.setPayloadLength(message_t* msg, uint8_t len)
{
! call SubPacket.setPayloadLength(msg, len + sizeof(timesync_relative_t));
}
command uint8_t Packet.payloadLength(message_t* msg)
{
! return call SubPacket.payloadLength(msg) - sizeof(timesync_relative_t);
}
command uint8_t Packet.maxPayloadLength()
{
! return call SubPacket.maxPayloadLength() - sizeof(timesync_relative_t);
}
command void* Packet.getPayload(message_t* msg, uint8_t len)
{
! return call SubPacket.getPayload(msg, len + sizeof(timesync_relative_t));
}
***************
*** 92,101 ****
command error_t TimeSyncAMSendRadio.send[am_id_t id](am_addr_t addr, message_t* msg, uint8_t len, uint32_t event_time)
{
! timesync_footer_t* footer = (timesync_footer_t*)(msg->data + len);
! footer->time_offset = (nx_int32_t)event_time;
call PacketTimeSyncOffset.set(msg, len);
! return call SubSend.send[id](addr, msg, len + sizeof(timesync_footer_t));
}
--- 92,100 ----
command error_t TimeSyncAMSendRadio.send[am_id_t id](am_addr_t addr, message_t* msg, uint8_t len, uint32_t event_time)
{
! *(timesync_absolute_t*)(msg->data + len) = event_time;
call PacketTimeSyncOffset.set(msg, len);
! return call SubSend.send[id](addr, msg, len + sizeof(timesync_relative_t));
}
***************
*** 111,120 ****
command uint8_t TimeSyncAMSendRadio.maxPayloadLength[am_id_t id]()
{
! return call SubSend.maxPayloadLength[id]() - sizeof(timesync_footer_t);
}
command void* TimeSyncAMSendRadio.getPayload[am_id_t id](message_t* msg, uint8_t len)
{
! return call SubSend.getPayload[id](msg, len + sizeof(timesync_footer_t));
}
--- 110,119 ----
command uint8_t TimeSyncAMSendRadio.maxPayloadLength[am_id_t id]()
{
! return call SubSend.maxPayloadLength[id]() - sizeof(timesync_relative_t);
}
command void* TimeSyncAMSendRadio.getPayload[am_id_t id](message_t* msg, uint8_t len)
{
! return call SubSend.getPayload[id](msg, len + sizeof(timesync_relative_t));
}
***************
*** 160,173 ****
async command bool TimeSyncPacketRadio.isValid(message_t* msg)
{
! timesync_footer_t* footer = getFooter(msg);
! return call PacketTimeStampRadio.isValid(msg) && footer->time_offset != 0x80000000L;
}
async command uint32_t TimeSyncPacketRadio.eventTime(message_t* msg)
{
! timesync_footer_t* footer = getFooter(msg);
! return (int32_t)(footer->time_offset) + call PacketTimeStampRadio.timestamp(msg);
}
--- 159,172 ----
async command bool TimeSyncPacketRadio.isValid(message_t* msg)
{
! timesync_relative_t* timesync = getFooter(msg);
! return call PacketTimeStampRadio.isValid(msg) && *timesync != 0x80000000L;
}
async command uint32_t TimeSyncPacketRadio.eventTime(message_t* msg)
{
! timesync_relative_t* timesync = getFooter(msg);
! return (*timesync) + call PacketTimeStampRadio.timestamp(msg);
}
***************
*** 176,189 ****
async command bool TimeSyncPacketMilli.isValid(message_t* msg)
{
! timesync_footer_t* footer = getFooter(msg);
! return call PacketTimeStampMilli.isValid(msg) && footer->time_offset != 0x80000000L;
}
async command uint32_t TimeSyncPacketMilli.eventTime(message_t* msg)
{
! timesync_footer_t* footer = getFooter(msg);
! return ((int32_t)(footer->time_offset) << 10) + call PacketTimeStampMilli.timestamp(msg);
}
}
--- 175,188 ----
async command bool TimeSyncPacketMilli.isValid(message_t* msg)
{
! timesync_relative_t* timesync = getFooter(msg);
! return call PacketTimeStampMilli.isValid(msg) && *timesync != 0x80000000L;
}
async command uint32_t TimeSyncPacketMilli.eventTime(message_t* msg)
{
! timesync_relative_t* timesync = getFooter(msg);
! return ((int32_t)(*timesync) << 10) + call PacketTimeStampMilli.timestamp(msg);
}
}
More information about the Tinyos-2-commits
mailing list