[Tinyos-help] SPI Resource Help
Eric Decker
cire831 at gmail.com
Mon Dec 22 07:10:27 PST 2008
I'm not sure what version of the code you are looking at but the following
is
from the current T2 tree and it is different. And will return SUCCESS if
the
resource has been appropriately released.
Eric
async command error_t Resource.release[uint8_t id]() {
atomic {
if(state == RES_BUSY && resId == id) {
if(call Queue.isEmpty() == FALSE) {
reqResId = call Queue.dequeue();
resId = NO_RES;
state = RES_GRANTING;
post grantedTask();
call ResourceConfigure.unconfigure[id]();
}
else {
resId = default_owner_id;
state = RES_CONTROLLED;
call ResourceConfigure.unconfigure[id]();
signal ResourceDefaultOwner.granted();
}
return SUCCESS;
}
}
return FAIL;
}
On Mon, Dec 22, 2008 at 1:26 AM, Michiel Konstapel <m.konstapel at sownet.nl>wrote:
> If you dig deep enough, you eventually get down to tos/system/ArbiterP.nc
> which implements the Resource interface:
>
>
>
> async command error_t Resource.release[uint8_t id]() {
>
> atomic {
>
> *if*(state == RES_BUSY && resId == id) {
>
> *if*(call Queue.isEmpty() == FALSE) {
>
> reqResId = call Queue.dequeue();
>
> state = RES_GRANTING;
>
> post grantedTask();
>
> }
>
> *else* {
>
> resId = default_owner_id;
>
> state = RES_CONTROLLED;
>
> signal ResourceDefaultOwner.granted();
>
> }
>
> call ResourceConfigure.unconfigure[id]();
>
> }
>
> }
>
> *return* FAIL;
>
> }
>
>
>
> So basically… it always return FAIL, which I think is a bug.
>
> Michiel
>
>
>
> *From:* tinyos-help-bounces at millennium.berkeley.edu [mailto:
> tinyos-help-bounces at millennium.berkeley.edu] *On Behalf Of *Shaun Lawrence
> *Sent:* vrijdag 19 december 2008 21:02
> *To:* tinyos-help at millennium.berkeley.edu
> *Subject:* Re: [Tinyos-help] SPI Resource Help
>
>
>
> Ok I figured out that the release is happening but for some reason it's
> returning FAIL instead of SUCCESS. Since I am not the owner initially the
> request is handled and granted and after the release led1 is toggled showing
> that I am no longer the owner. If I comment out "call
> SpiResource.release();" then led2 is toggled. So everything is expected but
> for some odd reason the .release() is not returning what I thought.
>
>
>
> Anyone know what might cause this? I am running the telosB.. this request
> is happening on Msp430Spi1.
>
>
>
> Here is the code I am using:
>
> task void release()
>
> {
>
> call SpiResource.release();
>
>
>
> if (!call SpiResource.isOwner())
>
> call Leds.led1Toggle();
>
> else
>
> call Leds.led2Toggle();
>
> }
>
>
>
> event void SpiResource.granted()
>
> {
>
> post release();
>
> }
>
>
>
> async command error_t Spi.convert()
>
> {
>
> if (!call SpiResource.isOwner())
>
> call SpiResource.request();
>
>
>
> return SUCCESS;
>
> }
>
>
>
>
>
> *From:* tinyos-help-bounces at millennium.berkeley.edu [mailto:
> tinyos-help-bounces at millennium.berkeley.edu] *On Behalf Of *Shaun Lawrence
> *Sent:* Friday, December 19, 2008 8:10 AM
> *To:* tinyos-help at millennium.berkeley.edu
> *Subject:* [Tinyos-help] SPI Resource Help
>
>
>
> I'm having a little trouble with the SPI Resources, I need to setup
> arbitration but that will come later. Just need to make sure I can get the
> following to work first.
>
>
>
> First I want to say that only one device is on the SPI bus, the one I'm
> trying to control. So the problem isn't that something else already has
> control.
>
>
>
> I call SpiResource.request() and in turn the SpiResource.granted() is
> called like its suppose to, I have already verified this.
>
>
>
> However, when I try to call SpiResource.release() it's coming back as FAIL
> but I have verified that the SpiResource.isOwner() is coming back as TRUE.
> Does anyone know why the release() is failing?
>
>
>
> Thanks in Advance.
>
>
>
> -Shaun
>
>
>
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help at millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
--
Eric B. Decker
Senior (over 50 :-) Researcher
Autonomous Systems Lab
Jack Baskin School of Engineering
UCSC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20081222/4e14c2af/attachment.htm
More information about the Tinyos-help
mailing list