{"id":13648333,"url":"https://github.com/4refr0nt/luatool","last_synced_at":"2025-04-06T10:13:38.976Z","repository":{"id":23533084,"uuid":"26899794","full_name":"4refr0nt/luatool","owner":"4refr0nt","description":"Small python script for loading init.lua to ESP8266 nodemcu firmware","archived":false,"fork":false,"pushed_at":"2019-09-02T17:31:26.000Z","size":70,"stargazers_count":312,"open_issues_count":18,"forks_count":96,"subscribers_count":39,"default_branch":"master","last_synced_at":"2025-03-30T09:07:30.775Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://esp8266.ru/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/4refr0nt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-20T06:50:20.000Z","updated_at":"2025-02-18T23:23:24.000Z","dependencies_parsed_at":"2022-07-25T13:32:21.792Z","dependency_job_id":null,"html_url":"https://github.com/4refr0nt/luatool","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4refr0nt%2Fluatool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4refr0nt%2Fluatool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4refr0nt%2Fluatool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/4refr0nt%2Fluatool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/4refr0nt","download_url":"https://codeload.github.com/4refr0nt/luatool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247464224,"owners_count":20942970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T01:04:09.020Z","updated_at":"2025-04-06T10:13:38.949Z","avatar_url":"https://github.com/4refr0nt.png","language":"Python","readme":"# **luatool** #\n\n[![Join the chat at https://gitter.im/4refr0nt/luatool](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/4refr0nt/luatool?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n### Tool for loading Lua-based scripts from file to ESP8266 with nodemcu firmware\n\n### Summary\n\n- Allow easy uploading of any Lua-based script into the ESP8266 flash memory with [NodeMcu firmware](https://github.com/nodemcu/nodemcu-firmware)\n\n### Other projects\nAnother my project for NodeMCU: ESPlorer  Integrated Development Environment (IDE) for ESP8266 developers\n- [ESPlorer home page and latest binaries](http://esp8266.ru/esplorer/)\n- [ESPlorer source code](https://github.com/4refr0nt/ESPlorer)\n\n### Requirements\n\npython 2.7, pyserial (as for esptool)\n\n### Discuss\n[http://esp8266.ru](http://esp8266.ru/forum/threads/luatool.11/)\n\n\n### Changelog\nv0.6.4\n- add TCP as possible transport to connect to the module using the supplied telnet server code\n- add --id/-i to query the ID of a module\n- add --delete to remove a given file from the module\n \nv0.6.3\n- fix download bug\n \nv0.6.2\n- added support for nested strings\n- added check to verify the UART buffer will not overflow.\n\nv0.6.1\n- put short versions of arguments back, see issue #2\n- flush serial port, fixes issue #1\n\nv0.6\n- switched to argparse from getopts, renamed some arguments\n- removed call-home from main.lua\n- added --verbose option to show debugging\n- added comments, fixed some grammar, updated README\n- chmod 755'd the script so its runnable on POSIX\n- checked with nodemcu 0.9.4 20141222\n\nv0.5\n- add new option  -r, --restart : auto restart module, send command \"node.restart()\", after file load \n- add new option  -d, --dofile  : auto run, send command \"dofile('file')\", after file load \n- delete line \"lua script loaded by luatool\" for correct line number, lines number now equal lines number in original file\n- add 0.3 sec delay after write\n\n\nv0.4\n- now check proper answer from NodeMCU after send data.\n  After send string we expect echo line, if not got it, then error message displayed \"Error sending data to LuaMCU\"\n- if lua interpreter error received, then error message displayed \"ERROR from LUA interpreter lua:...\"\n- add heap info and chip id to example file init.lua\n- some changes in example file main.lua\n\n\n### Run\n\n#### Typical use:\n\n\nEdit file init.lua and set SSID and MasterPassword\nThen disconnect any terminal programm, and at command prompt type\n\n```\n./luatool.py --port /dev/ttyUSB0 --src init.lua --dest init.lua --verbose\n\nDownloader start\nSet timeout 3\nSet interCharTimeout 3\nStage 1. Deleting old file from flash memory\n-\u003efile.remove(\"init.lua\") -\u003e ok\n.....................................\n-\u003efile.close() -\u003e ok\n---\u003e\u003e\u003e All done \u003c\u003c\u003c---\n\n./luatool.py\n\n-\u003efile.open(\"main.lua\", \"w\") -\u003e ok\n-\u003efile.close() -\u003e ok\n-\u003efile.remove(\"main.lua\") -\u003e ok\n-\u003efile.open(\"main.lua\", \"w+\") -\u003e ok\n-\u003efile.writeline([[tmr.alarm(0, 1000, 1, function()]]) -\u003e ok\n-\u003efile.writeline([[if wifi.sta.getip() == nil then]]) -\u003e ok\n-\u003efile.writeline([[print(\"Connecting to AP...\")]]) -\u003e ok\n-\u003efile.writeline([[else]]) -\u003e ok\n-\u003efile.writeline([[print('IP: ',wifi.sta.getip())]]) -\u003e ok\n-\u003efile.writeline([[tmr.stop(0)]]) -\u003e ok\n-\u003efile.writeline([[end]]) -\u003e ok\n-\u003efile.writeline([[end)]]) -\u003e ok\n-\u003efile.flush() -\u003e ok\n-\u003efile.close() -\u003e ok\n---\u003e\u003e\u003e All done \u003c\u003c\u003c---\n```\nConnect you terminal program and send command (or you can use --restart option, when loading file init.lua)\n```\nnode.restart()\n```\nafter reboot:\n```\nlua script loaded by luatool 0.4\ninit.lua ver 1.2\nset mode=STATION (mode=1)\nMAC: \t18-FE-34-98-D4-B5\nchip: \t10015925\nheap: \t18464\nset wifi\nNodeMcu 0.9.2 build 20141125  powered by Lua 5.1.4\n```\n\nsend command (or you can use --dofile option, when loading file main.lua)\n```\ndofile(\"main.lua\")\n```\nconnects to your AP and displays MCU's IP address\n\n```\n\u003e dofile(\"main.lua\")\n\u003e IP:   192.168.1.99\n\n```\n\n#### Examples:\n\n```\n./luatool.py --port COM4 --src file.lua --dest main.lua --baud 9600\n```\n- --port - COM1-COM128, default /dev/ttyUSB0\n- --baud - baud rate, default 9600\n- --src - source disk file, default main.lua\n- --dest - destination flash file, default main.lua\n\nIf use --dest option with parameter \"init.lua\" - autostart init.lua after boot.\nBe carefully about bugs in lua-script - may cause a boot loop. Use this option after full testing only.\n\nRunning without any parameters: load file \"main.lua\" via port /dev/ttyUSB0:9600 and place code into \"main.lua\" file into flash.\n\n```\n./luatool.py\n```\n\nafter loading file to flash you can connect any terminal programm to ESP8266 and type: \n```\ndofile(\"main.lua\") \n```\nfor executing you lua script\n\nIf you want load and autoexecute file main.lua, command dofile(\"main.lua\"), you can use --dofile option\n```\n./luatool.py --dofile\n```\nTypically, place wifi.setmode, wifi.sta.config commands to init.lua file for connecting to you AP with low risk of boot loop, and other code place to main.lua for manually start and debug.\n\n#### Alternative use:\n\nThis requires a nodemcu based module already configured to meet the following conditions:\n\n- the module is accessible via TCP/IP \n- the telnet server (file: **telnet_srv.lua**) is running \n\nNow the option **--ip IP[:PORT]** enables you to specify an IP and optionally a port (if changed for the telnet server)\nthat will be used to communicate with the module via TCP/IP.\n\n#### Examples:\n\n```\n./luatool.py --ip 192.168.12.34 --src file.lua --dest test.lua --dofile \n```\n\n- --ip - the IP to connect to. Note that no Port is given, so 23 will be used (can be changed in **telnet_srv.lua**)\n- --src - source disk file, default main.lua\n- --dest - destination flash file, default main.lua\n- --dofile - run the just uploaded file\n\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4refr0nt%2Fluatool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F4refr0nt%2Fluatool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F4refr0nt%2Fluatool/lists"}