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: [email protected]
[mailto:[email protected]] On Behalf Of Shaun
Lawrence
Sent: vrijdag 19 december 2008 21:02
To: [email protected]
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: [email protected]
[mailto:[email protected]] On Behalf Of Shaun
Lawrence
Sent: Friday, December 19, 2008 8:10 AM
To: [email protected]
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
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to