Refactorisé le socat, maintenant ce n'est plus un timer mais le cron qui le relance

This commit is contained in:
Christian Zufferey
2020-06-17 12:00:06 +02:00
parent 8fb0c9a1db
commit 0060a661ee
4 changed files with 22 additions and 7 deletions

View File

@@ -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())

View File

@@ -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

View File

@@ -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()

View File

@@ -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