Current Lua downloadable firmware will be posted here

User avatar
By ank
#66246 1) When an SD card is mounted, it seems to be possible to use the following volume names
/SD0, /SD1, /SD2, /SD3 (default is /FLASH)
However successive volume names seem not to work if /SD0 is mounted. Therefore I stick to /SD0 as I use a single SD card.

2) /SD0: and /SD0 both work as the volume's names
However file access becomes different:
with the first option (/SD0:) one needs to use file.chdir("/SD0:") before accessing the SD card and cannot access files directly like file.open("/SD0/Hello.txt")
with the second option the long file name can be used without file.chdir
Therefore I use /SD0

3) useful reference information (in addition to compulsory https://nodemcu.readthedocs.io/en/maste ... ules/file/ and https://nodemcu.readthedocs.io/en/master/en/sdcard/ )
"SPIFFS doesn’t have the concept of folders, but accepts arbitrary characters in the filename, so you can create pseudo-folders just by adding slashes within the file’s name. Note that the maximum filename length is 32 characters, and extensions on the end of a filename do not have any special meaning (except for lua-specific files, like .lua and .lc). ...
There can only be one file open at a time, so there is no need to maintain a file handle between operations."
https://blog.falafel.com/working-with-f ... e-esp8266/
User avatar
By devsaurus
#66266 The error message for file.mount() indicates that you run a firmware that was built without FATFS support:
volume=file.mount("/SD0", 4)

stdin:1: attempt to call field 'mount' (a nil value)
stack traceback:
stdin:1: in main chunk

Please post the startup messages of your firmware?

Please post the output of the following code:

Code: Select allfor key,val in pairs(file) do
    print(key)
end
User avatar
By ank
#66280 Thnaks devsaurus,

there is a lag between posting and getting the post approved by the moderator. I fixed the issue by reformatting the SD card, and gave full account and releveant references with credits in that post.

I tried the code you have suggested, and it returned
list
open
close
write
writeline
read
readline
format
fscfg
remove
seek
flush
rename
exists
fsinfo
on
stat
mount
chdir

I did not know one can check what functions are included in a module this way, thank you.

1) However I am puzzzled of how to find that FAT FS was actually included in the build from the above output. It seems to me that all the modules listed above would work with FLASH just fine both with and without FAT FS.

2) Also, is there a way to find whether the buld supports the object model (i.e. the capability of opening multiple files at the time)? Of course one can try this feature end get error then it could be unclear whether it was a mistake when using the API or absence of the support in the firmware build.

3) side topic: I want to serve from the ESP not just plain HTML but a full suite of HTML, CSS, JS. My understanding is that the server will get HTTP requests for the additional files, and should serve these as usual. Do you know (or anticipate) any caveats on the way? I want the ESP to be able to act as an local AP without connecting to the Internet thus these files cannot be hosted elsewhere. I will start a new topic if you think doing this is not straightforward.

Thanks again
User avatar
By marcelstoer
#66299
ank wrote:1) However I am puzzzled of how to find that FAT FS was actually included in the build from the above output. It seems to me that all the modules listed above would work with FLASH just fine both with and without FAT FS.


If you use the cloud builder ("...ticked FAT FS..." suggests you do) the firmware will print a list of included modules and whether SSL was enabled upon start, that's all.
However, the `mount` and `chdir` functions are only included in the binary if FAT FS support was enabled: https://github.com/nodemcu/nodemcu-firm ... ile.c#L631 (also at https://nodemcu.readthedocs.io/en/lates ... #filechdir)

ank wrote:2) Also, is there a way to find whether the buld supports the object model (i.e. the capability of opening multiple files at the time)? Of course one can try this feature end get error then it could be unclear whether it was a mistake when using the API or absence of the support in the firmware build.


As the functions are the same, see e.g. https://nodemcu.readthedocs.io/en/lates ... /#fileopen, I don't think that's possible.

ank wrote:3) side topic: I want to serve from the ESP not just plain HTML but a full suite of HTML, CSS, JS. My understanding is that the server will get HTTP requests for the additional files, and should serve these as usual. Do you know (or anticipate) any caveats on the way?


If you need a full HTTP server I suggest you don't implement that from scratch yourself but use an existing solution instead. The one from Marcos Kirsch is pretty popular and well maintained: https://github.com/marcoskirsch/nodemcu-httpserver