Is there way with lua to do something similar and reduce the demand on the heap?
Yes, there is.
The nodeMCU version of LUA based on eLUA and eLUA programs can be stored in the FLASH area of a controller.
This should increase the heap.
Explore... Chat... Share...
Is there way with lua to do something similar and reduce the demand on the heap?
-- small 'chunk' interpreter. Usage:
-- intr=loadfile("interpret.lua")
-- test: print( intr("test.lua", [startstring, endstring[, subchunk's params] ] ) )
-- function(fn, stidx, eidx, ...)
local fn, stidx, eidx,i
fn,stidx,eidx = ...
i=0
--for i,j in pairs(arg1) do print("P:",i,j) end
local rez="";local buf="";succ=true
local cidx=1;local cond=true
if not stidx then stidx=1 end
file.open(fn)
repeat
i=i+1
tmr.wdclr()
buf=file.readline() tmr.wdclr()
if buf and cidx>=stidx then
if not succ then
rez=rez..buf
else
rez=buf
end
succ, rx=pcall( loadstring(rez), select(4,...) )
print("read str:",i)
end
cidx=cidx+1
if eidx then cond=(cidx<=eidx) else cond=true end
until not( buf and cond)
file.close()
return rx
picstart wrote: Is there way with lua to do something similar and reduce the demand on the heap?
Hoksmur wrote:One more way. It isn't fast, but works not bad.
And here the same colored.Code: Select all-- small 'chunk' interpreter. Usage:
-- intr=loadfile("interpret.lua")
-- test: print( intr("test.lua", [startstring, endstring[, subchunk's params] ] ) )
-- function(fn, stidx, eidx, ...)
local fn, stidx, eidx,i
fn,stidx,eidx = ...
i=0
--for i,j in pairs(arg1) do print("P:",i,j) end
local rez="";local buf="";succ=true
local cidx=1;local cond=true
if not stidx then stidx=1 end
file.open(fn)
repeat
i=i+1
tmr.wdclr()
buf=file.readline() tmr.wdclr()
if buf and cidx>=stidx then
if not succ then
rez=rez..buf
else
rez=buf
end
succ, rx=pcall( loadstring(rez), select(4,...) )
print("read str:",i)
end
cidx=cidx+1
if eidx then cond=(cidx<=eidx) else cond=true end
until not( buf and cond)
file.close()
return rx
It takes about 20-25 seconds for home assistant c[…]
I tried to upgrade tof my sonoff basic R2 with the[…]
a problem Perhaps you want to define "Probl[…]
Rebooting your router will not give you a faster I[…]
There are no other notifications from esptool.py i[…]
Using the Arduino IDE, you'll learn how to set up […]
In this project, you will post to Twitter using an[…]
In this project, we will build a water level contr[…]
I guess I'm late, but I had the same problem and f[…]
Last night I received my first D1 Minis for a lear[…]
Although I am aware that this is an old post, I fe[…]