Page 1 of 1

Rules problem...

Posted: 15 Mar 2019, 01:44
by Shardan
Hi all,
testing with some rules, tested with Mega version mega-20190311
With running into problems i tried an old MegaV2, same result.

Code: Select all

on System#Boot do
   gpio,2,0
   timerset,1,10    //Set Timer 1
enddo

on rules#timer=1 do    //if Timer1 expires
   taskvalueset 5,1,1   //set dummy#var1 to 1
   timerset,2,10   //Set Timer2
enddo

on rules#timer=2 do   //If Timer2 expires
   taskvalueset 5,1,0   //set dummy#var1 to 0  
   timerset,1,10   //Set Timer1
enddo

on dummy#var1 do    //If dummy#var1 changes
   gpio,2,[dummy#var1]  //Set GPIO2 to dummy#var1
enddo
It seems that only the "om System#Boot do" is executed.

The dummy#var1 is set to the last taskvalueset command, GPIO2 is set to that value.
Swapping taskvalueset 5,1,1 and taskvalueset 5,1,0 shows it always remains on the last taskvalueset value.
The timer1/Timer2 sequence should toggle it but does not. I don't see any timer events in the log.

Second problem
The GPIO2 is set to that value only once.
If i manually send a taskvalueset, the "on dummy#var1 do" is not recognized.
By the log the event from dummy#var 1 is generated.
It seems to me that even the "On dummy#var1" is not executed.

What is going wrong? Maybe I'm partially blind again ;)

Re: Rules problem...

Posted: 15 Mar 2019, 02:04
by Shardan
Hello again,

Some more info

The timer-part seems to be a problem with setting the timer value.
With rebooting and external (serial) logger i see the following:

Code: Select all

EVENT: System#Boot
ACT  : timerSet,1,10
ACT  : enddo
ACT  : on Rules#Timer=1 do
ACT  : taskvalueset 5,1,0
ACT  : timerSet,2,10
ACT  : enddo
ACT  : on Rules#Timer=2 do
ACT  : taskvalueset 5,1,1
ACT  : timerSet,1,10
ACT  : enddo
These steps are not executed after 10 seconds but at once.
Seems the "timerSet,1,10" is not correct.

The event on changing "dummy#var1" is generated if I change the value manually:

Code: Select all

EVENT: dummy#var1=0.00 
but the "gpio,2,[dummy#var1] is not executed.

Re: Rules problem...

Posted: 15 Mar 2019, 03:55
by ThomasB
enddo is incorrect syntax. Correct usage is endon.

Revised rules with syntax corrections:

Code: Select all

on System#Boot do
   gpio,2,0
   timerset,1,10       //Set Timer 1
endon

on rules#timer=1 do    //if Timer1 expires
   taskvalueset 5,1,1  //set dummy#var1 to 1
   timerset,2,10       //Set Timer2
endon

on rules#timer=2 do    //If Timer2 expires
   taskvalueset 5,1,0  //set dummy#var1 to 0  
   timerset,1,10       //Set Timer1
endon

on dummy#var1 do        //If dummy#var1 changes
   gpio,2,[dummy#var1]  //Set GPIO2 to dummy#var1
endon

- Thomas

Re: Rules problem...

Posted: 15 Mar 2019, 17:02
by Shardan
Grrrr... 6 weeks away and everything is forgotten..

Many thanks, i knew i was blind....

Re: Rules problem...

Posted: 16 Mar 2019, 17:36
by budman1758
Grrrr... 6 weeks away and everything is forgotten..
They say the first thing that goes is memory....... Can't remember what the second thing was....... :lol: :lol:

Re: Rules problem...

Posted: 16 Mar 2019, 20:30
by Shardan
definitely right, from my own experience......

:D