-->
Page 1 of 1

Crashes using the Ticker lib?

PostPosted: Fri Jan 15, 2016 5:47 pm
by Solexious
Hey,

I tried to add a call to attach the ticker:
Code: Select alltickDMX.attach(1, sendDMX);

in my setup that calls a function:
Code: Select allvoid sendDMX(){
  artnetnode.sendDMX();
}


But adding this attach call causes my esp to reset with this output:

Code: Select allPanic /Users/solexious/Library/Arduino15/packages/esp8266/hardware/esp8266/2.0.0/cores/esp8266/core_esp8266_main.cpp:85 __yield

ctx: sys
sp: 3ffffd20 end: 3fffffb0 offset: 01b0

>>>stack>>>
3ffffed0:  3ffef984 40100ffb 3fff1be0 40203226 
3ffffee0:  40100f35 00000000 402012d0 40202c94 
3ffffef0:  402012e6 00000000 3fff0a78 4020306e 
3fffff00:  3fff0a78 00000184 3ffeee7a 40203778 
3fffff10:  3ffea684 3ffea6a0 00000000 0000033e 
3fffff20:  00000350 3ffee998 3fff0a78 4020290d 
3fffff30:  3ffee998 3ffee998 00000000 40202956 
3fffff40:  0000033a 0018f558 3ffea608 40208838 
3fffff50:  40100d6c 00000000 00000000 60000600 
3fffff60:  005044f3 3ffe8890 3fff1b70 4020180c 
3fffff70:  3fff1b70 4020c03c 3ffe8c2c 4020c049 
3fffff80:  4020c08e 3fffdab0 00000000 3fffdcb0 
3fffff90:  3ffe88a0 3fffdc20 3ffefa24 40202bcb 
3fffffa0:  40000f49 40000f49 3fffdab0 40000f49


If I comment out the call it doesn't crash.

If I try calling sendDMX() just in the loop I don't get the crash...

Any ideas?

Sol

Re: Crashes using the Ticker lib?

PostPosted: Wed Jan 20, 2016 3:55 pm
by damage31
I'm not sure of specifics, but I also was having a very similar (if not the exact) issue. I believe that there is a timing issue of some sort, and basically from what I gather you don't want any long running task to be performed within the method that the Ticker calls. So for me, I ended up just setting a bool flag to true in the ticker method that gets called, then in the Loop it checks that flag to trigger the action.

Re: Crashes using the Ticker lib?

PostPosted: Sat Jan 30, 2016 2:47 am
by Soelden
This is from the ADAFRUIT git rep. Hope it helps

Ticker

Library for calling functions repeatedly with a certain period. Two examples included.

It is currently not recommended to do blocking IO operations (network, serial, file) from Ticker callback functions. Instead, set a flag inside the ticker callback and check for that flag inside the loop function.

Re: Crashes using the Ticker lib?

PostPosted: Sat Jan 30, 2016 6:31 pm
by dancudds
I came across this too and did exactly what the other poster suggested. I have a ticker set a flag and the my loop function is running
Code: Select allif (checktempnow) {
  checktempnow = false;
  doTempcheck();
}