You post a task to release the resource but at the same time have a
periodic timer that requests it, so there is a race condition (your
task can release it just after you requested it and you'll not get a
granted). The idea of the Resource interface is that while you want to
access the resource you must own it (must have been granted it). After
you are finished accessing the resource you can release it. The right
place for calling release is often in dataReady() when you're done or
in granted() when something with the configuration fails. In your case
if your component is the only client to the ADC then you can call
Resource.request() in Boot.booted(), continue in granted() and never
worry about the Resource interface again (ie. no need to call
release()).

Jan

On Wed, Mar 26, 2008 at 3:18 PM, Sandip Bapat <[EMAIL PROTECTED]> wrote:
>
>
>
>
> Hi
>
> I am using MultiChannel sampling on the msp430 ADC as shown in
> tinyos-2.x/apps/tests/msp430/Adc12. When I run the program, it runs
> correctly for a non-deterministic length of time (sometimes minutes,
> sometimes a day) and then appears to be stuck. Debugging with LEDs and UART
> shows that the timer for sampling continues to fire, but the
> Resource.reserve call returns an EBUSY error type after this time and no
> more granted events are signalled.
>
> Also, there's no other ADC client in my application. I only use the timer,
> UART and this ADC getData call. The MultiChannel interface is wired to the
> Msp430Adc12ClientAutoRVGC component. I've seen this happen for sampling
> rates of 1kHz down to 167 Hz, but haven't tested for lower sampling rates.
>
> The code I am using looks like this
>
> event Timer.fired(){                      // this fires every 6ms
>     result = call Resource.request();    // returns SUCCESS upto some
> non-deterministic time, during which Resource is granted and I can read ADC
> correctly, after which always returns EBUSY, no more Resource.granted events
> are signalled
> }
>
>
>
> task void releaseResource(){
>
>     call Resource.release();
>
> }
>
>
>
> task void processData(){
>
>     .. send samples to UART
>
> }
>
>
> event Resource.granted(){
>     if (MultiChannel.configure(&config, &memCtl, 1, buffer, BUFFER_SIZE, 0)
> == SUCCESS)
>
>         if (call MultiChannel.getData() != SUCCESS)
>
>             post releaseResource();
>
>     else
>
>         post releaseResource();
>
> }
>
>
>
> event MultiChannel.dataReady(bufptr){
>
>     call Resource.release();
>
>     ...make local copy;
>
>     post processData();
>
> }
>
>
>
> If anyone has observed this or notices something I'm doing wrong, please let
> me know.
>
>
>
> Thank you
>
> Sandip
>  ________________________________
> Looking for last minute shopping deals? Find them fast with Yahoo! Search.
> _______________________________________________
>  Tinyos-help mailing list
>  [email protected]
>  https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to