put and get file on ESP32

Issue #271 resolved
Wenjie Wu created an issue

With MicroBlocks.app 1.1.46 (Macos 12.3.1 M1), "put file on board" is works well, but "get file from board" does’t work:

The other/Files.ubl library seems to be missing dependency: filePrimes.ubl. When I show block definition on file names in directory block, I saw some undefined cyan blocks.

How to use file names in directory to list the files in the root directory(The directory "put file on board" works in by default)

Another question, the web IDE also contains "put file on board" and "get file from board" , Will they work in the future? It would be great if they could!

Comments (5)

  1. John Maloney repo owner

    What does the "file names" block with no arguments return? It should return a list of files at the top level, including "image1.bmp" and "image2.bmp" (which are obviously there since you can get their sizes).

    I'm guessing you'll get an empty list...

    The "put file on board" menu command works for me in all the stand-alone apps (Win10, MacOS, Linux). The "get file from board" is works for me all the stand-alone stand-alone apps AND in the Chrome browser.

    The board must be connected in order to get and put files. The "get files from board" should, after a few seconds, offer a list of files that can be fetched from the board.

    I am not sure why "get file from board" is not working for you. It is possible that something about the state of the file system is breaking the file name enumeration code in the MicroBlocks VM. If so, I would expect the "file names" block to return an empty list.

    You might try erasing all of Flash and re-initializing the file system using the "erase flash and update firmware on ESP board". Creating the file system takes several minutes but should eventually complete. When it is finished, connect to the board using the stand-alone app and put a small file with a name like "test.txt" (i.e. no Chinese characters) onto the board. Then try to get the file back. If those operations work, we can try to figure out what got the file system into a state that prevented file name enumeration. I'm guessing it might be something about the form of the file or directory names.

    The other/Files.ubl library seems to be missing dependency: filePrimes.ubl. When I show block definition on file names in directory block, I saw some undefined cyan blocks.

    That's intentional. We don't include primitive libraries in the dependency list because they are usually low-level operations that are not useful except to create higher-level library functions. The IDE is supposed to know the format of all primitives so it can render them correctly but in this case the file:startList primitive was missing so the block rendered in a strange way. Will fix.

    Another question, the web IDE also contains "put file on board" and "get file from board" , Will they work in the future?

    Yes, for sure. "get file from board" already works -- unless the file names cannot be enumerated, as it the case with your file system. I will make "put file one board" work in the browser soon.

  2. Wenjie Wu reporter

    Thank you for your analysis and advice!

    I had these problems in the morning, repeatedly plugging and unplugging ESP32 did not help, just now I tried again and everything was fine!

    I did not "erase flash and update firmware on ESP board". It is recovering on its own and I don't know why yet. It has been very stable now, the previous error may be because I did something wrong.

    What does the "file names" block with no arguments return? It should return a list of files at the top level

    This is intuitive design.

    Yes, for sure. "get file from board" already works -- unless the file names cannot be enumerated, as it the case with your file system. I will make "put file one board" work in the browser soon.

    Looking forward to it!

  3. John Maloney repo owner

    "Put file on board" now works in the browser. Be sure to refresh the page to get the latest version 1.1.47.

  4. Log in to comment