Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current issues #1

Closed
scargill opened this issue Nov 21, 2014 · 35 comments
Closed

Current issues #1

scargill opened this issue Nov 21, 2014 · 35 comments

Comments

@scargill
Copy link

Current issues I'm aware of.. the latest http: server demo, every time it is used, the heap drops - starting at 6k and dropping eventually to 3k at which point the board reboots. The heap management needs sorting other wise any kind of fast polling (remote phone monitoring of output state or similar) would be impossible.

Secondly - - the Telnet demo just fails. Two of us have tested both of these on different installations, same response. REALLY would appreciate any fixes.

Are you planning to use the new SDK?

@nodemcu
Copy link
Collaborator

nodemcu commented Nov 22, 2014

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.

@scargill
Copy link
Author

Thanks - I will try the telnet .

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

@scargill
Copy link
Author

Erm, whereabouts is the new telnet demo?

@nodemcu
Copy link
Collaborator

nodemcu commented Nov 22, 2014

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

@scargill
Copy link
Author

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...

@scargill
Copy link
Author

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

@scargill
Copy link
Author

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.

@nodemcu
Copy link
Collaborator

nodemcu commented Nov 22, 2014

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

@nodemcu
Copy link
Collaborator

nodemcu commented Nov 22, 2014

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

@scargill
Copy link
Author

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..

@scargill
Copy link
Author

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.

@scargill
Copy link
Author

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...

@nodemcu
Copy link
Collaborator

nodemcu commented Nov 22, 2014

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

@scargill
Copy link
Author

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

@scargill
Copy link
Author

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()

@scargill
Copy link
Author

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

@lberezy
Copy link

lberezy commented Nov 23, 2014

If only this were open source...

@alonewolfx2
Copy link
Contributor

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

@scargill
Copy link
Author

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

@alonewolfx2
Copy link
Contributor

Lua needs absolutly ram management.

@scargill
Copy link
Author

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

@scargill
Copy link
Author

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?

@alonewolfx2
Copy link
Contributor

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

@alonewolfx2
Copy link
Contributor

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
> 

@scargill
Copy link
Author

Well, that's interesting isn't it!

@alonewolfx2
Copy link
Contributor

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.

@scargill
Copy link
Author

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.

@scargill
Copy link
Author

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.

@alonewolfx2
Copy link
Contributor

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
>

@scargill
Copy link
Author

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.

@nodemcu
Copy link
Collaborator

nodemcu commented Nov 25, 2014

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

@erinzm erinzm mentioned this issue Nov 25, 2014
@nodemcu nodemcu closed this as completed in 199f10f Dec 3, 2014
@scargill
Copy link
Author

scargill commented Dec 3, 2014

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.

vowstar added a commit that referenced this issue Jan 30, 2015
Update to MarsTechHAN's nodemcu-firmware
vowstar pushed a commit that referenced this issue Jan 30, 2015
Followed Vladimir Dronnikov's advices.
nodemcu pushed a commit that referenced this issue Mar 3, 2015
Added I/O expander MCP23008 module and two examples: digital output with...
nodemcu pushed a commit that referenced this issue Mar 3, 2015
@amancinellib
Copy link

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();

@TerryE
Copy link
Collaborator

TerryE commented Apr 28, 2016

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

@bastos1505 bastos1505 mentioned this issue Jun 26, 2016
marcelstoer pushed a commit that referenced this issue Aug 8, 2016
The name should be bme280.c, not bit.c .
@danjohn danjohn mentioned this issue Aug 19, 2019
HHHartmann pushed a commit that referenced this issue May 6, 2021
* File LFS module initial commit

* LFS file module update #1

* LFS file module update #2 - doc update and file.stat() returning read only attribute

* Implementing file.list()

* Fine-tuning `file_lfs` module

* Adding `file_lfs` to mkdocs.yml

* Implementing file.list() update #1

* Fine-tuning

* Fine-tuning #2
nwf pushed a commit that referenced this issue Dec 30, 2021
* File LFS module initial commit

* LFS file module update #1

* LFS file module update #2 - doc update and file.stat() returning read only attribute

* Implementing file.list()

* Fine-tuning `file_lfs` module

* Adding `file_lfs` to mkdocs.yml

* Implementing file.list() update #1

* Fine-tuning

* Fine-tuning #2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants