On Aug 7, 2008, at 3:12 AM, Antonio wrote:
> I need to do the Synchronous Sensor Reading since I have to
> simulate the
> behavior of sensor nodes without split-phase.
> I think I need something like a java wait() or a Thread.sleep()
> method. So I
> can manage split-phase in a component with a read() method like this:
>
> uint16_t newTemperature;
> bool temperatureTaken = FALSE;
>
> uint16_t readSensor(){
> call Sensor.acquireData();
> while(!temperatureTaken){
> call Thread.sleep(10)
> }
> temperatureTaken = FALSE;
> return newTemperature;
> }
>
> And a readDone method like this:
>
> event void Sensor.readDone(){
> newTemperature = call Sensor.getValue();
> temperatureTaken = TRUE;
> }
>
>
> In this example Thread.sleep(10) should be preemptable. I tried with
> BusyWaitMicroC, but it is not preemptable.
>
TinyOS is non-blocking. If the temperature reading takes 250ms to
collect, then you're going to block the entire system for 250ms (and
most probably crash it).
If you want blocking system calls, take a look at TOSThreads, in 2.1.0.
Phil
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help