From: janhauer Date: Thu, 30 Apr 2009 13:23:48 +0000 (+0000) Subject: Energy scan returned wrong status code if EnergyDetectList array size was equal to... X-Git-Tag: rc_6_tinyos_2_1_1~399 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=35905c1cd223f9fbef7f5435b518dc34acfd3bef Energy scan returned wrong status code if EnergyDetectList array size was equal to number of scanned channels (as pointed out by D. Santos). This is now fixed. --- diff --git a/tos/lib/mac/tkn154/ScanP.nc b/tos/lib/mac/tkn154/ScanP.nc index a92fc5ac..37ac03b6 100644 --- a/tos/lib/mac/tkn154/ScanP.nc +++ b/tos/lib/mac/tkn154/ScanP.nc @@ -272,21 +272,23 @@ implementation uint32_t unscannedChannels = 0; if (m_terminateScan){ - // scan operation terminated prematurely because the max. - // number of PAN descriptors/ED samples was reached - result = IEEE154_LIMIT_REACHED; - - // mark the channel on which we received the last beacon - // as unscanned, because it was not completely scanned + // Scan operation terminated because the max. + // number of PAN descriptors/ED samples was reached. + // Check if there are channels that were unscanned. + // In active/passive scan we consider a channel + // unscanned if it was not completely scanned. if (m_scanType == PASSIVE_SCAN || m_scanType == ACTIVE_SCAN) - currentChannelBit >>= 1; + currentChannelBit >>= 1; // last (partially) scanned channel while (!(currentChannelBit & INVALID_CHANNEL_BITMASK) && (m_scanChannels & currentChannelBit)){ unscannedChannels |= currentChannelBit; currentChannelBit <<= 1; } + if (unscannedChannels) // some channels were not (completely) scanned + result = IEEE154_LIMIT_REACHED; } else if (m_scanType != ENERGY_DETECTION_SCAN && !m_resultIndex) result = IEEE154_NO_BEACON; + if (m_scanType == PASSIVE_SCAN || m_scanType == ACTIVE_SCAN) call MLME_SET.macPANId(m_PANID); if (m_txFrame != NULL) {