From 0060a661ee152878513c06870899ec4afe641278 Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Wed, 17 Jun 2020 12:00:06 +0200 Subject: [PATCH] =?UTF-8?q?Refactoris=C3=A9=20le=20socat,=20maintenant=20c?= =?UTF-8?q?e=20n'est=20plus=20un=20timer=20mais=20le=20cron=20qui=20le=20r?= =?UTF-8?q?elance?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../energy/transfo_courant_clip_1p_1/0_cron.lua | 6 +++++- .../transfo_courant_clip_1p_1/0_http_post.lua | 3 ++- .../transfo_courant_clip_1p_1/0_tst4_socat.lua | 15 +++++++++++---- .../transfo_courant_clip_1p_1/_zlocal_cmd.txt | 5 ++++- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Mesures/energy/transfo_courant_clip_1p_1/0_cron.lua b/Mesures/energy/transfo_courant_clip_1p_1/0_cron.lua index d0dd28e..889eabe 100644 --- a/Mesures/energy/transfo_courant_clip_1p_1/0_cron.lua +++ b/Mesures/energy/transfo_courant_clip_1p_1/0_cron.lua @@ -1,11 +1,15 @@ -- Petit script pour faire office de crontab pour les mesures -print("\n 0_cron.lua zf200616.1638 \n") +print("\n 0_cron.lua zf200617.1014 \n") cron1=tmr.create() cron1:alarm(10*1000, tmr.ALARM_AUTO, function() if verbose then print("cron1........................") end if verbose then gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) end + + rt_launch() + + -- http_post(influxdb_url,"energy,value=test1_"..yellow_id.." val=1") -- http_post(influxdb_url,"energy,memory=cron1_"..yellow_id.." ram="..node.heap()) 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 9e08a5e..2207acb 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 zf200616.1633 \n") end +if verbose then print("\n 0_http_post.lua zf200617.1149 \n") end t_zurl={} t_zarg={} f_zpost=false @@ -18,6 +18,7 @@ function zpost() if (code < 0) then print("HTTP request failed") print("zuzu", code, data) + debug_rec("HTTP request failed: ", code, data) else if verbose then print(code, data) end end 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 1fb0abb..953d475 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.2242 \n") +print("\n 0_tst4_socat.lua zf200617.1014 \n") local node, table, tmr, uwrite, tostring = node, table, tmr, uart.write, tostring @@ -170,8 +170,7 @@ end -tmr_socat1=tmr.create() -tmr_socat1:alarm(15*1000, tmr.ALARM_AUTO , function() +function rt_launch() 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 @@ -181,6 +180,14 @@ tmr_socat1:alarm(15*1000, tmr.ALARM_AUTO , function() else rt_connect() end -end) +end + + + + +-- tmr_socat1=tmr.create() +-- tmr_socat1:alarm(15*1000, tmr.ALARM_AUTO , rt_launch) + + rt_connect() 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 8647c02..a386070 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.2238 +zf200617.1159 node.stripdebug(3) node.compile('0_tst4_socat.lua') @@ -9,6 +9,9 @@ print(srv_rt:getpeer()) node.output(nil) +http_post(influxdb_url,"energy,value=test1_"..yellow_id.." val=1") print("toto",node.heap(),#t_zurl) + + =srv_rt:getaddr() tmr_socat1:unregister() for k,v in pairs(_G) do print(k,v) end