A Basic Interpreter written from scratch for the ESP8266

Moderator: Mmiscool

User avatar
By forlotto
#54022 I believe you can only go to a routine something like 250 times without the use of a return and it will cause an error if there is no return if I recall correct in speaking with the developer.

It is quite possible that you may need to use a return.

Seems as if you are checking an awful lot for that little chip that could to be rather honest every 20 seconds to see if your providers modem is hanging if it is hanging that much you surely have an issue on your hands. Often your providers modem has an ip from which you can access it and view a live status of your connection to see things like this. Makes me wonder if you are sure it is not a cable issue often times cat5 cables go bad and visibly you would never be able to tell that they are bad. There are tools that help test this the best is a TDR ususally quite expensive though. Anyhow other things that go bad are the coax cable end if you have cable not uncommon to have to replace this end after a few years of service. Happened rather often with my satellite dish as well years ago.

Anyhow cat5 cables are a culprit in a network issue more than you know get new cable and test also NIC cards are good for going bad as well what happens is they will work and not work and work and not work it will seem as if they are good to the average computer tech without extensive testing. The options are a plenty for troubleshooting your issue.

It is good practice to power cycle your modems and routers every so often just like your computer things hang from time to time you can automate this process daily if you wished with a nodemcu. That may help things as well with a relay.

Anyhow best of luck to you try and add some returns to your subs and see how you fair from there.

forlotto
User avatar
By aphawk
#54049 Forlotto,

Thanks for your reply.
There are no problems with cables. The problem is with the modem... heat a lot, the provider has replaced two times, and keeps hanging one or two times each week. And because the modem is located far from my room, I made this project to make the remote reboot.

I made some research in all Fórum, and seems that really can have some problem with buffers.
And I learn many new tricks...

Then, I rewrote the program, and now this is running for more than 16 hours without any problem, using the HTMLVAR and the RETURNGUI.

Follow the actual code that is working well :

Code: Select allmemclear
cls
testes = 0
treb = 0
erro = 0
terros = 0
ct = "          "
tipo = "ON"
io(po,2,0)
wprint |<HTML>|
wprint |<HEAD>|
'wprint |<meta http-equiv='refresh'content='10;URL=/input?'>|
wprint |<font color="blue">|
wprint |<h2>STATUS INTERNET</h2>|
wprint |</HEAD>|
wprint |<body bgcolor="white">|
wprint |<font color="black">|
wprint "<br>"

button "Turn OFF", [desligar]
button "Turn ON", [ligar]
wprint "<br>"

wprint "Modem: "
wprint htmlvar(tipo)  ' status
wprint "<br>"

wprint "Time : "
wprint htmlvar(ct)  ' data e hora
wprint "<br>"

wprint "Tests made : "
wprint htmlvar(testes)  ' total de testes
wprint "<br>"

wprint "Simple fails : "
wprint htmlvar(terros)  ' total de erros
wprint "<br>"

wprint "Total Reboots: "
wprint htmlvar(treb)  ' total de reboots
wprint "<br>"

timer 30000, [update]

wait
end


[update]
testes = testes + 1
' Get ASCII time string
Traw = wget("tycho.usno.navy.mil/timer.html")

' Search for marker so we know where to trim
p = instr(Traw,"Universal Time")

' Get formatted string for "Eastern Time" formatted properly
time = mid(Traw,p + 19,24)

If p < 100 then
  ct = ct
  terros = terros + 1
  erro = erro + 1
else
  ct = time
  erro = 0
endif

if erro > 3 then
  timer 0
  gosub [reconecta]
  timer 20000 , [update]
  erro = 0
  treb = treb +1
endif
returngui
wait

[reconecta]
tipo = "OFF"
returngui
io(po,2,1)
delay 5000
tipo = "Waiting Resync"
returngui
io(po,2,0)
delay 300000
tipo = "ON"
return

[desligar]
tipo = "OFF"
io(po,2,1)
returngui
wait

[ligar]
tipo = "ON"
io(po,2,0)
returngui
wait



Thanks for your support !

Paulo
User avatar
By livetv
#57484 I agree that using WGET() is a good way to go. I am using it to test an auto-connect feature for those times when the ESP8266 gets disconnected from the router. My code is similar to yours except that it assumes that a failed page load is due to connection with the router, not a modem hang-up. Still, mine has run continuously for about 2 weeks with no trouble and has done re-connects when the router is wakened each morning.

Let's try to isolate a memory management problem. Add a meter to your output at line 3, after the CLS like this:

freeMem = ramfree()
meter freeMem, 0, 25000

Now put this line after your [update] label:

freeMem = ramfree()

Now you should be able to monitor your memory use.

If you see free memory disappearing, you should think about what is using it up. I'll have to look into how the returngui works and what happens to anything in a queue when the wait command is encountered but that would be the first place I'd look. Doesn't seem to me that this should be a problem. I *can* say that in my code, once I print initial reports via WPRINT() I don't send anything else to the browser. I do use a meter for something else, so I can assure you that web sockets are not a problem.
User avatar
By livetv
#57485 Another thought occurs to me. I have an ESP8266 reporting to my web server every minute. It worked very well for a long time and then it began reporting only once every few minutes. It still reported correctly, just not as often. What I discovered was a bug on my web server which was causing a very large amount of page content to be returned to the ESP8266. Since this unit was thousands of miles away, I couldn't debug on that end, but when I fixed the bug on the server, reporting resumed at once per minute.

My theory is that the large page returns were consuming all available RAM, causing a reset. Upon reset, my node reconnected to the router and auto-ran the basic program as per normal startup procedure (taking a couple minutes to do it).

Could this be happening in your case? Try a web site that returns a small amount of data.