-->
Page 1 of 1

Soft WDT reset while evaluating complex instructions

PostPosted: Sat May 07, 2016 5:27 pm
by psc-esp8266
As soon as you combine 'simple' statements into one more complex one the interpreter seems to crash with a 'soft WDT reset'.

The following programm:
t = "01:00"
offset = -2

a = (offset+val(mid(t,1,2))+24)%24
t = right("0" & str(a),2) & mid(t,3,8)

evaluates correctly into t="23:00"

but if you substitute the formula for 'a' directly into the formula for 't' like
t = right("0" & str((offset+val(mid(t,1,2))+24)%24),2) & mid(t,3,8)
the ESP crashes and reboots:
Executing line Debug Statement
16 t = right("0" & str((offset+val(mid(t,1,2))+24)%24),2) & mid(t,3,8)
t
=
right(0
&
str((offset+val(mid(t,1,2))+24)%24),2)
&
Executing line Debug Statement
17 print a
Soft WDT reset

ctx: cont
sp: 3fff2220 end: 4021d735 offset: 01b0

>>>stack>>>
3fff23d0: 3fff2420 00000002 3fff2484 40228b4e
3fff23e0: 3ffe8d4c 0000000a 3fff2484 4021e002
3fff23f0: 3fff2654 00000000 3ffe9778 402280ec etc.

I didn't examine the code but I suspect reloading the WTD at each parsed keyword instead of each statement would solve the problem.

Re: Soft WDT reset while evaluating complex instructions

PostPosted: Mon May 23, 2016 8:40 am
by Sailplane
I had a very similar issue using the library function tft.fillscreen (color) which is a very slow function. Apparently it is so slow that the Watch Dog Timer (WDT) is set off, thinking that the processor has been put into a "hungup" state. So the timer goes off and resets the device. I placed the Arduino function yield() after each tft.fillscreen() function and it allowed the system to do other things before moving onto the next tft.fillscreen.

So try calling yield() after / before your complex formula. Alternatively, you could try disabling the Watch Dog Timer temporarily and then renabling it. I have not done the latter however.

Re: Soft WDT reset while evaluating complex instructions

PostPosted: Fri May 27, 2016 8:22 am
by cicciocb
The problem is not related to missing delay(0) or yield() inside the code.
It's simply a memory overflow when the expression is too complex.
This is a limitation of the current parser.