B4R Question ESPUI trouble: MCU is loop rebooted

peacemaker

Expert
Licensed User
Longtime User
HI, All

Strange, but i'm using few controls on a web-page of ESPUI, but the MCU is rebooted sometimes.
Trouble is fore sure in "setUpUI" sub.
Each control event is in separated sub.
If to stop updating timer - no any help.
Texts of the controls are non-latin, and rather long.

Error is like:
Guru Meditation Error: Core 1 panic'ed (Unhandled debug exception).
Debug exception reason: Stack canary watchpoint triggered (async_tcp)

Any ideas ?
 

peacemaker

Expert
Licensed User
Longtime User
Errors are starting when start to navigate along the web-interface in a browser.

Stack canary watchpoint triggered (async_tcp)

It is something about web-engine work, i guess.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
I have prepared the test project with all my interface (removed all other code for sensors), 17 views in the interface, 10 are updatable - it's the same trouble - lopped restart.
@candide, did you wrap what ESPUI lib version ? Or any is OK for B4R lib?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Test project, please, try to start at your side and click "Save" button in the interface.
The views are partially commented now, but if to uncomment - even worse...
 

Attachments

  • espui_test2.zip
    9.2 KB · Views: 47
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
All the day - the most stupid process:
  1. Get the good working example code
  2. Add into it my additions (that work with trouble)
  3. Make sure that all together is OK !
  4. Comment something to be revoved
  5. Test the working: if OK - backup project version and go next
  6. If trouble - uncomment back - and try to comment something more.
No idea how to debug another way if "panic" loop boot.
But process is goin on, it seems, it can work OK, if all is to be made exactly correct.
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
All controls can be deleted, excepting:
B4X:
    UI.addControl_CB(UI.ControlTyp_Button, "Button", "Button", UI.Controlcol_Alizarin, maintab, 19)                        'paramCallback ********************
    '19--> paramCallback
   
             
    '//Add the invisible "Time" control
    mainTime = UI.addControl_cb(UI.ControlTyp_Time, "", "", UI.Controlcol_none,0,0)

    '//Request an update To the time
    '//Will trigger timeCallback
    UI.addControl_CB(UI.ControlTyp_Button, "Get Time", "Get Time", UI.Controlcol_Carrot, maintab,11)        'gettimeCallback
    '11 --> gettimeCallback
   
    UI.addControl_CB(UI.ControlTyp_Button, "Set Time", "Set Time", UI.Controlcol_Carrot, maintab,7)         'settimeCallback
    '7 --> settimeCallback

If to delete it = device is loop rebooted. Nonsense !
But WHY?!11
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
And finally, the cleaned example is anyway making the MCU loop rebooted in the full project code. Nevertheless just 88% of the memory is used. But ...
  1. Each control type that is used in the interface MUST HAVE the callback in OnExtendedCB sub (excepting Labels), including the ControlTyp_Time.
  2. Auto-updating controls during callback subs must be temporarily disabled.
  3. Do not use any Delay(x)
  4. Declare most long text statical in Process_Globals
Something like this:
Private Sub OnExtendedCB(ControlId As UInt, ControlType As Byte,ControlLabel As String, ControlValue As String, eventType As Int, userData As ULong)
    If ControlType <> 20 Then
        Main.SDlog(Array As String("ControlId=",ControlId," ControlType=",ControlType, " ControlLabel='",ControlLabel, "' ControlValue='",ControlValue, "' eventType=", eventType, " userData=",userData))
    End If
    timUpdate.Enabled = False
    Select ControlType
        Case UI.ControlTyp_Title         '0
       
        Case UI.ControlTyp_pad              '1

        Case UI.ControlTyp_PadWithCenter '2

        Case UI.ControlTyp_Button        '3
            If userData = 7 Then setTimeCallback(ControlId, ControlType, ControlLabel, ControlValue, eventType, userData)
            If userData = 11 Then getTimeCallback(ControlId, ControlType, ControlLabel, ControlValue, eventType, userData)
            If userData = 19 Then paramCallback(ControlId, ControlType, ControlLabel, ControlValue, eventType, userData)

            If userData = 100 And eventType = UI.CBEvent_B_DOWN Then saveTimeCallback 'save time
            If userData = 101 And eventType = UI.CBEvent_B_UP Then saveFlugCallback 'save flug calib
            If userData = 15 And eventType = UI.CBEvent_B_UP Then saveWiFiCallback
        Case UI.ControlTyp_Label        '4

        Case UI.ControlTyp_Switcher        '5
            If userData = 103 Then APswitcherCallback(ControlId)
        Case UI.ControlTyp_Slider        '6
            SlidersCallback(ControlId, ControlType, ControlLabel, ControlValue, eventType, userData)
        Case UI.ControlTyp_Number        '7

        Case UI.ControlTyp_Text            '8
            If userData = 13 Then textCallback(ControlId, ControlType,ControlLabel, ControlValue, eventType, userData)
            If userData = 14 Then textCallback(ControlId, ControlType,ControlLabel, ControlValue, eventType, userData)
    End Select
    timUpdate.Enabled = True
End Sub

... but finally works with the requirements above, if to remove part of the controls.

It's rebooting if just to swap some code lines ! Non-usable...
 
Last edited:
Upvote 0

candide

Active Member
Licensed User
did you try to extend stack size ?

- i checked your code ESPUItest : without modification, i have restart of cpu when i click on SAVE

- if i extend stack to 2600 (for test) no reset when i click SAVE button

can you check if it is your problem ?
 
Upvote 0

candide

Active Member
Licensed User
before your code you have, on head B4R :

#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 600 ------>2600
#End Region
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Ah, it's in the test project.
I mean my full project is not OK with 3100 stacksize.

Now tested 5000. No.

If you uncomment all other controls in my test project - does it work at you ?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Now tried #StackBufferSize: 8000 !!111
Anyway at web-browser Refresh page click - MCU is booted.

Further browser makes auto-reconnect and page works, but ... refresh kills it.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
If #StackBufferSize: 10000 - the same, reboot at web-page refresh.
Now i think the reason is not in the stack.

p.s. 50000 !!!! - no help.
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
What about if to refresh the web-page in browser ?
Now all my controls work,, when self-rebooting is finished and browser is restored connection.

But before with small controls qty - it was refreshed OK, without rebooting...
So, the reason is not found yet.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
@candide
What are dependencies lib versions do you have installed in Arduino ?
AsyncTCP and ESPAsyncWebServer

Error is always about: "Debug exception reason: Stack canary watchpoint triggered (async_tcp)"

Seems, there is workable variant:
ESP Async WebServer 3.0.6
AsyncTCP 1.1.1

if the callback is fast. But how to run a long sub at any interface button ?
 
Last edited:
Upvote 0
Top