wip, y'a plus rien qui marche au niveau socat avec le nouveau firmware :-(
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
-- Petit script pour faire office de crontab pour les mesures
|
||||
print("\n 0_cron.lua zf200617.1014 \n")
|
||||
print("\n 0_cron.lua zf200621.1206 \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
|
||||
-- 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()
|
||||
-- rt_launch()
|
||||
|
||||
|
||||
-- http_post(influxdb_url,"energy,value=test1_"..yellow_id.." val=1")
|
||||
@@ -25,9 +25,9 @@ cron1:alarm(10*1000, tmr.ALARM_AUTO, function()
|
||||
-- f = "0_zdyndns.lua" if file.exists(f) then dofile(f) end
|
||||
-- f=nil
|
||||
|
||||
if verbose then print("End cron:") end
|
||||
-- if verbose then print("End cron:") end
|
||||
collectgarbage()
|
||||
if verbose then print(node.heap()) end
|
||||
-- if verbose then print(node.heap()) end
|
||||
end)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- Lit le convertisseur ADC connecté sur le transformateur de courant
|
||||
-- pour mesurer le courant électrique de l'installation PV
|
||||
print("\n 0_get_power.lua zf200610.1154 \n")
|
||||
print("\n 0_get_power.lua zf200621.1143 \n")
|
||||
|
||||
-- Astuce de mesure:
|
||||
-- On converti le courant en tension avec la résistance de charge du
|
||||
@@ -51,12 +51,12 @@ end
|
||||
|
||||
function calc_rms()
|
||||
zadc_rms=math.floor(zadc_sum/znb_mes)
|
||||
if verbose then print(zadc_sum,znb_mes,zadc_rms) end
|
||||
-- if verbose then print(zadc_sum,znb_mes,zadc_rms) end
|
||||
if zadc_rms<=4 then zadc_rms=0 end
|
||||
zadc_offset=math.floor(zadc_offset_sum/znb_mes)
|
||||
zpower=math.floor(zadc_rms*zpow_cal/zadc_cal)
|
||||
if verbose then print(node.heap()) end
|
||||
if verbose then print(zadc_min,zadc_max,zadc_max-zadc_min,zadc_offset,zadc_rms,zpower.."W") end
|
||||
-- if verbose then print(node.heap()) end
|
||||
-- if verbose then print(zadc_min,zadc_max,zadc_max-zadc_min,zadc_offset,zadc_rms,zpower.."W") end
|
||||
zadc_min=zadc_offset zadc_max=zadc_offset
|
||||
zadc_sum=0 zadc_offset_sum=0 znb_mes=0
|
||||
zadc_min=zadc_offset zadc_max=zadc_offset
|
||||
|
||||
@@ -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 zf200617.1149 \n") end
|
||||
if verbose then print("\n 0_http_post.lua zf200621.1208 \n") end
|
||||
|
||||
t_zurl={} t_zarg={} f_zpost=false
|
||||
|
||||
@@ -20,7 +20,7 @@ function zpost()
|
||||
print("zuzu", code, data)
|
||||
debug_rec("HTTP request failed: ", code, data)
|
||||
else
|
||||
if verbose then print(code, data) end
|
||||
-- if verbose then print(code, data) end
|
||||
end
|
||||
table.remove(t_zurl, 1) table.remove(t_zarg, 1)
|
||||
if t_zurl[1]==nil then
|
||||
|
||||
@@ -3,7 +3,7 @@ tests connection reverse telnet commande à faire tourner sur le GATEWAY !
|
||||
|
||||
1ere console
|
||||
pour une liaison directe:
|
||||
socat TCP-LISTEN:23043,fork,reuseaddr STDIO
|
||||
socat TCP-LISTEN:23064,fork,reuseaddr STDIO
|
||||
pour une console sur un port:
|
||||
socat TCP-LISTEN:23043,reuseaddr,fork TCP-LISTEN:23000,reuseaddr,bind=127.0.0.1
|
||||
|
||||
@@ -27,12 +27,13 @@ telnet -rN localhost 23000
|
||||
]]
|
||||
|
||||
|
||||
print("\n 0_tst4_socat.lua zf200617.1014 \n")
|
||||
print("\n 0_tst4_socat.lua zf200621.1118 \n")
|
||||
|
||||
local node, table, tmr, uwrite, tostring =
|
||||
node, table, tmr, uart.write, tostring
|
||||
|
||||
local function telnet_listener(socket)
|
||||
print("................telnet_listener")
|
||||
local insert, remove, concat, heap, gc =
|
||||
table.insert, table.remove, table.concat, node.heap, collectgarbage
|
||||
local fifo1, fifo1l, fifo2, fifo2l = {}, 0, {}, 0
|
||||
@@ -59,11 +60,11 @@ local function telnet_listener(socket)
|
||||
fifo2l = fifo2l - #rec
|
||||
flushGarbage()
|
||||
--zzz
|
||||
if srv_rt~=nil then
|
||||
if console_port == srv_rt:getpeer() then
|
||||
-- if socket~=nil then
|
||||
-- if console_port == socket:getpeer() then
|
||||
s:send(rec)
|
||||
end
|
||||
end
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
|
||||
local F1_SIZE = 256
|
||||
@@ -97,7 +98,9 @@ local function telnet_listener(socket)
|
||||
end
|
||||
|
||||
local function disconnect(_,zerr)
|
||||
node.output(nil)
|
||||
node.output(nil)
|
||||
print("................disconnect", socket,socket:getpeer())
|
||||
-- socket:close()
|
||||
gpio.write(zLED, gpio.HIGH)
|
||||
fifo1, fifo1l, fifo2, fifo2l, s = nil, nil, nil, nil, nil
|
||||
collectgarbage() print("disconnected... "..zerr..", "..node.heap())
|
||||
@@ -112,11 +115,12 @@ local function telnet_listener(socket)
|
||||
local zstr="disconnect, reconnect 1x, "..node.heap()
|
||||
print(zstr) if debug_rec~=nil then debug_rec(zstr) end
|
||||
rt_connect()
|
||||
else
|
||||
print("on ne se reconnecte pas vite 1x...")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
--zzz
|
||||
local function zconnection(s)
|
||||
local zstr="zconnection, Welcome on ne devrait jamais passer par là to NodeMCU world."
|
||||
@@ -127,33 +131,21 @@ local function telnet_listener(socket)
|
||||
socket:on("receive", receiveLine)
|
||||
socket:on("disconnection", disconnect)
|
||||
socket:on("sent", sendLine)
|
||||
node.output(queueLine, 0)
|
||||
-- node.output(queueLine, 0)
|
||||
print(queueLine, 0)
|
||||
end
|
||||
|
||||
print("Revers telnet server running...\n")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function rt_connect()
|
||||
srv_rt = nil collectgarbage()
|
||||
srv_rt = net.createConnection(net.TCP, 0)
|
||||
|
||||
srv_rt:on("connection", function(sck)
|
||||
if debug_rec~=nil then debug_rec("rt_connect, srv_rt:on, connected on, "..node.heap()) end
|
||||
ztime_connect=tmr.now()/1000000
|
||||
collectgarbage()
|
||||
-- if verbose then
|
||||
gpio.write(zLED, gpio.LOW)
|
||||
print("connected on "..console_host..":"..console_port)
|
||||
print(node.heap())
|
||||
-- end
|
||||
if http_post~=nil then http_post(influxdb_url,"energy,memory=socat_connected_"..yellow_id.." ram="..node.heap()) end
|
||||
telnet_listener(sck)
|
||||
print("Welcome to NodeMCU world.")
|
||||
end)
|
||||
|
||||
print("................rt_connect")
|
||||
-- srv_rt = nil
|
||||
collectgarbage()
|
||||
ztime_connect=tmr.now()/1000000
|
||||
|
||||
srv_rt:connect(console_port,console_host)
|
||||
|
||||
collectgarbage()
|
||||
@@ -183,11 +175,25 @@ function rt_launch()
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-- tmr_socat1=tmr.create()
|
||||
-- tmr_socat1:alarm(15*1000, tmr.ALARM_AUTO , rt_launch)
|
||||
|
||||
srv_rt = net.createConnection(net.TCP, 0)
|
||||
|
||||
srv_rt:on("connection", function(sck)
|
||||
print("connection...")
|
||||
if debug_rec~=nil then debug_rec("rt_connect, srv_rt:on, connected on, "..node.heap()) end
|
||||
collectgarbage()
|
||||
-- if verbose then
|
||||
gpio.write(zLED, gpio.LOW)
|
||||
print("connected on "..console_host..":"..console_port)
|
||||
print(node.heap())
|
||||
-- end
|
||||
if http_post~=nil then http_post(influxdb_url,"energy,memory=socat_connected_"..yellow_id.." ram="..node.heap()) end
|
||||
telnet_listener(sck)
|
||||
print("Welcome to NodeMCU world.")
|
||||
end)
|
||||
|
||||
rt_connect()
|
||||
-- rt_launch()
|
||||
|
||||
print("Revers telnet server running...\n")
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
zf200617.1902
|
||||
zf200621.1125
|
||||
|
||||
verbose=true
|
||||
rt_connect()
|
||||
|
||||
|
||||
|
||||
|
||||
for k,v in ipairs(debug.getregistry()) do print(k,v) end
|
||||
|
||||
@@ -7,7 +13,6 @@ for k,v in ipairs(debug.getregistry()) do print(k,v) end
|
||||
node.stripdebug(3)
|
||||
node.compile('0_tst4_socat.lua')
|
||||
|
||||
rt_connect()
|
||||
print(srv_rt)
|
||||
print(srv_rt:getpeer())
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Quelques commandes remote (luatool) à envoyer avec le plugin Atom-IDE-terminal de l'éditeur Atom
|
||||
# zf200615.1725
|
||||
# zf200621.1154
|
||||
|
||||
|
||||
Todo à faire pour ce projet !
|
||||
@@ -76,6 +76,13 @@ for k,v in pairs(_G) do print(k,v) end
|
||||
################################
|
||||
# commandes lua pour ce projet #
|
||||
################################
|
||||
# pour les tests en direct sur la gateway
|
||||
ssh ubuntu@www.zuzu-test.ml
|
||||
socat TCP-LISTEN:23064,fork,reuseaddr STDIO
|
||||
|
||||
|
||||
|
||||
|
||||
killall -9 ssh
|
||||
ssh ubuntu@www.zuzu-test.ml killall -9 socat
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-- Scripts à charger après le boot pour démarrer son projet
|
||||
|
||||
function boot()
|
||||
print("\n boot.lua zf200616.1637 \n")
|
||||
print("\n boot.lua zf200621.1232 \n")
|
||||
print("On lance le boot...")
|
||||
collectgarbage() print(node.heap())
|
||||
local f
|
||||
@@ -26,36 +26,36 @@ function boot()
|
||||
f="0_cron.lua" if file.exists(f) then dofile(f) end
|
||||
collectgarbage() print(node.heap())
|
||||
|
||||
verbose = false
|
||||
verbose = true
|
||||
print("verbose: ",verbose,"\nle boot est lancé...")
|
||||
gpio.write(zLED, gpio.HIGH)
|
||||
boot=nil
|
||||
end
|
||||
|
||||
function debug_rec(zdebug)
|
||||
local sec, usec = rtctime.get() local tm = rtctime.epoch2cal(sec + 2*3600)
|
||||
local ztm = string.format("%04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"])
|
||||
file.open("00_debug.txt", "a+") file.writeline(ztm.."."..usec..", "..zdebug) file.close()
|
||||
end
|
||||
|
||||
function rec_boot()
|
||||
sntp.sync(nil, nil, nil, 1)
|
||||
tmr_rec_boot1=tmr.create()
|
||||
tmr_rec_boot1:alarm(1*1000, tmr.ALARM_AUTO, function()
|
||||
print("beep...")
|
||||
if rtctime.get() > 0 then
|
||||
tmr_rec_boot1:unregister()
|
||||
print("Voilà on à l'heure, on peut enregistrer la raison du boot...")
|
||||
local _, zboot_reason, zboot_detail = node.bootreason()
|
||||
debug_rec("boot reason: "..zboot_reason)
|
||||
tmr_rec_boot1=nil rec_boot=nil
|
||||
collectgarbage() print(node.heap())
|
||||
end
|
||||
end)
|
||||
end
|
||||
-- function debug_rec(zdebug)
|
||||
-- local sec, usec = rtctime.get() local tm = rtctime.epoch2cal(sec + 2*3600)
|
||||
-- local ztm = string.format("%04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"])
|
||||
-- file.open("00_debug.txt", "a+") file.writeline(ztm.."."..usec..", "..zdebug) file.close()
|
||||
-- end
|
||||
--
|
||||
-- function rec_boot()
|
||||
-- sntp.sync(nil, nil, nil, 1)
|
||||
-- tmr_rec_boot1=tmr.create()
|
||||
-- tmr_rec_boot1:alarm(1*1000, tmr.ALARM_AUTO, function()
|
||||
-- print("beep...")
|
||||
-- if rtctime.get() > 0 then
|
||||
-- tmr_rec_boot1:unregister()
|
||||
-- print("Voilà on à l'heure, on peut enregistrer la raison du boot...")
|
||||
-- local _, zboot_reason, zboot_detail = node.bootreason()
|
||||
-- debug_rec("boot reason: "..zboot_reason)
|
||||
-- tmr_rec_boot1=nil rec_boot=nil
|
||||
-- collectgarbage() print(node.heap())
|
||||
-- end
|
||||
-- end)
|
||||
-- end
|
||||
|
||||
verbose=true
|
||||
rec_boot()
|
||||
if rec_boot~=nil then rec_boot() end
|
||||
boot()
|
||||
collectgarbage() print(node.heap())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user