4refr0nt / luatool Goto Github PK
View Code? Open in Web Editor NEWSmall python script for loading init.lua to ESP8266 nodemcu firmware
Home Page: http://esp8266.ru/
License: GNU Lesser General Public License v3.0
Small python script for loading init.lua to ESP8266 nodemcu firmware
Home Page: http://esp8266.ru/
License: GNU Lesser General Public License v3.0
An upload appears to go ok, but the compile fails with:
ERRORTraceback (most recent call last):
File "./luat", line 298, in
transport.writeln("node.compile("" + args.dest + "")\r")
File "./luat", line 106, in writeln
self.performcheck(data)
File "./luat", line 73, in performcheck
sys.stdout.write("\r\n send string : '%s'" % data)
NameError: global name 'data' is not defined
While I'm aware that node.compile due to out of memory, this appears to be a code error?
around line 82, i will be larger than len(expected) and throw an IndexError if there's a compiler error message.
I hacked a change like this:
if i > len(expected): sys.stdout.write(char) elif char == chr(62) and expected[i] == char: char = ''
This is a feature request. As it stands, luatool works for text files. It would be great to have it work with binary files as well. As it stands, I'm not even sure nodemcu firmware provides the facilities to do this.
I know it's a simple command but being able to delete files from the command would be useful.
I successfully placed the board into 115200 baud, and luatool will then only connect at that rate, as I would expect. However, I was initially surprised to find that it made no difference to the upload speed. Is the python code (or error checking) a bottleneck here?
Not able to upload a program with the following line in it:
_, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP");
If I try to use luatool by creating a symlink to path/to/luatool/luatool.py
, then it can not find main.lua
file:
ceremcem@cca-erik:bin$ ls -l luatool.py
lrwxrwxrwx 1 ceremcem ceremcem 26 Mar 30 02:23 luatool.py -> luatool/luatool/luatool.py
I ran in an issue that my Prolific PL-2303/X USB UART adaptor was not responsive.
I appears under OSX 10.10.1 and Version V1.5.1 of the Prolific Driver.
A bugfix for me was to add an s.flush() before closing the serial connection.
Greetings Max
Hi,
First time using a nodemcu, so excuse me if I did this wrong. Host is OpenBSD, board is the new nodemcu amica.
$ sudo python2.7 luatool/luatool.py -p /dev/cuaU0
->file.open("main.lua", "w") -> ok
->file.close() -> ok
->file.remove("main.lua") -> ok
->file.open("main.lua", "w+")
ERROR
send string : 'file.open("main.lua", "w+")'
expected echo : 'file.open("main.lua", "w+")'
but got answer : ' file.open("main.lua", "w+")'
Traceback (most recent call last):
File "luatool/luatool.py", line 143, in <module>
writeln("file.open(\""+args.dest+"\", \"w+\")\r")
File "luatool/luatool.py", line 58, in writeln
raise Exception('Error sending data to MCU\r\n\r\n')
Exception: Error sending data to MCU
Looks like just an extra space was received.
is't already available with pip python install command ?
Please add an option to restart the module without an upload of a file.
Noticed a weird uploader behaviour..
second line in following lua script (even when commented) breaks the upload process:
DHT_PIN = 7
-- if current_buffer_length > 2 and is_valid_sequence == false then
LED_PIN=4
->file.writeline([==[DHT_PIN = 7]==]) -> ok
->file.writeline([==[-- if current_buffer_length > 2 and is_valid_sequence == false then]==])
->file.writeline([==[LED_PIN=4]==])
ERROR
send string : 'file.writeline([==[LED_PIN=4]==])'
expected echo : 'file.writeline([==[LED_PIN=4]==])'
but got answer : 'sequence == false then]==])'
Traceback (most recent call last):
File "./luatool.py", line 322, in <module>
transport.writer(line.strip())
File "./luatool.py", line 63, in writer
self.writeln("file.writeline([==[" + data + "]==])\r")
File "./luatool.py", line 122, in writeln
self.performcheck(data)
File "./luatool.py", line 89, in performcheck
raise Exception('Error sending data to MCU\r\n\r\n')
Exception: Error sending data to MCU
run command (first part is for syntax validation):
luac -p ~/mqtt.lua && ./luatool.py --port /dev/cu.wchusbserial1420 --src ~/mqtt.lua --dest mqtt.lua --baud 1200 --verbose
version mismatch issue!!!
root@kali:~# sudo python '/root/Desktop/luatool-master/luatool/luatool.py' --port /dev/ttyUSB0 --src '/root/Desktop/experimental/init.lua' --dest init.lua --verbose
Set timeout None
Set interCharTimeout None
Upload starting
Stage 1. Deleting old file from flash memory
->file.open("init.lua", "w")Traceback (most recent call last):
File "/root/Desktop/luatool-master/luatool/luatool.py", line 170, in
writeln("file.open("" + args.dest + "", "w")\r")
File "/root/Desktop/luatool-master/luatool/luatool.py", line 44, in writeln
raise Exception('No proper answer from MCU')
Exception: No proper answer from MCU
In a first use, lost some minutes figuring out this error... Thought it was some OS issue.
Traceback (most recent call last):
File "/usr/bin/luatool.py", line 192, in <module>
transport = decidetransport(args)
File "/usr/bin/luatool.py", line 168, in decidetransport
return SerialTransport(cliargs.port, cliargs.baud, cliargs.delay)
File "/usr/bin/luatool.py", line 97, in __init__
raise TransportError(e.strerror)
__main__.TransportError
Suggestion:
NO TTY: Please provide --port. Eg: /dev/ttyUSB*
PS.: A nice bet to detect tty is check for platform, linux: /dev/ttyUSB*
mac: /dev/tty.usbmodel*
Thanks for the gem!
PS2: Thank you for this, great tool!
The check in writeln
looks for '>' to detect a prompt (end of response). Unfortunately, it just takes the first '>' that appears instead of checking only the beginning of a new line. It doesn't seem to affect the written data, though.
Example output with this problem:
->file.writeline([==[handler["/"] = function(c, params)]==]) -> ok
->file.writeline([==[local buf = "<h1>ESP8266 Web Server</h1>"]==])
->file.writeline([==[buf = buf .. "<p>GPIO0 <a href=\"?gpio0=1\"><button>ON</button></a> <a href=\"?gpio0=0\"><button>OFF</button></a>"]==])
->file.writeline([==[buf = buf .. "<form action=\"\" method=\"GET\">"]==])
->file.writeline([==[buf = buf .. "<label>ON for (milliseconds)</label><input name=\"gpio0_time\" type=\"number\" min=\"100\" max=\"10000\" default=\"1000\"/>"]==])
->file.writeline([==[buf = buf .. "<input type=\"submit\"/></form></p>"]==])
->file.writeline([==[if params.gpio0 == "1" then]==]) -> ok
->file.writeline([==[gpio.write(gpio0, gpio.HIGH)]==]) -> ok
->file.writeline([==[elseif params.gpio0 == "0" then]==]) -> ok
Notice the missing -> ok
for the lines containing the '>' character.
Many thanks for adding upload via TCP. Unfortunately a triggered restart of the NodeMCU will cause the script to hang until the module is online again and then throw an exception.
->node.restart()Traceback (most recent call last):
File "./luatool.py", line 310, in <module>
transport.writeln("node.restart()\r")
File "./luatool.py", line 147, in writeln
self.performcheck(data)
File "./luatool.py", line 59, in performcheck
char = self.read(1)
File "./luatool.py", line 152, in read
return self.socket.recv(length)
socket.error: [Errno 104] Connection reset by peer
I invoke luatool from a script that only uploads files that have changed. I would like to be able to restart the my nodeMCU after the last file has been uploaded, no matter what it is.
I'm trying to upload a file to my ESP8266 with nodeMCU 0.9.5 (build 20150213) and luatool raises No proper answer from MCU
. I can connect to the ESP8266 via Stino's serial monitor and screen command. Any idea about what is happening?
Replace https://github.com/4refr0nt/luatool/blob/master/luatool/telnet_srv.lua with https://github.com/nodemcu/nodemcu-firmware/blob/dev/lua_examples/telnet.lua which works more reliable.
it is possible to read out lua files from the ESP8266? that would be nice, because so you can read log files without always sending print.readline() :)
Would it be faster to upload a multiline string, instead of one line at a time?
Hello I flashed my ESP8266 ESP-12E with NodeMCU by raspberry Pi 3 B. All was okay. On minicom -b 115200 -o -D /dev/ttyS0
I can normally connect but if I want to upload some files by exec command: python luatool.py --port /dev/ttyS0 --src init.lua --dest init.lua --verbose --baud 115200
then I get:
Stage 1. Deleting old file from flash memory
->file.open("init.lua", "w")Traceback (most recent call last):
File "luatool.py", line 272, in <module>
transport.writeln("file.open(\"" + args.dest + "\", \"w\")\r")
File "luatool.py", line 111, in writeln
self.performcheck(data)
File "luatool.py", line 61, in performcheck
raise Exception('No proper answer from MCU')
Exception: No proper answer from MCU
I have connect only RXD and TXD pins, when I'm connecting GPIO0 to GND and run it by baud 9600 its the same, please help me. When I try to the same on ESPlorer then I get double sending a command but not all command. Something like this:
print('TEST')
print('TES
Guys please help me!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.