Ajouté une fonction qui sauvegarde dans un fichier 00_debug.txt dans la FS des messages utilisés pour le debug

This commit is contained in:
Christian Zufferey
2020-06-14 17:37:25 +02:00
parent f08c3815db
commit 514e42806f
3 changed files with 21 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
-- Scripts qui permet d'enregistrer la raison du boot dans la flash
print("\n 0_rec_boot.lua zf200614.1422 \n")
print("\n 0_rec_boot.lua zf200614.1735 \n")
-- Problématique:
-- Afin de pouvoir enregistrer l'heure du boot dans la FLASH il faut
@@ -27,10 +27,11 @@ function rec_boot()
if rtctime.get() > 0 then
print("Voilà on à l'heure, on peut enregistrer la raison du boot...")
tmr_rec_boot1:unregister() tmr_rec_boot1=nil
file.open("00_boot_reason.txt", "a+")
file.writeline(ztime_format(rtctime.get()+3600))
local sec, usec = rtctime.get()
local _, zboot_reason, zboot_detail = node.bootreason()
file.writeline("boot reason: "..zboot_reason)
file.open("00_debug.txt", "a+")
file.writeline(string.rep(".",20))
file.writeline(zztime_format(sec).."."..usec..", boot reason: "..zboot_reason)
file.close()
ztime_format=nil rec_boot=nil
collectgarbage() print(node.heap())

View File

@@ -27,7 +27,7 @@ telnet -rN localhost 23000
]]
print("\n 0_tst4_socat.lua zf200614.1413 \n")
print("\n 0_tst4_socat.lua zf200614.1732 \n")
local node, table, tmr, uwrite, tostring =
node, table, tmr, uart.write, tostring
@@ -93,6 +93,7 @@ local function telnet_listener(socket)
local function disconnect(s)
debug_rec("disconnect, disconnected")
gpio.write(zLED, gpio.HIGH)
fifo1, fifo1l, fifo2, fifo2l, s = nil, nil, nil, nil, nil
node.output(nil) srv_rt = nil
collectgarbage() print(node.heap())
@@ -111,13 +112,22 @@ local function telnet_listener(socket)
--zzz
local function zconnection(s)
print("Welcome on ne devrait jamais passer par là to NodeMCU world.")
debug_rec("zconnection, pas glop")
local zstr="zconnection, Welcome on ne devrait jamais passer par là to NodeMCU world."
print(zstr) debug_rec(zstr)
end
--zzz
local function zreconnection(s)
local zstr="zreconnection, Oups... pourquoi ici ?"
print(zstr) debug_rec(zstr)
end
socket:on("connection", zconnection)
socket:on("receive", receiveLine)
socket:on("disconnection", disconnect)
socket:on("reconnection", zreconnection)
socket:on("sent", sendLine)
-- node.output(queueLine, 0)
node.output(queueLine, 1)

View File

@@ -1,15 +1,15 @@
-- Scripts à charger après le boot pour démarrer son projet
print("\n boot.lua zf200614.1424 \n")
print("\n boot.lua zf200614.1724 \n")
function zztime_format(ztime)
tm = rtctime.epoch2cal(ztime + 3600)
local tm = rtctime.epoch2cal(ztime + 3600)
return(string.format("%04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"]))
end
function debug_rec(zdebug)
local sec, usec = rtctime.get()
file.open("00_boot_reason.txt", "a+")
file.open("00_debug.txt", "a+")
file.writeline(zztime_format(sec).."."..usec..", "..zdebug)
file.close()
end