Current Lua downloadable firmware will be posted here

User avatar
By timg11
#77784 Deep in the NodeMCU Developer FAQ there is brief mention:
"For example, the standard io and os libraries don't work, but have been largely replaced by the NodeMCU node and file libraries."

But nowhere is it explained how to use file.write as an alternative for io.write.

A simple replacement of file.write for io.write yields:

Code: Select allPANIC: unprotected error in call to Lua API (calculateTime.lua:30: open a file first)


What file is to be opened to get the same serial console that is used by print()?
Where is this documented?
User avatar
By marcelstoer
#77788 Kudos for reading the FAQ.

I suggest you first consult the respective module documentation, https://nodemcu.readthedocs.io/en/lates ... ules/file/ in this case, before you just blindly execute functions.

I'm not sure I understand your other question(s) but it's explained here https://nodemcu.readthedocs.io/en/lates ... ules/uart/
User avatar
By timg11
#77801 Regular (non-NodeMCU) Lua offers io.write as a mechanism to provide more "direct" output to STDOUT than Print.

But, io doesn't exist in NodeMCU.

I want to use file.write, but need to know what file to open to emulate the behavior of Print and io.write in non-NodeMCU Lua.

Is STDOUT a file? I don't find it in the [url=https://nodemcu.readthedocs.io/en/latest/en/modules/file/
]NodeMCU docs[/url] for file.

I've searched elsewhere, and have not been successful in finding the NodeMCU equivalent to the STDOUT file.