-
Notifications
You must be signed in to change notification settings - Fork 1
/
util.lua
42 lines (38 loc) · 1.16 KB
/
util.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function reset ()
return node.restart()
end
function dump (t)
for k,v in pairs(t) do
print(k,v)
end
end
function gdump()
return dump (_G)
end
function ls ()
local sum = 0
for n,s in pairs(file.list()) do
sum = sum + s
print(n,s)
end
print ("Total:",sum.." Bytes")
end
function sysinfo ()
local majorVer, minorVer, devVer, chipid, flashid, flashsize, flashmode, flashspeed = node.info()
local heap = node.heap()
local luamem = collectgarbage("count")
local remaining, used, total=file.fsinfo()
print("\nSystem info:\n"..
"Node MCU "..majorVer.."."..minorVer.."."..devVer.."\n"..
"Chip ID : "..chipid.."\n"..
"Flash ID : "..flashid.."\n"..
"Flash Size : "..flashsize.."\n"..
"Flash Mode : "..flashmode.."\n"..
"Flash Speed : "..flashspeed.."\n\n"..
"Mem free (heap) : "..heap.." Bytes\n"..
"Mem used by lua : "..math.ceil(luamem*1000).." Bytes\n\n"..
"File system info:\n"..
"Total : "..total.." Bytes\n"..
"Used : "..used.." Bytes\n"..
"Remain: "..remaining.." Bytes\n")
end