Re: [Tinyos-help] Synchronous ADC read

2006-10-10 Thread R. Steve McKown
Hi Ian,

On Tuesday 10 October 2006 10:42 am, Ian Welch wrote:
> I want the following commands to happen order
>
> call Single.getData(1,0,0,0);
> post sendInfo();

I presume Single is an instance of the Atm128AdcSingle interface, or one 
similar.  The command getData() initiates an ADC operation.  The event 
dataReady() signals back to you when the operation is done.  So, in the 
component where you call Single.getData(), implement the Single.dataReady 
event, and post your sendInfo task from there.  Something like this:

module yourmodule {
  uses 
  provides ...
}
implementation {
  uint16_t ldata;

  task void sendInfo()
  {
/* atomic assignment avoids possible race condition */
uint16_t lldata;
atomic lldata = ldata;
/* do something with lldata */
  }

  command void YourComponent.someFunction() {
call Single.getData(...);
  }

  async event void Single.dataReady(uint16_t data, ...) {
ldata = data; /* save a local copy of the returned result */
post sendInfo();
  }
}

There's almost always good code examples to be found in the apps/ directory of 
the tinyos distribution that can be helpful.

Steve
___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


[Tinyos-help] Synchronous ADC read

2006-10-10 Thread Ian Welch
I want the following commands to happen ordercall Single.getData(1,0,0,0);post sendInfo();the sendInfo() task uses the reading from the previous ADC command. How do I make it so post sendInfo() doesn't get executed until my ADC  reading has occurred, without posting the task in 
Single.dataReady? Do I need an atomic statement somewhere?Thanks.
___
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help