What is the safest option for reading and writing the configuration file? I am afraid that when saving, for example, if there was no power, the file might not be saved completely ...
The next thing is the format ... Maybe json?
Config file, read or write - safety.
Re: Config file, read or write - safety.
The two things to ensure:
- Use LittleFS rather than FAT
- Don't overwrite the in-use file, write a new file, then delete the old one. Detect the correct one to use at startup.
JSON is good because there's built-in support and working with dictionaries is easy. The other common option is to write it as a Python file, then you can just import the file directly.
Re: Config file, read or write - safety.
Thanks ! one more question... why littlefs ?
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: Config file, read or write - safety.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode