[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/mac/tkn154 DataP.nc, 1.4, 1.5 DebugP.nc, 1.2, 1.3 DispatchUnslottedCsmaP.nc, 1.4, 1.5 ScanP.nc, 1.4, 1.5
Jan-Hinrich Hauer
janhauer at users.sourceforge.net
Fri Apr 17 07:47:11 PDT 2009
Update of /cvsroot/tinyos/tinyos-2.x/tos/lib/mac/tkn154
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv8652/tos/lib/mac/tkn154
Modified Files:
DataP.nc DebugP.nc DispatchUnslottedCsmaP.nc ScanP.nc
Log Message:
some cosmetic fixes, and a bugfix in ScanP (IEEE154_LIMIT_REACHED was not signalled when the maximum number of descriptors/ED samples was reached) -- this was noticed by Daniel F. P. Santos
Index: DataP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/mac/tkn154/DataP.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** DataP.nc 24 Mar 2009 12:56:46 -0000 1.4
--- DataP.nc 17 Apr 2009 14:47:09 -0000 1.5
***************
*** 89,95 ****
ieee154_txframe_t *txFrame;
uint8_t sfType=0;
! uint8_t *mhr;
! if (payloadLen > call Packet.maxPayloadLength())
txStatus = IEEE154_INVALID_PARAMETER;
else if ((!srcAddrMode && !dstAddrMode) ||
--- 89,96 ----
ieee154_txframe_t *txFrame;
uint8_t sfType=0;
! uint8_t *mhr, mhrLen = call Frame.getHeaderLength(frame);
! if (payloadLen > call Packet.maxPayloadLength() ||
! mhrLen + payloadLen + 2 > IEEE154_aMaxPHYPacketSize) // extra 2 for MAC footer (CRC)
txStatus = IEEE154_INVALID_PARAMETER;
else if ((!srcAddrMode && !dstAddrMode) ||
***************
*** 106,110 ****
txFrame->payloadLen = payloadLen;
mhr = txFrame->header->mhr;
! txFrame->headerLen = call Frame.getHeaderLength(frame);
mhr[MHR_INDEX_FC1] &= ~(FC1_FRAMETYPE_MASK | FC1_FRAME_PENDING | FC1_ACK_REQUEST);
mhr[MHR_INDEX_FC1] |= FC1_FRAMETYPE_DATA;
--- 107,111 ----
txFrame->payloadLen = payloadLen;
mhr = txFrame->header->mhr;
! txFrame->headerLen = mhrLen;
mhr[MHR_INDEX_FC1] &= ~(FC1_FRAMETYPE_MASK | FC1_FRAME_PENDING | FC1_ACK_REQUEST);
mhr[MHR_INDEX_FC1] |= FC1_FRAMETYPE_DATA;
Index: DebugP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/mac/tkn154/DebugP.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DebugP.nc 25 Mar 2009 16:47:49 -0000 1.2
--- DebugP.nc 17 Apr 2009 14:47:09 -0000 1.3
***************
*** 120,124 ****
m_assertLine = line;
strncpy(m_assertFilename, filename, MAX_LEN_FILENAME);
! strncpy(m_assertFunction, func, MAX_LEN_FILENAME);
post assertFailTask();
}
--- 120,124 ----
m_assertLine = line;
strncpy(m_assertFilename, filename, MAX_LEN_FILENAME);
! strncpy(m_assertFunction, func, MAX_LEN_FUNNAME);
post assertFailTask();
}
Index: DispatchUnslottedCsmaP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/mac/tkn154/DispatchUnslottedCsmaP.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** DispatchUnslottedCsmaP.nc 2 Apr 2009 14:02:14 -0000 1.4
--- DispatchUnslottedCsmaP.nc 17 Apr 2009 14:47:09 -0000 1.5
***************
*** 170,174 ****
call MLME_SET.phyCurrentChannel(logicalChannel);
call MLME_SET.macBeaconOrder(beaconOrder);
- call SetMacSuperframeOrder.set(superframeOrder);
call SetMacPanCoordinator.set(panCoordinator);
//TODO: check realignment
--- 170,173 ----
Index: ScanP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/mac/tkn154/ScanP.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ScanP.nc 24 Mar 2009 12:56:46 -0000 1.4
--- ScanP.nc 17 Apr 2009 14:47:09 -0000 1.5
***************
*** 70,74 ****
--- 70,76 ----
enum {
MAX_PAYLOAD_SIZE = 1,
+ LAST_CHANNEL = 26,
};
+ #define INVALID_CHANNEL_BITMASK 0xFC000000L
ieee154_txframe_t *m_txFrame = NULL;
***************
*** 76,83 ****
uint8_t m_scanType;
uint32_t m_scanChannels;
- uint32_t m_unscannedChannels;
- ieee154_macAutoRequest_t m_macAutoRequest;
- norace uint32_t m_currentChannelBit;
norace uint8_t m_currentChannelNum;
void* m_resultList;
uint8_t m_resultListNumEntries;
--- 78,83 ----
uint8_t m_scanType;
uint32_t m_scanChannels;
norace uint8_t m_currentChannelNum;
+ bool m_terminateScan;
void* m_resultList;
uint8_t m_resultListNumEntries;
***************
*** 99,103 ****
// but the RadioToken.granted() has not been signalled
if (m_busy) {
! m_currentChannelNum = 27;
nextIteration(); // signals confirm and resets state
}
--- 99,103 ----
// but the RadioToken.granted() has not been signalled
if (m_busy) {
! m_terminateScan = TRUE;
nextIteration(); // signals confirm and resets state
}
***************
*** 156,164 ****
m_scanChannels = ScanChannels;
m_scanDuration = (((uint32_t) 1 << ScanDuration) + 1) * IEEE154_aBaseSuperframeDuration;
- m_macAutoRequest = call MLME_GET.macAutoRequest();
m_PANID = call MLME_GET.macPANId();
- m_unscannedChannels = 0;
- m_currentChannelBit = 1;
m_currentChannelNum = 0;
m_resultIndex = 0;
if (ScanType == ENERGY_DETECTION_SCAN) {
--- 156,162 ----
m_scanChannels = ScanChannels;
m_scanDuration = (((uint32_t) 1 << ScanDuration) + 1) * IEEE154_aBaseSuperframeDuration;
m_PANID = call MLME_GET.macPANId();
m_currentChannelNum = 0;
+ m_terminateScan = FALSE;
m_resultIndex = 0;
if (ScanType == ENERGY_DETECTION_SCAN) {
***************
*** 237,250 ****
void nextIteration()
{
error_t radioStatus = SUCCESS;
! uint32_t supportedChannels = IEEE154_SUPPORTED_CHANNELS;
! atomic {
! while (!(m_scanChannels & m_currentChannelBit & supportedChannels) && m_currentChannelNum < 27) {
! m_unscannedChannels |= m_currentChannelBit;
! m_currentChannelBit <<= 1;
m_currentChannelNum++;
}
}
! if (m_currentChannelNum < 27) {
call MLME_SET.phyCurrentChannel(m_currentChannelNum);
dbg_serial("ScanP", "Scanning channel %lu...\n", (uint32_t) m_currentChannelNum);
--- 235,252 ----
void nextIteration()
{
+ ieee154_phyChannelsSupported_t supportedChannels = call MLME_GET.phyChannelsSupported();
+ uint32_t currentChannelBit = (uint32_t) 1 << m_currentChannelNum;
error_t radioStatus = SUCCESS;
!
! if (!m_terminateScan){
! while (m_currentChannelNum <= LAST_CHANNEL &&
! !(m_scanChannels & currentChannelBit & supportedChannels)){
m_currentChannelNum++;
+ currentChannelBit <<= 1;
}
}
!
! if (m_currentChannelNum <= LAST_CHANNEL && !m_terminateScan) {
! // scan the next channel
call MLME_SET.phyCurrentChannel(m_currentChannelNum);
dbg_serial("ScanP", "Scanning channel %lu...\n", (uint32_t) m_currentChannelNum);
***************
*** 265,275 ****
// we're done
ieee154_status_t result = IEEE154_SUCCESS;
! m_currentChannelBit <<= 1;
! while (m_currentChannelBit) {
! m_unscannedChannels |= m_currentChannelBit;
! m_currentChannelBit <<= 1;
! }
! m_unscannedChannels &= m_scanChannels; // only channels that were requested
! if (m_scanType != ENERGY_DETECTION_SCAN && !m_resultIndex)
result = IEEE154_NO_BEACON;
if (m_scanType == PASSIVE_SCAN || m_scanType == ACTIVE_SCAN)
--- 267,287 ----
// we're done
ieee154_status_t result = IEEE154_SUCCESS;
! 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
! if (m_scanType == PASSIVE_SCAN || m_scanType == ACTIVE_SCAN)
! currentChannelBit >>= 1;
! while (!(currentChannelBit & INVALID_CHANNEL_BITMASK) &&
! (m_scanChannels & currentChannelBit)){
! unscannedChannels |= currentChannelBit;
! currentChannelBit <<= 1;
! }
! } else if (m_scanType != ENERGY_DETECTION_SCAN && !m_resultIndex)
result = IEEE154_NO_BEACON;
if (m_scanType == PASSIVE_SCAN || m_scanType == ACTIVE_SCAN)
***************
*** 288,298 ****
m_scanType,
IEEE154_SUPPORTED_CHANNELPAGE,
! m_unscannedChannels,
(m_scanType == ENERGY_DETECTION_SCAN) ? m_resultIndex : 0,
(m_scanType == ENERGY_DETECTION_SCAN) ? (int8_t*) m_resultList : NULL,
((m_scanType == ACTIVE_SCAN ||
! m_scanType == PASSIVE_SCAN) && m_macAutoRequest) ? m_resultIndex : 0,
((m_scanType == ACTIVE_SCAN ||
! m_scanType == PASSIVE_SCAN) && m_macAutoRequest) ? (ieee154_PANDescriptor_t*) m_resultList : NULL);
}
dbg_serial_flush();
--- 300,310 ----
m_scanType,
IEEE154_SUPPORTED_CHANNELPAGE,
! unscannedChannels,
(m_scanType == ENERGY_DETECTION_SCAN) ? m_resultIndex : 0,
(m_scanType == ENERGY_DETECTION_SCAN) ? (int8_t*) m_resultList : NULL,
((m_scanType == ACTIVE_SCAN ||
! m_scanType == PASSIVE_SCAN) && call MLME_GET.macAutoRequest()) ? m_resultIndex : 0,
((m_scanType == ACTIVE_SCAN ||
! m_scanType == PASSIVE_SCAN) && call MLME_GET.macAutoRequest()) ? (ieee154_PANDescriptor_t*) m_resultList : NULL);
}
dbg_serial_flush();
***************
*** 310,319 ****
if (status == SUCCESS && m_resultListNumEntries)
((uint8_t*) m_resultList)[m_resultIndex++] = EnergyLevel;
- else
- m_unscannedChannels |= m_currentChannelBit;
if (m_resultIndex == m_resultListNumEntries)
! m_currentChannelNum = 27; // done
! else
! m_currentChannelNum++;
call RadioOff.off();
}
--- 322,327 ----
if (status == SUCCESS && m_resultListNumEntries)
((uint8_t*) m_resultList)[m_resultIndex++] = EnergyLevel;
if (m_resultIndex == m_resultListNumEntries)
! m_terminateScan = TRUE; // done
call RadioOff.off();
}
***************
*** 330,380 ****
event message_t* RadioRx.received(message_t *frame, const ieee154_timestamp_t *timestamp)
{
! atomic {
! if (!m_busy)
! return frame;
! if (m_scanType == ORPHAN_SCAN) {
! if (!m_resultIndex)
! if ((MHR(frame)[0] & FC1_FRAMETYPE_MASK) == FC1_FRAMETYPE_CMD &&
! ((uint8_t*)call Frame.getPayload(frame))[0] == CMD_FRAME_COORDINATOR_REALIGNMENT) {
! m_resultIndex++;
! dbg_serial("ScanP", "Received coordinator realignment frame.\n");
! m_currentChannelNum = 27; // terminate scan
! call RadioOff.off();
! }
! } else if ((((ieee154_header_t*) frame->header)->mhr[0] & FC1_FRAMETYPE_MASK) == FC1_FRAMETYPE_BEACON) {
! // PASSIVE_SCAN / ACTIVE_SCAN
! if (!m_macAutoRequest)
! return signal MLME_BEACON_NOTIFY.indication (frame);
! else if (m_resultListNumEntries && m_resultIndex < m_resultListNumEntries &&
! call BeaconFrame.parsePANDescriptor(
! frame,
! m_currentChannelNum,
! IEEE154_SUPPORTED_CHANNELPAGE,
! &((ieee154_PANDescriptor_t*) m_resultList)[m_resultIndex]) == SUCCESS) {
!
! // check uniqueness: both PAN ID and source address must not be in a previously received beacon
! uint8_t i;
! ieee154_PANDescriptor_t* descriptor = (ieee154_PANDescriptor_t*) m_resultList;
! if (m_resultIndex)
! for (i=0; i<m_resultIndex; i++)
! if (descriptor[i].CoordPANId == descriptor[m_resultIndex].CoordPANId &&
! descriptor[i].CoordAddrMode == descriptor[m_resultIndex].CoordAddrMode)
! if ((descriptor[i].CoordAddrMode == ADDR_MODE_SHORT_ADDRESS &&
! descriptor[i].CoordAddress.shortAddress ==
! descriptor[m_resultIndex].CoordAddress.shortAddress) ||
! (descriptor[i].CoordAddrMode == ADDR_MODE_EXTENDED_ADDRESS &&
! descriptor[i].CoordAddress.extendedAddress ==
! descriptor[m_resultIndex].CoordAddress.extendedAddress))
! return frame; // not unique
! dbg_serial("ScanP", "Received beacon, source: 0x%lx, channel: %lu.\n",
! (uint32_t) descriptor[m_resultIndex].CoordAddress.shortAddress, (uint32_t) m_currentChannelNum);
! m_resultIndex++;
! if (m_resultIndex == m_resultListNumEntries) {
! m_currentChannelNum = 27; // terminate scan
! call RadioOff.off();
! }
}
! } // PASSIVE_SCAN / ACTIVE_SCAN
! }
return frame;
}
--- 338,385 ----
event message_t* RadioRx.received(message_t *frame, const ieee154_timestamp_t *timestamp)
{
! if (!m_busy)
! return frame;
! if (m_scanType == ORPHAN_SCAN) {
! if (!m_resultIndex)
! if ((MHR(frame)[0] & FC1_FRAMETYPE_MASK) == FC1_FRAMETYPE_CMD &&
! ((uint8_t*)call Frame.getPayload(frame))[0] == CMD_FRAME_COORDINATOR_REALIGNMENT) {
! m_resultIndex++;
! dbg_serial("ScanP", "Received coordinator realignment frame.\n");
! m_terminateScan = TRUE;
! call RadioOff.off();
}
! } else if ((((ieee154_header_t*) frame->header)->mhr[0] & FC1_FRAMETYPE_MASK) == FC1_FRAMETYPE_BEACON) {
! // PASSIVE_SCAN / ACTIVE_SCAN
! if (!call MLME_GET.macAutoRequest())
! return signal MLME_BEACON_NOTIFY.indication (frame);
! else if (m_resultIndex >= m_resultListNumEntries) {
! m_terminateScan = TRUE;
! call RadioOff.off();
! } else if (call BeaconFrame.parsePANDescriptor(
! frame,
! m_currentChannelNum,
! IEEE154_SUPPORTED_CHANNELPAGE,
! &((ieee154_PANDescriptor_t*) m_resultList)[m_resultIndex]) == SUCCESS) {
!
! // check uniqueness: both PAN ID and source address must not be in a previously received beacon
! uint8_t i;
! ieee154_PANDescriptor_t* descriptor = (ieee154_PANDescriptor_t*) m_resultList;
!
! dbg_serial("ScanP", "Received beacon, source: 0x%lx, channel: %lu.\n",
! (uint32_t) descriptor[m_resultIndex].CoordAddress.shortAddress, (uint32_t) m_currentChannelNum);
! if (m_resultIndex)
! for (i=0; i<m_resultIndex; i++)
! if (descriptor[i].CoordPANId == descriptor[m_resultIndex].CoordPANId &&
! descriptor[i].CoordAddrMode == descriptor[m_resultIndex].CoordAddrMode)
! if ((descriptor[i].CoordAddrMode == ADDR_MODE_SHORT_ADDRESS &&
! descriptor[i].CoordAddress.shortAddress ==
! descriptor[m_resultIndex].CoordAddress.shortAddress) ||
! (descriptor[i].CoordAddrMode == ADDR_MODE_EXTENDED_ADDRESS &&
! descriptor[i].CoordAddress.extendedAddress ==
! descriptor[m_resultIndex].CoordAddress.extendedAddress))
! return frame; // not unique
! m_resultIndex++; // was unique
! }
! } // PASSIVE_SCAN / ACTIVE_SCAN
return frame;
}
***************
*** 397,401 ****
post continueScanRequestTask();
else {
- m_currentChannelBit <<= 1;
m_currentChannelNum++;
post nextIterationTask();
--- 402,405 ----
More information about the Tinyos-2-commits
mailing list