AndiDittrich / NodeMCU-Tool

:wrench: Upload + Manage Lua files on NodeMCU
https://www.npmjs.com/package/nodemcu-tool
MIT License
310 stars 54 forks source link

Lua file functions moved to standard io module #89

Open juju2143 opened 2 years ago

juju2143 commented 2 years ago

Checklist

  1. Can you establish a serial connection WITHOUT Nodemcu-Tool - e.g. with a serial terminal like Putty ?
    yes

  2. Does the nodemcu-tool fsinfo command work ?
    yes


Environment

Issue Description

Expected Behavior

You can upload files

Current Behavior

You can't upload files

Steps to Reproduce

nodemcu-tool upload something.lua

Detailed Description

The above command works, yet the file does not show up in the filesystem. This is because NodeMCU in the latest dev-esp32 branches moved file IO from the file module to the standard Lua io. The commands fails silently as if it worked, even though file.open is unavailable and returns nil.

Possible Solution

I have modified lib/lua/esp8266-commands.js to use io instead of file and so far it works very well, but of course we'll need some additional code to detect whether file or io is to be used so it works as usual on an ESP8266.

This took a while to figure out from the documentation even though the ESP32 is very unsupported, has preliminary support, the maintainers of this repo might not have an ESP32 to test on, and a casual user might think their ESP32 is broken, it's not, here's the solution :)

serg3295 commented 1 year ago

but of course we'll need some additional code to detect whether file or io is to be used so it works as usual on an ESP8266.

I have added --io-module flag in cli to allow to choose whether io or file module is to be used. The branch dev-esp32 The following pull requests also have been applied:

fix: upgrade prompt dep to fix non-existent property warning

Upgrade node-serialport dependency to v10 (Breaking Change)

Lua file functions moved to standard io module