From: janhauer Date: Thu, 14 May 2009 13:20:35 +0000 (+0000) Subject: bugfix: radio token was not properly transferred when MLME_SCAN/_RX_ENABLE was called... X-Git-Tag: rc_6_tinyos_2_1_1~389 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=9b7c447b3ec7173f2b22fce7452151bf209379f5 bugfix: radio token was not properly transferred when MLME_SCAN/_RX_ENABLE was called after the MAC had been switched to Rx/Tx before. --- diff --git a/tos/lib/mac/tkn154/DispatchSlottedCsmaP.nc b/tos/lib/mac/tkn154/DispatchSlottedCsmaP.nc index ca1abef2..c2b29323 100644 --- a/tos/lib/mac/tkn154/DispatchSlottedCsmaP.nc +++ b/tos/lib/mac/tkn154/DispatchSlottedCsmaP.nc @@ -73,6 +73,7 @@ generic module DispatchSlottedCsmaP(uint8_t sfDirection) interface Alarm as BLEAlarm; interface Alarm as RxWaitAlarm; interface TransferableResource as RadioToken; + interface ResourceRequested as RadioTokenRequested; interface SuperframeStructure; interface GetNow as IsRadioTokenRequested; interface GetNow as IsRxEnableActive; @@ -741,4 +742,6 @@ implementation command error_t WasRxEnabled.enable() {return FAIL;} command error_t WasRxEnabled.disable() {return FAIL;} + async event void RadioTokenRequested.requested(){ updateState(); } + async event void RadioTokenRequested.immediateRequested(){ updateState(); } } diff --git a/tos/lib/mac/tkn154/DispatchUnslottedCsmaP.nc b/tos/lib/mac/tkn154/DispatchUnslottedCsmaP.nc index 8415c1ba..6be52f45 100644 --- a/tos/lib/mac/tkn154/DispatchUnslottedCsmaP.nc +++ b/tos/lib/mac/tkn154/DispatchUnslottedCsmaP.nc @@ -61,6 +61,7 @@ module DispatchUnslottedCsmaP { interface Timer as IndirectTxWaitTimer; interface TransferableResource as RadioToken; + interface ResourceRequested as RadioTokenRequested; interface GetNow as IsRadioTokenRequested; interface GetNow as IsRxEnableActive; interface Set as SetMacSuperframeOrder; @@ -261,8 +262,9 @@ implementation else if (call IsRadioTokenRequested.getNow()) { if (call RadioOff.isOff()) { // nothing more to do... just release the Token - m_lock = FALSE; // unlock dbg_serial("DispatchUnslottedCsmaP", "Token requested: releasing it.\n"); + call RadioToken.request(); // we want it back afterwards ... + m_lock = FALSE; // unlock call RadioToken.release(); return; } else @@ -518,4 +520,6 @@ implementation command error_t WasRxEnabled.disable() {return FAIL;} default event void MLME_START.confirm(ieee154_status_t status) {} async event void RadioToken.transferredFrom(uint8_t fromClientID) {ASSERT(0);} + async event void RadioTokenRequested.requested(){ updateState(); } + async event void RadioTokenRequested.immediateRequested(){ updateState(); } } diff --git a/tos/lib/mac/tkn154/RadioClientC.nc b/tos/lib/mac/tkn154/RadioClientC.nc index 8aabcf70..a9fd02cf 100644 --- a/tos/lib/mac/tkn154/RadioClientC.nc +++ b/tos/lib/mac/tkn154/RadioClientC.nc @@ -44,6 +44,7 @@ generic configuration RadioClientC(uint8_t clientID) interface SlottedCsmaCa; interface UnslottedCsmaCa; interface TransferableResource as RadioToken; + interface ResourceRequested as RadioTokenRequested; } } implementation @@ -55,5 +56,6 @@ implementation SlottedCsmaCa = RadioControlP.SlottedCsmaCa[clientID]; UnslottedCsmaCa = RadioControlP.UnslottedCsmaCa[clientID]; RadioToken = RadioControlP.TransferableResource[clientID]; + RadioTokenRequested = RadioControlP.ResourceRequested[clientID]; } diff --git a/tos/lib/mac/tkn154/TKN154BeaconEnabledP.nc b/tos/lib/mac/tkn154/TKN154BeaconEnabledP.nc index 26a24c7d..7d7d749a 100644 --- a/tos/lib/mac/tkn154/TKN154BeaconEnabledP.nc +++ b/tos/lib/mac/tkn154/TKN154BeaconEnabledP.nc @@ -403,6 +403,7 @@ implementation DeviceCap.BLEAlarm = Alarm4; DeviceCap.RxWaitAlarm = Alarm5; DeviceCap.RadioToken -> DeviceCapRadioClient; + DeviceCap.RadioTokenRequested -> DeviceCapRadioClient; DeviceCap.SuperframeStructure -> BeaconSynchronizeP.IncomingSF; DeviceCap.IsRxEnableActive -> RxEnableP.IsRxEnableActive; DeviceCap.IsRadioTokenRequested -> PibP.IsRadioTokenRequested; // fan out... @@ -430,6 +431,7 @@ implementation CoordCap.CapEndAlarm = Alarm6; CoordCap.BLEAlarm = Alarm7; CoordCap.RadioToken -> CoordCapRadioClient; + CoordCap.RadioTokenRequested -> CoordCapRadioClient; CoordCap.SuperframeStructure -> BeaconTransmitP.OutgoingSF; CoordCap.IsRxEnableActive -> RxEnableP.IsRxEnableActive; CoordCap.IsRadioTokenRequested -> PibP.IsRadioTokenRequested; // fan out... diff --git a/tos/lib/mac/tkn154/TKN154NonBeaconEnabledP.nc b/tos/lib/mac/tkn154/TKN154NonBeaconEnabledP.nc index fa2d24d2..70f527bc 100644 --- a/tos/lib/mac/tkn154/TKN154NonBeaconEnabledP.nc +++ b/tos/lib/mac/tkn154/TKN154NonBeaconEnabledP.nc @@ -288,6 +288,7 @@ implementation DispatchP.SetMacSuperframeOrder -> PibP.SetMacSuperframeOrder; DispatchP.SetMacPanCoordinator -> PibP.SetMacPanCoordinator; DispatchP.IsRxEnableActive -> RxEnableP.IsRxEnableActive; + DispatchP.RadioTokenRequested -> DispatchRadioClient; DispatchP.IsRadioTokenRequested -> PibP.IsRadioTokenRequested; // fan out... DispatchP.IsRadioTokenRequested -> PromiscuousModeP.IsRadioTokenRequested; DispatchP.IsRadioTokenRequested -> ScanP.IsRadioTokenRequested; diff --git a/tos/lib/mac/tkn154/TKN154_MAC.h b/tos/lib/mac/tkn154/TKN154_MAC.h index 20d4e982..f7544e07 100644 --- a/tos/lib/mac/tkn154/TKN154_MAC.h +++ b/tos/lib/mac/tkn154/TKN154_MAC.h @@ -283,7 +283,7 @@ enum { typedef bool token_requested_t __attribute__((combine(rcombine))); token_requested_t rcombine(token_requested_t r1, token_requested_t r2) { - return r1 && r2; + return r1 || r2; } #ifdef TKN154_DEBUG diff --git a/tos/lib/mac/tkn154/dummies/NoDispatchSlottedCsmaP.nc b/tos/lib/mac/tkn154/dummies/NoDispatchSlottedCsmaP.nc index 67dcc5ba..e2fb0509 100644 --- a/tos/lib/mac/tkn154/dummies/NoDispatchSlottedCsmaP.nc +++ b/tos/lib/mac/tkn154/dummies/NoDispatchSlottedCsmaP.nc @@ -56,6 +56,7 @@ generic module NoDispatchSlottedCsmaP(uint8_t sfDirection) interface Alarm as RxWaitAlarm; interface GetNow as IsRadioTokenRequested; interface TransferableResource as RadioToken; + interface ResourceRequested as RadioTokenRequested; interface SuperframeStructure; interface GetNow as IsRxEnableActive; interface Get as GetIndirectTxFrame; @@ -113,4 +114,6 @@ implementation command error_t WasRxEnabled.enable(){return FAIL;} command error_t WasRxEnabled.disable(){return FAIL;} event void PIBUpdateMacRxOnWhenIdle.notify( const void* val ) {} + async event void RadioTokenRequested.requested(){ } + async event void RadioTokenRequested.immediateRequested(){ } }