From a843ae1631f2a0832fadffe50b5b540a63eb6a7e Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Sun, 21 Jun 2020 23:38:06 +0200 Subject: [PATCH] =?UTF-8?q?Cela=20commence=20enfin=20=C3=A0=20fonctionner?= =?UTF-8?q?=20correctement,=20j'ai=20encore=20le=20probl=C3=A8me=20du=20re?= =?UTF-8?q?boot=20apr=C3=A8s=2010mn=20=C3=A0=20v=C3=A9rifier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../transfo_courant_clip_1p_1/0_http_post.lua | 2 +- .../transfo_courant_clip_1p_1/0_rtelnet1.lua | 16 ++++++++-- .../0_tst5_socat.lua | 32 ++++++++++++++----- .../transfo_courant_clip_1p_1/_zlocal_cmd.txt | 15 ++++++--- .../_zremote_cmd.txt | 4 +-- 5 files changed, 51 insertions(+), 18 deletions(-) diff --git a/Mesures/energy/transfo_courant_clip_1p_1/0_http_post.lua b/Mesures/energy/transfo_courant_clip_1p_1/0_http_post.lua index 5ca1dad..bd0f922 100644 --- a/Mesures/energy/transfo_courant_clip_1p_1/0_http_post.lua +++ b/Mesures/energy/transfo_courant_clip_1p_1/0_http_post.lua @@ -1,7 +1,7 @@ -- Petit script pour envoyer en // es valeurs sur un serveur WEB (InfluxDB) -- via un http POST à travers un FIFO -if verbose then print("\n 0_http_post.lua zf200621.1238 \n") end +if verbose then print("\n 0_http_post.lua zf200621.2320 \n") end t_zurl={} t_zarg={} f_zpost=false diff --git a/Mesures/energy/transfo_courant_clip_1p_1/0_rtelnet1.lua b/Mesures/energy/transfo_courant_clip_1p_1/0_rtelnet1.lua index a95e77f..f1efa9c 100644 --- a/Mesures/energy/transfo_courant_clip_1p_1/0_rtelnet1.lua +++ b/Mesures/energy/transfo_courant_clip_1p_1/0_rtelnet1.lua @@ -1,7 +1,7 @@ -- script telnet pour le socat function telnet_listener(socket) - print("\n 0_rtelnet1.lua zf200621.1943 \n") + print("\n 0_rtelnet1.lua zf200621.2309 \n") -- node, table, tmr, uwrite, tostring = -- node, table, tmr, uart.write, tostring @@ -31,7 +31,9 @@ function telnet_listener(socket) rec = table.remove(fifo2,1)..(table.remove(fifo2,1) or '') ..(table.remove(fifo2,1) or '') .. (table.remove(fifo2,1) or '') fifo2l = fifo2l - #rec flushGarbage() - s:send(rec) + if srv_rt:getpeer()~=nil then + s:send(rec) + end end local F1_SIZE = 256 @@ -71,6 +73,12 @@ function telnet_listener(socket) if socket~=nil then -- if http_post~=nil then http_post(influxdb_url,"energy,memory=srv_rt_no_nil_"..yellow_id.." ram="..node.heap()) end print("................disconnect 2e", socket, socket:getpeer()) + socket:on("connection", nil) + socket:on("reconnection", nil) + socket:on("disconnection", nil) + socket:on("receive", nil) + socket:on("sent", nil) + socket=nil end @@ -92,6 +100,8 @@ function telnet_listener(socket) -- zconnection = nil -- disconnect = nil -- -- telnet_listener=nil + + fifo1, fifo1l, fifo2, fifo2l = nil, nil, nil, nil rec = nil @@ -111,7 +121,7 @@ function telnet_listener(socket) -- collectgarbage() - -- rt_connect() + rt_connect() end --zzz diff --git a/Mesures/energy/transfo_courant_clip_1p_1/0_tst5_socat.lua b/Mesures/energy/transfo_courant_clip_1p_1/0_tst5_socat.lua index 015f262..27997db 100644 --- a/Mesures/energy/transfo_courant_clip_1p_1/0_tst5_socat.lua +++ b/Mesures/energy/transfo_courant_clip_1p_1/0_tst5_socat.lua @@ -26,7 +26,7 @@ ou sur MAC telnet -rN localhost 23000 ]] -print("\n 0_tst5_socat.lua zf200621.1944 \n") +print("\n 0_tst5_socat.lua zf200621.2330 \n") function rt_connect() print("................rt_connect") @@ -34,7 +34,7 @@ function rt_connect() local zlaps=tmr.now()/1000000-ztime_connect print("time of retry connect... "..zlaps) -- if debug_rec~=nil then debug_rec("time of retry connect... "..zlaps..", "..node.heap()) end - if zlaps>1.5 then + if zlaps>1 then local zstr="trying connect to "..console_host..":"..console_port..", "..node.heap() -- if debug_rec~=nil then debug_rec(zstr) end if verbose==verbose then @@ -53,7 +53,7 @@ function rt_connect() collectgarbage() -- if verbose then gpio.write(zLED, gpio.LOW) - print("connected on "..console_host..":"..console_port) + print("connected on "..console_host..":"..console_port..", "..node.heap()) print(node.heap()) -- end if http_post~=nil then http_post(influxdb_url,"energy,memory=socat_connected_"..yellow_id.." ram="..node.heap()) end @@ -62,6 +62,25 @@ function rt_connect() print("Welcome to NodeMCU world.") end) + srv_rt:on("reconnection", function(sck) + print(";;;;;;;;;;;;;;;;reconnection") + srv_rt:on("connection", nil) + srv_rt:on("reconnection", nil) + end) + + -- srv_rt:on("disconnection", function(sck) + -- print(";;;;;;;;;;;;;;;;disconnection") + -- end) + -- + -- srv_rt:on("receive", function(sck) + -- print(";;;;;;;;;;;;;;;;receive") + -- end) + -- + -- srv_rt:on("sent", function(sck) + -- print(";;;;;;;;;;;;;;;;sent") + -- end) + + srv_rt:connect(console_port,console_host) else print("on ne se reconnecte pas vite 1x...") @@ -89,11 +108,8 @@ end -- tmr_socat1:alarm(15*1000, tmr.ALARM_AUTO , rt_launch) +ztime_connect=tmr.now()/1000000-10 - - -ztime_connect=tmr.now()/1000000 - --- rt_launch() +rt_launch() print("Revers telnet server running...\n") diff --git a/Mesures/energy/transfo_courant_clip_1p_1/_zlocal_cmd.txt b/Mesures/energy/transfo_courant_clip_1p_1/_zlocal_cmd.txt index 875af56..47aae1a 100644 --- a/Mesures/energy/transfo_courant_clip_1p_1/_zlocal_cmd.txt +++ b/Mesures/energy/transfo_courant_clip_1p_1/_zlocal_cmd.txt @@ -1,13 +1,19 @@ -zf200621.1125 +zf200621.2337 + +srv_rt:on("connection", nil) + + + =node.heap() rt_connect() - node, table, tmr, uwrite, tostring = nil, nil, nil, nil, nil - insert, remove, concat, heap, gc = nil, nil, nil, nil, nil fifo1, fifo1l, fifo2, fifo2l = nil, nil, nil, nil rec = nil + k = nil + l = nil s = nil + chunk = nil socket = nil flushGarbage = nil sendLine = nil @@ -16,7 +22,8 @@ rt_connect() zconnection = nil disconnect = nil telnet_listener=nil - + srv_rt=nil +=node.heap() diff --git a/Mesures/energy/transfo_courant_clip_1p_1/_zremote_cmd.txt b/Mesures/energy/transfo_courant_clip_1p_1/_zremote_cmd.txt index 19611e8..4e6cab1 100644 --- a/Mesures/energy/transfo_courant_clip_1p_1/_zremote_cmd.txt +++ b/Mesures/energy/transfo_courant_clip_1p_1/_zremote_cmd.txt @@ -1,5 +1,5 @@ # Quelques commandes remote (luatool) à envoyer avec le plugin Atom-IDE-terminal de l'éditeur Atom -# zf200621.1154 +# zf200621.2312 Todo à faire pour ce projet ! @@ -40,7 +40,7 @@ for k,v in pairs(_G) do print(k,v) end # pour les tests en direct sur la gateway ssh ubuntu@www.zuzu-test.ml socat TCP-LISTEN:23064,fork,reuseaddr STDIO - +################################ # pour les tests en remote killall -9 ssh ssh ubuntu@www.zuzu-test.ml killall -9 socat