Giter Club home page Giter Club logo

Comments (35)

 avatar commented on May 22, 2024

I have update a new telnet demo, pls have a try.
the heap drops issue, related to LUA gc,
I am trying to find a way to collect mem back in lua machine immediately.
no progress made yet.
collectgarbage("collect") does not work for this issue.

from nodemcu-firmware.

scargill avatar scargill commented on May 22, 2024

Thanks - I will try the telnet .

PLEASE, PLEASE fins a way to fix the heal issue, this is SO near to being GREAT firmware.

from nodemcu-firmware.

scargill avatar scargill commented on May 22, 2024

Erm, whereabouts is the new telnet demo?

from nodemcu-firmware.

 avatar commented on May 22, 2024

telnet2.lua in examples folder
and I put it in README.md, the last one.

from nodemcu-firmware.

scargill avatar scargill commented on May 22, 2024

Hmm, up to now nothing - ConnectBOT on my Android tablet says connecting... nothing happening. I have checked I have an IP address setup and I've dumped in your code.

Connectbot just says "connecting to 192.168.0.22:2323 via telnet" - the IP address is right...

from nodemcu-firmware.

scargill avatar scargill commented on May 22, 2024

Nope - got it to work - it said "Welcome to NodeMci World... So I sent print("Hello") and it died...

Connected to.loft-east.IP:.192.168.0.22
OK

s=net.createServer(net.TCP,180)
s:listen(2323,function(c)

   function s_output(str) 
      if(c~=nil) 
         then c:send(str) 
      end 
   end 
   node.output(s_output, 0)   -- re-direct output to function s_ouput.
   c:on("receive",function(c,l) 
      node.input(l)           -- works like pcall(loadstring(l)) but support multiple separate line
   end) 
   c:on("disconnection",function(c) 
      node.output(nil)        -- un-regist the redirect output function, output goes to serial
   end) 
   print("Welcome to NodeMcu world.")
end)

c_GORSvfJSzfJSzfn
Pete's LUA module 0.1
NodeMcu 0.9.2 build 20141120 powered by Lua 5.1.4

Loading functions
Connecting
Connected to.loft-east.IP:.192.168.0.22
OK

from nodemcu-firmware.

scargill avatar scargill commented on May 22, 2024

And again - rebooted, reloaded the new telnet script - connected "Welcome to NodeMcu World".. I sent back print("hello") and the ESP-01 immediately croaked and rebooted.

from nodemcu-firmware.

 avatar commented on May 22, 2024

How many ram(print(node.heap()) you got when esp-01 started?

from nodemcu-firmware.

 avatar commented on May 22, 2024

and try to send only "enter" to see if it echo ">" back

from nodemcu-firmware.

scargill avatar scargill commented on May 22, 2024

Ok so once I was started up with my init routine etc in there, the heap shows as 18456

On loading your telnet, a call to print(node.heap()) shows 5832

On connecting the tablet..... (it says Welcome top NodeMcu world) if I then try print(node.heap()) again - the board reboots.... so basicalyl doing anything at that point - it reboots..

from nodemcu-firmware.

scargill avatar scargill commented on May 22, 2024

Yes if I hit ENTER only I get a > on the tablet - I can do that many times. But any kind of print - and it reboots.

from nodemcu-firmware.

scargill avatar scargill commented on May 22, 2024

I'm only here for another 10 minutes then will continue again tomorrow night - off to see friends. Quite happy to test this to death until it works if that helps...

from nodemcu-firmware.

 avatar commented on May 22, 2024

change node.output(s_output, 0) to node.output(s_output, 1) to see if there is any output in serial.
this is weird.

from nodemcu-firmware.

scargill avatar scargill commented on May 22, 2024

Ok, made that change...

Loaded the function.

Said print("hi")

Hi came up on the serial terminal.... and then it rebooted.

Welcome to NodeMcu world.

hi
c_GORSvfJSzfJSz.n
Pete's LUA module 0.1
NodeMcu 0.9.2 build 20141120 powered by Lua 5.1.4

Loading functions
Connecting
Connected to.loft-east.IP:.192.168.0.22
OK

from nodemcu-firmware.

scargill avatar scargill commented on May 22, 2024

In case it helps... this is what I have in power up...use your router and pass in place of xxxx and yyyyy

file.remove("init.lua")
file.open("init.lua","w")
file.writeline([[print("Pete's LUA module 0.1")]])
file.writeline([[tmr.alarm(4000, 0, function() dofile("thelot.lua") end )]])
file.close()
file.remove("thelot.lua")
file.open("thelot.lua","w")
file.writeline([[print("")]])
file.writeline([[print("Loading functions")]])
file.writeline([[tmr.stop()]])
file.writeline([[tmr.delay(500000)]])
file.writeline([[connecttoap = function (ssid,pw)]])
file.writeline([[wifi.setmode(wifi.STATION)]])
file.writeline([[tmr.delay(500000)]])
file.writeline([[wifi.sta.config(ssid,pw)]])
file.writeline([[tmr.delay(4000000)]])
file.writeline([[print("Connected to",ssid,"IP:",wifi.sta.getip())]])
file.writeline([[end]])

file.writeline([[function listap(t)]])
file.writeline([[print("")]])
file.writeline([[for k,v in pairs(t) do]])
file.writeline([[print(k.." : "..v)]])
file.writeline([[end]])
file.writeline([[print("OK")]])
file.writeline([[end]])

file.writeline([[print("Connecting")]])
file.writeline([[connecttoap("xxxxxx","yyyyyyy")]])
file.writeline([[print("OK")]])
file.close()

from nodemcu-firmware.

scargill avatar scargill commented on May 22, 2024

I'm out of time - in on Sunday if that helps...happy to test.

from nodemcu-firmware.

lberezy avatar lberezy commented on May 22, 2024

If only this were open source...

from nodemcu-firmware.

alonewolfx2 avatar alonewolfx2 commented on May 22, 2024

telnet.lua and telnet2.lua working for me. i think your problem is heap. i think your functions consuming a lot of memory.

Welcome to NodeMcu world.

->print(node.heap() )
17408

->print(node.chipid() )
9988634

->print(wifi.sta.getip() )
192.168.2.171

from nodemcu-firmware.

scargill avatar scargill commented on May 22, 2024

They may well be but if a couple of subroutines are finishing off the RAM then we are in real trouble.

from nodemcu-firmware.

alonewolfx2 avatar alonewolfx2 commented on May 22, 2024

Lua needs absolutly ram management.

from nodemcu-firmware.

scargill avatar scargill commented on May 22, 2024

And that's what I'm counting on the author to fix.. are you able to help, have any ideas?

from nodemcu-firmware.

scargill avatar scargill commented on May 22, 2024

I just tried the domain name resolution - and that works - but again - heap management is simply not working. I put a memory check on either side and ran the function several times - here's what happened.

print (node.heap())
13200
sk=net.createConnection(net.TCP, 0)
sk:dns("home.scargill.org",function(conn,ip) print(ip) end)
109.170.132.114
sk = nil
print (node.heap())
13088
print (node.heap())
13088
sk=net.createConnection(net.TCP, 0)
sk:dns("home.scargill.org",function(conn,ip) print(ip) end)
109.170.132.114
sk = nil
print (node.heap())
12992
print (node.heap())
12992
sk=net.createConnection(net.TCP, 0)
sk:dns("home.scargill.org",function(conn,ip) print(ip) end)
109.170.132.114
sk = nil
print (node.heap())
12904

I'm losing 80+ bytes every time. How to get that back?

from nodemcu-firmware.

alonewolfx2 avatar alonewolfx2 commented on May 22, 2024

same on me. i pressed wrong key last line and ram always running out

lua: cannot open init.lua
NodeMcu 0.9.2 build 20141124  powered by Lua 5.1.4
> print (node.heap())
21472
> sk=net.createConnection(net.TCP, 0)
> sk:dns("home.scargill.org",function(conn,ip) print(ip) end)
> 109.170.132.114
sk = nil
> print (node.heap())
21072
> print (node.heap())
21072
> sk=net.createConnection(net.TCP, 0)
> sk:dns("home.scargill.org",function(conn,ip) print(ip) end)
> 109.170.132.114
sk = nil
> print (node.heap())
20984
> sk=net.createConnection(net.TCP, 0)
> sk:dns("home.scargill.org",function(conn,ip) print(ip) end)
> 109.170.132.114
sk = nil
> print (node.heap())
20920
> v
>> ei. .
lua: stdin:2: '=' expected near 'e'
> print (node.heap())
20320
> v
>> exit
lua: stdin:2: '=' expected near 'exit'
> print (node.heap())
19744

from nodemcu-firmware.

alonewolfx2 avatar alonewolfx2 commented on May 22, 2024

i think variables can not completely delete and this consuming ram.

> print(node.heap())
21472
> testValue=1
> print(node.heap())
21248
> testValue=nil
> print(node.heap())
21288
> print(node.heap())
21288
> testValue=1
> print(node.heap())
21232
> testValue=nil
> print(node.heap())
21288
> print(node.heap())
21288
> testValue2=1
> print(node.heap())
21232
> testValue2=nil
> print(node.heap())
21288
> 

from nodemcu-firmware.

scargill avatar scargill commented on May 22, 2024

Well, that's interesting isn't it!

from nodemcu-firmware.

alonewolfx2 avatar alonewolfx2 commented on May 22, 2024

intresting and alarming. i am using esp8266 mostly temprature logging operation and i am using deepsleep function. (restarts chip every minute) ram restored every restarts but there must be a solution for ram without restart.otherwise we cant use lua for any project.

from nodemcu-firmware.

scargill avatar scargill commented on May 22, 2024

Exactly - well, setting a variable to NIL gets memory back;

print(node.heap())
11296
print(node.heap())
12968
fred=1
print(fred)
1
print(node.heap())
12904
fred=nil
print(node.heap())
11296

So that's straight forward enough... but it is usually not that straightforward. my socket listener usually uses no RAM at all but if the chain of communication is broken - maybe the socket server stops part way through... I'm losing serious RAM - which means eventually it will die. There are several circumstances where you lose RAM and given there is so little of it this definitely needs fixing.

from nodemcu-firmware.

scargill avatar scargill commented on May 22, 2024

On the other hand - here is how to magic up memory (well, not really but it looks that way)

print(node.heap())
11296
sk=net.createConnection(net.TCP, 0)
sk:dns("home.scargill.org",function(conn,ip) print(ip) end)
109.170.132.114
sk = nil
print (node.heap())
12704

and at around 3k - the interpreter falls over and the card reboots.

from nodemcu-firmware.

alonewolfx2 avatar alonewolfx2 commented on May 22, 2024

what is the problem ? Have you any idea?

> print(node.heap())
19180
> httpserver = function ()
>> srv=net.createServer(net.TCP) srv:listen(80,function(conn)
>> conn:on("receive",function(conn,payload) print(payload)
>> conn:send("HTTP/1.1 200 OK\n\n")
>> conn:send("HTTP/1.1 200 OK\n\n")
>> conn:send("<h1>Served from GWR's ESP8266</h1><BR>")
>> conn:send("NODE.CHIPID : " .. node.chipid() .. "<BR>")
>> conn:send("NODE.HEAP : " .. node.heap() .. "<BR>")
>> conn:send("GPIO0 : " .. gpio.read(8) .. "<BR>")
>> conn:send("GPIO1 : " .. gpio.read(9) .. "<BR>")
>> conn:send("ADC0  : " .. adc.read(0) .. "<BR>")
>> conn:send("</html></body>")
>> conn:on("sent",function(conn) conn:close() end)
lua: not enough memory
> print(node.heap())
7000
>

from nodemcu-firmware.

scargill avatar scargill commented on May 22, 2024

I do... there just isn't enough RAM to do this..wrap it in a file and use dofile to run it... what I don't understand is how you start off with 19k - I don't have anywhere near that amount.

from nodemcu-firmware.

alonewolfx2 avatar alonewolfx2 commented on May 22, 2024

its starting 21k ram. (its new flashed)

> L(Ccd�.b%�H
C@@LJStHDj.@]p
�a.�N|..[*'.C. 0*`�J. Q�
lua: cannot open init.lua
NodeMcu 0.9.2 build 20141124  powered by Lua 5.1.4
> print(node.heap())
21472
> 

from nodemcu-firmware.

 avatar commented on May 22, 2024

the dns api has memory leak problem.
I have push a update to fix it.
thank you guys.

from nodemcu-firmware.

scargill avatar scargill commented on May 22, 2024

Lovely, I've just finished my meetings for this week and an ESP-03 just turned up on my door - I can feel some experimenting coming on in the morning. Thanks for your work.

from nodemcu-firmware.

amancinellib avatar amancinellib commented on May 22, 2024

I'm using firmware 0.9.6 build 20150704 on ESP01 to send data over internet, but each tcp call the heap consumes about 500 bytes.

The code in the alarm is:

conn=net.createConnection(net.TCP, false)
print("init:create="..node.heap())
conn:on(CONST_CONN_RECEIVE, function(conn, pl)
print(pl)
pl=nil
collectgarbage();
end)
conn:on(CONST_CONN_CONNECTION, function(c)
c:send(HTTP_REQ_GET..jsonTemp..HTTP_HEADER)
end)
conn:on(CONST_CONN_SENT, function(conn) collectgarbage("collect") end)
conn:connect(SERVER_PORT,SERVER_IP)
print("init:finishconn="..node.heap())
conn=nil;t=nil;h=nil;
collectgarbage();

from nodemcu-firmware.

TerryE avatar TerryE commented on May 22, 2024

Use a current build. See #719 for comments on 0.96 builds.

from nodemcu-firmware.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.