From 514e42806f017ce8eac57698bc13c4505c7a523d Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Sun, 14 Jun 2020 17:37:25 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=C3=A9=20une=20fonction=20qui=20sauvegarde?= =?UTF-8?q?=20dans=20un=20fichier=2000=5Fdebug.txt=20dans=20la=20FS=20des?= =?UTF-8?q?=20messages=20utilis=C3=A9s=20pour=20le=20debug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../transfo_courant_clip_1p_1/0_rec_boot.lua | 9 +++++---- .../transfo_courant_clip_1p_1/0_tst4_socat.lua | 16 +++++++++++++--- .../energy/transfo_courant_clip_1p_1/boot.lua | 6 +++--- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Mesures/energy/transfo_courant_clip_1p_1/0_rec_boot.lua b/Mesures/energy/transfo_courant_clip_1p_1/0_rec_boot.lua index f6588e5..e536d71 100644 --- a/Mesures/energy/transfo_courant_clip_1p_1/0_rec_boot.lua +++ b/Mesures/energy/transfo_courant_clip_1p_1/0_rec_boot.lua @@ -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()) diff --git a/Mesures/energy/transfo_courant_clip_1p_1/0_tst4_socat.lua b/Mesures/energy/transfo_courant_clip_1p_1/0_tst4_socat.lua index 1a8c615..a04dd1e 100644 --- a/Mesures/energy/transfo_courant_clip_1p_1/0_tst4_socat.lua +++ b/Mesures/energy/transfo_courant_clip_1p_1/0_tst4_socat.lua @@ -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) diff --git a/Mesures/energy/transfo_courant_clip_1p_1/boot.lua b/Mesures/energy/transfo_courant_clip_1p_1/boot.lua index ed5b85f..0aa373f 100644 --- a/Mesures/energy/transfo_courant_clip_1p_1/boot.lua +++ b/Mesures/energy/transfo_courant_clip_1p_1/boot.lua @@ -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