From 0c1d445166f7093b5c85f4ae0e6dcfc793bb4664 Mon Sep 17 00:00:00 2001 From: andreaskoepke Date: Thu, 4 Oct 2007 09:40:49 +0000 Subject: [PATCH] - age cache whenever a new messages arrives - add debug interface --- tos/chips/tda5250/mac/DuplicateC.nc | 6 +++++ tos/chips/tda5250/mac/DuplicateP.nc | 38 ++++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/tos/chips/tda5250/mac/DuplicateC.nc b/tos/chips/tda5250/mac/DuplicateC.nc index b57c166b..64bc4199 100644 --- a/tos/chips/tda5250/mac/DuplicateC.nc +++ b/tos/chips/tda5250/mac/DuplicateC.nc @@ -47,4 +47,10 @@ implementation { Duplicate = DuplicateP; DuplicateP.Timer -> Timer; // make information soft state MainC.SoftwareInit -> DuplicateP; + +#ifdef DUPLICATE_DEBUG + components new SerialDebugC() as SD; + DuplicateP.SerialDebug -> SD; +#endif + } diff --git a/tos/chips/tda5250/mac/DuplicateP.nc b/tos/chips/tda5250/mac/DuplicateP.nc index b07b5686..e5df6508 100644 --- a/tos/chips/tda5250/mac/DuplicateP.nc +++ b/tos/chips/tda5250/mac/DuplicateP.nc @@ -39,11 +39,35 @@ module DuplicateP { } uses { interface Timer as Timer; +#ifdef DUPLICATE_DEBUG + interface SerialDebug; +#endif } } -implementation { +implementation { known_t knownTable[TABLE_ENTRIES]; - + +#ifdef DUPLICATE_DEBUG + void sdDebug(uint16_t p) { + call SerialDebug.putPlace(p); + } + known_t dupOldest; + unsigned last; + task void dump() { + sdDebug(3000 + last); + sdDebug(dupOldest.src); + sdDebug(dupOldest.seqno); + sdDebug(dupOldest.age); + sdDebug(4000); + sdDebug(knownTable[last].src); + sdDebug(knownTable[last].seqno); + sdDebug(knownTable[last].age); + sdDebug(5000); + } +#else + void sdDebug(uint16_t p) {}; +#endif + /** helper functions */ task void ageMsgsTask() { unsigned i; @@ -80,14 +104,22 @@ implementation { break; } } + sdDebug(100 + rVal); + sdDebug(200 + i); return rVal; } async command void Duplicate.remember(am_addr_t src, uint8_t seqno) { unsigned oldest = findOldest(); +#ifdef DUPLICATE_DEBUG + dupOldest = knownTable[oldest]; + last = oldest; + post dump(); +#endif knownTable[oldest].src = src; knownTable[oldest].seqno = seqno; knownTable[oldest].age = 0; + post ageMsgsTask(); } /** helper interfaces */ @@ -99,7 +131,7 @@ implementation { uint8_t i; for(i = 0; i < TABLE_ENTRIES; i++) { atomic { - knownTable[i].age = MAX_AGE; + knownTable[i].age = MAX_AGE; } } call Timer.startPeriodic(AGE_INTERVALL); -- 2.39.2