-->
Page 1 of 1

Button sting

PostPosted: Tue Apr 19, 2016 1:15 pm
by Electroguard
This bug stings like a wasp! - and took ages to pin down cos it causes continued crashing and reboots (cicciocb's gpio00 button to prevent autorunning has been worn out!).

To cut a long story short, I suspect there's a problem when trying to use more than 10 BUTTONs.

I've included the script I was working on (Alpha 13) which shows the problem in case it doesn't ring any bells, and there's an explanation of things embedded in the script.

I'm not looking for any problem get-arounds B.T.W. cos that's not the point of sending the script (and it's already been hacked to destruction from chasing down the pest anyway) - it's purely to demonstrate the problem.

I've pinned it down to being a >10 button problem by commenting out any one of the scripts earlier buttons, and then the original 'problem' button no longer causes a crash. And it is button specific, because commenting out a Textbox doesn't make any difference to the button crashing... but it's worth mentioning that if the cause IS because of using more than 10 buttons which aren't being handled properly, then perhaps the same >10 problem may exist for some of the other web components as well.


Code: Select allmemclear
'let getstat = 66
let getvol = 67
'let geteq = 68
let getloop = 69
'let getver = 70
'let getsd = 71
let getfl = 73
let getdir = 83
let getind = 75
let getsecs = 80
let getlen = 81
let getname = 82
let vstart = 126 'Serial command start byte
let vlen = 2
let vend = 239 'Serial command end byte
let vplay = 13
let vreset = 12
let vpause = 14
let vnext = 1
let vprev = 2
let vup = 4 'not used
let vdown = 5 'not used
let vset = 6
let vol = 15
let vdirfile = hextoint("12")
let vdir = 1
let vfile = 1
let vloopmode = hextoint("11")
let vloop = 0 
' 0/1/2/3/4 for All/Folder/One/Ram/One_Stop
let vdchange =  hextoint("0F")
let vdnext =  hextoint("01")
let vdprev =  hextoint("00")
gosub [reset]
button "<" [prev]
button "Play" [play]
button "Pause" [pause]
button ">" [next]
html "<BR>"
html "<BR>"
textbox "vfile"
textbox "vdir"
button "Jump" [track]
html "<BR>"
html "<BR>"
'html hextoint("11")
html "<BR>"
html "<BR>"
slider "vol" 0 30
button "Set Volume" [setvol]
html "<BR>"
html "<BR>"
textbox "vloop"
button "Loop mode" [vlmode]
html "   0/1/2/3/4 for All/Folder/One/Ram/One_Stop"
html "<BR>"
html "<BR>"
button "Next Folder" [dnext]
button "Prev Folder" [dprev]
html "<BR>"
html "<BR>"

' ************************
' EITHER of these 2 buttons are ok by themselves, but uncommenting BOTH always causes a crash !!!
' Crash-recovery is a matter of commenting-out a button again, and waiting for esp reconnection after one of the
' reboots, then do a Save. If the save is speaking to deaf ears, just wait for reconnection again, then Save quicker!

'button "Get name" [getn]
button "Get volume" [getv]
' ************************

end ' *** This END is to prove that the problem isn't being caused but something after the buttons ***

html "<BR>"
html "<BR>"
[loop]

'serialbranch [serialin]
wait

[getn]
'serialprintln chr(vstart) & chr(2) & chr(getname) & chr(vend)
goto [loop]

[getv]
'serialprintln chr(vstart) & chr(2) & chr(getvol) & chr(vend)
goto [loop]

[serialin]
html "received:"
return



[dnext]
serialprintln chr(vstart) & chr(3) & chr(vdchange) & chr(vdnext) & chr(vend)
goto [loop]

[dprev]
serialprintln chr(vstart) & chr(3) & chr(vdchange) & chr(vdprev) & chr(vend)
goto [loop]

[vlmode]
serialprintln chr(vstart) & chr(4) & chr(vloopmode) & chr(vdir) & chr(vloop) & chr(vend)
goto [loop]

[track]
serialprintln chr(vstart) & chr(4) & chr(vdirfile) & chr(vdir) & chr(vfile) & chr(vend)
goto [loop]

[setvol]
serialprintln chr(vstart) & chr(3) & chr(vset) & chr(vol) & chr(vend)
goto [loop]

[play]
serialprintln chr(vstart) & chr(vlen) & chr(vplay) & chr(vend)
goto [loop]

[pause]
serialprintln chr(vstart) & chr(vlen) & chr(vpause) & chr(vend)
goto [loop]

[next]
serialprintln chr(vstart) & chr(vlen) & chr(vnext) & chr(vend)
goto [loop]

[prev]
serialprintln chr(vstart) & chr(vlen) & chr(vprev) & chr(vend)
goto [loop]

[volup]
serialprintln chr(vstart) & chr(vlen) & chr(vup) & chr(vend)
goto [loop]

[voldown]
serialprintln chr(vstart) & chr(vlen) & chr(vdown) & chr(vend)
goto [loop]

[reset]
serialprintln chr(vstart) & chr(vlen) & chr(vreset) & chr(vend)
return


Re: Button sting

PostPosted: Tue Apr 19, 2016 7:38 pm
by Mmiscool
All of the web componets (buttons, text boxes, dropdowns, list boxes and sliders) are limited to 10 a peice currently. Also only one graphics area can be added.

This has been the limit since day one how ever it might be time to lift it.

Re: Button sting

PostPosted: Tue Apr 19, 2016 9:06 pm
by Electroguard
Or at least try to flag it without crashing.
But perhaps capping them, and var name lengths, to 20 would ease those sutuations for now.

Re: Button sting

PostPosted: Tue Apr 19, 2016 10:26 pm
by Electroguard
Still something keeping me awake...

I didn't know about the 10 button limit from day1, and it certainly caught me out with this, but in the previous udp framework script I posted due to the var name cap of 10...

http://www.esp8266.com/viewtopic.php?f=39&t=9564&start=4

... that script has 20 TWENTY BUTTONS (all listed below) which ALL worked! and without any crashing or reboots. In fact until the var name length was reduced things were progressing quite nicely.
Go figure.

button "?" [intro]
button "Blink 5" [blink5] ' blinks the led 5 times for quick visual location
button "Blink 99" [blink99] ' blinks the led 99 times long enough to hunt for it
button "Blink IP" [blinkIP] ' blinks the last IP bytes digits
button "Spare" [button] ' spare test button, currently just triggers [blinkIP]
button "Exit" [exit] ' shut down the node
button "Reset" [reset] ' reboot the node
button "Home" [home]
button "Intro" [intro]
button "Party" [party]
button "Yummy" [yummy]
button "How2" [how2]
button "Plus" [plus]
button "Ideas" [ideas]
button "Bugs" [bugs]
button "Confirm" [blink]
button "Cancel" [home]
button "Save" [save] ' save details to persistent memory
button "Cancel" [home] ' don't save edits
button "Send" [broadcast] ' broadcast the message