Ajouté, enfin, la possibilité d'enregistrer dans la FLASH la raison du boot
This commit is contained in:
@@ -2,14 +2,14 @@
|
||||
-- Très intéressant la techno utilisée ici pour enlever les rebonds du micro switch
|
||||
-- dans la variable b se trouve l'heure à laquelle l'interruption est arrivée, il suffit juste alors de lui mettre un petit délai de 300mS
|
||||
|
||||
print("\n 0_btn_flipflop.lua zf200216.1457 \n")
|
||||
print("\n 0_btn_flipflop.lua zf200611.1153 \n")
|
||||
|
||||
gpio.write(zLED,1) gpio.mode(zLED,gpio.OUTPUT)
|
||||
gpio.mode(zBTN,gpio.INT)
|
||||
|
||||
d=tmr.now()
|
||||
|
||||
function zled (a,b,c)
|
||||
function z_btn_led (a,b,c)
|
||||
--print("a: "..a..",b: "..b..",c: "..c)
|
||||
if b-d > 300*1000 then
|
||||
if verbose then
|
||||
@@ -24,4 +24,4 @@ function zled (a,b,c)
|
||||
end
|
||||
end
|
||||
|
||||
gpio.trig(zBTN, "down", zled)
|
||||
gpio.trig(zBTN, "down", z_btn_led)
|
||||
|
||||
51
Mesures/energy/transfo_courant_clip_1p_1/0_rec_boot.lua
Normal file
51
Mesures/energy/transfo_courant_clip_1p_1/0_rec_boot.lua
Normal file
@@ -0,0 +1,51 @@
|
||||
-- Scripts qui permet d'enregistrer la raison du boot dans la flash
|
||||
|
||||
print("\n 0_rec_boot.lua zf200611.1151 \n")
|
||||
|
||||
-- Problématique:
|
||||
-- Afin de pouvoir enregistrer l'heure du boot dans la FLASH il faut
|
||||
-- en premier récupérer l'heure sur Internet et après seulement on peut
|
||||
-- faire l'enregistrement dans la FLASH
|
||||
|
||||
function rec_boot()
|
||||
|
||||
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
|
||||
|
||||
tmr_rec_boot1=tmr.create()
|
||||
tmr_rec_boot1:alarm(1*1000, tmr.ALARM_AUTO, function()
|
||||
if verbose then print("tmr_rec_boot1........................") end
|
||||
if verbose then gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) end
|
||||
|
||||
if verbose then print(rtctime.get()) end
|
||||
if verbose then print(ztime_format(rtctime.get()+3600)) end
|
||||
|
||||
if rtctime.get() > 0 then
|
||||
print("Voilà on à l'heure, on peut enregistrer...")
|
||||
tmr_rec_boot1:unregister() tmr_rec_boot1=nil
|
||||
file.open("00_boot_reason.txt", "a+")
|
||||
file.writeline(ztime_format(rtctime.get()+3600))
|
||||
_, zboot_reason, zboot_detail = node.bootreason()
|
||||
file.writeline(zboot_reason,zboot_detail)
|
||||
file.close()
|
||||
zboot_detail=nil zboot_reason=nil
|
||||
ztime_format=nil rec_boot=nil
|
||||
end
|
||||
|
||||
if verbose then print("End tmr_rec_boot1:") end
|
||||
collectgarbage()
|
||||
if verbose then print(node.heap()) end
|
||||
end)
|
||||
|
||||
end
|
||||
rec_boot()
|
||||
|
||||
|
||||
--[[
|
||||
verbose = true
|
||||
verbose = false
|
||||
]]
|
||||
@@ -1,12 +1,9 @@
|
||||
-- Scripts à charger après le boot pour démarrer son projet
|
||||
|
||||
print("\n boot.lua zf200610.2238 \n")
|
||||
print("\n boot.lua zf200611.1053 \n")
|
||||
|
||||
-- function ztime_stamp() return tmr.now()/1000000 end
|
||||
|
||||
|
||||
|
||||
|
||||
-- sntp.sync(nil, nil, nil, 1)
|
||||
--
|
||||
-- function ztime_format(ztime)
|
||||
@@ -26,24 +23,14 @@ print("\n boot.lua zf200610.2238 \n")
|
||||
-- znanosec= zsec*1000000000
|
||||
-- print(znanosec)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function boot()
|
||||
verbose = true
|
||||
print("On lance le boot...")
|
||||
collectgarbage() print(node.heap())
|
||||
|
||||
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())
|
||||
|
||||
@@ -63,8 +50,8 @@ function boot()
|
||||
-- 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)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-- Petit script pour initaliser la couche WIFI
|
||||
|
||||
function wifi_init()
|
||||
print("\n wifi_init.lua zf200610.2236 \n")
|
||||
print("\n wifi_init.lua zf200611.1053 \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
|
||||
@@ -14,7 +14,7 @@ function wifi_init()
|
||||
print(node.heap()) collectgarbage() print(node.heap())
|
||||
-- f= "telnet_srv2.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
f="0_tst4_socat.lua" if file.exists(f) then dofile(f) end
|
||||
-- f="0_tst4_socat.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
-- f= "web_srv2.lua" if file.exists(f) then dofile(f) end
|
||||
print(node.heap()) collectgarbage() print(node.heap())
|
||||
|
||||
Reference in New Issue
Block a user