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 a0d3048..23c1c2c 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.1851 \n") +print("\n 0_rec_boot.lua zf200615.2229 \n") -- Problématique: -- Afin de pouvoir enregistrer l'heure du boot dans la FLASH il faut @@ -31,7 +31,7 @@ function rec_boot() local _, zboot_reason, zboot_detail = node.bootreason() file.open("00_debug.txt", "a+") file.writeline(string.rep(".",20)) - file.writeline(zztime_format(sec).."."..usec..", boot reason: "..zboot_reason) + file.writeline(ztime_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 f87f570..1fb0abb 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 zf200615.1937 \n") +print("\n 0_tst4_socat.lua zf200615.2242 \n") local node, table, tmr, uwrite, tostring = node, table, tmr, uart.write, tostring @@ -109,12 +109,9 @@ local function telnet_listener(socket) if zlaps>1 then if http_post~=nil then http_post(influxdb_url,"energy,memory=socat_disconnected_"..yellow_id.." ram="..node.heap()) end - rt_retry=rt_retry-1 - if rt_retry>=0 then - local zstr="disconnect, reconnect 1x, "..node.heap() - print(zstr) if debug_rec~=nil then debug_rec(zstr) end - rt_connect() - end + local zstr="disconnect, reconnect 1x, "..node.heap() + print(zstr) if debug_rec~=nil then debug_rec(zstr) end + rt_connect() end end @@ -125,16 +122,14 @@ local function telnet_listener(socket) local zstr="zconnection, Welcome on ne devrait jamais passer par là to NodeMCU world." print(zstr) if debug_rec~=nil then debug_rec(zstr) end end - + socket:on("connection", zconnection) socket:on("receive", receiveLine) socket:on("disconnection", disconnect) socket:on("sent", sendLine) node.output(queueLine, 0) - -- node.output(queueLine, 1) end ---net.createServer(net.TCP, 180):listen(23, telnet_listener) print("Revers telnet server running...\n") @@ -164,11 +159,11 @@ function rt_connect() collectgarbage() -- if debug_rec~=nil then debug_rec("rt_connect, try connect, "..node.heap()) end - -- if verbose then - gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) - print("trying connect to "..console_host..":"..console_port) - print(node.heap()) - -- end + if verbose==verbose then + gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) + print("trying connect to "..console_host..":"..console_port) + print(node.heap()) + end if http_post~=nil then http_post(influxdb_url,"energy,memory=socat_try_con_"..yellow_id.." ram="..node.heap()) end end @@ -177,60 +172,15 @@ end tmr_socat1=tmr.create() tmr_socat1:alarm(15*1000, tmr.ALARM_AUTO , function() - - if http_post~=nil then http_post(influxdb_url,"energy,memory=tmr_socat1_"..yellow_id.." ram="..node.heap()) end - - rt_retry=3 - -- if verbose then gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) end + if http_post~=nil then http_post(influxdb_url,"energy,memory=tmr_socat1_"..yellow_id.." ram="..node.heap()) end if srv_rt~=nil then - -- if http_post~=nil then http_post(influxdb_url,"energy,memory=srv_rt_no_nil_"..yellow_id.." ram="..node.heap()) end - if console_port ~= srv_rt:getpeer() then - --on relance... rt_connect() end else - --on relance... rt_connect() end end) -rt_retry=3 rt_connect() - - - - - - ---[[ -rt_connect() -print(srv_rt) -print(srv_rt:getpeer()) - -rt_connect=nil -telnet_listener=nil -disconnect=nil - -total_allocated, estimated_used = node.egc.meminfo() -print(total_allocated, estimated_used) - -print(console_port) - -srv_rt = nil collectgarbage() - -tmr_socat1:unregister() -for k,v in pairs(_G) do print(k,v) end - -print(srv_rt:getpeer()) - -srv_rt:connect(console_port,console_host) - -gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) -if console_port == srv_rt:getpeer() then -gpio.write(zLED, gpio.LOW) -else -gpio.write(zLED, gpio.HIGH) -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 02c8449..8647c02 100644 --- a/Mesures/energy/transfo_courant_clip_1p_1/_zlocal_cmd.txt +++ b/Mesures/energy/transfo_courant_clip_1p_1/_zlocal_cmd.txt @@ -1,4 +1,4 @@ -zf200615.1932 +zf200615.2238 node.stripdebug(3) node.compile('0_tst4_socat.lua') @@ -10,7 +10,8 @@ print(srv_rt:getpeer()) node.output(nil) =srv_rt:getaddr() -srv_rt:close() +tmr_socat1:unregister() +for k,v in pairs(_G) do print(k,v) end total_allocated, estimated_used = node.egc.meminfo() print(total_allocated, estimated_used) diff --git a/Mesures/energy/transfo_courant_clip_1p_1/boot.lua b/Mesures/energy/transfo_courant_clip_1p_1/boot.lua index 6b9b525..c76eb06 100644 --- a/Mesures/energy/transfo_courant_clip_1p_1/boot.lua +++ b/Mesures/energy/transfo_courant_clip_1p_1/boot.lua @@ -1,18 +1,18 @@ -- Scripts à charger après le boot pour démarrer son projet -print("\n boot.lua zf200615.1933 \n") +print("\n boot.lua zf200615.2226 \n") -function zztime_format(ztime) - local tm = rtctime.epoch2cal(ztime + 2*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_debug.txt", "a+") - file.writeline(zztime_format(sec).."."..usec..", "..zdebug) - file.close() -end +-- function zztime_format(ztime) +-- local tm = rtctime.epoch2cal(ztime + 2*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_debug.txt", "a+") +-- file.writeline(zztime_format(sec).."."..usec..", "..zdebug) +-- file.close() +-- end @@ -24,14 +24,14 @@ function boot() f = "0_rec_boot.lua" if file.exists(f) then dofile(f) end collectgarbage() print(node.heap()) - f = "0_http_post.lua" if file.exists(f) then dofile(f) end - collectgarbage() print(node.heap()) + -- f = "0_http_post.lua" if file.exists(f) then dofile(f) end + -- collectgarbage() print(node.heap()) + function http_post() local z end - _, boot_reason = node.bootreason() - zarg_boot= "energy,memory=boot_"..yellow_id.." ram="..node.heap().."\n" - zarg_boot=zarg_boot.."energy,value=boot_reason_"..yellow_id.." val="..boot_reason - http_post(influxdb_url,zarg_boot) - boot_reason = nil + -- local _, boot_reason = node.bootreason() + -- zarg_boot= "energy,memory=boot_"..yellow_id.." ram="..node.heap().."\n" + -- zarg_boot=zarg_boot.."energy,value=boot_reason_"..yellow_id.." val="..boot_reason + -- http_post(influxdb_url,zarg_boot) -- f = "0_zdyndns.lua" if file.exists(f) then dofile(f) end -- print(node.heap()) collectgarbage() print(node.heap()) @@ -40,11 +40,11 @@ function boot() collectgarbage() print(node.heap()) zpower=0 - f="0_get_power.lua" if file.exists(f) then dofile(f) end - collectgarbage() print(node.heap()) - - f="0_cron.lua" if file.exists(f) then dofile(f) end - collectgarbage() print(node.heap()) + -- f="0_get_power.lua" if file.exists(f) then dofile(f) end + -- collectgarbage() print(node.heap()) + -- + -- f="0_cron.lua" if file.exists(f) then dofile(f) end + -- collectgarbage() print(node.heap()) print("verbose:",verbose) print("le boot est lancé...") gpio.write(zLED, gpio.HIGH)