wip, réaligné les tabs dans socat et recherche toujours le problème de crash toutes les 5 minutes

This commit is contained in:
Christian Zufferey
2020-06-12 11:46:47 +02:00
parent e893835527
commit 70f9652cef
6 changed files with 521 additions and 123 deletions

View File

@@ -0,0 +1,370 @@
2020/06/11 11:45:26
4
2020/06/11 11:46:05
4
2020/06/11 11:49:14
4
2020/06/11 11:54:10
4
2020/06/11 11:57:55
4
2020/06/11 12:14:37
3
2020/06/11 12:46:56
3
2020/06/11 13:03:17
3
2020/06/11 13:19:37
3
2020/06/11 13:29:21
4
2020/06/11 13:40:35
4
2020/06/11 13:57:15
3
2020/06/11 14:08:44
4
2020/06/11 14:25:15
4
2020/06/11 14:28:34
4
2020/06/11 14:45:10
3
2020/06/11 15:01:34
3
2020/06/11 15:19:40
4
2020/06/11 15:27:50
4
2020/06/11 15:29:12
4
2020/06/11 15:45:34
4
2020/06/11 15:48:51
4
2020/06/11 16:05:32
3
2020/06/11 16:19:49
4
2020/06/11 16:23:57
4
2020/06/11 16:40:45
4
2020/06/11 16:54:53
4
2020/06/11 16:58:53
4
2020/06/11 17:00:31
4
2020/06/11 17:03:18
4
2020/06/11 17:06:44
4
2020/06/11 17:11:19
4
2020/06/11 17:28:00
3
2020/06/11 17:44:22
3
2020/06/11 18:00:56
3
2020/06/11 18:17:30
3
2020/06/11 18:33:23
4
2020/06/11 18:50:14
3
2020/06/11 19:06:37
3
2020/06/11 19:21:19
4
2020/06/11 19:23:49
4
2020/06/11 19:28:44
4
2020/06/11 19:34:24
3
2020/06/11 19:39:58
3
2020/06/11 19:45:35
3
2020/06/11 19:47:22
6
2020/06/11 19:53:14
3
2020/06/11 19:58:44
3
2020/06/11 20:06:06
4
2020/06/11 20:11:45
3
2020/06/11 20:19:06
4
2020/06/11 20:24:49
3
2020/06/11 20:30:39
3
2020/06/11 20:36:14
3
2020/06/11 20:41:51
3
2020/06/11 20:47:28
3
2020/06/11 20:53:05
3
2020/06/11 20:58:56
3
2020/06/11 21:06:14
4
2020/06/11 21:11:56
3
2020/06/11 21:17:34
3
2020/06/11 21:23:10
3
2020/06/11 21:28:47
3
2020/06/11 21:34:29
3
2020/06/11 21:40:21
3
2020/06/11 21:45:58
3
2020/06/11 21:51:40
3
2020/06/11 21:57:12
3
2020/06/11 22:02:58
3
2020/06/11 22:08:27
3
2020/06/11 22:14:08
3
2020/06/11 22:19:45
3
2020/06/11 22:25:23
3
2020/06/11 22:31:04
3
2020/06/11 22:36:37
3
2020/06/11 22:42:25
3
2020/06/11 22:49:45
4
2020/06/11 22:55:22
3
2020/06/11 23:01:12
3
2020/06/11 23:06:47
3
2020/06/11 23:12:26
3
2020/06/11 23:18:03
3
2020/06/11 23:23:44
3
2020/06/11 23:29:34
3
2020/06/11 23:35:09
3
2020/06/11 23:40:51
3
2020/06/11 23:46:26
3
2020/06/11 23:52:06
3
2020/06/11 23:59:22
4
2020/06/12 00:05:01
3
2020/06/12 00:20:36
3
2020/06/12 00:26:12
3
2020/06/12 00:31:48
3
2020/06/12 00:37:38
3
2020/06/12 00:43:13
3
2020/06/12 00:49:01
3
2020/06/12 00:56:21
4
2020/06/12 01:02:22
3
2020/06/12 01:08:24
3
2020/06/12 01:14:19
3
2020/06/12 01:19:57
3
2020/06/12 01:25:30
3
2020/06/12 01:31:06
3
2020/06/12 01:36:44
3
2020/06/12 01:42:21
3
2020/06/12 01:47:54
3
2020/06/12 01:53:32
3
2020/06/12 01:59:08
3
2020/06/12 02:04:47
3
2020/06/12 02:10:22
3
2020/06/12 02:16:01
3
2020/06/12 02:21:37
3
2020/06/12 02:27:09
3
2020/06/12 02:32:49
3
2020/06/12 02:38:23
3
2020/06/12 02:44:01
3
2020/06/12 02:49:37
3
2020/06/12 02:55:13
3
2020/06/12 03:00:54
3
2020/06/12 03:06:28
3
2020/06/12 03:12:06
3
2020/06/12 03:17:40
3
2020/06/12 03:23:31
3
2020/06/12 03:29:07
3
2020/06/12 03:34:45
3
2020/06/12 03:42:18
4
2020/06/12 03:47:57
3
2020/06/12 03:53:32
3
2020/06/12 04:00:56
4
2020/06/12 04:06:35
3
2020/06/12 04:12:29
3
2020/06/12 04:18:12
3
2020/06/12 04:23:59
3
2020/06/12 04:29:36
3
2020/06/12 04:35:18
3
2020/06/12 04:40:51
3
2020/06/12 04:46:32
3
2020/06/12 04:52:06
3
2020/06/12 04:57:42
3
2020/06/12 05:03:18
3
2020/06/12 05:08:53
3
2020/06/12 05:14:36
3
2020/06/12 05:20:10
3
2020/06/12 05:25:45
3
2020/06/12 05:31:21
3
2020/06/12 05:36:59
3
2020/06/12 05:47:32
3
2020/06/12 05:53:10
3
2020/06/12 05:58:46
3
2020/06/12 06:04:24
3
2020/06/12 06:11:42
4
2020/06/12 06:19:07
4
2020/06/12 06:26:49
4
2020/06/12 06:32:39
3
2020/06/12 06:38:15
3
2020/06/12 06:43:53
3
2020/06/12 06:51:11
4
2020/06/12 06:56:51
3
2020/06/12 07:02:28
3
2020/06/12 07:08:04
3
2020/06/12 07:13:45
3
2020/06/12 07:19:36
3
2020/06/12 07:25:14
3
2020/06/12 07:30:50
3
2020/06/12 07:36:27
3
2020/06/12 07:42:06
3
2020/06/12 07:47:56
3
2020/06/12 07:53:40
3
2020/06/12 07:59:19
3
2020/06/12 08:05:00
3
2020/06/12 08:10:45
3
2020/06/12 08:16:54
3
2020/06/12 08:22:28
3
2020/06/12 08:29:50
4
2020/06/12 08:35:36
3
2020/06/12 08:41:12
3
2020/06/12 08:47:00
3
2020/06/12 08:52:41
3
2020/06/12 08:58:15
3
2020/06/12 09:03:52
3
2020/06/12 09:09:26
3
2020/06/12 09:15:05
3
2020/06/12 09:20:45
3
2020/06/12 09:26:19
3
2020/06/12 09:29:45
4

View File

@@ -1,6 +1,6 @@
-- Scripts qui permet d'enregistrer la raison du boot dans la flash
print("\n 0_rec_boot.lua zf200611.1705 \n")
print("\n 0_rec_boot.lua zf200612.1117 \n")
-- Problématique:
-- Afin de pouvoir enregistrer l'heure du boot dans la FLASH il faut
@@ -34,6 +34,7 @@ function rec_boot()
file.close()
zboot_detail=nil zboot_reason=nil tm=nil
ztime_format=nil rec_boot=nil
collectgarbage() print(node.heap())
end
if verbose then print("End tmr_rec_boot1:") end

View File

@@ -30,109 +30,105 @@ telnet -rN localhost 23000
print("\n 0_tst4_socat.lua zf200611.1339 \n")
local node, table, tmr, uwrite, tostring =
node, table, tmr, uart.write, tostring
node, table, tmr, uart.write, tostring
local function telnet_listener(socket)
local insert, remove, concat, heap, gc =
table.insert, table.remove, table.concat, node.heap, collectgarbage
local fifo1, fifo1l, fifo2, fifo2l = {}, 0, {}, 0
local s -- s is a copy of the TCP socket if and only if sending is in progress
-- local wdclr, cnt = tmr.wdclr, 0
-- local function debug(fmt, ...)
-- if (...) then fmt = fmt:format(...) end
-- uwrite(0, "\r\nDBG: ",fmt,"\r\n" )
-- cnt = cnt + 1
-- if cnt % 10 then wdclr() end
-- end
local function flushGarbage()
if heap() < 13440 then gc() end
end
local function sendLine()
if not s then return end
if fifo2l + fifo1l == 0 then -- both FIFOs empty, so clear down s
s = nil
return
local insert, remove, concat, heap, gc =
table.insert, table.remove, table.concat, node.heap, collectgarbage
local fifo1, fifo1l, fifo2, fifo2l = {}, 0, {}, 0
local s -- s is a copy of the TCP socket if and only if sending is in progress
-- local wdclr, cnt = tmr.wdclr, 0
-- local function debug(fmt, ...)
-- if (...) then fmt = fmt:format(...) end
-- uwrite(0, "\r\nDBG: ",fmt,"\r\n" )
-- cnt = cnt + 1
-- if cnt % 10 then wdclr() end
-- end
local function flushGarbage()
if heap() < 13440 then gc() end
end
flushGarbage()
if #fifo2 < 4 then -- Flush FIFO1 into FIFO2
insert(fifo2,concat(fifo1))
fifo2l, fifo1, fifo1l = fifo2l + fifo1l, {}, 0
local function sendLine()
if not s then return end
if fifo2l + fifo1l == 0 then -- both FIFOs empty, so clear down s
s = nil
return
end
flushGarbage()
if #fifo2 < 4 then -- Flush FIFO1 into FIFO2
insert(fifo2,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 '')
fifo2l = fifo2l - #rec
flushGarbage()
s:send(rec)
end
local rec = remove(fifo2,1) .. (remove(fifo2,1) or '') ..
(remove(fifo2,1) or '') .. (remove(fifo2,1) or '')
fifo2l = fifo2l - #rec
flushGarbage()
s:send(rec)
end
local F1_SIZE = 256
local 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
if #fifo1 >= 32 or (k < l and k < 16) then
insert(fifo2, 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
chunk, str = str:sub(1,k), str:sub(k+1)
else
chunk, str = str, ''
end
insert(fifo1, chunk)
fifo1l = fifo1l + #chunk
local F1_SIZE = 256
local 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
if #fifo1 >= 32 or (k < l and k < 16) then
insert(fifo2, 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
chunk, str = str:sub(1,k), str:sub(k+1)
else
chunk, str = str, ''
end
insert(fifo1, chunk)
fifo1l = fifo1l + #chunk
end
if not s and socket then
s = socket
sendLine()
else
flushGarbage()
end
end
if not s and socket then
s = socket
sendLine()
else
flushGarbage()
local function receiveLine(s, line)
node.input(line)
end
end
local function receiveLine(s, line)
node.input(line)
end
local function disconnect(s)
--fifo1, fifo1l, fifo2, fifo2l, s = {}, 0, {}, 0, nil
fifo1, fifo1l, fifo2, fifo2l, s = nil, nil, nil, nil, nil
--insert, remove, concat, heap, gc = nil, nil, nil, nil, nil
--wdclr, cnt = nil, nil
node.output(nil)
print("disconnected...")
-- print("rt_retry:",rt_retry)
-- rt_retry=rt_retry-1
-- print("rt_retry:",rt_retry)
-- if rt_retry>=0 then
local function disconnect(s)
--fifo1, fifo1l, fifo2, fifo2l, s = {}, 0, {}, 0, nil
fifo1, fifo1l, fifo2, fifo2l, s = nil, nil, nil, nil, nil
--insert, remove, concat, heap, gc = nil, nil, nil, nil, nil
--wdclr, cnt = nil, nil
node.output(nil)
print("disconnected...")
-- print("rt_retry:",rt_retry)
-- rt_retry=rt_retry-1
-- print("rt_retry:",rt_retry)
-- if rt_retry>=0 then
print("on ressaie en vitesse une fois ;-)")
rt_connect()
-- end
end
--zzz
local function zconnection(s)
print("Welcome on ne devrait jamais passer par là to NodeMCU world.")
end
socket:on("connection", zconnection)
socket:on("receive", receiveLine)
socket:on("disconnection", disconnect)
socket:on("sent", sendLine)
node.output(queueLine, 0)
-- end
end
--zzz
local function zconnection(s)
print("Welcome on ne devrait jamais passer par là to NodeMCU world.")
end
socket:on("connection", zconnection)
socket:on("receive", receiveLine)
socket:on("disconnection", disconnect)
socket:on("sent", sendLine)
node.output(queueLine, 0)
end
--net.createServer(net.TCP, 180):listen(23, telnet_listener)
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)
@@ -161,13 +157,13 @@ 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=1
-- if verbose then gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) 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()
@@ -196,9 +192,9 @@ 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)
gpio.write(zLED, gpio.LOW)
else
gpio.write(zLED, gpio.HIGH)
gpio.write(zLED, gpio.HIGH)
end

View File

@@ -1,27 +1,6 @@
-- Scripts à charger après le boot pour démarrer son projet
print("\n boot.lua zf200611.1328 \n")
-- function ztime_stamp() return tmr.now()/1000000 end
-- sntp.sync(nil, nil, nil, 1)
--
-- function ztime_format(ztime)
-- tm = rtctime.epoch2cal(ztime + 3600)
-- return(string.format("%04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"]))
-- end
--
-- print(ztime_format(rtctime.get()+3600))
--
-- zsec, zusec = rtctime.get()
--
-- print(zsec, zusec)
-- zsec=zsec+3600+zusec/1000000
-- print(ztime_format(zsec))
--
-- print(zsec)
-- znanosec= zsec*1000000000
-- print(znanosec)
print("\n boot.lua zf200612.0936 \n")
function boot()
verbose = false
@@ -47,11 +26,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_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_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)

View File

@@ -0,0 +1,52 @@
-- Scripts pour régler l'horloge quand on est connecté en WIFI
-- Permet aussi de 'compresser' le unix time afin de prendre moins de place dans les strings
-- je suis en train de faire une version plus économique au niveau RAM (voir à la fin)
print("\n set_time2.lua zf200611.1926 \n")
--source: https://www.freeformatter.com/epoch-timestamp-to-date-converter.html
ztime2019 = 1546300800 -- Unix time pour le 1.1.2019
function set_time()
sntp.sync(nil, nil, nil, 1)
end
function ztime_compress(ztime_long)
return ztime_long - ztime2019
end
function ztime_uncompress(ztime_short)
return ztime_short + ztime2019
end
function ztime_format(ztime)
tm = rtctime.epoch2cal(ztime + 3600)
return(string.format("%04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"]))
end
set_time()
print(ztime_format(rtctime.get()))
-- function ztime_stamp() return tmr.now()/1000000 end
-- sntp.sync(nil, nil, nil, 1)
--
-- function ztime_format(ztime)
-- tm = rtctime.epoch2cal(ztime + 3600)
-- return(string.format("%04d/%02d/%02d %02d:%02d:%02d", tm["year"], tm["mon"], tm["day"], tm["hour"], tm["min"], tm["sec"]))
-- end
--
-- print(ztime_format(rtctime.get()+3600))
--
-- zsec, zusec = rtctime.get()
--
-- print(zsec, zusec)
-- zsec=zsec+3600+zusec/1000000
-- print(ztime_format(zsec))
--
-- print(zsec)
-- znanosec= zsec*1000000000
-- print(znanosec)

View File

@@ -1,7 +1,7 @@
-- Petit script pour initaliser la couche WIFI
function wifi_init()
print("\n wifi_init.lua zf200611.1157 \n")
print("\n wifi_init.lua zf200612.0943 \n")
f= "secrets_wifi.lua" if file.exists(f) then dofile(f) end
f= "secrets_project.lua" if file.exists(f) then dofile(f) end