From 152e78a2643293b5c67facdbcbaccfffda041d5d Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Sun, 21 Jun 2020 19:35:22 +0200 Subject: [PATCH] =?UTF-8?q?Enfin=20on=20dirait=20que=20j'ai=20r=C3=A9ussi?= =?UTF-8?q?=20=C3=A0=20boucher=20la=20fuite=20m=C3=A9moire,=20mais=20il=20?= =?UTF-8?q?faut=20encore=20v=C3=A9rifier=20mieux=20;-)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../transfo_courant_clip_1p_1/0_rtelnet1.lua | 50 ++++++++++++------- .../transfo_courant_clip_1p_1/_zlocal_cmd.txt | 31 +++++++++++- 2 files changed, 62 insertions(+), 19 deletions(-) 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 347e6de..2850169 100644 --- a/Mesures/energy/transfo_courant_clip_1p_1/0_rtelnet1.lua +++ b/Mesures/energy/transfo_courant_clip_1p_1/0_rtelnet1.lua @@ -3,17 +3,17 @@ function telnet_listener(socket) print("\n 0_rtelnet1.lua zf200621.1603 \n") - node, table, tmr, uwrite, tostring = - node, table, tmr, uart.write, tostring + -- node, table, tmr, uwrite, tostring = + -- node, table, tmr, uart.write, tostring print("................telnet_listener") - insert, remove, concat, heap, gc = - table.insert, table.remove, table.concat, node.heap, collectgarbage + -- insert, remove, concat, heap, gc = + -- table.insert, table.remove, table.concat, node.heap, collectgarbage fifo1, fifo1l, fifo2, fifo2l = {}, 0, {}, 0 -- local s -- s is a copy of the TCP socket if and only if sending is in progress function flushGarbage() - if heap() < 13440 then gc() end + if node.heap() < 13440 then collectgarbage() end end function sendLine() @@ -25,11 +25,10 @@ function telnet_listener(socket) end flushGarbage() if #fifo2 < 4 then -- Flush FIFO1 into FIFO2 - insert(fifo2,concat(fifo1)) + table.insert(fifo2,table.concat(fifo1)) fifo2l, fifo1, fifo1l = fifo2l + fifo1l, {}, 0 end - local rec = remove(fifo2,1) .. (remove(fifo2,1) or '') .. - (remove(fifo2,1) or '') .. (remove(fifo2,1) or '') + 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) @@ -39,10 +38,9 @@ function telnet_listener(socket) function queueLine(str) while #str > 0 do -- this is because str might be longer than the packet size! - local k, l = F1_SIZE - fifo1l, #str - local chunk + k, l = F1_SIZE - fifo1l, #str if #fifo1 >= 32 or (k < l and k < 16) then - insert(fifo2, concat(fifo1)) + table.insert(fifo2, table.concat(fifo1)) fifo2l, fifo1, fifo1l, k = fifo2l + fifo1l, {}, 0, F1_SIZE end if l > k+16 then -- also tolerate a size overrun of 16 bytes to avoid a split @@ -50,7 +48,7 @@ function telnet_listener(socket) else chunk, str = str, '' end - insert(fifo1, chunk) + table.insert(fifo1, chunk) fifo1l = fifo1l + #chunk end if not s and socket then @@ -73,28 +71,46 @@ 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=nil end -- fifo1, fifo1l, fifo2, fifo2l, s = nil, nil, nil, nil, nil print("disconnected... "..zerr..", "..node.heap()) -- if debug_rec~=nil then debug_rec("disconnect, disconnected, "..zerr..", "..node.heap()) end - -- telnet_listener=nil - node, table, tmr, uwrite, tostring = nil, nil, nil, nil, nil - insert, remove, concat, heap, gc = nil, nil, nil, nil, nil + -- 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 + -- s = nil + -- socket = nil + -- flushGarbage = nil + -- sendLine = nil + -- queueLine = nil + -- receiveLine = nil + -- zconnection = nil + -- disconnect = nil + -- -- telnet_listener=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 queueLine = nil receiveLine = nil zconnection = nil disconnect = nil + telnet_listener=nil + srv_rt=nil - collectgarbage() + -- collectgarbage() -- rt_connect() end 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 5553b20..875af56 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,40 @@ zf200621.1125 -verbose=true +=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 + s = nil + socket = nil + flushGarbage = nil + sendLine = nil + queueLine = nil + receiveLine = nil + zconnection = nil + disconnect = nil + telnet_listener=nil + + + + + + + + + + + =node.heap() dofile("0_rtelnet1.lua") =node.heap() telnet_listener=nil =node.heap() +srv_rt=nil +=node.heap() + for k,v in ipairs(debug.getregistry()) do print(k,v) end @@ -25,7 +52,7 @@ print(socket) print(socket:getpeer()) socket:close() - +verbose=true node.output(nil) http_post(influxdb_url,"energy,value=test1_"..yellow_id.." val=1") print("toto",node.heap(),#t_zurl)