[Tinyos-help] Problems with readToneDetector()

Philip Levis pal at cs.stanford.edu
Tue Apr 3 09:18:12 PDT 2007


On Mar 28, 2007, at 2:38 AM, Jorge Grande wrote:

> Hello everybody,
>
> I'm using TinyOS 2.0 and I'm trying to write an application for two  
> micaz motes using the microphone.  One of the two motes (mote 1)  
> will beep each 1000 ms and the other one (mote 2), once it has  
> detected the tone, will toggle the green led (if it doesn't detect  
> the tone, it will turn one the red led). This mote checks every 50  
> ms if the tone has been detected; I'm using  command startPeriodic  
> including in tos/lib/timer and command readToneDetector including  
> in tos/sensorboards/mts300/MicSetting.nc.
>
> Here is part of the mote 2 application:
>
> ...
>
> event void Timer.fired() {
>   if (call MicSetting.readToneDetector() == 0)  //tone has been  
> detected
>    {call Leds.led1Toggle();}
>   else  // tone has not been detected
>    {call Leds.led0On();}
>  }
>
>
> async event error_t MicSetting.toneDetected() {
>   return SUCCESS;
>  }
>
> ...
>
>
> The problem is that mote 2 is continuously toggling the green led,  
> even if mote 1 is not beeping but I don't know why.
>
> Can anyone help me?
>

I'd email the folks who wrote the drivers; I'm not sure they all  
ready tinyos-help regularly. It looks like the driver is just  
checking an interrupt line when it does this test. Looking at the  
code, it seems like it just returns 1 when the line is high and 0  
when it's low... which suggests that the documentation of the return  
value is incorrect. Does the LED toggle when there is a tone, or does  
it stop toggling?

Phil


More information about the Tinyos-help mailing list