Anomalia

Spazio dedicato agli utenti Italiani
Post Reply
videobelu
Posts: 73
Joined: Fri Feb 12, 2021 4:25 pm
Location: Villar Perosa
Has thanked: 140 times
Been thanked: 16 times

Anomalia

Post by videobelu »

Buonasera volevo segnalare una cosa anomala che succede al mio sistema che e' attivo 24 ore su 24.
E' un modulo ESP32 ma prima utilizzavo un ESP8266 e il problema si manifestava lo stesso.
In pratica il mio sistema funziona correttamente e senza problemi per 10 /20 giorni poi improvvisamente si "addormenta"
cioe' non e' piu' raggiungibile la sua interfaccia web e lui non risulta connesso neanche facendo uno scanner della rete.
La prima cosa strana e' che in questo caso non e' nemmeno presente la modalita' AP con la sua rete ESPXXX.
In pratica l'unica cosa da fare e' resettare tramite il pulsantino del board ESP32, in questo modo tutto riprende a funzionare correttamente.
Per cercare di ovviare a questo problema ho inserito nel programma sia il Whatchdog che anche un reboot
ogni 6 ore ma sembra che non servano a nulla.
La prima cosa che volevo sapere era proprio inerente al reboot....mi pare di capire che il comando non ha
la stessa "efficacia" del reset hardware...non c'e altro modo di effetture un riavvio che "pulisca" tutto???


Grazie
Fabrizio
Fabrizio Bellini
User avatar
Electroguard
Posts: 836
Joined: Mon Feb 08, 2021 6:22 pm
Has thanked: 268 times
Been thanked: 317 times

Re: Anomalia

Post by Electroguard »

Hi Fabrizio,

You did not say if you maintain contact with the device(s), or only connect momentarily occasionally.
It is important because if browser connection is maintained continuously it will eventually cause problems from the browser itself, eg: any web-socket connections will cause the javascript to 'tangle up' over time.

My Annex devices (esp8266 and esp32) are running 24/7 without problems because I only connect to them when needed then disconnect again.

Another consideration is some form of memory leak eventually causing Annex to fail from lack of memory.
My Sentry Alarm includes a Log Server which records date+time-stamped events to file, so the growing text would eventually eat up all available memory and cause problems if left unattended.
Other activities temporarily uses memory which doesn't necessarily all get freed up again after. That's why I often include a 'memory monitor' to quickly keep an eye on how much memory is still available... if you look at "The Thing" project https://sites.google.com/site/annexwifi ... lar-system you will see it includes a 'dev' option to display the memory in green above a chosen threshold value which changes to red when dropping below the threshold value. As well as changing colours the value could easily instigate a reboot when it drops below a preset value if wished.
I haven't tried running the code excerts below, I've simply hacked them out of the Sentry for your ease of access...

lowmem=140000 'for 4Mb ESP32
mem$=""
timer0 1000, heartbeat
html textbox$(mem$,"mem")+" MEM free<br>"
wait

heartbeat:
mem$=str$(ramfree) 'used for development diagnostics
if val(mem$)<lowmem then css CSSID$("mem","color:darkred;") else css CSSID$("mem","color:darkgreen;")

t$=time$
hour$=word$(t$,1,":"): mins$=word$(t$,2,":"): secs$=word$(t$,3,":")
hour=val(hour$)
if (hour=1) and (mins$="30") and (val(secs$)<10) then pause 9000: reboot
return


But I decided the best and simplest solution was just to schedule a nightly reboot, which allows the device to continue unattended indefinitely. A scheduled 'de-clutter' reboot need not prevent anything important from being saved to file first (such as total number of event triggers) and then read back again afterwards.


So in summary, 2 things that might keep your devices running indefinitely...
Never stay connected to a device
Schedule nightly reboots
videobelu
Posts: 73
Joined: Fri Feb 12, 2021 4:25 pm
Location: Villar Perosa
Has thanked: 140 times
Been thanked: 16 times

Re: Anomalia

Post by videobelu »

Grazie mille per la risposta Electroguard ....io non sono connesso al modulo ESP32 ma lui riceve regolarmente dei messaggi da Domoticz (su raspberry) ogni pochi secondi mediante comandi (UrlMsgGet$) e a sua volta di tanto in tanto manda dei comandi (wget$) ad un altra periferica.
Per il reboot io lo eseguo ogni 6 ore ma comunque di tanto in tanto come dicevo il sistema si blocca.
Evidentemente il reboot non serve a resettare completamente il modulo.

Fabrizio
Fabrizio Bellini
User avatar
dMajo
Posts: 5
Joined: Thu Apr 08, 2021 5:42 pm
Has thanked: 2 times

Re: Anomalia

Post by dMajo »

Ciao Fabrizio,
non credo che il reboot non faccia a fondo il suo dovere. Probabilmente l'esaurimento della memoria disponibile a cui fa riferimento Electroguard non avviene in modo lento e progressivo (10/20gg). Forse accade in maniera rapida (meno delle 6 ore di reboot) ma sporadicamente (ogni 10/20gg). Forse è qualche ramo del programma che viene eseguito occasionalmente al verificarsi di certi eventi. Magari contenete un loop dinamico o chiamate annidate che allocano lo stack.

Se logghi in qualche modo l'attività converebbe forse esaminare gli eventi accaduti immediatamente prima del blocco e poi verificare la parte del codice che gli gestisce.

Dario
Annex WiFi RDS [Local Link Removed for Guests]
[Local Link Removed for Guests] [Local Link Removed for Guests]
videobelu
Posts: 73
Joined: Fri Feb 12, 2021 4:25 pm
Location: Villar Perosa
Has thanked: 140 times
Been thanked: 16 times

Re: Anomalia

Post by videobelu »

Grazie Dario, pensavo in effetti di analizzare ancora bene dove puo' nascere il problema.
La cosa che mi lascia un po' perplesso e' il fatto che il watchdog non intervenga mai .
Quando il sistema si riavvia mi comunica via Telegram il codice BAS.RESETREASON che e' sempre 12 quindi non interviene mai il whatchdog.
Un altro test che eseguo in diversi punti del programma e' la presenza della rete

While WIFI.STATUS <> 3
pause 500
wend

anche questo in presenza di problemi di connessione dovrebbe provocare un reboot tramite il watchdog......ma non succede mai.
Lo stato di "coma" in cui trovo il modulo non mi permette di intervenire in altro modo se non un reset hardware.

Comunque proseguo con le mie verifiche
Grazie a tutti per i consigli

Fabrizio
Fabrizio Bellini
Post Reply