J'ai l'air d'avoir trouvé le problème, mais ce n'est pas encore terminé :-(
This commit is contained in:
73
IDE_remote/SocketIDE/atom_plugin/test1/initz - copie.lua
Normal file
73
IDE_remote/SocketIDE/atom_plugin/test1/initz - copie.lua
Normal file
@@ -0,0 +1,73 @@
|
||||
--Script de bootstrap, test au moment du boot qui a été la cause de boot.
|
||||
|
||||
print("\n init.lua zf191021.0914 \n")
|
||||
|
||||
local bootreasons={
|
||||
[0]="power-on",
|
||||
[1]="hardware watchdog reset",
|
||||
[2]="exception reset",
|
||||
[3]="software watchdog reset",
|
||||
[4]="software restart",
|
||||
[5]="wake from deep sleep",
|
||||
[6]="external reset"
|
||||
}
|
||||
|
||||
local ip = wifi.sta.getip()
|
||||
if ip then
|
||||
print("already got:"..ip)
|
||||
else
|
||||
print("Connecting...")
|
||||
-- charge ses propres secrets
|
||||
f= "secrets_energy.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
-- configure le WIFI
|
||||
f= "wifi_ap_stop.lua" if file.exists(f) then dofile(f) end
|
||||
f= "wifi_cli_conf.lua" if file.exists(f) then dofile(f) end
|
||||
f= "wifi_cli_start.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
--[[
|
||||
wifi.setmode(wifi.STATION)
|
||||
ip_cfg={}
|
||||
ip_cfg.ip = "192.168.6.90"
|
||||
ip_cfg.netmask = "255.255.255.0"
|
||||
ip_cfg.gateway = "192.168.6.1"
|
||||
wifi.sta.setip(ip_cfg)
|
||||
station_cfg={}
|
||||
station_cfg.ssid="holternet"
|
||||
station_cfg.pwd="nemosushi_sushinemo"
|
||||
wifi.sta.sethostname("mybutton1")
|
||||
wifi.sta.config(station_cfg)
|
||||
wifi.sta.connect()
|
||||
wifi.sta.autoconnect(1)
|
||||
]]
|
||||
|
||||
plugtimer1=tmr.create()
|
||||
plugtimer1:alarm(1*1000, tmr.ALARM_AUTO, function()
|
||||
local ip = wifi.sta.getip()
|
||||
if ip then
|
||||
plugtimer1:unregister()
|
||||
print(ip)
|
||||
end
|
||||
end)
|
||||
end
|
||||
dofile("websocket.lua")
|
||||
dofile("main.lua")
|
||||
if file.exists("userinit.lua") then
|
||||
--[[
|
||||
0, power-on
|
||||
1, hardware watchdog reset
|
||||
2, exception reset
|
||||
3, software watchdog reset
|
||||
4, software restart
|
||||
5, wake from deep sleep
|
||||
6, external reset
|
||||
]]
|
||||
_ , reason = node.bootreason()
|
||||
if (reason<1 or reason > 3) then
|
||||
dofile("userinit.lua")
|
||||
else
|
||||
print ("Bootreason="..reason.." ("..bootreasons[reason].."), skipping userinit.lua")
|
||||
end
|
||||
else
|
||||
print("userinit.lua not found")
|
||||
end
|
||||
@@ -16,14 +16,14 @@ local ip = wifi.sta.getip()
|
||||
if ip then
|
||||
print("already got:"..ip)
|
||||
else
|
||||
print("Connecting...")
|
||||
-- print("Connecting...")
|
||||
-- charge ses propres secrets
|
||||
f= "secrets_energy.lua" if file.exists(f) then dofile(f) end
|
||||
-- f= "secrets_energy.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
-- configure le WIFI
|
||||
f= "wifi_ap_stop.lua" if file.exists(f) then dofile(f) end
|
||||
f= "wifi_cli_conf.lua" if file.exists(f) then dofile(f) end
|
||||
f= "wifi_cli_start.lua" if file.exists(f) then dofile(f) end
|
||||
-- f= "wifi_ap_stop.lua" if file.exists(f) then dofile(f) end
|
||||
-- f= "wifi_cli_conf.lua" if file.exists(f) then dofile(f) end
|
||||
-- f= "wifi_cli_start.lua" if file.exists(f) then dofile(f) end
|
||||
|
||||
--[[
|
||||
wifi.setmode(wifi.STATION)
|
||||
@@ -41,19 +41,29 @@ else
|
||||
wifi.sta.autoconnect(1)
|
||||
]]
|
||||
|
||||
--[[
|
||||
plugtimer1=tmr.create()
|
||||
plugtimer1:alarm(1*1000, tmr.ALARM_AUTO, function()
|
||||
local ip = wifi.sta.getip()
|
||||
if ip then
|
||||
plugtimer1:unregister()
|
||||
print(ip)
|
||||
print("> ")
|
||||
end
|
||||
end)
|
||||
]]
|
||||
|
||||
end
|
||||
|
||||
--[[
|
||||
dofile("websocket.lua")
|
||||
dofile("main.lua")
|
||||
]]
|
||||
|
||||
--[[
|
||||
|
||||
if file.exists("userinit.lua") then
|
||||
--[[
|
||||
--[z[
|
||||
0, power-on
|
||||
1, hardware watchdog reset
|
||||
2, exception reset
|
||||
@@ -61,7 +71,7 @@ if file.exists("userinit.lua") then
|
||||
4, software restart
|
||||
5, wake from deep sleep
|
||||
6, external reset
|
||||
]]
|
||||
]z]
|
||||
_ , reason = node.bootreason()
|
||||
if (reason<1 or reason > 3) then
|
||||
dofile("userinit.lua")
|
||||
@@ -71,3 +81,5 @@ if file.exists("userinit.lua") then
|
||||
else
|
||||
print("userinit.lua not found")
|
||||
end
|
||||
|
||||
]]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python2
|
||||
# -*- coding: utf-8 -*-
|
||||
version = "0.6.5 zf191021.1027"
|
||||
version = "0.6.5 zf191021.1534"
|
||||
|
||||
print("luatool.py ver " + version)
|
||||
|
||||
@@ -71,12 +71,14 @@ class AbstractTransport:
|
||||
self.writeln("file.writeline([==[" + data + "]==])\r")
|
||||
|
||||
def performcheck(self, expected):
|
||||
print("toto1434")
|
||||
line = ''
|
||||
char = ''
|
||||
i = -1
|
||||
while char != chr(62): # '>'
|
||||
char = self.read(1)
|
||||
if char == '':
|
||||
#print("toto14491 char: ." + char + ".")
|
||||
if char == '£':
|
||||
raise Exception('No proper answer from MCU')
|
||||
if char == chr(13) or char == chr(10): # LF or CR
|
||||
if line != '':
|
||||
@@ -122,15 +124,31 @@ class SerialTransport(AbstractTransport):
|
||||
self.serial.timeout = 3
|
||||
self.serial.interCharTimeout = 3
|
||||
|
||||
# zzz191020 Il faut faire une pause juste après l'ouverture du port série
|
||||
print("\ntoto1023\n")
|
||||
sleep(0.7)
|
||||
print("\ntoto10231\n")
|
||||
# zzz191021 juste après l'ouverture du port série, on attend le caractère '>'
|
||||
line = ''
|
||||
char = ''
|
||||
i = -1
|
||||
while char != chr(62): # '>'
|
||||
char = self.read(1)
|
||||
if char == '':
|
||||
raise Exception('No proper answer from MCU')
|
||||
line += char
|
||||
i += 1
|
||||
if args.verbose:
|
||||
print("toto1518 line: ." + line + ".")
|
||||
|
||||
|
||||
def writeln(self, data, check=1):
|
||||
print("toto1439 check: " + str(check))
|
||||
|
||||
# zzz191020 une petite pause après l'envoi de chaque ligne
|
||||
sleep(self.delay)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if self.serial.inWaiting() > 0:
|
||||
self.serial.flushInput()
|
||||
if len(data) > 0 and not args.bar:
|
||||
@@ -140,6 +158,7 @@ class SerialTransport(AbstractTransport):
|
||||
# zzz191021 Affiche ce que l'on a envoyé au NodeMCU
|
||||
if args.verbose:
|
||||
print("\n\nzwrite0952: {" + data + "\n}\n")
|
||||
print("toto1435 check: " + str(check))
|
||||
if check > 0:
|
||||
self.performcheck(data)
|
||||
elif not args.bar:
|
||||
@@ -238,8 +257,11 @@ if __name__ == '__main__':
|
||||
print("\ntoto1024\n")
|
||||
|
||||
transport.writeln("print('\\n-----');local l = file.list();for k,v in pairs(l) do print(k..', size:'..v)end;print('-----\\n')\r", 0)
|
||||
#transport.writeln("print('toto et tutu')\r", 1)
|
||||
print("\ntoto10241\n")
|
||||
while True:
|
||||
char = transport.read(1)
|
||||
#print("toto1400: ." + char + ".")
|
||||
if char == '' or char == chr(62): # '' or '>'
|
||||
#if char == chr(62): # '>'
|
||||
print("\ntoto1017: ." + char + ".")
|
||||
|
||||
Reference in New Issue
Block a user