How to use fopen in the extended module?

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
Mars_CN
Posts: 2
Joined: Tue Feb 15, 2022 7:00 am

How to use fopen in the extended module?

Post by Mars_CN » Mon Sep 05, 2022 12:37 pm

I'm writing my own module, which requires file operations. But when I write file * FP = fopen (file, "R") in the C code, the returned result is null, that is, the file does not exist. Is it because I don't have mount spiffs? But why can micropython itself read it? I use Python to execute OS Listdir () can read all the files in the directory.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: How to use fopen in the extended module?

Post by jimmo » Tue Sep 06, 2022 2:51 am

As per the message, please open new posts at GitHub discussions. https://github.com/orgs/micropython/discussions

MicroPython does not make the libc file methods available. If you want to access the filesystem you need to do it through MicroPython's VFS layer. See extmod/vfs.h

Post Reply