>
> On May 9, 2008, at 5:53 AM, Nicole Neureiter wrote:
> > Hi all,
> >
> > I have a problem with two timers in my programm, they seem to cancel
> > each other
> > out. My programm is hierarchical, meaning I have a main programm, in
> > which a
> > Timer should fire periodically. But I have two subprogramms which
> > include also
> > a Timer, that is only called once for Timeouts.
> >
> > __________________
> > Main Programm
> > ------------------
> > | |
> > | |
> > ------- ----------
> > Prog 1 Prog2
> > ------- ----------
> >
> > It seems that everytime the timer in one subprogramm is called my
> > main timer is
> > cancelled.
> >
> > Any ideas?
> >
> > Thanks in advance
> >
> > Nicole Neureiter
>
> Please say what TinyOS version you're using, and can you give snippets
> of the actual code?
>
> My first guess is that you are using TinyOS 1.x and have not wired to
> TimerC correctly (i.e. have used the wrong key to unique()). There are
> a lot of posts about this in the archives, probably from about 2 years
> ago.
>
> Phil
>
Hi,
I'm using TinyOS 2.x with micaz motes and a 510 board. In the following I give
parts of my implementation and configuration.
Configuration of my main file:
configuration ConvergecastAuthC {
provides interface ConvergecastAuth;
}
implementation {
components MainC;
components ConvergecastAuthM as App;
[...]
components new TimerMilliC() as Timer3;//periodic Timer
[..]
components firstphaseC, secondphaseC; //the two called subprogramms
ConvergecastAuth = App;
[..]
App.Timer3 -> Timer3;
App.firstphase -> firstphaseC;
App.secondphase -> secondphaseC;
[..]
}
Implementation:
module ConvergecastAuthM {
provides interface ConvergecastAuth;
uses {
[..]
interface Timer<TMilli> as Timer3;
interface firstphase;
interface secondphase;
}
}
implementation {
[..]
// start following action dependent of message type
//FSM of the programm, from here the subprogramms are called
task void processNextPacket() {
// decide what to do.. and start corresponding function
[..]
case MSG_UPFLOW_INIT:
if((fsmState == IDLE) || (fsmState == UPFLOW))
{
fsmState = UPFLOW;
call firstphase.processUpflowInit();
}
break;
case MSG_UPFLOW_ANSWER: //should only be received and handled by the
aggregator
if ((I_AM_AGGREGATOR) && (fsmState == UPFLOW))
{
call firstphase.processInitialSensorData();
break;
case MSG_SEND_DATA: //should only be received and handled by the
aggrgator
if (I_AM_AGGREGATOR && fsmState == UPFLOW)
{ call Leds.led0Off();
call Leds.led1Off();
call Leds.led2Off();
call secondphase.sendInitialAggregatedData();
}
else dbg("AM", "\t IGNORING\n");
break;
[..] }
// advance to next packet
nextIncPacket = nextIncPacket+1 % PACKET_QUEUE_SIZE;
incPacketsLeft--;
}
[..]
/*****************************************
*
* Timer functions for the aggregator
*
******************************************/
event void Timer3.fired()//aggregator starts one run of upflow phase
{
post send_MSG_UPFLOW_INIT();
call firstphase.processUpflowInit();
}
/********************************
*
* Initialization of the motes
*
*****************************/
event void Boot.booted()//boots the motes
{
if (TOS_NODE_ID == CLUSTER_SINK_ID)
{call SerialControl.start();}//only for the sink
call AMControl.start(); //is done for all nodes+sink
}
[..]
event void SerialControl.startDone(error_t err) { }
event void SerialControl.stopDone(error_t err) { }
event void AMControl.startDone(error_t err) { }
event void AMControl.stopDone(error_t err) { }
}
Subprogramm firstphase:
configuration firstphaseC {
provides interface firstphase;
}
implementation {
components firstphaseM as App;
components new TimerMilliC() as MilliTimer;
[..]
firstphase = App;
[..]
App.MilliTimer -> MilliTimer;
[..]
}
Implementation:
module firstphaseM {
provides interface firstphase;
uses {
[..]
interface Timer<TMilli> as MilliTimer;
[..] }
}
implementation {
[..]
// AGGREGATOR + NODE: process upflow msg, e.g. save upflow-data
command void firstphase.processUpflowInit() {
// extract nodecount and nonce from msg
[..]
if (myRndNonce == UsedRndNonce[count])
{
// init aggregator
if (I_AM_AGGREGATOR) {
// intitialize stuff & timer
nodeCounter = 0;
statFlags.timeOutOccured = FALSE;
verified[count] = FALSE;
// timeout timer
call MilliTimer.startOneShot(TIMEOUT);
// seed list
idList[count][0] = TOS_NODE_ID;
}
// read sensor-data
call Read.read();
}
}
command void firstphase.processInitialSensorData() {
[..]
if (nodeCounter == myNodeCount-1)
// check if we already have all initial values
if (!statFlags.timeOutOccured) { //Millitimer has not fired yet
[..]
call MilliTimer.stop();
} else {
[..]
}
count++;
}
// just set timeOut=TRUE, used by aggregator only
event void MilliTimer.fired() {
statFlags.timeOutOccured = TRUE;
}
[..]
// event is fired by sensor-interface when value-read is done..
event void Read.readDone(error_t result, SensorData_t data) {
[..]
}
}
Nicole
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help