From 9092b3c0aa9215dff07b3465a88eb706e3e2193f Mon Sep 17 00:00:00 2001 From: andreaskoepke Date: Thu, 10 Jul 2008 12:40:01 +0000 Subject: [PATCH] keep sfd time --- tos/chips/tda5250/Tda5250ActiveMessageP.nc | 2 +- tos/chips/tda5250/mac/CsmaMacP.nc | 8 ++++++-- tos/chips/tda5250/mac/RedMac.h | 7 ------- tos/chips/tda5250/mac/RedMacP.nc | 10 +++++++--- tos/chips/tda5250/mac/SpeckMacDP.nc | 5 ++++- tos/chips/tda5250/tda5250_message.h | 19 ++++++++++++++----- 6 files changed, 32 insertions(+), 19 deletions(-) diff --git a/tos/chips/tda5250/Tda5250ActiveMessageP.nc b/tos/chips/tda5250/Tda5250ActiveMessageP.nc index 5c1a41b6..30a25192 100644 --- a/tos/chips/tda5250/Tda5250ActiveMessageP.nc +++ b/tos/chips/tda5250/Tda5250ActiveMessageP.nc @@ -157,7 +157,7 @@ implementation { return getMetadata(msg)->strength; } - default event message_t* Receive.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) { + default event message_t* Receive.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) { return msg; } diff --git a/tos/chips/tda5250/mac/CsmaMacP.nc b/tos/chips/tda5250/mac/CsmaMacP.nc index 2a236528..2b8b57fe 100644 --- a/tos/chips/tda5250/mac/CsmaMacP.nc +++ b/tos/chips/tda5250/mac/CsmaMacP.nc @@ -303,7 +303,7 @@ implementation task void postponeReRx() { call ReRxTimer.startOneShot(5000); } - + uint16_t backoff(uint8_t counter) { uint16_t mask = BACKOFF_MASK >> (MAX_LONG_RETRY - counter); return (call Random.rand16() & mask); @@ -962,7 +962,11 @@ implementation } } - async event void RadioTimeStamping.transmittedSFD( uint16_t time, message_t* p_msg ) {} + async event void RadioTimeStamping.transmittedSFD( uint16_t time, message_t* p_msg ) { + if((macState == TX) && (p_msg == txBufPtr)) { + // to do + } + } /***** Rssi Resource events ******************/ event void RssiAdcResource.granted() { diff --git a/tos/chips/tda5250/mac/RedMac.h b/tos/chips/tda5250/mac/RedMac.h index 84497b48..9a614439 100644 --- a/tos/chips/tda5250/mac/RedMac.h +++ b/tos/chips/tda5250/mac/RedMac.h @@ -36,13 +36,6 @@ #ifndef RED_MAC_H #define RED_MAC_H -/* - * highest bit of token set: this message is ACK and not intended for the - * upper layers. Token is used for alternating bit like duplicate detection, - * and set by the sender in [0,127] intervall. The receiver reflects the - * token in the Ack, with the highest bit set. - */ - typedef nx_struct red_mac_header_t { nx_uint8_t repetitionCounter; nx_uint32_t time; // processing delay of message diff --git a/tos/chips/tda5250/mac/RedMacP.nc b/tos/chips/tda5250/mac/RedMacP.nc index 6d07f267..d734b492 100644 --- a/tos/chips/tda5250/mac/RedMacP.nc +++ b/tos/chips/tda5250/mac/RedMacP.nc @@ -147,10 +147,10 @@ implementation SUB_HEADER_TIME=PHY_HEADER_TIME + sizeof(message_header_t)*BYTE_TIME, SUB_FOOTER_TIME=2*BYTE_TIME, // 2 bytes crc // DEFAULT_SLEEP_TIME=1625, - // DEFAULT_SLEEP_TIME=2048, + DEFAULT_SLEEP_TIME=2048, // DEFAULT_SLEEP_TIME=4096, // DEFAULT_SLEEP_TIME=8192, - DEFAULT_SLEEP_TIME=16384, + // DEFAULT_SLEEP_TIME=16384, // DEFAULT_SLEEP_TIME=32768U, // DEFAULT_SLEEP_TIME=65535U, DATA_DETECT_TIME=17, @@ -875,6 +875,7 @@ implementation #ifdef DELTATIMEDEBUG dTrace.sender = getHeader(msg)->src; #endif + getMetadata(msg)->sfdtime = rxTime; getMetadata(msg)->time = calcGeneratedTime((red_mac_header_t*) payload); getMetadata(msg)->ack = WAS_NOT_ACKED; m = signal MacReceive.receiveDone(msg); @@ -1066,9 +1067,12 @@ implementation dTrace.delta = call TimeDiff32.computeDelta(dTrace.now, dTrace.msgTime); txMacHdr->time = dTrace.delta; call DeltaTrace.traceTx(&dTrace); + getMetadata(p_msg)->sfdtime = dTrace.now; #else + getMetadata(p_msg)->sfdtime = call LocalTime32kHz.get(); txMacHdr->time = - call TimeDiff32.computeDelta(call LocalTime32kHz.get(), getMetadata(p_msg)->time); + call TimeDiff32.computeDelta(getMetadata(p_msg)->sfdtime, + getMetadata(p_msg)->time); #endif } } diff --git a/tos/chips/tda5250/mac/SpeckMacDP.nc b/tos/chips/tda5250/mac/SpeckMacDP.nc index 5988ed47..bc904ebf 100644 --- a/tos/chips/tda5250/mac/SpeckMacDP.nc +++ b/tos/chips/tda5250/mac/SpeckMacDP.nc @@ -788,6 +788,7 @@ implementation rxStat.duplicate = PERF_NEW_MSG; #endif storeStrength(msg); + getMetadata(msg)->sfdtime = rxTime; getMetadata(msg)->time = calcGeneratedTime((red_mac_header_t*) payload); getMetadata(msg)->ack = WAS_NOT_ACKED; m = signal MacReceive.receiveDone(msg); @@ -949,8 +950,10 @@ implementation async event void RadioTimeStamping.transmittedSFD(uint16_t time, message_t* p_msg ) { if((macState == TX) && (p_msg == txBufPtr)) { + getMetadata(msg)->sfdtime = call LocalTime32kHz.get(); txMacHdr->time = - call TimeDiff32.computeDelta(call LocalTime32kHz.get(), getMetadata(p_msg)->time); + call TimeDiff32.computeDelta(getMetadata(msg)->sfdtime, + getMetadata(p_msg)->time); } } diff --git a/tos/chips/tda5250/tda5250_message.h b/tos/chips/tda5250/tda5250_message.h index 1f377841..b6053fde 100644 --- a/tos/chips/tda5250/tda5250_message.h +++ b/tos/chips/tda5250/tda5250_message.h @@ -4,12 +4,19 @@ #include "AM.h" #include "PacketAck.h" +/* + * highest bit of token set: this message is ACK and not intended for the + * upper layers. Token is used for alternating bit like duplicate detection, + * and set by the sender in [0,127] intervall. The receiver reflects the + * token in the Ack, with the highest bit set. + */ + typedef nx_struct tda5250_header_t { - nx_uint8_t length; - nx_am_addr_t src; - nx_am_addr_t dest; - nx_am_id_t type; - nx_uint8_t token; + nx_uint8_t length; + nx_am_addr_t src; + nx_am_addr_t dest; + nx_am_id_t type; + nx_uint8_t token; } tda5250_header_t; typedef nx_struct tda5250_footer_t { @@ -21,6 +28,8 @@ typedef nx_struct tda5250_metadata_t { nx_uint8_t ack; /* local time when message was generated */ nx_uint32_t time; + /* time of sfd generation */ + nx_uint32_t sfdtime; nx_uint8_t sendSecurityMode; nx_uint8_t receiveSecurityMode; /* some meta information that allows to compute a density */ -- 2.39.2