diff --git a/IDE_remote/SocketIDE/atom_plugin/test1/initz - copie.lua b/IDE_remote/SocketIDE/atom_plugin/test1/initz - copie.lua deleted file mode 100644 index 70c66fb..0000000 --- a/IDE_remote/SocketIDE/atom_plugin/test1/initz - copie.lua +++ /dev/null @@ -1,73 +0,0 @@ ---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 diff --git a/IDE_remote/SocketIDE/atom_plugin/test1/luatool.py b/IDE_remote/SocketIDE/atom_plugin/test1/luatool.py index 286e43e..9781932 100755 --- a/IDE_remote/SocketIDE/atom_plugin/test1/luatool.py +++ b/IDE_remote/SocketIDE/atom_plugin/test1/luatool.py @@ -1,6 +1,6 @@ #!/usr/bin/env python2 # -*- coding: utf-8 -*- -version = "0.6.5 zf191021.1543" +version = "0.6.5 zf191021.1558" print("luatool.py ver " + version) diff --git a/IDE_remote/SocketIDE/atom_plugin/test1/toto.lua b/IDE_remote/SocketIDE/atom_plugin/test1/toto.lua deleted file mode 100644 index 434de1f..0000000 --- a/IDE_remote/SocketIDE/atom_plugin/test1/toto.lua +++ /dev/null @@ -1,26 +0,0 @@ -print("c'est toto") - ---l = file.list();for k,v in pairs(l) do print('name:'..k..', size:'..v)end - -function dir2() - l = file.list();for k,v in pairs(l) do print('name:'..k..', size:'..v)end -end - - - -function dir() - print("\n-------------------------------") - l=file.list() i=0 - for k,v in pairs(l) do - i=i+v - print(k..string.rep(" ",19-string.len(k)).." : "..v.." bytes") - end - print("-------------------------------") - print('\nUsed: '..i..' bytes\nusage: dofile("file.lua")\n') -end - ---[[ -dir() -dir2() - -]] \ No newline at end of file diff --git a/IDE_remote/SocketIDE/atom_plugin/test1/upload.sh b/IDE_remote/SocketIDE/atom_plugin/test1/upload.sh index 9601adb..5b96229 100755 --- a/IDE_remote/SocketIDE/atom_plugin/test1/upload.sh +++ b/IDE_remote/SocketIDE/atom_plugin/test1/upload.sh @@ -1,11 +1,11 @@ #!/bin/bash # Petit script pour télécharger facilement tout le binz -#zf191021.1555 +#zf191021.1608 # S'il y a des erreurs lors d'un téléchargement, il faut simplement augmenter un peu le délai ! # Il est préférable de télécharger en premier les *gros* fichiers .lua ! -#ATTENTION: cela efface tout le NodeMCU ! +# ATTENTION: cela efface tout le NodeMCU ! luatool_tty="/dev/cu.wchusbserial1410" @@ -28,6 +28,6 @@ read -p "Est-ce bien vide ?" ./luatool.py --port /dev/cu.wchusbserial1410 --bar --delay 0.001 -f wifi_info.lua ./luatool.py --port $luatool_tty -l -read -p "Pas eu d'erreur, on redémarre et part à fond ?" +read -p "Pas eu d'erreur, on part à fond avec le init.lua ?" ./luatool.py --port $luatool_tty --bar --delay 0.001 -f initz.lua -t init.lua echo -e "\nC'est tout bon ;-)" diff --git a/IDE_remote/SocketIDE/luatool/luatool.py b/IDE_remote/SocketIDE/luatool/luatool.py index 6cd1e40..9781932 100755 --- a/IDE_remote/SocketIDE/luatool/luatool.py +++ b/IDE_remote/SocketIDE/luatool/luatool.py @@ -1,6 +1,6 @@ #!/usr/bin/env python2 # -*- coding: utf-8 -*- -version = "0.6.5 zf191020.2041" +version = "0.6.5 zf191021.1558" print("luatool.py ver " + version) @@ -81,6 +81,10 @@ class AbstractTransport: if char == chr(13) or char == chr(10): # LF or CR if line != '': line = line.strip() + # zzz191021 Affiche ce que l'on a reçu du NodeMCU + if args.verbose: + print("\n\nzread0957: {" + line + "\n}\n") + if line+'\r' == expected and not args.bar: sys.stdout.write(" -> ok") elif line+'\r' != expected: @@ -118,12 +122,22 @@ 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 - sleep(0.5) + # 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("line: ." + line + ".") def writeln(self, data, check=1): - # zzz191020 une petite pause après l'envoi de chaque ligne + # zzz191020 on fait une petite pause avant l'envoi de chaque ligne sleep(self.delay) if self.serial.inWaiting() > 0: self.serial.flushInput() @@ -131,6 +145,9 @@ class SerialTransport(AbstractTransport): sys.stdout.write("\r\n->") sys.stdout.write(data.split("\r")[0]) self.serial.write(data) + # zzz191021 Affiche ce que l'on a envoyé au NodeMCU + if args.verbose: + print("\n\nzwrite0952: {" + data + "\n}\n") if check > 0: self.performcheck(data) elif not args.bar: @@ -228,7 +245,7 @@ if __name__ == '__main__': transport.writeln("print('\\n-----');local l = file.list();for k,v in pairs(l) do print(k..', size:'..v)end;print('-----\\n')\r", 0) while True: char = transport.read(1) - if char == '' or char == chr(62): + if char == '' or char == chr(62): # '' or '>' break sys.stdout.write(char) sys.exit(0) @@ -276,7 +293,7 @@ if __name__ == '__main__': if args.dest is None: args.dest = basename(args.src) - ### zzz191020 Affiche le fichier à envoyer + # zzz191020 Affiche le fichier à envoyer print("File: " + args.src) # open source file for reading diff --git a/IDE_remote/SocketIDE/luatool/upload.sh b/IDE_remote/SocketIDE/luatool/upload.sh index 00ac797..5e1235a 100755 --- a/IDE_remote/SocketIDE/luatool/upload.sh +++ b/IDE_remote/SocketIDE/luatool/upload.sh @@ -1,30 +1,34 @@ #!/bin/bash # Petit script pour télécharger facilement tout le binz -#zf191021.0844 +#zf191021.1606 # S'il y a des erreurs lors d'un téléchargement, il faut simplement augmenter un peu le délai ! # Il est préférable de télécharger en premier les *gros* fichiers .lua ! -#ATTENTION: cela efface tout le NodeMCU ! +# ATTENTION: cela efface tout le NodeMCU ! + +luatool_tty="/dev/cu.wchusbserial1410" read -p "ATTENTION, cela va effacer tout le NodeMCU !" read -p "Etes-vous vraiment certain ?" chmod +x luatool.py -./luatool.py --port /dev/cu.wchusbserial1410 --zrestart -sleep 0.5 -./luatool.py --port /dev/cu.wchusbserial1410 -w -./luatool.py --port /dev/cu.wchusbserial1410 -l -./luatool.py --port /dev/cu.wchusbserial1410 --bar --delay 0.06 --src telnet_srv2.lua -./luatool.py --port /dev/cu.wchusbserial1410 --bar --delay 0.001 --src boot.lua -./luatool.py --port /dev/cu.wchusbserial1410 --bar --delay 0.001 --src boot2.lua -./luatool.py --port /dev/cu.wchusbserial1410 --bar --delay 0.03 --src flash_led_xfois.lua -./luatool.py --port /dev/cu.wchusbserial1410 --bar --delay 0.001 --src secrets_energy.lua -./luatool.py --port /dev/cu.wchusbserial1410 --bar --delay 0.001 --src wifi_ap_stop.lua -./luatool.py --port /dev/cu.wchusbserial1410 --bar --delay 0.001 --src wifi_cli_conf.lua -./luatool.py --port /dev/cu.wchusbserial1410 --bar --delay 0.001 --src wifi_cli_start.lua -./luatool.py --port /dev/cu.wchusbserial1410 --bar --delay 0.001 --src wifi_info.lua -./luatool.py --port /dev/cu.wchusbserial1410 --bar --delay 0.001 --src initz.lua --dest init.lua -./luatool.py --port /dev/cu.wchusbserial1410 -l -./luatool.py --port /dev/cu.wchusbserial1410 --zrestart +./luatool.py --port $luatool_tty -w +./luatool.py --port $luatool_tty -l +read -p "Est-ce bien vide ?" + +./luatool.py --port $luatool_tty --bar --delay 0.06 -f telnet_srv2.lua +./luatool.py --port $luatool_tty --bar --delay 0.001 -f boot.lua +./luatool.py --port $luatool_tty --bar --delay 0.001 -f boot2.lua +./luatool.py --port $luatool_tty --bar --delay 0.03 -f flash_led_xfois.lua +./luatool.py --port $luatool_tty --bar --delay 0.001 -f secrets_energy.lua +./luatool.py --port $luatool_tty --bar --delay 0.001 -f wifi_ap_stop.lua +./luatool.py --port $luatool_tty --bar --delay 0.001 -f wifi_cli_conf.lua +./luatool.py --port $luatool_tty --bar --delay 0.001 -f wifi_cli_start.lua +./luatool.py --port $luatool_tty --bar --delay 0.001 -f wifi_info.lua + +./luatool.py --port $luatool_tty -l +read -p "Pas eu d'erreur, on part à fond avec le init.lua ?" +./luatool.py --port $luatool_tty --bar --delay 0.001 -f initz.lua -t init.lua +echo -e "\nC'est tout bon ;-)"